/* ============================================================================
 * Ledger · Expense Agent — UI styling, inspired by Google AI Studio.
 * Calm, dark, spacious. Thin left rail · roomy thread · clean rounded composer
 * · subtle category-colored accents. Light theme via prefers-color-scheme.
 * ==========================================================================*/

:root {
  --bg:        #131314;   /* app background (near-black warm gray) */
  --surface:   #1b1c1d;   /* sidebar / rail / composer surfaces   */
  --surface-2: #212223;   /* elevated cards, bubbles              */
  --surface-3: #2a2b2d;   /* hover / inputs                       */
  --line:      rgba(255,255,255,.09);
  --line-soft: rgba(255,255,255,.06);

  --text:      #e8eaed;
  --text-dim:  #9aa0a6;
  --text-faint:#777c82;

  --accent:    #8ab4f8;   /* AI-Studio blue (dark)  */
  --accent-2:  #aa7bf0;   /* violet                 */
  --accent-fill:#1a73e8;  /* filled primary button  */

  --green:  #81c995;
  --amber:  #fdd663;
  --red:    #f28b82;
  --teal:   #78d9ec;
  --violet: #c58af9;

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 18px;
  --r-pill: 999px;

  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 8px 30px rgba(0,0,0,.45);
  --shadow-pop: 0 18px 50px rgba(0,0,0,.55);

  --font: 'Google Sans', 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'Roboto Mono', ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;

  --sidebar-w: 256px;
  --rail-w: 300px;
  --thread-max: 760px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:#ffffff; --surface:#f7f8fa; --surface-2:#ffffff; --surface-3:#eef0f3;
    --line:rgba(0,0,0,.10); --line-soft:rgba(0,0,0,.06);
    --text:#1f2125; --text-dim:#5f6368; --text-faint:#80868b;
    --accent:#1a73e8; --accent-fill:#1a73e8;
    --shadow-1:0 1px 2px rgba(0,0,0,.08); --shadow-2:0 8px 30px rgba(0,0,0,.12);
    --shadow-pop:0 18px 50px rgba(0,0,0,.18);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}
[hidden] { display: none !important; }
button { font-family: inherit; cursor: pointer; }
.visually-hidden { position:absolute!important; width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing:-.01em; }
.muted { color: var(--text-dim); }
.small { font-size: 13px; }
::selection { background: rgba(138,180,248,.30); }

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 99px; border:2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); background-clip: padding-box; }

/* ============================ Buttons ============================ */
.btn {
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  border:1px solid transparent; border-radius: var(--r-sm);
  padding: 10px 16px; font-size: 14px; font-weight: 600;
  color: var(--text); background: var(--surface-3);
  transition: background .15s, border-color .15s, transform .08s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { background: #34363a; }
.btn:active { transform: translateY(1px); }
.btn--block { width:100%; }
.btn--primary { background: var(--accent-fill); color:#fff; border-color: transparent; }
.btn--primary:hover { background:#2b7de9; box-shadow: 0 2px 12px rgba(26,115,232,.4); }
.btn--secondary { background: transparent; border-color: var(--line); color: var(--accent); }
.btn--secondary:hover { background: rgba(138,180,248,.10); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--text-dim); }
.btn--ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.is-busy { color: transparent !important; position: relative; pointer-events:none; }
.btn.is-busy::after { content:""; position:absolute; width:16px;height:16px; border-radius:50%;
  border:2px solid rgba(255,255,255,.4); border-top-color:#fff; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.iconbtn {
  display:inline-flex; align-items:center; justify-content:center;
  width:40px; height:40px; border-radius: 50%; border:none;
  background: transparent; color: var(--text-dim);
  transition: background .15s, color .15s;
}
.iconbtn:hover { background: var(--surface-3); color: var(--text); }

/* ============================ Login ============================ */
.screen--auth {
  position: fixed; inset:0; display:grid; place-items:center; padding: 24px;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(138,180,248,.10), transparent 60%),
    radial-gradient(1000px 600px at 110% 110%, rgba(197,138,249,.10), transparent 55%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--surface-2);
  border:1px solid var(--line); border-radius: 20px; padding: 34px 30px;
  box-shadow: var(--shadow-pop);
  animation: rise .5s cubic-bezier(.2,.7,.2,1);
}
.brand { text-align:center; margin-bottom: 22px; }
.brand__mark {
  width:60px; height:60px; margin:0 auto 14px; border-radius: 18px;
  display:grid; place-items:center; color:#fff;
  background: linear-gradient(140deg, var(--accent-fill), var(--accent-2));
  box-shadow: 0 10px 30px rgba(26,115,232,.4);
}
.wordmark { font-size: 26px; font-weight: 600; margin: 0; letter-spacing:-.02em; }
.wordmark em { color: var(--accent); font-style: normal; }
.brand p { color: var(--text-dim); margin: 4px 0 0; font-size: 14px; }

.form { display:flex; flex-direction:column; gap: 14px; }
.form--grid { display:grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display:flex; flex-direction:column; gap:6px; }
.field > span { font-size: 12.5px; color: var(--text-dim); font-weight:500; }
.field input, .field select, .field textarea {
  width:100%; background: var(--surface-3); color: var(--text);
  border:1px solid var(--line); border-radius: 10px; padding: 11px 13px;
  font-size: 14px; font-family: inherit; transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline:none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138,180,248,.18);
}
.field textarea { resize: vertical; min-height: 56px; }
.form-error { color: var(--red); font-size: 13px; margin: 2px 0 0; }
.form--grid .btn, .form--grid .form-error { grid-column: 1 / -1; }

/* ============================ App shell ============================ */
#app { height: 100dvh; }
.shell {
  display:grid;
  grid-template-columns: var(--sidebar-w) minmax(0,1fr) var(--rail-w);
  height: 100dvh;
}
@media (max-width: 1180px) { .shell { grid-template-columns: var(--sidebar-w) minmax(0,1fr); } .rail { display:none; } }
@media (max-width: 899px)  { .shell { grid-template-columns: 1fr; } .sidebar { display:none; } }

/* ---- Sidebar (desktop) ---- */
.sidebar {
  background: var(--surface); border-right:1px solid var(--line-soft);
  display:flex; flex-direction:column; padding: 14px 12px; gap: 6px; min-height:0;
}
.sidebar__brand { display:flex; align-items:center; gap:10px; padding: 6px 8px 12px; }
.sidebar__logo {
  width:34px;height:34px;border-radius:10px; display:grid;place-items:center;color:#fff;
  background: linear-gradient(140deg, var(--accent-fill), var(--accent-2));
  flex:none;
}
.sidebar__title { font-size: 18px; margin:0; font-weight:600; letter-spacing:-.02em; }
.sidebar__title em { color: var(--accent); font-style:normal; }
.sidebar__sub { display:flex; align-items:center; gap:6px; font-size:12px; color: var(--text-faint); }
.net-dot { width:7px;height:7px;border-radius:50%; background: var(--green); box-shadow:0 0 0 3px rgba(129,201,149,.18); }
.net-dot.is-off { background: var(--text-faint); box-shadow:none; }

.sidebar__add {
  display:flex; align-items:center; gap:10px; width:100%;
  background: var(--surface-3); border:1px solid var(--line);
  color: var(--text); border-radius: var(--r-pill); padding: 10px 16px; margin: 2px 0 10px;
  font-size: 14px; font-weight:600; transition: background .15s, box-shadow .15s, transform .08s;
}
.sidebar__add:hover { background:#34363a; box-shadow: var(--shadow-1); }
.sidebar__add:active { transform: translateY(1px); }
.sidebar__add-ic { display:grid; place-items:center; color: var(--accent); }

.sidebar__nav { display:flex; flex-direction:column; gap:2px; }
.navlink {
  display:flex; align-items:center; gap:12px; width:100%; text-align:left;
  background:transparent; border:none; color: var(--text-dim);
  border-radius: var(--r-pill); padding: 9px 14px; font-size: 14px; font-weight:500;
  transition: background .15s, color .15s;
}
.navlink:hover { background: var(--surface-3); color: var(--text); }
.navlink.is-active { background: rgba(138,180,248,.14); color: var(--accent); }
.navlink__ic { display:grid; place-items:center; flex:none; }
.navlink__count {
  margin-left:auto; background: var(--amber); color:#3a2d00; font-size:11px; font-weight:700;
  min-width:18px; height:18px; border-radius:9px; display:grid;place-items:center; padding:0 5px;
}
.sidebar__foot { margin-top:auto; padding-top: 10px; border-top:1px solid var(--line-soft); }
.sidebar__user { display:flex; align-items:center; gap:10px; padding: 6px 6px; }
.sidebar__avatar, .drawer__avatar {
  width:34px;height:34px;border-radius:50%; flex:none; display:grid;place-items:center;
  font-weight:700; font-size:14px; color:#fff;
  background: linear-gradient(140deg, var(--accent-2), var(--accent-fill));
}
.sidebar__user-main { min-width:0; flex:1; }
.sidebar__user-name { font-size:13.5px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.sidebar__user-sub { font-size:12px; color: var(--text-faint); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* ---- Main column ---- */
.main { display:flex; flex-direction:column; min-width:0; min-height:0; position:relative; background: var(--bg); }

.appbar {
  display:none; align-items:center; justify-content:space-between;
  padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top));
  border-bottom:1px solid var(--line-soft); background: rgba(19,19,20,.8); backdrop-filter: blur(12px);
  position: sticky; top:0; z-index: 5;
}
@media (max-width: 899px) { .appbar { display:flex; } }
.appbar__brand { display:flex; align-items:center; gap:10px; }
.appbar__logo { width:30px;height:30px;border-radius:9px; display:grid;place-items:center; color:#fff;
  background: linear-gradient(140deg, var(--accent-fill), var(--accent-2)); }
.appbar__title { font-size:17px; margin:0; font-weight:600; }
.appbar__sub { display:flex; align-items:center; gap:6px; font-size:11.5px; color:var(--text-faint); }
.menu-badge { position:absolute; top:4px; right:4px; background: var(--amber); color:#3a2d00;
  font-size:10px; font-weight:700; min-width:16px;height:16px;border-radius:8px; display:grid;place-items:center; padding:0 4px; }

/* ---- Thread ---- */
.thread { flex:1; overflow-y:auto; min-height:0; scroll-behavior: smooth; }
.thread__inner { max-width: var(--thread-max); margin:0 auto; padding: 28px 22px 16px; display:flex; flex-direction:column; gap: 16px; }
.thread__day { align-self:center; font-size:12px; color: var(--text-faint); background: var(--surface-2);
  border:1px solid var(--line-soft); padding:3px 12px; border-radius: var(--r-pill); margin: 4px 0; }

.msg { display:flex; gap:11px; max-width: 100%; animation: rise .32s cubic-bezier(.2,.7,.2,1); }
.msg--in { align-self: stretch; }
.msg--out { align-self: flex-end; max-width: 86%; }
.msg__avatar {
  width:30px;height:30px;border-radius:50%; flex:none; display:grid;place-items:center; color:#fff; margin-top:2px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
}
.msg__avatar svg { width:18px;height:18px; }
.bubble {
  background: var(--surface-2); border:1px solid var(--line-soft);
  border-radius: 16px; padding: 11px 15px; max-width: 100%;
  font-size: 14.5px; box-shadow: var(--shadow-1); position: relative;
}
.bubble p { margin: 0; white-space: pre-wrap; word-wrap: break-word; }
.bubble p + p { margin-top: 8px; }
.msg--in .bubble { border-top-left-radius: 6px; }
.msg--out .bubble {
  background: linear-gradient(160deg, #2b3b57, #2a3350);
  border-color: rgba(138,180,248,.25); border-top-right-radius: 6px; color: #eef3fc;
}
.bubble__time { display:block; margin-top:6px; font-size:11px; color: var(--text-faint); text-align:right; }
.msg--in.greeting .bubble { background: var(--surface-2); }
.hint-list { list-style:none; margin: 10px 0 2px; padding:0; display:flex; flex-direction:column; gap:9px; }
.hint-list li { display:flex; gap:10px; align-items:flex-start; font-size:13.5px; color: var(--text); }
.hint-list .ic { color: var(--accent); flex:none; margin-top:1px; }
.hint-list b { color:#fff; }

.msg--out.attach .bubble { padding: 6px; background: var(--surface-2); border-color: var(--line); }
.attach__img { display:block; max-width: 240px; max-height: 300px; border-radius: 12px; object-fit: cover; }
.attach__pdf { display:flex; align-items:center; gap:12px; padding: 10px 12px; }
.attach__pdf-ic { background: var(--red); color:#3a0d0a; font-weight:800; font-size:11px; padding:8px 9px; border-radius:8px; letter-spacing:.04em; }
.attach__pdf-name { font-size:13.5px; font-weight:600; }
.attach__pdf-sub { font-size:12px; color: var(--text-faint); }

.delivery { display:flex; align-items:center; gap:6px; font-size:11.5px; color: var(--text-faint); padding: 5px 8px 3px; }
.delivery__ico { display:grid;place-items:center; }
.delivery--queued { color: var(--amber); }
.delivery--uploading { color: var(--accent); }
.delivery--done { color: var(--green); }
.delivery--error { color: var(--red); }
.delivery__retry { margin-left:6px; background:transparent;border:1px solid var(--line); color:var(--accent);
  border-radius: var(--r-pill); padding:2px 10px; font-size:11px; font-weight:600; }

.stamping { display:flex; align-items:center; gap:12px; }
.stamp { width:34px;height:34px;border-radius:10px; display:grid;place-items:center; flex:none;
  color: var(--accent); border:1.5px dashed rgba(138,180,248,.5); position:relative; overflow:hidden; }
.stamp::after { content:""; position:absolute; inset:0; background: linear-gradient(110deg, transparent, rgba(138,180,248,.25), transparent);
  transform: translateX(-100%); animation: sweep 1.3s infinite; }
@keyframes sweep { to { transform: translateX(100%); } }
.stamping__txt { display:flex; flex-direction:column; font-size:13.5px; font-weight:600; }
.stamping__txt small { font-weight:400; font-size:12px; color: var(--text-faint); }

.typing { display:flex; gap:5px; padding: 3px 2px; }
.typing i { width:7px;height:7px;border-radius:50%; background: var(--text-dim); animation: blink 1.3s infinite both; }
.typing i:nth-child(2){ animation-delay:.18s; } .typing i:nth-child(3){ animation-delay:.36s; }
@keyframes blink { 0%,80%,100%{ opacity:.25; transform:translateY(0);} 40%{ opacity:1; transform:translateY(-3px);} }

.actionchip { display:inline-flex; align-items:center; gap:6px; margin-top:8px;
  background: rgba(129,201,149,.14); color: var(--green); border:1px solid rgba(129,201,149,.3);
  border-radius: var(--r-pill); padding: 4px 11px; font-size:12.5px; font-weight:600; }
.actionchip .ico { display:grid;place-items:center; }

/* ============================ Receipt card ============================ */
.receipt {
  position: relative; background: var(--surface-2); border:1px solid var(--line);
  border-radius: 16px; padding: 16px 16px 16px 20px; overflow:hidden;
  box-shadow: var(--shadow-1); min-width: 280px; max-width: 420px;
  animation: rise .35s cubic-bezier(.2,.7,.2,1);
}
.receipt__rail { position:absolute; left:0; top:0; bottom:0; width:5px; background: var(--green); }
.receipt--review .receipt__rail { background: var(--amber); }
.receipt--error  .receipt__rail { background: var(--red); }
.receipt--dupe   .receipt__rail { background: var(--text-faint); }
.receipt__head { display:flex; align-items:flex-start; justify-content:space-between; gap:10px; }
.receipt__vendor { font-size: 16px; font-weight: 700; letter-spacing:-.01em; }
.receipt__date { font-size: 12.5px; color: var(--text-dim); margin-top:1px; }
.receipt__badge { font-size:11px; font-weight:700; padding:3px 9px; border-radius: var(--r-pill); flex:none; }
.badge--written { background: rgba(129,201,149,.16); color: var(--green); }
.badge--review  { background: rgba(253,214,99,.16); color: var(--amber); }
.badge--error   { background: rgba(242,139,130,.16); color: var(--red); }
.badge--dupe    { background: rgba(255,255,255,.08); color: var(--text-dim); }
.receipt__perf { height:1px; margin:13px -16px 13px -20px; border-top:1.5px dashed var(--line); }
.receipt__amount { display:flex; align-items:baseline; gap:10px; flex-wrap:wrap; }
.receipt__paid { font-family: var(--mono); font-size: 15px; color: var(--text-dim); }
.receipt__usd { font-family: var(--mono); font-size: 24px; font-weight:700; color: var(--text); display:flex; align-items:baseline; gap:7px; }
.receipt__arrow { color: var(--accent); font-size:18px; }
.receipt__rows { margin-top: 14px; display:flex; flex-direction:column; gap:8px; }
.receipt__row { display:flex; align-items:center; justify-content:space-between; font-size:13px; }
.receipt__row .k { color: var(--text-faint); }
.receipt__row .v { color: var(--text); font-weight:500; }
.receipt__note, .receipt__dupe-note {
  display:flex; gap:8px; align-items:flex-start; margin-top:14px; padding:10px 12px;
  border-radius: 10px; font-size:12.5px; line-height:1.45;
}
.receipt__note { background: rgba(253,214,99,.10); color: #f6d97a; }
.receipt__dupe-note { background: rgba(255,255,255,.05); color: var(--text-dim); }
.receipt__note svg, .receipt__dupe-note svg { flex:none; margin-top:1px; }
.receipt__actions { display:flex; gap:10px; margin-top:16px; }
.receipt__actions .btn { flex:1; }
.receipt__edit { display:flex; flex-direction:column; gap:12px; margin-top: 8px; }
.receipt__edit .field, .receipt__edit label { display:flex; flex-direction:column; gap:6px; }
.receipt__edit label > span { font-size:12px; color: var(--text-dim); }
.receipt__edit input, .receipt__edit select, .receipt__edit textarea {
  background: var(--surface-3); color: var(--text); border:1px solid var(--line);
  border-radius: 9px; padding: 9px 11px; font-size:14px; font-family: inherit;
}
.receipt__edit input:focus, .receipt__edit select:focus, .receipt__edit textarea:focus {
  outline:none; border-color: var(--accent); box-shadow:0 0 0 3px rgba(138,180,248,.18);
}
.receipt__edit-img { width:100%; max-height: 200px; object-fit: contain; border-radius: 12px; background: var(--surface); border:1px solid var(--line-soft); }
.row2 { display:grid; grid-template-columns: 1fr 1fr; gap:12px; }
.field--flag input, .field--flag select { border-color: var(--amber) !important; box-shadow:0 0 0 3px rgba(253,214,99,.16) !important; }
.reason-chip { display:inline-block; background: rgba(253,214,99,.12); color:#f6d97a;
  border-radius: var(--r-pill); padding:3px 10px; font-size:12px; margin:0 6px 6px 0; }

/* ============================ Composer ============================ */
.composer { padding: 10px 16px 16px; padding-bottom: max(16px, calc(env(safe-area-inset-bottom) + 8px)); background: linear-gradient(transparent, var(--bg) 30%); }
.composer__inner {
  max-width: var(--thread-max); margin:0 auto; display:flex; align-items:flex-end; gap:8px;
  background: var(--surface); border:1px solid var(--line); border-radius: 26px;
  padding: 7px 7px 7px 8px; box-shadow: var(--shadow-2); transition: border-color .15s, box-shadow .15s;
}
.composer__inner:focus-within { border-color: rgba(138,180,248,.5); box-shadow: 0 8px 30px rgba(0,0,0,.5), 0 0 0 3px rgba(138,180,248,.12); }
.composer__attach {
  width:42px;height:42px;border-radius:50%; flex:none; border:none; background: transparent; color: var(--accent);
  display:grid;place-items:center; transition: background .15s, transform .15s;
}
.composer__attach:hover { background: rgba(138,180,248,.14); }
.composer__attach:active { transform: rotate(90deg); }
.composer__field { flex:1; display:flex; align-items:flex-end; gap:8px; min-width:0; }
.composer__input {
  flex:1; background: transparent; border:none; color: var(--text); resize:none;
  font-family: inherit; font-size: 15px; line-height: 1.45; padding: 11px 4px; max-height: 160px; min-width:0;
}
.composer__input:focus { outline:none; }
.composer__input::placeholder { color: var(--text-faint); }
.composer__send {
  width:42px;height:42px;border-radius:50%; flex:none; border:none; color:#fff;
  background: var(--accent-fill); display:grid;place-items:center;
  transition: background .15s, transform .12s, opacity .15s;
}
.composer__send:hover { background:#2b7de9; }
.composer__send:disabled { background: var(--surface-3); color: var(--text-faint); cursor:default; }

/* ============================ Right rail ============================ */
.rail { background: var(--surface); border-left:1px solid var(--line-soft); padding: 18px 16px; display:flex; flex-direction:column; gap: 14px; overflow-y:auto; }
.rail__card { background: var(--surface-2); border:1px solid var(--line-soft); border-radius: var(--r); padding: 16px; }
.rail__card--hero { background: linear-gradient(150deg, rgba(138,180,248,.12), rgba(197,138,249,.10)); border-color: rgba(138,180,248,.2); }
.rail__eyebrow { font-size:12px; color: var(--text-dim); text-transform:uppercase; letter-spacing:.06em; font-weight:600; }
.rail__total { font-family: var(--mono); font-size: 32px; font-weight:700; margin-top:6px; letter-spacing:-.02em; }
.rail__sub { font-size:12.5px; color: var(--text-faint); }
.rail__spark { height:5px; background: rgba(255,255,255,.08); border-radius:99px; margin-top:12px; overflow:hidden; }
.rail__spark i { display:block; height:100%; width:40%; border-radius:99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.rail__stat-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.rail__stat { text-align:center; }
.rail__stat-num { font-family: var(--mono); font-size:22px; font-weight:700; }
.rail__stat-lbl { font-size:12px; color: var(--text-faint); margin-top:2px; }
.rail__cta { display:flex; align-items:center; justify-content:space-between; gap:8px; width:100%;
  background:transparent; border:1px solid var(--line); color: var(--text); border-radius: var(--r);
  padding: 13px 15px; font-size:13.5px; font-weight:600; transition: background .15s; }
.rail__cta:hover { background: var(--surface-3); }
.rail__cta svg { color: var(--accent); }

/* ============================ Panels ============================ */
.panel { position: fixed; inset:0; z-index: 40; background: var(--bg); display:flex; flex-direction:column;
  animation: slideUp .28s cubic-bezier(.2,.7,.2,1); }
.panel.is-leaving { animation: slideDown .24s ease forwards; }
.panel__bar { display:flex; align-items:center; gap:8px; padding: 12px 12px; padding-top: max(12px, env(safe-area-inset-top));
  border-bottom:1px solid var(--line-soft); position:sticky; top:0; background: var(--bg); }
.panel__bar h2 { font-size: 17px; margin:0; font-weight:600; flex:1; }
.panel__body { flex:1; overflow-y:auto; }
.panel__inner { max-width: 640px; margin:0 auto; padding: 18px 18px 40px; display:flex; flex-direction:column; gap:14px; }
@media (min-width: 900px) { .panel { left: var(--sidebar-w); } }

.list { list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:10px; }
.tile { display:flex; gap:12px; width:100%; text-align:left; background: var(--surface-2); border:1px solid var(--line-soft);
  border-radius: var(--r); padding: 13px 14px; transition: background .15s, border-color .15s; }
.tile:hover { background: var(--surface-3); border-color: var(--line); }
.tile__ic { font-size: 22px; flex:none; }
.tile__body { flex:1; min-width:0; }
.tile__title { font-weight:600; font-size:14.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.tile__sub { font-size:12.5px; color: var(--text-faint); margin-top:2px; }
.tile__meta { display:flex; flex-direction:column; align-items:flex-end; gap:6px; }
.tile__amount { font-family: var(--mono); font-weight:700; font-size:14px; }

.empty { text-align:center; color: var(--text-dim); padding: 50px 20px; font-size:14px; }
.empty .ic { width:54px;height:54px;border-radius:50%; margin:0 auto 14px; display:grid;place-items:center;
  background: rgba(129,201,149,.14); color: var(--green); }
.skel-list { display:flex; flex-direction:column; gap:10px; }
.skel-tile { height: 64px; border-radius: var(--r); }
.skel { background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.card { background: var(--surface-2); border:1px solid var(--line-soft); border-radius: var(--r); padding: 18px; }
.card__title { font-size: 15px; font-weight:600; margin: 0 0 14px; display:flex; align-items:center; gap:8px; }
.kv { display:flex; justify-content:space-between; gap:12px; padding: 8px 0; border-bottom:1px solid var(--line-soft); font-size:14px; }
.kv:last-child { border-bottom:none; }
.kv .v { font-weight:500; }
.tag { font-size:11px; font-weight:700; padding:2px 8px; border-radius: var(--r-pill); }
.tag--admin { background: rgba(197,138,249,.16); color: var(--violet); }
.chip { display:inline-flex; align-items:center; gap:6px; border-radius: var(--r-pill); padding:6px 13px; font-size:12.5px; font-weight:600; text-decoration:none; }
.chip--accent { background: var(--accent-fill); color:#fff; }
.chip--ghost { background: var(--surface-3); color: var(--text-dim); }

/* ============================ Drawer ============================ */
#drawer-host { position: fixed; inset:0; z-index: 50; }
.scrim, .sheet__scrim, .attach-menu__scrim { position:absolute; inset:0; background: rgba(0,0,0,.55); animation: fade .2s ease; }
.drawer { position:absolute; top:0; left:0; bottom:0; width: min(82vw, 320px); background: var(--surface);
  border-right:1px solid var(--line); display:flex; flex-direction:column; padding: 14px; animation: slideRight .26s cubic-bezier(.2,.7,.2,1); }
.drawer.is-leaving { animation: slideLeft .22s ease forwards; }
.drawer__head { display:flex; align-items:center; justify-content:space-between; padding: 4px 6px 12px; }
.drawer__head h2 { font-size:17px; margin:0; }
.drawer__nav { display:flex; flex-direction:column; gap:2px; }
.drawer__link { display:flex; align-items:center; gap:12px; width:100%; text-align:left; background:transparent; border:none;
  color: var(--text); border-radius: var(--r-pill); padding: 12px 14px; font-size:14.5px; font-weight:500; transition: background .15s; }
.drawer__link:hover { background: var(--surface-3); }
.drawer__link .ico { color: var(--text-dim); display:grid;place-items:center; }
.drawer__link .count { margin-left:auto; background: var(--amber); color:#3a2d00; font-size:11px; font-weight:700; min-width:18px;height:18px;border-radius:9px; display:grid;place-items:center; }
.drawer__foot { margin-top:auto; border-top:1px solid var(--line-soft); padding-top:12px; }
.drawer__user { display:flex; align-items:center; gap:10px; margin-bottom:12px; padding: 0 6px; }
.drawer__user-main { min-width:0; }
.drawer__user-name { font-weight:600; font-size:14px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.drawer__user-sub { font-size:12px; color: var(--text-faint); }

/* ============================ Bottom sheets ============================ */
.attach-menu, .sheet { position: fixed; inset:0; z-index: 60; }
.attach-menu__panel, .sheet__panel {
  position:absolute; left:0; right:0; bottom:0; background: var(--surface-2);
  border-top:1px solid var(--line); border-radius: 22px 22px 0 0; padding: 10px 18px 24px;
  padding-bottom: max(24px, calc(env(safe-area-inset-bottom) + 12px));
  max-width: 520px; margin:0 auto; animation: slideUp .28s cubic-bezier(.2,.7,.2,1); box-shadow: var(--shadow-pop);
}
@media (min-width: 560px) { .attach-menu__panel, .sheet__panel { border-radius: 22px; bottom: auto; top:50%; transform: translateY(-50%); } }
.attach-menu__grip, .sheet__grip { width:40px;height:4px;border-radius:99px; background: var(--line); margin: 4px auto 14px; }
.attach-opt { display:flex; align-items:center; gap:14px; width:100%; text-align:left; background: transparent; border:none;
  border-radius: var(--r); padding: 13px 12px; color: var(--text); transition: background .15s; }
.attach-opt:hover { background: var(--surface-3); }
.attach-opt__ic { width:42px;height:42px;border-radius:12px; flex:none; display:grid;place-items:center; color: var(--accent); background: rgba(138,180,248,.12); }
.attach-opt:nth-child(3) .attach-opt__ic { color: var(--violet); background: rgba(197,138,249,.12); }
.attach-opt:nth-child(4) .attach-opt__ic { color: var(--teal); background: rgba(120,217,236,.12); }
.attach-opt__txt { display:flex; flex-direction:column; }
.attach-opt__txt b { font-size:14.5px; }
.attach-opt__txt small { font-size:12.5px; color: var(--text-faint); }
.attach-opt--cancel { justify-content:center; color: var(--text-dim); margin-top:6px; font-weight:600; }

.sheet__head { display:flex; align-items:center; justify-content:space-between; margin-bottom: 6px; }
.sheet__head h2 { font-size:17px; margin:0; }

/* ============================ Toasts ============================ */
.toasts { position: fixed; left:50%; bottom: 22px; transform: translateX(-50%); z-index: 80;
  display:flex; flex-direction:column; gap:8px; align-items:center; width: max-content; max-width: 92vw; pointer-events:none; }
.toast { display:flex; align-items:center; gap:9px; background: #2a2b2d; color: var(--text); border:1px solid var(--line);
  border-radius: 12px; padding: 11px 16px; font-size:13.5px; box-shadow: var(--shadow-pop); animation: rise .3s cubic-bezier(.2,.7,.2,1); }
.toast .ico { display:grid;place-items:center; }
.toast--ok .ico { color: var(--green); }
.toast--err .ico { color: var(--red); }
.toast--info .ico { color: var(--accent); }
.toast.is-out { animation: fadeOut .25s ease forwards; }

/* ============================ Keyframes ============================ */
@keyframes rise { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform:none; } }
@keyframes fade { from { opacity:0; } to { opacity:1; } }
@keyframes fadeOut { to { opacity:0; transform: translateY(6px); } }
@keyframes slideUp { from { transform: translateY(16px); opacity:0; } to { transform:none; opacity:1; } }
@keyframes slideDown { to { transform: translateY(100%); opacity:0; } }
@keyframes slideRight { from { transform: translateX(-100%); } to { transform:none; } }
@keyframes slideLeft { to { transform: translateX(-100%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::after, *::before { animation-duration: .01ms !important; transition-duration: .05ms !important; }
}
