/* Wiman Gateway Simulator — minimal Bootstrap-ish utility CSS */
:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --border: #e2e6ec;
  --text: #1d2433;
  --muted: #6b7280;
  --accent: #5d4fff;
  --warn: #d97706;
  --danger: #dc2626;
  --go: #16a34a;
  --pill: #eef0f4;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
em { color: var(--danger); font-style: normal; }

/* Topbar ------------------------------------------------------------------ */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 24px; background: #111827; color: #fff;
  border-bottom: 1px solid #0b0f17;
}
.topbar a { color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.brand-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 12px var(--accent);
}
.ver { color: #9aa3b1; font-weight: 400; font-size: 12px; margin-left: 8px; }
.nav { display: flex; gap: 18px; }
.nav a { color: #cbd5e1; font-weight: 500; }
.nav a:hover { color: #fff; text-decoration: none; }

/* Layout ------------------------------------------------------------------ */
.main { max-width: 1280px; margin: 24px auto; padding: 0 24px; }
.footer { text-align: center; color: var(--muted); padding: 24px; font-size: 12px; }
h1 { font-size: 22px; margin: 0 0 4px 0; display: flex; align-items: center; gap: 10px; }
h2 { font-size: 16px; margin: 24px 0 8px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.page-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  margin-bottom: 16px;
}

/* Cards + forms ----------------------------------------------------------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 16px; margin: 14px 0;
}
.form label { display: block; margin-bottom: 12px; }
.form label > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.form input, .form select, .form textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13.5px; font-family: inherit; background: #fff;
}
.form textarea { font-family: var(--mono); font-size: 12.5px; }
.form input.mono { font-family: var(--mono); font-size: 12.5px; }
.form .row, .form.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.form .row.r-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form .row.r-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.form .row.r-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .form .row.r-5, .form .row.r-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form .row.r-3 { grid-template-columns: 1fr; }
}
.form .col { display: flex; flex-direction: column; }
.form .col.grow { grid-column: span 2; }
.form input.wide { width: 100%; }
.check { display: inline-flex; align-items: center; gap: 6px; padding-top: 18px; }
.inline-form { background: #fafbfd; border-top: 1px solid var(--border); padding: 10px; border-radius: 0 0 8px 8px; margin: 10px -16px -14px; }

/* Grouped sections in compact form (Device identity / Comms / GPRS) -------- */
fieldset.grp { border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 12px 10px; margin: 0 0 10px; background: #fff; }
fieldset.grp legend { padding: 0 6px; font-size: 11px; color: var(--muted);
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
fieldset.grp .row { margin-bottom: 6px; }
fieldset.grp .row:last-child { margin-bottom: 0; }
fieldset.grp .full-row { display: block; margin: 0 0 6px; }
fieldset.grp .full-row > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
fieldset.grp .full-row > input { width: 100%; box-sizing: border-box; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 6px; font-size: 13px; font-family: inherit; }

/* Slimmer form inputs across the board for a denser pro look -------------- */
.form label { margin-bottom: 8px; }
.form label > span { font-size: 11px; margin-bottom: 3px; }
.form input, .form select { padding: 6px 8px; font-size: 13px; }
.form textarea { padding: 8px 10px; font-size: 12.5px; }

/* Buttons ----------------------------------------------------------------- */
.btn {
  display: inline-block; padding: 6px 12px; border-radius: 6px;
  background: #fff; border: 1px solid var(--border); color: var(--text);
  font-size: 13px; cursor: pointer; line-height: 1.3;
  text-decoration: none;
}
.btn:hover { background: #f4f5f8; }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #4c40d6; border-color: #4c40d6; }
.btn-go { background: var(--go); color: #fff; border-color: var(--go); }
.btn-warn { background: var(--warn); color: #fff; border-color: var(--warn); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.actions { display: flex; gap: 8px; align-items: flex-end; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions form { display: inline; margin: 0; }
form.inline { display: inline; }

/* Tables ------------------------------------------------------------------ */
table.data {
  width: 100%; border-collapse: collapse; background: #fff; border-radius: 6px;
  overflow: hidden; border: 1px solid var(--border);
}
table.data th, table.data td {
  padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top;
  text-align: left;
}
table.data th { background: #fafbfd; font-size: 12px; color: var(--muted); font-weight: 600; }
table.data tr.running td { background: #f0fdf4; }
table.data tr:last-child td { border-bottom: 0; }
.ellipsis { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Pills + protocol tags --------------------------------------------------- */
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: var(--pill); font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.pill-on { background: #dcfce7; color: #166534; }
.pill-off { background: #f1f5f9; color: #475569; }
.pill.dir-tx { background: #dbeafe; color: #1d4ed8; }
.pill.dir-rx { background: #ddd6fe; color: #5b21b6; }
.pill.dir-info { background: #fef3c7; color: #92400e; }
.pill.dir-error { background: #fee2e2; color: #991b1b; }
.stat-0 { background: #dcfce7; color: #166534; }
.stat-21, .stat-22, .stat-23, .stat-24 { background: #fee2e2; color: #991b1b; }

.proto { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 11px;
  font-family: var(--mono); background: var(--pill); }
.proto-http { background: #dbeafe; color: #1d4ed8; }
.proto-mqtt { background: #ede9fe; color: #6d28d9; }
.proto-tcp  { background: #fef3c7; color: #92400e; }

/* Payload-format pills (sibling to .proto, intentionally distinct palette) -- */
.fmt { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 11px;
  font-family: var(--mono); background: var(--pill); font-weight: 600;
  letter-spacing: 0.02em; }
.fmt-json { background: #d1fae5; color: #065f46; }
.fmt-csv  { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; padding: 0 5px; }

/* Gateway-list rich rows --------------------------------------------------- */
table.gw-list { table-layout: auto; }
table.gw-list td { vertical-align: middle; padding: 10px; }
table.gw-list td.cell-stack { line-height: 1.35; }
table.gw-list .primary { display: block; font-weight: 600; color: var(--text); }
table.gw-list a.primary { color: var(--accent); text-decoration: none; }
table.gw-list a.primary:hover { text-decoration: underline; }
table.gw-list .sub { display: block; font-size: 12px; color: var(--text); margin-top: 1px; }
table.gw-list .muted-tiny { display: block; font-size: 10.5px; color: var(--muted);
  letter-spacing: 0.02em; margin-top: 2px; }
table.gw-list .chip-row { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
table.gw-list td.cell-target { max-width: 280px; }
table.gw-list td.cell-target .ellipsis { display: block; max-width: 280px; }

/* Flashes ----------------------------------------------------------------- */
.flashes { list-style: none; padding: 0; margin: 0 0 14px; }
.flash { padding: 8px 12px; border-radius: 6px; margin-bottom: 6px; }
.flash-success { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }
.flash-info { background: #dbeafe; color: #1d4ed8; }

/* Grid + slave cards ------------------------------------------------------ */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 14px; }
.slave-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.slave-head form { margin: 0; }

/* Log table tweaks -------------------------------------------------------- */
table.log td { font-size: 12.5px; }
table.log tr.dir-error td { background: #fff7f7; }
table.log tr.dir-tx td { background: #f7faff; }

/* Scrollable live-log container — keeps the page short on busy gateways */
.log-scroll {
  max-height: 420px; overflow-y: auto; overflow-x: hidden;
  border: 1px solid var(--border); border-radius: 6px; background: #fff;
}
.log-scroll table.log { border: 0; border-radius: 0; }
.log-scroll table.log thead th {
  position: sticky; top: 0; z-index: 1;
  background: #fafbfd; border-bottom: 1px solid var(--border);
  font-size: 10.5px; padding: 4px 8px;
}
/* Tight 11px monospace rows — pack more entries on screen for analysis */
.log-scroll table.log td { padding: 2px 8px; font-size: 11px; line-height: 1.4; }
.log-scroll table.log td.mono { font-size: 11px; }
.log-scroll table.log .pill {
  padding: 0 6px; font-size: 9.5px; letter-spacing: 0.03em;
}

pre { background: #f5f7fa; padding: 10px; border-radius: 6px; overflow-x: auto;
  font-family: var(--mono); font-size: 12.5px; }
details summary { cursor: pointer; padding: 4px 0; font-weight: 500; }

.empty { text-align: center; padding: 40px 20px; background: #fff;
  border: 1px dashed var(--border); border-radius: 8px; }

/* IMEI/MAC radio segment ---------------------------------------------------- */
.seg {
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 12px 6px;
  margin: 0 0 12px; display: flex; flex-wrap: wrap; align-items: center;
  gap: 4px 20px; background: #fafbfd;
}
.seg legend { padding: 0 6px; font-size: 11px; color: var(--muted); font-weight: 600;
              text-transform: uppercase; letter-spacing: 0.04em; }
.seg .radio { display: inline-flex; align-items: center; gap: 6px;
              padding: 2px 0; margin: 0; font-size: 13px; }
.seg .radio input[type=radio] { margin: 0; }
.seg .radio .muted { font-weight: 400; }

/* Input + sidekick button (e.g. 🎲 Random) ---------------------------------- */
.input-with-btn { display: flex; gap: 6px; align-items: stretch; }
.input-with-btn > input { flex: 1; min-width: 0; }
.input-with-btn > .btn { white-space: nowrap; }

/* live preview block -------------------------------------------------------- */
#login-preview, .preview-pane {
  background: #0f172a; color: #e2e8f0; padding: 14px; border-radius: 6px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.5;
  max-height: 380px; overflow: auto; margin: 0; white-space: pre;
}

/* Full-width form rows (break out of multi-col layout) --------------------- */
.form label.full-row { display: block; width: 100%; }
.form label.full-row > textarea,
.form label.full-row > input { width: 100%; box-sizing: border-box; }

/* Code-style textarea — full width, monospace, gentle scroll, light bg ----- */
.code-area {
  width: 100%; min-height: 260px;
  background: #fafbfd; border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5;
  resize: vertical; white-space: pre; overflow: auto; tab-size: 2;
}
.code-area:focus { outline: 2px solid var(--accent); outline-offset: -2px; border-color: var(--accent); }

/* preview pair (login on left, data on right) ------------------------------ */
.preview-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.preview-pair > div { min-width: 0; }   /* let children shrink so <pre> wraps */
.preview-h {
  font-size: 12px; color: var(--muted); font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  margin: 0 0 6px;
}
@media (max-width: 900px) { .preview-pair { grid-template-columns: 1fr; } }

/* Register Mapping table -------------------------------------------------- */
table.data.regmap td { padding: 4px 6px; vertical-align: middle; }
table.data.regmap input,
table.data.regmap select {
  width: 100%; padding: 4px 6px; font-size: 12.5px;
  border: 1px solid var(--border); border-radius: 4px; background: #fff;
}
table.data.regmap input.mono { font-family: var(--mono); }
table.data.regmap .w-name   { min-width: 110px; }
table.data.regmap .w-units  { min-width: 50px;  max-width: 80px; }
table.data.regmap .w-ft     { min-width: 130px; }
table.data.regmap .w-res    { min-width: 80px; }
table.data.regmap .w-gen    { min-width: 80px; }
table.data.regmap .w-mm     { min-width: 70px;  max-width: 110px; text-align: right; }

details.regmap-add { background: #fafbfd; border: 1px solid var(--border);
  border-radius: 6px; padding: 8px 12px; margin-top: 10px; }
details.regmap-add summary { cursor: pointer; padding: 4px 0; font-weight: 500; }
details.regmap-add hr { border: 0; border-top: 1px dashed var(--border); margin: 10px 0; }

/* Detail-page meta line — single-line summary above the cards --------------- */
.meta-line { line-height: 1.7; word-break: break-word; }
.meta-line .mono { font-size: 12px; }

/* Slimmer cards on detail page --------------------------------------------- */
.card { padding: 12px 14px; }
.card h3 { margin-bottom: 6px; }
section.slave { padding: 10px 14px; }
section.slave .slave-head { margin-bottom: 6px; }

/* Inline editable slave header -------------------------------------------- */
.slave-head-form {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 4px 0 8px; border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.slave-head-form .muted { padding-left: 8px; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.04em; }
.slave-head-form .muted:first-child { padding-left: 0; }
.slave-head-form input {
  padding: 4px 6px; font-size: 12.5px; border: 1px solid var(--border);
  border-radius: 4px; background: #fff;
}
.slave-head-form .w-sid   { width: 54px;  text-align: right; }
.slave-head-form .w-stat  { width: 60px;  text-align: right; }
.slave-head-form .w-csv   { width: 95px; }
.slave-head-form select   { padding: 4px 6px; font-size: 12.5px;
  border: 1px solid var(--border); border-radius: 4px; background: #fff; }
.slave-head-form .w-label { flex: 1; min-width: 140px; }
.slave-head-form .w-int   { width: 70px;  text-align: right; }
/* Slave on/off toggle styled as a clickable pill (matches gateway-level state pill) */
.slave-head-form .slave-toggle {
  border: 0; cursor: pointer; padding: 2px 10px; margin-right: 4px;
  font-family: inherit;
}
.slave-head-form .slave-toggle:hover { filter: brightness(0.95); }
/* Disabled slave card: dim everything but keep the toggle pill readable */
.slave.slave-disabled { opacity: 0.55; background: #fafafa; }
.slave.slave-disabled .slave-toggle { opacity: 1; }
.slave-head-form button { margin-left: 4px; }
.slave-head-form button.btn-danger { margin-left: auto; }

/* Live preview + Test Emit card on detail page --------------------------- */
.preview-card .emit-actions {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin: 6px 0 12px;
}
.preview-card .preview-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
@media (max-width: 1000px) {
  .preview-card .preview-grid { grid-template-columns: 1fr; }
}
.preview-card .pkt-pre {
  margin: 4px 0 0; padding: 10px; background: #0f172a; color: #e2e8f0;
  border-radius: 4px; font-family: var(--mono); font-size: 11.5px;
  line-height: 1.45; white-space: pre-wrap; word-break: break-all;
  max-height: 280px; overflow: auto;
}

/* =========================================================================
   Operator Console — scenario engine UI
   ========================================================================= */

.console-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 18px; gap: 16px;
}
.console-head h1 { margin: 6px 0 4px; font-size: 28px; }
.console-crumb { font-size: 13px; }
.console-crumb a { font-weight: 500; }
.console-head-state { display: flex; gap: 8px; align-items: center; }

.console-slave {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  margin-bottom: 18px; overflow: hidden;
}
.console-slave-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: #fafbfd;
  border-bottom: 1px solid var(--border); gap: 12px;
}
.csh-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.csh-left h2 { margin: 0; font-size: 18px; }
.csh-left h2 .muted { margin-right: 6px; }
.scenario-chip {
  display: inline-block; padding: 2px 10px; border-radius: 6px;
  background: #ede9fe; color: #5b21b6; font-size: 12px; font-weight: 600;
}
.scenario-chip-empty { background: #f1f5f9; color: var(--muted); }
.csh-right select { padding: 4px 8px; font-size: 12.5px;
  border: 1px solid var(--border); border-radius: 4px; background: #fff; }

.console-grid {
  display: grid; grid-template-columns: minmax(340px, 1fr) minmax(340px, 1fr);
  gap: 0;
}
@media (max-width: 980px) { .console-grid { grid-template-columns: 1fr; } }
.panel { padding: 16px 18px; }
.panel-control { border-right: 1px solid var(--border); background: #fbfcff; }
@media (max-width: 980px) {
  .panel-control { border-right: 0; border-bottom: 1px solid var(--border); }
}
.panel-title {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 12px; font-weight: 600; font-size: 14px;
}
.panel-title .muted { font-weight: 400; }

.console-empty {
  padding: 24px; color: var(--muted); background: #fafbfd;
  border-top: 1px dashed var(--border);
}
.console-empty strong { color: var(--text); }

/* Industrial switch buttons --------------------------------------------- */
.switch-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
@media (min-width: 1200px) { .switch-grid { grid-template-columns: repeat(2, 1fr); } }
.switch {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; cursor: pointer; font-family: inherit; font-size: 13px;
  text-align: left; transition: all 0.15s ease;
}
.switch:hover { border-color: #a5b4fc; transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(93, 79, 255, 0.08); }
.switch .led {
  width: 12px; height: 12px; border-radius: 50%;
  background: #cbd5e1; box-shadow: inset 0 1px 2px rgba(0,0,0,0.15);
  flex-shrink: 0; transition: all 0.15s ease;
}
.switch.is-on { background: linear-gradient(180deg, #f0fdf4 0%, #dcfce7 100%);
  border-color: #86efac; }
.switch.is-on .led {
  background: #16a34a;
  box-shadow: 0 0 8px rgba(22, 163, 74, 0.6),
              inset 0 1px 2px rgba(255,255,255,0.4);
}
.switch-body { display: flex; flex-direction: column; gap: 1px; }
.switch-name { font-weight: 600; color: var(--text); }
.switch-rating { font-size: 11px; color: var(--muted); font-family: var(--mono); }

.panel-divider { height: 1px; background: var(--border); margin: 16px 0; }
.panel-sub { margin-bottom: 12px; }
.slider-label {
  display: flex; justify-content: space-between; font-size: 13px;
  font-weight: 500; margin-bottom: 6px;
}
.slider-value { font-family: var(--mono); color: var(--accent); font-weight: 600; }
.slider {
  width: 100%; -webkit-appearance: none; appearance: none;
  height: 6px; border-radius: 3px; background: #e2e6ec; outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.slider::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; border: 0;
  background: var(--accent); cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.action-btn.is-active { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

/* Live tiles ------------------------------------------------------------ */
.tile-row { display: grid; gap: 10px; margin-bottom: 14px; }
.tile-row-hero { grid-template-columns: repeat(3, 1fr); }
.tile-row-small { grid-template-columns: repeat(3, 1fr); }
.tile {
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px;
}
.tile-hero { padding: 14px 16px; }
.tile-label {
  font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 600; margin-bottom: 4px;
}
.tile-value { display: flex; align-items: baseline; gap: 6px; }
.tile-num { font-family: var(--mono); font-weight: 700; color: var(--text); }
.tile-unit { font-size: 12px; color: var(--muted); font-weight: 600; }
.tile-hero .tile-num { font-size: 30px; }
.tile-hero .tile-unit { font-size: 14px; }
.tile-small .tile-num { font-size: 18px; }

.tile-primary { background: linear-gradient(180deg, #fefeff 0%, #f5f3ff 100%);
  border-color: #ddd6fe; }
.tile-primary .tile-num { color: var(--accent); }
.tile-go { background: linear-gradient(180deg, #fefffe 0%, #f0fdf4 100%);
  border-color: #bbf7d0; }
.tile-go .tile-num { color: #16a34a; }
.tile-muted { background: #fafbfd; }

.flash-pulse { animation: tile-pulse 0.6s ease; }
@keyframes tile-pulse {
  0%   { background-color: transparent; }
  20%  { background-color: rgba(93, 79, 255, 0.18); }
  100% { background-color: transparent; }
}

/* Phase table ----------------------------------------------------------- */
.phase-table { width: 100%; border-collapse: collapse;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; margin-bottom: 14px; }
.phase-table th {
  text-align: left; padding: 8px 12px; background: #fafbfd;
  font-size: 11px; color: var(--muted); text-transform: uppercase;
  font-weight: 600; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}
.phase-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.phase-table tr:last-child td { border-bottom: 0; }
.phase-table .mono { font-size: 15px; font-weight: 600; }
.phase-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  margin-right: 8px; vertical-align: middle;
  box-shadow: 0 0 6px currentColor;
}

/* =========================================================================
   Operator Console v2 — appliance store + arc gauges
   ========================================================================= */

/* Gauge strip (top row of 4 stat cards) ---------------------------------- */
.gauge-strip {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  padding: 18px; background: #fbfcff; border-bottom: 1px solid var(--border);
}
@media (max-width: 980px) { .gauge-strip { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; text-align: center; position: relative;
}
.stat-label {
  font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 600; margin-bottom: 6px;
}
.stat-value, .stat-big {
  display: flex; align-items: baseline; justify-content: center; gap: 6px;
  margin-top: 4px;
}
.stat-big { padding: 18px 0 14px; }
.stat-num { font-family: var(--mono); font-weight: 700; font-size: 26px; color: var(--text); }
.stat-big .stat-num { font-size: 36px; }
.stat-unit { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat-foot { margin-top: 6px; font-size: 11px; }
.stat-power .stat-num { color: var(--accent); }
.stat-energy .stat-num { color: var(--go); }

.arc-gauge { display: block; width: 100%; max-width: 140px; margin: 4px auto -8px; height: auto; }
.arc-track { fill: none; stroke: #e2e6ec; stroke-width: 8; stroke-linecap: round; }
.arc-fill  { fill: none; stroke: var(--accent); stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 0 999;
  transition: stroke-dasharray 0.6s ease;
}
.arc-fill-warn { stroke: #f59e0b; }
.arc-fill-go   { stroke: var(--go); }

/* Appliance room (the focus) -------------------------------------------- */
.appliance-room { padding: 18px; }
.appliance-room-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; gap: 12px; flex-wrap: wrap;
}
.appliance-toolbar { display: flex; gap: 6px; flex-wrap: wrap; }

.appliance-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
}
@media (max-width: 820px) { .appliance-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .appliance-grid { grid-template-columns: repeat(2, 1fr); } }

.appliance {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 18px 10px 14px; background: #fff;
  border: 2px solid #e2e6ec; border-radius: 12px;
  cursor: pointer; font-family: inherit; text-align: center;
  transition: all 0.18s ease;
  color: #94a3b8;
}
.appliance:hover {
  border-color: #a5b4fc; transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(93, 79, 255, 0.10);
  color: var(--accent);
}
.appliance-icon { width: 56px; height: 56px; display: block; }
.appliance-name {
  font-weight: 600; font-size: 13px; color: var(--text);
  margin-top: 4px;
}
.appliance-rating {
  font-size: 11.5px; color: var(--muted); font-family: var(--mono);
}

.appliance.is-on {
  background: linear-gradient(180deg, #f0fdf4 0%, #dcfce7 100%);
  border-color: #22c55e; color: #16a34a;
  box-shadow: 0 0 0 1px rgba(34,197,94,0.20),
              0 6px 14px rgba(34,197,94,0.18);
}
.appliance.is-on .appliance-name { color: #14532d; }
.appliance.is-on .appliance-rating { color: #166534; }
.appliance.is-on .appliance-icon { filter: drop-shadow(0 0 6px rgba(34,197,94,0.5)); }

.appliance-foot { margin-top: 18px; }

/* =========================================================================
   v0.11.0 — sparklines, cash box, state pills, demo scripts
   ========================================================================= */

/* Sparklines under arc gauges ------------------------------------------- */
.sparkline {
  display: block; width: 100%; max-width: 140px; height: 22px;
  margin: -4px auto 4px; color: #cbd5e1; opacity: 0.85;
}
.stat-power .sparkline    { color: var(--accent); }
.stat-arc .arc-fill-warn ~ .stat-value ~ .sparkline,
.stat-arc .arc-fill-warn ~ .sparkline { color: #f59e0b; }
/* Easier: target by stat-card class which we already have specialized */
.stat-arc:has(.arc-fill-warn) .sparkline { color: #f59e0b; }
.stat-arc:has(.arc-fill-go)   .sparkline { color: var(--go); }

/* Cash Box gauge (currency + big balance + spent + kWh underline) ------- */
.stat-cash { background: linear-gradient(180deg, #ffffff 0%, #fef9c3 100%);
  border-color: #fde68a; }
.stat-cash .stat-currency {
  font-size: 22px; font-weight: 700; color: #92400e; margin-right: 4px;
}
.stat-cash .stat-num { color: #92400e; font-size: 32px; }
.stat-cash .stat-foot { color: #a16207; }

/* State pill (compressor / door) ---------------------------------------- */
.stat-state { display: flex; flex-direction: column; justify-content: center;
  align-items: center; }
.state-pill {
  display: inline-block; padding: 8px 18px; border-radius: 999px;
  font-weight: 700; font-size: 14px; letter-spacing: 0.06em;
  text-transform: uppercase; margin: 14px 0 6px;
  transition: all 0.25s ease;
}
.state-muted { background: #f1f5f9; color: #64748b; }
.state-go    { background: #dcfce7; color: #166534;
  box-shadow: 0 0 0 4px rgba(34,197,94,0.10); }
.state-warn  { background: #fef3c7; color: #92400e;
  box-shadow: 0 0 0 4px rgba(245,158,11,0.15); animation: state-warn-pulse 1.4s infinite; }
.state-danger{ background: #fee2e2; color: #991b1b;
  box-shadow: 0 0 0 4px rgba(220,38,38,0.18); }
@keyframes state-warn-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(245,158,11,0.15); }
  50%      { box-shadow: 0 0 0 8px rgba(245,158,11,0.05); }
}

/* Slider rows (stack multiple) ------------------------------------------ */
.slider-row { margin-top: 14px; }
.slider-row:first-child { margin-top: 0; }

/* Demo script strip ----------------------------------------------------- */
.demo-strip {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-top: 16px; padding: 10px 12px;
  background: #f8fafc; border: 1px solid var(--border); border-radius: 8px;
}
.demo-select {
  padding: 4px 8px; font-size: 12.5px; border: 1px solid var(--border);
  border-radius: 4px; background: #fff; flex: 1; min-width: 200px;
  font-family: inherit;
}
[data-role="demo-progress"] {
  min-width: 90px; text-align: right;
  background: #fff; padding: 3px 8px; border-radius: 4px;
  border: 1px solid var(--border);
}

/* stat-num color variants ----------------------------------------------- */
.stat-num-primary { color: var(--accent); }
.stat-num-go      { color: var(--go); }
.stat-num-warn    { color: var(--warn); }

/* =========================================================================
   v0.11.1 — Device-type chip + redesigned Add Slave form
   ========================================================================= */

/* Device-type chip in slave header — clickable link styled as a pill ---- */
.dt-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 6px;
  background: #ede9fe; color: #5b21b6;
  font-size: 11.5px; font-weight: 600;
  text-decoration: none; white-space: nowrap;
  margin: 0 4px; transition: all 0.15s ease;
}
.dt-chip:hover {
  background: #ddd6fe; text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(91,33,182,0.18);
}
.dt-chip-empty {
  background: #f1f5f9; color: var(--muted); font-weight: 500;
}
.dt-chip-empty:hover { background: #e2e8f0; color: var(--text); }

/* Add Slave card — device type promoted to headline field --------------- */
.add-slave-card { border-color: #ddd6fe; background: #fbfaff; }
.add-slave-form { display: flex; flex-direction: column; gap: 10px; }
.add-slave-primary {
  display: grid; grid-template-columns: 2fr 0.6fr 1.5fr auto; gap: 10px;
  align-items: end;
}
@media (max-width: 820px) {
  .add-slave-primary { grid-template-columns: 1fr 1fr; }
  .add-slave-primary .col.actions { grid-column: 1 / -1; }
}
.add-slave-form .dt-select {
  width: 100%; padding: 8px 10px; border: 1.5px solid #c4b5fd;
  border-radius: 6px; font-size: 13.5px; background: #fff;
  font-family: inherit; font-weight: 500;
}
.add-slave-form .dt-select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(93,79,255,0.15);
}
.add-slave-advanced { padding: 4px 0; }
.add-slave-advanced summary { padding: 4px 0; cursor: pointer; user-select: none; }
.add-slave-advanced summary:hover { color: var(--text); }

/* =========================================================================
   v0.11.2 — compact / aligned operator console
   ========================================================================= */

/* Header: tighter slave head ------------------------------------------- */
.console-slave-head { padding: 8px 14px; }
.csh-left h2 { font-size: 15px; }
.csh-left h2 .muted { margin-right: 4px; font-size: 11px; }

/* Gauge strip: more compact, denser, equal heights -------------------- */
.gauge-strip { padding: 12px; gap: 10px; }
@media (min-width: 720px) {
  .gauge-strip { grid-template-columns: repeat(4, 1fr); }
}
.stat-card {
  padding: 10px 12px 8px; border-radius: 8px;
  display: flex; flex-direction: column; justify-content: space-between;
  min-height: 132px;
}
.stat-label {
  font-size: 10px; margin-bottom: 2px;
  letter-spacing: 0.07em;
}
.stat-value, .stat-big {
  display: flex; align-items: baseline; justify-content: center; gap: 4px;
  margin: 2px 0;
}
.stat-big { padding: 4px 0; }
.stat-num { font-size: 20px; }
.stat-big .stat-num { font-size: 26px; }
.stat-unit { font-size: 11px; }
.stat-foot { font-size: 10px; margin-top: 2px; line-height: 1.3; }

/* Arc gauges — tighter */
.arc-gauge { max-width: 96px; margin: 2px auto -4px; }
.arc-track, .arc-fill { stroke-width: 7; }

/* Sparklines under gauges — smaller */
.sparkline { max-width: 96px; height: 18px; margin: -2px auto 2px; }

/* Cash box — keep the warmth, just smaller numbers */
.stat-cash .stat-currency { font-size: 16px; }
.stat-cash .stat-num { font-size: 24px; }

/* State pill (compressor / door) — smaller */
.state-pill {
  padding: 5px 14px; font-size: 12px; margin: 8px 0 4px;
}

/* Appliance grid — compact tap-friendly cards ------------------------- */
.appliance-room { padding: 12px 14px; }
.appliance-room-head { margin-bottom: 10px; }
.appliance-grid { gap: 8px; }
@media (min-width: 1100px) {
  .appliance-grid { grid-template-columns: repeat(8, 1fr); }
}
@media (min-width: 820px) and (max-width: 1099px) {
  .appliance-grid { grid-template-columns: repeat(4, 1fr); }
}
.appliance {
  padding: 10px 6px 8px; gap: 3px;
  border-radius: 10px; border-width: 1.5px;
}
.appliance-icon { width: 38px; height: 38px; }
.appliance-name { font-size: 11.5px; margin-top: 2px; line-height: 1.2; }
.appliance-rating { font-size: 10.5px; }

/* Footer: sliders side-by-side + demo strip full-width ---------------- */
.appliance-foot {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--border);
}
.appliance-foot .slider-row { margin-top: 0; }
.appliance-foot .demo-strip { grid-column: 1 / -1; margin-top: 4px; }
.appliance-foot [data-role="updated"] { grid-column: 1 / -1; margin-top: 0; }
@media (max-width: 640px) {
  .appliance-foot { grid-template-columns: 1fr; }
}
.slider-label { margin-bottom: 4px; font-size: 12px; }

/* Demo strip — compact */
.demo-strip { padding: 6px 10px; gap: 6px; }
.demo-strip .btn.small { padding: 3px 8px; }

/* Appliance toolbar — tighter buttons */
.appliance-toolbar .btn.small { padding: 3px 8px; font-size: 11.5px; }

/* =========================================================================
   v0.13.0 — Atomic-sensor kits installer
   ========================================================================= */
.kit-card { border-color: #bae6fd; background: #f0f9ff; }
.kit-card h3 { margin: 0 0 4px; }
.kit-install-row { display: flex; gap: 8px; align-items: center; }
.kit-select {
  flex: 1; padding: 8px 10px; border: 1.5px solid #7dd3fc;
  border-radius: 6px; font-size: 13.5px; background: #fff;
  font-family: inherit; font-weight: 500;
}
.kit-select:focus {
  outline: none; border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2,132,199,0.15);
}
.kit-details { margin-top: 10px; }
.kit-details summary { padding: 6px 0; cursor: pointer; user-select: none; }
.kit-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px; margin-top: 8px;
}
.kit-tile {
  background: #fff; border: 1px solid #bae6fd; border-radius: 8px;
  padding: 10px 12px;
}
.kit-tile-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 4px;
}
.kit-tile-desc { margin-bottom: 6px; line-height: 1.35; }
.kit-tile-sensors {
  margin: 0; padding-left: 16px; font-size: 11.5px; color: var(--text);
}
.kit-tile-sensors li { margin: 2px 0; }
.kit-tile-sensors .mono { color: #0369a1; }

/* =========================================================================
   v0.14.0 — Project wizard (env picker · slave list · load chips)
   ========================================================================= */

/* Environment tile picker --------------------------------------------- */
.env-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.env-tile {
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 14px; border: 2px solid var(--border); border-radius: 10px;
  background: #fff; color: var(--text); text-decoration: none;
  transition: all 0.15s ease;
}
.env-tile:hover {
  border-color: var(--accent); transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(93,79,255,0.10); text-decoration: none;
}
.env-tile.is-selected {
  border-color: var(--accent);
  background: linear-gradient(180deg, #ffffff 0%, #f5f3ff 100%);
  box-shadow: 0 0 0 1px rgba(93,79,255,0.20),
              0 4px 12px rgba(93,79,255,0.15);
}
.env-tile-icon { font-size: 28px; line-height: 1; }
.env-tile-name { font-weight: 600; font-size: 15px; margin-top: 2px; }
.env-tile-desc { line-height: 1.35; }
.env-tile-meta { margin-top: auto; padding-top: 6px; font-weight: 500; }

/* Wizard sensor rows --------------------------------------------------- */
.wizard-slaves { display: flex; flex-direction: column; gap: 10px; }
.wizard-slave {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; background: #fff;
}
.ws-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
}
.ws-include {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: 14px;
}
.ws-include input[type=checkbox] { width: 18px; height: 18px; cursor: pointer; }
.ws-name { font-weight: 600; }

.ws-meta { display: flex; gap: 10px; align-items: end; }
.ws-meta label { display: flex; flex-direction: column; gap: 2px; }
.ws-sid input { width: 64px; padding: 4px 6px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 4px; text-align: right; }
.ws-label input { width: 220px; padding: 4px 8px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 4px; }
.ws-meta label > span { font-size: 10.5px; letter-spacing: 0.03em; }

.ws-loads { margin-top: 8px; }
.ws-loads summary {
  display: flex; gap: 8px; align-items: center;
  padding: 4px 0; cursor: pointer; user-select: none;
}
.ws-loads summary::-webkit-details-marker { display: none; }
.ws-loads summary::before {
  content: '▸'; transition: transform 0.15s; display: inline-block;
  font-size: 10px; color: var(--muted);
}
.ws-loads[open] summary::before { transform: rotate(90deg); }
.ws-loads-count {
  font-size: 11.5px; font-weight: 600; color: var(--accent);
  background: #ede9fe; padding: 1px 8px; border-radius: 999px;
}
.ws-loads-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px; margin-top: 8px;
}
.ws-load {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: #fafbfd; cursor: pointer; font-size: 12.5px;
  transition: all 0.12s ease;
}
.ws-load input[type=checkbox] { cursor: pointer; }
.ws-load:hover { border-color: #a5b4fc; }
.ws-load.is-on {
  background: linear-gradient(180deg, #ffffff 0%, #dcfce7 100%);
  border-color: #22c55e;
}
.ws-load-name { font-weight: 500; }
.ws-load-kw { color: var(--muted); margin-left: auto; font-size: 11px; }
.ws-noloads { padding: 6px 0 2px; font-style: italic; }

/* =========================================================================
   v0.17.0 — Project-level storylines strip (operator console headline)
   ========================================================================= */
.storyline-strip {
  background: linear-gradient(135deg, #faf5ff 0%, #fdf2f8 100%);
  border: 1.5px solid #d8b4fe;
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 18px;
  box-shadow: 0 2px 8px rgba(168,85,247,0.08);
  transition: all 0.25s ease;
}
.storyline-strip.is-playing {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(93,79,255,0.12),
              0 4px 12px rgba(93,79,255,0.15);
}
.storyline-head {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.storyline-head strong { font-size: 15px; color: #6b21a8; }
.storyline-controls {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.storyline-select {
  flex: 1; min-width: 260px;
  padding: 7px 10px; border: 1px solid #d8b4fe;
  border-radius: 6px; background: #fff;
  font-size: 13px; font-family: inherit; font-weight: 500;
}
.storyline-select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(93,79,255,0.15);
}
.storyline-prog {
  min-width: 90px; text-align: right;
  background: #fff; padding: 4px 10px; border-radius: 4px;
  border: 1px solid #d8b4fe; color: #6b21a8;
}
.storyline-desc {
  margin-top: 8px; padding-left: 4px; font-style: italic;
  min-height: 1.2em;
}
