:root {
  --surface-1: #f5f4ef; --surface-2: #ffffff; --page: #fbfaf7;
  --text-primary: #1a1a19; --text-secondary: #52514e; --text-muted: #898781;
  --border: rgba(11, 11, 11, .12); --border-strong: rgba(11, 11, 11, .25);
  --radius: 8px;
  --bg-warning: #faeeda; --text-warning: #854f0b;
  --bg-ok: #eaf3de; --text-ok: #3b6d11;
  --text-accent: #185fa5; --bg-accent: #e6f1fb;
  --neg: #e34948; --pos: #2a78d6;
  --chart-basket: #2a78d6; --chart-sp500: #eb6834; --chart-r3000: #1baf7a;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface-1: #242423; --surface-2: #1c1c1b; --page: #161615;
    --text-primary: #f2f1ea; --text-secondary: #c3c2b7; --text-muted: #898781;
    --border: rgba(255, 255, 255, .12); --border-strong: rgba(255, 255, 255, .28);
    --bg-warning: #412402; --text-warning: #fac775;
    --bg-ok: #1c2b10; --text-ok: #97c459;
    --text-accent: #85b7eb; --bg-accent: #0c2c47;
    --neg: #e66767; --pos: #3987e5;
    --chart-basket: #3987e5; --chart-sp500: #f0997b; --chart-r3000: #5dcaa5;
  }
}
* { box-sizing: border-box; }
body {
  font-family: system-ui, -apple-system, sans-serif; color: var(--text-primary);
  background: var(--page); max-width: 860px; margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem; line-height: 1.6;
}
h1 { font-size: 20px; font-weight: 600; margin: 0; }
h2 { font-size: 17px; font-weight: 600; margin: 26px 0 8px; }
h3 { font-size: 15px; font-weight: 600; margin: 20px 0 6px; }
a { color: var(--text-accent); }
nav { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
nav .brand { font-weight: 650; font-size: 16px; color: var(--text-primary); text-decoration: none; }
nav a { font-size: 13.5px; text-decoration: none; }
nav form { margin-left: auto; }

button, .btn {
  font: inherit; font-size: 14px; padding: 8px 16px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface-2);
  color: var(--text-primary); cursor: pointer; text-decoration: none; display: inline-block;
}
button.primary, .btn.primary { background: var(--pos); border-color: var(--pos); color: #fff; }
button.quiet, .btn.quiet { background: transparent; }
button:active { transform: scale(.98); }

.kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.mcard { background: var(--surface-1); border-radius: 12px; padding: 14px 16px; }
.mlab { font-size: 13px; color: var(--text-secondary); margin: 0 0 4px; }
.mval { font-size: 24px; font-weight: 600; margin: 0; }
.msub { font-size: 12px; color: var(--text-muted); margin: 6px 0 0; line-height: 1.5; }
.brow { display: flex; justify-content: space-between; font-size: 14px; padding: 3px 0; gap: 10px; }
.brow span:first-child { color: var(--text-secondary); }
.brow span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }

.chip { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 999px; }
.chip.warn { background: var(--bg-warning); color: var(--text-warning); }
.chip.ok { background: var(--bg-ok); color: var(--text-ok); }
.chip.info { background: var(--bg-accent); color: var(--text-accent); }

.plain { background: var(--surface-1); border-radius: 12px; padding: 12px 16px; margin: 14px 0 0; }
.plain b { font-size: 12px; font-weight: 600; color: var(--text-accent); display: block; margin: 0 0 4px; }
.plain p { font-size: 14px; margin: 0; }

.panel { background: var(--surface-1); border-radius: 12px; padding: 16px 18px; margin: 14px 0; }
.muted { color: var(--text-muted); font-size: 12.5px; }
.small { font-size: 13px; }

.row { display: grid; grid-template-columns: minmax(0,1fr) 64px minmax(0,1fr); align-items: center; height: 24px; }
.srow { display: grid; grid-template-columns: minmax(0,1fr) 190px minmax(0,1fr); align-items: center; min-height: 24px; }
.bneg { height: 13px; border-radius: 4px 0 0 4px; background: var(--neg); }
.bpos { height: 13px; border-radius: 0 4px 4px 0; background: var(--pos); }
.tick { text-align: center; font-family: var(--font-mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 4px; }
.vlab { font-size: 12px; color: var(--text-secondary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.zl { display: flex; justify-content: flex-end; align-items: center; gap: 6px; }
.zr { display: flex; justify-content: flex-start; align-items: center; gap: 6px; }
.leg { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-secondary); flex-wrap: wrap; margin: 4px 0 8px; }
.leg span { display: flex; align-items: center; gap: 5px; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

table.metrics { width: 100%; border-collapse: collapse; font-size: 13.5px; margin: 8px 0; }
table.metrics th { text-align: right; font-weight: 600; color: var(--text-secondary); padding: 6px 8px; border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
table.metrics th:first-child, table.metrics td:first-child { text-align: left; }
table.metrics td { text-align: right; padding: 6px 8px; border-bottom: 0.5px solid var(--border); font-variant-numeric: tabular-nums; }
table.metrics tr.hl td { background: var(--bg-accent); }
table.metrics tr.hl td:first-child { border-radius: 6px 0 0 6px; }
table.metrics tr.hl td:last-child { border-radius: 0 6px 6px 0; }

.flag { display: flex; gap: 10px; align-items: baseline; padding: 9px 0; border-top: 0.5px solid var(--border); font-size: 13.5px; color: var(--text-secondary); }
.flag .tag { font-weight: 600; font-size: 12.5px; flex-shrink: 0; }
.flag.ok .tag { color: var(--text-ok); }
.flag.warn .tag { color: var(--text-warning); }
.flag.info .tag { color: var(--text-accent); }

.drop { border: 1.5px dashed var(--border-strong); border-radius: 12px; padding: 26px 18px; text-align: center; background: var(--surface-2); margin: 12px 0; }
input[type="file"] { font-size: 13.5px; max-width: 100%; }
.filecard { border-top: 0.5px solid var(--border); padding: 12px 0; }
.filecard:first-child { border-top: none; }

.bar-outer { height: 10px; border-radius: 999px; background: var(--surface-2); border: 0.5px solid var(--border); overflow: hidden; margin: 10px 0; }
.bar-inner { height: 100%; background: var(--pos); border-radius: 999px; transition: width .4s; }

footer.method { font-size: 12.5px; color: var(--text-muted); margin-top: 26px; border-top: 0.5px solid var(--border); padding-top: 12px; line-height: 1.65; }
.actions { display: flex; gap: 10px; margin: 16px 0; flex-wrap: wrap; align-items: center; }
.chartbox { background: var(--surface-1); border-radius: 12px; padding: 12px 14px; margin: 8px 0; }
.notice { background: var(--bg-warning); color: var(--text-warning); border-radius: var(--radius); padding: 10px 14px; font-size: 13.5px; margin: 12px 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
