/* 共有ダッシュボード。配色の役割は dataviz の参照パレット（状態色は good/warning/serious/critical に固定）。 */
:root {
  color-scheme: light;
  --surface-0: #f4f3f0;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e0da;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77756f;
  --accent: #2a78d6;
  --accent-soft: #cde2fb;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-text: #006300;
  --critical-text: #b42828;
  --neutral: #c9c7c0;
  --radius: 12px;
  font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --surface-2: #262624;
    --border: #383835;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #96958d;
    --accent: #3987e5;
    --accent-soft: #1c3a5e;
    --good-text: #4cc94c;
    --critical-text: #ef7a7a;
    --neutral: #55544f;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--surface-0); color: var(--text-primary); font-size: 14px; line-height: 1.55; }
a { color: var(--accent); }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px 48px; }

/* ヘッダー */
.top { position: sticky; top: 0; z-index: 10; background: var(--surface-1); border-bottom: 1px solid var(--border); }
.top .wrap { display: flex; align-items: center; gap: 16px; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 15px; }
nav { display: flex; gap: 4px; }
nav a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--text-secondary); font-weight: 600; }
nav a[aria-current="page"] { background: var(--accent-soft); color: var(--text-primary); }
.updated { margin-left: auto; color: var(--text-muted); font-size: 12px; display: flex; align-items: center; gap: 8px; }
button, select { font: inherit; color: var(--text-primary); background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: 5px 10px; cursor: pointer; }
button:hover, select:hover { border-color: var(--accent); }
.stale { color: var(--critical-text); font-weight: 600; }

h1 { font-size: 20px; margin: 24px 0 4px; }
h2 { font-size: 16px; margin: 28px 0 10px; }
.lead { color: var(--text-secondary); margin: 0 0 12px; }
.note { color: var(--text-muted); font-size: 12px; }
.panel { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.err { background: var(--surface-1); border: 1px solid var(--critical); color: var(--critical-text); border-radius: var(--radius); padding: 12px 16px; margin-top: 16px; }

/* KPI タイル */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 12px; }
.tile h3 { margin: 0 0 8px; font-size: 14px; display: flex; justify-content: space-between; gap: 8px; }
.tile .row { display: grid; grid-template-columns: 64px repeat(3, minmax(0, 1fr)); gap: 4px 8px; align-items: baseline; }
.tile .row + .row { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--border); }
.tile .k { color: var(--text-muted); font-size: 12px; }
.tile .v { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; }
.tile .v small { display: block; font-weight: 400; font-size: 11px; color: var(--text-muted); }
.pos { color: var(--good-text); }
.neg { color: var(--critical-text); }

/* フィルター */
.filters { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin: 20px 0 12px; }
.filters label { color: var(--text-secondary); font-size: 12px; display: flex; gap: 6px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 5px 10px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }

/* クリエイティブカード */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.card.off { opacity: .78; }
.thumb { aspect-ratio: 1 / 1; background: var(--surface-2); display: flex; align-items: center; justify-content: center; color: var(--text-muted); position: relative; }
.thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.thumb .chip { position: absolute; top: 8px; left: 8px; }
.body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.name { font-weight: 700; font-size: 13px; word-break: break-all; }
.sub { color: var(--text-muted); font-size: 11px; word-break: break-all; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-1); border: 1px solid var(--border); }
.chip.on::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.chip.paused::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--neutral); }
.judge { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); border-left: 4px solid var(--neutral); font-size: 12px; }
.judge b { white-space: nowrap; }
.judge.good { border-color: var(--good); }
.judge.watch { border-color: var(--neutral); }
.judge.warn { border-color: var(--warning); }
.judge.stop { border-color: var(--critical); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.box { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.box .t { font-size: 11px; color: var(--text-muted); font-weight: 700; }
.box dl { margin: 4px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 1px 8px; font-size: 12px; }
.box dt { color: var(--text-secondary); }
.box dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.metrics { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; text-align: center; font-size: 11px; }
.metrics .m { background: var(--surface-2); border-radius: 6px; padding: 5px 2px; }
.metrics .m span { display: block; color: var(--text-muted); font-size: 10px; line-height: 1.3; word-break: break-all; }
.metrics .m b { font-variant-numeric: tabular-nums; font-size: 12px; }
.metrics-cap { font-size: 11px; color: var(--text-muted); margin-bottom: -6px; }

/* 表 */
.tablewrap { overflow-x: auto; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 12px; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
th { position: sticky; top: 0; background: var(--surface-2); color: var(--text-secondary); font-weight: 700; }
td:first-child, th:first-child, td.l, th.l { text-align: left; }
td.wrap-name { white-space: normal; min-width: 220px; }
tr.sum td { font-weight: 700; background: var(--surface-2); }
td.mini img { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; display: block; }

/* 撤退ライン */
.hero { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.big { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.meter { height: 14px; background: var(--surface-2); border-radius: 7px; overflow: hidden; margin: 10px 0 4px; }
.meter > span { display: block; height: 100%; border-radius: 7px; }
.meter-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); }
.status { display: inline-flex; gap: 6px; align-items: center; font-weight: 700; font-size: 13px; }
.status .dot { width: 10px; height: 10px; border-radius: 50%; }
.months { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 10px; }
.month { border: 1px solid var(--border); border-radius: 8px; padding: 6px; text-align: center; font-size: 11px; }
.month b { display: block; font-size: 12px; font-variant-numeric: tabular-nums; }
.month.black { border-color: var(--good); }
.month.red { border-color: var(--critical); }
.month.future { border-style: dashed; color: var(--text-muted); }
.month.now { box-shadow: 0 0 0 2px var(--accent) inset; }
.chart { width: 100%; max-width: 820px; height: auto; display: block; }
.chart text { fill: var(--text-secondary); font-size: 11px; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .zero { stroke: var(--text-muted); stroke-width: 1; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-secondary); margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -2px; }
.tip { position: fixed; pointer-events: none; background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.15); display: none; z-index: 20; }
blockquote { margin: 0; padding: 10px 14px; border-left: 4px solid var(--accent); background: var(--surface-2); border-radius: 0 8px 8px 0; color: var(--text-secondary); }

/* プラン */
.timeline { display: grid; gap: 10px; }
.stage { display: grid; grid-template-columns: 200px 1fr; gap: 12px; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stage.now { border: 2px solid var(--accent); }
.stage.done { opacity: .65; }
.stage h3 { margin: 0; font-size: 15px; }
.stage .when { color: var(--text-muted); font-size: 12px; }
.stage ul { margin: 0; padding-left: 18px; }
.gate { display: flex; gap: 10px; align-items: center; padding: 6px 0 6px 18px; color: var(--text-secondary); font-size: 13px; }
.gate::before { content: ""; width: 12px; height: 12px; transform: rotate(45deg); border: 2px solid var(--text-muted); flex: none; }
.gate.key::before { border-color: var(--accent); background: var(--accent-soft); }
.gate b { color: var(--text-primary); }
.badge-now { background: var(--accent); color: #fff; font-size: 11px; padding: 1px 8px; border-radius: 999px; margin-left: 6px; }
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.check h3 { margin: 0 0 6px; font-size: 14px; }
.check .val { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.check ul { margin: 6px 0 0; padding-left: 18px; font-size: 12px; color: var(--text-secondary); }
.check li.ok::marker { content: "✓ "; color: var(--good-text); }
.check li.ng::marker { content: "✗ "; color: var(--critical-text); }
.task { display: flex; gap: 8px; align-items: baseline; }
.task .d { font-variant-numeric: tabular-nums; color: var(--text-muted); width: 72px; flex: none; }

/* ログイン */
.login { max-width: 360px; margin: 12vh auto; }
.login input { width: 100%; font: inherit; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); margin: 8px 0 12px; }
.login button { width: 100%; padding: 10px; background: var(--accent); color: #fff; border: 0; font-weight: 700; }

@media (max-width: 640px) {
  .tiles { grid-template-columns: 1fr; }
  .stage { grid-template-columns: 1fr; }
  .months { grid-template-columns: repeat(4, 1fr); }
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .updated { margin-left: 0; }
}
