/* EQUINOX Insight — dashboard styles.
   Direction: an editorial instrument panel. Paper surfaces, ink type with strong
   scale contrast, one amber "lamp" accent for the brand, and the validated data
   palette (dataviz reference instance) reserved for the data itself. */

:root {
  color-scheme: light;
  --paper: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6d68;
  --faint: #898781;
  --line: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.1);
  --wash: rgba(11, 11, 11, 0.04);
  --lamp: #b87800;
  --lamp-soft: #fbefd5;
  --focus: #2a78d6;
  --good: #006300;
  --bad: #b42f2f;
  --warn-bg: #fff4dc;
  --bad-bg: #fdecec;
  --good-bg: #e8f4e8;

  /* data palette — categorical (fixed order, never cycled) */
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --s5: #e87ba4;
  --s6: #008300;
  --s7: #6250d6;
  --s8: #e34948;
  --s-cmp: #b9b7ae;
  --seq-100: #cde2fb;
  --seq-250: #86b6ef;
  --seq-450: #2a78d6;
  --seq-650: #104281;

  /* keyword flags (chapter 4 of the requirements) */
  --kw-orange: #eb6834;
  --kw-yellow: #eda100;
  --kw-blue: #2a78d6;

  /* Japanese text uses a Universal Design font (BIZ UDPGothic) for easy reading */
  --font: -apple-system, "Segoe UI", "BIZ UDPGothic", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --shadow: 0 1px 0 rgba(11, 11, 11, 0.04), 0 8px 24px -16px rgba(11, 11, 11, 0.18);
  --shadow-pop: 0 12px 40px -12px rgba(11, 11, 11, 0.28);
  --side-w: 236px;
  --dur: 160ms;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #a3a198;
    --faint: #898781;
    --line: #2c2c2a;
    --axis: #383835;
    --ring: rgba(255, 255, 255, 0.1);
    --wash: rgba(255, 255, 255, 0.05);
    --lamp: #e0a33a;
    --lamp-soft: #3a2c12;
    --focus: #3987e5;
    --good: #0ca30c;
    --bad: #e66767;
    --warn-bg: #3a2c12;
    --bad-bg: #3b1d1d;
    --good-bg: #13301a;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --s-cmp: #5b5a55;
    --seq-100: #104281; --seq-250: #1c5cab; --seq-450: #3987e5; --seq-650: #9ec5f4;
    --kw-orange: #d95926; --kw-yellow: #c98500; --kw-blue: #3987e5;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.4), 0 8px 24px -16px rgba(0, 0, 0, 0.7);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #a3a198;
  --faint: #898781;
  --line: #2c2c2a;
  --axis: #383835;
  --ring: rgba(255, 255, 255, 0.1);
  --wash: rgba(255, 255, 255, 0.05);
  --lamp: #e0a33a;
  --lamp-soft: #3a2c12;
  --focus: #3987e5;
  --good: #0ca30c;
  --bad: #e66767;
  --warn-bg: #3a2c12;
  --bad-bg: #3b1d1d;
  --good-bg: #13301a;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --s-cmp: #5b5a55;
  --seq-100: #104281; --seq-250: #1c5cab; --seq-450: #3987e5; --seq-650: #9ec5f4;
  --kw-orange: #d95926; --kw-yellow: #c98500; --kw-blue: #3987e5;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.4), 0 8px 24px -16px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.6 var(--font);
  font-feature-settings: "palt" 0;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); letter-spacing: 0.12em; font-size: 12px; text-transform: uppercase; }

/* ---------------------------------------------------------------- layout */
.app { min-height: 100vh; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); }
.side {
  position: sticky; top: 0; height: 100vh; overflow: hidden;
  border-right: 1px solid var(--line); background: var(--paper);
  display: flex; flex-direction: column; padding: 18px 14px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; background: var(--ink); display: grid; place-items: center; flex: none; }
.brand-mark svg { width: 18px; height: 18px; fill: var(--surface); }
.brand-name { font-weight: 700; letter-spacing: 0.02em; line-height: 1.1; }
.brand-name small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); letter-spacing: 0.14em; text-transform: uppercase; }

/* only the menu scrolls: the brand and the display switch stay in view */
.nav { display: flex; flex-direction: column; gap: 1px; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; margin: 0 -14px; padding: 0 14px 8px; }
.side-top { display: flex; align-items: flex-start; gap: 4px; }
.side-top .brand { flex: 1; min-width: 0; }
.rail-btn { flex: none; padding: 6px; margin-top: 2px; }
.rail-btn svg { width: 18px; height: 18px; }
.nav-sec + .nav-sec { margin-top: 4px; }
.nav-sec-h { display: flex; align-items: center; gap: 2px; margin: 6px 0 2px; }
.nav-sec-t {
  flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 6px;
  border: 0; background: transparent; padding: 5px 8px; border-radius: var(--r-sm); cursor: pointer; text-align: left;
  font-size: 12.5px; font-weight: 700; letter-spacing: 0.04em; color: var(--ink-2);
}
.nav-sec-t:hover { background: var(--wash); color: var(--ink); }
.nav-sec-t svg { width: 14px; height: 14px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--dur) var(--ease); }
.nav-sec-t[aria-expanded="false"] svg { transform: rotate(-90deg); }
/* the section holding the current page keeps a lamp mark, also while it is closed */
.nav-sec.has-current > .nav-sec-h .nav-sec-t { color: var(--ink); }
.nav-sec.has-current > .nav-sec-h .nav-sec-t > span::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 8px; border-radius: 50%; background: var(--lamp); vertical-align: 0.15em; }
.nav-sec-b { display: flex; flex-direction: column; gap: 1px; }
.nav a .nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a .nav-ext { margin-left: auto; display: inline-flex; }
.nav a .nav-ext svg { width: 13px; height: 13px; opacity: 0.6; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--r-sm); text-decoration: none; color: var(--ink-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav a svg { width: 17px; height: 17px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: 0.85; }
.nav a:hover { background: var(--wash); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--ring); }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--lamp); }
.side-foot { flex: none; padding: 14px 8px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); display: grid; gap: 10px; }
.side-pref { display: grid; gap: 6px; }
.side-pref-l { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.side-pref-l svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side-pref .seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.side-pref .seg button { padding: 0 6px; }
.side-user { overflow-wrap: anywhere; }
.side-foot .btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side-foot .row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 10px 28px;
}
.topbar-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.view-title { font-size: 20px; font-weight: 700; letter-spacing: 0.01em; margin: 0 12px 0 0; }
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.view { padding: 24px 28px 64px; display: grid; gap: 20px; min-width: 0; }
.view.is-loading > * { opacity: 0.55; transition: opacity var(--dur) var(--ease); pointer-events: none; }
.menu-btn { display: none; }

/* ---------------------------------------------------------------- surfaces */
.card {
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: 0 0 0 1px var(--ring), var(--shadow);
  min-width: 0;
}
.card-h { display: flex; align-items: baseline; gap: 12px; padding: 16px 20px 0; flex-wrap: wrap; }
.card-h h2, .card-h h3 { margin: 0; font-size: 14px; font-weight: 700; letter-spacing: 0.04em; }
.card-h .sub { color: var(--muted); font-size: 13px; }
.card-h .actions { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; min-width: 0; }
.card-h .actions .input { max-width: 100%; }
.card-b { padding: 14px 20px 18px; min-width: 0; }
.card-b.flush { padding: 8px 0 4px; }
.eyebrow { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

.grid { display: grid; gap: 20px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prose { max-width: 70ch; color: var(--ink-2); }
.prose p { margin: 0 0 8px; }

/* ---------------------------------------------------------------- KPI */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) 340px; }
.hero-main { padding: 20px 22px 12px; min-width: 0; border-right: 1px solid var(--line); }
.hero-figure { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin: 6px 0 4px; }
.hero-figure .v { font-size: 52px; line-height: 1; font-weight: 650; letter-spacing: -0.02em; }
.hero-figure .unit { font-size: 15px; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; }
.kpi {
  position: relative; text-align: left;
  padding: 14px 18px; border-bottom: 1px solid var(--line); min-width: 0;
  transition: background var(--dur) var(--ease);
}
.kpi:nth-child(odd) { border-right: 1px solid var(--line); }
/* the whole tile is the button (cover), the ⓘ sits above it */
.kpi-hit { position: absolute; inset: 0; width: 100%; margin: 0; padding: 0; border: 0; background: transparent; cursor: pointer; border-radius: 0; }
.kpi-hit:focus-visible { outline-offset: -3px; }
.kpi .info-i { z-index: 1; }
.kpi:not(.static):hover { background: var(--wash); }
.kpi.is-on, .kpi.is-on:hover { background: var(--lamp-soft); }
.kpi.is-on .kpi-l::before { background: var(--lamp); }
.kpi-l { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.kpi-l::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--line); flex: none; }
.kpi-v { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; margin-top: 2px; }
.kpi.static { cursor: default; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; padding: 1px 6px; border-radius: 999px; white-space: nowrap; }
.delta.good { color: var(--good); background: var(--good-bg); }
.delta.bad { color: var(--bad); background: var(--bad-bg); }
.delta.flat { color: var(--muted); background: var(--wash); }
.delta svg { width: 10px; height: 10px; fill: currentColor; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; }
.tile { padding: 16px 20px; border-right: 1px solid var(--line); min-width: 0; }
.tile:last-child { border-right: 0; }
.tile .kpi-v { font-size: 26px; }

/* ---------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:hover { border-color: var(--axis); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--surface); font-weight: 600; }
.btn-primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--lamp)); border-color: transparent; }
.btn-danger { color: var(--bad); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--wash); border-color: transparent; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.seg { display: inline-flex; padding: 3px; border-radius: 8px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--ring); gap: 2px; }
.seg button { border: 0; background: transparent; height: 26px; padding: 0 10px; border-radius: 6px; cursor: pointer; color: var(--ink-2); white-space: nowrap; font-size: 13px; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--ring), 0 1px 2px rgba(0, 0, 0, 0.06); }

.select, .input, .textarea {
  height: 34px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface);
  padding: 0 10px; min-width: 0;
}
.select { padding-right: 28px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%23898781' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 12px; }
.textarea { height: auto; min-height: 80px; padding: 8px 10px; resize: vertical; width: 100%; }
.input:hover, .select:hover { border-color: var(--axis); }
.input[type="date"] { padding-right: 6px; }
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > span, .field > label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.field > .btn { justify-self: start; }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--ink); }

.range-pop { position: relative; }
.range-btn { min-width: 210px; justify-content: space-between; }
.popover {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 260px;
  background: var(--surface); border-radius: var(--r); box-shadow: 0 0 0 1px var(--ring), var(--shadow-pop);
  padding: 6px;
}
.popover .opt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: transparent; border-radius: 6px; cursor: pointer; text-align: left; }
.popover .opt:hover { background: var(--wash); }
.popover .opt .tick { width: 16px; font-weight: 800; }
.popover .opt[aria-selected="true"] { font-weight: 600; }
.popover .custom { border-top: 1px solid var(--line); margin-top: 6px; padding: 10px 6px 4px; display: grid; gap: 8px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 10px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip .dot, .key-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge.lamp { background: var(--lamp-soft); color: var(--lamp); }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th, .table td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { position: sticky; top: 0; background: var(--surface); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; color: var(--muted); white-space: nowrap; z-index: 1; }
.table th.num, .table td.num { text-align: right; }
.table th button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
.table th button:hover { color: var(--ink); }
.table th[aria-sort] button { color: var(--ink); }
.table tbody tr { transition: background var(--dur) var(--ease); }
.table tbody tr:hover { background: var(--wash); }
.table tbody tr.clickable { cursor: pointer; }
.table td.page-cell { max-width: 520px; }
.table td.page-cell .p { font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table td.page-cell .t { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table td .cmp { display: block; font-size: 12px; color: var(--muted); }
.table tfoot td { font-weight: 600; border-bottom: 0; }
.table-foot { display: flex; align-items: center; gap: 10px; padding: 10px 16px; color: var(--muted); font-size: 12px; }

/* ---------------------------------------------------------------- bar lists */
.bars { display: grid; gap: 2px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(40px, 1fr) auto; gap: 12px; align-items: center; padding: 5px 4px; border-radius: 6px; }
.bar-row:hover { background: var(--wash); }
.bar-row .name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar-row .name span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; position: relative; }
.bar-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; background: var(--s1); min-width: 2px; }
.bar-row .val { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; font-size: 13px; }
.bar-row .val small { color: var(--muted); margin-left: 6px; }

/* ---------------------------------------------------------------- charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { stroke: none; opacity: 0.1; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; }
.chart .memo-mark { fill: var(--lamp); cursor: pointer; }
.chart .memo-line { stroke: var(--lamp); stroke-width: 1; opacity: 0.45; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-bottom: 8px; }
.legend .key { display: inline-flex; gap: 6px; align-items: center; }
.legend .line-key { width: 14px; height: 2px; border-radius: 2px; display: inline-block; }
.legend .rect-key { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.tooltip {
  position: fixed; z-index: 100; pointer-events: none; min-width: 140px; max-width: 320px;
  background: var(--surface); color: var(--ink); border-radius: 8px; padding: 9px 11px;
  box-shadow: 0 0 0 1px var(--ring), var(--shadow-pop); font-size: 12px;
}
.tooltip .tt-h { color: var(--muted); margin-bottom: 4px; }
.tooltip .tt-row { display: grid; grid-template-columns: 14px auto 1fr; gap: 6px; align-items: center; }
.tooltip .tt-row b { font-variant-numeric: tabular-nums; font-size: 13px; }
.tooltip .tt-row span:last-child { color: var(--muted); }
.tooltip .tt-key { width: 12px; height: 2px; border-radius: 2px; }

/* ---------------------------------------------------------------- misc */
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }
.notice { padding: 12px 14px; border-radius: var(--r); background: var(--warn-bg); color: var(--ink); font-size: 13px; }
.notice.info { background: var(--surface-2); }
.notice.bad { background: var(--bad-bg); }
.code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); border-radius: var(--r-sm); padding: 10px 12px; white-space: pre-wrap; word-break: break-all; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 200; }
.toast { background: var(--ink); color: var(--surface); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow-pop); font-size: 13px; max-width: 420px; animation: toast-in 220ms var(--ease); }
.toast.bad { background: var(--bad); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.modal-back { position: fixed; inset: 0; background: rgba(11, 11, 11, 0.35); z-index: 150; display: grid; place-items: center; padding: 20px; }
.modal { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; }
.modal-h { padding: 18px 20px 6px; font-weight: 700; font-size: 15px; }
.modal-b { padding: 8px 20px 16px; }
.modal-f { padding: 12px 20px 18px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--line); }

.drawer-back { position: fixed; inset: 0; z-index: 120; background: rgba(11, 11, 11, 0.25); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--surface); z-index: 121; box-shadow: var(--shadow-pop); overflow-y: auto; animation: drawer-in 220ms var(--ease); }
.drawer-h { position: sticky; top: 0; background: var(--surface); padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; z-index: 2; }
.drawer-h h2 { margin: 0; font-size: 15px; word-break: break-all; }
.drawer-b { padding: 16px 20px 40px; display: grid; gap: 18px; }
.drawer-b > * { min-width: 0; }
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; grid-column: 1 / -1; }
.login-card { width: min(380px, 100%); padding: 28px; display: grid; gap: 16px; }
.login-card h1 { margin: 0; font-size: 20px; }

.realtime { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--s3); box-shadow: 0 0 0 0 color-mix(in srgb, var(--s3) 60%, transparent); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ---------------------------------------------------------------- Japanese line breaks */
/* phrases.js wraps Japanese text in .jp: <wbr> between BudouX phrases, short phrases kept whole (.ph);
   lines break only between phrases (never 「わかりま｜す。」).
   auto-phrase is Chrome's own phrase breaking for text not handled yet. */
:root:lang(ja) body { word-break: auto-phrase; }
.jp { word-break: keep-all; overflow-wrap: break-word; }
.jp .ph { white-space: nowrap; }
/* in tables a word never splits: the table scrolls sideways instead; in a narrow tile the ⓘ wraps, not the word */
.table .jp { overflow-wrap: normal; }
.kpi-l { flex-wrap: wrap; row-gap: 2px; }
/* Not for Japanese: Chrome crashes the tab when text-wrap: pretty lays out the no-wrap .ph phrases
   at some widths (seen on a 390 px phone, 2026-11-01). BudouX already keeps the lines tidy there. */
:root:not(:lang(ja)) :is(p, li, dd, figcaption, blockquote, .hint, .notice, .prose, .empty) { text-wrap: pretty; }
h1, h2, h3, .view-title, .help-pop-h strong { text-wrap: balance; }

/* ---------------------------------------------------------------- ⓘ help */
.info-i {
  position: relative; display: inline-grid; place-items: center; flex: none; vertical-align: 0.1em;
  width: 18px; height: 18px; margin-left: 6px; border-radius: 50%;
  background: var(--surface-2); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--axis);
  font: 700 12px/1 var(--font); letter-spacing: 0; text-transform: none; font-style: normal;
  cursor: help; user-select: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.info-i::after { content: ""; position: absolute; inset: -4px; } /* 26px touch target */
.info-i:hover, .info-i[aria-expanded="true"] { background: var(--ink); color: var(--surface); box-shadow: none; }
.help-pop {
  position: fixed; z-index: 90; width: max-content; max-width: min(340px, calc(100vw - 16px));
  background: var(--surface); color: var(--ink); border-radius: var(--r);
  box-shadow: 0 0 0 1px var(--ring), var(--shadow-pop);
  padding: 12px 14px; font-size: 14px; line-height: 1.75; text-align: left; white-space: normal;
}
.help-pop-h { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 14.5px; }
.help-pop p { margin: 0; color: var(--ink-2); }
.help-pop-x { margin-left: auto; border: 0; background: transparent; font-size: 20px; line-height: 1; padding: 2px 8px; cursor: pointer; color: var(--muted); border-radius: var(--r-sm); }
.help-pop-x:hover { background: var(--wash); color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1180px) {
  .hero { grid-template-columns: 1fr; }
  .hero-main { border-right: 0; border-bottom: 1px solid var(--line); }
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kpi:nth-child(odd) { border-right: 0; }
  .kpi { border-right: 1px solid var(--line); }
  .span-3, .span-4, .span-5 { grid-column: span 6; }
  .span-7, .span-8 { grid-column: span 12; }
}
/* small menu: icons only (wide screens; phones use the slide-in menu) */
@media (min-width: 861px) {
  .app.rail { grid-template-columns: 68px minmax(0, 1fr); }
  .app.rail .side { padding: 14px 10px; }
  .app.rail .nav { margin: 0 -10px; padding: 0 10px 8px; }
  .app.rail .side-top { flex-direction: column; align-items: center; gap: 8px; padding-bottom: 8px; }
  .app.rail .brand { padding: 4px 0; }
  .app.rail .brand-name, .app.rail .nav-sec-h, .app.rail .side-foot { display: none; }
  .app.rail .nav-sec-b[hidden] { display: flex !important; }
  .app.rail .nav-sec + .nav-sec { border-top: 1px solid var(--line); padding-top: 4px; }
  .app.rail .nav a { justify-content: center; padding: 9px 0; }
  .app.rail .nav a[aria-current="page"]::before { left: -10px; }
  .app.rail .nav a .nav-label, .app.rail .nav a .nav-ext { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail-btn { display: none; }
  .side { position: fixed; z-index: 60; width: var(--side-w); transform: translateX(-100%); transition: transform 220ms var(--ease); box-shadow: var(--shadow-pop); }
  .app.nav-open .side { transform: none; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .view { padding: 16px 16px 48px; }
  .filters { margin-left: 0; width: 100%; }
  .span-3, .span-4, .span-5, .span-6 { grid-column: span 12; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(odd) { border-right: 1px solid var(--line); }
  .kpi:nth-child(even) { border-right: 0; }
  .hero-figure .v { font-size: 44px; }
  .range-btn { min-width: 0; }
  .tile { border-right: 0; border-bottom: 1px solid var(--line); }
}

/* ---------------------------------------------------------------- API・連携 */
.key-list, .conn-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.key-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--line); }
.key-row.is-active { background: var(--lamp-soft); margin: 0 -12px; padding-left: 12px; padding-right: 12px; border-radius: var(--r-sm); border-bottom-color: transparent; }
.key-main { display: grid; gap: 4px; min-width: 0; }
.key-name { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.key-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.key-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.bad-text { color: var(--bad); }
.sub-h { margin: 8px 0 0; font-size: 14px; }
.conn-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.conn-lamp { width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; background: var(--axis); }
.conn-lamp.ok { background: var(--good); }

/* ---------------------------------------------------------------- settings */
/* Each setting is a row: what it is (and why) on the left, its control on the right,
   sized to the value it holds. Groups end in a footer that carries their actions. */
.set-panel { display: grid; gap: 20px; }
.set-intro { margin: 0; color: var(--ink-2); font-size: 14px; max-width: 70ch; }
.set-card { container-type: inline-size; overflow: hidden; }
.set-card-h { display: flex; gap: 12px 20px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; padding: 20px 24px 18px; }
.set-card-h h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: 0.02em; line-height: 1.4; }
.set-card-d { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.7; max-width: 62ch; }
.set-chips { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.set-rows { padding: 0 24px; }
.set-row { display: grid; grid-template-columns: minmax(11rem, 0.36fr) minmax(0, 1fr); gap: 6px clamp(20px, 3vw, 44px); padding: 18px 0; border-top: 1px solid var(--line); align-items: start; }
.set-row-t { display: inline-flex; align-items: center; flex-wrap: wrap; font-size: 14px; font-weight: 600; color: var(--ink); padding-top: 6px; }
.set-row-hint { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.7; max-width: 42ch; }
.set-row-c { min-width: 0; display: grid; gap: 10px; justify-items: start; }
.set-row-c > .input, .set-row-c > .select, .set-row-c > .textarea, .set-stack > .textarea { width: min(100%, 30rem); }
.set-row-c > .input[type="number"] { width: 8rem; }
.set-row-c > input.switch { margin-top: 5px; }
.set-stack { display: grid; gap: 10px; justify-items: start; width: 100%; }
.set-val { font-size: 18px; font-weight: 650; padding-top: 3px; font-variant-numeric: tabular-nums; }
.set-card-b { padding: 0 24px 22px; display: grid; gap: 12px; }
.set-card-f { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; padding: 12px 24px; background: var(--surface-2); border-top: 1px solid var(--line); }
.set-card-f .spacer { flex: 1; }
.set-wide { width: 100%; }
/* technical values (domains, IDs, parameters) in mono, at the same size as other values */
.input.mono, .textarea.mono, .select.mono { font-size: 14px; }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); }
.chip.good { background: var(--good-bg); color: var(--good); box-shadow: none; }
.chip.off { color: var(--muted); }
.chip-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* a yes/no setting: a checkbox drawn as a track and thumb */
/* in settings-like screens every checkbox reads as a switch */
input.switch, .set-panel label.check > input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; flex: none; width: 42px; height: 24px; margin: 0; border-radius: 999px; cursor: pointer;
  background: var(--axis) radial-gradient(circle at 12px 50%, #fff 0 8px, transparent 8.5px) no-repeat 0 0;
  transition: background-color var(--dur) var(--ease), background-position var(--dur) var(--ease);
}
input.switch:checked, .set-panel label.check > input[type="checkbox"]:checked { background-color: var(--good); background-position: 18px 0; }
input.switch:disabled, .set-panel label.check > input[type="checkbox"]:disabled { opacity: 0.5; cursor: not-allowed; }
input.switch:focus-visible, .set-panel label.check > input[type="checkbox"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.set-panel label.check { gap: 10px; }

/* code to copy: the button sits on the code */
.code-box { position: relative; }
.code-box .code { padding-right: 96px; }
.code-box > .btn { position: absolute; top: 8px; right: 8px; }

/* directories editor */
.dir-list { display: grid; gap: 8px; }
.dir-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.dir-head { font-size: 12px; font-weight: 600; color: var(--muted); grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 108px; }
.dir-tools { display: flex; gap: 2px; }

/* the other settings sections (conversions, reports, Search Console, heatmaps) use the same rows */
.set-panel .card:not(.set-card) .field { grid-template-columns: minmax(11rem, 0.36fr) minmax(0, 1fr); grid-template-rows: min-content 1fr; grid-template-areas: "label control" "hint control"; column-gap: clamp(20px, 3vw, 44px); row-gap: 4px; padding: 14px 0; border-top: 1px solid var(--line); align-items: start; }
.set-panel .card:not(.set-card) .field > :first-child { grid-area: label; padding-top: 6px; font-size: 14px; color: var(--ink); }
.set-panel .card:not(.set-card) .field > .hint { grid-area: hint; }
.set-panel .card:not(.set-card) .field > :not(:first-child):not(.hint) { grid-area: control; justify-self: start; width: min(100%, 30rem); }
.set-panel .card:not(.set-card) .form-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }

@container (max-width: 640px) {
  .set-row { grid-template-columns: minmax(0, 1fr); padding: 14px 0; }
  .set-row-t { padding-top: 0; }
  .set-rows, .set-card-h, .set-card-b { padding-left: 16px; padding-right: 16px; }
  .set-card-f { padding: 10px 16px; }
  .dir-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .dir-tools { grid-column: 1 / -1; justify-content: flex-end; }
  .dir-head { display: none; }
}
@media (max-width: 760px) {
  .set-panel .card:not(.set-card) .field { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; grid-template-areas: "label" "control" "hint"; }
}
