/* Layout: one calm column; counts first, dates second, projects third. Tables turn into cards on phones. */
:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --fg: #1c2024;
  --muted: #5d666f;
  --line: #dfe3e0;
  --accent: #1f6f5c;
  --accent-fg: #ffffff;
  --ok: #1d7a46;
  --warn: #9a6200;
  --bad: #b42318;
  --lane-1: #1f6f5c;
  --lane-2: #3b5bdb;
  --lane-3: #9a6200;
  --lane-4: #7c3aed;
  --lane-5: #5d666f;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --font-num: ui-sans-serif, -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --panel: #1c2126;
    --fg: #e8ebee;
    --muted: #9aa5af;
    --line: #2d343b;
    --accent: #5fc4aa;
    --accent-fg: #0d1a17;
    --ok: #5fc48a;
    --warn: #e0a84a;
    --bad: #f0857a;
    --lane-1: #5fc4aa;
    --lane-2: #8aa2ff;
    --lane-3: #e0a84a;
    --lane-4: #b79cff;
    --lane-5: #9aa5af;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- sign-in ---- */
.gate { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); }
.gate-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px 24px; display: flex; flex-direction: column; gap: 14px; }
.gate-title { margin: 0; font-size: 22px; font-weight: 600; }
.gate-lead, .gate-note { margin: 0; color: var(--muted); }
.gate-note { font-size: 13px; }
.gate-msg { margin: 0; min-height: 1.4em; font-size: 14px; color: var(--muted); }
.gate-bad { color: var(--bad); }
#gate-setup, #gate-login { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; color: var(--muted); }
.input { font: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); width: 100%; }

.btn { font: inherit; border-radius: 8px; padding: 10px 14px; border: 1px solid var(--line); background: var(--panel); color: var(--fg); cursor: pointer; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
.btn-quiet { padding: 6px 10px; font-size: 13px; color: var(--muted); background: transparent; }

/* ---- dashboard ---- */
.app { max-width: 1120px; margin: 0 auto; padding: 20px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 28px; }
.top { display: flex; flex-direction: column; gap: 8px; }
.top-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.top-actions { display: flex; gap: 6px; }
.title { margin: 0; font-size: 24px; font-weight: 600; text-wrap: balance; }
.take { margin: 0; max-width: 46em; }
.take b { font-weight: 600; font-variant-numeric: tabular-nums; }
.app-msg { margin: 0; font-size: 13px; color: var(--muted); min-height: 0; }
.app-msg:empty { display: none; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 8px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile-n { font-family: var(--font-num); font-size: 28px; line-height: 1.1; font-weight: 500; font-variant-numeric: tabular-nums; }
.tile-l { font-size: 13px; color: var(--muted); }

.sec { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.sec-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.h2 { margin: 0; font-size: 17px; font-weight: 600; }
.sub { margin: 0; color: var(--muted); font-size: 13px; max-width: 60em; }
.select { font: inherit; font-size: 14px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--fg); max-width: 100%; }

.chart { position: relative; min-height: 200px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart text { font-family: var(--font); font-size: 12px; fill: var(--muted); }
.grid-line { stroke: var(--line); stroke-width: 1; }
.today-line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.pt { stroke-width: 2; cursor: pointer; }
.pt-1 { stroke: var(--lane-1); } .pt-1.pt-full { fill: var(--lane-1); }
.pt-2 { stroke: var(--lane-2); } .pt-2.pt-full { fill: var(--lane-2); }
.pt-3 { stroke: var(--lane-3); } .pt-3.pt-full { fill: var(--lane-3); }
.pt-4 { stroke: var(--lane-4); } .pt-4.pt-full { fill: var(--lane-4); }
.pt-5 { stroke: var(--lane-5); } .pt-5.pt-full { fill: var(--lane-5); }
.pt-hollow { fill: var(--bg); }
.tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 6px 20px rgba(0, 0, 0, .14); border-radius: 8px; padding: 6px 10px; font-size: 13px; max-width: 260px; z-index: 2; }
.tip-d { color: var(--muted); font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--muted); }
.dot-full { background: var(--muted); }

.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.table { border-collapse: collapse; width: 100%; }
.table th { text-align: left; font-weight: 600; font-size: 13px; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); font-size: 13px; }
.strong { font-weight: 600; }
.block { display: block; }
.wide { min-width: 15em; }
.mid { min-width: 9em; }
.empty { color: var(--muted); padding: 12px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 13px; border: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pill-bad { color: var(--bad); border-color: var(--bad); }
.pill-warn { color: var(--warn); border-color: var(--warn); }
.pill-ok { color: var(--ok); border-color: var(--ok); }
.pill-quiet { color: var(--muted); }
.rank { display: inline-block; margin-left: 6px; padding: 0 5px; border-radius: 4px; font-size: 12px; background: var(--line); white-space: nowrap; }
.link { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.list { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 8px; }
.notes summary { cursor: pointer; color: var(--muted); }
.notes[open] summary { margin-bottom: 8px; }
.foot { color: var(--muted); font-size: 13px; }

/* Phones: each table row becomes a card. */
@media (max-width: 680px) {
  .scroll { border: 0; background: none; overflow: visible; border-radius: 0; }
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table, .table tbody, .table tr, .table td { display: block; width: auto; }
  .table tr { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; }
  .table td, .table tr:last-child td { padding: 3px 0; border: 0; min-width: 0; }
  .table td:empty { display: none; }
  .table td.c-inline { display: inline-block; margin-right: 8px; vertical-align: middle; }
  .table td.c-head { font-weight: 600; }
  .table td[data-label]::before { content: attr(data-label) "："; color: var(--muted); font-size: 13px; }
  .tile-n { font-size: 24px; }
  .title { font-size: 21px; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn { transition: opacity .15s ease; }
}
