/* =========================================================
   SPEED TRACK — Auto Car Wash | HMI Control Panel
   Brand colours sampled from logo:  #C55E2D / #313131
   ========================================================= */

:root {
  /* --- brand --- */
  --brand:        #c55e2d;
  --brand-dark:   #a44a1f;
  --brand-light:  #e8834f;
  --brand-50:     #fdf3ee;
  --brand-100:    #f8e2d6;

  --ink:          #313131;
  --ink-2:        #4f4f4f;
  --muted:        #8b8f94;

  /* --- surfaces --- */
  --bg:           #ffffff;
  --surface:      #ffffff;
  --surface-2:    #f6f7f9;
  --surface-3:    #eef0f3;
  --line:         #e4e7eb;
  --line-strong:  #d3d8de;

  /* --- semantic --- */
  --ok:      #17a34a;
  --danger:  #dc2f2f;
  --warn:    #f0a020;
  --water:   #2571e6;
  --info:    #0ea5c4;
  --violet:  #7c5cd6;

  --radius:    16px;
  --radius-sm: 12px;
  --shadow:    0 1px 2px rgba(17, 24, 39, .04), 0 8px 24px rgba(17, 24, 39, .06);
  --shadow-lg: 0 12px 40px rgba(17, 24, 39, .14);

  --ff-display: "Rajdhani", "Segoe UI", system-ui, sans-serif;
  --ff-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ff-body);
  font-size: 15px;
  padding-bottom: 88px;                 /* room for mobile action bar */
  -webkit-tap-highlight-color: transparent;
}

/* subtle industrial texture behind the page */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 420px at 12% -6%, var(--brand-50), transparent 70%),
    radial-gradient(760px 380px at 105% 0%, #eef4fb, transparent 70%);
  pointer-events: none;
}

h1, h2, h3, h4, h5, h6, .display-font {
  font-family: var(--ff-display);
  font-weight: 700;
  letter-spacing: .2px;
}

.text-brand   { color: var(--brand) !important; }
.bg-brand     { background: var(--brand) !important; }
.text-muted-2 { color: var(--muted) !important; }

.section-title {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: 1.06rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  margin: 0;
}
.section-title i { color: var(--brand); font-size: 1.15rem; }

.eyebrow {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------------------------------------------------------
   Cards / panels
   --------------------------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel + .panel { margin-top: 1rem; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  padding: .85rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, var(--surface-2));
}
.panel-body { padding: 1.1rem; }

/* orange accent strip on top of feature panels */
.panel--accent { position: relative; }
.panel--accent::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--brand-light) 55%, #f2c39f);
}

/* ---------------------------------------------------------
   Navbar
   --------------------------------------------------------- */
.app-navbar {
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 14px rgba(17, 24, 39, .05);
}
.app-navbar .navbar-brand img { height: 38px; width: auto; }
@media (max-width: 575.98px) { .app-navbar .navbar-brand img { height: 30px; } }

.nav-clock {
  font-family: var(--ff-display);
  font-size: 1.28rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.nav-clock small { display: block; font-size: .62rem; letter-spacing: .12em; color: var(--muted); }

/* connection chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .34rem .7rem;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink-2);
  white-space: nowrap;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.chip.is-ok     { border-color: #b6e6c6; background: #eafaf0; color: #12783a; }
.chip.is-ok .dot     { background: var(--ok);    box-shadow: 0 0 0 4px rgba(23, 163, 74, .16); animation: pulse 2s infinite; }
.chip.is-warn   { border-color: #f6dfae; background: #fdf6e7; color: #91620a; }
.chip.is-warn .dot   { background: var(--warn);  box-shadow: 0 0 0 4px rgba(240, 160, 32, .18); }
.chip.is-danger { border-color: #f5c2c2; background: #fdeeee; color: #a51f1f; }
.chip.is-danger .dot { background: var(--danger); box-shadow: 0 0 0 4px rgba(220, 47, 47, .18); animation: pulse .9s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .35; }
}

/* ---------------------------------------------------------
   Alarm banner
   --------------------------------------------------------- */
.alarm-bar {
  display: none;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, #fdecec, #fff6f0);
  border: 1px solid #f3bcbc;
  border-left: 5px solid var(--danger);
  color: #8f1d1d;
  font-weight: 600;
  box-shadow: var(--shadow);
}
.alarm-bar.show { display: flex; animation: alarmIn .25s ease-out, alarmGlow 1.6s ease-in-out infinite 0.3s; }
.alarm-bar i.lead-ico { font-size: 1.4rem; color: var(--danger); }
@keyframes alarmIn  { from { transform: translateY(-6px); opacity: 0; } }
@keyframes alarmGlow{ 50% { box-shadow: 0 0 0 4px rgba(220, 47, 47, .12); } }

/* ---------------------------------------------------------
   Status hero
   --------------------------------------------------------- */
.status-hero {
  background: linear-gradient(135deg, #34383d 0%, #1f2226 60%, #16181b 100%);
  color: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  position: relative;
}
.status-hero::after {
  content: "";
  position: absolute;
  right: -70px; top: -70px;
  width: 240px; height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(197, 94, 45, .38), transparent 68%);
  pointer-events: none;
}
.status-hero .hero-inner { padding: 1.15rem 1.25rem; position: relative; z-index: 1; }

.state-badge {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  font-family: var(--ff-display);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: .05em;
  line-height: 1;
  padding: .45rem .95rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .16);
}
.state-badge[data-state="IDLE"]      { color: #cfd4da; }
.state-badge[data-state="RUNNING"]   { color: #6ee79a; border-color: rgba(110, 231, 154, .4); background: rgba(23, 163, 74, .18); }
.state-badge[data-state="HOMING"]    { color: #6fc0ff; border-color: rgba(111, 192, 255, .4); background: rgba(37, 113, 230, .18); }
.state-badge[data-state="PAUSED"]    { color: #ffd07a; border-color: rgba(255, 208, 122, .4); background: rgba(240, 160, 32, .18); }
.state-badge[data-state="E-STOP"],
.state-badge[data-state="FAULT"]     { color: #ff9b9b; border-color: rgba(255, 155, 155, .45); background: rgba(220, 47, 47, .22); animation: pulse 1s infinite; }

.hero-label { font-size: .68rem; letter-spacing: .16em; text-transform: uppercase; color: rgba(255, 255, 255, .55); }
.hero-value { font-family: var(--ff-display); font-size: 1.16rem; font-weight: 700; color: #fff; }

.hero-progress {
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  overflow: hidden;
}
.hero-progress .bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--brand-light));
  background-size: 28px 28px;
  transition: width .45s ease;
}
.hero-progress .bar.striped {
  background-image: linear-gradient(45deg, rgba(255,255,255,.22) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.22) 50%, rgba(255,255,255,.22) 75%, transparent 75%, transparent);
  animation: stripes 1s linear infinite;
}
@keyframes stripes { from { background-position: 0 0; } to { background-position: 28px 0; } }

/* cycle step chips */
.step-track { display: flex; gap: .4rem; flex-wrap: wrap; }
.step-chip {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: .28rem .6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .12);
  color: rgba(255, 255, 255, .55);
  white-space: nowrap;
}
.step-chip.done   { background: rgba(23, 163, 74, .2);  border-color: rgba(110, 231, 154, .4); color: #9df0bb; }
.step-chip.active { background: var(--brand);          border-color: var(--brand-light);      color: #fff; box-shadow: 0 0 0 3px rgba(197, 94, 45, .25); }

/* ---------------------------------------------------------
   Indicator lamps (top row of the physical panel)
   --------------------------------------------------------- */
.lamp-rail {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
}
.lamp-unit { text-align: center; min-width: 74px; }
.lamp {
  width: 46px; height: 46px;
  margin: 0 auto .45rem;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f2f4f6, #c8ced5 60%, #9aa2ab);
  box-shadow:
    0 0 0 5px #eceef1,
    0 0 0 6px var(--line-strong),
    inset 0 -4px 8px rgba(0, 0, 0, .25),
    inset 0 4px 8px rgba(255, 255, 255, .55);
  transition: box-shadow .2s ease, background .2s ease;
}
.lamp.on {
  background: radial-gradient(circle at 35% 30%, var(--lamp-hi), var(--lamp) 62%, var(--lamp-lo));
  box-shadow:
    0 0 0 5px #eceef1,
    0 0 0 6px var(--line-strong),
    0 0 18px 2px var(--lamp-glow),
    inset 0 -4px 8px rgba(0, 0, 0, .3),
    inset 0 5px 10px rgba(255, 255, 255, .45);
}
.lamp.blink { animation: lampBlink .8s steps(1, end) infinite; }
@keyframes lampBlink { 50% { filter: brightness(.35) saturate(.6); } }

.lamp-unit .lamp-label {
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.l-blue  { --lamp: #2571e6; --lamp-hi: #9dc4ff; --lamp-lo: #14458f; --lamp-glow: rgba(37,113,230,.6); }
.l-amber { --lamp: #f0a020; --lamp-hi: #ffdd9c; --lamp-lo: #9c6407; --lamp-glow: rgba(240,160,32,.6); }
.l-red   { --lamp: #dc2f2f; --lamp-hi: #ff9d9d; --lamp-lo: #8c1414; --lamp-glow: rgba(220,47,47,.6); }
.l-green { --lamp: #17a34a; --lamp-hi: #8ef0b3; --lamp-lo: #0a6c2f; --lamp-glow: rgba(23,163,74,.6); }

/* ---------------------------------------------------------
   Industrial push buttons
   --------------------------------------------------------- */
.btn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 1.15rem .5rem;
}

.pbtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .55rem;
  background: none;
  border: 0;
  padding: .35rem 0;
  width: 100%;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.pbtn:focus-visible { outline: none; }
.pbtn:focus-visible .pbtn-cap { box-shadow: 0 0 0 4px rgba(197, 94, 45, .35), var(--cap-shadow); }

.pbtn-cap {
  --c:    #17a34a;
  --c-hi: #63d98d;
  --c-lo: #0c6f31;
  --c-glow: rgba(23, 163, 74, .55);
  --cap-shadow:
    0 0 0 6px #f0f2f4,
    0 0 0 7px var(--line-strong),
    0 8px 16px rgba(17, 24, 39, .18),
    inset 0 -7px 14px rgba(0, 0, 0, .32),
    inset 0 7px 12px rgba(255, 255, 255, .3);

  position: relative;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.45rem;
  background: radial-gradient(circle at 34% 28%, var(--c-hi), var(--c) 58%, var(--c-lo) 100%);
  box-shadow: var(--cap-shadow);
  transition: transform .09s ease, box-shadow .18s ease, filter .18s ease;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
.pbtn-cap::after {                                  /* glass highlight */
  content: "";
  position: absolute;
  inset: 7px 12px auto 12px;
  height: 34%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, .45), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.pbtn:active .pbtn-cap { transform: translateY(3px) scale(.97); filter: brightness(.92); }

.pbtn.is-active .pbtn-cap {
  box-shadow:
    0 0 0 6px #f0f2f4,
    0 0 0 7px var(--c),
    0 0 22px 3px var(--c-glow),
    inset 0 -5px 12px rgba(0, 0, 0, .28),
    inset 0 6px 14px rgba(255, 255, 255, .5);
  filter: brightness(1.12) saturate(1.1);
}
.pbtn.is-active .pbtn-label { color: var(--c); }

.pbtn:disabled { cursor: not-allowed; }
.pbtn:disabled .pbtn-cap { filter: grayscale(.85) brightness(1.05); opacity: .55; box-shadow: 0 0 0 6px #f3f4f6, 0 0 0 7px var(--line), inset 0 -4px 10px rgba(0,0,0,.18); }
.pbtn:disabled .pbtn-label { color: var(--muted); }
/* an output the running cycle is driving stays lit even though it is locked */
.pbtn:disabled.is-active .pbtn-cap {
  filter: none;
  opacity: 1;
  box-shadow:
    0 0 0 6px #f0f2f4,
    0 0 0 7px var(--c),
    0 0 22px 3px var(--c-glow),
    inset 0 -5px 12px rgba(0, 0, 0, .28),
    inset 0 6px 14px rgba(255, 255, 255, .5);
}
.pbtn:disabled.is-active .pbtn-label { color: var(--ink); }

.pbtn-label {
  font-family: var(--ff-display);
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink);
  text-align: center;
  min-height: 2.1em;
}
.pbtn-sub { display: block; font-size: .62rem; font-weight: 600; letter-spacing: .04em; color: var(--muted); }

/* small LED under the cap showing output state */
.pbtn-led {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--line-strong);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .3);
}
.pbtn.is-active .pbtn-led { background: var(--c); box-shadow: 0 0 8px 1px var(--c-glow); }

/* colour variants */
.c-green  { --c:#17a34a; --c-hi:#63d98d; --c-lo:#0c6f31; --c-glow:rgba(23,163,74,.55); }
.c-red    { --c:#dc2f2f; --c-hi:#ff8b8b; --c-lo:#8b1414; --c-glow:rgba(220,47,47,.55); }
.c-blue   { --c:#2571e6; --c-hi:#84b4ff; --c-lo:#12458f; --c-glow:rgba(37,113,230,.55); }
.c-amber  { --c:#f0a020; --c-hi:#ffd479; --c-lo:#9a6206; --c-glow:rgba(240,160,32,.55); }
.c-orange { --c:#c55e2d; --c-hi:#f0a075; --c-lo:#7d3512; --c-glow:rgba(197,94,45,.55); }
.c-cyan   { --c:#0ea5c4; --c-hi:#79dcf0; --c-lo:#066a80; --c-glow:rgba(14,165,196,.55); }
.c-violet { --c:#7c5cd6; --c-hi:#bda6ff; --c-lo:#4a3190; --c-glow:rgba(124,92,214,.55); }
.c-slate  { --c:#556070; --c-hi:#9aa5b4; --c-lo:#2c333d; --c-glow:rgba(85,96,112,.55); }

/* ---------------------------------------------------------
   Emergency stop (mushroom head)
   --------------------------------------------------------- */
.estop {
  background: none;
  border: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
}
.estop-head {
  position: relative;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 36% 30%, #ffe36b, #f5c518 55%, #c99a06);
  box-shadow: 0 10px 22px rgba(17, 24, 39, .22), inset 0 -6px 12px rgba(0, 0, 0, .18);
}
.estop-head .mushroom {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.7rem;
  background: radial-gradient(circle at 36% 28%, #ff8181, #dc2f2f 58%, #8b1414);
  box-shadow: 0 6px 12px rgba(0, 0, 0, .3), inset 0 -6px 12px rgba(0, 0, 0, .35), inset 0 6px 10px rgba(255, 255, 255, .28);
  transition: transform .1s ease, filter .2s ease;
}
.estop:active .mushroom { transform: scale(.94); }
.estop.latched .estop-head { animation: pulse 1s infinite; }
.estop.latched .mushroom { transform: scale(.88); filter: brightness(.8); }
.estop-label {
  font-family: var(--ff-display);
  font-weight: 700;
  font-size: .8rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--danger);
}
.estop-sm .estop-head { width: 62px; height: 62px; }
.estop-sm .mushroom { width: 40px; height: 40px; font-size: 1.05rem; }

/* ---------------------------------------------------------
   Rotary selector switch
   --------------------------------------------------------- */
.rotary-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #fff, var(--surface-2));
  padding: 1rem .85rem .85rem;
  height: 100%;
  text-align: center;
}
.rotary-card .rotary-title {
  font-family: var(--ff-display);
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: .1rem;
}
.rotary-card .rotary-value {
  font-family: var(--ff-display);
  font-size: 1.28rem;
  font-weight: 700;
  color: var(--brand);
  line-height: 1.1;
  margin-bottom: .7rem;
}

.knob-wrap { position: relative; width: 96px; height: 96px; margin: 0 auto .7rem; }
.knob {
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #5c646e, #33383f 60%, #1b1f24);
  box-shadow: 0 0 0 6px #eef0f3, 0 0 0 7px var(--line-strong), 0 6px 14px rgba(0, 0, 0, .25), inset 0 -4px 10px rgba(0, 0, 0, .4);
  transition: transform .3s cubic-bezier(.34, 1.4, .64, 1);
}
.knob::after {                                   /* pointer */
  content: "";
  position: absolute;
  left: 50%;
  top: 8px;
  width: 5px;
  height: 40%;
  transform: translateX(-50%);
  border-radius: 3px;
  background: linear-gradient(180deg, #fff, #cfd4da);
  box-shadow: 0 0 6px rgba(255, 255, 255, .5);
}
.knob-ticks { position: absolute; inset: 0; }
.knob-tick {
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--line-strong);
  transition: background .2s ease, box-shadow .2s ease;
}
.knob-tick.on { background: var(--brand); box-shadow: 0 0 8px 1px rgba(197, 94, 45, .5); }
.knob-tick.p0 { left: 2px;  bottom: 16px; }
.knob-tick.p1 { left: 50%;  top: 0; transform: translateX(-50%); }
.knob-tick.p2 { right: 2px; bottom: 16px; }

/* segmented control (mobile-friendly way to drive the knob) */
.seg {
  display: inline-flex;
  width: 100%;
  padding: 4px;
  gap: 4px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--line);
}
.seg button {
  flex: 1 1 0;
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: .45rem .3rem;
  font-family: var(--ff-display);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-2);
  cursor: pointer;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
  white-space: nowrap;
}
.seg button:hover:not(.active) { background: rgba(255, 255, 255, .75); }
.seg button.active {
  background: linear-gradient(180deg, var(--brand-light), var(--brand));
  color: #fff;
  box-shadow: 0 3px 8px rgba(197, 94, 45, .35);
}
.seg.seg-dark button.active { background: linear-gradient(180deg, #4b525b, #2b3037); box-shadow: 0 3px 8px rgba(43, 48, 55, .3); }

/* ---------------------------------------------------------
   Counter / stat cards
   --------------------------------------------------------- */
.stat {
  position: relative;
  height: 100%;
  padding: 1rem 1.05rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--stat-c, var(--brand));
}
.stat-ico {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  color: var(--stat-c, var(--brand));
  background: var(--stat-bg, var(--brand-50));
}
.stat-value {
  font-family: var(--ff-display);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.stat-value.bump { animation: bump .45s ease; }
@keyframes bump { 30% { transform: scale(1.16); color: var(--brand); } }
.stat-label { font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stat-foot { font-size: .74rem; color: var(--muted); }

.s-orange { --stat-c:#c55e2d; --stat-bg:#fdf3ee; }
.s-green  { --stat-c:#17a34a; --stat-bg:#eafaf0; }
.s-blue   { --stat-c:#2571e6; --stat-bg:#eaf1fd; }
.s-amber  { --stat-c:#f0a020; --stat-bg:#fdf6e7; }
.s-violet { --stat-c:#7c5cd6; --stat-bg:#f1ecfd; }
.s-red    { --stat-c:#dc2f2f; --stat-bg:#fdeeee; }

/* ---------------------------------------------------------
   Cycle launcher buttons
   --------------------------------------------------------- */
.cycle-btn {
  display: flex;
  align-items: center;
  gap: .85rem;
  width: 100%;
  text-align: left;
  padding: .9rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, background .15s ease;
}
.cycle-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--cy-c, var(--brand));
  box-shadow: 0 10px 22px rgba(17, 24, 39, .1);
}
.cycle-btn:disabled { opacity: .5; cursor: not-allowed; }
.cycle-btn .cy-ico {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  color: #fff;
  background: linear-gradient(140deg, var(--cy-c, var(--brand)), var(--cy-c2, var(--brand-dark)));
  box-shadow: 0 4px 10px rgba(17, 24, 39, .18);
}
.cycle-btn .cy-name {
  font-family: var(--ff-display);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  line-height: 1.15;
}
.cycle-btn .cy-meta { font-size: .74rem; color: var(--muted); }
.cycle-btn.running { border-color: var(--cy-c); background: linear-gradient(90deg, rgba(197,94,45,.06), transparent); box-shadow: 0 0 0 3px rgba(197, 94, 45, .12); }

.cy-ucw   { --cy-c:#2571e6; --cy-c2:#12458f; }
.cy-water { --cy-c:#0ea5c4; --cy-c2:#066a80; }
.cy-sham  { --cy-c:#7c5cd6; --cy-c2:#4a3190; }
.cy-auto  { --cy-c:#c55e2d; --cy-c2:#7d3512; }

/* ---------------------------------------------------------
   Diagnostics
   --------------------------------------------------------- */
.gauge { padding: .35rem 0; }
.gauge-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .35rem;
}
.gauge-name { font-size: .78rem; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: .4rem; }
.gauge-name i { color: var(--g-c, var(--brand)); }
.gauge-val {
  font-family: var(--ff-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.gauge-track { height: 9px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.gauge-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--g-c, var(--brand)), var(--g-c2, var(--brand-light)));
  transition: width .5s ease, background .3s ease;
}
/* per-sensor hues — warn/crit below have higher specificity and override these */
.g-water { --g-c:#2571e6; --g-c2:#79a9ff; }
.g-sham  { --g-c:#7c5cd6; --g-c2:#b49dff; }
.g-wax   { --g-c:#e0a41c; --g-c2:#ffd98a; }
.g-tank  { --g-c:#0ea5c4; --g-c2:#6bd8ec; }
.g-motor { --g-c:#c55e2d; --g-c2:#f0a075; }
.g-air   { --g-c:#4a8f7b; --g-c2:#8ecfb9; }

.gauge.warn  { --g-c:#f0a020; --g-c2:#ffcb6b; }
.gauge.crit  { --g-c:#dc2f2f; --g-c2:#ff8b8b; }
.gauge.crit .gauge-val { color: var(--danger); }
.gauge-scale { display: flex; justify-content: space-between; font-size: .62rem; color: var(--muted); margin-top: .2rem; }

/* I/O list */
.io-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .2rem;
  border-bottom: 1px dashed var(--line);
  font-size: .84rem;
}
.io-item:last-child { border-bottom: 0; }
.io-item .io-name { flex: 1 1 auto; color: var(--ink-2); }
.io-item .io-addr { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .7rem; color: var(--muted); }
.io-led {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: #cfd4da;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .25);
}
.io-led.ok   { background: var(--ok);     box-shadow: 0 0 8px 1px rgba(23, 163, 74, .5); }
.io-led.warn { background: var(--warn);   box-shadow: 0 0 8px 1px rgba(240, 160, 32, .5); }
.io-led.err  { background: var(--danger); box-shadow: 0 0 8px 1px rgba(220, 47, 47, .55); animation: pulse .9s infinite; }
.io-state { font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); min-width: 46px; text-align: right; }

/* fault log */
.log-table { font-size: .82rem; }
.log-table thead th {
  font-size: .66rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  border-bottom: 1px solid var(--line) !important;
  white-space: nowrap;
}
.log-table td { vertical-align: middle; border-color: var(--line) !important; }
.log-time { font-family: ui-monospace, Consolas, monospace; font-size: .74rem; color: var(--muted); white-space: nowrap; }
.log-code { font-family: ui-monospace, Consolas, monospace; font-size: .74rem; font-weight: 700; color: var(--ink-2); }

.sev {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .64rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: .2rem .5rem;
  border-radius: 999px;
}
.sev-info  { background:#eaf1fd; color:#1a56b8; }
.sev-warn  { background:#fdf6e7; color:#8f610a; }
.sev-fault { background:#fdeeee; color:#a51f1f; }
.sev-ok    { background:#eafaf0; color:#12783a; }

/* self-test */
.test-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .2rem;
  font-size: .84rem;
  border-bottom: 1px dashed var(--line);
}
.test-row:last-child { border-bottom: 0; }
.test-row .t-name { flex: 1 1 auto; color: var(--ink-2); }
.test-row .t-res { font-size: .68rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.t-pass { color: var(--ok); }
.t-fail { color: var(--danger); }
.t-wait { color: var(--muted); }

/* ---------------------------------------------------------
   Toasts
   --------------------------------------------------------- */
.toast-stack {
  position: fixed;
  top: 82px;
  right: 14px;
  z-index: 1090;
  width: min(360px, calc(100vw - 28px));
  display: flex;
  flex-direction: column;
  gap: .55rem;
  pointer-events: none;
}
.toast-stack > * { pointer-events: auto; }
.app-toast {
  display: flex;
  gap: .7rem;
  align-items: flex-start;
  padding: .75rem .85rem;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--t-c, var(--brand));
  box-shadow: var(--shadow-lg);
  animation: toastIn .28s cubic-bezier(.2, .9, .3, 1.3);
}
.app-toast.out { animation: toastOut .25s ease forwards; }
@keyframes toastIn  { from { transform: translateX(24px); opacity: 0; } }
@keyframes toastOut { to   { transform: translateX(24px); opacity: 0; } }
.app-toast .t-ico { font-size: 1.25rem; color: var(--t-c, var(--brand)); line-height: 1.1; }
.app-toast .t-title { font-weight: 700; font-size: .88rem; margin-bottom: .1rem; }
.app-toast .t-msg { font-size: .8rem; color: var(--ink-2); }
.app-toast .btn-close { font-size: .62rem; }
.t-ok    { --t-c: #17a34a; }
.t-warn  { --t-c: #f0a020; }
.t-error { --t-c: #dc2f2f; }
.t-info  { --t-c: #2571e6; }

/* ---------------------------------------------------------
   Sticky mobile action bar
   --------------------------------------------------------- */
.action-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1040;
  display: flex;
  gap: .5rem;
  padding: .6rem .75rem calc(.6rem + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 18px rgba(17, 24, 39, .08);
}
.action-bar .btn { flex: 1 1 0; font-weight: 700; letter-spacing: .04em; }
.action-bar .btn.latched { animation: pulse 1s infinite; }

/* ---------------------------------------------------------
   Misc / buttons
   --------------------------------------------------------- */
.btn-brand {
  background: linear-gradient(180deg, var(--brand-light), var(--brand));
  border: 1px solid var(--brand-dark);
  color: #fff;
  font-weight: 700;
}
.btn-brand:hover, .btn-brand:focus { background: linear-gradient(180deg, var(--brand), var(--brand-dark)); color: #fff; }
.btn-outline-brand { border: 1px solid var(--brand); color: var(--brand); font-weight: 700; }
.btn-outline-brand:hover { background: var(--brand); color: #fff; }

.instr-accordion .accordion-button {
  font-family: var(--ff-display);
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  font-size: .9rem;
  color: var(--ink);
  background: var(--surface-2);
}
.instr-accordion .accordion-button:not(.collapsed) { background: var(--brand-50); color: var(--brand-dark); box-shadow: none; }
.instr-accordion .accordion-button:focus { box-shadow: 0 0 0 .2rem rgba(197, 94, 45, .18); }
.instr-accordion .accordion-item { border-color: var(--line); }
.instr-accordion ol { margin: 0; padding-left: 1.15rem; font-size: .87rem; color: var(--ink-2); }
.instr-accordion ol li { margin-bottom: .3rem; }

.app-footer {
  border-top: 1px solid var(--line);
  padding: 1.25rem 0;
  font-size: .8rem;
  color: var(--muted);
}
.app-footer img { height: 26px; opacity: .8; }

/* ---------------------------------------------------------
   Responsive tuning
   --------------------------------------------------------- */
@media (max-width: 767.98px) {
  .btn-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 1rem .35rem; }
  .pbtn-cap { width: 60px; height: 60px; font-size: 1.25rem; }
  .pbtn-label { font-size: .7rem; }
  .state-badge { font-size: 1.3rem; }
  .stat-value { font-size: 1.65rem; }
  .knob-wrap { width: 84px; height: 84px; }
  .toast-stack { top: auto; bottom: 84px; right: 8px; left: 8px; width: auto; }
}

@media (max-width: 400px) {
  .btn-grid { grid-template-columns: repeat(3, 1fr); }
  .pbtn-cap { width: 54px; height: 54px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* print */
@media print {
  .app-navbar, .sidebar, .topbar, .action-bar, .toast-stack, .no-print { display: none !important; }
  body { padding-bottom: 0; }
  .app-main { margin-left: 0 !important; }
  .panel { break-inside: avoid; box-shadow: none; }
}

/* =========================================================
   APP SHELL — sidebar + topbar (multi-page layout)
   ========================================================= */
.app-shell { display: block; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  z-index: 1035;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #24272b 0%, #1b1e21 100%);
  border-right: 1px solid #0f1113;
}
/* the logo artwork is dark ink — it needs a light plate on the dark rail */
.sidebar .sb-brand {
  display: block;
  padding: .9rem 1.1rem;
  background: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar .sb-brand img { height: 40px; width: auto; }
.sb-scroll { flex: 1 1 auto; overflow-y: auto; padding: .75rem .6rem; }

.sb-nav { display: flex; flex-direction: column; gap: .2rem; }
.sb-link {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .6rem .75rem;
  border-radius: 11px;
  color: rgba(255, 255, 255, .68);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.sb-link i { font-size: 1.1rem; width: 1.35rem; text-align: center; flex: 0 0 auto; }
.sb-link .sb-txt { flex: 1 1 auto; min-width: 0; line-height: 1.15; }
.sb-link .sb-txt b {
  display: block;
  font-family: var(--ff-display);
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.sb-link .sb-txt small { display: block; font-size: .66rem; color: rgba(255, 255, 255, .38); letter-spacing: .04em; }
.sb-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sb-link.active {
  background: linear-gradient(90deg, rgba(197, 94, 45, .32), rgba(197, 94, 45, .08));
  border-color: rgba(232, 131, 79, .45);
  color: #fff;
}
.sb-link.active i { color: var(--brand-light); }
.sb-badge {
  flex: 0 0 auto;
  min-width: 20px;
  padding: 0 .35rem;
  height: 20px;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  color: #fff;
}
.sb-badge.b-crit { background: var(--danger); animation: pulse 1.1s infinite; }
.sb-badge.b-warn { background: var(--warn); color: #3d2a03; }

.sb-foot {
  padding: .9rem 1rem 1.1rem;
  border-top: 1px solid rgba(255, 255, 255, .08);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.sb-estop {
  flex: 0 0 auto;
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 36% 30%, #ffe36b, #f5c518 55%, #c99a06);
  box-shadow: 0 6px 14px rgba(0, 0, 0, .4);
  cursor: pointer;
}
.sb-estop .dome {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 28%, #ff8181, #dc2f2f 58%, #8b1414);
  box-shadow: inset 0 -4px 8px rgba(0, 0, 0, .35), inset 0 4px 8px rgba(255, 255, 255, .25);
  transition: transform .12s ease;
}
.sb-estop:active .dome { transform: scale(.92); }
.sb-estop.latched { animation: pulse 1s infinite; }
.sb-estop.latched .dome { transform: scale(.85); filter: brightness(.8); }
.sb-estop-txt {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.sb-meta { font-size: .7rem; color: rgba(255, 255, 255, .45); line-height: 1.4; letter-spacing: .03em; }
.sb-meta b { color: rgba(255, 255, 255, .8); }

.app-main { min-height: 100vh; }
@media (min-width: 1200px) {
  .app-main { margin-left: 260px; }
  body { padding-bottom: 0; }            /* no mobile action bar to clear */
}

.nav-drawer { width: 268px; background: linear-gradient(180deg, #24272b, #1b1e21); }
.nav-drawer .offcanvas-header { border-color: rgba(255, 255, 255, .08) !important; background: #fff; }

/* --- topbar --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1rem;
  min-height: 62px;
  background: rgba(255, 255, 255, .93);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 14px rgba(17, 24, 39, .04);
}
.tb-burger {
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  border-radius: 10px;
  width: 40px; height: 40px;
  font-size: 1.2rem;
  color: var(--ink);
  flex: 0 0 auto;
}
.tb-logo img { height: 30px; }
.tb-title h1 { font-size: 1.25rem; margin: 0; line-height: 1.1; text-transform: uppercase; letter-spacing: .06em; }
.tb-title .eyebrow { display: block; font-size: .6rem; }
.tb-right { display: flex; align-items: center; gap: .6rem; margin-left: auto; }

/* --- page wrapper + page head --- */
.page-wrap { padding: 1.1rem 1rem 1.5rem; max-width: 1360px; }
@media (min-width: 768px) { .page-wrap { padding: 1.4rem 1.5rem 2rem; } }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .85rem;
  margin-bottom: 1.15rem;
  padding-bottom: .9rem;
  border-bottom: 1px solid var(--line);
}
.page-head .ph-ico {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  color: #fff;
  background: linear-gradient(140deg, var(--brand-light), var(--brand-dark));
  box-shadow: 0 6px 16px rgba(197, 94, 45, .3);
  flex: 0 0 auto;
}
.page-head h1 {
  font-size: 1.55rem;
  margin: 0;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.page-head p { margin: .15rem 0 0; font-size: .84rem; color: var(--muted); max-width: 62ch; }
.page-head .ph-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
@media (max-width: 575.98px) { .page-head h1 { font-size: 1.25rem; } }

/* =========================================================
   Slim status strip + single control card (dashboard)
   ========================================================= */
.status-hero--slim .hero-inner { padding: .9rem 1.15rem; }
.hero-grid {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1.25rem;
}
.hero-grid .hg-step { min-width: 0; }
.status-hero--slim .state-badge { font-size: 1.35rem; }
.status-hero--slim .estop-label { color: #ff9b9b; }
.status-hero--slim .hero-progress { height: 10px; }

@media (max-width: 767.98px) {
  .hero-grid { grid-template-columns: 1fr auto; }
  .hero-grid .hg-step { grid-column: 1 / -1; order: 3; }
  .status-hero--slim .state-badge { font-size: 1.15rem; }
}

/* section label inside the control card */
.ctl-label {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .7rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}
.ctl-label::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--line); }

.ctl-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.ctl-row .btn { font-weight: 700; }

/* compact segmented control for the panel header */
.seg.seg-sm { width: auto; padding: 3px; gap: 3px; }
.seg.seg-sm button { padding: .25rem .8rem; font-size: .74rem; }

/* =========================================================
   KPI tiles
   ========================================================= */
.kpi {
  position: relative;
  height: 100%;
  padding: .9rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--stat-c, var(--brand));
}
.kpi-top { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.kpi-ico {
  width: 30px; height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: .95rem;
  color: var(--stat-c, var(--brand));
  background: var(--stat-bg, var(--brand-50));
  flex: 0 0 auto;
}
.kpi-name { font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.kpi-val {
  font-family: var(--ff-display);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.kpi-val small { font-size: .8rem; color: var(--muted); font-weight: 600; margin-left: .15rem; }
.kpi-sub { font-size: .72rem; color: var(--muted); margin-top: .3rem; }
.kpi-val.bump { animation: bump .45s ease; }

/* =========================================================
   Charts
   ========================================================= */
.chart {
  position: relative;
  height: 210px;
  padding: 0 0 0 2.1rem;
}
.chart-grid { position: absolute; inset: 0 0 26px 2.1rem; }
.chart-grid span {
  position: absolute;
  left: 0; right: 0;
  border-top: 1px dashed var(--line);
}
.chart-grid span i {
  position: absolute;
  left: -2.1rem;
  top: -.55rem;
  width: 1.9rem;
  text-align: right;
  font-style: normal;
  font-size: .62rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.chart-bars {
  position: relative;
  height: 100%;
  display: flex;
  align-items: flex-end;
  gap: .3rem;
  padding-bottom: 26px;
}
.cb { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.cb-bar {
  --cb: var(--brand);
  width: 100%;
  max-width: 42px;
  border-radius: 6px 6px 0 0;
  background: var(--cb);                                    /* fallback */
  background: linear-gradient(180deg, color-mix(in srgb, var(--cb) 78%, #fff), var(--cb));
  transition: height .5s cubic-bezier(.2, .8, .3, 1);
}
.cb.hl .cb-bar { --cb: var(--brand); box-shadow: 0 0 0 2px rgba(197, 94, 45, .22); }
.cb:not(.hl) .cb-bar { --cb: #93a1b0; }
.cb:hover .cb-bar { filter: brightness(1.08); }
.cb-val {
  font-size: .64rem;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: .2rem;
  font-variant-numeric: tabular-nums;
}
.cb-lab {
  position: absolute;
  bottom: -20px;
  font-size: .6rem;
  letter-spacing: .02em;
  color: var(--muted);
  white-space: nowrap;
}
.cb { position: relative; }

.spark { width: 100%; height: 44px; display: block; }

.donut-wrap { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.donut { width: 152px; height: 152px; flex: 0 0 auto; transform: rotate(-90deg); }
.donut .dn-track { fill: none; stroke: var(--surface-3); stroke-width: 16; }
.donut .dn-seg { fill: none; stroke-width: 16; stroke-linecap: butt; transition: stroke-dasharray .6s ease; }
.donut text { transform: rotate(90deg); transform-origin: 70px 70px; text-anchor: middle; }
.donut .dn-num { font-family: var(--ff-display); font-size: 1.7rem; font-weight: 700; fill: var(--ink); }
.donut .dn-cap { font-size: .5rem; letter-spacing: .16em; fill: var(--muted); font-weight: 700; }
.donut-legend { list-style: none; margin: 0; padding: 0; flex: 1 1 190px; display: flex; flex-direction: column; gap: .45rem; }
.donut-legend li { display: flex; align-items: center; gap: .55rem; font-size: .84rem; }
.donut-legend .dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.donut-legend .dl-name { flex: 1 1 auto; color: var(--ink-2); }
.donut-legend .dl-val { font-family: var(--ff-display); font-weight: 700; }
.donut-legend .dl-val small { color: var(--muted); font-weight: 600; margin-left: .35rem; font-size: .72rem; }

/* =========================================================
   Sensor cards (diagnostics page)
   ========================================================= */
.sensor-card {
  height: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 1rem 1.05rem;
  color: var(--g-c, var(--brand));
  transition: border-color .2s ease, box-shadow .2s ease;
}
.sensor-card.warn { border-color: #f6dfae; box-shadow: 0 0 0 3px rgba(240, 160, 32, .12); }
.sensor-card.crit { border-color: #f3bcbc; box-shadow: 0 0 0 3px rgba(220, 47, 47, .14); }
.sc-head { display: flex; align-items: center; gap: .55rem; margin-bottom: .55rem; }
.sc-ico {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--surface-2);                             /* fallback */
  background: color-mix(in srgb, currentColor 12%, #fff);
  font-size: 1rem;
  flex: 0 0 auto;
}
.sc-name { font-family: var(--ff-display); font-weight: 700; font-size: .95rem; letter-spacing: .05em; text-transform: uppercase; color: var(--ink); flex: 1 1 auto; }
.sc-pill { font-size: .6rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; padding: .2rem .5rem; border-radius: 999px; background: #eafaf0; color: #12783a; }
.sensor-card.warn .sc-pill { background: #fdf6e7; color: #8f610a; }
.sensor-card.crit .sc-pill { background: #fdeeee; color: #a51f1f; }
.sc-value { font-family: var(--ff-display); font-size: 2.1rem; font-weight: 700; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.sc-spark { color: var(--g-c, var(--brand)); margin: .35rem 0 .1rem; }
.sc-meta { display: flex; justify-content: space-between; font-size: .68rem; color: var(--muted); }
.sc-bar {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
  margin: .5rem 0 .3rem;
}
.sc-bar .fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--g-c), var(--g-c2)); transition: width .5s ease; }
.sensor-card.warn .sc-bar .fill { background: linear-gradient(90deg, #f0a020, #ffcb6b); }
.sensor-card.crit .sc-bar .fill { background: linear-gradient(90deg, #dc2f2f, #ff8b8b); }
.sc-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: rgba(17, 24, 39, .35); }
.sc-mark.crit { background: rgba(220, 47, 47, .75); }

/* =========================================================
   Data tables
   ========================================================= */
.data-table { font-size: .84rem; margin: 0; }
.data-table thead th {
  font-size: .64rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line) !important;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}
.data-table td { vertical-align: middle; border-color: var(--line) !important; }
.data-table tbody tr:hover { background: var(--brand-50); }
.data-table .num { font-variant-numeric: tabular-nums; text-align: right; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }

.filter-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.filter-pill {
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink-2);
  border-radius: 999px;
  padding: .3rem .8rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.filter-pill.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.filter-pill.active.f-fault { background: var(--danger); border-color: var(--danger); }
.filter-pill.active.f-warn  { background: var(--warn); border-color: var(--warn); color: #3d2a03; }
.filter-pill.active.f-ok    { background: var(--ok); border-color: var(--ok); }
.filter-pill.active.f-info  { background: var(--water); border-color: var(--water); }

.empty-state { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }
.empty-state i { font-size: 2rem; display: block; margin-bottom: .5rem; opacity: .6; }

/* =========================================================
   Instructions page
   ========================================================= */
.proc-card {
  height: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.proc-head {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .85rem 1rem;
  background: linear-gradient(180deg, #fff, var(--surface-2));
  border-bottom: 1px solid var(--line);
}
.proc-head .p-ico {
  width: 38px; height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.05rem;
  background: linear-gradient(140deg, var(--p-c, var(--brand)), var(--p-c2, var(--brand-dark)));
  flex: 0 0 auto;
}
.proc-head h3 { margin: 0; font-size: 1rem; text-transform: uppercase; letter-spacing: .05em; }
.proc-head small { display: block; font-size: .68rem; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; font-weight: 700; }
.proc-steps { list-style: none; counter-reset: st; margin: 0; padding: .85rem 1rem 1rem; }
.proc-steps li {
  counter-increment: st;
  position: relative;
  padding: .45rem 0 .45rem 2.2rem;
  font-size: .88rem;
  color: var(--ink-2);
  border-bottom: 1px dashed var(--line);
}
.proc-steps li:last-child { border-bottom: 0; }
.proc-steps li::before {
  content: counter(st);
  position: absolute;
  left: 0; top: .45rem;
  width: 1.5rem; height: 1.5rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--ff-display);
  font-size: .78rem;
  font-weight: 700;
  color: var(--p-c, var(--brand));
  background: var(--surface-2);                             /* fallback */
  background: color-mix(in srgb, var(--p-c, var(--brand)) 12%, #fff);
  border: 1px solid var(--line);
  border-color: color-mix(in srgb, var(--p-c, var(--brand)) 28%, #fff);
}
.note {
  display: flex;
  gap: .7rem;
  align-items: flex-start;
  padding: .8rem .95rem;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
}
.note i { font-size: 1.15rem; line-height: 1.2; }
.note.n-danger { background: #fdeeee; border-color: #f3bcbc; color: #8f1d1d; }
.note.n-danger i { color: var(--danger); }
.note.n-warn { background: #fdf6e7; border-color: #f6dfae; color: #7a5205; }
.note.n-warn i { color: var(--warn); }
.note.n-info { background: var(--brand-50); border-color: var(--brand-100); color: #7a3c18; }
.note.n-info i { color: var(--brand); }

/* =========================================================
   Misc page bits
   ========================================================= */
.mini-bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.mini-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--stat-c, var(--brand)); transition: width .5s ease; }

.usage-row { display: flex; align-items: center; gap: .85rem; padding: .7rem 0; border-bottom: 1px dashed var(--line); }
.usage-row:last-child { border-bottom: 0; }
.usage-row .u-ico {
  width: 38px; height: 38px;
  border-radius: 11px;
  display: grid; place-items: center;
  font-size: 1.05rem;
  color: var(--stat-c, var(--brand));
  background: var(--stat-bg, var(--brand-50));
  flex: 0 0 auto;
}
.usage-row .u-body { flex: 1 1 auto; min-width: 0; }
.usage-row .u-name { font-size: .84rem; font-weight: 600; color: var(--ink-2); display: flex; justify-content: space-between; gap: .5rem; }
.usage-row .u-name b { font-family: var(--ff-display); color: var(--ink); }
.usage-row .u-sub { font-size: .68rem; color: var(--muted); margin-top: .25rem; }

.state-pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .64rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: .2rem .55rem;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
}
.state-pill.on   { background: #eafaf0; color: #12783a; }
.state-pill.warn { background: #fdf6e7; color: #8f610a; }
.state-pill.err  { background: #fdeeee; color: #a51f1f; }

.timeline { position: relative; padding-left: 1.4rem; }
.timeline::before { content: ""; position: absolute; left: .42rem; top: .3rem; bottom: .3rem; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: .45rem 0; font-size: .84rem; }
.tl-item::before {
  content: "";
  position: absolute;
  left: -1.16rem; top: .78rem;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-50);
}
.tl-item.pass::before { background: var(--ok); box-shadow: 0 0 0 3px #eafaf0; }
.tl-item.fail::before { background: var(--danger); box-shadow: 0 0 0 3px #fdeeee; }
.tl-time { font-size: .68rem; color: var(--muted); font-family: ui-monospace, Consolas, monospace; }

@media (max-width: 1199.98px) {
  .toast-stack { top: 74px; }
}
@media (max-width: 767.98px) {
  .chart { height: 180px; padding-left: 1.8rem; }
  .chart-grid { left: 1.8rem; }
  .cb-val { display: none; }
  .kpi-val { font-size: 1.45rem; }
}
