/* WDMA GLOBAL OPERATIONS COMMAND — console styling.
   Dark is the default surface; light is a selected alternate, not a flip.
   Data marks use categorical slots 1-3 and the reserved status palette, both
   validated against these surfaces for CVD separation and contrast. */

:root {
  color-scheme: dark;

  --plane: #070908;
  --surface-1: #0e1211;
  --surface-2: #151a18;
  --surface-3: #1b2220;

  --text-primary: #e8ece9;
  --text-secondary: #9aa5a0;
  --text-muted: #6b7873;

  --line: #1e2523;
  --line-strong: #2b3431;
  --grid: #1c2321;
  --axis: #2b3431;

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;

  --ramp-track: #143a6b;
  --ramp-fill: #3987e5;

  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;

  --delta-good: #0ca30c;
  --delta-bad: #e66767;

  --class-bg: #e8b400;
  --class-fg: #10120e;

  /* Korean falls back explicitly — none of the mono faces carry Hangul. */
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI",
          "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", "Apple SD Gothic Neo", "Malgun Gothic",
          "Noto Sans KR", monospace;

  --radius: 2px;
}

@media (prefers-color-scheme: light) {
  :root:where(:not([data-theme="dark"])) {
    color-scheme: light;

    --plane: #eceee9;
    --surface-1: #f7f8f5;
    --surface-2: #eaece7;
    --surface-3: #e0e3dc;

    --text-primary: #0b0f0e;
    --text-secondary: #4a534f;
    --text-muted: #78827d;

    --line: #d5d9d1;
    --line-strong: #bcc2b9;
    --grid: #dee2d9;
    --axis: #c2c8bf;

    --series-1: #2a78d6;
    --series-2: #eb6834;
    --series-3: #1baf7a;

    --ramp-track: #b7d3f6;
    --ramp-fill: #2a78d6;

    --delta-good: #006300;
    --delta-bad: #d03b3b;
  }
}

:root[data-theme="light"] {
  color-scheme: light;

  --plane: #eceee9;
  --surface-1: #f7f8f5;
  --surface-2: #eaece7;
  --surface-3: #e0e3dc;

  --text-primary: #0b0f0e;
  --text-secondary: #4a534f;
  --text-muted: #78827d;

  --line: #d5d9d1;
  --line-strong: #bcc2b9;
  --grid: #dee2d9;
  --axis: #c2c8bf;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;

  --ramp-track: #b7d3f6;
  --ramp-fill: #2a78d6;

  --delta-good: #006300;
  --delta-bad: #d03b3b;
}

/* ------------------------------------------------------------------ base -- */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, ol, ul, figure { margin: 0; }
ol, ul { padding: 0; list-style: none; }

:focus-visible {
  outline: 1px solid var(--series-1);
  outline-offset: 1px;
}

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

.shell {
  max-width: 1680px;
  margin: 0 auto;
  padding: 0 20px 40px;
}

/* -------------------------------------------------- classification banner -- */

.classbar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--class-bg);
  color: var(--class-fg);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-align: center;
  padding: 5px 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px 20px;
  flex-wrap: wrap;
}

.classbar--foot { position: static; }

.classbar__x {
  font-weight: 600;
  letter-spacing: 0.1em;
  opacity: 0.72;
}

/* ------------------------------------------------------------- command bar -- */

.cmdbar {
  position: sticky;
  top: 25px;
  z-index: 50;
  background: var(--surface-1);
  border-bottom: 1px solid var(--line-strong);
}

.cmdbar__inner {
  max-width: 1680px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.seal {
  width: 32px; height: 32px;
  flex: none;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--series-1);
}

.seal svg { width: 19px; height: 19px; display: block; }

.cmdbar__id { min-width: 0; }

.cmdbar__title {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.cmdbar__sub {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  white-space: nowrap;
}

.cmdbar__spacer { flex: 1 1 auto; }

.cmdbar__meta {
  display: flex;
  align-items: center;
  gap: 6px 14px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 11px;
}

.kv { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.kv__k { color: var(--text-muted); letter-spacing: 0.08em; font-size: 10px; }
.kv__v { color: var(--text-primary); font-variant-numeric: tabular-nums; }

.btn {
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  cursor: pointer;
}

.btn:hover { color: var(--text-primary); border-color: var(--text-muted); }

/* ------------------------------------------------------------- link strip -- */

.link {
  margin-top: 14px;
  border: 1px solid var(--line-strong);
  border-left: 2px solid var(--status-good);
  border-radius: var(--radius);
  background: var(--surface-1);
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
}

.link__cell {
  padding: 8px 14px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.link__cell:last-child { border-right: 0; }
.link__cell--grow { flex: 1 1 auto; }

.link__k {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  white-space: nowrap;
}

.link__v {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.led {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 12px;
  white-space: nowrap;
}

.led::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  flex: none;
  background: currentColor;
}

.led--good { color: var(--status-good); }
.led--warn { color: var(--status-warning); }
.led--crit { color: var(--status-critical); }
.led__t { color: var(--text-primary); }

/* --------------------------------------------------------------- sections -- */

.sec { margin-top: 26px; }

.sec__head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line-strong);
}

.sec__no {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--series-1);
  letter-spacing: 0.1em;
}

.sec__title {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.sec__note {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* ------------------------------------------------------------------ panel -- */

.panel {
  background: var(--surface-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.panel__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.panel__head::before {
  content: "";
  width: 2px;
  height: 11px;
  background: var(--series-1);
  flex: none;
}

.panel__title {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel__mark {
  margin-left: auto;
  flex: none;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 1px 5px;
}

.panel__sub {
  padding: 8px 12px 0;
  font-size: 11px;
  color: var(--text-muted);
}

.panel__body { padding: 12px; min-width: 0; }
.panel__body--flush { padding: 0; }

.toggle {
  flex: none;
  height: 20px;
  padding: 0 7px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  cursor: pointer;
}

.toggle:hover { color: var(--text-primary); border-color: var(--text-muted); }
.toggle[aria-pressed="true"] {
  color: var(--text-primary);
  background: var(--surface-3);
  border-color: var(--text-muted);
}

/* ----------------------------------------------------------- partner grid -- */

.pgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 10px;
}

.proster { width: 100%; border-collapse: collapse; font-family: var(--mono); }

.proster td {
  padding: 4px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  vertical-align: baseline;
}

.proster tr:last-child td { border-bottom: 0; }
.proster tr:hover td { background: var(--surface-2); }

.proster__node {
  color: var(--series-1);
  white-space: nowrap;
  width: 1%;
  padding-right: 10px;
}

.proster__name {
  font-family: var(--font);
  font-size: 12px;
  color: var(--text-primary);
}

.proster__tag {
  text-align: right;
  color: var(--text-muted);
  white-space: nowrap;
  width: 1%;
}

/* Rules live on the cells, not on a background showing through gaps, so a
   short final row leaves clean surface rather than a block of gap colour. */
.states {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  border-top: 1px solid var(--line);
}

.state {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
}

.state__node { color: var(--text-muted); flex: none; }
.state__code { color: var(--series-1); flex: none; }

.state__name {
  font-family: var(--font);
  font-size: 12px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------------------------------------------------------------- filters -- */

.filters {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: var(--surface-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.field__label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--text-muted);
}

.field select {
  appearance: none;
  height: 28px;
  min-width: 176px;
  padding: 0 28px 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background-color: var(--surface-2);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 14px) 13px, calc(100% - 10px) 13px;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
}

.filters__reset { margin-left: auto; }

/* ----------------------------------------------------------------- readout -- */

.readouts {
  display: grid;
  grid-template-columns: minmax(250px, 1.25fr) repeat(auto-fit, minmax(168px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.ro { padding: 10px 12px; display: flex; flex-direction: column; gap: 1px; }

.ro__k {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--text-muted);
}

.ro__v {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-top: 3px;
  line-height: 1.1;
}

.ro--hero .ro__v { font-size: 48px; letter-spacing: -0.03em; }

.ro__d { font-family: var(--mono); font-size: 10px; color: var(--text-muted); }
.ro__d b { font-weight: 700; }
.ro__d.is-good b { color: var(--delta-good); }
.ro__d.is-bad b { color: var(--delta-bad); }

.ro__spark { margin-top: auto; padding-top: 8px; }
.ro__spark svg { display: block; width: 100%; height: 26px; }

.ro__foot {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 11px;
}

.ro__foot .kv { flex-direction: column; gap: 1px; }

/* ------------------------------------------------------------------ charts -- */

.grid-a {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.grid-b {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.plot { position: relative; min-width: 0; }
.plot svg { display: block; width: 100%; height: auto; overflow: visible; }

.ax-line { stroke: var(--axis); stroke-width: 1; }
.ax-grid { stroke: var(--grid); stroke-width: 1; }

.ax-text {
  fill: var(--text-muted);
  font-family: var(--mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.ax-text--mid { text-anchor: middle; }
.ax-text--end { text-anchor: end; }

.mark-label {
  fill: var(--text-secondary);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
}

.mark-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.mark-dot { stroke: var(--surface-1); stroke-width: 2; }
.crosshair { stroke: var(--axis); stroke-width: 1; pointer-events: none; }
.hit { fill: transparent; cursor: crosshair; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  background: none;
  border: 0;
  padding: 2px 0;
  cursor: pointer;
}

.legend-item[aria-pressed="false"] { opacity: 0.4; }
.legend-key { width: 12px; height: 3px; flex: none; }
.legend-item__v { color: var(--text-muted); font-variant-numeric: tabular-nums; }

.tip {
  position: absolute;
  z-index: 20;
  min-width: 158px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -100%);
  transition: opacity 0.08s linear;
  font-family: var(--mono);
}

.tip.is-on { opacity: 1; }

.tip__t {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  margin-bottom: 5px;
  color: var(--text-primary);
}

.tip__r {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--text-secondary);
  padding: 1px 0;
}

.tip__k { width: 8px; height: 8px; flex: none; }
.tip__v { margin-left: auto; color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------- prec stack -- */

.stack { display: flex; width: 100%; height: 24px; gap: 2px; }
.stack__seg { height: 100%; border: 0; padding: 0; cursor: pointer; }

.rows { display: flex; flex-direction: column; }

.subhead {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.row {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
}

.row:last-child { border-bottom: 0; }
.row__glyph { font-size: 9px; width: 11px; flex: none; }
.row__code { color: var(--text-muted); width: 20px; flex: none; }
.row__label { letter-spacing: 0.08em; }

.row__n {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text-primary);
}

.row__pct {
  width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

/* ----------------------------------------------------------------- meters -- */

.meters { display: flex; flex-direction: column; gap: 12px; }

.meter__head {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin-bottom: 5px;
  font-family: var(--mono);
  font-size: 11px;
}

.meter__code { color: var(--series-1); flex: none; letter-spacing: 0.08em; }
.meter__label { font-family: var(--font); font-size: 12px; }

.meter__v {
  margin-left: auto;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.meter__track { height: 6px; background: var(--ramp-track); overflow: hidden; }
.meter__fill { height: 100%; background: var(--ramp-fill); }

.meter__sub {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 5px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  white-space: nowrap;
  color: var(--text-primary);
}

.chip__g { font-size: 8px; line-height: 1; }
.chip--critical .chip__g { color: var(--status-critical); }
.chip--serious .chip__g { color: var(--status-serious); }
.chip--warning .chip__g { color: var(--status-warning); }
.chip--good .chip__g { color: var(--status-good); }

/* ------------------------------------------------------------------ tables -- */

.tbl-wrap { overflow: auto; max-height: 560px; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 11px;
}

table.data caption {
  text-align: left;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}

table.data th,
table.data td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

table.data th {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-strong);
}

table.data td.num,
table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

table.data td.key { color: var(--series-1); }
table.data td.ev { font-family: var(--font); font-size: 12px; }

table.data td.clip {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
}

table.data tbody tr:hover td { background: var(--surface-2); }

.empty {
  padding: 26px 12px;
  text-align: center;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
}

[hidden] { display: none !important; }

/* ------------------------------------------------------------------ footer -- */

.foot {
  margin-top: 24px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.foot__spacer { flex: 1 1 auto; }

/* -------------------------------------------------------------- responsive -- */

@media (max-width: 1240px) {
  .grid-a { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .grid-a > :first-child { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
  .grid-a,
  .grid-b { grid-template-columns: minmax(0, 1fr); }
  .grid-a > :first-child { grid-column: auto; }
  .readouts { grid-template-columns: minmax(0, 1fr); }
  .cmdbar { position: static; }
}

@media (max-width: 620px) {
  .shell { padding: 0 12px 32px; }
  .cmdbar__inner { padding: 10px 12px; }
  .ro--hero .ro__v { font-size: 38px; }
  .field { flex: 1 1 100%; }
  .field select { min-width: 100%; }
}

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