:root {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321; --border: rgba(255,255,255,.10);
  --text: #f0efec; --text-2: #c3c2b7; --muted: #898781; --grid: #2c2c2a; --axis: #383835;
  --series: #3987e5; --series-wash: rgba(57,135,229,.14);
  --good: #0ca30c; --bad: #d03b3b; --good-text: #2fbf2f; --bad-text: #e66767;
  --good-wash: rgba(12,163,12,.16); --bad-wash: rgba(208,59,59,.18);
  --warn: #fab219; --accent: #3987e5; --accent-ink: #fff;
}
:root[data-theme="light"] {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --surface-2: #f0efec; --border: rgba(11,11,11,.10);
  --text: #0b0b0b; --text-2: #52514e; --muted: #898781; --grid: #e1e0d9; --axis: #c3c2b7;
  --series: #2a78d6; --series-wash: rgba(42,120,214,.12);
  --good: #0ca30c; --bad: #d03b3b; --good-text: #006300; --bad-text: #b02a2a;
  --good-wash: rgba(12,163,12,.12); --bad-wash: rgba(208,59,59,.12);
  --accent: #2a78d6;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--page); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 20px; margin: 0; font-weight: 650; }
h2 { font-size: 14px; margin: 0 0 12px; font-weight: 600; color: var(--text-2); }
h3 { font-size: 13px; margin: 0 0 8px; font-weight: 600; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.pos { color: var(--good-text); } .neg { color: var(--bad-text); }
.num { font-variant-numeric: tabular-nums; }

#app { display: grid; grid-template-columns: 216px 1fr; min-height: 100%; }
nav { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 10px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; }
.brand { font-weight: 700; font-size: 16px; padding: 4px 10px 16px; letter-spacing: .2px; }
.brand span { color: var(--accent); }
nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
nav a:hover { background: var(--surface-2); color: var(--text); }
nav a.on { background: var(--series-wash); color: var(--text); }
nav a svg { width: 17px; height: 17px; flex: none; }
nav .spacer { flex: 1; }
main { padding: 18px 24px 60px; min-width: 0; }
.top { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.top h1 { margin-right: auto; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

select, input, textarea, button { font: inherit; color: var(--text); }
select, input[type=text], input[type=number], input[type=date], input[type=password], input[type=datetime-local], input[type=file], textarea {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; min-width: 0; }
textarea { width: 100%; resize: vertical; min-height: 84px; line-height: 1.5; }
select:focus, input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button, .btn { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px; cursor: pointer; font-weight: 550; color: var(--text); display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
button.buy { background: var(--good); border-color: transparent; color: #fff; }
button.sell { background: var(--bad); border-color: transparent; color: #fff; }
button.ghost { background: transparent; }
button.danger { color: var(--bad-text); }
button:disabled { opacity: .45; cursor: not-allowed; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; min-width: 0; }
.grid { display: grid; gap: 14px; }
.tiles { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.g3 { grid-template-columns: minmax(260px, 1fr) minmax(0, 2fr); }
.gdetail { grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr); align-items: start; }
.tile .k { font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.tile .v { font-size: 24px; font-weight: 650; letter-spacing: -.3px; }
.tile .s { font-size: 12px; color: var(--muted); margin-top: 4px; }
.meter { height: 6px; border-radius: 3px; background: var(--bad-wash); overflow: hidden; margin-top: 8px; display: flex; gap: 2px; }
.meter i { display: block; background: var(--good); border-radius: 3px; }
.meter i.l { background: var(--bad); flex: 1; }
.mt { margin-top: 14px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 550; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--surface-2); }
.tablewrap { overflow-x: auto; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.pill.long { color: var(--good-text); } .pill.short { color: var(--bad-text); }
.pill.g-Ap { background: var(--good-wash); color: var(--good-text); border-color: transparent; }
.pill.g-A { background: var(--series-wash); color: var(--text); border-color: transparent; }
.pill.g-C { background: var(--bad-wash); color: var(--bad-text); border-color: transparent; }
.pill.mistake { color: var(--bad-text); }
.pill button { all: unset; cursor: pointer; margin-left: 4px; opacity: .6; }
.bar-cell { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.bar-cell i { height: 6px; border-radius: 3px; display: block; min-width: 2px; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr) 0.9fr; gap: 4px; }
.cal .hd { font-size: 11px; color: var(--muted); text-align: center; padding: 2px 0; }
.cal .d { min-height: 62px; border-radius: 8px; padding: 6px; background: var(--surface-2); font-size: 11px; display: flex; flex-direction: column; gap: 1px; border: 1px solid transparent; }
.cal .d.out { background: transparent; }
.cal .d.w { background: var(--good-wash); cursor: pointer; } .cal .d.l { background: var(--bad-wash); cursor: pointer; }
.cal .d.wk { background: transparent; border-color: var(--border); }
.cal .d:hover.w, .cal .d:hover.l { border-color: var(--muted); }
.cal .d b { font-size: 12.5px; font-variant-numeric: tabular-nums; }
.cal .d .n { color: var(--muted); }

.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
#tip { position: fixed; z-index: 50; pointer-events: none; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font-size: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.35); display: none; max-width: 260px; }
#tip b { display: block; font-size: 13px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button.on { background: var(--series-wash); border-color: var(--accent); }
.candles { height: 440px; width: 100%; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.kv div { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--grid); padding-bottom: 5px; }
.kv span { color: var(--text-2); }
.check { display: flex; gap: 9px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--good); flex: none; }
.stars button { all: unset; cursor: pointer; font-size: 20px; color: var(--axis); padding: 0 1px; }
.stars button.on { color: var(--warn); }
.shots { display: flex; flex-wrap: wrap; gap: 8px; }
.shots div { position: relative; }
.shots img { height: 96px; border-radius: 8px; border: 1px solid var(--border); display: block; }
.shots button { position: absolute; top: 3px; right: 3px; padding: 0 6px; }
.empty { text-align: center; padding: 40px 16px; color: var(--text-2); }
.empty h2 { color: var(--text); font-size: 17px; }
.banner { background: var(--series-wash); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.banner.warn { background: rgba(250,178,25,.12); }
code, pre { font: 12.5px ui-monospace, Menlo, Consolas, monospace; background: var(--surface-2); border-radius: 6px; }
code { padding: 1px 5px; word-break: break-all; }
pre { padding: 10px 12px; overflow-x: auto; margin: 8px 0; border: 1px solid var(--border); }
ol.steps { padding-left: 20px; margin: 8px 0; } ol.steps li { margin-bottom: 6px; }
dialog { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 20px; width: min(560px, 94vw); }
dialog::backdrop { background: rgba(0,0,0,.55); }
.formgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.formgrid .wide { grid-column: 1 / -1; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--border); padding: 9px 16px; border-radius: 10px; display: none; z-index: 60; box-shadow: 0 6px 20px rgba(0,0,0,.35); }
#toast.err { border-color: var(--bad); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login form { width: min(340px, 100%); display: flex; flex-direction: column; gap: 12px; }
.cond { display: inline-flex; gap: 5px; align-items: center; margin: 2px 4px 2px 0; }
.btbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; }
  nav { position: sticky; height: auto; flex-direction: row; overflow-x: auto; padding: 8px; z-index: 20; border-right: 0; border-bottom: 1px solid var(--border); }
  nav .brand, nav .spacer { display: none; }
  nav a { white-space: nowrap; padding: 7px 10px; }
  main { padding: 14px 12px 60px; }
  .g2, .g3, .gdetail { grid-template-columns: 1fr; }
  .candles { height: 340px; }
  .cal .d { min-height: 50px; padding: 4px; } .cal .d .n { display: none; }
}
