/* Navy theme: navy sidebar, cool light-blue canvas. */
:root {
  color-scheme: light;
  --sidebar-bg: #0b2545;
  --sidebar-ink: #eef3fa;
  --sidebar-muted: #9db0cb;
  --sidebar-active: #1d4477;
  --sidebar-hover: #14345e;
  --accent: #9ec5f4;
  --accent-ink: #0b2545;

  --page: #f3f6fb;
  --glow-1: rgba(158, 197, 244, 0.45);
  --glow-2: rgba(183, 211, 246, 0.35);
  --card: #ffffff;
  --card-border: #dfe6f1;
  --inset: #f5f8fc;
  --ink: #0b1b33;
  --ink-2: #42526b;
  --muted: #74839a;
  --grid: #e7edf5;
  --axis: #c6d1e0;
  --chip: #e8eef7;
  --chip-active: #0b2545;
  --chip-active-ink: #ffffff;
  --up: #b4372f;
  --down: #12763a;
  --warn: #b26b00;

  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(11, 37, 69, 0.05), 0 4px 16px rgba(11, 37, 69, 0.05);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --sidebar-bg: #071a33;
    --sidebar-active: #173a66;
    --sidebar-hover: #0f2a4d;
    --page: #0c1626;
    --glow-1: rgba(42, 120, 214, 0.18);
    --glow-2: rgba(29, 68, 119, 0.25);
    --card: #13213a;
    --card-border: #24365a;
    --inset: #182945;
    --ink: #eef3fa;
    --ink-2: #c3cfe0;
    --muted: #8a9ab3;
    --grid: #1f3050;
    --axis: #34496f;
    --chip: #1c2e4e;
    --chip-active: #9ec5f4;
    --chip-active-ink: #0b2545;
    --up: #f07b72;
    --down: #4cc47a;
    --warn: #f0b04a;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --sidebar-bg: #071a33; --sidebar-active: #173a66; --sidebar-hover: #0f2a4d;
  --page: #0c1626; --glow-1: rgba(42, 120, 214, 0.18); --glow-2: rgba(29, 68, 119, 0.25);
  --card: #13213a; --card-border: #24365a; --inset: #182945;
  --ink: #eef3fa; --ink-2: #c3cfe0; --muted: #8a9ab3; --grid: #1f3050; --axis: #34496f;
  --chip: #1c2e4e; --chip-active: #9ec5f4; --chip-active-ink: #0b2545;
  --up: #f07b72; --down: #4cc47a; --warn: #f0b04a;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--page); color: var(--ink); font-size: 14px; line-height: 1.45; }
a { color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button { font: inherit; color: inherit; }
.muted { color: var(--muted); }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px; flex: none; background: var(--sidebar-bg); color: var(--sidebar-ink);
  display: flex; flex-direction: column; padding: 18px 10px 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 30;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 4px 8px 22px; }
.brand-mark { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.brand-mark svg { width: 22px; height: 22px; stroke-width: 2.4; }
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 12px; color: var(--sidebar-muted); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a, .nav button {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  text-decoration: none; color: var(--sidebar-muted); background: none; border: 0; cursor: pointer;
  text-align: left; font-size: 14px;
}
.nav a:hover, .nav button:hover { background: var(--sidebar-hover); color: var(--sidebar-ink); }
.nav a.active, .nav button.active { background: var(--sidebar-active); color: var(--sidebar-ink); font-weight: 600; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-muted); padding: 22px 10px 6px; opacity: .8; }
.regions .count { margin-left: auto; font-size: 12px; opacity: .7; }

.sidebar-foot { display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px; border-top: 1px solid rgba(255,255,255,0.08); font-size: 12.5px; }
.sidebar-foot .muted { color: var(--sidebar-muted); font-size: 12px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #888; flex: none; }
.status-dot.ok { background: #3cc06c; }
.status-dot.warn { background: #f0b04a; }
.status-dot.err { background: #e5534b; }
.status-text { min-width: 0; flex: 1; }
.icon-btn { background: none; border: 0; padding: 6px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; color: inherit; }
.icon-btn:hover { background: rgba(127,127,127,0.15); }

.main {
  flex: 1; min-width: 0;
  background:
    radial-gradient(900px 500px at 75% -10%, var(--glow-1), transparent 60%),
    radial-gradient(800px 600px at 60% 110%, var(--glow-2), transparent 60%),
    var(--page);
  background-attachment: fixed;
}
.topbar { display: flex; gap: 10px; align-items: center; padding: 18px 28px; border-bottom: 1px solid var(--card-border); background: color-mix(in srgb, var(--card) 55%, transparent); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 10; }
.topbar h1 { margin: 0; font-size: 19px; }
.topbar .muted { font-size: 13px; }
.menu-btn { display: none; }
.content { padding: 26px 28px 48px; max-width: 1360px; }

.hello h2 { margin: 0; font-size: 22px; }
.hello .tag { color: var(--muted); margin: 4px 0 20px; font-size: 13.5px; }

/* ---------- cards ---------- */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card h3 { margin: 0 0 4px; font-size: 15px; display: flex; gap: 8px; align-items: center; }
.card .sub { color: var(--muted); font-size: 12.5px; }
.section { margin-top: 22px; }
.section-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-head h3 { margin: 0; font-size: 16px; }

.market-card { display: flex; flex-direction: column; gap: 12px; cursor: pointer; transition: border-color .15s, transform .15s; }
.market-card:hover { border-color: var(--axis); }
.market-card.selected { outline: 2px solid var(--chip-active); outline-offset: -1px; }
.market-card .head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.market-card .name { font-weight: 650; font-size: 15px; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; row-gap: 12px; gap: 8px; background: var(--inset); border: 1px dashed var(--card-border); border-radius: 10px; padding: 10px; }
.metric .label { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.metric .value { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.metric .value.na { color: var(--muted); font-weight: 500; font-size: 16px; }
.metric .delta { font-size: 11.5px; color: var(--ink-2); white-space: nowrap; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--muted); }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: var(--chip); color: var(--ink-2); white-space: nowrap; }
.badge.warn { color: var(--warn); }

/* ---------- controls ---------- */
.controls { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.seg { display: inline-flex; background: var(--chip); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 5px 11px; border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.seg button.active { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--card-border); background: var(--card); border-radius: 99px; padding: 4px 11px 4px 9px; font-size: 12.5px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.chip .sw { width: 10px; height: 10px; border-radius: 3px; background: var(--axis); }
.chip.on { color: var(--ink); border-color: var(--axis); font-weight: 600; }
.chip:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- chart ---------- */
.chart-wrap { position: relative; height: 380px; margin-top: 8px; }
.chart-empty[hidden] { display: none; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 20px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.tooltip { position: fixed; pointer-events: none; z-index: 50; background: var(--card); border: 1px solid var(--card-border); box-shadow: 0 8px 24px rgba(0,0,0,.12); border-radius: 10px; padding: 9px 11px; font-size: 12.5px; opacity: 0; transition: opacity .1s; min-width: 170px; }
.tooltip .t-date { font-weight: 600; margin-bottom: 4px; }
.tooltip .row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tooltip .row span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tooltip i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.tooltip b { font-variant-numeric: tabular-nums; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--inset); }
tbody tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--row-color, var(--chip-active)); }
.region-row td { background: var(--inset); font-weight: 600; color: var(--ink-2); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; cursor: default; }

/* ---------- cap rates ---------- */
.segments { display: flex; flex-direction: column; gap: 6px; }
.segrow { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; font-size: 13px; }
.segrow .bar { grid-column: 1 / -1; height: 6px; background: var(--inset); border-radius: 4px; overflow: hidden; }
.segrow .bar > div { height: 100%; background: var(--s1); border-radius: 0 4px 4px 0; }
.segrow b { font-variant-numeric: tabular-nums; }
.source { font-size: 12px; color: var(--muted); }
.source a { color: var(--ink-2); }
.note { font-size: 12.5px; color: var(--ink-2); background: var(--inset); border: 1px dashed var(--card-border); border-radius: 10px; padding: 10px 12px; }
.banner { border-radius: 12px; padding: 12px 14px; margin-bottom: 18px; border: 1px solid var(--card-border); background: var(--card); font-size: 13.5px; }
.banner.warn { border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.banner code { background: var(--inset); padding: 1px 5px; border-radius: 5px; }

/* ---------- mobile ---------- */
.scrim { display: none; }
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; }
  .menu-btn { display: grid; }
  .topbar { padding: 14px 16px; }
  .content { padding: 18px 16px 40px; }
  .chart-wrap { height: 300px; }
  .metric .value { font-size: 18px; }
}

/* ---------- cap rate sectors & sources ---------- */
.seg-detail { color: var(--muted); font-size: 12px; margin-left: 4px; }
.segrow.missing { color: var(--muted); padding-bottom: 6px; border-bottom: 1px dashed var(--card-border); }
.segrow.missing span:first-child { color: var(--ink-2); }
.badge.basis-prime { background: var(--chip-active); color: var(--chip-active-ink); }
.sources h3 { margin: 0 0 6px; font-size: 16px; }
.sources p, .sources li { color: var(--ink-2); font-size: 13.5px; max-width: 900px; }
.sources a { color: var(--ink); }
.sources td { white-space: normal; vertical-align: top; }
.seg-sources { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.6; }

/* ---------- language switch (bottom of sidebar) ---------- */
.lang-switch { display: flex; align-items: center; gap: 8px; padding: 10px 10px 12px; color: var(--sidebar-muted); font-size: 12.5px; }
.lang-switch .lang-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.lang-switch .lang-seg { margin-left: auto; }
.lang-seg { display: inline-flex; background: rgba(255,255,255,0.08); border-radius: 8px; padding: 3px; gap: 2px; }
.lang-seg button { white-space: nowrap; border: 0; background: none; color: var(--sidebar-muted); padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 12.5px; }
.lang-seg button:hover { color: var(--sidebar-ink); }
.lang-seg button.active { background: var(--sidebar-active); color: var(--sidebar-ink); font-weight: 600; }
:lang(ko) body, body:lang(ko) { word-break: keep-all; }

/* ---------- US daily 10Y ---------- */
.metric .daily { font-size: 11.5px; color: var(--ink-2); margin-top: 2px; white-space: nowrap; }
td .daily { font-size: 11.5px; color: var(--ink-2); font-weight: 400; margin-top: 2px; }
.daily-figs { display: flex; flex-wrap: wrap; gap: 16px 48px; }
.daily-figs .label { font-size: 12px; color: var(--muted); }
.daily-figs .big { font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }
.daily-figs .muted-big { color: var(--ink-2); }
.daily-figs .delta { font-size: 12.5px; color: var(--ink-2); }

/* Secondary links (Sources) sit at the bottom of the sidebar, out of the main menu */
.nav-secondary { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.08); }
.nav-secondary a { font-size: 13px; padding: 6px 10px; }
.nav-secondary svg { width: 16px; height: 16px; }

/* ---------- copyright footer ---------- */
.site-footer { max-width: 1360px; padding: 0 28px 28px; font-size: 12px; color: var(--muted); }
@media (max-width: 860px) { .site-footer { padding: 0 16px 24px; } }
