/* ============================================================
   BITÁCORA — Trading journal design system
   Dark terminal aesthetic. IBM Plex Sans + IBM Plex Mono.
   ============================================================ */

:root {
  /* surfaces — deep cool slate */
  --bg:          oklch(0.155 0.012 255);
  --bg-grad:     oklch(0.175 0.014 255);
  --bg-2:        oklch(0.190 0.013 255);
  --surface:     oklch(0.212 0.014 255);
  --surface-2:   oklch(0.245 0.015 255);
  --surface-3:   oklch(0.285 0.016 255);
  --border:      oklch(0.305 0.014 255);
  --border-soft: oklch(0.260 0.013 255);
  --border-strong: oklch(0.40 0.016 255);

  /* text */
  --text:        oklch(0.962 0.004 255);
  --text-muted:  oklch(0.700 0.012 255);
  --text-faint:  oklch(0.540 0.013 255);

  /* accent (tweakable) */
  --accent:      oklch(0.705 0.135 258);
  --accent-2:    oklch(0.78 0.12 258);
  --accent-soft: oklch(0.705 0.135 258 / 0.16);
  --accent-line: oklch(0.705 0.135 258 / 0.40);

  /* semantic — reserved strictly for P/L */
  --profit:      oklch(0.77 0.155 156);
  --profit-soft: oklch(0.77 0.155 156 / 0.15);
  --loss:        oklch(0.665 0.185 22);
  --loss-soft:   oklch(0.665 0.185 22 / 0.15);
  --warn:        oklch(0.80 0.13 80);
  --warn-soft:   oklch(0.80 0.13 80 / 0.15);

  --radius:   14px;
  --radius-sm: 9px;
  --radius-lg: 20px;

  --shadow-1: 0 1px 2px oklch(0 0 0 / 0.4);
  --shadow-2: 0 8px 28px -8px oklch(0 0 0 / 0.55);
  --shadow-pop: 0 24px 60px -16px oklch(0 0 0 / 0.7);

  --font-sans: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --sidebar-w: 248px;
  --maxw: 1320px;

  /* density (tweakable) */
  --row-pad: 14px;
  --gap: 20px;
}

/* accent variants set by tweaks */
[data-accent="teal"]   { --accent: oklch(0.74 0.105 195); --accent-2: oklch(0.82 0.10 195); --accent-soft: oklch(0.74 0.105 195 / 0.16); --accent-line: oklch(0.74 0.105 195 / 0.40); }
[data-accent="amber"]  { --accent: oklch(0.80 0.12 80);   --accent-2: oklch(0.86 0.11 80);  --accent-soft: oklch(0.80 0.12 80 / 0.16);  --accent-line: oklch(0.80 0.12 80 / 0.40); }
[data-accent="violet"] { --accent: oklch(0.67 0.16 300);  --accent-2: oklch(0.76 0.14 300); --accent-soft: oklch(0.67 0.16 300 / 0.16); --accent-line: oklch(0.67 0.16 300 / 0.40); }
[data-accent="rose"]   { --accent: oklch(0.70 0.16 12);   --accent-2: oklch(0.78 0.14 12);  --accent-soft: oklch(0.70 0.16 12 / 0.16);  --accent-line: oklch(0.70 0.16 12 / 0.40); }
[data-accent="green"]  { --accent: oklch(0.74 0.16 150);  --accent-2: oklch(0.82 0.15 150); --accent-soft: oklch(0.74 0.16 150 / 0.16); --accent-line: oklch(0.74 0.16 150 / 0.40); }
[data-accent="cyan"]   { --accent: oklch(0.78 0.12 220);  --accent-2: oklch(0.85 0.11 220); --accent-soft: oklch(0.78 0.12 220 / 0.16); --accent-line: oklch(0.78 0.12 220 / 0.40); }
[data-accent="orange"] { --accent: oklch(0.73 0.16 50);   --accent-2: oklch(0.80 0.15 50);  --accent-soft: oklch(0.73 0.16 50 / 0.16);  --accent-line: oklch(0.73 0.16 50 / 0.40); }
[data-accent="blue"]   { --accent: oklch(0.68 0.15 250);  --accent-2: oklch(0.77 0.13 250); --accent-soft: oklch(0.68 0.15 250 / 0.16); --accent-line: oklch(0.68 0.15 250 / 0.40); }
[data-accent="magenta"]{ --accent: oklch(0.68 0.20 340);  --accent-2: oklch(0.77 0.18 340); --accent-soft: oklch(0.68 0.20 340 / 0.16); --accent-line: oklch(0.68 0.20 340 / 0.40); }

[data-density="compact"] { --row-pad: 9px;  --gap: 14px; }
[data-density="comfy"]   { --row-pad: 19px; --gap: 26px; }

/* ============================================================ LIGHT THEME */
[data-theme="light"] {
  --bg:          oklch(0.975 0.004 255);
  --bg-grad:     oklch(0.95 0.012 255);
  --bg-2:        oklch(0.995 0.002 255);
  --surface:     oklch(1 0 0);
  --surface-2:   oklch(0.965 0.004 255);
  --surface-3:   oklch(0.93 0.006 255);
  --border:      oklch(0.89 0.006 255);
  --border-soft: oklch(0.925 0.005 255);
  --border-strong: oklch(0.82 0.008 255);

  --text:        oklch(0.245 0.014 255);
  --text-muted:  oklch(0.44 0.014 255);
  --text-faint:  oklch(0.60 0.012 255);

  --shadow-1: 0 1px 2px oklch(0.5 0.02 255 / 0.08);
  --shadow-2: 0 8px 28px -8px oklch(0.4 0.02 255 / 0.16);
  --shadow-pop: 0 24px 60px -16px oklch(0.4 0.02 255 / 0.24);

  --profit:      oklch(0.58 0.16 156);
  --profit-soft: oklch(0.58 0.16 156 / 0.13);
  --loss:        oklch(0.58 0.20 24);
  --loss-soft:   oklch(0.58 0.20 24 / 0.12);
}
[data-theme="light"] body {
  background:
    radial-gradient(1200px 600px at 78% -8%, var(--bg-grad), transparent 60%),
    var(--bg);
}
[data-theme="light"] .sidebar { background: linear-gradient(180deg, oklch(0.985 0.003 255), oklch(0.96 0.006 255)); }
[data-theme="light"] .topbar { background: oklch(0.975 0.004 255 / 0.82); }
[data-theme="light"] .card,
[data-theme="light"] .stat { background: var(--surface); }
[data-theme="light"] table.trades thead th { background: oklch(0.96 0.004 255); }
[data-theme="light"] .mobile-nav { background: oklch(0.99 0.003 255 / 0.96); }

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

html, body { height: 100%; }

body {
  font-family: var(--font-sans);
  background:
    radial-gradient(1200px 600px at 78% -8%, var(--bg-grad), transparent 60%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.01em;
}

#root { min-height: 100%; }

::selection { background: var(--accent-soft); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: content-box; }

.mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; }
.tnum { font-variant-numeric: tabular-nums; }

/* ============================================================ APP SHELL */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  border-right: 1px solid var(--border-soft);
  background: linear-gradient(180deg, var(--bg-2), oklch(0.165 0.012 255));
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 13px; padding: 22px 22px 18px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; position: relative; overflow: hidden;
  background: linear-gradient(155deg, var(--accent-2), var(--accent) 70%);
  box-shadow: 0 6px 18px -5px var(--accent), inset 0 1px 0 oklch(1 0 0 / 0.4), inset 0 0 0 1px oklch(1 0 0 / 0.08);
  flex: 0 0 auto;
}
.brand-mark::after { content: ""; position: absolute; inset: 0; background: radial-gradient(110% 75% at 50% -15%, oklch(1 0 0 / 0.4), transparent 58%); pointer-events: none; }
.brand-mark svg { width: 24px; height: 24px; position: relative; z-index: 1; }
.brand-name { font-weight: 600; font-size: 16px; letter-spacing: 0.04em; }
.brand-name b { color: var(--accent-2); font-weight: 600; }
.brand-sub { font-size: 10px; letter-spacing: 0.22em; color: var(--text-faint); text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 3px; padding: 8px 12px; }
.nav-label { font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-faint); padding: 14px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--text-muted); font-size: 14px; font-weight: 500;
  cursor: pointer; border: 1px solid transparent;
  transition: background .14s, color .14s, border-color .14s;
  text-align: left; width: 100%; background: none; font-family: inherit; white-space: nowrap;
}
.nav-item svg { width: 18px; height: 18px; opacity: 0.85; flex: 0 0 auto; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-2); border-color: var(--accent-line); }
.nav-item.active svg { opacity: 1; }
.nav-spacer { flex: 1; }

.sidebar-foot { padding: 14px; border-top: 1px solid var(--border-soft); }
.balance-chip { padding: 13px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border-soft); }
.balance-chip .lbl { font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-faint); }
.balance-chip .val { font-size: 20px; font-weight: 600; margin-top: 3px; }

/* ============================================================ MAIN */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 18px clamp(18px, 3vw, 38px);
  background: oklch(0.155 0.012 255 / 0.78);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.topbar h1 { font-size: 21px; font-weight: 600; letter-spacing: -0.02em; }
.topbar .sub { font-size: 12.5px; color: var(--text-faint); margin-top: 2px; }
.topbar-spacer { flex: 1; }

.content { padding: clamp(18px, 3vw, 34px); max-width: var(--maxw); width: 100%; margin: 0 auto; }

/* ============================================================ BUTTONS */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 15px; border-radius: 10px;
  font-family: inherit; font-size: 13.5px; font-weight: 500;
  border: 1px solid var(--btn-border, var(--border)); background: var(--surface); color: var(--text);
  cursor: pointer; transition: background .14s, border-color .14s, transform .06s, color .14s;
  white-space: nowrap; user-select: none;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-2); border-color: var(--btn-border, var(--border-strong)); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: transparent; color: oklch(0.16 0.02 258); font-weight: 600; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-sm { padding: 7px 11px; font-size: 12.5px; }
.btn-icon { padding: 9px; }
.btn-icon svg { width: 17px; height: 17px; }
.btn-danger:hover { background: var(--loss-soft); border-color: var(--loss); color: var(--loss); }

/* ============================================================ CARDS */
.card {
  background: linear-gradient(180deg, var(--surface), oklch(0.198 0.013 255));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.card-pad { padding: 20px; }

.grid { display: grid; gap: var(--gap); }

/* ============================================================ STAT CARDS */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--gap); }
.stat {
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, var(--surface), oklch(0.196 0.013 255));
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 17px 18px;
}
.stat::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent); opacity: 0.0; transition: opacity .2s; }
.stat:hover::before { opacity: 0.7; }
.stat .lbl { display: flex; align-items: center; gap: 7px; font-size: 11px; letter-spacing: 0.13em; text-transform: uppercase; color: var(--text-faint); }
.stat .lbl svg { width: 14px; height: 14px; }
.stat .val { font-family: var(--font-mono); font-size: 27px; font-weight: 600; margin-top: 9px; letter-spacing: -0.02em; }
.stat .meta { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.pos { color: var(--profit); }
.neg { color: var(--loss); }
.val.pos, .val.neg { }

/* ============================================================ BADGES & CHIPS */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 7px; font-size: 11.5px; font-weight: 500;
  font-family: var(--font-mono); letter-spacing: 0.01em;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted);
  white-space: nowrap;
}
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.badge.long  { color: var(--profit); background: var(--profit-soft); border-color: oklch(0.77 0.155 156 / 0.3); }
.badge.short { color: var(--loss);   background: var(--loss-soft);   border-color: oklch(0.665 0.185 22 / 0.3); }
.badge.tp    { color: var(--profit); background: var(--profit-soft); border-color: oklch(0.77 0.155 156 / 0.3); }
.badge.sl    { color: var(--loss);   background: var(--loss-soft);   border-color: oklch(0.665 0.185 22 / 0.3); }
.badge.be    { color: var(--text-muted); }
.badge.manual{ color: var(--warn); background: var(--warn-soft); border-color: oklch(0.80 0.13 80 / 0.3); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 8px; font-size: 12.5px; font-weight: 500;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted);
  cursor: pointer; transition: all .13s; user-select: none; font-family: inherit;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-2); }
.chip.on .chip-x { opacity: 1; }
.chip-x { opacity: 0; width: 13px; height: 13px; }
.chip-static { cursor: default; padding: 3px 9px; font-size: 11.5px; }
.chip-static:hover { border-color: var(--border); color: var(--text-muted); }

.tag-flow { display: flex; flex-wrap: wrap; gap: 7px; }

/* ============================================================ TABLE */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--surface); }
table.trades { width: 100%; border-collapse: collapse; min-width: 980px; }
table.trades thead th {
  text-align: left; font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 600; padding: 13px var(--row-pad);
  border-bottom: 1px solid var(--border); position: sticky; top: 0;
  background: oklch(0.205 0.013 255); white-space: nowrap; cursor: pointer; user-select: none;
}
table.trades thead th.sortable:hover { color: var(--text-muted); }
table.trades thead th .arrow { opacity: 0.5; font-size: 9px; }
table.trades tbody td { padding: var(--row-pad); border-bottom: 1px solid var(--border-soft); font-size: 13.5px; vertical-align: middle; }
table.trades tbody tr { cursor: pointer; transition: background .12s; }
table.trades tbody tr:hover { background: var(--surface-2); }
table.trades tbody tr:last-child td { border-bottom: none; }
.cell-asset { font-weight: 600; font-family: var(--font-mono); letter-spacing: 0.01em; }
.cell-date { color: var(--text-muted); font-family: var(--font-mono); font-size: 12.5px; }
.cell-pl { font-family: var(--font-mono); font-weight: 600; font-size: 14px; text-align: right; }
.cell-thumb { width: 46px; height: 32px; border-radius: 6px; object-fit: cover; border: 1px solid var(--border); background: var(--surface-2); }
.thumb-stack { display: flex; align-items: center; }
.thumb-stack .cell-thumb:not(:first-child) { margin-left: -14px; }
.thumb-count { font-size: 11px; color: var(--text-faint); margin-left: 6px; }
.conf-mini { display: flex; gap: 4px; flex-wrap: wrap; max-width: 240px; }

/* trade cards (alt list view) */
.trade-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--gap); }
.trade-card { overflow: hidden; cursor: pointer; transition: border-color .15s, transform .1s; }
.trade-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.trade-card .tc-img { height: 138px; background: var(--surface-2); position: relative; overflow: hidden; }
.trade-card .tc-img img { width: 100%; height: 100%; object-fit: cover; }
.trade-card .tc-img .tc-pl { position: absolute; top: 10px; right: 10px; padding: 4px 9px; border-radius: 8px; font-family: var(--font-mono); font-weight: 600; font-size: 13px; backdrop-filter: blur(8px); }
.trade-card .tc-img .tc-pl.pos { background: var(--profit-soft); color: var(--profit); }
.trade-card .tc-img .tc-pl.neg { background: var(--loss-soft); color: var(--loss); }
.trade-card .tc-body { padding: 14px 15px; }

/* ============================================================ FORMS */
.field { display: flex; flex-direction: column; gap: 7px; }
.field label, .flabel { font-size: 12px; font-weight: 500; color: var(--text-muted); letter-spacing: 0.01em; }
.field .hint { font-size: 11px; color: var(--text-faint); }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  font-family: inherit; font-size: 14px; transition: border-color .14s, box-shadow .14s, background .14s;
}
.input.mono { font-family: var(--font-mono); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--bg); }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238792a8' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.input-affix { position: relative; display: flex; align-items: center; }
.input-affix .affix { position: absolute; right: 12px; font-family: var(--font-mono); color: var(--text-faint); font-size: 13px; pointer-events: none; }
.input-affix .affix-l { left: 12px; right: auto; }
.input-affix.has-l .input { padding-left: 26px; }
/* hide native number spinners so affixes sit clean */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 3px; }
.seg button { flex: 1; padding: 8px 13px; border-radius: 6px; border: none; background: none; color: var(--text-muted); font-family: inherit; font-size: 13px; font-weight: 500; cursor: pointer; transition: all .13s; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow-1); }
.seg button.on.buy  { background: var(--profit-soft); color: var(--profit); }
.seg button.on.sell { background: var(--loss-soft); color: var(--loss); }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 18px; }
.form-grid .span2 { grid-column: 1 / -1; }

/* image dropzone */
.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: var(--bg-2); padding: 22px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s; color: var(--text-faint);
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-2); }
.dropzone svg { width: 24px; height: 24px; margin-bottom: 6px; }
.dropzone .dz-main { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.dropzone .dz-sub { font-size: 11.5px; margin-top: 3px; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-top: 12px; }
.img-thumb { position: relative; aspect-ratio: 4/3; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.img-thumb img { width: 100%; height: 100%; object-fit: cover; }
.img-thumb .rm { position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; border-radius: 6px; background: oklch(0.16 0.01 255 / 0.8); border: 1px solid var(--border); display: grid; place-items: center; cursor: pointer; color: var(--text); }
.img-thumb .rm:hover { background: var(--loss); border-color: var(--loss); }
.img-thumb .rm svg { width: 12px; height: 12px; }

/* ============================================================ MODAL / DRAWER */
.overlay { position: fixed; inset: 0; background: oklch(0.10 0.01 255 / 0.6); backdrop-filter: blur(3px); z-index: 100; display: flex; opacity: 0; animation: fade .18s forwards; }
@keyframes fade { to { opacity: 1; } }
.drawer {
  margin-left: auto; height: 100%; width: min(680px, 100%);
  background: var(--bg); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-pop); display: flex; flex-direction: column;
  transform: translateX(20px); animation: slidein .22s cubic-bezier(.2,.7,.3,1) forwards;
  overflow: hidden;
}
@keyframes slidein { to { transform: translateX(0); } }
.modal {
  margin: auto; width: min(560px, 100%);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-pop);
  transform: translateY(10px) scale(.99); animation: popin .2s cubic-bezier(.2,.7,.3,1) forwards;
}
@keyframes popin { to { transform: translateY(0) scale(1); } }
.modal-head, .drawer-head { display: flex; align-items: flex-start; gap: 14px; padding: 20px 22px; border-bottom: 1px solid var(--border-soft); }
.modal-head h2, .drawer-head h2 { font-size: 18px; font-weight: 600; }
.modal-head .sub, .drawer-head .sub { font-size: 12.5px; color: var(--text-faint); margin-top: 2px; }
.modal-body, .drawer-body { padding: 22px; overflow-y: auto; }
.drawer-body { flex: 1; }
.modal-foot, .drawer-foot { display: flex; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border-soft); background: var(--bg-2); }
.modal-foot .spacer, .drawer-foot .spacer { flex: 1; }
.x-close { margin-left: auto; }

/* detail */
.detail-hero { display: grid; gap: 14px; }
.detail-imgs { display: grid; grid-template-columns: 1fr; gap: 10px; }
.detail-imgs img { width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--border); cursor: zoom-in; display: block; }
.detail-kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px,1fr)); gap: 1px; background: var(--border-soft); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); overflow: hidden; }
.kv { background: var(--surface); padding: 12px 14px; }
.kv .k { font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); }
.kv .v { font-size: 15px; font-weight: 600; margin-top: 4px; font-family: var(--font-mono); }
.detail-section-title { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-faint); margin: 4px 0 2px; }
.note-box { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 14px 15px; font-size: 14px; line-height: 1.6; color: var(--text-muted); white-space: pre-wrap; }

/* lightbox */
.lightbox { position: fixed; inset: 0; background: oklch(0.08 0.01 255 / 0.92); z-index: 200; display: grid; place-items: center; padding: 40px; cursor: zoom-out; animation: fade .15s forwards; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: var(--shadow-pop); }

/* ============================================================ CALENDAR */
.cal-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.cal-title { font-size: 18px; font-weight: 600; font-family: var(--font-mono); letter-spacing: 0.01em; text-transform: capitalize; min-width: 200px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal-dow { font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-faint); text-align: center; padding-bottom: 4px; font-weight: 600; }
.cal-cell {
  aspect-ratio: 1 / 0.92; border-radius: 10px; border: 1px solid var(--border-soft);
  background: var(--surface); padding: 9px 10px; display: flex; flex-direction: column;
  position: relative; overflow: hidden; transition: border-color .13s, transform .08s; cursor: default;
}
.cal-cell.has:hover { border-color: var(--border-strong); transform: translateY(-1px); cursor: pointer; }
.cal-cell.muted { background: transparent; border-color: transparent; }
.cal-cell.today { border-color: var(--accent-line); }
.cal-cell .d { font-size: 12px; color: var(--text-faint); font-family: var(--font-mono); }
.cal-cell.today .d { color: var(--accent-2); font-weight: 600; }
.cal-cell .cal-pl { margin-top: auto; font-family: var(--font-mono); font-weight: 600; font-size: 14px; letter-spacing: -0.02em; }
.cal-cell .cal-n { font-size: 10.5px; color: var(--text-faint); }
.cal-cell.win  { background: linear-gradient(160deg, var(--profit-soft), transparent 90%); }
.cal-cell.lose { background: linear-gradient(160deg, var(--loss-soft), transparent 90%); }
.cal-cell.win::after, .cal-cell.lose::after { content:""; position:absolute; inset:0 auto 0 0; width:3px; }
.cal-cell.win::after  { background: var(--profit); }
.cal-cell.lose::after { background: var(--loss); }
.cal-week-sum { display: grid; gap: 8px; align-content: start; }
.week-sum-cell { border-radius: 10px; border: 1px dashed var(--border-soft); padding: 9px 10px; display: flex; flex-direction: column; justify-content: center; aspect-ratio: 1/0.92; }
.week-sum-cell .lbl { font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); }
.week-sum-cell .v { font-family: var(--font-mono); font-weight: 600; font-size: 13px; margin-top: 3px; }

/* ============================================================ EQUITY CURVE */
.equity-wrap { position: relative; }
.equity-inner { position: relative; width: 100%; cursor: crosshair; touch-action: none; }
.equity-svg { width: 100%; height: 220px; display: block; overflow: visible; }
.equity-svg .grid-line { stroke: var(--border-soft); stroke-width: 1; }
.equity-svg .area { fill: url(#eqGrad); }
.equity-svg .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.equity-svg .dot { fill: var(--accent); stroke: var(--bg); stroke-width: 2; }
.equity-svg .equity-guide { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 3 3; opacity: .55; vector-effect: non-scaling-stroke; }
.equity-svg .equity-base { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 5 4; opacity: .7; vector-effect: non-scaling-stroke; }
.equity-svg .equity-move-mark { stroke: var(--warn); stroke-width: 1; stroke-dasharray: 2 3; opacity: .45; vector-effect: non-scaling-stroke; }
.equity-axis { font-family: var(--font-mono); font-size: 10px; fill: var(--text-faint); }
.equity-hover-dot {
  position: absolute; width: 11px; height: 11px; border-radius: 99px;
  background: var(--accent); border: 2px solid var(--bg); box-shadow: 0 0 0 3px var(--accent-soft);
  transform: translate(-50%, -50%); pointer-events: none; transition: left .04s linear, top .04s linear;
}
.equity-hover-dot.move { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.equity-tip {
  position: absolute; top: -4px; transform: translate(-50%, -100%);
  background: var(--surface-3); border: 1px solid var(--border-strong);
  border-radius: 9px; padding: 7px 11px; pointer-events: none; white-space: nowrap;
  box-shadow: var(--shadow-pop); z-index: 5; transition: left .04s linear;
}
.equity-tip.flip { transform: translate(-100%, -100%); }
.equity-tip::after {
  content: ""; position: absolute; bottom: -5px; left: 50%; transform: translateX(-50%) rotate(45deg);
  width: 8px; height: 8px; background: var(--surface-3); border-right: 1px solid var(--border-strong); border-bottom: 1px solid var(--border-strong);
}
.equity-tip.flip::after { left: auto; right: 14px; }
.equity-tip-val { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.equity-tip-pl { font-size: 12px; font-weight: 600; margin-top: 1px; }
.equity-tip-sub { font-size: 11px; color: var(--text-faint); margin-top: 1px; }

/* ============================================================ TOOLBAR / FILTERS */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: var(--gap); }
.search { position: relative; flex: 1; min-width: 180px; max-width: 320px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-faint); }
.search input { width: 100%; padding: 9px 12px 9px 34px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--border); color: var(--text); font-family: inherit; font-size: 13.5px; }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.toolbar-spacer { flex: 1; }
.view-toggle { display: inline-flex; background: var(--bg-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.view-toggle button { padding: 7px 9px; border-radius: 6px; border: none; background: none; color: var(--text-faint); cursor: pointer; display: grid; place-items: center; }
.view-toggle button svg { width: 16px; height: 16px; }
.view-toggle button.on { background: var(--surface-3); color: var(--text); }

/* ============================================================ EMPTY STATE */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 70px 24px; color: var(--text-faint); }
.empty .ic { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border-soft); margin-bottom: 18px; }
.empty .ic svg { width: 26px; height: 26px; color: var(--accent-2); }
.empty h3 { font-size: 17px; color: var(--text); font-weight: 600; }
.empty p { font-size: 13.5px; margin-top: 7px; max-width: 380px; line-height: 1.6; }
.empty .actions { margin-top: 22px; display: flex; gap: 10px; }

/* section heading */
.sec-title { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sec-title h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.sec-title .count { font-size: 12px; color: var(--text-faint); font-family: var(--font-mono); }
.sec-title .line { flex: 1; height: 1px; background: var(--border-soft); }

/* emotion pill */
.emo { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-muted); }
.emo .face { font-size: 14px; }

/* ============================================================ WELCOME / FRASE */
.welcome { display: flex; align-items: center; gap: 18px; padding: 18px 24px; position: relative; overflow: hidden; }
.welcome::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.welcome .wq { font-family: Georgia, "Times New Roman", serif; font-size: 56px; line-height: 0.7; color: var(--accent); opacity: 0.55; flex: 0 0 auto; align-self: flex-start; margin-top: 6px; }
.welcome-body { flex: 1; min-width: 0; }
.welcome-greeting { font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-faint); }
.welcome-phrase { font-size: clamp(16px, 2.1vw, 21px); font-weight: 500; margin-top: 5px; letter-spacing: -0.01em; line-height: 1.4; color: var(--text); text-wrap: pretty; cursor: text; }
.welcome-phrase:hover { color: var(--accent-2); }
.phrase-input { width: 100%; font-family: inherit; font-size: clamp(16px, 2.1vw, 21px); font-weight: 500; margin-top: 5px; background: var(--bg-2); border: 1px solid var(--accent); border-radius: var(--radius-sm); padding: 7px 11px; color: var(--text); }
.phrase-input:focus { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.welcome .edit-btn { flex: 0 0 auto; opacity: 0; transition: opacity .15s; }
.welcome:hover .edit-btn { opacity: 1; }
@media (max-width: 880px) { .welcome .edit-btn { opacity: 1; } .welcome .wq { font-size: 42px; } }

/* mini bar (win/loss split) */
.split-bar { height: 8px; border-radius: 99px; overflow: hidden; display: flex; background: var(--surface-3); }
.split-bar .win { background: var(--profit); }
.split-bar .lose { background: var(--loss); }

/* donut handled inline svg */

.fade-up { animation: fadeUp .35s cubic-bezier(.2,.7,.3,1) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text); padding: 11px 18px; border-radius: 11px; font-size: 13.5px; box-shadow: var(--shadow-pop); z-index: 300; display: flex; align-items: center; gap: 9px; animation: toastIn .25s cubic-bezier(.2,.7,.3,1); }
.toast svg { width: 16px; height: 16px; color: var(--profit); }
@keyframes toastIn { from { opacity: 0; transform: transl(-50%, 12px); } }

/* mobile bottom nav */
.mobile-nav { display: none; }

/* ============================================================ QUICK COLOR */
.color-quick { position: relative; }
.color-quick-btn { position: relative; }
.color-quick-btn .dot {
  position: absolute; right: 4px; bottom: 4px; width: 9px; height: 9px;
  border-radius: 99px; background: var(--accent); border: 1.5px solid var(--surface);
}
.color-pop {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-pop);
  padding: 14px; width: 268px;
  transform-origin: top right; animation: popin .16s cubic-bezier(.2,.7,.3,1);
}
.color-pop .cp-title { font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 10px; }
.color-pop .cp-title:not(:first-child) { margin-top: 16px; }
.color-pop .cp-row { display: flex; gap: 9px; }
.swatch {
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer; padding: 0;
  border: 2px solid oklch(1 0 0 / 0.12); transition: transform .1s, box-shadow .12s;
  display: grid; place-items: center;
}
.swatch:hover { transform: translateY(-2px); }
.swatch.on { border-color: #fff; box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px currentColor; }
.swatch svg { width: 15px; height: 15px; color: #fff; opacity: 0; }
.swatch.on svg { opacity: 1; }
.swatch.outline { background: transparent !important; }

/* color popover in sidebar nav */
.color-quick-nav { position: relative; }
.color-pop-nav { position: absolute; left: 8px; right: auto; top: calc(100% + 4px); width: 216px; }

/* ============================================================ ACCOUNT SWITCHER */
.acct-switch { position: relative; padding: 0 12px 6px; }
.acct-current {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 11px; border-radius: 11px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border-soft);
  font-family: inherit; color: var(--text); transition: border-color .14s, background .14s;
}
.acct-current:hover { border-color: var(--border-strong); background: var(--surface-2); }
.acct-ic {
  width: 32px; height: 32px; border-radius: 9px; flex: 0 0 auto;
  display: grid; place-items: center; color: var(--accent-2);
  background: var(--accent-soft); border: 1px solid var(--accent-line);
}
.acct-ic svg { width: 17px; height: 17px; }
.acct-meta { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; flex: 1; }
.acct-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.acct-bal { font-size: 11.5px; color: var(--text-faint); margin-top: 1px; }
.acct-caret { color: var(--text-faint); display: grid; place-items: center; transition: transform .18s; }
.acct-caret svg { width: 15px; height: 15px; }
.acct-caret.up { transform: rotate(180deg); }

.acct-pop {
  position: absolute; left: 12px; right: 12px; top: calc(100% + 2px); z-index: 70;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-pop);
  padding: 8px; animation: popin .15s cubic-bezier(.2,.7,.3,1);
}
.acct-pop-label { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--text-faint); padding: 6px 8px 8px; }
.acct-list { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow-y: auto; }
.acct-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 9px 9px; border-radius: 9px; cursor: pointer;
  background: none; border: none; font-family: inherit; color: var(--text-muted);
  transition: background .12s, color .12s; text-align: left;
}
.acct-item:hover { background: var(--surface-2); color: var(--text); }
.acct-item.on { background: var(--accent-soft); color: var(--accent-2); }
.acct-dot { width: 7px; height: 7px; border-radius: 99px; background: currentColor; flex: 0 0 auto; opacity: .5; }
.acct-item.on .acct-dot { opacity: 1; }
.acct-item-name { font-size: 13px; font-weight: 500; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-item-bal { font-size: 12px; flex: 0 0 auto; }
.acct-check { width: 15px; height: 15px; flex: 0 0 auto; }
.acct-pop-actions { display: flex; gap: 4px; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border-soft); }
.acct-action {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px; border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 12px;
  background: none; border: 1px solid transparent; color: var(--text-muted); transition: background .12s, color .12s;
}
.acct-action:hover { background: var(--surface-2); color: var(--text); }
.acct-action svg { width: 14px; height: 14px; }

/* capital movements */
.mv-break { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-soft); font-size: 12.5px; color: var(--text-muted); }
.mv-break b { font-weight: 600; margin-left: 3px; }
.mv-item { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border-soft); }
.mv-badge { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: 0 0 auto; }
.mv-badge svg { width: 15px; height: 15px; }
.mv-badge.out { background: var(--loss-soft); color: var(--loss); }
.mv-badge.in { background: var(--profit-soft); color: var(--profit); }

/* filter bar */
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; align-items: end; }
@media (max-width: 600px) { .filter-grid { grid-template-columns: 1fr 1fr; } }

/* ============================================================ RESPONSIVE */
@media (max-width: 880px) {
  .sidebar { display: none; }
  .main { padding-bottom: 76px; }
  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: oklch(0.175 0.012 255 / 0.96); backdrop-filter: blur(14px);
    border-top: 1px solid var(--border); padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .mobile-nav button { background: none; border: none; color: var(--text-faint); display: flex; flex-direction: column; align-items: center; gap: 3px; font-family: inherit; font-size: 10px; cursor: pointer; padding: 4px 10px; border-radius: 9px; }
  .mobile-nav button svg { width: 21px; height: 21px; }
  .mobile-nav button.active { color: var(--accent-2); }
  .form-grid { grid-template-columns: 1fr; }
  .drawer { width: 100%; }
  .topbar h1 { font-size: 18px; }
  .cal-week-sum { display: none; }
  .content { padding: 16px; }
}

@media (max-width: 520px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .cal-grid { gap: 5px; }
  .cal-cell { padding: 5px 6px; border-radius: 8px; }
  .cal-cell .cal-pl { font-size: 11px; }
}
