@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@500;700&display=swap');

/* Crypto Leverage / Overheat Radar — Phase 1 stylesheet.
   Palette + header chrome are kept VERBATIM from club_crypto_01 so the two
   tools share an identical look on katsumoku.com. Radar-specific cards
   (state bar / OI / Funding / Heatmap / Reset / supplementary / list / alerts)
   are reskinned to that same palette below. */

:root {
    --bg: #f5f6f9;
    --panel: #ffffff;
    --text: #313131;
    --muted: #6b7280;
    --line: #e7e9f0;
    --accent: #3b4675;
    --accent-strong: #2e3860;
    --soft-accent: #eef0f7;
    --gold: #ffcd44;
    --link: #008db7;
    --positive: #0f9d8b;
    --negative: #d9333f;
    --neutral: #374151;
    --warning-bg: #fffdef;
    --warning-line: #ffe39a;
    --heading-font: "Quicksand", "ヒラギノ角ゴ ProN W3", Hiragino Sans, "ヒラギノ角ゴ ProN W3", Hiragino Kaku Gothic ProN, "メイリオ", Meiryo, sans-serif;
    --body-font:    "Quicksand", "ヒラギノ角ゴ ProN W3", Hiragino Sans, "ヒラギノ角ゴ ProN W3", Hiragino Kaku Gothic ProN, "メイリオ", Meiryo, sans-serif;

    /* State color mapping — translated into the navy/gold palette */
    --state-calm:    var(--muted);
    --state-buildup: var(--link);
    --state-crowd:   var(--negative);
    --state-reset:   var(--positive);
    --state-mixed:   #94a3b8;
    --state-amber:   #d97706;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--body-font);
    line-height: 1.55;
}

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

.page {
    width: min(1280px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 56px;
}

/* ════════════════════════════════════════════════════════════════════
   Global header / menu bar — VERBATIM from club_crypto_01 / portfolio.
   ════════════════════════════════════════════════════════════════════ */
#header-box { background: var(--accent); }
#header {
    width: min(1280px, calc(100% - 32px));
    margin: 0 auto;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: relative;
}
#site-info { padding: 12px 0; }
#site-info a {
    font-family: var(--heading-font);
    font-weight: 700;
    font-size: 20px;
    letter-spacing: .04em;
    color: #f4f4f4;
    text-decoration: none;
}
#site-info a:hover { color: var(--gold); }

.global-nav .menu-box {
    list-style: none; margin: 0; padding: 0;
    display: flex; align-items: stretch;
}
.global-nav .menu-item { position: relative; }
.global-nav .menu-item > a {
    display: flex; align-items: center;
    height: 60px; padding: 0 16px;
    color: #f4f4f4; text-decoration: none;
    font-size: 14px; font-weight: normal; white-space: nowrap;
    transition: color .15s ease;
}
.global-nav .menu-item > a:hover { color: var(--gold); }
.global-nav .menu-item-has-children > a::after {
    content: "\25BE"; margin-left: 6px; font-size: 11px; opacity: .85;
}
.global-nav .sub-menu {
    list-style: none; margin: 0; padding: 6px 0;
    position: absolute; top: 100%; left: 0;
    min-width: 180px; background: #fff;
    border: 1px solid var(--line); border-radius: 10px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, .12);
    opacity: 0; visibility: hidden; transform: translateY(6px);
    transition: opacity .15s ease, transform .15s ease, visibility .15s;
    z-index: 30;
}
.global-nav .menu-item-has-children:hover .sub-menu {
    opacity: 1; visibility: visible; transform: translateY(0);
}
.global-nav .sub-menu a {
    display: block; padding: 8px 16px;
    color: var(--text); text-decoration: none;
    font-size: 13px; font-weight: 600;
}
.global-nav .sub-menu a:hover { color: var(--accent); background: var(--soft-accent); }
#navtoggle   { display: none; }
.sp-menu-open { display: none; }
@media (max-width: 767px) {
    #header { min-height: 56px; }
    .sp-menu-open {
        display: inline-flex; flex-direction: column;
        justify-content: center; gap: 5px;
        width: 44px; height: 44px; padding: 0 10px; cursor: pointer;
    }
    .cps-icon-bar {
        display: block; height: 2px; background: #f4f4f4;
        border-radius: 2px;
        transition: transform .2s ease, opacity .2s ease;
    }
    .global-nav {
        position: absolute; top: 56px; left: 0; right: 0;
        background: #fff; border-top: 1px solid var(--line);
        max-height: 0; overflow: hidden;
        transition: max-height .25s ease;
    }
    #navtoggle:checked ~ .global-nav { max-height: 80vh; overflow: auto; }
    .global-nav .menu-box { display: block; }
    .global-nav .menu-item > a {
        height: auto; padding: 14px 18px;
        color: var(--text); font-weight: 600; border-bottom: 1px solid var(--line);
    }
    .global-nav .menu-item > a:hover { color: var(--accent); }
    .global-nav .menu-item-has-children > a::after { margin-left: auto; }
    .global-nav .sub-menu {
        position: static; opacity: 1; visibility: visible; transform: none;
        border: 0; border-radius: 0; box-shadow: none; padding: 0;
        background: #f7f8fa;
    }
    .global-nav .sub-menu a {
        padding: 11px 18px 11px 34px; border-bottom: 1px solid var(--line);
    }
    #navtoggle:checked ~ .sp-menu-open .cps-icon-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
    #navtoggle:checked ~ .sp-menu-open .cps-icon-bar:nth-child(2) { opacity: 0; }
    #navtoggle:checked ~ .sp-menu-open .cps-icon-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
}

/* ════════════════════════════════════════════════════════════════════
   Hero
   ════════════════════════════════════════════════════════════════════ */
.hero {
    display: grid;
    grid-template-columns: 1fr minmax(240px, 320px);
    gap: 24px; align-items: start; margin-bottom: 24px;
}
.eyebrow {
    color: var(--accent); font-size: 13px; letter-spacing: .08em;
    text-transform: uppercase; margin: 0 0 6px; font-weight: 700;
}
h1, h2, h3 { line-height: 1.25; margin: 0; font-family: var(--heading-font); }
h1 { font-size: clamp(28px, 4vw, 42px); letter-spacing: .01em; }
h2 { font-size: 22px; }
h3 { font-size: 14px; }
.lead { margin: 14px 0 0; color: var(--muted); max-width: 760px; }

.status-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.04);
    padding: 14px 18px;
}
.status-card .label { color: var(--muted); font-size: 13px; }
.status-card .value { font-size: 18px; font-weight: 700; margin-top: 4px; font-family: var(--heading-font); }
.status-card .sub   { color: var(--muted); font-size: 12px; margin-top: 6px; }

/* ════════════════════════════════════════════════════════════════════
   Card / panel base
   ════════════════════════════════════════════════════════════════════ */
.card,
.list-view,
.alerts,
.supplementary {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.04);
}

/* ════════════════════════════════════════════════════════════════════
   Main "Leverage Timeline" chart (Case A, M12+M13).
   Stacked panel: Price+OI line on top, Funding bar + state band on bottom.
   ════════════════════════════════════════════════════════════════════ */
.main-chart {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.04);
    padding: 20px 22px 22px;
    margin-bottom: 28px;
}
.main-chart-head {
    display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
    margin-bottom: 12px;
}
.main-chart-head h2 {
    font-family: var(--heading-font);
    color: var(--accent-strong);
    font-size: 18px;
    margin: 0;
}
.main-chart-head .sub {
    color: var(--muted); font-size: 12px;
}
.main-chart-controls {
    margin-left: auto;
    display: flex; gap: 14px; align-items: center;
}
.tab-group {
    display: inline-flex;
    background: var(--soft-accent);
    border-radius: 999px;
    padding: 2px;
}
.tab-group button {
    border: 0; background: transparent; color: var(--accent);
    padding: 6px 14px;
    font-family: var(--body-font); font-size: 13px; font-weight: 700;
    cursor: pointer; border-radius: 999px;
    transition: background-color .15s ease, color .15s ease;
}
.tab-group button:hover { color: var(--accent-strong); }
.tab-group button.active {
    background: var(--accent); color: #fff;
}
.main-chart-body {
    position: relative;
    display: flex; flex-direction: column;
}
.main-chart-top, .main-chart-bot {
    position: relative;
    width: 100%;
}
.main-chart-top { height: 280px; }
.main-chart-bot { height: 130px; margin-top: 4px; }
.main-chart-empty {
    color: var(--muted);
    background: var(--soft-accent);
    border-radius: 12px;
    text-align: center;
    padding: 60px 20px;
    font-size: 13px;
    line-height: 1.7;
}
.main-chart-legend {
    margin-top: 10px;
    display: flex; gap: 16px 22px; flex-wrap: wrap;
    font-size: 11px; color: var(--muted);
    align-items: center;
}
.main-chart-legend .swatch {
    display: inline-block; width: 14px; height: 8px;
    border-radius: 2px; margin-right: 6px;
    vertical-align: middle;
}
.swatch.s-CALM            { background: #d1d5db; }
.swatch.s-LONG_BUILDUP    { background: #93c5fd; }
.swatch.s-LONG_CROWDED    { background: #fca5a5; }
.swatch.s-SHORT_BUILDUP   { background: #5eead4; }
.swatch.s-SHORT_CROWDED   { background: #fcd34d; }
.swatch.s-RESET_CONFIRMED { background: #86efac; }
.swatch.s-MIXED,
.swatch.s-UNKNOWN         { background: #e5e7eb; }

/* ════════════════════════════════════════════════════════════════════
   Asset block
   ════════════════════════════════════════════════════════════════════ */
.asset-block { margin-top: 28px; }

.asset-header {
    display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap;
    padding-left: 13px; border-left: 5px solid var(--accent);
    margin-bottom: 12px;
}
.asset-header::after {
    content: ""; display: block;
    width: 44px; height: 3px; margin-top: 6px; margin-left: -13px;
    background: var(--gold); border-radius: 999px;
    flex-basis: 100%; order: 99;
}
.asset-header h2 {
    font-family: var(--heading-font);
    color: var(--accent-strong);
    font-size: 22px;
}
.asset-header .price {
    font-family: var(--heading-font); font-weight: 700; font-size: 20px;
    font-variant-numeric: tabular-nums;
}
.asset-header .change {
    font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums;
}
.asset-header .change.up   { color: var(--positive); }
.asset-header .change.down { color: var(--negative); }

/* State bar */
.state-bar {
    padding: 16px 18px;
    background: var(--soft-accent);
    border: 1px solid var(--line);
    border-left: 5px solid var(--accent);
    border-radius: 14px;
    margin-bottom: 16px;
}
.state-bar .state-label {
    font-family: var(--heading-font);
    font-weight: 700; font-size: 18px; color: var(--accent-strong);
}
.state-bar .headline { color: var(--text); margin-top: 4px; font-size: 14px; line-height: 1.7; }
.state-bar .rationale {
    color: var(--muted); font-size: 13px; margin-top: 10px;
    padding-left: 0; list-style: none;
}
.state-bar .rationale li { padding: 1px 0; }
.state-bar .rationale li::before { content: '・'; color: var(--accent); margin-right: 2px; }
.state-bar.state-CALM            { border-left-color: var(--state-calm); }
.state-bar.state-LONG_BUILDUP    { border-left-color: var(--state-buildup); }
.state-bar.state-LONG_CROWDED    { border-left-color: var(--state-crowd); }
.state-bar.state-SHORT_BUILDUP   { border-left-color: var(--state-buildup); }
.state-bar.state-SHORT_CROWDED   { border-left-color: var(--state-amber); }
.state-bar.state-RESET_CONFIRMED { border-left-color: var(--state-reset); }
.state-bar.state-MIXED,
.state-bar.state-UNKNOWN         { border-left-color: var(--state-mixed); }

/* ════════════════════════════════════════════════════════════════════
   Cards grid (§3.2)
   ════════════════════════════════════════════════════════════════════ */
.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card-grid.span-2 { grid-template-columns: 1fr; }
.card-grid + .card-grid { margin-top: 16px; }

.card { padding: 18px 20px; }
.card h3 {
    color: var(--accent);
    font-family: var(--heading-font);
    font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em;
    margin: 0 0 10px;
    display: flex; align-items: center; gap: 8px;
}
.card h3 .num {
    background: var(--accent); color: #fff;
    padding: 2px 8px; border-radius: 6px; font-size: 12px;
    font-family: var(--body-font);
}

.badge {
    display: inline-block; font-size: 11px; font-weight: 700;
    padding: 2px 8px; border-radius: 999px;
    margin-left: auto; letter-spacing: .04em;
}
.badge.observed  { background: rgba(15, 157, 139, 0.12); color: var(--positive); }
.badge.estimated { background: rgba(217, 119, 6, 0.12); color: var(--state-amber); }
.badge.reference { background: rgba(0, 141, 183, 0.12); color: var(--link); }
.badge.stale     { background: rgba(217, 51, 63, 0.12); color: var(--negative); }

.metric-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 0; border-bottom: 1px dashed var(--line);
    font-size: 14px;
}
.metric-row:last-child { border-bottom: none; }
.metric-row .k { color: var(--muted); }
.metric-row .v {
    font-variant-numeric: tabular-nums; font-weight: 700; text-align: right;
    color: var(--neutral);
}
.metric-row .v.up   { color: var(--positive); }
.metric-row .v.down { color: var(--negative); }
.metric-row .v.muted { color: var(--muted); font-weight: 500; }

.label-pill {
    margin-top: 10px; padding: 6px 12px;
    background: var(--soft-accent); color: var(--accent-strong);
    border-radius: 999px; font-size: 13px;
    text-align: center; font-weight: 700;
}

.chart-wrap { margin-top: 14px; height: 200px; position: relative; }
.chart-empty {
    color: var(--muted); text-align: center; padding: 30px 0; font-size: 13px;
    background: var(--soft-accent); border-radius: 12px;
}

/* Card ③ (Heatmap external) */
.card-heatmap .note { color: var(--muted); font-size: 13px; margin: 4px 0 12px; }
.card-heatmap .ext-link {
    display: inline-block; padding: 8px 16px;
    background: var(--accent); color: #fff;
    border-radius: 999px; font-weight: 700; font-size: 13px;
}
.card-heatmap .ext-link:hover { background: var(--accent-strong); text-decoration: none; }

/* Supplementary fold */
.supplementary { margin-top: 16px; padding: 14px 18px; }
.supplementary summary {
    cursor: pointer; color: var(--accent);
    font-family: var(--heading-font); font-weight: 700; font-size: 14px;
    list-style: none; user-select: none;
    text-transform: uppercase; letter-spacing: .06em;
    display: flex; align-items: center; gap: 8px;
}
.supplementary summary::-webkit-details-marker { display: none; }
.supplementary summary::after {
    content: '＋'; margin-left: auto; color: var(--muted-strong); color: var(--accent);
}
.supplementary[open] summary::after { content: '−'; }
.supplementary-grid {
    margin-top: 12px;
    display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px;
}

/* List view (§10.2) */
.list-view { margin-top: 28px; padding: 18px 20px; }
.list-view h2 {
    color: var(--accent); font-family: var(--heading-font);
    text-transform: uppercase; letter-spacing: .06em;
    font-size: 14px; margin: 0 0 12px;
}
.list-table {
    width: 100%; border-collapse: collapse; font-size: 14px;
}
.list-table th, .list-table td {
    text-align: left; padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    font-variant-numeric: tabular-nums;
}
.list-table th {
    color: var(--muted); font-weight: 700; font-size: 11px;
    text-transform: uppercase; letter-spacing: .06em;
}
.list-table tbody tr:hover { background: var(--soft-accent); }
.list-table td.v.up   { color: var(--positive); font-weight: 700; }
.list-table td.v.down { color: var(--negative); font-weight: 700; }
.list-table td:first-child { font-weight: 700; }
.list-table td:first-child a { color: var(--accent-strong); }

/* Alerts panel */
.alerts { margin-top: 24px; padding: 18px 20px; }
.alerts h2 {
    color: var(--accent); font-family: var(--heading-font);
    text-transform: uppercase; letter-spacing: .06em;
    font-size: 14px; margin: 0 0 12px;
}
.alert-item {
    padding: 12px 14px; margin-bottom: 8px;
    background: var(--soft-accent);
    border-left: 4px solid var(--state-mixed);
    border-radius: 0 10px 10px 0;
    font-size: 14px; line-height: 1.6;
}
.alert-item.severity-info { border-left-color: var(--link);     background: rgba(0, 141, 183, 0.06); }
.alert-item.severity-warn { border-left-color: var(--state-amber); background: rgba(217, 119, 6, 0.06); }
.alert-item.severity-high { border-left-color: var(--negative); background: rgba(217, 51, 63, 0.06); }
.alert-item .alert-type {
    font-weight: 700; margin-right: 8px; font-size: 11px;
    text-transform: uppercase; letter-spacing: .04em;
    color: var(--accent);
}

/* Data-quality strip */
.dq-row {
    display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px;
    font-size: 11px;
}
.dq-row .dq {
    padding: 2px 8px; border-radius: 999px;
    background: var(--soft-accent); color: var(--muted);
    font-weight: 700;
}
.dq.ok            { color: var(--positive); }
.dq.stale         { color: var(--state-amber); }
.dq.very_stale    { color: var(--negative); }
.dq.missing       { color: var(--muted); }
.dq.disabled,
.dq.external_only { color: var(--muted); }

/* Footer */
.disclaimer {
    color: var(--muted); font-size: 12px;
    border-top: 1px solid var(--line);
    margin-top: 36px; padding-top: 18px;
}
.loading { color: var(--muted); text-align: center; padding: 40px; }

/* Error / membership panel */
.error-banner {
    background: var(--warning-bg);
    border: 1px solid var(--warning-line);
    border-radius: 14px;
    padding: 14px 16px; margin-bottom: 20px;
}

/* Membership-denied panel (shown when PMPro returns 403). */
.membership-denied {
    max-width: 560px;
    margin: 32px auto;
    padding: 32px 28px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.04);
    text-align: center;
}
.membership-denied .md-icon {
    width: 56px; height: 56px;
    margin: 0 auto 14px;
    display: flex; align-items: center; justify-content: center;
    background: var(--soft-accent);
    color: var(--accent);
    border-radius: 999px;
    font-size: 26px;
    font-family: var(--heading-font);
    font-weight: 700;
}
.membership-denied h2 {
    font-family: var(--heading-font);
    color: var(--accent-strong);
    font-size: 22px;
    margin: 0 0 12px;
}
.membership-denied p {
    color: var(--text);
    font-size: 14px;
    line-height: 1.7;
    margin: 0 0 22px;
}
.membership-denied .md-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}
.membership-denied .md-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 22px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
    min-width: 140px;
}
.membership-denied .md-btn.primary {
    background: var(--accent);
    color: #fff;
}
.membership-denied .md-btn.primary:hover {
    background: var(--accent-strong);
    text-decoration: none;
}
.membership-denied .md-btn.secondary {
    background: var(--panel);
    color: var(--accent);
    border: 1.5px solid var(--accent);
}
.membership-denied .md-btn.secondary:hover {
    background: var(--soft-accent);
    text-decoration: none;
}
.membership-denied .md-note {
    margin-top: 18px;
    color: var(--muted);
    font-size: 12px;
}

@media (max-width: 767px) {
    .page { padding: 20px 0 40px; }
    .hero { grid-template-columns: 1fr; }
    .card-grid { grid-template-columns: 1fr; }
    .supplementary-grid { grid-template-columns: 1fr; }
    .list-table { font-size: 12px; }
    .list-table th:nth-child(5),
    .list-table td:nth-child(5),
    .list-table th:nth-child(6),
    .list-table td:nth-child(6) { display: none; }
}
