/* ==========================================================================
   Modbus -> MQTT Gateway  ·  Industrial console UI
   Design goals: high information density, strict grid, colour used only as
   signal, tabular numerals, no dead space.
   ========================================================================== */
:root {
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #eef2f8;
  --bg-2: #e6ecf5;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #edf1f8;
  --border: #e3e9f1;
  --border-2: #ccd6e5;

  --text: #0f172a;
  --text-2: #44536b;
  --muted: #7b8ba1;

  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-700: #1e40af;
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;

  --sidebar: #0b1220;
  --sidebar-2: #0f1930;
  --sidebar-line: rgba(255, 255, 255, .07);
  --sidebar-text: #93a3b8;
  --sidebar-text-hi: #e6edf5;

  --ok: #15803d;   --ok-bg: #ecfdf3;   --ok-line: #b7e6c7;
  --warn: #b45309; --warn-bg: #fffaeb; --warn-line: #f6dfb0;
  --err: #b91c1c;  --err-bg: #fef2f2;  --err-line: #f6c9c9;
  --info: #0369a1; --info-bg: #f0f9ff; --info-line: #bfe3f7;
  --idle: #64748b; --idle-bg: #f1f5f9; --idle-line: #dae2ec;

  --r-lg: 11px;
  --r-md: 8px;
  --r-sm: 6px;

  /* elevation ladder - real, layered, low alpha (never muddy) */
  --shadow-0: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-1: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .035);
  --shadow-2: 0 2px 4px rgba(15, 23, 42, .05), 0 6px 14px -4px rgba(15, 23, 42, .09);
  --shadow-3: 0 10px 28px -8px rgba(15, 23, 42, .16), 0 3px 8px rgba(15, 23, 42, .05);
  --shadow-4: 0 26px 64px -18px rgba(15, 23, 42, .30), 0 6px 16px rgba(15, 23, 42, .07);
  /* focus ring shared by every interactive element */
  --ring: 0 0 0 3px rgba(37, 99, 235, .16);
  --ring-err: 0 0 0 3px rgba(185, 28, 28, .14);

  --sidebar-w: 264px;
  --topbar-h: 54px;
}

/* ----------------------------------------------------------------- reset */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--text);
  background: linear-gradient(180deg, #f7f9fc 0%, #f0f3f9 100%) fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-600); }
h1, h2, h3, h4, h5, h6 { font-weight: 660; letter-spacing: -.012em; }
/* keyboard users get a visible ring, mouse users do not */
a:focus-visible, .sb-link:focus-visible, .sb-search input:focus-visible,
.tbl-filter input:focus-visible, select:focus-visible, button:focus-visible {
  outline: none; box-shadow: var(--ring); border-radius: var(--r-sm);
}
::selection { background: rgba(37, 99, 235, .18); color: var(--text); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c2cddc; border-radius: 20px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; background-clip: content-box; border: 3px solid transparent; }
/* table scrollers get a thinner, quieter rail */
.tbl-wrap::-webkit-scrollbar { height: 9px; width: 9px; }
.tbl-wrap::-webkit-scrollbar-thumb { background: #ccd6e3; border-width: 2px; }

/* ---------------------------------------------------------------- layout */
.shell { display: flex; min-height: 100vh; position: relative; z-index: 1; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.page { padding: 18px 22px 30px; flex: 1; max-width: 1720px; width: 100%; }
.page > .panel { margin-top: 14px; }
.page > .panel:first-child { margin-top: 0; }

/* ---------------------------------------------------------------- sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: var(--sidebar-text);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  border-right: 1px solid rgba(0, 0, 0, .4);
  z-index: 60;
}
.sb-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 15px 12px;
  border-bottom: 1px solid var(--sidebar-line);
}
.sb-logo {
  width: 32px; height: 32px; border-radius: 8px; flex: none;
  display: grid; place-items: center; font-size: 16px; color: #fff;
  background: linear-gradient(135deg, #3b82f6, #1e40af);
  box-shadow: 0 4px 12px rgba(37, 99, 235, .45);
}
.sb-name { color: #fff; font-weight: 650; font-size: 14px; line-height: 1.15; letter-spacing: -.012em; }
.sb-name span { color: #60a5fa; }
.sb-ver { font-size: 9.5px; color: #5b6b80; letter-spacing: .09em; text-transform: uppercase; margin-top: 2px; }

.sb-search { padding: 11px 12px 5px; position: relative; }
.sb-search input {
  width: 100%; padding: 7.5px 10px 7.5px 29px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--sidebar-line);
  border-radius: var(--r-sm);
  color: var(--sidebar-text-hi); font-size: 12.5px; outline: none;
  transition: background .13s, border-color .13s, box-shadow .13s;
}
.sb-search input::placeholder { color: #5b6b80; }
.sb-search input:focus {
  border-color: rgba(96, 165, 250, .55); background: rgba(255, 255, 255, .09);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .16);
}
.sb-search i { position: absolute; left: 22px; top: 19px; font-size: 12px; color: #5b6b80; }

.sb-scroll { flex: 1; overflow-y: auto; padding: 6px 10px 20px; }
.sb-section { margin-top: 13px; }
.sb-section:first-child { margin-top: 3px; }
.sb-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 7px 7px;
  font-size: 9.5px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: #5a6b83;
}
.sb-head a { color: #5a6b83; padding: 1px 5px; border-radius: 4px; font-size: 12px; line-height: 1; transition: background .12s, color .12s; }
.sb-head a:hover { color: #fff; background: rgba(255, 255, 255, .1); }

.sb-link {
  display: flex; align-items: center; gap: 9px;
  padding: 6.5px 9px; border-radius: var(--r-sm);
  color: var(--sidebar-text); font-size: 12.5px; font-weight: 500;
  margin-bottom: 1px; position: relative;
  transition: background .12s, color .12s;
}
.sb-link i { width: 15px; text-align: center; font-size: 13px; opacity: .85; }
.sb-link:hover { background: rgba(255, 255, 255, .07); color: var(--sidebar-text-hi); }
.sb-link.active {
  background: linear-gradient(90deg, rgba(37, 99, 235, .95), rgba(37, 99, 235, .62));
  color: #fff; font-weight: 570;
  box-shadow: 0 2px 10px rgba(37, 99, 235, .34), inset 0 1px 0 rgba(255,255,255,.12);
}
.sb-link.active i { opacity: 1; }
.sb-link.active::before {
  content: ""; position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; background: #60a5fa; border-radius: 0 3px 3px 0;
}
.sb-count {
  margin-left: auto; font-size: 10px; font-weight: 650;
  background: rgba(255, 255, 255, .1); color: #cbd5e1;
  padding: 1px 6px; border-radius: 20px; min-width: 19px; text-align: center;
  font-variant-numeric: tabular-nums;
}

/* tree (details/summary) */
.tree { margin: 1px 0; border-left: 1px solid var(--sidebar-line); padding-left: 8px; margin-left: 8px; }
.tree > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 7px;
  padding: 4.5px 8px; border-radius: var(--r-sm);
  font-size: 12.5px; color: var(--sidebar-text);
}
.tree > summary::-webkit-details-marker { display: none; }
.tree > summary:hover { background: rgba(255, 255, 255, .06); color: var(--sidebar-text-hi); }
.tree > summary .tw { width: 10px; font-size: 9px; transition: transform .15s; color: #46566d; }
.tree[open] > summary .tw { transform: rotate(90deg); }
.tree > summary .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree > summary .uid {
  font-family: var(--mono); font-size: 9.5px; color: #5b6b80;
  border: 1px solid var(--sidebar-line); padding: 0 4px; border-radius: 4px;
  max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: none;
}
.tree-body { padding: 1px 0 3px 13px; }
.tree-leaf {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 8px; border-radius: 5px;
  font-size: 12px; color: #7f8ea3;
}
.tree-leaf:hover { background: rgba(255, 255, 255, .05); color: var(--sidebar-text-hi); }
.tree-leaf i { font-size: 10px; opacity: .7; }
.tree-leaf .ad { margin-left: auto; font-family: var(--mono); font-size: 10px; color: #46566d; }
.tree-empty { font-size: 11.5px; color: #46566d; padding: 3px 8px; }
.tree-empty a { color: #60a5fa; }

.sb-note {
  margin: 4px 7px 0; font-size: 10.5px; color: #46566d;
  line-height: 1.45;
}
.sb-foot {
  padding: 10px 14px; border-top: 1px solid var(--sidebar-line);
  font-size: 10.5px; color: #46566d; display: flex; align-items: center; gap: 6px;
}
.sb-foot .dot { width: 6px; height: 6px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .16); }

/* ---------------------------------------------------------------- topbar */
.topbar {
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; gap: 14px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border-2);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .04);
  padding: 0 22px; position: sticky; top: 0; z-index: 50;
}
.tb-title { font-size: 15px; font-weight: 660; letter-spacing: -.018em; line-height: 1.2; }
.crumb { font-size: 10.5px; color: var(--muted); margin-bottom: 2px; letter-spacing: .03em; }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--primary); }
.crumb i { font-size: 8px; margin: 0 5px; opacity: .55; }

.chips { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 570; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
  box-shadow: var(--shadow-0);
  font-variant-numeric: tabular-nums;
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--idle); flex: none; }
.chip-quiet {
  background: transparent; border-color: transparent; color: var(--muted);
  font-weight: 500; font-size: 10.5px; letter-spacing: .01em; box-shadow: none;
}
.chip.ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.chip.ok .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(21, 128, 61, .14); }
.chip.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.chip.warn .dot { background: var(--warn); box-shadow: 0 0 0 3px rgba(180, 83, 9, .14); }
.chip.err { background: var(--err-bg); border-color: var(--err-line); color: var(--err); }
.chip.err .dot { background: var(--err); box-shadow: 0 0 0 3px rgba(185, 28, 28, .14); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(185, 28, 28, 0); } }

.tb-btn {
  width: 30px; height: 30px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow-0);
}
.tb-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-2); }

.user-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 10px 3px 3px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 12.5px; font-weight: 570; color: var(--text); cursor: pointer;
  box-shadow: var(--shadow-0);
}
.user-btn:hover { background: var(--surface-2); border-color: var(--border-2); }
.avatar {
  width: 25px; height: 25px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 10.5px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #3b82f6, #1e40af);
  box-shadow: 0 1px 3px rgba(30, 64, 175, .4);
}

/* ------------------------------------------------------------- page head */
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.page-title { font-size: 20px; font-weight: 680; letter-spacing: -.022em; margin: 0; }
.page-sub { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.page-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* page level toolbar: description on the left, actions pinned right */
.toolbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255,255,255,.9);
  padding: 12px 16px; margin-bottom: 14px;
  position: relative; overflow: hidden;
}
.toolbar::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--primary) 0%, #60a5fa 100%);
}
.toolbar .tb-txt { font-size: 12.5px; color: var(--text-2); line-height: 1.55; max-width: 92ch; }
.toolbar .tb-txt b { color: var(--text); font-weight: 620; }
.toolbar .tb-act { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
/* toolbar sitting inside a panel: no accent border, becomes a filter strip */
.toolbar.in-panel {
  border: 0; border-bottom: 1px solid var(--border); border-radius: 0;
  box-shadow: none; background: var(--surface-2);
  padding: 9px 14px; margin-bottom: 0;
}

/* ---------------------------------------------------------------- panels */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255, 255, 255, .9);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.panel-head {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 16px; border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff 0%, var(--surface-2) 100%);
  flex: none;
}
.panel-title { font-size: 13px; font-weight: 640; display: flex; align-items: center; gap: 7px; letter-spacing: -.005em; }
.panel-title i { color: var(--primary); font-size: 14px; }
.panel-title .text-muted { font-weight: 450; font-size: 12px; }
.panel-head .spacer { margin-left: auto; }
.panel-body { padding: 16px; flex: 1; }
.panel-body.flush { padding: 0; }
.panel-foot {
  padding: 10px 16px; border-top: 1px solid var(--border);
  background: var(--surface-2); display: flex; align-items: center; gap: 10px;
  font-size: 11.5px; color: var(--muted); flex: none;
}

/* ------------------------------------------------------------------ stat */
.stat-grid {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px; margin-bottom: 14px;
}
.stat-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1279.98px) {
  .stat-grid, .stat-grid.cols-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 767.98px) {
  .stat-grid, .stat-grid.cols-4, .stat-grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 11px 12px;
  display: flex; align-items: flex-start; gap: 10px;
  box-shadow: var(--shadow-0); min-width: 0;
  position: relative; overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: var(--primary); opacity: .0;
}
.stat-ico {
  width: 32px; height: 32px; border-radius: 7px; flex: none;
  display: grid; place-items: center; font-size: 15px;
  background: var(--primary-50); color: var(--primary); border: 1px solid var(--primary-100);
}
.stat-ico.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.stat-ico.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.stat-ico.err { background: var(--err-bg); color: var(--err); border-color: var(--err-line); }
.stat-ico.info { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }
.stat-ico.idle { background: var(--idle-bg); color: var(--idle); border-color: var(--idle-line); }
.stat-body { min-width: 0; }
.stat-val {
  font-size: 19px; font-weight: 700; line-height: 1.1;
  letter-spacing: -.025em; font-variant-numeric: tabular-nums;
}
.stat-val .unit { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.stat-lbl {
  font-size: 10px; color: var(--muted); font-weight: 620;
  letter-spacing: .07em; text-transform: uppercase; margin-top: 3px;
}
.stat-ctx { font-size: 11px; color: var(--muted); margin-top: 5px; line-height: 1.35; }
.stat-ctx.ok { color: var(--ok); }
.stat-ctx.warn { color: var(--warn); }
.stat-ctx.err { color: var(--err); }

/* system banner across the top of the dashboard */
.sysbar {
  display: flex; align-items: center; gap: 0; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  margin-bottom: 14px; overflow: hidden;
}
.sysbar-item {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 16px; flex: 1 1 auto; min-width: 168px;
  border-right: 1px solid var(--border);
}
.sysbar-item:last-child { border-right: 0; }
.sysbar-item i { font-size: 15px; color: var(--muted); }
.sysbar-item .k {
  font-size: 9.5px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}
.sysbar-item .v { font-size: 13px; font-weight: 620; font-variant-numeric: tabular-nums; }
.sysbar-item .v.ok { color: var(--ok); }
.sysbar-item .v.err { color: var(--err); }

/* ------------------------------------------------- dashboard hero + KPIs */
.hero {
  display: flex; align-items: stretch; justify-content: space-between; gap: 0;
  background: linear-gradient(135deg, #ffffff 0%, #fbfdff 55%, #f5f8fd 100%);
  border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255,255,255,.9);
  margin-bottom: 14px; overflow: hidden; flex-wrap: wrap;
}
.hero-status { display: flex; align-items: center; gap: 15px; padding: 18px 22px; flex: 1 1 340px; min-width: 0; }
.hero-dot { width: 13px; height: 13px; border-radius: 50%; flex: none; position: relative; }
.hero-dot::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid currentColor; opacity: .28; }
.hero-dot.ok { background: var(--ok); color: var(--ok); box-shadow: 0 0 0 4px rgba(21, 128, 61, .12); }
.hero-dot.warn { background: var(--warn); color: var(--warn); box-shadow: 0 0 0 4px rgba(180, 83, 9, .12); }
.hero-dot.err { background: var(--err); color: var(--err); box-shadow: 0 0 0 4px rgba(185, 28, 28, .12); }
.hero-dot.idle { background: var(--idle); color: var(--idle); box-shadow: 0 0 0 4px rgba(100, 116, 139, .12); }
.hero-title { font-size: 16.5px; font-weight: 700; letter-spacing: -.015em; line-height: 1.15; }
.hero-title.ok { color: var(--ok); } .hero-title.warn { color: var(--warn); } .hero-title.err { color: var(--err); }
.hero-sub { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.35; }
.hero-sub b { color: var(--text-2); font-weight: 600; }
.hero-metrics { display: flex; align-items: stretch; flex-wrap: wrap; }
.hero-m { padding: 16px 22px; border-left: 1px solid var(--border); text-align: right; min-width: 118px; display: flex; flex-direction: column; justify-content: center; background: rgba(255,255,255,.5); }
.hero-m .k { font-size: 9.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.hero-m .v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; margin-top: 3px; line-height: 1; }
.hero-m .v .unit { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.hero-m .v.ok { color: var(--ok); } .hero-m .v.err { color: var(--err); }

.kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
@media (max-width: 1279.98px) { .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 767.98px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi {
  position: relative; overflow: hidden; min-width: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255,255,255,.9);
  padding: 15px 15px 14px; padding-top: 17px;
  transition: box-shadow .15s, transform .15s;
}
.kpi:hover { box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255,255,255,.9); transform: translateY(-1px); }
.kpi::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--border-2); }
.kpi.ok::before { background: linear-gradient(90deg, var(--ok), #4ade80); }
.kpi.warn::before { background: linear-gradient(90deg, var(--warn), #fbbf24); }
.kpi.err::before { background: linear-gradient(90deg, var(--err), #f87171); }
.kpi.idle::before { background: linear-gradient(90deg, var(--idle), #94a3b8); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.kpi-top i { font-size: 15px; color: var(--muted); opacity: .75; line-height: 1; }
.kpi-lbl { font-size: 9.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.kpi-val { font-size: 24px; font-weight: 700; line-height: 1; letter-spacing: -.028em; font-variant-numeric: tabular-nums; }
.kpi-val .unit { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.kpi-ctx { font-size: 11px; color: var(--muted); margin-top: 7px; line-height: 1.3; }
.kpi-ctx.ok { color: var(--ok); } .kpi-ctx.warn { color: var(--warn); } .kpi-ctx.err { color: var(--err); }

/* tunnel list: keep a long error readable without blowing out the column */
.pill.tunnel-err { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; }

/* ---------------------------------------------------------------- tables */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl thead th {
  text-align: left; padding: 9px 16px;
  font-size: 9.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); background: var(--surface-2);
  border-bottom: 1px solid var(--border-2); white-space: nowrap;
}
table.tbl tbody td {
  padding: 10px 16px; border-bottom: 1px solid #eef1f6;
  vertical-align: middle; transition: background .1s;
}
table.tbl tbody tr:nth-child(even) td { background: #fafbfd; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover td { background: var(--primary-50); }
table.tbl tbody tr:hover .row-actions { opacity: 1; }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12px; }
table.tbl .mono, .mono { font-family: var(--mono); font-size: 12px; }
table.tbl a { font-weight: 570; }
table.tbl a:hover { text-decoration: underline; text-underline-offset: 2px; }
.row-actions { display: flex; gap: 5px; justify-content: flex-end; opacity: .5; transition: opacity .13s; }
.cell-main { font-weight: 570; letter-spacing: -.004em; }
.cell-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* empty states: an icon badge reads as a designed placeholder, not a blank row */
.empty {
  text-align: center; color: var(--muted);
  padding: 42px 24px 44px;
  font-size: 12.5px; line-height: 1.6;
}
.empty i {
  display: grid; place-items: center;
  width: 46px; height: 46px; border-radius: 13px;
  margin: 0 auto 14px; font-size: 19px; line-height: 1;
  color: var(--primary);
  background: var(--primary-50); border: 1px solid var(--primary-100);
  box-shadow: 0 3px 10px -2px rgba(37, 99, 235, .18);
}
.empty-title {
  font-size: 13.5px; font-weight: 640; color: var(--text);
  letter-spacing: -.008em; margin-bottom: 5px;
}
.empty-text { font-size: 12.5px; color: var(--muted); max-width: 46ch; margin: 0 auto; line-height: 1.6; }
.empty .btn { margin-top: 16px; }
.empty.sm { padding: 26px 16px 28px; }
.empty.sm i { width: 36px; height: 36px; border-radius: 10px; font-size: 15px; margin-bottom: 10px; }
.empty.sm .empty-title { font-size: 12.5px; }
/* transient state - the badge breathes instead of sitting dead */
.empty.loading i { animation: emptyPulse 1.5s ease-in-out infinite; }
@keyframes emptyPulse {
  0%, 100% { opacity: .5; transform: scale(.96); }
  50%      { opacity: 1;  transform: scale(1); }
}

/* ---------------------------------------------------------------- pills */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2.5px 9px; border-radius: 20px;
  font-size: 10.5px; font-weight: 620; white-space: nowrap;
  background: var(--idle-bg); border: 1px solid var(--idle-line); color: var(--idle);
  font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 1px rgba(15, 23, 42, .04);
}
.pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .9; flex: none; }
.pill.plain::before { display: none; }
.pill.ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.pill.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.pill.err { background: var(--err-bg); border-color: var(--err-line); color: var(--err); }
.pill.info { background: var(--info-bg); border-color: var(--info-line); color: var(--info); }
.pill.dark { background: #0f172a; border-color: #0f172a; color: #fff; }
.pill.dark::before { display: none; }
.pill.light { background: var(--surface-2); border-color: var(--border); color: var(--text-2); }
.pill.light::before { display: none; }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 13px; border-radius: var(--r-sm);
  font-size: 12.5px; font-weight: 570; font-family: inherit;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: background .13s, border-color .13s, color .13s, box-shadow .13s, transform .08s;
}
.btn:active { transform: translateY(.5px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary {
  background: var(--primary);
  color: #fff; border-color: var(--primary);
  box-shadow: 0 1px 2px rgba(30, 64, 175, .3);
}
.btn-primary:hover {
  color: #fff; border-color: var(--primary-600);
  background: var(--primary-600);
  box-shadow: 0 3px 10px -2px rgba(30, 64, 175, .42);
}
.btn-dark {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%); color: #fff;
  border-color: #0b1220;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .22), inset 0 1px 0 rgba(255, 255, 255, .08);
}
.btn-dark:hover { background: linear-gradient(180deg, #263449 0%, #16213a 100%); color: #fff; }
.btn-outline {
  background: var(--surface); border-color: var(--border-2); color: var(--text-2);
  box-shadow: var(--shadow-0);
}
.btn-outline:hover {
  background: var(--surface-2); color: var(--text); border-color: #b9c5d8;
  box-shadow: var(--shadow-1);
}
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger {
  background: #dc2626; color: #fff;
  border-color: #dc2626;
  box-shadow: 0 1px 2px rgba(153, 27, 27, .28);
}
.btn-danger:hover { background: var(--err); color: #fff; border-color: var(--err); box-shadow: 0 3px 10px -2px rgba(153, 27, 27, .4); }
.btn-danger-o {
  background: var(--surface); border-color: #f0c9c9; color: var(--err);
  box-shadow: var(--shadow-0);
}
.btn-danger-o:hover { background: var(--err-bg); border-color: #e6a9a9; }
.btn-sm { padding: 4.5px 9px; font-size: 11.5px; gap: 5px; border-radius: var(--r-sm); }
.btn-lg { padding: 10px 18px; font-size: 13.5px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }
/* compact icon-only button used in table rows */
.btn-ico {
  width: 28px; height: 28px; padding: 0; border-radius: var(--r-sm);
  display: inline-grid; place-items: center; font-size: 13px;
}

/* ----------------------------------------------------------------- forms */
.form-label {
  display: block; font-size: 10px; font-weight: 700;
  color: var(--text-2); margin-bottom: 5px; letter-spacing: .08em; text-transform: uppercase;
}
.form-label .req { color: var(--err); }
.form-control, .form-select {
  width: 100%; padding: 8px 11px;
  font-size: 13px; font-family: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r-sm); outline: none;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, .03);
  transition: border-color .13s, box-shadow .13s;
}
.form-control:hover, .form-select:hover { border-color: #b9c5d8; }
.form-control:focus, .form-select:focus {
  border-color: var(--primary); box-shadow: var(--ring), inset 0 1px 2px rgba(15,23,42,.02);
}
.form-control::placeholder { color: #a5b4c8; }
/* native select arrow is the single most "basic web app" tell - replace it */
.form-select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%237b8ba1' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.5 8 10.5 12 6.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 15px;
}
.form-select:focus {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%232563eb' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.5 8 10.5 12 6.5'/%3E%3C/svg%3E");
}
.form-select option { color: var(--text); background: #fff; }
.form-control.mono, .form-select.mono { font-family: var(--mono); font-size: 12.5px; }
.form-control-sm { padding: 5px 9px; font-size: 12px; }
/* number spinners are noise on a control face */
.form-control[type=number]::-webkit-outer-spin-button,
.form-control[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.form-control[type=number] { -moz-appearance: textfield; appearance: textfield; }
.form-text { font-size: 11px; color: var(--muted); margin-top: 5px; line-height: 1.45; }
.form-text code { background: var(--surface-3); padding: 1px 4px; border-radius: 4px; font-size: 10.5px; }
.input-group { display: flex; }
.input-group .input-group-text {
  display: grid; place-items: center; padding: 0 11px;
  background: var(--surface-2); border: 1px solid var(--border-2);
  color: var(--muted); font-size: 13px; border-radius: var(--r-sm) 0 0 var(--r-sm); border-right: 0;
}
.input-group .form-control { border-radius: 0 var(--r-sm) var(--r-sm) 0; }

/* grid: cols stretch so paired panels never leave a hole */
.row { display: flex; flex-wrap: wrap; margin: 0 -7px; align-items: stretch; }
.row > * { padding: 0 7px; margin-bottom: 14px; display: flex; flex-direction: column; }
/* only the bottom panel of a column grows: panel edges stay aligned across columns */
.row > * > .panel { flex: 0 0 auto; min-width: 0; }
.row > * > .panel:last-child { flex: 1 1 auto; }
/* 2-up panel grid: because both rows are shared, the seam between panels lines
   up across the two columns (flex columns can never guarantee that). */
.pgrid {
  display: grid;
  grid-template-columns: minmax(0, 8fr) minmax(0, 4fr);
  gap: 14px;
}
.pgrid > .panel { min-width: 0; }
.g-2 > * { margin-bottom: 8px; }
.g-3 > * { margin-bottom: 14px; }
/* rows that live *inside* a panel body: no extra bottom gap */
.row.tight > * { margin-bottom: 0; }
.col-1 { width: 8.33%; } .col-2 { width: 16.66%; } .col-3 { width: 25%; }
.col-4 { width: 33.33%; } .col-5 { width: 41.66%; } .col-6 { width: 50%; }
.col-7 { width: 58.33%; } .col-8 { width: 66.66%; } .col-9 { width: 75%; }
.col-12 { width: 100%; }
@media (min-width: 900px) {
  .sm-4 { width: 33.33%; } .sm-6 { width: 50%; } .sm-8 { width: 66.66%; }
}
.divider { border: 0; border-top: 1px solid var(--border); margin: 16px 0 13px; }
.sec-title {
  font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 10px; display: flex; align-items: center; gap: 8px;
}
.sec-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { display: none; }
.switch .track {
  width: 34px; height: 19px; border-radius: 20px; flex: none;
  background: var(--border-2); position: relative; transition: background .15s;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 15px; height: 15px; border-radius: 50%; background: #fff;
  transition: transform .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(15px); }
.switch .lbl { font-size: 12.5px; font-weight: 560; color: var(--text-2); }
.switch .lbl small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }

.test-output {
  font-size: 11.5px; min-height: 16px; line-height: 1.5;
  padding: 8px 10px; border-radius: var(--r-sm); margin-top: 10px;
  background: var(--surface-2); border: 1px dashed var(--border-2); color: var(--muted);
  font-family: var(--mono);
}
.test-output.ok { background: var(--ok-bg); border: 1px solid var(--ok-line); color: var(--ok); font-family: var(--font); }
.test-output.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn); font-family: var(--font); }
.test-output.fail { background: var(--err-bg); border: 1px solid var(--err-line); color: var(--err); font-family: var(--font); }
/* no dangling empty dashed box before the user runs a test */
.test-output:empty { display: none; }

/* ------------------------------------------------------------- tag picker */
.tag-picker { max-height: 540px; overflow: auto; padding: 4px 8px 8px; }
.picker-group {
  position: sticky; top: 0; z-index: 2;
  padding: 8px 8px 5px; margin-top: 4px;
  background: var(--surface-2); border-radius: var(--r-sm);
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-2); display: flex; align-items: center; gap: 7px;
}
.picker-item {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 9px; border-radius: var(--r-sm); cursor: pointer; margin: 2px 0;
  border: 1px solid transparent;
}
.picker-item:hover { background: var(--primary-50); border-color: var(--primary-100); }
.picker-item input[type=checkbox] { accent-color: var(--primary); width: 15px; height: 15px; }
.picker-item.on { background: var(--primary-50); border-color: var(--primary-100); }
.picker-name { font-size: 13px; font-weight: 560; }
.picker-meta { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.picker-item .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.preview-box {
  margin: 0; background: #0b1220; color: #cbd5e1;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.65;
  padding: 12px; border-radius: var(--r-md);
  white-space: pre-wrap; word-break: break-word; max-height: 280px; overflow: auto;
}

/* ---------------------------------------------------------------- alerts */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; border-radius: var(--r-md);
  font-size: 12.5px; margin-bottom: 14px; border: 1px solid;
  box-shadow: var(--shadow-0);
}
.alert > i {
  font-size: 15px; margin-top: 1px; flex: none;
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px;
  background: currentColor;
}
.alert > i::before { color: #fff; }
.alert span { padding-top: 1px; }
.alert-success { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.alert-danger { background: var(--err-bg); border-color: var(--err-line); color: var(--err); }
.alert-warning { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.alert-info { background: var(--info-bg); border-color: var(--info-line); color: var(--info); }
.alert .x { margin-left: auto; cursor: pointer; opacity: .5; background: none; border: 0; padding: 0; flex: none; }
.alert .x:hover { opacity: 1; }

/* ----------------------------------------------------------------- login */
.guest { min-height: 100vh; position: relative; z-index: 1; }
.login {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr;
  position: relative; z-index: 1;
  background:
    radial-gradient(900px 430px at 76% -4%, rgba(37, 99, 235, .08), transparent 62%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}
.login-side {
  position: relative; color: #fff; padding: 46px;
  display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(1000px 500px at 15% 10%, rgba(59, 130, 246, .35), transparent 60%),
    linear-gradient(150deg, #0b1220 0%, #101a2c 55%, #1e3a8a 130%);
  overflow: hidden;
  box-shadow: inset -1px 0 0 rgba(255,255,255,.06);
}
.login-side::after {
  content: ""; position: absolute; inset: 0; opacity: .5;
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 44px 44px;
}
.login-side > * { position: relative; z-index: 1; }
.ls-brand { display: flex; align-items: center; gap: 12px; }
.ls-logo {
  width: 42px; height: 42px; border-radius: 11px;
  display: grid; place-items: center; font-size: 21px; color: #fff;
  background: linear-gradient(135deg, #3b82f6, #1e40af);
  box-shadow: 0 8px 22px rgba(37, 99, 235, .5), inset 0 1px 0 rgba(255,255,255,.2);
}
.ls-name { font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.ls-tag { font-size: 11px; color: #93a3b8; letter-spacing: .1em; text-transform: uppercase; margin-top: 2px; }
.ls-h { font-size: 27px; font-weight: 700; line-height: 1.25; letter-spacing: -.028em; margin: 0 0 10px; }
.ls-p { font-size: 13.5px; color: #a9b8cc; line-height: 1.65; margin: 0; max-width: 430px; }
.ls-feats { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 10px; }
.ls-feats li {
  display: flex; align-items: center; gap: 10px; font-size: 13px; color: #c4d2e3;
  padding: 8px 11px; border-radius: 9px;
  background: rgba(255, 255, 255, .035);
  border: 1px solid rgba(255, 255, 255, .06);
}
.ls-feats i {
  width: 22px; height: 22px; border-radius: 6px; flex: none; display: grid; place-items: center;
  font-size: 11px; background: rgba(96, 165, 250, .18); color: #93c5fd;
}
.ls-foot { font-size: 11.5px; color: #64748b; }

.login-form { display: grid; place-items: center; padding: 40px; }
.lf-box {
  width: 100%; max-width: 392px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 30px 30px 26px;
  box-shadow: var(--shadow-3), inset 0 1px 0 rgba(255, 255, 255, .9);
}
.lf-h { font-size: 22px; font-weight: 700; letter-spacing: -.022em; margin: 0 0 5px; }
.lf-p { font-size: 13px; color: var(--muted); margin: 0 0 24px; }
.lf-field { margin-bottom: 15px; }
.lf-box .btn-lg { margin-top: 6px; }
.lf-note {
  margin-top: 22px; padding: 11px 13px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 11.5px; color: var(--muted); line-height: 1.55;
}
.lf-note b { color: var(--text-2); }

/* ----------------------------------------------------------------- misc */
.kbd {
  font-family: var(--mono); font-size: 11px;
  background: var(--surface-3); border: 1px solid var(--border-2);
  padding: 1px 5px; border-radius: 4px; color: var(--text-2);
}
.hint-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.hint-list li { display: flex; gap: 9px; line-height: 1.55; }
.hint-list i { color: var(--primary); margin-top: 3px; font-size: 10px; flex: none; }
.kv { display: grid; gap: 11px; }
.kv-row { display: flex; align-items: baseline; gap: 10px; }
.kv-k {
  font-size: 10px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); min-width: 104px;
}
.kv-v { font-size: 13px; font-weight: 560; font-variant-numeric: tabular-nums; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 14px; }
.ml-auto { margin-left: auto; }
.d-flex { display: flex; } .items-center { align-items: center; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.wrap { flex-wrap: wrap; }
.text-ok { color: var(--ok); } .text-err { color: var(--err); }
.text-warn { color: var(--warn); } .text-muted { color: var(--muted) !important; }
.val-ok { color: var(--ok); font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; }
.val-err { color: var(--err); font-family: var(--mono); }

/* inline table filter */
.tbl-filter { position: relative; }
.tbl-filter input {
  padding: 6px 10px 6px 28px; font-size: 12.5px; min-width: 190px;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-sm);
  outline: none; color: var(--text);
}
.tbl-filter input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .13); }
.tbl-filter i { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--muted); }

.footer {
  padding: 11px 20px; border-top: 1px solid var(--border);
  background: var(--surface); font-size: 11px; color: var(--muted);
  display: flex; align-items: center; gap: 12px;
}
.footer .sep { width: 1px; height: 11px; background: var(--border-2); }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1099.98px) {
  .login { grid-template-columns: 1fr; }
  .login-side { display: none; }
}
/* --------------------------------------------------- SCADA write audit log */
.wlog { display: flex; flex-direction: column; gap: 2px; }
.wlog-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; font-size: 12px; border-radius: var(--r-sm);
  border: 1px solid transparent; flex-wrap: wrap;
}
.wlog-row:nth-child(odd) { background: var(--surface-2); }
.wlog-ts { color: var(--muted); font-size: 11px; flex: 0 0 auto; }
.wlog-addr { color: var(--text-2); flex: 0 0 auto; }
.wlog-val {
  font-weight: 640; font-variant-numeric: tabular-nums;
  flex: 0 0 auto; min-width: 52px;
}
.wlog-arrow { color: var(--muted); font-size: 11px; flex: 0 0 auto; }
.wlog-src { font-size: 12px; flex: 1 1 auto; min-width: 0; }
.wlog-src a { font-weight: 620; }
.wlog-src .text-muted { font-size: 11px; margin-left: 5px; }
.wlog-row .pill { margin-left: auto; }
.wlog-why {
  margin-left: auto; font-size: 11px; color: var(--err);
  background: var(--err-bg); border: 1px solid var(--err-line);
  border-radius: 999px; padding: 2px 9px; white-space: nowrap;
}
.wlog-row.failed .wlog-val,
.wlog-row.failed .wlog-addr { text-decoration: line-through; color: var(--muted); }

@media (max-width: 991.98px) {
  /* sidebar stays docked on the left on every screen size */
  .sidebar {
    position: sticky;
    width: 224px;
    flex: 0 0 224px;
    transform: none;
    box-shadow: none;
  }
  .sb-name { font-size: 13px; }
  .pgrid { grid-template-columns: minmax(0, 1fr); }
  .page { padding: 14px 13px 26px; }
  .topbar { padding: 0 13px; gap: 10px; position: sticky; top: 0; }
  .chips .chip.hide-sm { display: none; }
}
/* forms: never let a 12-col fraction squeeze a select/input on a phone */
@media (max-width: 767.98px) {
  .row > [class*="col-"],
  .row > .sm-4, .row > .sm-6, .row > .sm-8 { width: 100%; }
  .page-title { font-size: 18px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .tb-act { margin-left: 0; }
  .sysbar-item { border-right: 0; border-bottom: 1px solid var(--border); min-width: 0; }
  .sysbar-item:last-child { border-bottom: 0; }
  .panel-head { flex-wrap: wrap; }
  .tbl-filter input { min-width: 0; width: 100%; }
}

/* ==========================================================================
   ARCHETYPES — each page type gets its own structural design.
   A. .arch-dash    mission control + live data-pipeline diagram
   B. .arch-catalog entity card catalogue (networks, gateways, servers)
   C. .arch-entity  entity detail page with identity header + fact strip
   D. .arch-editor  two column editor with a sticky context rail
   E. .arch-monitor live monitor with a filter rail
   F. .arch-flow    tunnel bridges drawn as source -> destination chains
   ========================================================================== */

/* shared: archetype page scaffolding
   NOTE: base.html already renders <main class="page">, so archetype pages must
   NOT add another .page wrapper - the outer main owns the gutters. */
.arch { padding: 0 0 30px; }
.arch-wrap { padding: 0; }
.arch-head {
  display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap;
  padding: 4px 0 16px;
}
.arch-eyebrow {
  font-size: 9.5px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase;
  color: var(--primary); display: flex; align-items: center; gap: 7px; margin-bottom: 7px;
}
.arch-eyebrow::before {
  content: ""; width: 16px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
}
.arch-h1 {
  font-size: 25px; font-weight: 720; letter-spacing: -.032em; line-height: 1.1;
  margin: 0; color: var(--text);
}
.arch-lede { font-size: 13px; color: var(--text-2); margin-top: 6px; max-width: 78ch; line-height: 1.55; }
.arch-head-actions { margin-left: auto; display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.arch-head-actions .btn { padding: 8px 15px; }

/* ---------------------------------------------------- A. mission control */
.mc {
  border-radius: var(--r-lg); overflow: hidden; margin-bottom: 16px;
  border: 1px solid var(--border);
  background:
    radial-gradient(760px 260px at 90% -40%, rgba(37, 99, 235, .06), transparent 64%),
    linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
  box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255, 255, 255, .8);
  color: var(--text);
  position: relative;
}
.mc > * { position: relative; z-index: 1; }
.mc-top { display: flex; align-items: flex-start; gap: 22px; padding: 22px 24px 20px; flex-wrap: wrap; }
.mc-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 12px 4px 9px; border-radius: 20px; margin-bottom: 11px;
  font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  background: var(--idle-bg); border: 1px solid var(--idle-line); color: var(--text-2);
}
.mc-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--idle); flex: none; }
.mc-badge.ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.mc-badge.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.mc-badge.err { background: var(--err-bg); border-color: var(--err-line); color: var(--err); }
.mc-badge.ok .dot { background: var(--ok); box-shadow: 0 0 0 4px rgba(21, 128, 61, .14); animation: mcPulse 2.4s infinite; }
.mc-badge.warn .dot { background: var(--warn); box-shadow: 0 0 0 4px rgba(180, 83, 9, .14); animation: mcPulse 2.4s infinite; }
.mc-badge.err .dot { background: var(--err); box-shadow: 0 0 0 4px rgba(185, 28, 28, .16); animation: mcPulse 1.4s infinite; }
@keyframes mcPulse { 50% { opacity: .45; } }
.mc-title { font-size: 24px; font-weight: 700; letter-spacing: -.03em; line-height: 1.12; margin: 0; color: var(--text); }
.mc-title.ok { color: var(--ok); } .mc-title.warn { color: var(--warn); } .mc-title.err { color: var(--err); }
.mc-sub { font-size: 12.5px; color: var(--text-2); margin-top: 7px; line-height: 1.55; max-width: 62ch; }
.mc-sub b { color: var(--text); font-weight: 620; }
.mc-gauge { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }
.gauge {
  min-width: 124px; padding: 11px 14px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.gauge .k {
  font-size: 9px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.gauge .v {
  font-size: 21px; font-weight: 700; color: var(--text); margin-top: 4px;
  font-variant-numeric: tabular-nums; letter-spacing: -.025em; line-height: 1;
}
.gauge .v .unit { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-left: 3px; }
.gauge .v.ok { color: var(--ok); } .gauge .v.warn { color: var(--warn); } .gauge .v.err { color: var(--err); }
.gauge .ctx { font-size: 10.5px; color: var(--muted); margin-top: 5px; }

/* live cycle meter */
.cyc { margin-top: 9px; }
.cyc-bar {
  height: 3px; border-radius: 3px; background: var(--surface-3); overflow: hidden; position: relative;
}
.cyc-bar i {
  position: absolute; inset: 0 auto 0 0; width: 0%;
  background: var(--primary);
  border-radius: 3px; transition: width .4s linear;
}
.cyc-lbl {
  display: flex; justify-content: space-between; font-size: 9.5px; color: var(--muted);
  letter-spacing: .08em; text-transform: uppercase; font-weight: 650; margin-bottom: 5px;
}

/* ------------------------------------------------- pipeline diagram */
.flow {
  display: grid; grid-template-columns: 1fr 26px 1fr 26px 1fr 26px 1fr;
  align-items: stretch; gap: 0;
  padding: 0 24px 22px;
}
.flow-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.flow-col-lbl {
  font-size: 9px; font-weight: 750; letter-spacing: .15em; text-transform: uppercase;
  color: #6f84a3; margin-bottom: 2px; padding-left: 2px;
}
.flow-node {
  background: rgba(255, 255, 255, .055); border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 10px; padding: 10px 12px; position: relative; overflow: hidden;
  transition: background .15s, border-color .15s;
}
.flow-node:hover { background: rgba(255, 255, 255, .085); border-color: rgba(255, 255, 255, .18); }
.flow-node::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2.5px;
  background: var(--idle); opacity: .8;
}
.flow-node.ok::before { background: #34d399; }
.flow-node.warn::before { background: #fbbf24; }
.flow-node.err::before { background: #f87171; }
.flow-node.info::before { background: #60a5fa; }
.flow-node .n-lbl {
  font-size: 9.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #8397b4;
  display: flex; align-items: center; gap: 6px;
}
.flow-node .n-lbl i { font-size: 11px; opacity: .9; }
.flow-node .n-val {
  font-size: 17px; font-weight: 700; color: #fff; margin-top: 4px;
  font-variant-numeric: tabular-nums; letter-spacing: -.022em; line-height: 1.1;
}
.flow-node .n-val .unit { font-size: 11px; font-weight: 600; color: #8397b4; letter-spacing: 0; margin-left: 2px; }
.flow-node .n-sub {
  font-size: 10.5px; color: #8397b4; margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.flow-node .n-sub.mono { font-family: var(--mono); font-size: 10px; }
.flow-arrow {
  display: grid; place-items: center; position: relative; padding-top: 26px;
}
.flow-arrow::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1.5px;
  background: repeating-linear-gradient(90deg, rgba(96, 165, 250, .5) 0 5px, transparent 5px 10px);
  background-size: 10px 1.5px;
  animation: flowDash 1.1s linear infinite;
}
@keyframes flowDash { to { background-position: 10px 0; } }
.flow-arrow::after {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: #60a5fa; box-shadow: 0 0 8px rgba(96, 165, 250, .8);
  position: relative; z-index: 1;
}
.flow-arrow.dead::before { background: repeating-linear-gradient(90deg, rgba(248,113,113,.45) 0 5px, transparent 5px 10px); background-size: 10px 1.5px; animation: none; }
.flow-arrow.dead::after { background: #f87171; box-shadow: none; }
.flow-arrow span {
  position: absolute; bottom: 12px; font-size: 9px; letter-spacing: .1em;
  text-transform: uppercase; color: #5f7494; font-weight: 700; white-space: nowrap;
}

/* telemetry + attention */
.mc-cols { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 14px; padding: 0 24px 22px; }
.mc-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
}
.mc-card-h {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  border-bottom: 1px solid var(--border); background: rgba(255, 255, 255, .6);
  font-size: 9.5px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; color: var(--text-2);
}
.mc-card-h i { font-size: 12px; color: var(--primary); }
.mc-card-h .spacer { margin-left: auto; }
.mc-card-b { padding: 12px 14px; }
.tel {
  display: grid; grid-template-columns: 128px 1fr 74px; gap: 12px; align-items: center;
  padding: 7px 0;
}
.tel + .tel { border-top: 1px solid rgba(255, 255, 255, .055); }
.tel .t-lbl { font-size: 11.5px; color: #a5b6cd; }
.tel .t-track { height: 5px; border-radius: 4px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.tel .t-track i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #38bdf8, #60a5fa); transition: width .5s ease; }
.tel .t-track i.ok { background: linear-gradient(90deg, #10b981, #34d399); }
.tel .t-track i.warn { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.tel .t-track i.err { background: linear-gradient(90deg, #dc2626, #f87171); }
.tel .t-val { font-size: 12.5px; font-weight: 650; color: #fff; text-align: right; font-variant-numeric: tabular-nums; }
.tel .t-val.ok { color: #6ee7b7; } .tel .t-val.warn { color: #fcd34d; } .tel .t-val.err { color: #fca5a5; }

/* attention list */
.att { display: flex; flex-direction: column; }
.att-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .055); font-size: 12px; color: #b9c8dc; line-height: 1.45;
}
.att-item:last-child { border-bottom: 0; }
.att-ic {
  width: 20px; height: 20px; border-radius: 6px; flex: none; display: grid; place-items: center;
  font-size: 11px; background: rgba(148, 163, 184, .16); color: #cbd5e1; margin-top: 1px;
}
.att-item.err .att-ic { background: rgba(248, 113, 113, .18); color: #fca5a5; }
.att-item.warn .att-ic { background: rgba(251, 191, 36, .18); color: #fcd34d; }
.att-item.ok .att-ic { background: rgba(52, 211, 153, .18); color: #6ee7b7; }
.att-item b { color: #fff; font-weight: 620; }
.att-item .att-act { margin-left: auto; flex: none; }
.att-item .att-act a {
  font-size: 10.5px; font-weight: 650; letter-spacing: .04em; padding: 3px 9px;
  border-radius: 20px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .12);
  color: #cbd9ec; white-space: nowrap;
}
.att-item .att-act a:hover { background: rgba(255, 255, 255, .16); color: #fff; }
.att-empty { padding: 22px 14px; text-align: center; font-size: 12px; color: #7f93b0; }
.att-empty i { font-size: 20px; opacity: .5; display: block; margin-bottom: 7px; color: #6ee7b7; }

/* activity feed */
.feed { max-height: 340px; overflow-y: auto; }
.feed-item {
  display: grid; grid-template-columns: 62px 22px 1fr auto; gap: 10px; align-items: baseline;
  padding: 7px 14px; border-bottom: 1px solid rgba(255, 255, 255, .05); font-size: 12px;
}
.feed-item:last-child { border-bottom: 0; }
.feed-item .f-ts { font-family: var(--mono); font-size: 10.5px; color: #6f84a3; }
.feed-item .f-ic { font-size: 11px; color: #60a5fa; text-align: center; }
.feed-item .f-txt { color: #b9c8dc; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-item .f-txt b { color: #fff; font-weight: 600; }
.feed-item .f-val { font-family: var(--mono); font-size: 11.5px; color: #6ee7b7; font-weight: 600; }
.feed-item .f-val.err { color: #fca5a5; }
/* light variant - the same stream rendered on a white panel */
.feed.light { background: var(--surface); max-height: 430px; }
.feed.light .feed-item { border-bottom-color: var(--border); }
.feed.light .feed-item:hover { background: var(--surface-2); }
.feed.light .f-ts { color: var(--muted); }
.feed.light .f-ic { color: var(--primary); }
.feed.light .f-txt { color: var(--text-2); }
.feed.light .f-txt b { color: var(--text); }
.feed.light .f-val { color: var(--ok); }
.feed.light .f-val.err { color: var(--err); }

/* ------------------------------------------------------- B. catalogue */
.cat-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255, 255, 255, .9);
}
.cat-bar .cat-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cat-bar .cat-count b { color: var(--text); font-weight: 660; font-size: 13px; }
.cat-bar .spacer { margin-left: auto; }
.cat-search { position: relative; }
.cat-search i {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: 12px; color: var(--muted); pointer-events: none;
}
.cat-search input {
  width: 230px; padding: 7px 10px 7px 29px; font-size: 12.5px; font-family: inherit;
  background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--r-sm);
  outline: none; transition: border-color .13s, box-shadow .13s, width .15s;
}
.cat-search input:focus { border-color: var(--primary); box-shadow: var(--ring); background: #fff; width: 260px; }

.catalog {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(324px, 1fr)); gap: 14px;
}
.cat-card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255, 255, 255, .9);
  overflow: hidden; transition: box-shadow .16s, transform .16s, border-color .16s;
}
.cat-card:hover { box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255, 255, 255, .9); transform: translateY(-2px); border-color: var(--border-2); }
.cat-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--cat-accent, var(--border-2));
}
.cat-card.t-net { --cat-accent: linear-gradient(90deg, #0ea5e9, #38bdf8); --cat-tint: #e0f2fe; --cat-ink: #0369a1; }
.cat-card.t-gw { --cat-accent: linear-gradient(90deg, #7c3aed, #a78bfa); --cat-tint: #ede9fe; --cat-ink: #6d28d9; }
.cat-card.t-srv { --cat-accent: linear-gradient(90deg, #059669, #34d399); --cat-tint: #d1fae5; --cat-ink: #047857; }
.cat-card.t-tun { --cat-accent: linear-gradient(90deg, #d97706, #fbbf24); --cat-tint: #fef3c7; --cat-ink: #b45309; }
.cat-head { display: flex; gap: 11px; padding: 15px 16px 12px; align-items: flex-start; }
.cat-av {
  width: 38px; height: 38px; border-radius: 10px; flex: none; display: grid; place-items: center;
  font-size: 16px; background: var(--cat-tint, var(--surface-3)); color: var(--cat-ink, var(--text-2));
  border: 1px solid rgba(0, 0, 0, .05);
}
.cat-id { min-width: 0; flex: 1; }
.cat-name {
  font-size: 14px; font-weight: 650; letter-spacing: -.012em; color: var(--text);
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cat-name:hover { color: var(--primary); }
.cat-sub {
  font-size: 11.5px; color: var(--muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cat-sub.mono { font-family: var(--mono); font-size: 11px; }
.cat-body { padding: 0 16px 12px; flex: 1; }
.cat-facts { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-fact {
  display: inline-flex; align-items: center; gap: 5px; padding: 2.5px 8px;
  border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border);
  font-size: 10.5px; color: var(--text-2); font-weight: 550;
}
.cat-fact b { font-weight: 680; color: var(--text); font-variant-numeric: tabular-nums; }
.cat-fact i { font-size: 10px; color: var(--muted); }
.cat-foot {
  display: flex; align-items: center; gap: 8px; padding: 9px 16px;
  border-top: 1px solid var(--border); background: var(--surface-2);
}
.cat-foot .pill { font-size: 10px; }
.cat-actions {
  margin-left: auto; display: flex; gap: 4px; opacity: 0; transition: opacity .14s;
}
.cat-card:hover .cat-actions { opacity: 1; }
.cat-actions .btn { padding: 3.5px 8px; font-size: 11px; }

/* --------------------------------------------------------- C. entity */
.ehead {
  display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap;
  padding: 20px 0 16px;
}
.ehead-av {
  width: 58px; height: 58px; border-radius: 14px; flex: none;
  display: grid; place-items: center; font-size: 24px;
  background: var(--cat-tint, var(--primary-50)); color: var(--cat-ink, var(--primary));
  border: 1px solid rgba(0, 0, 0, .05);
  box-shadow: var(--shadow-1);
}
.ehead-id { min-width: 0; flex: 1; }
.ehead-title {
  font-size: 23px; font-weight: 700; letter-spacing: -.03em; line-height: 1.12; margin: 0;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.ehead-sub { font-size: 12.5px; color: var(--text-2); margin-top: 6px; line-height: 1.5; max-width: 74ch; }
.ehead-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.facts {
  display: flex; flex-wrap: wrap; gap: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255, 255, 255, .9);
  overflow: hidden; margin-bottom: 16px;
}
.fact { padding: 11px 16px; border-right: 1px solid var(--border); min-width: 118px; }
.fact:last-child { border-right: 0; }
.fact .f-k {
  font-size: 9px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; color: var(--muted);
}
.fact .f-v {
  font-size: 14px; font-weight: 640; margin-top: 4px; color: var(--text);
  font-variant-numeric: tabular-nums; letter-spacing: -.01em;
}
.fact .f-v.mono { font-family: var(--mono); font-size: 12.5px; }
.fact .f-v.ok { color: var(--ok); } .fact .f-v.err { color: var(--err); } .fact .f-v.warn { color: var(--warn); }
.egrid { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 16px; align-items: start; }
.erail { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 70px; }

/* --------------------------------------------------------- D. editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 336px; gap: 16px; align-items: start; }
.editor > :only-child { grid-column: 1 / -1; } /* form spans full width when the side rail is absent */
.editor-form { min-width: 0; }
.form-actions {
  position: sticky; bottom: 0; z-index: 6;
  display: flex; gap: 9px; align-items: center;
  padding: 12px 16px; margin-top: 2px;
  background: rgba(255, 255, 255, .93);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid var(--border-2); border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
}
.editor-side { position: sticky; top: 68px; display: flex; flex-direction: column; gap: 14px; }
.side-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255, 255, 255, .9); overflow: hidden;
}
.side-card-h {
  display: flex; align-items: center; gap: 8px; padding: 11px 14px;
  border-bottom: 1px solid var(--border); background: linear-gradient(180deg, #fff, var(--surface-2));
  font-size: 9.5px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; color: var(--text-2);
}
.side-card-h i { color: var(--primary); font-size: 13px; }
.side-card-b { padding: 13px 14px; font-size: 12px; color: var(--text-2); line-height: 1.6; }
.side-card-b p { margin: 0 0 9px; } .side-card-b p:last-child { margin-bottom: 0; }
.side-card-b ul { margin: 0; padding-left: 16px; } .side-card-b li { margin-bottom: 5px; }
.side-card-b code {
  background: var(--surface-3); border: 1px solid var(--border); padding: 1px 5px;
  border-radius: 4px; font-size: 11px; font-family: var(--mono);
}
.side-kv { display: grid; gap: 8px; }
.side-kv-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
.side-kv-row .k { color: var(--muted); }
.side-kv-row .v { font-weight: 600; color: var(--text); text-align: right; word-break: break-word; }
.formsec { margin-bottom: 16px; }
.formsec-h {
  display: flex; align-items: center; gap: 10px; margin-bottom: 11px;
}
.formsec-n {
  width: 22px; height: 22px; border-radius: 7px; flex: none; display: grid; place-items: center;
  font-size: 10.5px; font-weight: 750; color: var(--primary);
  background: var(--primary-50); border: 1px solid var(--primary-100);
}
.formsec-t { font-size: 13.5px; font-weight: 660; letter-spacing: -.008em; }
.formsec-d { font-size: 11.5px; color: var(--muted); margin-left: auto; text-align: right; }

/* --------------------------------------------------------- E. monitor */
.mon { display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 16px; align-items: start; }
.mon-rail {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255, 255, 255, .9); overflow: hidden;
  position: sticky; top: 68px;
}
.mon-rail-h {
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #fff, var(--surface-2));
  font-size: 9.5px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; color: var(--text-2);
}
.mon-group { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.mon-group:last-child { border-bottom: 0; }
.mon-group-lbl {
  font-size: 9px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 7px;
}
.mon-pick {
  display: flex; align-items: center; gap: 8px; padding: 4.5px 6px; border-radius: var(--r-sm);
  font-size: 12px; color: var(--text-2); cursor: pointer; transition: background .12s;
}
.mon-pick:hover { background: var(--surface-2); color: var(--text); }
.mon-pick .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--idle); flex: none; }
.mon-pick.on { background: var(--primary-50); color: var(--primary-700); font-weight: 620; }
.mon-pick.on .dot { background: var(--primary); }
.mon-pick .cnt { margin-left: auto; font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mon-rail .cat-search input,
.mon-rail .cat-search input:focus { width: 100%; }
.mon-rail .empty.sm { padding: 14px 8px; }

/* --------------------------------------------------------- F. flow rows */
.tflow { display: flex; flex-direction: column; gap: 10px; }
.tflow-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 128px minmax(0, 1fr) 268px;
  align-items: center; gap: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255, 255, 255, .9);
  overflow: hidden; transition: box-shadow .15s, border-color .15s;
}
.tflow-row:hover { box-shadow: var(--shadow-2); border-color: var(--border-2); }
.tf-node { padding: 13px 16px; min-width: 0; }
.tf-node .tf-lbl {
  font-size: 9px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: 6px;
}
.tf-node .tf-name {
  font-size: 13.5px; font-weight: 640; margin-top: 4px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tf-node .tf-path {
  font-size: 10.5px; color: var(--muted); margin-top: 2px; font-family: var(--mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tf-mid {
  position: relative; align-self: stretch; display: grid; place-items: center;
  border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  background: var(--surface-2);
}
.tf-mid::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1.5px;
  background: repeating-linear-gradient(90deg, var(--primary) 0 6px, transparent 6px 12px);
  background-size: 12px 1.5px; animation: flowDash 1.2s linear infinite;
}
.tf-mid::after {
  content: ""; position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  border-left: 6px solid var(--primary); border-top: 4px solid transparent; border-bottom: 4px solid transparent;
}
.tf-mid .tf-xf {
  position: relative; z-index: 1; font-size: 9.5px; font-weight: 700; letter-spacing: .04em;
  background: var(--surface-2); padding: 2px 6px; border-radius: 5px; color: var(--text-2);
  font-variant-numeric: tabular-nums; border: 1px solid var(--border);
}
.tf-state { padding: 13px 16px; display: flex; align-items: center; gap: 7px; justify-content: flex-end; flex-wrap: wrap; }
.tf-state .test-output { display: none; }
.tf-title { grid-column: 1 / -1; padding: 9px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2);
  display: flex; align-items: center; gap: 9px; font-size: 12.5px; font-weight: 620; flex-wrap: wrap; }
.tf-title a { color: var(--text); font-weight: 660; }
.tf-title a:hover { color: var(--primary); }
.tf-title .spacer { margin-left: auto; }


/* ------------------------------------------------ metric tiles (stats) */
.mgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(108px, 1fr)); gap: 8px; }
.mtile {
  padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2);
  border: 1px solid var(--border); position: relative; overflow: hidden;
  transition: border-color .14s, background .14s, transform .14s;
}
.mtile:hover { border-color: var(--border-2); background: #fff; transform: translateY(-1px); }
.mtile::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2.5px;
  background: var(--primary); opacity: .55;
}
.mtile.ok::before { background: var(--ok); opacity: 1; }
.mtile.warn::before { background: var(--warn); opacity: 1; }
.mtile.err::before { background: var(--err); opacity: 1; }
.mtile .m-k {
  font-size: 8.5px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); line-height: 1.3;
}
.mtile .m-v {
  font-size: 18px; font-weight: 700; margin-top: 5px; color: var(--text);
  font-variant-numeric: tabular-nums; letter-spacing: -.022em; line-height: 1;
}
.mtile .m-v.mono { font-family: var(--mono); font-size: 15px; }
.mtile.ok .m-v { color: var(--ok); }
.mtile.warn .m-v { color: var(--warn); }
.mtile.err .m-v { color: var(--err); }
.mtile .m-c { font-size: 10px; color: var(--muted); margin-top: 4px; }


/* --------------------------------------------------- E. monitor header */
.mhead {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 14px 18px; margin-bottom: 14px; border-radius: var(--r-lg);
  background: linear-gradient(180deg, #ffffff 0%, #fafcff 100%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255, 255, 255, .8);
  position: relative; overflow: hidden; color: var(--text);
}
.mhead > * { position: relative; z-index: 1; }
.mhead-l { display: flex; align-items: center; gap: 11px; min-width: 0; }
.mled {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  background: var(--ok); box-shadow: 0 0 0 4px rgba(21, 128, 61, .14);
  animation: mcPulse 2.2s infinite;
}
.mled.warn { background: var(--warn); box-shadow: 0 0 0 4px rgba(180, 83, 9, .14); }
.mled.err { background: var(--err); box-shadow: 0 0 0 4px rgba(185, 28, 28, .14); }
.mhead-t { font-size: 14px; font-weight: 680; letter-spacing: -.012em; color: var(--text); }
.mhead-s { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.mhead-s b { color: var(--text-2); font-weight: 600; }
.mh-stats { display: flex; margin-left: auto; flex-wrap: wrap; }
.mh-stat { padding: 0 16px; border-left: 1px solid var(--border); }
.mh-stat:first-child { border-left: 0; }
.mh-stat .k {
  font-size: 8.5px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  white-space: nowrap;
}
.mh-stat .v {
  font-size: 19px; font-weight: 700; margin-top: 3px; color: var(--text);
  font-variant-numeric: tabular-nums; letter-spacing: -.022em; line-height: 1.1;
}
.mh-stat .v.ok { color: var(--ok); } .mh-stat .v.err { color: var(--err); } .mh-stat .v.warn { color: var(--warn); }
.mh-stat .v .u { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: 0; }

/* connection list rows inside the monitor rail */
.con {
  display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: var(--r-sm);
  transition: background .12s;
}
.con:hover { background: var(--surface-2); }
.con > .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--idle); flex: none; }
.con > .dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(16, 185, 129, .14); }
.con > .dot.err { background: var(--err); box-shadow: 0 0 0 3px rgba(220, 38, 38, .14); }
.con > .dot.warn { background: var(--warn); }
.con-n { min-width: 0; flex: 1; }
.con-n a { display: block; font-size: 12px; font-weight: 600; color: var(--text); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.con-n a:hover { color: var(--primary); }
.con-n .t { display: block; font-size: 10px; color: var(--muted); font-family: var(--mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.con .pill { flex: none; }


/* -------------------------------------------------- coverage / audit rows */
.cov-grid { display: grid; gap: 8px; }
.cov-row {
  display: grid; grid-template-columns: 236px minmax(0, 1fr) 210px;
  align-items: center; gap: 16px; padding: 11px 15px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255, 255, 255, .85);
  transition: border-color .14s, box-shadow .14s;
}
.cov-row:hover { border-color: var(--border-2); box-shadow: var(--shadow-2); }
.cov-id { min-width: 0; }
.cov-n { font-size: 12.5px; font-weight: 640; color: var(--text); display: flex; align-items: center; gap: 6px; }
.cov-n a { color: var(--text); }
.cov-n a:hover { color: var(--primary); }
.cov-t {
  font-size: 10.5px; color: var(--muted); font-family: var(--mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px;
}
.cov-bar {
  display: flex; height: 9px; border-radius: 99px; overflow: hidden;
  background: var(--surface-3); border: 1px solid var(--border);
}
.cov-bar i { display: block; height: 100%; transition: width .4s ease; }
.cov-bar .rw { background: linear-gradient(90deg, #059669, #34d399); }
.cov-bar .ro { background: linear-gradient(90deg, #0284c7, #38bdf8); }
.cov-bar .un { background: repeating-linear-gradient(135deg, #e2e8f0 0 5px, #eef2f7 5px 10px); }
.cov-stats { display: flex; gap: 5px; justify-content: flex-end; flex-wrap: wrap; }
.cov-legend { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.cov-legend span { display: inline-flex; align-items: center; gap: 5px; }
.cov-legend i { width: 9px; height: 9px; border-radius: 3px; display: block; }
.cov-legend i.rw { background: linear-gradient(90deg, #059669, #34d399); }
.cov-legend i.ro { background: linear-gradient(90deg, #0284c7, #38bdf8); }
.cov-legend i.un { background: repeating-linear-gradient(135deg, #cbd5e1 0 4px, #e8eef5 4px 8px); }

/* --------------------------------------------------------- responsive */
@media (max-width: 1279.98px) {
  .mc-cols { grid-template-columns: minmax(0, 1fr); }
  .editor { grid-template-columns: minmax(0, 1fr); }
  .editor-side { position: static; }
  .egrid { grid-template-columns: minmax(0, 1fr); }
  .erail { position: static; }
  .mon { grid-template-columns: minmax(0, 1fr); }
  .mon-rail { position: static; }
  .flow { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .flow-arrow { padding: 0; height: 26px; }
  .flow-arrow::before { left: 50%; right: auto; top: 0; bottom: 0; width: 1.5px; height: auto;
    background: repeating-linear-gradient(180deg, rgba(96,165,250,.5) 0 5px, transparent 5px 10px);
    background-size: 1.5px 10px; }
  .flow-arrow span { display: none; }
  .tflow-row { grid-template-columns: minmax(0, 1fr); }
  .tf-mid { border: 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); height: 34px; }
  .tf-state { justify-content: flex-start; border-top: 1px solid var(--border); }
}
@media (max-width: 991.98px) {
  .arch-wrap { padding: 0; }
  .arch-h1 { font-size: 21px; }
  .mc-top { padding: 18px 16px 16px; }
  .mc-gauge { margin-left: 0; width: 100%; }
  .gauge { flex: 1; min-width: 0; }
  .mc-cols { padding: 0 16px 18px; }
  .flow { padding: 0 16px 18px; }
  .catalog { grid-template-columns: minmax(0, 1fr); }
  .cat-search input, .cat-search input:focus { width: 100%; }
  .cat-bar { flex-wrap: wrap; }
}
@media (max-width: 767.98px) {
  .cov-row { grid-template-columns: minmax(0, 1fr); gap: 9px; }
  .cov-stats { justify-content: flex-start; }
  .mh-stats { margin-left: 0; width: 100%; }
  .mh-stat { flex: 1 1 auto; padding: 0 12px; }
  .mh-stat:first-child { border-left: 0; padding-left: 0; }
  .mhead { gap: 12px; }
  .arch-head { padding: 14px 0 12px; }
}
@media (max-width: 479.98px) {
  .mh-stat { flex: 1 1 42%; border-left: 0; padding: 6px 0 0; }
  .mh-stat .v { font-size: 17px; }
  .fact { min-width: 0; flex: 1 1 46%; border-right: 0; border-bottom: 1px solid var(--border); }
  .fact:nth-last-child(-n+2) { border-bottom: 0; }
  .tf-state { justify-content: flex-start; }
}

/* ======================================================================
   NAVIGATION · collapsible sidebar rail
   ====================================================================== */
.sidebar { transition: width .18s ease, flex-basis .18s ease; }

/* section headers get a small icon marker */
.sb-head > span { display: flex; align-items: center; gap: 6px; }
.sb-head > span > i { font-size: 9px; opacity: .85; }

.sb-link { transition: background .12s, color .12s, padding .18s ease, transform .12s; }
.sb-link:hover { transform: translateX(1px); }

@media (max-width: 991.98px) {
}
.sb-foot .sb-v {
  margin-left: auto; font-size: 9px; letter-spacing: .08em;
  color: #3f4d61; font-family: var(--mono);
}

/* ======================================================================
   Micro-interactions · page arrival + press states
   ====================================================================== */
@keyframes pageIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: none; }
}
.page { animation: pageIn .24s cubic-bezier(.2, .7, .3, 1) both; }

.btn:active { transform: translateY(1px); }
.btn { transition: background .13s, border-color .13s, color .13s, box-shadow .13s, transform .08s; }

.tb-title { font-size: 15.5px; font-weight: 690; letter-spacing: -.02em; }

.sb-scroll::-webkit-scrollbar { width: 8px; }
.sb-scroll::-webkit-scrollbar-track { background: transparent; }
.sb-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .1); border-radius: 8px; border: 2px solid transparent;
  background-clip: content-box;
}
.sb-scroll::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .18); background-clip: content-box; }

@media (prefers-reduced-motion: reduce) {
  .page { animation: none; }
  .sidebar { transition: none; }
}

/* ======================================================================
   SIDEBAR · live status card + flat navigation polish
   ====================================================================== */
.sb-status {
  margin: 6px 12px 10px;
  padding: 10px 11px 9px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .018));
  border: 1px solid var(--sidebar-line);
  flex: none;
}
.sb-status-h {
  font-size: 8.5px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: #56677e;
  margin-bottom: 6px;
}
.sb-status-row {
  display: flex; align-items: center; gap: 7px;
  padding: 3px 0; font-size: 11.5px; color: #93a3b8;
}
.sb-status-row .s-dot {
  width: 6px; height: 6px; border-radius: 50%; flex: none;
  background: #475569; box-shadow: 0 0 0 3px rgba(71, 85, 105, .14);
  transition: background .2s, box-shadow .2s;
}
.sb-status-row.ok .s-dot { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .15); }
.sb-status-row.warn .s-dot { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, .15); }
.sb-status-row.err .s-dot { background: #ef4444; box-shadow: 0 0 0 3px rgba(239, 68, 68, .15); }
.sb-status-row .v {
  margin-left: auto; font-family: var(--mono); font-size: 9.5px;
  color: #7d8da3; letter-spacing: -.01em;
}

/* flat nav reads better with a touch more air between sections */
.sb-section { margin-top: 15px; }
.sb-section:first-child { margin-top: 4px; }
.sb-link { padding: 7px 9px; }
.sb-link > span:not(.sb-count) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ======================================================================
   CONSOLE v2 · in-page section nav + surface refinements
   ====================================================================== */

/* --- page section nav (entity pages) ---------------------------------- */
.pnav {
  display: flex; align-items: center; gap: 2px;
  margin: -2px 0 16px; padding: 0 2px;
  border-bottom: 1px solid var(--border-2);
  overflow-x: auto; scrollbar-width: none;
}
.pnav::-webkit-scrollbar { display: none; }
.pnav .pn {
  position: relative; display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 12px 10px; border-radius: 8px 8px 0 0;
  font-size: 12.5px; font-weight: 560; color: var(--text-2); white-space: nowrap;
  transition: color .12s, background .12s;
}
.pnav .pn:hover { color: var(--text); background: var(--surface-2); }
.pnav .pn i { font-size: 12px; opacity: .8; }
.pnav .pn b {
  font-size: 9.5px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--surface-3); color: var(--muted);
  padding: 1px 6px; border-radius: 20px; border: 1px solid var(--border);
}
.pnav .pn.on { color: var(--primary); }
.pnav .pn.on i { opacity: 1; }
.pnav .pn.on b { background: var(--primary-50); color: var(--primary); border-color: #cfe0fb; }
.pnav .pn.on::after {
  content: ""; position: absolute; left: 9px; right: 9px; bottom: -1px;
  height: 2px; border-radius: 3px 3px 0 0;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
}
[tabindex], .pnav ~ .egrid [id] { scroll-margin-top: 78px; }

/* --- panel headers: tinted icon chip ---------------------------------- */
.panel-title > i {
  width: 23px; height: 23px; border-radius: 7px; flex: none;
  display: inline-grid; place-items: center;
  font-size: 11.5px; color: var(--primary);
  background: linear-gradient(180deg, #f3f8ff, #e3eefd);
  border: 1px solid #d3e2f8;
  box-shadow: inset 0 1px 0 #fff;
}
.side-card-h i {
  width: 20px; height: 20px; border-radius: 6px; flex: none;
  display: inline-grid; place-items: center; font-size: 10.5px;
  background: var(--primary-50); border: 1px solid #dbe7fb; color: var(--primary);
}

/* --- metric band ------------------------------------------------------ */
.fact { transition: background .13s; }
.fact:hover { background: var(--surface-2); }
.fact .f-k { font-size: 8.5px; letter-spacing: .135em; }
.fact .f-v { font-size: 16px; margin-top: 5px; letter-spacing: -.022em; }

/* --- catalogue cards: tinted head, stronger identity ------------------ */
.cat-card { border-radius: 13px; }
.cat-head {
  padding: 15px 16px 13px;
  background: linear-gradient(180deg, var(--cat-tint, var(--surface-2)) 0%, rgba(255, 255, 255, 0) 92%);
}
.cat-av { width: 40px; height: 40px; border-radius: 11px; font-size: 17px; }
.cat-name { font-size: 14.5px; }
.cat-card:hover { border-color: var(--border-2); box-shadow: var(--shadow-3); }

/* --- controls --------------------------------------------------------- */
.btn { min-height: 32px; border-radius: 8px; }
.btn-sm { min-height: 26px; border-radius: 7px; }
.btn-lg { min-height: 38px; }

/* --- topbar ----------------------------------------------------------- */
.tb-title { font-size: 15.5px; font-weight: 690; }
/* pages that already carry a page-level h1 (.arch-h1) would show the same
   text twice in a row: keep the small crumb, drop the repeated title */
body:has(.arch-h1) .tb-title { display: none; }
.crumb {
  font-size: 9.5px; font-weight: 650; letter-spacing: .1em;
  text-transform: uppercase;
}
.crumb i { font-size: 7px; }

/* --- sidebar section labels ------------------------------------------ */
.sb-head { color: #5f7189; letter-spacing: .16em; }
.sb-section { margin-top: 16px; }
.sb-link { font-weight: 520; }
.sb-link.active { font-weight: 600; }
a.cat-fact.lnk { transition: border-color .12s, background .12s, color .12s; }
a.cat-fact.lnk:hover {
  border-color: #bfd4f7; background: var(--primary-50); color: var(--primary);
}
a.cat-fact.lnk:hover b, a.cat-fact.lnk:hover i { color: var(--primary); }

/* ======================================================================
   DASHBOARD v2 · rings, pipeline board, telemetry tiles, quick actions
   ====================================================================== */
.mc-lead { flex: 1 1 360px; min-width: 0; }
.mc-facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 15px; }
.mc-fact {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 20px;
  font-size: 10.5px; font-weight: 600; color: var(--text-2);
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-0);
  transition: background .13s, border-color .13s;
}
.mc-fact:hover { background: var(--primary-50); border-color: var(--primary-100); color: var(--primary-700); }
.mc-fact i { font-size: 10px; color: var(--primary); }
.mc-fact b { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }

/* --- ring gauges --- */
.rings { margin-left: auto; display: flex; gap: 20px; flex-wrap: wrap; }
.ring { width: 104px; text-align: center; }
.ring-dial {
  width: 84px; height: 84px; margin: 0 auto 8px; border-radius: 50%;
  display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--c, #60a5fa) calc(var(--p, 0) * 1%), #e8edf6 0);
  box-shadow: 0 2px 10px -3px rgba(15, 23, 42, .14);
}
.ring-dial::before {
  content: ""; position: absolute; inset: 7px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, .02), inset 0 1px 4px rgba(15, 23, 42, .04);
}
.ring-v {
  position: relative; z-index: 1; font-size: 16px; font-weight: 700;
  color: var(--text); letter-spacing: -.02em; line-height: 1.05;
}
.ring-v small {
  display: block; font-size: 8px; font-weight: 700; letter-spacing: .11em;
  text-transform: uppercase; color: var(--muted); margin-top: 2px;
}
.ring-k { font-size: 8.5px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.ring-s { font-size: 10px; color: var(--text-2); margin-top: 2px; font-variant-numeric: tabular-nums; }

/* --- cycle strip --- */
.cyc2 {
  display: grid; grid-template-columns: auto minmax(80px, 1fr) auto;
  align-items: center; gap: 14px; padding: 0 24px 18px;
}
.cyc2-l { display: flex; align-items: baseline; gap: 9px; }
.cyc2-k { font-size: 9px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; color: var(--muted); }
.cyc2-v { font-size: 13px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.cyc2-v span { font-size: 9.5px; font-weight: 600; color: var(--muted); margin-left: 4px; }
.cyc2-bar { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; position: relative; box-shadow: inset 0 1px 2px rgba(15, 23, 42, .05); }
.cyc2-bar i {
  position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 6px;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  transition: width .4s linear;
}
.cyc2-r { display: flex; align-items: center; gap: 7px; font-size: 10px; color: var(--muted); }
.cyc2-r .mono { font-variant-numeric: tabular-nums; }
.cyc2-sep { color: var(--border-2); }
.cyc2-edit {
  width: 22px; height: 22px; margin-left: 3px; border-radius: 6px;
  display: grid; place-items: center; font-size: 10px;
  color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background .13s, color .13s, border-color .13s;
}
.cyc2-edit:hover { background: var(--primary-50); color: var(--primary); border-color: var(--primary-100); }

/* --- pipeline board --- */
.pl-wrap { padding: 0 24px 22px; }
.pl-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.pl-title {
  display: flex; align-items: center; gap: 7px;
  font-size: 9px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; color: var(--text-2);
}
.pl-title i { font-size: 12px; color: var(--primary); }
.pl-sub { font-size: 10px; color: var(--muted); }
.pl-live {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
  font-size: 8.5px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; color: var(--ok);
}
.pl-live::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 0 3px rgba(21, 128, 61, .14); animation: mcPulse 2.4s infinite;
}

.pl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr) 24px minmax(0, 1fr) 24px minmax(0, 1fr);
  gap: 0; align-items: stretch;
}
.pl-arrow { display: grid; place-items: center; position: relative; }
.pl-arrow::before {
  content: ""; position: absolute; left: 2px; right: 2px; top: 50%; height: 1.5px;
  background: repeating-linear-gradient(90deg, rgba(37, 99, 235, .45) 0 5px, transparent 5px 10px);
  animation: flowDash 1.1s linear infinite;
}
.pl-arrow::after {
  content: ""; width: 5px; height: 5px; border-radius: 50%; position: relative;
  background: var(--primary); box-shadow: 0 0 6px rgba(37, 99, 235, .55);
}
.pl-arrow span {
  position: absolute; bottom: -3px; font-size: 8px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}

.pl-stage {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
}
.pl-sh {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .65);
}
.pl-n {
  width: 18px; height: 18px; border-radius: 5px; flex: none;
  display: grid; place-items: center; font-size: 9.5px; font-weight: 800; color: #fff;
  background: linear-gradient(180deg, #3b82f6, #2563eb);
  box-shadow: 0 1px 3px rgba(30, 64, 175, .35);
}
.pl-st { font-size: 8.5px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; color: var(--text-2); }
.pl-c {
  margin-left: auto; font-size: 9.5px; font-weight: 700; color: var(--text-2);
  background: #fff; border: 1px solid var(--border); padding: 1px 7px; border-radius: 20px;
  font-variant-numeric: tabular-nums;
}

.pl-body { display: flex; flex-direction: column; gap: 5px; flex: 1; padding: 8px; min-height: 0; }
.pl-scroll { max-height: 300px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(15, 23, 42, .22) transparent; }
.pl-scroll::-webkit-scrollbar { width: 5px; }
.pl-scroll::-webkit-scrollbar-thumb { background: rgba(15, 23, 42, .22); border-radius: 5px; }

.pl-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 7px;
  background: #fff; border: 1px solid transparent;
  box-shadow: var(--shadow-0);
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.pl-row:hover { border-color: var(--primary-100); box-shadow: 0 1px 3px rgba(37, 99, 235, .12); }
.pl-dot { width: 6px; height: 6px; border-radius: 50%; flex: none; background: #cbd5e1; }
.pl-row.ok .pl-dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(21, 128, 61, .12); }
.pl-row.err .pl-dot { background: var(--err); box-shadow: 0 0 0 3px rgba(185, 28, 28, .12); }
.pl-row.warn .pl-dot { background: var(--warn); box-shadow: 0 0 0 3px rgba(180, 83, 9, .12); }
.pl-row.info .pl-dot { background: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.pl-main { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.pl-name {
  font-size: 11.5px; font-weight: 600; color: var(--text); line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pl-meta {
  font-size: 9.5px; color: var(--muted); line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pl-meta.mono { font-family: var(--mono); font-size: 9px; }
.pl-badge {
  flex: none; font-size: 9px; font-weight: 700; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 1px 6px; border-radius: 5px;
  font-variant-numeric: tabular-nums;
}
.pl-ic { flex: none; font-size: 11px; color: var(--muted); }
.pl-row:hover .pl-ic { color: var(--primary); }
.pl-empty { padding: 7px 8px; font-size: 10.5px; color: var(--muted); line-height: 1.45; }
.pl-foot {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 5px 8px; border-top: 1px solid var(--border);
  font-size: 8.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); background: rgba(255, 255, 255, .5);
}

.pl-kpi { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pl-kv { padding: 8px 9px; border-radius: 8px; background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow-0); }
.pl-kv b { display: block; font-size: 17px; font-weight: 700; color: var(--text); line-height: 1; font-variant-numeric: tabular-nums; }
.pl-kv.ok b { color: var(--ok); } .pl-kv.err b { color: var(--err); }
.pl-kv span { display: block; margin-top: 3px; font-size: 8px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.pl-split { height: 6px; border-radius: 6px; overflow: hidden; background: var(--err-bg); border: 1px solid var(--err-line); }
.pl-split i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, #059669, #34d399); }
.pl-legend { display: flex; gap: 12px; font-size: 9px; color: var(--muted); }
.pl-legend .sw { display: inline-block; width: 6px; height: 6px; border-radius: 2px; margin-right: 4px; }
.pl-legend .sw.ok { background: var(--ok); } .pl-legend .sw.err { background: var(--err); }

/* --- telemetry tiles --- */
.tg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 12px; }
.tg-tile { padding: 9px 10px; border-radius: 9px; background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow-0); }
.tg-top { display: flex; align-items: center; gap: 6px; font-size: 8px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.tg-top i { font-size: 10px; color: var(--primary); }
.tg-v { margin: 6px 0 7px; font-size: 18px; font-weight: 700; color: var(--text); line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tg-v small { font-size: 10px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.tg-bar { height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; box-shadow: inset 0 1px 2px rgba(15, 23, 42, .04); }
.tg-bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.tg-bar i.ok { background: linear-gradient(90deg, #059669, #34d399); }
.tg-bar i.warn { background: linear-gradient(90deg, #d97706, #fbbf24); }
.tg-bar i.err { background: linear-gradient(90deg, #dc2626, #f87171); }

/* --- quick actions --- */
.qa { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 12px; }
.qa-i {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 9px 10px; border-radius: 9px;
  background: #fff; border: 1px solid var(--border);
  box-shadow: var(--shadow-0);
  transition: background .12s, border-color .12s, transform .12s, box-shadow .12s;
}
.qa-i:hover { background: #fff; border-color: var(--primary-100); transform: translateY(-1px); box-shadow: 0 3px 10px -3px rgba(37, 99, 235, .22); }
.qa-i > i {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  display: grid; place-items: center; font-size: 12px;
  background: var(--primary-50); border: 1px solid var(--primary-100); color: var(--primary);
}
.qa-i b { display: block; font-size: 11px; font-weight: 650; color: var(--text); line-height: 1.2; }
.qa-i small { display: block; margin-top: 2px; font-size: 9.5px; color: var(--muted); line-height: 1.3; }
.qa-foot {
  display: flex; align-items: center; gap: 8px; padding: 9px 14px;
  border-top: 1px solid var(--border);
  font-size: 10px; color: var(--muted);
}
.qa-foot a { margin-left: auto; color: var(--primary); font-weight: 650; }
.qa-foot a:hover { color: var(--primary-600); }

@media (max-width: 1180px) {
  .pl { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .pl-arrow { display: none; }
  .pl-scroll { max-height: 200px; }
}
@media (max-width: 1060px) {
  .rings { margin-left: 0; }
}
@media (max-width: 820px) {
  .cyc2 { grid-template-columns: 1fr; gap: 8px; }
  .cyc2-r { justify-content: flex-end; }
}
@media (max-width: 640px) {
  .pl { grid-template-columns: 1fr; }
  .tg { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .qa { grid-template-columns: 1fr; }
}

/* ======================================================================
   SETTINGS · editor extras
   ====================================================================== */
.input-unit { position: relative; display: flex; align-items: center; }
.input-unit .form-control { padding-right: 72px; }
.input-unit .unit {
  position: absolute; right: 10px; font-size: 10.5px; font-weight: 650;
  letter-spacing: .04em; color: var(--muted); pointer-events: none;
  text-transform: uppercase;
}
.preset-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.preset {
  padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600;
  font-family: inherit; color: var(--text-2); cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border);
  transition: background .12s, border-color .12s, color .12s;
}
.preset:hover { border-color: var(--border-2); background: #fff; }
.preset.on { color: var(--primary); background: var(--primary-50); border-color: #bfd4f7; }

.rate-card {
  padding: 12px 14px; border-radius: 10px;
  background: linear-gradient(180deg, var(--surface-2), #fff);
  border: 1px solid var(--border);
}
.rate-v {
  display: flex; align-items: baseline; gap: 7px;
  font-size: 24px; font-weight: 720; letter-spacing: -.03em; color: var(--text);
  font-variant-numeric: tabular-nums; line-height: 1;
}
.rate-v .unit { font-size: 10.5px; font-weight: 650; color: var(--muted); letter-spacing: .03em; }
.rate-sub { margin-top: 6px; font-size: 11.5px; color: var(--muted); line-height: 1.45; }

.hint-list { margin: 4px 0 0; padding-left: 17px; font-size: 12px; color: var(--text-2); line-height: 1.6; }
.hint-list li { margin-bottom: 5px; }
.hint-list code { font-size: 11px; }

.editor-note {
  display: flex; gap: 9px; padding: 11px 12px; border-radius: 9px;
  background: var(--primary-50); border: 1px solid #dbe7fb;
  font-size: 11.5px; color: #1e40af; line-height: 1.55;
}
.editor-note i { font-size: 13px; margin-top: 1px; flex: none; }

.kv-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kv { padding: 12px 16px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); min-width: 0; }
.kv:nth-child(3n) { border-right: 0; }
.kv:nth-last-child(-n+3) { border-bottom: 0; }
.kv .k { display: block; font-size: 8.5px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; color: var(--muted); }
.kv .v {
  display: block; margin-top: 5px; font-size: 12.5px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kv .v.mono { font-family: var(--mono); font-size: 11.5px; }
.kv .v.ok { color: var(--ok); } .kv .v.err { color: var(--err); }
.form-actions .spacer { margin-left: auto; }
.form-actions-hint { font-size: 10.5px; font-weight: 650; letter-spacing: .04em; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.form-actions-hint i { color: var(--warn); }

@media (max-width: 767.98px) {
  .kv-grid { grid-template-columns: 1fr 1fr; }
  .kv:nth-child(3n) { border-right: 1px solid var(--border); }
  .kv:nth-child(2n) { border-right: 0; }
  .kv:nth-last-child(-n+3) { border-bottom: 1px solid var(--border); }
  .kv:nth-last-child(-n+2) { border-bottom: 0; }
}

/* ======================================================================
   DASHBOARD · professional layout
   status hero → data pipeline → system overview matrix
   ====================================================================== */

/* --- status hero ------------------------------------------------------- */
.dhero {
  display: flex; align-items: center; gap: 18px;
  padding: 18px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--idle);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  margin-bottom: 16px;
}
.dhero.ok    { border-left-color: var(--ok); }
.dhero.warn  { border-left-color: var(--warn); }
.dhero.err   { border-left-color: var(--err); }
.dhero.idle  { border-left-color: var(--idle); }

.dh-ring { position: relative; width: 56px; height: 56px; flex: none; }
.dh-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }
.dh-ring .track { fill: none; stroke: var(--surface-3); stroke-width: 5; }
.dh-ring .prog  { fill: none; stroke-width: 5; stroke-linecap: round; transition: stroke-dasharray .5s ease; }
.dh-ring .val {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums; color: var(--text);
}
.dh-ring .val small { font-size: 9px; font-weight: 600; color: var(--muted); margin-left: 1px; }

.dh-lead { min-width: 0; flex: 1; }
.dh-title {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 17px; font-weight: 700; letter-spacing: -.018em;
  line-height: 1.25; color: var(--text);
}
.dh-sub { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.dh-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; padding: 3px 9px;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-2);
}
.dh-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.dh-pill.ok   { color: var(--ok);   background: var(--ok-bg);   border-color: var(--ok-line); }
.dh-pill.warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
.dh-pill.err  { color: var(--err);  background: var(--err-bg);  border-color: var(--err-line); }
.dh-pill.idle { color: var(--muted); }

.dh-meta { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dh-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 11px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.dh-chip i { color: var(--muted); font-size: 11px; }

/* --- panel shell ------------------------------------------------------- */
.dpanel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  margin-bottom: 16px;
}
.dpanel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
}
.dp-t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dpanel-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13.5px; font-weight: 650; letter-spacing: -.01em; color: var(--text);
}
.dpanel-title i { color: var(--muted); font-size: 13px; }
.dpanel-sub  { font-size: 11.5px; color: var(--muted); }
.dpanel-note {
  font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* --- data pipeline ----------------------------------------------------- */
.dpipe { display: flex; align-items: center; gap: 10px; padding: 16px 18px; flex-wrap: wrap; }
.dp-node {
  flex: 1 1 0; min-width: 150px;
  display: flex; align-items: center; gap: 11px;
  padding: 11px 13px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  text-decoration: none;
  transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}
.dp-node:hover {
  border-color: #c7d7f7;
  box-shadow: 0 8px 18px -14px rgba(15, 23, 42, .55);
  transform: translateY(-1px);
}
.dp-ic {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-2); font-size: 13px;
}
.dp-b { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.dp-lbl {
  font-size: 10px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted);
}
.dp-val {
  font-size: 15px; font-weight: 700; letter-spacing: -.025em;
  color: var(--text); font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dp-val small { font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: -.005em; }
.dp-arrow { flex: none; width: 22px; height: 1px; background: var(--border); position: relative; }
.dp-arrow::after {
  content: ""; position: absolute; right: -1px; top: -3.5px;
  border-left: 5px solid var(--border);
  border-top: 3.5px solid transparent;
  border-bottom: 3.5px solid transparent;
}
@media (max-width: 1100px) { .dp-arrow { display: none; } }

/* --- system overview matrix -------------------------------------------- */
.ov-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border-top: 1px solid var(--border);
}
@media (max-width: 1300px) { .ov-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px)  { .ov-grid { grid-template-columns: 1fr; } }

.ov-card {
  display: flex; flex-direction: column; gap: 9px;
  padding: 16px 18px 15px;
  background: var(--surface);
  text-decoration: none;
  transition: background .14s ease;
}
.ov-card:hover { background: #f7faff; }
.ov-card:hover .ov-ic { border-color: #c7d7f7; color: var(--primary); }

.ov-top { display: flex; align-items: center; gap: 9px; }
.ov-ic {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-2); font-size: 13px;
  transition: color .14s ease, border-color .14s ease;
}
.ov-name {
  flex: 1; min-width: 0;
  font-size: 13px; font-weight: 650; letter-spacing: -.01em; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ov-st {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; color: var(--muted);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.ov-st .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--idle); flex: none; }
.ov-st.ok   { color: var(--ok); }
.ov-st.ok .dot   { background: var(--ok); }
.ov-st.warn { color: var(--warn); }
.ov-st.warn .dot { background: var(--warn); }
.ov-st.err  { color: var(--err); }
.ov-st.err .dot  { background: var(--err); }

.ov-val {
  display: flex; align-items: baseline; gap: 7px;
  font-size: 24px; font-weight: 700; letter-spacing: -.03em;
  color: var(--text); font-variant-numeric: tabular-nums;
}
.ov-val small { font-size: 14px; font-weight: 600; color: var(--muted); letter-spacing: -.01em; }
.ov-unit { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.ov-note {
  margin-top: auto;
  font-size: 11.5px; color: var(--muted);
  border-top: 1px dashed var(--border);
  padding-top: 9px;
}

/* ======================================================================
   INLINE ENTITY TABLES · group rows + tree marker
   ====================================================================== */
.tbl td .cell-main .pill { margin-right: 2px; }
.tbl tr.grp > td {
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}
.tbl tr.grp:hover > td { background: #edf1f7; }
.tbl tr.grp .cell-main strong { color: var(--text); font-weight: 650; }
.pt-tree { color: var(--muted); font-size: 12px; opacity: .7; padding-left: 3px; }
.tbl td { vertical-align: top; }

/* ======================================================================
   MODBUS SERVER · slaves accordion (tags open on click)
   ====================================================================== */
#ptTbl tr.slave-row { cursor: pointer; }
.pt-chev {
  display: inline-grid; place-items: center;
  width: 16px; height: 16px; flex: none;
  color: var(--muted);
  transition: transform .15s ease, color .15s ease;
}
#ptTbl tr.slave-row.open .pt-chev { transform: rotate(90deg); color: var(--primary); }
#ptTbl tr.pts-row > td { background: #fbfcfe; padding: 0; border-top: 0; }
.pts-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px dashed var(--border);
  font-size: 12px; color: var(--muted);
}
.pts-head b { color: var(--text); font-weight: 600; }
.pts-head i { margin-right: 4px; }
.tbl-nested { margin: 0; background: transparent; }
.tbl-nested thead th {
  font-size: 10px; letter-spacing: .09em; text-transform: uppercase;
  padding: 9px 16px; background: transparent; color: var(--muted);
}
.tbl-nested td { padding: 10px 16px; border-color: var(--border); }
.tbl-nested tbody tr:hover > td { background: var(--surface-2); }
.pts-empty { padding: 14px 18px; font-size: 12.5px; color: var(--muted); }
.panel-head .panel-sub { font-size: 11.5px; color: var(--muted); align-self: center; margin-left: 8px; }

/* ======================================================================
   LIVE DATA · toolbar status picks
   ====================================================================== */
.lv-picks { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lv-pick {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-2); font-size: 12px; font-weight: 600;
  border-radius: 999px; padding: 5px 11px; cursor: pointer;
  transition: color .13s, background .13s, border-color .13s;
}
.lv-pick:hover { color: var(--text); }
.lv-pick .c {
  font-variant-numeric: tabular-nums; font-size: 11px; font-weight: 600;
  background: #fff; border: 1px solid var(--border);
  border-radius: 999px; padding: 0 7px; color: var(--muted);
}
.lv-pick.on { color: var(--primary); background: var(--primary-50); border-color: #cfe0fb; }
.lv-pick.on .c { background: var(--primary); color: #fff; border-color: var(--primary); }
.lv-auto { display: inline-flex; align-items: center; margin: 0 4px; }
.live-panel .panel-foot { font-size: 11.5px; color: var(--muted); }

/* dashboard · narrow screens: let pipeline values wrap instead of clipping */
@media (max-width: 1100px) {
  .dp-val { white-space: normal; font-size: 14px; }
  .dp-node { flex: 1 1 170px; }
}

/* ======================================================================
   INLINE POLL INTERVAL EDITORS · network / gateway / server pages
   ====================================================================== */
.poll-inline { display: flex; align-items: center; gap: 6px; }
.poll-inline input {
  width: 76px; height: 30px; padding: 0 9px;
  border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text);
  font-family: var(--mono); font-size: 13px; font-weight: 650;
  font-variant-numeric: tabular-nums;
  transition: border-color .13s, box-shadow .13s;
}
.poll-inline input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-50);
}
.poll-inline .unit { font-size: 11px; font-weight: 650; color: var(--muted); }
.poll-inline .btn { padding: 5px 8px; line-height: 1; }
.fact-poll { background: #f8fafd; }
.fact-poll .f-v { font-size: inherit; letter-spacing: 0; margin-top: 7px; }
.f-hint { margin-top: 5px; font-size: 10.5px; color: var(--muted); }

/* ====================================================================== *
   NETWORK / DEVICE TYPE
   ====================================================================== */
.type-static {
  display: flex; align-items: center; gap: 10px; min-height: 38px;
  background: #f8fafc; cursor: default; font-weight: 600;
}
.type-static .type-note {
  font-size: 11px; color: var(--muted); font-weight: 500; letter-spacing: .02em;
}
.cat-card.t-net.is-mqtt {
  --cat-accent: linear-gradient(90deg, #f59e0b, #fbbf24);
  --cat-tint: #fef3c7; --cat-ink: #b45309;
}

/* ====================================================================== *
   DROP-DOWN FILTERS · live page + catalog pages
   ====================================================================== */
.sel-wrap { position: relative; display: inline-flex; align-items: center; }
.sel-wrap > i {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 10px; color: var(--muted); pointer-events: none;
}
.sel {
  appearance: none; -webkit-appearance: none;
  height: 32px; padding: 0 27px 0 11px;
  border: 1px solid var(--border); border-radius: 9px;
  background: #fff; color: var(--text);
  font-family: inherit; font-size: 12.5px; font-weight: 620; letter-spacing: -.01em;
  cursor: pointer; max-width: 230px;
  transition: border-color .13s, box-shadow .13s, background .13s;
}
.sel:hover { border-color: #cbd5e1; background: #fbfdff; }
.sel:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-50);
}
.sel.on { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }
.sel option { font-weight: 500; }

/* the bar that carries them (live page) */
.filterbar {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 11px 13px; margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.filterbar .fb-title {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 10.5px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase;
  color: var(--muted); margin-right: 3px;
}
.filterbar .fb-title i { font-size: 12px; }
.filterbar .fb-k {
  font-size: 11.5px; font-weight: 650; color: var(--muted);
  margin-left: 6px; white-space: nowrap;
}
.filterbar .fb-k:first-of-type { margin-left: 0; }
.filterbar .sel { max-width: 260px; }
.filterbar .btn { height: 32px; }

/* inside a catalog bar or a panel toolbar */
.cat-bar .sel-wrap, .toolbar .sel-wrap { margin-left: 6px; }
.toolbar .sel { height: 30px; }

/* --------------------------------------------------- settings page (host) */
.act { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-top: 20px; }
.act .form-text { margin-top: 0; }

/* two-way segmented radio (DHCP / Static) */
.seg2 { position: relative; display: inline-flex; gap: 3px; padding: 3px;
        background: var(--surface-3); border: 1px solid var(--border); border-radius: 9px; }
.seg2 > input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg2 > label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
  font-weight: 600; color: var(--text-2); padding: 6px 14px; border-radius: 7px;
  cursor: pointer; transition: background .13s, color .13s; }
.seg2 > label i { font-size: 12px; }
.seg2 > input:checked + label { background: #fff; color: var(--text);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .14); }
.seg2 > input:focus-visible + label { box-shadow: var(--ring); }

/* one card per network interface */
.ip-card { border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2);
  padding: 14px 16px 15px; margin-bottom: 13px; }
.ip-card.is-primary { border-color: #c8d8f8; background: linear-gradient(180deg, #f8fbff 0%, #fff 62%); }
.ip-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ip-head .spacer { margin-left: auto; }
.ip-name { font-family: var(--mono); font-size: 13.5px; font-weight: 650; letter-spacing: .2px; }
.ip-meta { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.ip-fields { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; margin-top: 13px; }
.ip-fields .f { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.ip-fields .f > label { font-size: 10.5px; font-weight: 650; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; }
.ip-fields .f > label span { text-transform: none; letter-spacing: 0; font-weight: 400; }
.ip-fields .f.wide { flex: 1 1 170px; }
.ip-actions { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.ip-actions .switch .lbl small { font-size: 10px; }

/* ======================================================================
   DASHBOARD · interactive layer
   entrance motion, count-ups, flowing pipeline, live sparklines
   ====================================================================== */
@keyframes d-fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes d-ring    { from { stroke-dasharray: 0 135.1; } }
@keyframes d-pulse   {
  0%   { box-shadow: 0 0 0 0 currentColor; }
  70%  { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes d-run {
  0%   { left: 0;      opacity: 0; }
  12%  { opacity: 1; }
  88%  { opacity: 1; }
  100% { left: calc(100% - 12px); opacity: 0; }
}
@keyframes d-bump { 0% { transform: scale(1); } 32% { transform: scale(1.16); } 100% { transform: scale(1); } }

.dhero, .dpanel { animation: d-fade-up .5s cubic-bezier(.2, .7, .3, 1) both; }
.d-anim-1 { animation-delay: .04s; } .d-anim-2 { animation-delay: .08s; }
.d-anim-3 { animation-delay: .12s; } .d-anim-4 { animation-delay: .16s; }
.d-anim-5 { animation-delay: .2s; }

.dh-ring .prog { animation: d-ring .9s cubic-bezier(.2, .7, .3, 1) both; }
.dh-ring .val b { font-weight: 700; }
.dh-pill .dot, .ov-st .dot { animation: d-pulse 2.6s ease-out infinite; }

/* pipeline: a packet of data running along each link */
.dp-arrow::before {
  content: ""; position: absolute; top: -1.5px; width: 12px; height: 4px;
  border-radius: 3px; z-index: 1;
  background: linear-gradient(90deg, rgba(37, 99, 235, 0), var(--primary));
  animation: d-run 2.4s linear infinite;
}
.dp-node:hover .dp-ic { background: var(--primary); border-color: var(--primary); color: #fff; }
.dp-val b { font-weight: 700; }

/* two-column: live values + devices */
.dash-cols {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 16px; align-items: start; margin-bottom: 16px;
}
.dash-cols .dpanel { margin-bottom: 0; }
@media (max-width: 1180px) { .dash-cols { grid-template-columns: 1fr; } }

/* quick action strip */
.dquick { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; padding: 13px 18px; }
.dq-eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin-right: 3px;
}
.dq-eyebrow i { font-size: 11px; color: var(--primary); }
.dq-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 13px; border-radius: 9px;
  border: 1px solid var(--border); background: #fff;
  color: var(--text-2); font-size: 12.5px; font-weight: 600; text-decoration: none;
  transition: background .15s ease, border-color .15s ease, color .15s ease,
              transform .15s ease, box-shadow .15s ease;
}
.dq-btn i { font-size: 12px; }
.dq-btn:hover {
  border-color: #c7d7f7; background: #f7faff; color: var(--primary);
  transform: translateY(-1px); box-shadow: 0 8px 16px -12px rgba(15, 23, 42, .65);
}
.dq-btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.dq-btn.primary:hover { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }

/* live value rows */
.dlv-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto 100px;
  gap: 12px; align-items: center; padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  transition: background .14s ease;
}
.dlv-row:last-child { border-bottom: 0; }
.dlv-row:hover { background: #f8faff; }
.dlv-id { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dlv-name {
  font-size: 12.5px; font-weight: 640; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dlv-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dlv-reg {
  font-size: 10.5px; color: var(--text-2); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 6px; padding: 3px 7px;
  white-space: nowrap;
}
.dlv-val {
  font-family: var(--mono); font-size: 14px; font-weight: 650; letter-spacing: -.02em;
  color: var(--text); font-variant-numeric: tabular-nums;
  text-align: right; min-width: 58px; max-width: 175px; display: inline-block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dlv-row.is-bad .dlv-val { color: var(--err); }
.dlv-val.bump { animation: d-bump .45s ease; }
.dlv-st { justify-self: end; }
canvas.spark { display: block; width: 100px; height: 30px; }

/* device status rows */
.ddv-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 11px; align-items: center; padding: 11px 18px;
  border-bottom: 1px solid var(--border); text-decoration: none;
  transition: background .14s ease;
}
.ddv-row:last-child { border-bottom: 0; }
.ddv-row:hover { background: #f8faff; }
.ddv-dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--idle); box-shadow: 0 0 0 3px rgba(148, 163, 184, .18);
  transition: background .2s ease, box-shadow .2s ease;
}
.ddv-row[data-state="ok"]   .ddv-dot { background: var(--ok);   box-shadow: 0 0 0 3px var(--ok-bg); }
.ddv-row[data-state="warn"] .ddv-dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.ddv-row[data-state="err"]  .ddv-dot { background: var(--err);  box-shadow: 0 0 0 3px var(--err-bg); }
.ddv-id { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ddv-name { font-size: 12.5px; font-weight: 640; color: var(--text); }
.ddv-sub  { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ddv-st {
  font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted); transition: color .2s ease;
}
.ddv-row[data-state="ok"]   .ddv-st { color: var(--ok); }
.ddv-row[data-state="warn"] .ddv-st { color: var(--warn); }
.ddv-row[data-state="err"]  .ddv-st { color: var(--err); }
.ddv-more {
  display: block; padding: 10px 18px; font-size: 12px; font-weight: 600;
  color: var(--primary); text-decoration: none; background: var(--surface-2);
}
.ddv-more:hover { text-decoration: underline; }

.dempty {
  padding: 30px 18px; text-align: center; color: var(--muted);
  font-size: 12.5px; line-height: 1.5;
}
.dempty i { display: block; font-size: 20px; margin-bottom: 7px; opacity: .45; }

/* system overview cards lift on hover */
.ov-card { position: relative; z-index: 0; transition: background .14s ease, transform .16s ease, box-shadow .16s ease; }
.ov-card:hover {
  background: #f7faff; transform: translateY(-2px); z-index: 2;
  box-shadow: 0 14px 26px -20px rgba(15, 23, 42, .8);
}
.ov-val b { font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  .dhero, .dpanel, .dh-ring .prog, .dh-pill .dot, .ov-st .dot,
  .dp-arrow::before, .dlv-val.bump { animation: none !important; }
  .ov-card:hover, .dq-btn:hover, .dp-node:hover { transform: none; }
}
