:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f1f3f6; --border: #e3e6ec; --text: #14181f; --muted: #667085;
  --accent: #047857; --accent-btn: #047857; --brand: #059669; --k-stem: #374151; --pos: #15803d; --neg: #c62828; --pos-bg: #16a34a; --neg-bg: #dc2626; --warn: #b45309;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --radius: 12px;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218; --surface: #171b23; --surface-2: #1e232d; --border: #2a303c; --text: #e8ebf0; --muted: #8b93a3;
    --accent: #34d399; --accent-btn: #047857; --brand: #34d399; --k-stem: #e5e7eb; --pos: #4ade80; --neg: #f87171; --pos-bg: #22c55e; --neg-bg: #ef4444; --warn: #fbbf24;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 18px; } h3 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.section-title { font-size: 16px; margin-bottom: 0; }
a { color: var(--accent); }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .strong { font-weight: 600; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .flat { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.app { max-width: none; margin: 0; padding: 0 clamp(12px, 1.6vw, 28px) 40px; min-height: 100vh; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 14px 0; flex-wrap: wrap; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); border-radius: 10px; padding: 2px 6px 2px 2px; }
.brand:hover .wm-text { filter: brightness(1.18); }
.brand-text { display: grid; line-height: 1.1; }
.wordmark { font-family: "Avenir Next", "Helvetica Neue", Arial, sans-serif; font-size: 30px; letter-spacing: -.02em; line-height: 1; white-space: nowrap; }
.wm-a { font-weight: 300; color: var(--text); }
.wm-b { font-weight: 800; color: var(--brand); }
.brand-text small { margin-top: 3px; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
.logo { display: block; flex: none; }
.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.tabs a { padding: 7px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; }
.tabs a:hover { background: var(--surface-2); color: var(--text); }
.tabs a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); border: 1px solid var(--border); padding: 6px 11px; }
.topright { display: flex; align-items: center; gap: 12px; }
.filters { display: flex; gap: 8px; }
.save-status { font-size: 12px; color: var(--muted); min-width: 90px; text-align: right; }
.save-status.error { color: var(--neg); font-weight: 600; }

main .page { display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card > * + * { margin-top: 12px; }
.card > h2 + p, .card > h3 + p { margin-top: 6px; }
.empty-state { text-align: center; padding: 48px 16px; display: grid; gap: 12px; justify-items: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.block { display: grid; gap: 4px; }

button, .button, select, input[type=text], input[type=search], textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 11px;
}
button, .button { cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button:hover:not(:disabled), .button:hover { background: var(--surface-2); }
button:disabled { opacity: .5; cursor: default; }
button.primary, .button.primary { background: var(--accent-btn); border-color: var(--accent-btn); color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled), .button.primary:hover { background: var(--accent-btn); filter: brightness(1.15); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
button.small { padding: 3px 8px; font-size: 12px; }
button.danger { color: var(--neg); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
textarea, input[type=text], input[type=search] { width: 100%; }
textarea { resize: vertical; }
.search { max-width: 280px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }

/* stat cards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; overflow-wrap: anywhere; }
.stat-value.small { font-size: 16px; }
.stat .small { font-size: 12.5px; }

/* calendar */
.cal-head { display: flex; align-items: center; gap: 8px; }
.cal-head h2 { flex: 1; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)) minmax(88px, .9fr); gap: 6px; }
.week-col .cal-pnl { font-size: 14px; }
.cal-dow { text-align: center; font-size: 12px; color: var(--muted); padding: 2px 0; }
.cal-cell {
  min-height: clamp(76px, 11vh, 120px); border-radius: 10px; border: 1px solid var(--border); background: var(--surface); padding: 6px 8px;
  display: flex; flex-direction: column; gap: 2px; text-align: left; align-items: flex-start; font: inherit; color: inherit;
}
.cal-cell.empty { background: transparent; border-color: transparent; }
.cal-cell.weekend { background: var(--surface-2); }
.cal-cell.empty.weekend { background: transparent; }
.cal-cell:disabled { cursor: default; opacity: 1; }
.cal-cell.has.pos { background: color-mix(in srgb, var(--pos-bg) var(--heat, 20%), var(--surface)); border-color: color-mix(in srgb, var(--pos-bg) 45%, var(--border)); }
.cal-cell.has.neg { background: color-mix(in srgb, var(--neg-bg) var(--heat, 20%), var(--surface)); border-color: color-mix(in srgb, var(--neg-bg) 45%, var(--border)); }
.cal-cell.has { cursor: pointer; }
.cal-cell.has:hover { filter: brightness(1.04); border-color: var(--accent); }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-cell.selected { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-cell.week-col { background: transparent; border-style: dashed; cursor: default; }
.cal-num { font-size: 12px; color: var(--muted); }
.cal-pnl { font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums; }
.cal-sub { font-size: 12px; color: var(--muted); }
.week-col.cal-dow { color: var(--muted); }

/* day detail */
.day-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; }
.day-head > :first-child { flex: 1; }
.day-net { text-align: right; }
.big { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-box { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.chart-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }

/* tables */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface); position: sticky; top: 0; }
.tbl .num { text-align: right; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sorted { color: var(--text); }
.trade-row { cursor: pointer; }
.trade-row:hover { background: var(--surface-2); }
.tbl tr.dim { opacity: .5; }
.note-grid { display: grid; gap: 8px; padding: 6px 0; }
.note-grid label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.note-row td { background: var(--surface-2); white-space: normal; }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; margin-left: 6px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); }
.badge.tag { color: var(--accent); }
.warnings { margin: 0; padding-left: 18px; color: var(--muted); }
.plain { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 6px; }

/* charts */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 540px), 1fr)); gap: 16px; }
.chart-card.wide { grid-column: 1 / -1; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .zero { stroke: var(--muted); stroke-width: 1; opacity: .6; }
.chart .ax-label { fill: var(--muted); font-size: 12.5px; }
.chart .ax-label.strong { fill: var(--text); }
.chart .bar-pos { fill: var(--pos-bg); } .chart .bar-neg { fill: var(--neg-bg); }
.chart .line { stroke: var(--accent); stroke-width: 2; }
.chart .line.pos { stroke: var(--pos-bg); } .chart .line.neg { stroke: var(--neg-bg); }
.chart .area { fill: var(--accent); opacity: .12; stroke: none; }
.chart .area.pos { fill: var(--pos-bg); } .chart .area.neg { fill: var(--neg-bg); }
.chart .dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart .dot.pos { stroke: var(--pos-bg); } .chart .dot.neg { stroke: var(--neg-bg); }
.chart .dot-pos { fill: var(--pos-bg); opacity: .75; } .chart .dot-neg { fill: var(--neg-bg); opacity: .75; }
.chart rect:hover, .chart circle:hover { filter: brightness(1.15); }

/* import */
.drop { display: grid; gap: 4px; text-align: center; padding: 28px 16px; border: 2px dashed var(--border); border-radius: 12px; cursor: pointer; background: var(--surface-2); }
.drop:hover, .drop.over { border-color: var(--accent); }
.opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.opts label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.notice { padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); font-size: 13px; }
.notice.ok { border-color: color-mix(in srgb, var(--pos-bg) 50%, var(--border)); }
.notice.warn { border-color: color-mix(in srgb, var(--warn) 55%, var(--border)); }
.notice.error { border-color: color-mix(in srgb, var(--neg-bg) 55%, var(--border)); color: var(--neg); }
.toast { position: fixed; right: 16px; bottom: 16px; z-index: 10; padding: 10px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 6px 24px rgba(0,0,0,.2); display: flex; gap: 8px; align-items: center; max-width: 420px; }
.toast.error { border-color: var(--neg); }
.toast.ok { border-color: var(--pos-bg); }

@media (max-width: 700px) {
  .cal-cell { min-height: 62px; padding: 4px 5px; }
  .cal-pnl { font-size: 12px; } .cal-sub { display: none; }
  .cal-grid { gap: 3px; grid-template-columns: repeat(7, minmax(0, 1fr)) minmax(46px, .9fr); }
  .day-head { flex-wrap: wrap; }
}

/* ---- home: stats, then calendar, then day view (full width, stacked) ---- */
.day-detail { scroll-margin-top: 84px; }
.day-detail h2 { display: flex; align-items: center; gap: 8px; }
.day-detail .badge { margin-left: 0; }
.day-detail.placeholder { text-align: center; padding: 48px 16px; }
.stats.tight { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stats.tight .stat-value { font-size: 21px; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 12px; }
.chart-grid > * { margin-top: 0; }

/* ---- strategy picker + chips ---- */
.strat-select { padding: 3px 6px; font-size: 12px; max-width: 170px; color: var(--muted); border-style: dashed; }
.strat-select.tagged { color: var(--accent); border-style: solid; font-weight: 600; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px 4px 3px 12px; }
.chip button { padding: 1px 6px; }

/* ---- time-axis chart: session shading + markers ---- */
.chart .band-pre { fill: #818cf8; opacity: .14; }
.chart .band-reg { fill: var(--pos-bg); opacity: .045; }
.chart .band-post { fill: #f59e0b; opacity: .14; }
.chart .band-label { font-size: 12px; font-weight: 600; opacity: 1; }
.chart text.band-pre { fill: #818cf8; opacity: 1; } .chart text.band-reg { fill: var(--pos); opacity: .9; } .chart text.band-post { fill: #f59e0b; opacity: 1; }
.chart .mk { stroke-width: 1.6; stroke-dasharray: 5 4; }
.chart .mk-open { stroke: var(--pos-bg); } .chart .mk-close { stroke: var(--neg-bg); }
.chart text.mk-label { font-size: 12px; font-weight: 600; }
.chart text.mk-open { fill: var(--pos); } .chart text.mk-close { fill: var(--neg); }
.chart .ax-label.val { font-weight: 600; } .chart .ax-label.val.pos { fill: var(--pos); } .chart .ax-label.val.neg { fill: var(--neg); }
.time-row { display: flex; gap: 16px; align-items: end; flex-wrap: wrap; }
.time-row label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.time-row input[type=time] { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; }

/* ---- broker badges ---- */
.broker-label { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.broker-badge { display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: 6px; color: #fff; font-weight: 700; font-family: "Avenir Next", "Helvetica Neue", Arial, sans-serif; line-height: 1; letter-spacing: -.02em; }
.acct { margin-top: 1px; }
.filters { flex-wrap: wrap; justify-content: flex-end; }

.filterbar { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; flex-wrap: wrap; }
.filterbar .filters { justify-content: flex-start; }

/* ---- header spacing, clock, filter bar ---- */
.topbar { border-bottom: 1px solid var(--border); margin-bottom: 14px; padding: 12px 0; }
.filterbar { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px 14px; margin: 0 0 18px; }
.filterbar > .small { text-transform: uppercase; letter-spacing: .1em; font-size: 11px; }
.clock { display: flex; align-items: center; gap: 10px; text-align: right; line-height: 1.2; }
.clock-date { font-size: 12.5px; color: var(--muted); }
.clock-time { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 14px; }
.mkt { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap; }
.mkt.open { color: var(--pos); border-color: color-mix(in srgb, var(--pos-bg) 55%, var(--border)); background: color-mix(in srgb, var(--pos-bg) 12%, transparent); }
.mkt.ext { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, var(--border)); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.mkt.closed { color: var(--muted); }
.topright { gap: 16px; }

/* ---- win/loss bars, two-column lists ---- */
.wl { display: flex; height: 22px; min-width: 130px; border-radius: 6px; overflow: hidden; background: var(--surface-2); font-size: 12px; font-weight: 600; }
.wl .w { background: var(--pos-bg); color: #fff; display: flex; align-items: center; justify-content: center; }
.wl .l { background: var(--neg-bg); color: #fff; display: flex; align-items: center; justify-content: center; }
.wl .f { background: var(--muted); }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; }
.two-col h4 { margin: 0 0 6px; font-size: 14px; }

/* ---- hold-time distribution ---- */
.stack { display: grid; gap: 14px; }
.chart .box-iqr { fill: var(--accent); fill-opacity: .13; stroke: var(--accent); stroke-width: 1; }
.chart .box-med { stroke: var(--text); stroke-width: 2.2; }
.chart .dot-out { fill: none; stroke: var(--muted); stroke-width: 1; }

/* ---- trades: year / month / day navigation + pager ---- */
.nav-block { display: grid; gap: 12px; }
.nav-block.dim { opacity: .45; }
.nav-row { display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: start; }
.nav-label { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding-top: 10px; }
.nav-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.nav-chip { display: grid; gap: 1px; text-align: left; padding: 7px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); min-width: 92px; }
.nav-chip:hover:not(.empty) { background: var(--surface-2); }
.nav-chip.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); box-shadow: inset 0 0 0 1px var(--accent); }
.nav-chip.empty { opacity: .35; cursor: default; background: transparent; border-style: dashed; }
.nc-label { font-weight: 650; font-size: 14px; }
.nc-sub { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.nc-count { font-size: 11.5px; }
.pager { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; }
.pager-btns { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.pager select { padding: 4px 8px; font-size: 13px; }
details > summary { cursor: pointer; }
@media (max-width: 700px) { .nav-row { grid-template-columns: 1fr; } .nav-label { padding-top: 0; } }

/* ---- wordmark: logo tile + name ---- */
.wm-text { overflow: visible; }
.wm-text text { font-family: Arial, Helvetica, sans-serif; font-weight: 700; }
.brand { gap: 12px; }
.wordmark, .logo { flex: none; }

/* ---- header layout: brand + tabs left, market badge centered, date/time right ---- */
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; }
.tb-left { display: flex; align-items: center; gap: 16px; min-width: 0; flex-wrap: wrap; }
.tb-center { display: flex; justify-content: center; }
.topright { justify-self: end; display: flex; align-items: center; gap: 16px; }
.clock { display: block; text-align: right; }
@media (max-width: 1180px) {
  .topbar { grid-template-columns: 1fr auto; }
  .tb-center { grid-column: 1 / -1; grid-row: 2; }
}

/* ---- market badge with countdown ---- */
.mkt { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; font-variant-numeric: tabular-nums; }
.mkt-dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: none; }
.mkt-sep { opacity: .5; }
.mkt-time { font-weight: 500; }
.mkt.open { color: var(--pos); background: color-mix(in srgb, var(--pos-bg) 20%, var(--surface)); border-color: color-mix(in srgb, var(--pos-bg) 60%, var(--border)); }
.mkt.open .mkt-dot { animation: mktPulse 2s ease-in-out infinite; }
.mkt.pre, .mkt.after { color: var(--warn); background: color-mix(in srgb, var(--warn) 17%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 55%, var(--border)); }
.mkt.closed { color: var(--neg); background: color-mix(in srgb, var(--neg-bg) 15%, var(--surface)); border-color: color-mix(in srgb, var(--neg-bg) 50%, var(--border)); }
@keyframes mktPulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .mkt.open .mkt-dot { animation: none; } }
.topbar { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
.tb-left { flex-wrap: nowrap; }
.tb-left .tabs { flex: none; flex-wrap: nowrap; }
@media (max-width: 1360px) {
  .topbar { grid-template-columns: 1fr auto; }
  .tb-left { flex-wrap: wrap; }
  .tb-center { grid-column: 1 / -1; grid-row: 2; }
}

/* clock flush with the right page padding, like the logo on the left */
.save-status { min-width: 0; }
.save-status:empty { display: none; }
.topright { padding: 0; margin: 0; }
.clock { padding: 0; margin: 0; }

/* share buttons */
.share-btns { display: inline-flex; gap: 6px; }
.share-cell { width: 1%; white-space: nowrap; }

.share-modal { position: fixed; inset: 0; z-index: 50; background: rgba(2, 6, 12, .72); display: grid; place-items: center; padding: 20px; overflow: auto; }
.share-modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; display: grid; gap: 12px; max-width: min(96vw, 900px); }
.share-img { width: 100%; height: auto; border-radius: 8px; display: block; }

.icon-btn { width: 32px; height: 32px; padding: 0; justify-content: center; line-height: 0; flex: none; }
.icon-btn svg { display: block; }

/* ---- executions list + outcome chips ---- */
.executions { display: grid; gap: 8px; }
.executions h3 { margin: 0; }
.badge.st-open { color: var(--pos); border-color: color-mix(in srgb, var(--pos-bg) 55%, var(--border)); background: color-mix(in srgb, var(--pos-bg) 10%, transparent); margin-left: 0; margin-right: 4px; }
.badge.st-closed, .badge.st-expired { margin-left: 0; margin-right: 4px; }
.badge.st-unmatched { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 55%, var(--border)); background: color-mix(in srgb, var(--warn) 10%, transparent); margin-left: 0; margin-right: 4px; }
.cal-cell.has.act { border-style: dashed; cursor: pointer; }
.cal-cell.has.act:hover { border-color: var(--accent); }
.opened { display: grid; gap: 8px; }
.opened h3 { margin: 0; }

/* multi-tag input */
.field { display: grid; gap: 4px; }
.field-label { font-size: 12px; color: var(--muted); }
.tag-input { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 5px 8px; min-height: 36px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: text; }
.tag-input:focus-within { border-color: var(--accent); }
.tag-input .chips { display: contents; }
.tag-input .tag-text { flex: 1 1 120px; min-width: 100px; border: 0; outline: 0; background: transparent; color: inherit; padding: 3px 2px; font: inherit; }
.chip { display: inline-flex; align-items: center; gap: 4px; }
.chip-x { border: 0; background: transparent; color: inherit; cursor: pointer; padding: 0 2px; font-size: 14px; line-height: 1; opacity: .7; }
.chip-x:hover { opacity: 1; }
.tag-menu { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; display: flex; flex-wrap: wrap; gap: 6px; padding: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.tag-opt { border: 1px solid var(--border); background: transparent; color: var(--accent); border-radius: 999px; padding: 3px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.tag-opt:hover { background: var(--surface-2); border-color: var(--accent); }
.tag-opt.new { color: inherit; border-style: dashed; }
.row-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

/* zoom */
.card.zoomable { position: relative; }
.zoom-btn { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  font-size: 15px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity .12s; margin: 0 !important; }
.card.zoomable:hover .zoom-btn, .zoom-btn:focus-visible { opacity: 1; }
.zoom-btn:hover { color: var(--accent); border-color: var(--accent); }
@media (hover: none) { .zoom-btn { opacity: .8; } }
.zoom-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(2, 6, 12, .78); overflow: auto; padding: 12px; display: grid; place-items: start center; }
.zoom-box { width: min(1800px, 100%); position: relative; }
.zoom-close { position: sticky; top: 0; float: right; z-index: 2; margin: 0 0 8px 8px; }
.card.zoomed { font-size: 1.3em; padding: 20px; clear: both; }
.card.zoomed svg { width: 100%; height: auto; max-height: 80vh; }
.card.zoomed .zoom-btn { display: none; }

/* trade review: right / wrong */
.review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 760px) { .review-grid { grid-template-columns: 1fr; } }
.field.right .tag-input:focus-within { border-color: var(--pos); }
.field.wrong .tag-input:focus-within { border-color: var(--neg); }
.field.right .field-label { color: var(--pos); } .field.wrong .field-label { color: var(--neg); }
.badge.right { color: var(--pos); border-color: color-mix(in srgb, var(--pos) 45%, transparent); }
.badge.wrong { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 45%, transparent); }
.field.right .tag-opt { color: var(--pos); } .field.wrong .tag-opt { color: var(--neg); }

/* calendar navigation and cells */
.cal-head { gap: 10px; flex-wrap: wrap; }
.cal-title { flex: 1; display: flex; gap: 8px; justify-content: center; min-width: 200px; }
.cal-select { font-size: 18px; font-weight: 650; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
.cal-select:hover { border-color: var(--accent); }
.cal-nav { font-size: 15px; font-weight: 600; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
.cal-nav:hover { border-color: var(--accent); color: var(--accent); }
.cal-today { font-size: 15px; font-weight: 700; padding: 9px 18px; border-radius: 10px; border: 0; background: var(--accent-btn); color: #fff; cursor: pointer; }
.cal-today:hover { filter: brightness(1.12); }
.year-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 12px; }
.year-label { font-size: 16px; padding: 0 6px; }
.year-step, .month-chip { font: inherit; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
.year-step:hover, .month-chip:hover { border-color: var(--accent); }
.month-chip.pos { color: var(--pos); } .month-chip.neg { color: var(--neg); }
.month-chip.on { background: var(--accent-btn); border-color: var(--accent-btn); color: #fff; }
.cal-today-tag { position: absolute; top: 6px; right: 6px; font-size: 10px; font-weight: 800; letter-spacing: .06em; padding: 2px 7px; border-radius: 999px; background: var(--accent-btn); color: #fff; }
.cal-cell { position: relative; }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--accent-btn); }
.cal-wl { display: flex; gap: 8px; font-size: 13px; font-weight: 700; margin-top: auto; }
.badge.today-badge { background: var(--accent-btn); border-color: var(--accent-btn); color: #fff; font-size: 12px; font-weight: 800; letter-spacing: .06em; padding: 3px 10px; margin-left: 10px; vertical-align: middle; }
.tag-menu { max-height: 190px; overflow: auto; }
@media (max-width: 760px) { .cal-wl { font-size: 10px; gap: 4px; } .cal-today-tag { display: none; } .cal-nav { padding: 8px 10px; } }

.big-pct { font-size: .55em; font-weight: 650; margin-left: 10px; opacity: .9; }

/* ---- modal dialog ---- */
.dlg { border: 1px solid var(--border); border-radius: 14px; padding: 20px; background: var(--surface); color: var(--text); width: min(92vw, 420px); }
.dlg::backdrop { background: rgba(2, 6, 12, .6); }
.dlg form { display: grid; gap: 12px; }
.dlg h3 { margin: 0; }
.dlg label.block { display: grid; gap: 4px; }
.dlg input { width: 100%; box-sizing: border-box; }
.dlg-actions { justify-content: flex-end; margin-top: 4px; }
.dlg-text { margin: 0; line-height: 1.45; }
.dlg-help { display: grid; gap: 6px; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; font-size: 13px; line-height: 1.4; }
.dlg-help p { margin: 0; }
.dlg-examples { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-btn { border-radius: 999px; padding: 2px 10px; font-size: 12.5px; }
.dlg-preview { font-size: 13px; color: var(--muted); }
button.danger:not(.ghost) { background: var(--neg); color: #fff; border-color: var(--neg); }
button.danger:not(.ghost):hover:not(:disabled) { filter: brightness(1.1); background: var(--neg); }
.dlg { width: min(92vw, 460px); }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chart-head > h3, .chart-head > .chart-title { margin: 0; }
.chart-head .chart-copy { width: 28px; height: 28px; opacity: .55; }
.chart-card:hover .chart-copy, .chart-box:hover .chart-copy, .chart-copy:focus-visible { opacity: 1; }
.card.zoomable > .chart-head { padding-right: 36px; } /* keep the copy icon clear of the zoom button in the corner */

/* ---- sign in ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.login-card { width: min(100%, 420px); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px 24px; display: grid; gap: 14px; }
.login-brand { display: flex; justify-content: center; }
.login-tag { text-align: center; margin: 0; }
.login-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; }
.login-tabs button { border: 0; background: transparent; padding: 8px; border-radius: 8px; }
.login-tabs button.active { background: var(--surface); box-shadow: 0 0 0 1px var(--border); font-weight: 600; }
.login-form { display: grid; gap: 12px; }
.login-field { display: grid; gap: 4px; }
.login-label { font-size: 12.5px; color: var(--muted); }
.login-input { width: 100%; box-sizing: border-box; padding: 10px 12px; font-size: 16px; }
.login-submit { padding: 10px 14px; font-size: 15px; justify-content: center; }
.login-lead { margin: 0; line-height: 1.45; }
.login-links { display: flex; justify-content: space-between; gap: 8px; }
button.link { border: 0; background: none; color: var(--accent); padding: 4px 0; text-decoration: underline; cursor: pointer; }
button.link:disabled { opacity: .5; cursor: default; }
.login-msg { padding: 10px 12px; border-radius: 10px; font-size: 14px; line-height: 1.4; }
.login-msg.error { background: var(--neg-bg, rgba(239, 68, 68, .15)); color: var(--neg); }
/* header: signed-in user */
.clock-user { display: flex; align-items: center; justify-content: flex-end; gap: 10px; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.clock-user .who-box { text-align: right; line-height: 1.25; min-width: 0; }
.clock-user .who { color: var(--text); font-weight: 600; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clock-user .who-sub { font-size: 12px; color: var(--muted); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clock-user .who-bar { align-self: stretch; width: 1px; background: var(--border); margin: 2px 0; }
.clock-user button { padding: 2px 8px; font-size: 12.5px; }
