/* foresight の画面スタイル（フェーズ8a）。
 *
 * 見た目はすべてこのファイル。CSP が style-src 'self' で <style> もインラインの
 * style 属性も禁じている（crates/web/src/security.rs）ので、幅を値で持つものは
 * <progress> のような属性で表す。トークンは :root の変数に集約し、値は
 * docs/superpowers/specs/2026-09-14-phase8a-ui-foundation-design.md §2.1 と同じ。
 *
 * 系列色 --s1〜--s9 は static/chart.js の COLORS と同じ順序。片方を変えたら両方。
 */

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --border: #e4e7ec;
    --border-strong: #cbd1d9;
    --row: #eef0f3;
    --ink: #1a1f27;
    --ink-2: #5c6673;
    --ink-3: #8b95a1;
    --accent: #2557b8;
    --accent-hover: #1e4794;
    --accent-tint: #e9effb;
    --danger: #b42318;
    --danger-tint: #fdecea;
    --good-text: #006300;
    --s1: #2a78d6;
    --s2: #eb6834;
    --s3: #1baf7a;
    --s4: #eda100;
    --s5: #e87ba4;
    --s6: #008300;
    --s7: #4a3aa7;
    --s8: #e34948;
    --s9: #8b95a1;
    --grid: #e1e0d9;
    --axis: #c3c2b7;
    --muted-ink: #898781;
    --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
        "Yu Gothic UI", Meiryo, "Segoe UI", system-ui, sans-serif;
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    --radius: 6px;
    --radius-card: 10px;
    --control: 36px;
    --content: 1120px;
}

/* ---------- 基本 ---------- */

*,
*::before,
*::after { box-sizing: border-box; }

/* `hidden` 属性の既定の display: none は、button の display: inline-flex のような作者スタイルに負ける（フェーズ7b の
 * プッシュ通知のカードで、有効化・解除の両方のボタンが最初から見えてしまう）。 */
[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
h2 { margin: 0 0 12px; font-size: 16px; font-weight: 600; }
h3 { margin: 0 0 8px; font-size: 14px; font-weight: 600; }
p { margin: 0 0 8px; }

main {
    max-width: var(--content);
    margin: 0 auto;
    padding: 28px 32px 48px;
}

/* 価格・残高・数量など、桁を読み違えてはいけない数値。等幅 + tabular で桁を揃える
 * （取引金額の読み違いは金銭事故になり得るので、フェーズ3b から固定している規則）。 */
.num {
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.icon { vertical-align: -0.15em; flex: none; }

/* ---------- 外枠とナビ ---------- */

.topbar {
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: stretch;
    gap: 28px;
    padding: 0 32px;
}

.brand {
    display: flex;
    align-items: center;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.01em;
    color: var(--ink);
}
.brand:hover { color: var(--ink); text-decoration: none; }

nav.primary {
    display: flex;
    align-items: stretch;
    gap: 2px;
    overflow-x: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0 12px;
    color: var(--ink-2);
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.nav-link:hover { color: var(--ink); text-decoration: none; }
.nav-link.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.bell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    color: var(--ink-2);
}
.bell:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.bell .count {
    position: absolute;
    top: 3px;
    right: 1px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}

.nav-me {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--ink-2);
    min-height: 32px;
}
.nav-balance { white-space: nowrap; }
.nav-balance .num { font-size: 14px; font-weight: 600; color: var(--ink); }
.nav-me .handle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    color: var(--ink);
}
.nav-me .handle::before {
    content: "";
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: #c9d6f0;
}

/* ---------- ページの骨格 ---------- */

.page-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}
.page-head-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.season-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.two-col {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-areas: "main side";
    gap: 20px;
    align-items: start;
}
.col-main { grid-area: main; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.col-side { grid-area: side; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 16px; }

.stack { display: flex; flex-direction: column; gap: 16px; }

/* ---------- 部品 ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 18px 20px;
}
.card > h2 { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card > h2 .meta { font-weight: 400; }
.card.table-card { padding-bottom: 8px; }

.btn,
button,
input[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: var(--control);
    padding: 0 14px;
    border-radius: var(--radius);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover,
button:hover { background: #f8f9fb; color: var(--ink); text-decoration: none; }
.btn-primary,
button[type="submit"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover,
button[type="submit"]:hover { background: var(--accent-hover); color: #fff; }
.btn-lg { height: 44px; font-size: 15px; width: 100%; }
button:disabled { cursor: not-allowed; opacity: 0.6; }
button.danger, .btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }

.badge {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    background: var(--row);
    color: var(--ink-2);
}
.status-open, .status-active { background: #e3f3ea; color: #176b3f; }
.status-closed { background: #fbf1d9; color: #8a5a00; }
.status-resolved_pending { background: #eee9fb; color: #6b4bb8; }
.status-resolved { background: var(--accent-tint); color: var(--accent); }
.status-pending, .status-scheduled { background: var(--accent-tint); color: var(--accent); }
/* refunded・rejected・settled・未知は .badge の既定（灰） */

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.chip {
    display: inline-flex;
    align-items: center;
    height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--ink-2);
    font-size: 13px;
}
.chip:hover { color: var(--ink); text-decoration: none; }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }

input,
select,
textarea {
    font: inherit;
    font-size: 14px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 0 12px;
    height: var(--control);
    width: 100%;
}
textarea { height: auto; min-height: 84px; padding: 8px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent-tint);
    border-color: var(--accent);
}
input[type="number"] { font-family: var(--mono); font-variant-numeric: tabular-nums; }

form { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.meta { font-size: 12px; color: var(--ink-3); }
.note { font-size: 12px; color: var(--ink-2); margin: 12px 0 0; }
.empty { color: var(--ink-3); }
.pos { color: var(--good-text); }

progress.bar {
    display: block;
    width: 100%;
    height: 6px;
    margin-top: 10px;
    border: 0;
    border-radius: 3px;
    background: var(--row);
    overflow: hidden;
    -webkit-appearance: none;
    appearance: none;
}
progress.bar::-webkit-progress-bar { background: var(--row); border-radius: 3px; }
progress.bar::-webkit-progress-value { background: var(--s1); border-radius: 3px; }
progress.bar::-moz-progress-bar { background: var(--s1); border-radius: 3px; }
progress.bar.muted::-webkit-progress-value { background: var(--axis); }
progress.bar.muted::-moz-progress-bar { background: var(--axis); }

/* 系列の色見本（価格パネルの凡例）。chart.js の COLORS と同じ順序。
 * ベンダー別の疑似要素は 1 規則ずつ書く —— セレクタ列に Chrome が解釈できない
 * ::-moz-progress-bar を並べると規則全体が無効になる（手動確認で実測）。 */
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--s9); }
.swatch-1 .swatch { background: var(--s1); }
.swatch-1 progress.bar::-webkit-progress-value { background: var(--s1); }
.swatch-1 progress.bar::-moz-progress-bar { background: var(--s1); }
.swatch-2 .swatch { background: var(--s2); }
.swatch-2 progress.bar::-webkit-progress-value { background: var(--s2); }
.swatch-2 progress.bar::-moz-progress-bar { background: var(--s2); }
.swatch-3 .swatch { background: var(--s3); }
.swatch-3 progress.bar::-webkit-progress-value { background: var(--s3); }
.swatch-3 progress.bar::-moz-progress-bar { background: var(--s3); }
.swatch-4 .swatch { background: var(--s4); }
.swatch-4 progress.bar::-webkit-progress-value { background: var(--s4); }
.swatch-4 progress.bar::-moz-progress-bar { background: var(--s4); }
.swatch-5 .swatch { background: var(--s5); }
.swatch-5 progress.bar::-webkit-progress-value { background: var(--s5); }
.swatch-5 progress.bar::-moz-progress-bar { background: var(--s5); }
.swatch-6 .swatch { background: var(--s6); }
.swatch-6 progress.bar::-webkit-progress-value { background: var(--s6); }
.swatch-6 progress.bar::-moz-progress-bar { background: var(--s6); }
.swatch-7 .swatch { background: var(--s7); }
.swatch-7 progress.bar::-webkit-progress-value { background: var(--s7); }
.swatch-7 progress.bar::-moz-progress-bar { background: var(--s7); }
.swatch-8 .swatch { background: var(--s8); }
.swatch-8 progress.bar::-webkit-progress-value { background: var(--s8); }
.swatch-8 progress.bar::-moz-progress-bar { background: var(--s8); }
.swatch-9 .swatch { background: var(--s9); }
.swatch-9 progress.bar::-webkit-progress-value { background: var(--s9); }
.swatch-9 progress.bar::-moz-progress-bar { background: var(--s9); }

.stat { padding: 16px 20px; }
.stat .value { display: flex; align-items: baseline; gap: 6px; margin-top: 4px; }
.stat .value .num { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; }
.stat .value .unit { font-size: 13px; color: var(--ink-2); }

/* ---------- 表 ---------- */

.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-2);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    background: #fafbfc;
    white-space: nowrap;
}
td { padding: 10px 12px; border-bottom: 1px solid var(--row); font-size: 13px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num, td.r, th.r { text-align: right; }
tr.me td { background: var(--accent-tint); }

/* ---------- 市場一覧 ---------- */

.market-card { display: flex; flex-direction: column; padding: 16px 18px 14px; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-title {
    display: block;
    color: var(--ink);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.45;
    margin: 10px 0 14px;
    min-height: 44px;
}
.card-title:hover { color: var(--accent); text-decoration: none; }
.card-value { margin-top: auto; }
.lead { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.lead-label { font-size: 13px; color: var(--ink-2); }
.lead-label strong { color: var(--ink); }
.market-price { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1; }
.market-price .unit { font-size: 14px; font-weight: 500; color: var(--ink-2); font-family: var(--font); }
.market-outcome { display: inline-flex; align-items: center; gap: 6px; font-size: 20px; font-weight: 600; }
.card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 14px;
}
.card-foot .deadline { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- 市場詳細 ---------- */

.crumb { margin-bottom: 8px; }
.market-head { margin-bottom: 20px; }
.market-head h1 { font-size: 24px; line-height: 1.35; margin-bottom: 8px; }
.market-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--ink-2); }
.market-meta .deadline { display: inline-flex; align-items: center; gap: 4px; }

/* 高さは CSS が持つ。chart.js は autoSize で容器の大きさに追随する（400px で横にはみ出さない）。 */
#chart { height: 260px; margin: 4px 0 12px; }
ul.prices { list-style: none; margin: 0; padding: 12px 0 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
ul.prices li {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr) 72px;
    align-items: center;
    gap: 12px;
}
ul.prices li progress.bar { margin: 0; height: 8px; }
.outcome-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.outcome-price { font-size: 16px; font-weight: 600; text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }

.resolution-criteria p { line-height: 1.7; margin: 0; }

/* `.official-forecast` はテストがクラスを完全一致で見るので `.card` を付けず、ここでカードの見た目を当てる。 */
.official-forecast { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 18px 20px; }
.official-forecast .figures { display: flex; align-items: center; gap: 24px; }
.official-forecast .figures .num { font-size: 24px; font-weight: 600; }
.official-forecast .figures .gap { border-left: 1px solid var(--border); padding-left: 24px; }
.official-forecast .source { margin-left: auto; text-align: right; }

.trade-panel form { gap: 14px; }
.trade-panel .qty { display: flex; gap: 8px; align-items: center; }
.trade-panel .wallet { font-size: 13px; color: var(--ink-2); }
.trade-panel .wallet .wallet-balance-value { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
#trade-preview:empty { display: none; }
#trade-preview {
    background: var(--bg);
    border-radius: 8px;
    padding: 12px 14px;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 12px;
    font-size: 13px;
}
#trade-preview .k { color: var(--ink-2); }
#trade-preview .v { text-align: right; }
#trade-preview .preview-cash-flow { font-weight: 600; }
#my-position { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
#my-position .num { font-size: 20px; font-weight: 600; }
#my-position .unit { font-size: 12px; color: var(--ink-2); font-weight: 500; font-family: var(--font); }

.comments .comment { display: flex; flex-direction: column; gap: 4px; padding: 12px 0; border-bottom: 1px solid var(--row); }
.comments .comment-head { display: flex; align-items: center; gap: 8px; }
.comments .comment-handle { font-size: 13px; font-weight: 600; }
.comments .comment-handle::before { content: ""; display: inline-block; width: 20px; height: 20px; border-radius: 999px; background: #d9e2f2; vertical-align: middle; margin-right: 8px; }
.comments .comment-time { font-size: 12px; color: var(--ink-3); }
.comments .comment-body { margin: 0 0 0 28px; line-height: 1.6; }
.comments .comment-tombstone { margin: 0 0 0 28px; color: var(--ink-3); }
.comments .comment button { height: 28px; padding: 0 10px; font-size: 12px; font-weight: 500; margin-left: 28px; align-self: flex-start; }
.comments form { margin-top: 16px; }
.comments form button { align-self: flex-end; }

/* ---------- ダッシュボード・リーダーボード・レポート ---------- */

.rank { width: 64px; }
td.rank.top3 { font-weight: 700; }

.report-top { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.calibration-wrap { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; align-items: start; }
svg.calibration { display: block; max-width: 100%; height: auto; }
.calibration .axis { stroke: var(--axis); stroke-width: 1; }
.calibration .grid { stroke: var(--grid); stroke-width: 1; }
.calibration .ideal { stroke: var(--axis); stroke-width: 1; }
.calibration .curve { fill: none; stroke: var(--s1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.calibration .bin { fill: var(--s1); stroke: var(--surface); stroke-width: 2; }
.calibration .tick { fill: var(--muted-ink); font-family: var(--mono); font-size: 11px; }
.calibration .axis-label { fill: var(--ink-2); font-size: 11px; }
table.brier tr.total td { font-weight: 600; background: #fafbfc; }

/* ---------- アンカー・検証（フェーズ8b） ---------- */

code.hash {
    display: inline-block;
    max-width: 14ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--ink-2);
}
a code.hash { color: var(--accent); }
.lede { color: var(--ink-2); margin-bottom: 16px; }
#verify-status { font-weight: 600; margin: 0 0 12px; }
#verify-status.ok { color: #1a7f37; }
#verify-status.bad { color: var(--danger); }
table.steps { width: auto; min-width: 320px; margin-bottom: 16px; }
table.steps th { background: transparent; border-bottom: 1px solid var(--row); width: 120px; color: var(--ink); }
table.steps td { font-family: var(--mono); }
dl.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0 0 16px; font-size: 13px; }
dl.facts dt { color: var(--ink-2); }
dl.facts dd { margin: 0; font-family: var(--mono); word-break: break-all; }
#verify-form textarea { font-family: var(--mono); font-size: 12px; min-height: 200px; }

/* ---------- チャートの期間切り替え・乖離（フェーズ8b） ---------- */

.seg > button { height: 30px; padding: 0 12px; font-size: 13px; font-weight: 500; color: var(--ink-2); border: 0; border-right: 1px solid var(--border); border-radius: 0; background: var(--surface); }
.seg > button:last-child { border-right: none; }
.seg > button.active { background: var(--accent-tint); color: var(--accent); font-weight: 600; }
.seg > button:hover { background: #f8f9fb; }
.official-forecast .gap .num { font-size: 24px; font-weight: 600; }

/* ---------- セグメント選択（radio + CSS。フェーズ8b） ---------- */

.seg-radio { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.seg-radio legend { padding: 0; }
.seg-radio .seg { display: flex; }
.seg-radio input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg-radio label {
    flex: 1;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-2);
    border-right: 1px solid var(--border);
    cursor: pointer;
}
.seg-radio label:last-child { border-right: none; }
.seg-radio input:checked + label { background: var(--accent-tint); color: var(--accent); font-weight: 600; }
.seg-radio input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: -2px; }
.status-filter { margin-top: -8px; }

/* ---------- 提案フォーム（フェーズ8b） ---------- */

form.stack { gap: 16px; }
form.stack .card { display: flex; flex-direction: column; gap: 12px; }
form.stack .card h2 { margin-bottom: 0; }
form.stack > button { align-self: flex-end; width: auto; min-width: 200px; }
fieldset.outcomes { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; margin: 0; }
fieldset.outcomes legend { font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 0 4px; }
.outcome-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 8px; }
.notice { margin-bottom: 16px; }

/* ---------- 通知センター（フェーズ8b） ---------- */

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.card-head button { height: 30px; padding: 0 12px; font-size: 13px; font-weight: 500; }
.notification-list { list-style: none; margin: 0; padding: 0; }
.notification {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 12px;
    padding: 12px 8px;
    border-bottom: 1px solid var(--row);
    border-left: 3px solid transparent;
}
.notification:last-child { border-bottom: none; }
.notification.unread { border-left-color: var(--accent); background: var(--accent-tint); }
.notification.unread .body { font-weight: 600; }
.notification .body { color: var(--ink); }
.notification .body:hover { color: var(--accent); }
.notification .time { white-space: nowrap; }
.notification button { height: 28px; padding: 0 10px; font-size: 12px; font-weight: 500; }
.badge.kind-resolved { background: var(--accent-tint); color: var(--accent); }
.badge.kind-refunded { background: var(--row); color: var(--ink-2); }
.badge.kind-price { background: #fbf1d9; color: #8a5a00; }
.badge.kind-other { background: var(--row); color: var(--ink-2); }

/* ---------- ログイン ---------- */

.login-wrap {
    min-height: calc(100vh - 56px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 0;
}
.login-wrap .brand { font-size: 22px; margin-bottom: 24px; }
.login-card { width: 100%; max-width: 420px; padding: 32px; }
.login-card h1 { font-size: 20px; margin-bottom: 6px; }
.login-card .lede { color: var(--ink-2); font-size: 13px; line-height: 1.6; margin-bottom: 24px; }
.login-card form { gap: 16px; }
.login-foot { margin-top: 24px; display: flex; align-items: center; gap: 6px; font-size: 13px; }

/* ---------- プッシュ通知のカード（フェーズ7b） ---------- */

#push-card { margin-bottom: 16px; }
#push-card .note { margin: 0 0 8px; }
/* 状態の 1 行はこのカードで一番大事な情報。.meta（12px・薄い灰）のままだと読み落とす（手動確認で実測）。 */
#push-card #push-status { margin: 0; font-size: 13px; font-weight: 600; color: var(--ink-2); }
#push-card .actions { display: flex; gap: 8px; }

/* ---------- 管理画面（フェーズ8c） ---------- */

nav.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: -8px 0 20px; overflow-x: auto; }
nav.tabs a { padding: 8px 12px; font-size: 13px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
nav.tabs a:hover { color: var(--ink); text-decoration: none; }
nav.tabs a.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }

.badge.danger { background: var(--danger-tint); color: var(--danger); }
.admin-tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--danger-tint); color: var(--danger); }

.automation { margin-bottom: 16px; }
.automation .counts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 16px; margin: 8px 0; padding: 0; list-style: none; font-size: 13px; color: var(--ink-2); }
.automation .due { color: var(--danger); font-weight: 600; }
.automation .empty { color: var(--ink-3); }
.automation ul { margin: 4px 0 0; padding-left: 18px; font-size: 13px; }

.queue-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.queue-section .empty { color: var(--ink-3); margin: 0; }
.queue-list { list-style: none; margin: 0; padding: 0; }
.queue-list li { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--row); font-size: 13px; }
.queue-list li:last-child { border-bottom: none; }
.queue-list .actions { margin-left: auto; display: flex; gap: 8px; }
.queue-list button { height: 28px; padding: 0 10px; font-size: 12px; font-weight: 500; }
.slug { color: var(--ink-3); font-size: 12px; font-family: var(--mono); }
.due { color: var(--danger); font-weight: 600; }
.until { color: var(--ink-2); }

/* `.admin-panel` は管理画面の本体の容器（`admin.js` が #admin-panel の中のエラーを #admin-panel-error に書く）。
 * 市場詳細では `.card` を併用する。 */
.admin-panel { display: flex; flex-direction: column; gap: 16px; }
.admin-panel > h2 { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0; }
.admin-panel .empty { color: var(--ink-3); }
.admin-panel .warning { color: var(--danger); font-weight: 600; font-size: 13px; margin: 0; }
.admin-panel .waiting { color: var(--ink-2); margin: 0; }
.admin-panel .forecast-form { margin: 0; }
.admin-panel .forecast-history { font-size: 13px; color: var(--ink-2); margin: 0; padding-left: 18px; }
.admin-panel .dangerous { background: transparent; border: 0; padding: 0; }
#admin-panel-error:empty { display: none; }
/* エラーの受け皿はパネルの先頭にある。下の方の操作（精算など）で失敗しても見えるように貼り付ける（手動確認で、
 * 精算の確認欄の不一致が画面外に出るのを実測）。`admin.js` は無変更 —— 見た目だけ。 */
#admin-panel-error { position: sticky; top: 8px; z-index: 5; }
.op-error { color: var(--danger); font-weight: 600; margin: 0; padding: 10px 14px; background: var(--danger-tint); border: 1px solid #f3c7c2; border-radius: var(--radius); }
/* 管理のフォームの送信ボタンは全幅にしない（取引パネルの .btn-lg とは別）。 */
.admin-panel form > button { align-self: flex-start; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-row > div { display: flex; flex-direction: column; gap: 6px; }
/* フォームの中の注記は、直前の入力欄に寄せる（.note の既定の上マージンだと次の見出し側に見える。9a のテナント設定で実測）。 */
.admin-panel form .note { margin: -6px 0 4px; }
.admin-panel form h2:not(:first-child) { margin-top: 12px; }

/* 危険操作は一段畳む（spec §3.4）。開くと「何が起きるか」の 1 文と実行ボタン／フォーム。 */
details.danger-zone { border: 1px solid #f3c7c2; border-radius: var(--radius); background: var(--danger-tint); }
details.danger-zone > summary { cursor: pointer; padding: 10px 14px; color: var(--danger); font-weight: 600; font-size: 14px; list-style: none; display: flex; align-items: center; gap: 8px; }
details.danger-zone > summary::-webkit-details-marker { display: none; }
details.danger-zone > summary::before { content: ""; border: 5px solid transparent; border-left-color: currentColor; margin-left: 2px; transition: transform 0.1s; }
details.danger-zone[open] > summary::before { transform: rotate(90deg) translateX(2px); }
details.danger-zone > .zone-body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 10px; }
/* 直下のボタンを全幅に伸ばさない（flex column の既定は stretch）。 */
details.danger-zone > .zone-body > button { align-self: flex-start; }

.season-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 16px 20px; display: flex; flex-direction: column; gap: 8px; }
.season-row h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 15px; }
.season-row .period { color: var(--ink-2); font-size: 13px; margin: 0; }
.season-row .settle ul { margin: 0; padding-left: 18px; font-size: 13px; }
.season-select { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.season-select label { flex-direction: row; align-items: center; gap: 8px; }
.season-select select { width: auto; min-width: 200px; }

table#outbox td.error { max-width: 280px; word-break: break-word; font-size: 12px; color: var(--ink-2); }
table#outbox td:first-child, table#outbox td:nth-child(4) { white-space: nowrap; }

/* メンバー管理（フェーズ9a） */
/* この画面は実名の一覧。上部バーの自分の仮名を同じ画面に並べない（GC 76。残高は出してよい）。 */
body:has(#admin-panel[data-page="members"]) .nav-me .handle { display: none; }
/* 氏名・メール・登録は折り返さない（狭いときは .table-scroll の中で横スクロール）。操作列は幅を固定して、details を開いても他の列を潰さない。 */
table#members td:nth-child(1), table#members td:nth-child(2), table#members td:nth-child(5) { white-space: nowrap; }
table#members th:last-child, table#members td:last-child { width: 360px; }
.member-actions details.danger-zone { width: 100%; }
.member-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 220px; }
.member-actions form { gap: 8px; }
.member-actions button { height: 30px; padding: 0 12px; font-size: 13px; }
table#members td { vertical-align: top; }

.ok { color: #1a7f37; }
.bad { color: var(--danger); }


/* ---------- 幅 720px 以下（400px でも崩れない） ---------- */

@media (max-width: 720px) {
    main { padding: 16px 16px 40px; }
    .topbar { padding: 0 16px; gap: 16px; }
    .nav-me .handle { display: none; }
    .page-head { flex-wrap: wrap; }
    .page-head-right { margin-left: 0; width: 100%; justify-content: space-between; }
    .grid-3 { grid-template-columns: 1fr; }
    .two-col { grid-template-columns: 1fr; grid-template-areas: "side" "main"; }
    .col-side { position: static; }
    .report-top { grid-template-columns: 1fr; }
    .calibration-wrap { grid-template-columns: 1fr; }
    .card { padding: 16px; }
    /* 狭い幅で表を潰さず、.table-scroll の中で横スクロールさせる（手動確認で 1 文字ずつ折り返るのを実測）。 */
    .table-scroll table { min-width: 640px; }
    .official-forecast .figures { flex-wrap: wrap; }
    .official-forecast .source { margin-left: 0; text-align: left; width: 100%; }
    ul.prices li { grid-template-columns: 90px minmax(0, 1fr) 64px; }
    .notification { grid-template-columns: auto minmax(0, 1fr); }
    .notification .time, .notification button { grid-column: 2; justify-self: start; }
    .queue-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .automation .counts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
