/* ==========================================================================
   Mercury Mining Operations — shared theme (a11y-NEUTRAL chrome)
   Visual frame shared by BOTH trees: colours, type, layout grid, and generic
   component styling. It carries NO accessibility behaviour of its own — the
   toolkit base.css (loaded after this) provides .sr-only / :focus-visible /
   reduced-motion, and the root tree's inaccessible-overrides.css breaks them.
   Contrast here is the accessible baseline; the override file degrades it.
   ========================================================================== */

:root {
  --bg: #0b0f14;
  --bg-panel: #131a23;
  --bg-panel-2: #1a232e;
  --bg-elev: #1f2a37;
  --line: #2c3a4a;
  --line-soft: #223040;

  --text: #eef3f8;          /* primary text — high contrast on --bg */
  --text-dim: #c2cedb;      /* secondary text — still ≥ 4.5:1 on panels */
  --text-muted: #9fb0c0;    /* tertiary — meets 4.5:1 on --bg */

  --amber: #ff9e3d;         /* Mercury / molten accent */
  --amber-bright: #ffc371;
  --teal: #38e0c8;
  --teal-deep: #16b8a6;
  --blue: #5aa6ff;

  --ok: #3ddc91;
  --ok-text: #8ff0c4;
  --warn: #ffcf4d;
  --warn-text: #ffe39a;
  --crit: #ff6b6b;
  --crit-text: #ffb3b3;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  --mono: "SFMono-Regular", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(255, 158, 61, 0.10), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--amber-bright); }

h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 0.4em; font-weight: 650; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

/* --- App shell ----------------------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas: "sidebar topbar" "sidebar main";
  min-height: 100vh;
}
.sidebar { grid-area: sidebar; background: var(--bg-panel); border-right: 1px solid var(--line); padding: 1.1rem 0.9rem; }
.topbar  { grid-area: topbar;  background: var(--bg-panel); border-bottom: 1px solid var(--line); padding: 0.9rem 1.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.main    { grid-area: main; padding: 1.5rem; max-width: var(--pt-container-max, 1200px); }

.brand { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1.4rem; }
.brand__mark { width: 34px; height: 34px; flex: 0 0 auto; display: block; object-fit: contain; }
.brand__name { font-weight: 700; letter-spacing: 0.2px; }
.brand__sub { display: block; font-size: 0.72rem; color: var(--text-muted); font-weight: 500; }

.navlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.navlink { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.7rem; border-radius: var(--radius-sm); color: var(--text-dim); text-decoration: none; font-weight: 550; }
.navlink:hover { background: var(--bg-panel-2); color: var(--text); }
.navlink[aria-current="page"], .navlink.is-active { background: var(--bg-elev); color: var(--amber-bright); box-shadow: inset 3px 0 0 var(--amber); }
.navlink__icon { width: 18px; height: 18px; flex: 0 0 auto; }

.topbar__meta { display: flex; align-items: center; gap: 1.2rem; color: var(--text-muted); font-size: 0.85rem; }
.topbar__sol { font-family: var(--mono); color: var(--text-dim); }

.pagehead { margin-bottom: 1.25rem; }
.pagehead p { color: var(--text-muted); margin: 0.2rem 0 0; max-width: 70ch; }

/* --- Cards / grid -------------------------------------------------------- */
.grid { display: grid; gap: 1rem; }
.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.card { background: var(--bg-panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.card__title { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin: 0 0 0.8rem; font-size: 1rem; color: var(--text); }

.kpi__label { color: var(--text-muted); font-size: 0.82rem; }
.kpi__value { font-family: var(--mono); font-size: 1.9rem; font-weight: 700; margin: 0.2rem 0; }
.kpi__unit { color: var(--text-muted); font-size: 0.8rem; font-weight: 500; }
.kpi__delta { font-size: 0.82rem; font-weight: 600; font-family: var(--mono); }
.kpi__delta--up { color: var(--ok-text); }
.kpi__delta--down { color: var(--crit-text); }
.kpi__delta--flat { color: var(--text-muted); }

/* --- Badges -------------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.12rem 0.5rem; border-radius: 999px; font-size: 0.74rem; font-weight: 650; border: 1px solid transparent; }
.badge--ok   { color: var(--ok-text);   background: rgba(61, 220, 145, 0.12); border-color: rgba(61, 220, 145, 0.4); }
.badge--warn { color: var(--warn-text); background: rgba(255, 207, 77, 0.12);  border-color: rgba(255, 207, 77, 0.4); }
.badge--crit { color: var(--crit-text); background: rgba(255, 107, 107, 0.14); border-color: rgba(255, 107, 107, 0.45); }
.badge--muted{ color: var(--text-muted);background: rgba(159, 176, 192, 0.12); border-color: rgba(159, 176, 192, 0.35); }
.badge--info { color: var(--blue); background: rgba(90, 166, 255, 0.12); border-color: rgba(90, 166, 255, 0.4); }
.badge__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* --- Tables -------------------------------------------------------------- */
.tablewrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.data caption { text-align: left; color: var(--text-muted); font-size: 0.85rem; padding-bottom: 0.6rem; }
table.data th, table.data td { padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--line-soft); text-align: left; }
table.data thead th { color: var(--text-dim); font-weight: 650; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg-panel); }
table.data td.num, table.data th.num { text-align: right; font-family: var(--mono); }
table.data tbody tr:hover { background: var(--bg-panel-2); }
.sortbtn { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 0.35rem; font: inherit; font-weight: 650; color: var(--text-dim); }
.sortbtn:hover { color: var(--text); }
.sortbtn__arrow { font-size: 0.7rem; opacity: 0.8; }

/* --- Charts (SVG) -------------------------------------------------------- */
.chart { width: 100%; height: auto; display: block; }
.chart__axis { stroke: var(--line); stroke-width: 1; }
.chart__grid { stroke: var(--line-soft); stroke-width: 1; }
.chart__line { fill: none; stroke: var(--amber); stroke-width: 2.5; }
.chart__area { fill: url(#area-grad); }
.chart__dot { fill: var(--amber-bright); }
.chart__label { fill: var(--text-muted); font-size: 11px; font-family: var(--mono); }
.bar { fill: var(--teal); }
.bar--il { fill: var(--amber); }
.bar--an { fill: var(--teal); }
.bar--px { fill: var(--blue); }
.bar--wi { fill: var(--amber-bright); }
.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; margin-top: 0.8rem; font-size: 0.85rem; color: var(--text-dim); }
.legend__item { display: inline-flex; align-items: center; gap: 0.45rem; }
.legend__swatch { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; }
.chart__series-area { fill-opacity: 0.12; }

/* --- Dashboard widgets: equipment status grid + commodities + mini feed --- */
.eqgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(24px, 1fr)); gap: 5px; margin: 0; padding: 0; list-style: none; }
.eqcell { position: relative; aspect-ratio: 1; border-radius: 4px; display: grid; place-items: center; font-size: 0.62rem; font-weight: 800; color: rgba(0, 0, 0, 0.62); }
.eqcell--operational { background: var(--ok); }
.eqcell--idle { background: #7a8794; }
.eqcell--maintenance { background: var(--warn); }
.eqcell--offline { background: var(--crit); }
.eqlegend { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; margin-top: 0.9rem; font-size: 0.82rem; color: var(--text-dim); }

.commoditylist { list-style: none; margin: 0; padding: 0; }
.commodity { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0; border-bottom: 1px solid var(--line-soft); }
.commodity:last-child { border-bottom: 0; }
.commodity__name { display: flex; flex-direction: column; }
.commodity__sym { color: var(--text-muted); font-family: var(--mono); font-size: 0.74rem; }
.commodity__price { font-family: var(--mono); font-weight: 700; margin-left: auto; }
.commodity__chg { display: inline-flex; align-items: center; gap: 0.25rem; font-family: var(--mono); font-size: 0.84rem; font-weight: 650; min-width: 84px; justify-content: flex-end; }
.commodity__chg--up { color: var(--ok-text); }
.commodity__chg--down { color: var(--crit-text); }
.commodity__chg--stable { color: var(--text-muted); }

.feedlink { display: inline-block; margin-top: 0.8rem; font-weight: 600; }
.minifeed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.minialert { display: grid; grid-template-columns: 1fr auto; gap: 0.15rem 0.6rem; padding: 0.55rem 0.7rem; border-radius: var(--radius-sm); border: 1px solid var(--line); border-left: 4px solid var(--line); }
.minialert--critical { border-left-color: var(--crit); }
.minialert--warning { border-left-color: var(--warn); }
.minialert--info { border-left-color: var(--blue); }
.minialert--success { border-left-color: var(--ok); }
.minialert__title { font-size: 0.9rem; font-weight: 600; margin: 0; }
.minialert__msg { grid-column: 1 / -1; color: var(--text-muted); font-size: 0.82rem; margin: 0; }
.minialert__time { color: var(--text-muted); font-family: var(--mono); font-size: 0.74rem; white-space: nowrap; }

/* --- Tabs ---------------------------------------------------------------- */
.tabs { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--bg-panel); }
.tablist { display: flex; gap: 2px; background: var(--bg-panel-2); border-bottom: 1px solid var(--line); padding: 4px; }
.tab { all: unset; cursor: pointer; padding: 0.6rem 1rem; border-radius: var(--radius-sm); font-weight: 600; color: var(--text-dim); }
.tab:hover { background: var(--bg-elev); color: var(--text); }
.tab[aria-selected="true"], .tab.is-active { background: var(--bg-elev); color: var(--amber-bright); }
.tabpanel { padding: 1.2rem; }
.tabpanel[hidden] { display: none; }

/* --- Forms --------------------------------------------------------------- */
.field { margin-bottom: 1.1rem; }
.field > label, .field__label { display: block; font-weight: 600; margin-bottom: 0.35rem; color: var(--text); }
.field__hint { color: var(--text-muted); font-size: 0.82rem; margin-top: 0.3rem; }
.field__error { color: var(--crit-text); font-size: 0.83rem; margin-top: 0.3rem; font-weight: 600; }
.input, .select, .textarea {
  width: 100%; padding: 0.55rem 0.7rem; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm); font: inherit;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--amber); }
.input--invalid, .select--invalid { border-color: var(--crit); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.9rem 1rem; margin: 0 0 1.1rem; }
legend { padding: 0 0.4rem; font-weight: 650; }
.checkrow { display: flex; align-items: center; gap: 0.55rem; margin-bottom: 0.5rem; }
.btn { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.6rem 1.1rem; border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-weight: 650; cursor: pointer; }
.btn--primary { background: var(--amber); color: #1a0f02; }
.btn--primary:hover { background: var(--amber-bright); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--line); }
.toolbar { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }

/* --- Alerts / notifications --------------------------------------------- */
.alertlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.7rem; }
.alert { display: grid; grid-template-columns: auto 1fr auto; gap: 0.5rem 0.9rem; padding: 0.85rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--bg-panel); align-items: start; }
.alert--critical { border-left: 4px solid var(--crit); }
.alert--warning  { border-left: 4px solid var(--warn); }
.alert--info     { border-left: 4px solid var(--blue); }
.alert--success  { border-left: 4px solid #10b981; }
.alert__icon { width: 22px; height: 22px; flex: 0 0 auto; margin-top: 2px; }
.alert__body h3 { margin: 0 0 0.15rem; font-size: 0.98rem; }
.alert__meta { color: var(--text-muted); font-size: 0.8rem; font-family: var(--mono); }
.alert__detail { color: var(--text-dim); font-size: 0.9rem; margin: 0.25rem 0 0; }
.alert__time { color: var(--text-muted); font-size: 0.8rem; font-family: var(--mono); white-space: nowrap; }
.alert__dismiss { all: unset; cursor: pointer; color: var(--text-muted); padding: 0.2rem 0.4rem; border-radius: 6px; }
.alert__dismiss:hover { color: var(--text); background: var(--bg-elev); }

.banner { display: flex; align-items: center; gap: 0.7rem; padding: 0.7rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1.2rem; font-weight: 600; }
.banner--critical { background: rgba(255, 107, 107, 0.12); border: 1px solid rgba(255, 107, 107, 0.5); color: var(--crit-text); }

/* --- Notifications: stat cards + filter bar ----------------------------- */
.statcards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; list-style: none; padding: 0; }
.statcard { background: var(--bg-panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1.1rem; }
.statcard__head { display: flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
.statcard__icon { flex: 0 0 auto; }
.statcard__value { font-family: var(--mono); font-size: 1.9rem; font-weight: 700; margin: 0.35rem 0 0; color: var(--text); }
.statcard--critical .statcard__head, .statcard--critical .statcard__icon { color: var(--crit-text); }
.statcard--warning  .statcard__head, .statcard--warning  .statcard__icon { color: var(--warn-text); }
.statcard--info     .statcard__head, .statcard--info     .statcard__icon { color: var(--blue); }
.statcard--success  .statcard__head, .statcard--success  .statcard__icon { color: var(--ok-text); }

.alertfilters { display: flex; flex-wrap: wrap; gap: 1rem 1.4rem; align-items: flex-end; padding: 0.9rem 1.1rem; margin-bottom: 1.2rem; background: var(--bg-panel); border: 1px solid var(--line); border-radius: var(--radius); }
.alertfilter { display: flex; flex-direction: column; gap: 0.3rem; min-width: 200px; flex: 1 1 200px; }
.alertfilter__label { font-weight: 600; font-size: 0.85rem; color: var(--text-dim); }

/* --- Filters / batch bar / pagination ----------------------------------- */
.filterbar { display: flex; flex-wrap: wrap; gap: 0.6rem 1.4rem; align-items: center; margin-bottom: 1rem; }
.filtergroup { display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; align-items: center; }
.filtergroup > .filtergroup__label { font-weight: 600; color: var(--text-dim); font-size: 0.85rem; }
.chk { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.88rem; }
.batchbar { display: flex; align-items: center; gap: 0.8rem; padding: 0.6rem 0.9rem; margin-bottom: 0.9rem; background: var(--bg-elev); border: 1px solid var(--amber); border-radius: var(--radius-sm); }
.batchbar[hidden] { display: none; }
.pagination { display: flex; align-items: center; gap: 0.35rem; margin-top: 1rem; flex-wrap: wrap; }
.pagebtn { all: unset; cursor: pointer; min-width: 2rem; text-align: center; padding: 0.35rem 0.6rem; border-radius: var(--radius-sm); border: 1px solid var(--line); color: var(--text-dim); font: inherit; }
.pagebtn:hover { background: var(--bg-elev); color: var(--text); }
.pagebtn[aria-current="page"], .pagebtn.is-current { background: var(--amber); color: #1a0f02; border-color: var(--amber); font-weight: 700; }
.pageinfo { color: var(--text-muted); font-size: 0.85rem; margin-left: auto; }

/* Colour-only status text (root tree). The accessible tree uses text badges. */
.otext { font-weight: 600; }
.otext--active { color: var(--ok-text); }
.otext--idle { color: var(--text-muted); }
.otext--maintenance { color: var(--warn-text); }
.otext--offline { color: var(--crit-text); }
.rowdetails { color: var(--amber-bright); cursor: pointer; text-decoration: underline; }
.selectcol { width: 1%; white-space: nowrap; }

/* --- Meter / progress --------------------------------------------------- */
.meter { height: 8px; background: var(--bg-elev); border-radius: 999px; overflow: hidden; }
.meter__fill { height: 100%; background: var(--amber); border-radius: 999px; }

/* --- Modal dialog ------------------------------------------------------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 1.2rem; background: rgba(0, 0, 0, 0.62); }
.modal-backdrop[hidden] { display: none; }
.modal { width: min(580px, 100%); max-height: 86vh; overflow: auto; background: var(--bg-panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg-panel); }
.modal__title { margin: 0; font-size: 1.15rem; }
.modal__close { all: unset; cursor: pointer; display: inline-flex; padding: 0.35rem; border-radius: 6px; color: var(--text-dim); }
.modal__close:hover { background: var(--bg-elev); color: var(--text); }
.modal__body { padding: 1.2rem; }
.modal__foot { display: flex; justify-content: flex-end; gap: 0.6rem; padding: 1rem 1.2rem; border-top: 1px solid var(--line); }
.detailgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0.9rem 1.1rem; margin: 0 0 1.1rem; }
.detailitem { margin: 0; }
.detailitem dt { color: var(--text-muted); font-size: 0.78rem; }
.detailitem dd { margin: 0.1rem 0 0; font-family: var(--mono); font-weight: 650; }

/* --- Equipment cards ---------------------------------------------------- */
.eqcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); gap: 1rem; }
.eqcard { display: block; width: 100%; text-align: left; background: var(--bg-panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
button.eqcard { font: inherit; color: inherit; cursor: pointer; }
.eqcard:hover { border-color: var(--amber); }
.eqcard__head { display: flex; justify-content: space-between; align-items: start; gap: 0.5rem; }
.eqcard__name { font-weight: 650; }
.eqcard__type { color: var(--text-muted); font-size: 0.8rem; }
.eqcard__util { margin: 0.7rem 0 0.25rem; }
.eqcard__meta { color: var(--text-muted); font-size: 0.8rem; display: flex; justify-content: space-between; gap: 0.5rem; margin-top: 0.6rem; }

/* --- Circular gauges ---------------------------------------------------- */
.gaugegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1.1rem; }
.gauge { text-align: center; }
.gauge svg { width: 108px; height: 108px; }
.gauge__track { fill: none; stroke: var(--bg-elev); }
.gauge__val { fill: none; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; }
.gauge__val--normal { stroke: var(--ok); }
.gauge__val--warning { stroke: var(--warn); }
.gauge__val--critical { stroke: var(--crit); }
.gauge__num { font-family: var(--mono); font-weight: 700; font-size: 13px; fill: var(--text); }
.gauge__name { font-size: 0.82rem; color: var(--text-dim); margin-top: 0.35rem; }
.gaugesub { font-weight: 650; margin: 1.1rem 0 0.7rem; }
.gaugesub:first-child { margin-top: 0; }

/* --- Timeline ----------------------------------------------------------- */
.tgroup { margin-bottom: 1.5rem; }
.tgroup__title { font-size: 0.95rem; margin: 0 0 0.7rem; display: flex; align-items: center; gap: 0.5rem; }
.tlist { list-style: none; margin: 0; padding: 0; }
.titem { position: relative; padding: 0 0 1rem 1.5rem; border-left: 2px solid var(--line); margin-left: 0.4rem; }
.titem:last-child { padding-bottom: 0; }
.titem__dot { position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--text-muted); border: 2px solid var(--bg); }
.titem__dot--critical, .titem__dot--high { background: var(--crit); }
.titem__dot--medium { background: var(--warn); }
.titem__dot--low { background: var(--ok); }
.titem__title { font-weight: 600; }
.titem__meta { color: var(--text-muted); font-size: 0.82rem; margin-top: 0.15rem; }

/* --- Personnel: avatars, cards, shift roster, wizard -------------------- */
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--bg-elev); color: var(--amber-bright); display: grid; place-items: center; font-weight: 700; font-size: 0.85rem; flex: 0 0 auto; }
.pcard__head { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.5rem; }
.pcard__name { font-weight: 650; }
.pcard__role { color: var(--text-muted); font-size: 0.8rem; }

.shiftcols { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; }
.shiftcol { background: var(--bg-panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem; }
.shiftcol__title { font-weight: 650; margin: 0 0 0.2rem; }
.shiftcol__sub { color: var(--text-muted); font-size: 0.8rem; margin: 0 0 0.8rem; }
.roster { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.rosteritem { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.6rem; background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.rosteritem__grip { color: var(--text-muted); cursor: grab; flex: 0 0 auto; }
.rosteritem__name { flex: 1 1 auto; font-size: 0.9rem; }
.rosteritem__role { color: var(--text-muted); font-size: 0.76rem; }
.rosteritem.dragging { opacity: 0.45; }
.movebtns { display: inline-flex; gap: 0.2rem; flex: 0 0 auto; }
.movebtn { all: unset; cursor: pointer; padding: 0.1rem 0.4rem; border-radius: 5px; border: 1px solid var(--line); color: var(--text-dim); font-size: 0.85rem; }
.movebtn:hover { background: var(--bg-panel); color: var(--text); }
.movebtn[disabled] { opacity: 0.4; cursor: default; }

.steps { display: flex; align-items: center; gap: 0.3rem; margin-bottom: 1.3rem; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 0.45rem; color: var(--text-muted); font-size: 0.85rem; }
.step__num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line); font-weight: 700; font-size: 0.8rem; }
.step.is-active { color: var(--text); }
.step.is-active .step__num { border-color: var(--amber); color: var(--amber-bright); }
.step.is-done .step__num { background: var(--amber); border-color: var(--amber); color: #1a0f02; }
.step__line { width: 18px; height: 2px; background: var(--line); }

/* --- Accordion + report builder ----------------------------------------- */
.acc { border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 0.6rem; overflow: hidden; }
.acc__head { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.7rem 0.9rem; background: var(--bg-panel-2); border: 0; font: inherit; font-weight: 600; color: var(--text); text-align: left; cursor: pointer; }
.acc__head:hover { background: var(--bg-elev); }
.acc__arrow { transition: transform 0.15s; color: var(--text-muted); }
.acc.is-open .acc__arrow, .acc__head[aria-expanded="true"] .acc__arrow { transform: rotate(90deg); }
.acc__panel { padding: 0.9rem; }
.acc__panel[hidden] { display: none; }
.builder { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 1.2rem; align-items: start; }
@media (max-width: 860px) { .builder { grid-template-columns: 1fr; } }
.previewstats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 0.8rem; margin-bottom: 1rem; }
.previewstat__label { color: var(--text-muted); font-size: 0.78rem; }
.previewstat__value { font-family: var(--mono); font-weight: 700; font-size: 1.25rem; }
.savedactions { display: inline-flex; gap: 0.3rem; }
.togglegroup { display: inline-flex; gap: 0.25rem; }

/* --- Misc ---------------------------------------------------------------- */
.stack > * + * { margin-top: 1rem; }
.muted { color: var(--text-muted); }
.mono { font-family: var(--mono); }
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1 1 auto; }
.footer { color: var(--text-muted); font-size: 0.82rem; padding: 1.4rem 0 0.4rem; border-top: 1px solid var(--line-soft); margin-top: 2rem; }

/* --- Header (topbar) search + icon buttons ------------------------------ */
.icon { display: inline-block; vertical-align: middle; flex: 0 0 auto; }
.topsearch { display: flex; align-items: center; gap: 0.5rem; flex: 1 1 300px; max-width: 440px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.4rem 0.7rem; color: var(--text-muted); }
.topsearch:focus-within { border-color: var(--amber); }
.topsearch__icon { display: flex; color: var(--text-muted); }
.topsearch__input { flex: 1 1 auto; min-width: 0; border: 0; background: transparent; padding: 0; font: inherit; color: var(--text); }
.iconbtn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--radius-sm); color: var(--text-dim); text-decoration: none; }
.iconbtn:hover { background: var(--bg-elev); color: var(--text); }
.iconbtn__badge { position: absolute; top: 1px; right: 1px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--crit); color: #1a0f02; font-size: 0.66rem; font-weight: 700; display: grid; place-items: center; }

/* --- Footer system-status row ------------------------------------------- */
.footer--status { display: flex; flex-wrap: wrap; gap: 0.4rem 1.3rem; align-items: center; }
.footstat { display: inline-flex; align-items: center; gap: 0.4rem; margin: 0; }
.footstat--end { margin-left: auto; }
.footstat__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex: 0 0 auto; }
.footstat__dot--ok { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.skiplink { position: absolute; left: 0.75rem; top: 0.6rem; z-index: 50; background: var(--amber); color: #1a0f02; padding: 0.5rem 0.9rem; border-radius: var(--radius-sm); font-weight: 700; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  .sidebar { display: none; }
}

/* --- Login (full-screen) ------------------------------------------------ */
/* Full-viewport stage with the operator's background photo. A Mercury-toned
   gradient sits underneath as a fallback until /mercury-bg.jpg is present. */
.login-stage {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background-color: #0b0f14;
  background-image:
    linear-gradient(135deg, rgba(178, 90, 18, 0.55), rgba(11, 15, 20, 0.9)),
    url("/mercury-bg.jpg");
  background-size: cover;
  background-position: center;
}
/* Legibility scrim — used by the ACCESSIBLE login so card/text contrast holds
   over any photo. The inaccessible login omits it on purpose. */
.login-scrim {
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 50% 40%, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.7));
}
.login-card {
  position: relative;
  width: min(420px, 100%);
  padding: 2rem 1.9rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
/* Accessible: solid, high-contrast panel. */
.login-card--solid {
  background: rgba(13, 19, 27, 0.92);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
/* Inaccessible: barely-there panel, so text sits low-contrast over the photo. */
.login-card--thin {
  background: rgba(20, 26, 35, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.login-card .brand { justify-content: center; margin-bottom: 1.1rem; }
.login-card h1 { font-size: 1.4rem; text-align: center; }
.login-tagline { text-align: center; color: var(--text-muted); margin: 0 0 1.4rem; font-size: 0.9rem; }
.login-error {
  display: none;
  margin-bottom: 1rem;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 107, 107, 0.14);
  border: 1px solid rgba(255, 107, 107, 0.5);
  color: var(--crit-text);
  font-size: 0.9rem;
  font-weight: 600;
}
.login-error.is-shown { display: block; }
.login-success {
  display: none;
  margin-bottom: 1rem;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  background: rgba(61, 220, 145, 0.14);
  border: 1px solid rgba(61, 220, 145, 0.5);
  color: var(--ok-text);
  font-size: 0.9rem;
  font-weight: 600;
}
.login-success.is-shown { display: block; }
.login-card .btn--primary { width: 100%; justify-content: center; margin-top: 0.3rem; }
.login-foot { text-align: center; margin-top: 1.2rem; font-size: 0.82rem; }
.login-hint { text-align: center; color: var(--text-muted); font-size: 0.78rem; margin-top: 0.9rem; }

/* Live pulse used by the alerts feed; respects reduced-motion via base.css
   in the accessible tree, and is re-enabled by the override in the root tree. */
@keyframes pt-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--crit); animation: pt-pulse 1.4s ease-in-out infinite; }

/* --- Settings: preference rows, toggle switches, sliders, widget list ---- */
.section__title { font-size: 1rem; font-weight: 650; margin: 0 0 0.8rem; }
.prefrow { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.8rem 0; border-top: 1px solid var(--line-soft); }
.prefrow:first-of-type { border-top: 0; }
.prefrow__text { min-width: 0; }
.prefrow__label { display: block; font-weight: 600; color: var(--text); margin: 0; }
.prefrow__hint { color: var(--text-muted); font-size: 0.82rem; margin-top: 0.2rem; }
.prefrow__control { width: auto; min-width: 160px; flex: 0 0 auto; }

/* Toggle switch — a div in the root tree, a button[role=switch] in accessible. */
.switch {
  position: relative; display: inline-block; flex: 0 0 auto; width: 44px; height: 24px;
  border-radius: 999px; background: var(--bg-elev); border: 1px solid var(--line);
  cursor: pointer; padding: 0; transition: background 0.15s, border-color 0.15s; vertical-align: middle;
}
.switch__thumb {
  position: absolute; top: 50%; left: 3px; transform: translateY(-50%);
  width: 16px; height: 16px; border-radius: 50%; background: var(--text); transition: left 0.15s;
}
.switch.is-on, .switch[aria-checked="true"] { background: var(--amber); border-color: var(--amber); }
.switch.is-on .switch__thumb, .switch[aria-checked="true"] .switch__thumb { left: 24px; background: #1a0f02; }
.switch:focus-visible { outline: 2px solid var(--amber-bright); outline-offset: 2px; }
.switch--sm { width: 34px; height: 18px; }
.switch--sm .switch__thumb { width: 12px; height: 12px; }
.switch--sm.is-on .switch__thumb, .switch--sm[aria-checked="true"] .switch__thumb { left: 18px; }

/* Range slider */
.sliderrow { padding: 0.8rem 0; border-top: 1px solid var(--line-soft); }
.sliderrow:first-of-type { border-top: 0; }
.sliderrow__control { display: flex; align-items: center; gap: 0.8rem; margin-top: 0.5rem; }
.sliderrow__value { font-family: var(--mono); min-width: 3.2rem; text-align: right; color: var(--text-dim); }
.range { flex: 1 1 auto; appearance: none; -webkit-appearance: none; height: 6px; border-radius: 999px; background: var(--bg-elev); cursor: pointer; }
.range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--amber); border: 0; cursor: pointer; }
.range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--amber); border: 0; cursor: pointer; }
.range:focus-visible { outline: 2px solid var(--amber-bright); outline-offset: 3px; }

/* Dashboard widget list (reuses .roster / .rosteritem / .movebtn) */
.widgetlist { margin-top: 0.6rem; }
.widgetitem.is-hidden { opacity: 0.55; }
.widgetitem__vis[aria-pressed="false"] { color: var(--text-muted); }
