/* ============================================================
   Trading Journal — black & white theme
   Colour is reserved for meaning: green = profit, red = loss,
   and each account's own colour.
   ============================================================ */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000; --surface: #0e0e0e; --surface-2: #161616; --hover: #1c1c1c;
  --border: #292929; --grid: #202020;
  --text: #f5f5f5; --muted: #a3a3a3; --faint: #737373;
  --accent: #fff; --accent-fg: #000;
  --profit: #3ecf8e; --loss: #f2545b; --neutral: #737373;
  --shadow: 0 10px 40px rgba(0, 0, 0, .6);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f4f4; --surface: #fff; --surface-2: #fafafa; --hover: #f0f0f0;
  --border: #e2e2e2; --grid: #ececec;
  --text: #0a0a0a; --muted: #555; --faint: #8a8a8a;
  --accent: #000; --accent-fg: #fff;
  --profit: #08805a; --loss: #d62839; --neutral: #a3a3a3;
  --shadow: 0 10px 40px rgba(0, 0, 0, .12);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14.5px/1.5 Inter, -apple-system, "Segoe UI", "Noto Sans Georgian", Sylfaen, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ico { flex: none; vertical-align: -3px; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12.5px; }
.pos { color: var(--profit); } .neg { color: var(--loss); } .zero { color: var(--muted); }
.nowrap { white-space: nowrap; } .center { text-align: center; } .right { text-align: right; } .num { text-align: right; font-variant-numeric: tabular-nums; }
.pad { padding: 16px; } .pad-lg { padding: 40px 16px; } .mt { margin-top: 20px; }
[hidden] { display: none !important; }

/* ---------- buttons & controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); font-weight: 550; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--hover); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.primary:hover { opacity: .88; background: var(--accent); }
.btn.danger { background: var(--loss); border-color: var(--loss); color: #fff; }
.btn.danger:hover { opacity: .88; background: var(--loss); }
.btn.danger-ghost { color: var(--loss); }
.btn.danger-ghost:hover { border-color: var(--loss); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { height: 46px; padding: 0 22px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.icon-only { width: 38px; padding: 0; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--muted); }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.row-gap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; }
.seg button { border: 0; background: transparent; padding: 6px 13px; border-radius: 8px; color: var(--muted); font-weight: 550; display: inline-flex; gap: 6px; align-items: center; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--accent); color: var(--accent-fg); }
.seg.sm button { padding: 4px 9px; font-size: 13px; }
.side-seg { display: flex; }
.side-seg button { flex: 1; justify-content: center; padding: 8px 12px; }
.side-seg button.on.long { background: var(--profit); color: #fff; }
.side-seg button.on.short { background: var(--loss); color: #fff; }

.chip { border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 3px 11px; font-size: 12.5px; font-weight: 550; }
.chip:hover { color: var(--text); border-color: var(--faint); }
.chip.active { color: var(--accent-fg); background: var(--accent); border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }

input, select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); outline: none; transition: border-color .15s;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type=color] { padding: 3px; width: 44px; height: 32px; cursor: pointer; }
input[type=checkbox] { width: auto; height: auto; }
input[type=number]::-webkit-inner-spin-button { opacity: .3; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.card-body .field + .field { margin-top: 14px; }
.lbl { min-height: 22px; font-size: 12.5px; font-weight: 600; color: var(--muted); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lbl em { font-style: normal; font-weight: 400; color: var(--faint); }
.hint { font-size: 12px; color: var(--faint); line-height: 1.35; }
.form-error { padding: 10px 12px; border-radius: 10px; color: var(--loss); background: color-mix(in srgb, var(--loss) 12%, transparent); border: 1px solid color-mix(in srgb, var(--loss) 40%, transparent); font-size: 13.5px; }
.form-row { display: grid; gap: 14px; margin-bottom: 14px; }
.form-row.c2 { grid-template-columns: repeat(2, 1fr); }
.form-row.c3 { grid-template-columns: repeat(3, 1fr); }
.sub-title { margin: 22px 0 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); font-weight: 700; border-top: 1px solid var(--border); padding-top: 16px; }
.pnl-input { font-weight: 700; }
.inline-form { display: flex; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 20px 14px; border-right: 1px solid var(--border); background: var(--bg); display: flex; flex-direction: column; gap: 22px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 16px; padding: 0 8px; }
.brand.big { font-size: 20px; padding: 0; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--muted); font-weight: 550; }
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a.active { background: var(--accent); color: var(--accent-fg); }
.sidebar-foot { margin-top: auto; padding: 0 8px; }
.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: 12px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.spacer { flex: 1; }
.view { padding: 28px; max-width: 1360px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin-top: 4px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.back:hover { color: var(--text); }
.month-title { min-width: 150px; text-align: center; font-weight: 700; font-size: 16px; text-transform: capitalize; }

.dropdown { position: relative; }
.menu { position: absolute; top: calc(100% + 8px); left: 0; min-width: 250px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); z-index: 60; }
.dropdown.right .menu { left: auto; right: 0; }
.menu button, .menu-link { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: transparent; padding: 9px 10px; border-radius: 9px; }
.menu button:hover, .menu-link:hover { background: var(--hover); }
.menu button.on { background: var(--surface-2); font-weight: 650; }
.menu span em { display: block; font-style: normal; font-size: 12px; color: var(--faint); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.menu-title { padding: 8px 10px 4px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); font-weight: 700; }
.menu-user { padding: 8px 10px; display: flex; flex-direction: column; } .menu-user span { color: var(--faint); font-size: 12.5px; }
.dot-c { width: 11px; height: 11px; border-radius: 50%; display: inline-block; flex: none; }
.acc-btn { min-width: 170px; justify-content: space-between; }
.avatar { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-fg); font-weight: 750; }

/* ---------- cards & grids ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 20px 0; }
.card-body { padding: 16px 20px 20px; }
.card.flush { overflow: hidden; }
.card.flush .card-body, .card.flush > .table-wrap { padding: 0; }
.danger-card { border-color: color-mix(in srgb, var(--loss) 40%, var(--border)); }
.grid { display: grid; gap: 20px; margin-bottom: 20px; }
.g-2-1 { grid-template-columns: 2fr 1fr; } .g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-1-2 { grid-template-columns: 1fr 1.6fr; } .g-detail { grid-template-columns: minmax(0, 1.75fr) minmax(300px, 1fr); align-items: start; }
.grid > * { min-width: 0; }
.settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.chart { position: relative; width: 100%; }

.kpi-grid { display: grid; grid-template-columns: 1.35fr repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.kpi-grid.k4 { grid-template-columns: repeat(4, 1fr); margin-bottom: 20px; } .kpi-grid.k5 { grid-template-columns: repeat(5, 1fr); margin-bottom: 20px; }
.kpi { padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; position: relative; overflow: hidden; min-width: 0; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--border); }
.kpi.pos::before { background: var(--profit); } .kpi.neg::before { background: var(--loss); }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 26px; font-weight: 750; letter-spacing: -.02em; margin: 4px 0 2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi.lg .kpi-value { font-size: 32px; }
.kpi-sub { font-size: 12.5px; color: var(--faint); }
.meter { height: 6px; border-radius: 6px; background: var(--grid); margin: 8px 0 6px; overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 6px; background: var(--profit); transition: width .6s; }

.mini-stats { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; margin-bottom: 20px; }
.mini-stats.col { grid-template-columns: 1fr; gap: 6px; margin: 0; }
.mini { padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mini-stats.col .mini { flex-direction: row; justify-content: space-between; align-items: center; }
.mini span { font-size: 12px; color: var(--muted); } .mini b { font-size: 15px; font-variant-numeric: tabular-nums; }
.dayrow { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.dayrow:last-child { border: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; padding: 0; margin: 12px 0 0; justify-content: center; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.legend b { color: var(--text); }
.side-compare { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.side-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.side-row b { font-size: 16px; min-width: 90px; }
.disc { display: grid; grid-template-columns: 170px 1fr; gap: 20px; align-items: center; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; padding: 12px 10px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 700; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table th.num { text-align: right; } .table th.center { text-align: center; }
.table tbody tr:hover { background: var(--hover); }
.table tr.tinted { background: color-mix(in srgb, var(--acc) 8%, transparent); }
.table tr.tinted:hover { background: color-mix(in srgb, var(--acc) 15%, transparent); }
.table tr.tinted td:first-child { box-shadow: inset 4px 0 0 var(--acc); }
.table td.center { text-align: center; }
.acc-badge { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; }
.acc-badge i { width: 10px; height: 10px; border-radius: 3px; }
.side { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.side.long { color: var(--profit); background: color-mix(in srgb, var(--profit) 15%, transparent); }
.side.short { color: var(--loss); background: color-mix(in srgb, var(--loss) 15%, transparent); }
.dot { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; }
.dot.yes { color: var(--profit); background: color-mix(in srgb, var(--profit) 16%, transparent); }
.dot.no { color: var(--loss); background: color-mix(in srgb, var(--loss) 16%, transparent); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px; margin-bottom: 16px; }
.filters input[type=search] { flex: 1 1 220px; width: auto; }
.filters select, .filters input[type=date] { width: auto; }
.quick { display: flex; gap: 6px; margin-left: auto; }
.summary-strip { display: flex; flex-wrap: wrap; gap: 28px; margin: 0 4px 14px; }
.summary-strip div { display: flex; flex-direction: column; } .summary-strip span { font-size: 12px; color: var(--muted); } .summary-strip b { font-size: 18px; }
.empty { text-align: center; padding: 60px 20px; background: var(--surface); border: 1px dashed var(--border); border-radius: 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty.small-empty { padding: 30px; }
.empty-ico { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }

/* ---------- calendar ---------- */
.pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.pill { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; color: var(--muted); }
.pill i { width: 10px; height: 10px; border-radius: 50%; }
.pill em { font-style: normal; font-weight: 400; font-size: 12px; opacity: .7; }
.pill:hover { color: var(--text); border-color: var(--faint); }
.pill.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.pill.on[style] { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--acc); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)) 128px; }
.cal-dow { padding: 12px 10px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 700; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.cal-cell { position: relative; min-height: 104px; padding: 8px 10px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; transition: background .12s; }
.cal-cell.out { background: repeating-linear-gradient(135deg, transparent 0 8px, var(--grid) 8px 9px); opacity: .6; }
.cal-cell:not(.out):hover { background: var(--hover); }
.cal-cell.win { background: color-mix(in srgb, var(--profit) var(--heat), var(--surface)); }
.cal-cell.loss { background: color-mix(in srgb, var(--loss) var(--heat), var(--surface)); }
.cal-cell.flat { background: var(--surface-2); }
.cal-cell.win:hover, .cal-cell.loss:hover { filter: brightness(1.12); }
.cal-cell.today .cal-day { background: var(--accent); color: var(--accent-fg); }
.cal-day { font-size: 12.5px; font-weight: 650; color: var(--muted); width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; margin: -2px 0 0 -4px; }
.cal-pnl { font-size: 16px; font-weight: 750; font-variant-numeric: tabular-nums; margin-top: auto; }
.cal-pnl.pos, .cal-pnl.neg { color: var(--text); }
.cal-n { font-size: 11.5px; color: var(--muted); }
.cal-dots { position: absolute; top: 10px; right: 10px; display: flex; gap: 3px; }
.cal-dots i { width: 8px; height: 8px; border-radius: 50%; }
.cal-week { padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); display: flex; flex-direction: column; gap: 3px; justify-content: center; }
.cal-week b { font-size: 15px; font-variant-numeric: tabular-nums; }
.cal-week.pos b { color: var(--profit); } .cal-week.neg b { color: var(--loss); }
.cal-week-lbl { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); }
.acc-strip { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.acc-chip { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-radius: 12px; background: color-mix(in srgb, var(--acc) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--acc) 45%, var(--border)); }
.acc-chip i { width: 10px; height: 10px; border-radius: 3px; } .acc-chip em { font-style: normal; color: var(--faint); font-size: 12.5px; }

/* ---------- trade detail ---------- */
.trade-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.meta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.result { font-size: 12px; font-weight: 700; padding: 3px 11px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; }
.result.win { color: var(--profit); background: color-mix(in srgb, var(--profit) 15%, transparent); }
.result.loss { color: var(--loss); background: color-mix(in srgb, var(--loss) 15%, transparent); }
.result.be { color: var(--muted); background: var(--surface-2); }
.save-state { font-size: 13px; color: var(--faint); min-width: 90px; text-align: right; }
.save-state.saved { color: var(--profit); } .save-state.error { color: var(--loss); }
.facts { display: grid; grid-template-columns: repeat(9, 1fr); margin-bottom: 20px; padding: 6px 0; }
.facts div { padding: 10px 16px; border-right: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; }
.facts div:last-child { border: 0; }
.facts span { font-size: 11.5px; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; } .facts b { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tip-line { margin-bottom: 14px; display: flex; gap: 8px; align-items: flex-start; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; }
.slot { border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); overflow: hidden; display: flex; flex-direction: column; outline: none; transition: border-color .15s, box-shadow .15s; }
.slot:hover { border-color: var(--faint); }
.slot.active { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.slot.drag { border-color: var(--profit); border-style: dashed; }
.slot.busy { opacity: .55; pointer-events: none; }
.slot-head { display: flex; align-items: center; gap: 6px; padding: 8px; border-bottom: 1px solid var(--border); }
.tf { flex: 1; min-width: 0; font-weight: 700; font-size: 13px; letter-spacing: .02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tf-grip { flex: none; display: flex; align-items: center; padding: 4px; border-radius: 6px; color: var(--faint); cursor: grab; user-select: none; touch-action: none; }
.tf-grip:hover { color: var(--muted); background: var(--hover); }
.tf-grip:active { cursor: grabbing; }
.slot.dragging { opacity: .4; }
.slot.drag-over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.slot-actions { display: flex; gap: 2px; }
.slot-actions button { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.slot-actions button:hover { background: var(--hover); color: var(--text); }
/* Image on the left, its comment on the right — one bordered slot frames both so it's clear which note goes with which screenshot. */
.slot-split { display: flex; align-items: stretch; min-height: 190px; }
.slot-body { flex: 0 0 44%; display: grid; place-items: center; background: var(--surface); border-right: 1px solid var(--border); }
.slot-body img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.slot-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--faint); text-align: center; padding: 10px; }
.slot-empty b { color: var(--muted); font-size: 13px; } .slot-empty span { font-size: 11.5px; }
.slot-comment { flex: 1 1 auto; display: flex; min-width: 0; }
.slot-comment textarea { flex: 1; border: 0; border-radius: 0; background: transparent; resize: none; padding: 10px 12px; font-size: 12.5px; line-height: 1.5; }
.slot-comment textarea:focus { background: var(--hover); }
.add-slot { align-items: center; justify-content: center; gap: 8px; min-height: 190px; border-style: dashed; color: var(--muted); background: transparent; }
.add-slot:hover { color: var(--text); }
@media (max-width: 520px) {
  .slot-split { flex-direction: column; min-height: 0; }
  .slot-body { flex-basis: auto; aspect-ratio: 16 / 10; border-right: 0; border-bottom: 1px solid var(--border); }
  .slot-comment textarea { min-height: 70px; }
}
.notes { min-height: 160px; }
.yesno { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.yesno button { height: 48px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); font-weight: 650; display: inline-flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); }
.yesno button:hover { border-color: var(--faint); color: var(--text); }
.yesno button.on.yes { background: var(--profit); border-color: var(--profit); color: #fff; }
.yesno button.on.no { background: var(--loss); border-color: var(--loss); color: #fff; }
.checks { display: flex; flex-direction: column; gap: 8px; }
.check { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; background: var(--surface-2); transition: background .15s, border-color .15s; user-select: none; }
.check:hover { border-color: var(--faint); }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box { width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--faint); display: grid; place-items: center; color: transparent; flex: none; transition: all .15s; }
.check input:checked + .box { color: #fff; }
.check.good input:checked + .box { background: var(--profit); border-color: var(--profit); }
.check.bad input:checked + .box { background: var(--loss); border-color: var(--loss); }
.check.good:has(input:checked) { background: color-mix(in srgb, var(--profit) 10%, var(--surface-2)); border-color: color-mix(in srgb, var(--profit) 50%, var(--border)); }
.check.bad:has(input:checked) { background: color-mix(in srgb, var(--loss) 10%, var(--surface-2)); border-color: color-mix(in srgb, var(--loss) 50%, var(--border)); }
.check input:focus-visible + .box { outline: 2px solid var(--accent); outline-offset: 2px; }
.stars { display: flex; gap: 2px; }
.star { border: 0; background: transparent; color: var(--faint); padding: 2px; display: inline-flex; }
.star.on { color: #f5b301; } .star.on svg { fill: currentColor; }
button.star:hover { color: #f5b301; }

/* ---------- modal, toast, lightbox ---------- */
.modal-back { position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .65); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 20px; animation: fade .15s; }
.modal { width: 100%; max-width: 480px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); animation: pop .18s; }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.live { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin: 18px 0 4px; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.live-item { display: flex; flex-direction: column; } .live-item span { font-size: 11.5px; color: var(--faint); } .live-item b { font-size: 14px; font-variant-numeric: tabular-nums; }
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(0, 0, 0, .9); display: grid; place-items: center; padding: 30px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.lightbox .icon-btn { position: absolute; top: 16px; right: 16px; color: #fff; }
/* Split view: screenshot on the left, its comment editable on the right. */
.lightbox.split { display: flex; align-items: stretch; padding: 0; cursor: default; }
.lb-image { position: relative; flex: 1 1 60%; min-width: 0; display: grid; place-items: center; padding: 30px; cursor: zoom-out; }
.lb-panel { flex: 0 0 400px; max-width: 42vw; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--border); cursor: default; }
.lb-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 700; }
.lb-head .lb-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-count { flex: none; color: var(--muted); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.lb-head .icon-btn { position: static; flex: none; color: var(--muted); }
.lb-note { flex: 1; border: 0; border-radius: 0; background: transparent; resize: none; padding: 16px; font-size: 14px; line-height: 1.65; }
.lb-note:focus { background: var(--hover); }
.lb-nav { position: absolute; top: 50%; translate: 0 -50%; width: 46px; height: 46px; border-radius: 50%; border: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .45); color: #fff; cursor: pointer; transition: background .15s; }
.lb-nav:hover { background: rgba(0, 0, 0, .7); }
.lb-prev { left: 16px; } .lb-next { right: 16px; }
@media (max-width: 760px) {
  .lightbox.split { flex-direction: column; }
  .lb-image { flex: 1 1 55%; padding: 16px; }
  .lb-panel { flex: 1 1 45%; max-width: none; border-left: 0; border-top: 1px solid var(--border); }
  .lb-nav { width: 38px; height: 38px; }
}
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 11px 16px; border-radius: 12px; background: var(--accent); color: var(--accent-fg); font-weight: 600; box-shadow: var(--shadow); animation: pop .2s; }
.toast.err { background: var(--loss); color: #fff; } .toast.out { opacity: 0; transition: opacity .25s; }
@keyframes fade { from { opacity: 0; } } @keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- settings ---------- */
.acc-list { display: flex; flex-direction: column; gap: 10px; margin: 14px 0 16px; }
.acc-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--acc) 8%, var(--surface-2)); border: 1px solid color-mix(in srgb, var(--acc) 35%, var(--border)); }
.acc-row > i { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.acc-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.swatches { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; }
.swatch.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }

/* ---------- auth ---------- */
.auth { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; }
.auth-side { background: #000; color: #fff; padding: 48px; display: flex; flex-direction: column; gap: 28px; justify-content: center; border-right: 1px solid #222; position: relative; overflow: hidden; }
:root[data-theme="light"] .auth-side { background: #0a0a0a; }
.auth-side h2 { font-size: 36px; max-width: 460px; line-height: 1.15; }
.auth-points { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; color: #d4d4d4; }
.auth-points li { display: flex; gap: 10px; align-items: center; } .auth-points .ico { color: #3ecf8e; }
.auth-preview { display: flex; align-items: flex-end; gap: 10px; height: 130px; max-width: 420px; margin-top: 10px; }
.auth-preview span { flex: 1; border-radius: 6px; background: #3ecf8e; opacity: .85; } .auth-preview span.l { background: #f2545b; }
.auth-main { display: flex; flex-direction: column; padding: 20px; }
.auth-tools { display: flex; justify-content: flex-end; gap: 8px; align-items: center; }
.auth-card { margin: auto; width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 16px; padding: 20px 0; }
.auth-card .switch { text-align: center; color: var(--muted); } .auth-card .switch a { color: var(--text); font-weight: 650; text-decoration: underline; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); } .kpi-grid .kpi.lg { grid-column: span 3; }
  .kpi-grid.k5 { grid-template-columns: repeat(3, 1fr); }
  .mini-stats { grid-template-columns: repeat(4, 1fr); }
  .facts { grid-template-columns: repeat(3, 1fr); } .facts div { border-bottom: 1px solid var(--border); }
}
@media (max-width: 980px) {
  .g-2-1, .g-2, .g-1-2, .g-detail, .settings { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; inset: auto 0 0 0; height: auto; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(12px); }
  .sidebar .brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav a { flex: 1; min-width: 0; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; font-size: 10.5px; text-align: center; }
  .nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar { padding: 10px 14px; flex-wrap: wrap; } .view { padding: 18px 14px 96px; }
  .hide-sm { display: none; }
  .acc-btn { min-width: 0; }
  .kpi-grid, .kpi-grid.k4, .kpi-grid.k5 { grid-template-columns: repeat(2, 1fr); } .kpi-grid .kpi.lg { grid-column: span 2; }
  .mini-stats { grid-template-columns: repeat(2, 1fr); }
  .form-row.c3 { grid-template-columns: repeat(2, 1fr); } .form-row.c2 { grid-template-columns: 1fr; }
  .facts { grid-template-columns: repeat(2, 1fr); }
  .cal-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); } .cal-week, .cal-dow.wk { display: none; }
  .cal-cell { min-height: 74px; padding: 5px 4px; } .cal-pnl { font-size: 9.5px; letter-spacing: -.03em; white-space: nowrap; } .cal-n { display: none; } .cal-dots { display: none; }
  .cal-dow { padding: 8px 2px; text-align: center; font-size: 10px; }
  .auth { grid-template-columns: 1fr; } .auth-side { display: none; }
  .disc { grid-template-columns: 1fr; }
  .quick { margin-left: 0; }
  h1 { font-size: 22px; }
}
@media (max-width: 480px) { .form-row.c3 { grid-template-columns: 1fr; } }

.table th:first-child, .table td:first-child { padding-left: 16px; } .table th:last-child, .table td:last-child { padding-right: 16px; }
.table .seemore-cell { white-space: nowrap; }

/* ---------- add-ons: multi-account entry, account rules, deleting ---------- */
.acc-wrap { display: flex; align-items: center; gap: 8px; }
.add-acc { color: var(--muted); }
.btn.sm.icon-only { width: 30px; padding: 0; }
.mt-s { margin-top: 14px; }
.rules-hint { margin: -4px 0 14px; }

.acc-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.acc-check { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; user-select: none; position: relative; transition: background .15s, border-color .15s; }
.acc-check:hover { border-color: var(--faint); }
.acc-check input { position: absolute; opacity: 0; pointer-events: none; }
.acc-check .box { width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--faint); display: grid; place-items: center; color: transparent; flex: none; transition: all .15s; }
.acc-check input:checked + .box { background: var(--acc); border-color: var(--acc); color: #fff; }
.acc-check:has(input:checked) { background: color-mix(in srgb, var(--acc) 12%, var(--surface-2)); border-color: color-mix(in srgb, var(--acc) 60%, var(--border)); }
.acc-check input:focus-visible + .box { outline: 2px solid var(--accent); outline-offset: 2px; }
.acc-check-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.acc-check-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-check-text em { font-style: normal; font-size: 12px; color: var(--faint); }

.input-unit { display: flex; gap: 6px; align-items: stretch; }
.input-unit input { flex: 1; min-width: 0; }
.input-unit select { width: 84px; flex: none; }
.unit-tag { display: grid; place-items: center; width: 84px; flex: none; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-weight: 600; }

.radios { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.radio { position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); cursor: pointer; }
.radio:hover { border-color: var(--faint); }
.radio em { margin-left: auto; font-style: normal; color: var(--faint); font-size: 13px; }
.radio input { position: absolute; opacity: 0; pointer-events: none; }
.dotr { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--faint); flex: none; display: grid; place-items: center; }
.radio input:checked + .dotr { border-color: var(--accent); }
.radio input:checked + .dotr::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.radio:has(input:checked) { border-color: var(--accent); }
.radio input:focus-visible + .dotr { outline: 2px solid var(--accent); outline-offset: 2px; }
.radio .dot-c { vertical-align: middle; }
.ack { display: flex; align-items: center; gap: 10px; margin-top: 4px; cursor: pointer; }
.ack input { width: 18px; height: 18px; }

.bulkbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--accent); }
.bulkbar b { margin-right: auto; }
th.sel, td.sel { width: 40px; padding-right: 0 !important; }
.sel input { width: 16px; height: 16px; cursor: pointer; }

.rules-balance { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.rules-balance b { font-size: 22px; font-variant-numeric: tabular-nums; }
.rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px 28px; }
.rule-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.rule-head span { color: var(--muted); } .rule-head b { font-variant-numeric: tabular-nums; }
.rules-card { margin-bottom: 20px; }
.meter.warn i { background: #f5b301; } .meter.bad i { background: var(--loss); }
.acc-info span + span { margin-top: 1px; }

/* ---------- CSV import wizard ---------- */
.import-drop { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 40px 20px; border: 1.5px dashed var(--border); border-radius: 14px; color: var(--muted); cursor: pointer; text-align: center; transition: border-color .15s, background .15s; }
.import-drop:hover, .import-drop:focus-visible { border-color: var(--accent); background: var(--surface-2); }
.import-drop.drag { border-color: var(--profit); background: color-mix(in srgb, var(--profit) 8%, transparent); }
.import-drop b { color: var(--text); font-size: 15px; }
.import-or { text-align: center; margin: 16px 0 10px; color: var(--faint); font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; }
#pasteArea { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }

.import-opts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.check-inline { flex-direction: row; align-items: center; gap: 8px; justify-content: flex-start; }
.check-inline input { width: 16px; height: 16px; flex: none; }
.check-inline span { font-size: 13px; color: var(--muted); }
.map-scroll { max-height: 260px; overflow-y: auto; margin-bottom: 4px; }
.map-table th, .map-table td { padding: 8px 12px; }
.map-table select { height: 34px; }
.trunc { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.side-map, .acc-map { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.side-map-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.side-seg.sm button { padding: 5px 12px; font-size: 12.5px; }
.acc-map-row { display: grid; grid-template-columns: 1fr 170px 1fr; gap: 10px; align-items: center; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.acc-map-row select, .acc-map-row input { height: 34px; }

.import-summary { display: flex; gap: 14px; margin-bottom: 16px; }
.import-summary .kpi { flex: 1; padding: 12px 16px; }
.import-issues { margin: 8px 0 0; padding-left: 20px; color: var(--muted); font-size: 13px; }
.import-issues li { margin-bottom: 4px; }
.import-progress { margin-top: 14px; }
.import-progress .meter { margin-bottom: 6px; }
.import-done { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 30px 10px; text-align: center; color: var(--profit); }
.import-done h3 { color: var(--text); font-size: 18px; }
