/* ==========================================================================
   Rossmann Sales Terminal - quant-desk styling for the static forecast UI.
   No framework, no build step. Fonts are loaded via <link> in index.html.
   ========================================================================== */

:root {
  /* ---- palette ---- */
  --bg: #0a0b0d;
  --panel: #131519;
  --panel-deep: #0e1013;
  --border: #232630;
  --accent-amber: #ffb020;
  --accent-cyan: #00d9a3;
  --accent-red: #ff4d4d;
  --text: #e8e6e1;
  --text-muted: #6b6f76;
  --text-faint: #43484f;

  /* ---- type ---- */
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Consolas, monospace;

  /* ---- geometry ---- */
  --radius: 2px;
  --control-width: 340px;
  --gutter: 28px;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

/* scrollbars ------------------------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: #262a34 var(--bg); }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #262a34; }
::-webkit-scrollbar-thumb:hover { background: #333846; }

::selection { background: rgba(255, 176, 32, 0.25); color: var(--text); }

/* ==========================================================================
   Masthead
   ========================================================================== */

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding: 26px var(--gutter) 14px;
  border-bottom: 1px solid var(--border);
}

.masthead__title {
  margin: 0;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1;
}
/* Italic serif overhangs its box - pad so it cannot collide with the next word. */
.masthead__title em {
  font-style: italic;
  color: var(--accent-amber);
  padding: 0 0.09em;
}

.masthead__sub {
  margin: 8px 0 0;
  font-size: 9.5px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.masthead__right { text-align: right; }

.conn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.conn__dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  flex: none;
}
.conn__dot--idle { animation: blink 1.4s ease-in-out infinite; }
.conn__dot--live {
  background: var(--accent-cyan);
  box-shadow: 0 0 7px rgba(0, 217, 163, 0.75);
  animation: pulse 2.4s ease-in-out infinite;
}
.conn__dot--dead {
  background: var(--accent-red);
  box-shadow: 0 0 7px rgba(255, 77, 77, 0.7);
  animation: none;
}
.conn__label { color: var(--text); font-weight: 500; }
.conn__meta {
  margin-top: 5px;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.conn__meta b { color: var(--text); font-weight: 500; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes blink { 0%, 100% { opacity: 0.25; } 50% { opacity: 0.85; } }

/* ==========================================================================
   Shell
   ========================================================================== */

.shell {
  flex: 1;
  display: grid;
  grid-template-columns: var(--control-width) minmax(0, 1fr);
  gap: var(--gutter);
  padding: var(--gutter);
  max-width: 1560px;
  width: 100%;
  margin: 0 auto;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ==========================================================================
   Control panel
   ========================================================================== */

.control { padding: 20px 18px 18px; position: sticky; top: var(--gutter); }

.control__head {
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.control__head em { font-style: italic; color: var(--accent-amber); padding: 0 0.09em; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 22px 0 12px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.section-head:first-of-type { margin-top: 16px; }
.section-head__idx { color: #3a3f4a; letter-spacing: 0.1em; }

/* ---- fields ---- */
.field { margin-bottom: 15px; }

.field__label {
  display: block;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.field__input {
  width: 100%;
  background: var(--panel-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.03em;
  padding: 9px 11px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
  appearance: none;
}
.field__input:hover { border-color: #2e3340; }
.field__input:focus {
  outline: none;
  border-color: var(--accent-amber);
  box-shadow: 0 0 0 1px rgba(255, 176, 32, 0.18);
}
.field__input--area { resize: vertical; min-height: 96px; line-height: 1.7; }
.field__input::placeholder { color: #3f444d; }
.field__input[aria-invalid="true"] {
  border-color: var(--accent-red);
  box-shadow: 0 0 0 1px rgba(255, 77, 77, 0.18);
}

/* Chrome renders the native date/number widgets light-on-light otherwise. */
.field__input[type="date"] { color-scheme: dark; }
/* Chrome's native spinners paint a light chip on the dark well; drop them. */
.field__input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.field__input[type="number"]::-webkit-outer-spin-button,
.field__input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}
.field__input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.55) sepia(1) saturate(4) hue-rotate(2deg);
  cursor: pointer;
}

.select-wrap { position: relative; }
.select-wrap::after {
  content: "";
  position: absolute;
  right: 12px; top: 50%;
  width: 6px; height: 6px;
  border-right: 1px solid var(--text-muted);
  border-bottom: 1px solid var(--text-muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.select-wrap select { padding-right: 30px; cursor: pointer; }
.select-wrap option { background: var(--panel); color: var(--text); }

.field__hint {
  margin: 5px 0 0;
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.field__hint--block {
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 10.5px;
  line-height: 1.7;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.field__error {
  margin: 6px 0 0;
  font-size: 10px;
  letter-spacing: 0.09em;
  color: var(--accent-red);
}
.field__note {
  margin: 8px 0 0;
  font-size: 10px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}
.field__note--ok { color: var(--accent-cyan); }
.field__note--warn { color: var(--accent-amber); }
.field__note--bad { color: var(--accent-red); }

/* ---- toggles ---- */
.toggle-row { margin-bottom: 11px; }

.toggle {
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  user-select: none;
}
.toggle input {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}
.toggle__track {
  position: relative;
  width: 34px; height: 18px;
  border-radius: 9px;
  background: #2a2e37;
  flex: none;
  transition: background 160ms ease;
}
.toggle__thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 160ms cubic-bezier(0.3, 0.7, 0.4, 1), background 160ms ease;
}
.toggle input:checked + .toggle__track { background: var(--accent-cyan); }
.toggle input:checked + .toggle__track .toggle__thumb {
  transform: translateX(16px);
  background: var(--bg);
}
.toggle input:focus-visible + .toggle__track {
  box-shadow: 0 0 0 2px rgba(255, 176, 32, 0.4);
}
.toggle__label {
  font-size: 11.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text);
}

/* ---- disclosure ---- */
.disclosure {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-deep);
}
.disclosure__summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 12px;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 9px;
  transition: color 140ms ease;
}
.disclosure__summary::-webkit-details-marker { display: none; }
.disclosure__summary::before {
  content: "";
  width: 5px; height: 5px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 160ms ease;
  flex: none;
}
.disclosure[open] > .disclosure__summary::before { transform: rotate(45deg); }
.disclosure__summary:hover { color: var(--accent-amber); }
.disclosure__body { padding: 0 12px 12px; }
.disclosure__body--flush { padding: 0; }

/* ---- button ---- */
.btn {
  width: 100%;
  margin-top: 18px;
  padding: 12px 16px;
  background: var(--accent-amber);
  color: #0a0b0d;
  border: none;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 140ms ease, transform 90ms ease, opacity 140ms ease;
}
.btn:hover:not(:disabled) { background: #ffc247; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(255, 176, 32, 0.35); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.control__foot {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 9px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.control__foot .k { color: var(--text-faint); }
.control__foot .v { color: var(--text-muted); word-break: break-all; }

/* ==========================================================================
   Readout column
   ========================================================================== */

.readout-col { min-width: 0; }

@keyframes reveal {
  from { opacity: 0; transform: translateY(9px); }
  to   { opacity: 1; transform: none; }
}
.state { animation: reveal 420ms cubic-bezier(0.22, 0.68, 0.35, 1) both; }

/* ---- idle ---- */
.state--idle {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 64px 24px;
  text-align: center;
}
.idle__title {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 21px;
  color: #4e535c;
}
.idle__sub {
  margin: 11px 0 0;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #3d424b;
}

/* ---- loading ---- */
.loading {
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent-amber);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 30px 26px;
}
.loading__bar {
  height: 2px;
  background: #1c1f27;
  overflow: hidden;
  margin-bottom: 18px;
}
.loading__bar span {
  display: block;
  height: 100%;
  width: 34%;
  background: var(--accent-amber);
  animation: sweep 1.15s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}
@keyframes sweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(390%); }
}
.loading__msg {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-amber);
}
.loading__sub {
  margin: 8px 0 0;
  font-size: 10.5px;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  line-height: 1.7;
}

/* ---- fault ---- */
.fault {
  border: 1px solid rgba(255, 77, 77, 0.4);
  border-left: 2px solid var(--accent-red);
  background: rgba(255, 77, 77, 0.045);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.fault__kind {
  margin: 0 0 9px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-red);
}
.fault__msg { margin: 0; font-size: 13px; color: var(--text); line-height: 1.65; }
.fault__hint {
  margin: 11px 0 0;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  line-height: 1.7;
}

/* ---- figure card ---- */
.figure-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 30px 22px;
  overflow: hidden;
}
.figure-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  background: var(--accent-amber);
}
.figure-card--closed::before { background: var(--accent-red); }

.figure__meta {
  margin: 0 0 9px;
  font-size: 10px;
  letter-spacing: 0.19em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.figure__meta b { color: var(--text); font-weight: 500; }
.figure__meta .sep { color: #333844; margin: 0 9px; }

.figure__value-row {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 9px;
  flex-wrap: wrap;
  line-height: 0.95;
}
.figure__currency { font-family: var(--serif); font-size: 34px; color: #7a5f22; }
.figure__value {
  font-family: var(--serif);
  font-size: clamp(44px, 7.4vw, 76px);
  font-weight: 600;
  color: var(--accent-amber);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.figure-card--closed .figure__value { color: var(--accent-red); }
.figure__unit {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1.35;
  padding-bottom: 8px;
}

/* ---- badges ---- */
.badges { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 18px; }
.badge {
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: var(--radius);
  border: 1px solid;
  white-space: nowrap;
}
.badge--amber { color: var(--accent-amber); border-color: rgba(255, 176, 32, 0.42); background: rgba(255, 176, 32, 0.07); }
.badge--cyan  { color: var(--accent-cyan);  border-color: rgba(0, 217, 163, 0.42);  background: rgba(0, 217, 163, 0.07); }
.badge--red   { color: var(--accent-red);   border-color: rgba(255, 77, 77, 0.42);  background: rgba(255, 77, 77, 0.07); }
.badge--mute  { color: var(--text-muted);   border-color: var(--border);            background: rgba(255, 255, 255, 0.015); }

/* ---- tiles ---- */
/* Exactly six tiles, so the column count is chosen to divide 6 evenly.
   auto-fit would leave a 5+1 orphan row with a dead cell showing through. */
.tiles {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 18px;
  overflow: hidden;
}
.tile { background: var(--panel); padding: 14px 15px 15px; }
.tile__k {
  font-size: 9px;
  letter-spacing: 0.19em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 7px;
}
.tile__v {
  font-size: 19px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.tile__v--amber { color: var(--accent-amber); }
.tile__v--cyan { color: var(--accent-cyan); }
.tile__v--null { color: #3f444d; }
.tile__f {
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #4c515a;
  margin-top: 5px;
}

/* ---- section rule ---- */
.rule {
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 32px 0 14px;
  font-size: 9.5px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.rule::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---- chart ---- */
.chart-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px 10px;
  position: relative;
  height: 320px;
}
.chart-note {
  margin: 10px 0 0;
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #4c515a;
}

/* ---- feature vector ---- */
.fv { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.fv tr { border-bottom: 1px solid #1a1d24; }
.fv tr:last-child { border-bottom: none; }
.fv td { padding: 7px 14px; }
.fv td:first-child { color: var(--text-muted); letter-spacing: 0.09em; width: 55%; }
.fv td:last-child { color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
.fv td.nullv { color: #3f444d; }

/* ==========================================================================
   Footer
   ========================================================================== */

.page-foot {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px var(--gutter) 22px;
  border-top: 1px solid var(--border);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ==========================================================================
   Responsive - control panel stacks above the readout
   ========================================================================== */

@media (max-width: 1400px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  :root { --gutter: 18px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .control { position: static; }
  .masthead { padding-top: 20px; }
  .masthead__title { font-size: 24px; }
  .masthead__right { text-align: left; }
  .figure-card { padding: 22px 20px 18px; }
  .chart-wrap { height: 260px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .loading__bar span { width: 100%; animation: none !important; }
}
