/* ------------------------------------------------------------------
   運用ボード — 見た目。
   色は :root にトークンで置き、ダークは prefers-color-scheme で差し替える。
   ------------------------------------------------------------------ */
:root {
  --bg: #faf9f7;
  --panel: #ffffff;
  --panel-2: #f3f1ee;
  --line: #e2ded8;
  --ink: #23201c;
  --ink-2: #6d675f;
  --ink-3: #9b948a;
  --accent: #c15f3c;
  --accent-soft: #f6e7e0;
  --ok: #3f7d58;
  --warn: #b8860b;
  --danger: #b3402f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.05);
  --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1917;
    --panel: #232120;
    --panel-2: #2c2a28;
    --line: #3a3735;
    --ink: #ece8e3;
    --ink-2: #a8a19a;
    --ink-3: #7c756d;
    --accent: #e08560;
    --accent-soft: #3a2a22;
    --ok: #6bab84;
    --warn: #d9ad4a;
    --danger: #e08070;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }
/* ⚠️ 最重要の1行。
   hidden属性の「非表示」はブラウザ標準の弱いルールなので、
   .gate { display: grid } のような自作の display 指定が勝ってしまい、
   「hidden にしたのに画面に残り続ける」事故が起きる（実際に起きた。
   ログイン画面が消えず、その下に完成したボードが隠れていた）。 */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; }
button, select, input, textarea { font: inherit; color: inherit; }

/* ---------------------------------------------------------- ログイン画面 */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.gate-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px 28px; text-align: center; box-shadow: var(--shadow); max-width: 380px; width: 100%;
}
.gate-title { margin: 0 0 6px; font-size: 20px; letter-spacing: .02em; }
.gate-note { margin: 0 0 20px; color: var(--ink-2); font-size: 13px; }

/* ---------------------------------------------------------- ボタン類 */
.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; transition: .12s;
}
.btn:hover { border-color: var(--ink-3); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: none; border-color: transparent; padding: 6px 8px; }
.btn-sm { padding: 4px 9px; font-size: 13px; border-radius: 6px; }

/* ---------------------------------------------------------- 上部バー */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 8px max(10px, env(safe-area-inset-left)) 8px max(10px, env(safe-area-inset-right));
  padding-top: calc(8px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  text-decoration: none; white-space: nowrap; padding: 6px 11px; border-radius: 7px;
  font-size: 14px; color: var(--ink-2);
}
.tabs a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.select-sm {
  background: var(--panel); border: 1px solid var(--line); border-radius: 7px;
  padding: 5px 8px; font-size: 13px; max-width: 40vw;
}
.badge {
  display: inline-block; min-width: 17px; margin-left: 5px; padding: 0 5px;
  background: var(--danger); color: #fff; border-radius: 9px;
  font-size: 11px; line-height: 17px; text-align: center; font-weight: 700;
}

.view { padding: 14px max(12px, env(safe-area-inset-left)) 60px max(12px, env(safe-area-inset-right)); max-width: 1180px; margin: 0 auto; }

/* ---------------------------------------------------------- 共通パーツ */
h2.sec { font-size: 15px; margin: 22px 0 10px; letter-spacing: .02em; }
h2.sec:first-child { margin-top: 4px; }
.muted { color: var(--ink-2); }
.tiny { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow);
}
.notice {
  border-left: 3px solid var(--warn); background: var(--panel-2);
  padding: 9px 12px; border-radius: 0 8px 8px 0; font-size: 13px; margin-bottom: 12px;
}
.notice.danger { border-left-color: var(--danger); }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 99px; padding: 2px 9px; font-size: 12px; color: var(--ink-2);
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }

/* ---------------------------------------------------------- 進行ボード */
.summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 13px; min-width: 88px;
}
.stat b { display: block; font-size: 21px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: var(--ink-2); }

.lanes { display: grid; gap: 10px; }
@media (min-width: 900px) {
  .lanes { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); align-items: start; }
}
.lane { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); }
.lane > summary {
  cursor: pointer; padding: 9px 12px; font-size: 13px; font-weight: 600;
  display: flex; justify-content: space-between; align-items: center; list-style: none;
}
.lane > summary::-webkit-details-marker { display: none; }
.lane > summary .n { color: var(--ink-3); font-weight: 400; }
.lane-body { padding: 0 8px 8px; display: grid; gap: 7px; }

.pcard {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; cursor: pointer; text-decoration: none; display: block;
}
.pcard:hover { border-color: var(--ink-3); }
.pcard-top { display: flex; align-items: baseline; gap: 6px; font-size: 11px; color: var(--ink-3); }
.pcard-title { font-size: 13.5px; font-weight: 600; margin: 2px 0 4px; }
.pcard-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11.5px; color: var(--ink-2); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; }

/* ---------------------------------------------------------- 詳細 */
.detail-grid { display: grid; gap: 14px; }
@media (min-width: 860px) { .detail-grid { grid-template-columns: 1.15fr .85fr; align-items: start; } }
.kv { display: grid; grid-template-columns: 7.5em 1fr; gap: 5px 10px; font-size: 13.5px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; word-break: break-all; }
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--ink-2); }
.field input, .field textarea, .field select {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; width: 100%;
}
.field textarea { min-height: 76px; resize: vertical; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.timeline li { display: flex; gap: 9px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--ink-3); font-size: 12px; white-space: nowrap; }

/* ---------------------------------------------------------- 表 */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th, table.data td { padding: 7px 9px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.data th { color: var(--ink-2); font-weight: 600; font-size: 12px; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.weak td { color: var(--ink-3); }

/* タスク表（進行ボード） */
table.tasks td.chk, table.tasks th.chk { text-align: center; width: 52px; }
table.tasks input[type="checkbox"] {
  width: 19px; height: 19px; accent-color: var(--accent); cursor: pointer;
}
table.tasks td.name { white-space: normal; min-width: 180px; max-width: 340px; }
table.tasks td.name a { text-decoration: none; }
table.tasks td.name a:hover { color: var(--accent); }
table.tasks tbody tr:hover { background: var(--panel-2); }

/* 施策カード（モバイル用） */
.tcards { display: grid; gap: 8px; }
@media (min-width: 760px) { .tcards { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); } }

/* ---------------------------------------------------------- グラフ */
svg.chart { width: 100%; height: auto; display: block; }
svg.chart text { fill: var(--ink-2); font-size: 10px; }
svg.chart .grid { stroke: var(--line); }
svg.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
svg.chart .bar { fill: var(--accent); opacity: .8; }
svg.chart .bar:hover { opacity: 1; }
.spark { width: 100%; height: 34px; }

/* ---------------------------------------------------------- トースト */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom));
  background: var(--ink); color: var(--bg); padding: 8px 16px; border-radius: 99px;
  font-size: 13px; z-index: 60; box-shadow: var(--shadow);
}

.empty { text-align: center; color: var(--ink-3); padding: 40px 0; font-size: 14px; }
