/* ============================================================
   DSA Portal — Premium staff UI
   Midnight ink + champagne gold. Mobile-first.
   ============================================================ */

:root {
  --ink:        #0c1230;
  --ink-2:      #161f4d;
  --brand:      #2b3aa8;
  --brand-soft: #eceefb;
  --gold:       #c9a24a;
  --gold-deep:  #a8822c;
  --gold-soft:  #f7efdb;
  --canvas:     #f3f4f9;
  --surface:    #ffffff;
  --text:       #141a38;
  --muted:      #6a7292;
  --line:       #e5e8f1;
  --danger:     #c0352e;
  --danger-soft:#fdeceb;
  --ok:         #0e8a5f;
  --ok-soft:    #e3f5ee;
  --warn:       #a8680f;
  --warn-soft:  #fbf0dc;
  --radius:     16px;
  --shadow-sm:  0 1px 2px rgba(12,18,48,.06), 0 2px 8px rgba(12,18,48,.05);
  --shadow-md:  0 10px 30px rgba(12,18,48,.12);
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--canvas);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

.ico { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(900px 500px at 50% -10%, #25307a 0%, transparent 60%),
    var(--ink);
  color: #fff;
}

.login-mark {
  width: 56px; height: 56px;
  border-radius: 18px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--gold), var(--gold-deep));
  color: var(--ink);
  margin-bottom: 1.1rem;
  box-shadow: 0 10px 30px rgba(201,162,74,.35);
}
.login-mark .ico { width: 28px; height: 28px; stroke-width: 2; }

.login-title { font-size: 1.6rem; font-weight: 800; letter-spacing: -.5px; }
.login-sub   { color: rgba(255,255,255,.62); font-size: .9rem; margin: .3rem 0 1.75rem; }

.login-card {
  width: 100%;
  max-width: 330px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 26px;
  padding: 1.75rem 1.4rem 1.5rem;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.pin-display { display: flex; justify-content: center; gap: 16px; margin-bottom: 1.6rem; }

.pin-dot {
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35);
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.pin-dot.filled { background: var(--gold); border-color: var(--gold); transform: scale(1.18); }

.pin-keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; }

.key-btn {
  aspect-ratio: 1.25;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px;
  background: rgba(255,255,255,.07);
  color: #fff;
  font-size: 1.45rem;
  font-weight: 600;
  cursor: pointer;
  display: grid; place-items: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s ease, transform .12s ease;
}
.key-btn:active { transform: scale(.94); background: rgba(255,255,255,.18); }
.key-btn.is-ghost { background: transparent; border-color: transparent; color: rgba(255,255,255,.7); font-size: 1.15rem; }
.key-btn.is-go { background: var(--gold); border-color: var(--gold); color: var(--ink); font-weight: 800; }
.key-btn.is-go:active { background: var(--gold-deep); }
.key-btn:disabled { opacity: .6; }

.pin-error { text-align: center; color: #ffb4ae; font-size: .85rem; margin-top: .9rem; min-height: 1.3em; }

.admin-link {
  margin-top: 1.75rem;
  color: rgba(255,255,255,.45);
  font-size: .78rem;
  font-weight: 600;
}
.admin-link:hover { color: rgba(255,255,255,.8); }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(9px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

/* ============================================================
   TOP BAR + HERO
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 60;
  background: var(--ink);
  color: #fff;
  padding: .7rem 1rem;
  padding-top: calc(.7rem + env(safe-area-inset-top, 0px));
  display: flex; align-items: center; justify-content: space-between;
}

.who { display: flex; align-items: center; gap: .7rem; min-width: 0; }

.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 800; font-size: .95rem;
  background: var(--ink-2);
  color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold);
  flex-shrink: 0;
}

.who-name { font-weight: 700; font-size: .95rem; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-role { font-size: .72rem; color: rgba(255,255,255,.55); }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
}
.icon-btn:hover { background: rgba(255,255,255,.14); }

.hero {
  background: var(--ink);
  color: #fff;
  padding: .35rem 1rem 3.6rem;
}
.hero-inner { max-width: 720px; margin: 0 auto; }
.hero h1 { font-size: 1.45rem; font-weight: 800; letter-spacing: -.4px; line-height: 1.2; }
.hero p  { color: rgba(255,255,255,.6); font-size: .85rem; margin-top: .2rem; }

.wrap { max-width: 720px; margin: 0 auto; padding: 0 1rem 7rem; }

.stats {
  margin-top: -2.6rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  display: grid; grid-template-columns: repeat(3, 1fr);
  position: relative;
}
.stat { padding: .95rem .5rem; text-align: center; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat-num { font-size: 1.55rem; font-weight: 800; letter-spacing: -.5px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-lbl { font-size: .74rem; color: var(--muted); font-weight: 600; margin-top: .15rem; }
.stat.is-gold .stat-num { color: var(--gold-deep); }

/* ============================================================
   SEARCH + FILTER CHIPS
   ============================================================ */
.searchbar { position: relative; margin-top: 1rem; }
.searchbar .ico { position: absolute; left: .95rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.searchbar input {
  width: 100%;
  height: 48px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 0 1rem 0 2.75rem;
  font: inherit; font-size: .95rem; color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.searchbar input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(43,58,168,.1); }

.chips {
  display: flex; gap: .45rem;
  overflow-x: auto;
  padding: .85rem 1rem .25rem;
  margin: 0 -1rem;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: .38rem .85rem;
  font-size: .8rem; font-weight: 700;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: .4rem;
}
.chip b { font-weight: 800; font-variant-numeric: tabular-nums; }
.chip.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.is-on b { color: var(--gold); }

.list-head { display: flex; align-items: baseline; justify-content: space-between; margin: 1rem .15rem .6rem; }
.list-head h2 { font-size: 1rem; font-weight: 800; }
.list-head span { font-size: .78rem; color: var(--muted); font-weight: 600; }

/* ============================================================
   CASE CARD
   ============================================================ */
.case {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: .8rem;
  overflow: hidden;
  border: 1px solid transparent;
}
.case.is-gone { display: none; }

.case-top { display: flex; gap: .8rem; padding: .95rem 1rem .6rem; align-items: flex-start; }

.case-av {
  width: 42px; height: 42px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 1rem;
  background: var(--brand-soft); color: var(--brand);
  flex-shrink: 0;
}

.case-id { flex: 1; min-width: 0; }
.case-name { font-weight: 800; font-size: 1rem; line-height: 1.25; overflow-wrap: anywhere; }
.case-mob  { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: .1rem; }

.pill {
  flex-shrink: 0;
  border-radius: 999px;
  padding: .22rem .65rem;
  font-size: .72rem; font-weight: 800;
  background: var(--brand-soft); color: var(--brand);
  white-space: nowrap;
}
.st-pending    { background: var(--warn-soft);   color: var(--warn); }
.st-on-hold    { background: #eceef4;            color: #555d7a; }
.st-processing { background: var(--brand-soft);  color: var(--brand); }
.st-approved   { background: var(--ok-soft);     color: var(--ok); }
.st-disbursed  { background: #dff3f4;            color: #0a6f78; }
.st-rejected   { background: var(--danger-soft); color: var(--danger); }
.st-cancelled  { background: #f1e9ea;            color: #8a4a52; }

.case-tags { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 1rem .2rem 4.4rem; }
.tag {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .76rem; font-weight: 700;
  background: var(--canvas); color: var(--text);
  border-radius: 8px; padding: .22rem .55rem;
}
.tag .ico { width: 13px; height: 13px; color: var(--muted); }
.tag.is-gold { background: var(--gold-soft); color: #7a5a14; }
.tag.is-gold .ico { color: var(--gold-deep); }

.case-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: .65rem 1rem;
  padding: .75rem 1rem .8rem;
  margin-top: .55rem;
  border-top: 1px dashed var(--line);
}
.kv { min-width: 0; }
.kv dt { font-size: .7rem; color: var(--muted); font-weight: 700; }
.kv dd { font-size: .85rem; font-weight: 600; overflow-wrap: anywhere; }

.case-notes { border-top: 1px dashed var(--line); padding: 0 1rem; }
.case-notes summary {
  list-style: none; cursor: pointer;
  padding: .6rem 0;
  font-size: .8rem; font-weight: 700; color: var(--brand);
  display: flex; align-items: center; justify-content: space-between;
}
.case-notes summary::-webkit-details-marker { display: none; }
.case-notes summary .ico { width: 15px; height: 15px; transition: transform .2s; }
.case-notes[open] summary .ico { transform: rotate(180deg); }
.note-block { padding-bottom: .7rem; }
.note-block h4 { font-size: .7rem; color: var(--muted); font-weight: 700; }
.note-block p { font-size: .86rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-block + .note-block { margin-top: .5rem; }

.case-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: .55rem .75rem .55rem 1rem;
  background: #fafbfd;
  border-top: 1px solid var(--line);
}
.case-when { font-size: .76rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.case-actions { display: flex; gap: .35rem; }

.act {
  height: 36px; min-width: 36px;
  padding: 0 .65rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: .8rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  cursor: pointer;
}
.act:hover { background: var(--canvas); }
.act.is-call { color: var(--ok); }
.act.is-del  { color: var(--danger); }
.act.is-del:hover { background: var(--danger-soft); border-color: #f5c6c3; }

.empty {
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2.75rem 1.5rem;
  box-shadow: var(--shadow-sm);
}
.empty-mark { width: 64px; height: 64px; margin: 0 auto 1rem; border-radius: 20px; background: var(--gold-soft); color: var(--gold-deep); display: grid; place-items: center; }
.empty-mark .ico { width: 30px; height: 30px; }
.empty h3 { font-size: 1.05rem; font-weight: 800; }
.empty p  { color: var(--muted); font-size: .88rem; margin-top: .3rem; }
#noMatch { display: none; }

/* ============================================================
   FLOATING BUTTON
   ============================================================ */
.fab {
  position: fixed;
  right: 1.1rem;
  bottom: calc(1.2rem + env(safe-area-inset-bottom, 0px));
  z-index: 70;
  height: 54px;
  padding: 0 1.35rem 0 1.1rem;
  border-radius: 18px;
  border: none;
  background: var(--ink);
  color: #fff;
  font-size: .95rem; font-weight: 800;
  display: inline-flex; align-items: center; gap: .55rem;
  box-shadow: 0 12px 28px rgba(12,18,48,.35);
  cursor: pointer;
}
.fab .ico { width: 20px; height: 20px; color: var(--gold); stroke-width: 2.4; }
.fab:active { transform: scale(.96); }

/* ============================================================
   BOTTOM SHEET
   ============================================================ */
.backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(12,18,48,.55);
  display: none;
  align-items: flex-end; justify-content: center;
}
.backdrop.open { display: flex; }

.sheet {
  background: var(--surface);
  width: 100%; max-width: 640px;
  max-height: 94vh; max-height: 94dvh;
  border-radius: 24px 24px 0 0;
  display: flex; flex-direction: column;
  animation: rise .26s cubic-bezier(.2,.8,.2,1);
}
@keyframes rise { from { transform: translateY(60px); opacity: .4; } to { transform: none; opacity: 1; } }

.sheet-head { padding: .75rem 1.1rem .7rem; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.grab { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto .75rem; }
.sheet-title-row { display: flex; align-items: center; justify-content: space-between; }
.sheet-title { font-size: 1.1rem; font-weight: 800; }
.sheet-close {
  width: 34px; height: 34px; border-radius: 10px;
  border: none; background: var(--canvas); color: var(--text);
  display: grid; place-items: center; cursor: pointer;
}

.sheet-body { padding: .4rem 1.1rem 1rem; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }

.sheet-foot {
  padding: .8rem 1.1rem;
  padding-bottom: calc(.8rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  display: flex; gap: .6rem;
  flex-shrink: 0;
  background: var(--surface);
}

.btn {
  height: 50px;
  border-radius: 14px;
  border: none;
  font-size: .95rem; font-weight: 800;
  padding: 0 1.3rem;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
}
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--ink); color: #fff; flex: 1; }
.btn-primary .ico { color: var(--gold); }
.btn-ghost   { background: var(--canvas); color: var(--text); }
.btn-danger  { background: var(--danger); color: #fff; flex: 1; }

.fsec { margin-top: 1.1rem; }
.fsec-title {
  font-size: .82rem; font-weight: 800; color: var(--brand);
  display: flex; align-items: center; gap: .5rem;
  margin-bottom: .6rem;
}
.fsec-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.fgrid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: .76rem; font-weight: 700; color: var(--muted); margin-bottom: .3rem; }
.field label i { color: var(--danger); font-style: normal; }

.input {
  width: 100%;
  height: 46px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 0 .85rem;
  font: inherit; font-size: .95rem; color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
textarea.input { height: auto; min-height: 76px; padding: .65rem .85rem; resize: vertical; }
select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236a7292' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .8rem center;
  padding-right: 2.2rem;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(43,58,168,.1); }
.input.is-bad { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(192,53,46,.08); }

/* duplicate / error banner inside the sheet */
.note {
  display: none;
  gap: .6rem;
  align-items: flex-start;
  border-radius: 12px;
  padding: .7rem .85rem;
  margin-top: .8rem;
  font-size: .84rem; font-weight: 600;
}
.note.show { display: flex; }
.note .ico { margin-top: 2px; }
.note-danger { background: var(--danger-soft); color: #8f251f; }
.note-warn   { background: var(--warn-soft);   color: #7a4a08; }

/* searchable bank list */
.combo { position: relative; }
.combo-list {
  display: none;
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  max-height: 210px; overflow-y: auto;
  z-index: 20;
}
.combo-list.show { display: block; }
.combo-opt { padding: .65rem .85rem; font-size: .9rem; font-weight: 600; cursor: pointer; border-bottom: 1px solid var(--canvas); }
.combo-opt:last-child { border-bottom: none; }
.combo-opt:hover, .combo-opt.is-active { background: var(--brand-soft); }

/* delete confirm */
.confirm-body { padding: 1.4rem 1.2rem .4rem; text-align: center; }
.confirm-mark { width: 56px; height: 56px; border-radius: 18px; margin: 0 auto .9rem; background: var(--danger-soft); color: var(--danger); display: grid; place-items: center; }
.confirm-mark .ico { width: 26px; height: 26px; }
.confirm-body h3 { font-size: 1.1rem; font-weight: 800; }
.confirm-body p  { color: var(--muted); font-size: .9rem; margin-top: .35rem; }
.confirm-body strong { color: var(--text); }

/* toast */
.toast {
  position: fixed; left: 50%; top: calc(.9rem + env(safe-area-inset-top, 0px));
  transform: translate(-50%, -140%);
  z-index: 200;
  background: var(--ink); color: #fff;
  border-radius: 14px;
  padding: .75rem 1.1rem;
  font-size: .88rem; font-weight: 700;
  display: flex; align-items: center; gap: .55rem;
  box-shadow: var(--shadow-md);
  max-width: calc(100vw - 2rem);
  transition: transform .35s cubic-bezier(.2,.9,.2,1);
}
.toast.show { transform: translate(-50%, 0); }
.toast .ico { color: var(--gold); }
.toast.is-error .ico { color: #ff9b94; }

@media (min-width: 640px) {
  .backdrop { align-items: center; }
  .sheet { border-radius: 24px; max-height: 88vh; }
  .grab { display: none; }
  .case-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 380px) {
  .fgrid { grid-template-columns: 1fr; }
  .case-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet, .toast { animation: none; transition: none; }
}
