/* StarX Connect — front-end MVP design system.
   Adapted from the ODX/holodBot platform: slate/indigo palette, glass cards,
   light by default, dark via `html.dark`. System font stack, no CDN — fully
   self-contained so the mockup opens straight from disk. */

:root {
  /* ── LIGHT (default) ───────────────────────────────────────────────────── */
  --bg:            #f8fafc;
  --bg-2:          #ffffff;
  --glass:         #ffffff;
  --glass-2:       #f1f5f9;
  --glass-strong:  #e2e8f0;
  --border:        #e2e8f0;
  --border-strong: #cbd5e1;

  --app-bg: radial-gradient(120% 75% at 82% -8%, rgba(99,102,241,0.06), transparent 52%), #f8fafc;
  --bar-bg: rgba(255,255,255,0.80);
  --th-bg:  rgba(241,245,249,0.96);

  --text:   #1e293b;
  --dim:    #64748b;
  --faint:  #94a3b8;
  --strong: #0f172a;

  --accent:    #6366f1;
  --accent-2:  #4f46e5;
  --accent-soft: rgba(99,102,241,0.12);
  --grad: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  --grad-soft: linear-gradient(135deg, rgba(99,102,241,0.14), rgba(79,70,229,0.06));

  --ok:    #51d39a;
  --ok-soft: rgba(81,211,154,0.14);
  --warn:  #f6b545;
  --danger:#ff5e5e;
  --info:  #6db5ff;

  --radius:    14px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --maxw:      1160px;
}

html.dark {
  /* ── DARK ──────────────────────────────────────────────────────────────── */
  --bg:            #000000;
  --bg-2:          #0a0a0a;
  --glass:         rgba(255,255,255,0.045);
  --glass-2:       rgba(255,255,255,0.07);
  --glass-strong:  rgba(255,255,255,0.10);
  --border:        rgba(255,255,255,0.10);
  --border-strong: rgba(255,255,255,0.20);

  --app-bg: radial-gradient(120% 75% at 82% -8%, rgba(99,102,241,0.10), transparent 52%), #000000;
  --bar-bg: rgba(0,0,0,0.72);
  --th-bg:  rgba(10,10,10,0.96);

  --text:   #ededed;
  --dim:    #a0a0a0;
  --faint:  #6b6b6b;
  --strong: #ffffff;

  --accent:    #818cf8;
  --accent-2:  #6366f1;
  --accent-soft: rgba(129,140,248,0.16);
  --grad: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  --grad-soft: linear-gradient(135deg, rgba(99,102,241,0.22), rgba(79,70,229,0.10));
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background: var(--app-bg);
  transition: background-color .3s ease, color .3s ease;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
::selection { background: rgba(99,102,241,0.3); }

/* ── Icons ─────────────────────────────────────────────────────────────── */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 17px; height: 17px; flex-shrink: 0; }

/* ── Brand ─────────────────────────────────────────────────────────────── */
.mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 9px; color: #fff;
  background: var(--grad); box-shadow: 0 4px 14px rgba(99,102,241,0.35);
}
.mark svg { width: 16px; height: 16px; }
.brand { font-weight: 700; letter-spacing: -0.02em; font-size: 19px; color: var(--strong); }
.brand-row { display: inline-flex; align-items: center; gap: 10px; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--radius);
  font-size: 13.5px; font-weight: 600; line-height: 1; white-space: nowrap;
  border: 1px solid transparent; cursor: pointer; font-family: inherit;
  transition: transform .12s ease, background .14s ease, border-color .14s ease, color .14s ease, box-shadow .14s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(99,102,241,0.32); }
.btn-primary:hover { box-shadow: 0 8px 24px rgba(99,102,241,0.45); }
.btn-ghost { background: var(--glass); border-color: var(--border); color: var(--dim); }
.btn-ghost:hover { background: var(--glass-2); border-color: var(--border-strong); color: var(--text); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; }
.btn-icon { padding: 0; width: 34px; }
.btn-sm.btn-icon { width: 32px; }
.btn[disabled] { opacity: 0.4; pointer-events: none; }
.btn-ok { background: linear-gradient(135deg,#34d399,#10b981); color:#fff; box-shadow: 0 6px 18px rgba(16,185,129,0.32); }

/* ── Badge / chip ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 11px;
  border: 1px solid var(--border); border-radius: 999px;
  font-size: 11.5px; color: var(--dim); background: var(--glass);
}
.badge.ok { border-color: rgba(81,211,154,0.45); color: var(--ok); }
.badge.warn { border-color: rgba(246,181,69,0.45); color: var(--warn); }

/* ── App shell ─────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20; height: 60px;
  display: flex; align-items: center; justify-content: space-between; padding: 0 22px;
  background: var(--bar-bg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.topbar .meta { color: var(--faint); font-size: 12.5px; margin-left: 4px; }
.top-left { display: flex; align-items: center; gap: 12px; }
.top-right { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--dim); }
.top-right .user { color: var(--text); }

.layout { display: flex; min-height: calc(100vh - 60px); }

/* Sidebar: persistent left rail on desktop, off-canvas drawer on mobile. */
.side {
  width: 232px; flex-shrink: 0; padding: 22px 14px;
  display: flex; flex-direction: column; gap: 3px;
  border-right: 1px solid var(--border);
}
.side-head { display: none; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); padding: 8px 12px 8px; }
.nav {
  display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 14px; border-radius: var(--radius);
  color: var(--dim); font-size: 14px; font-weight: 500; cursor: pointer; user-select: none;
  transition: background .13s ease, color .13s ease;
}
.nav .ic { color: var(--faint); }
.nav:hover { background: var(--glass-2); color: var(--text); }
.nav:hover .ic { color: var(--dim); }
.nav.active { background: var(--grad-soft); color: var(--strong); cursor: default; }
.nav.active .ic { color: var(--accent); }
.side-foot { margin-top: auto; padding: 14px 12px 4px; color: var(--faint); font-size: 11.5px; line-height: 1.6; }
.nav-backdrop {
  position: fixed; inset: 0; z-index: 55; background: rgba(2, 6, 23, 0.5);
  opacity: 0; pointer-events: none; transition: opacity .22s ease;
}
#nav-toggle { display: none; }

.main { flex: 1; padding: 38px 40px 60px; max-width: var(--maxw); width: 100%; margin: 0 auto; min-width: 0; }
.view { display: none; }
.view.active { display: block; animation: fadein .18s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── Headings ──────────────────────────────────────────────────────────── */
.h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; margin: 4px 0 8px; color: var(--strong); line-height: 1.12; }
.lead { color: var(--dim); font-size: 15px; line-height: 1.6; max-width: 620px; margin: 0; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 22px; }
.view-head .h1 { margin: 0; }
.view-head .lead { margin-top: 6px; font-size: 13px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--faint); margin: 28px 0 12px; display: flex; align-items: center; gap: 8px; }
.section-title:first-child { margin-top: 0; }

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--glass); border: 1px solid var(--border); border-radius: var(--radius-lg);
  backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2);
}
.card-pad { padding: 22px; }
.card h3 { margin: 0 0 4px; font-size: 16px; font-weight: 700; color: var(--strong); display: flex; align-items: center; gap: 9px; }
.card h3 .ic { color: var(--accent); }
.card .desc { color: var(--dim); font-size: 13px; margin: 0 0 18px; line-height: 1.55; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }

/* KPI card */
.kpi { padding: 18px; border-radius: var(--radius-lg); }
.kpi .lbl { font-size: 12.5px; color: var(--dim); display: flex; align-items: center; gap: 8px; }
.kpi .lbl .ic { width: 15px; height: 15px; color: var(--accent); }
.kpi .num { font-size: 32px; font-weight: 800; letter-spacing: -0.03em; color: var(--strong); margin-top: 10px; line-height: 1; }
.kpi .sub { font-size: 12px; color: var(--faint); margin-top: 7px; }
.kpi .sub .up { color: var(--ok); font-weight: 600; }
.kpi .sub .down { color: var(--danger); font-weight: 600; }

/* status tiles */
.stile { padding: 16px 18px; border-radius: var(--radius-lg); }
.stile .row { display: flex; align-items: center; gap: 9px; color: var(--dim); font-size: 13px; font-weight: 500; }
.stile .row .ic { width: 16px; height: 16px; color: var(--faint); }
.stile .val { font-size: 15px; font-weight: 700; margin-top: 8px; color: var(--strong); display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dot-ok { background: var(--ok); box-shadow: 0 0 0 4px rgba(81,211,154,0.18); }
.dot-warn { background: var(--warn); box-shadow: 0 0 0 4px rgba(246,181,69,0.18); }
.dot-muted { background: var(--faint); }

/* ── Pills (segmented filters) ─────────────────────────────────────────── */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  height: 36px; padding: 0 15px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--glass); color: var(--dim); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.tab:hover { color: var(--text); border-color: var(--border-strong); }
.tab.active { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 4px 12px rgba(99,102,241,0.3); }

/* ── Charts (inline SVG) ───────────────────────────────────────────────── */
.chart-card { padding: 18px; border-radius: var(--radius-lg); }
.chart-card .ct { font-size: 14px; font-weight: 600; color: var(--strong); margin: 0 0 14px; display: flex; align-items: center; gap: 9px; }
.chart-card .ct .ic { width: 16px; height: 16px; color: var(--accent); }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-lbl { fill: var(--faint); font-size: 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--dim); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.barlist { display: flex; flex-direction: column; gap: 11px; }
.barlist .bl-row { display: grid; grid-template-columns: 120px 1fr 42px; align-items: center; gap: 12px; }
.barlist .bl-name { font-size: 12.5px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barlist .bl-track { height: 10px; border-radius: 999px; background: var(--glass-strong); overflow: hidden; }
.barlist .bl-fill { height: 100%; border-radius: 999px; background: var(--grad); }
.barlist .bl-val { font-size: 12.5px; color: var(--strong); font-weight: 600; text-align: right; }

/* activity feed */
.feed { padding: 8px 6px; border-radius: var(--radius-lg); }
.feed-row { display: flex; align-items: center; gap: 12px; padding: 9px 12px; }
.feed-row .fdot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.feed-row .ft { font-size: 13.5px; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-row .fmeta { font-size: 11.5px; color: var(--faint); white-space: nowrap; }
.feed-row .fwho { font-size: 11.5px; color: var(--dim); white-space: nowrap; max-width: 30%; overflow: hidden; text-overflow: ellipsis; }

/* ── Tables ────────────────────────────────────────────────────────────── */
.table-wrap {
  border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: auto;
  background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  position: sticky; top: 0; z-index: 1; text-align: left; white-space: nowrap;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint);
  padding: 12px 14px; background: var(--th-bg); border-bottom: 1px solid var(--border);
}
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--glass-2); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; color: var(--dim); }

/* ── Inputs / forms ────────────────────────────────────────────────────── */
.input {
  width: 100%; height: 38px; padding: 0 12px; font: inherit; font-size: 14px;
  color: var(--text); background: var(--glass); border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color .12s ease, background .12s ease;
}
.input::placeholder { color: var(--faint); }
.input:hover { border-color: var(--border-strong); }
.input:focus { outline: none; border-color: var(--accent); background: var(--glass-2); }
textarea.input { height: auto; min-height: 76px; padding: 10px 12px; resize: vertical; }
.select {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='none' stroke='%2394a3b8' stroke-width='1.4' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.select option { background: var(--bg-2); color: var(--text); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field .flabel { font-size: 12px; color: var(--faint); font-weight: 500; }
.field .fhint { font-size: 11.5px; color: var(--faint); }
.field.span-2 { grid-column: span 2; }

/* toggle switch */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.switch-row:last-of-type { border-bottom: 0; }
.switch-row .st { font-size: 13.5px; color: var(--text); font-weight: 500; }
.switch-row .sd { font-size: 12px; color: var(--faint); margin-top: 1px; }
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch .knob {
  position: absolute; inset: 0; border-radius: 999px; background: var(--glass-strong);
  border: 1px solid var(--border); transition: background .15s ease;
}
.switch .knob::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.25); transition: transform .15s ease;
}
.switch input:checked + .knob { background: var(--grad); border-color: transparent; }
.switch input:checked + .knob::after { transform: translateX(18px); }

/* ── Integration: endpoints & API key ──────────────────────────────────── */
.endpoints { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.ep-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--glass); }
.ep-row:last-child { border-bottom: 0; }
.ep-method {
  width: 52px; text-align: center; padding: 3px 0; border-radius: 7px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 10.5px; font-weight: 700;
}
.ep-method.get  { background: rgba(109,181,255,0.16); color: var(--info); }
.ep-method.post { background: rgba(81,211,154,0.16);  color: var(--ok); }
.ep-path { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ep-desc { font-size: 11.5px; color: var(--faint); white-space: nowrap; }

.keybox {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--glass-2);
}
.keybox .kv {
  flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px; color: var(--strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.keybox .kv.empty { color: var(--faint); font-style: italic; font-family: inherit; }

/* ── Integration: dropzone ─────────────────────────────────────────────── */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 38px 20px; text-align: center; cursor: pointer;
  border: 2px dashed var(--border-strong); border-radius: var(--radius-lg);
  background: var(--glass-2); color: var(--dim);
  transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .dz-ic {
  width: 46px; height: 46px; border-radius: 13px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--grad-soft); color: var(--accent);
}
.dropzone .dz-ic .ic { width: 22px; height: 22px; }
.dropzone .dz-t { font-size: 14px; font-weight: 600; color: var(--text); }
.dropzone .dz-d { font-size: 12px; color: var(--faint); }
.dropzone.has-file { border-style: solid; border-color: rgba(81,211,154,0.5); background: var(--ok-soft); }
.dropzone.has-file .dz-ic { background: rgba(81,211,154,0.18); color: var(--ok); }

/* progress bar */
.progress { height: 8px; border-radius: 999px; background: var(--glass-strong); overflow: hidden; }
.progress .p-fill { height: 100%; width: 0; border-radius: 999px; background: var(--grad); transition: width .3s ease; }

/* success panel */
.success-panel {
  display: flex; align-items: flex-start; gap: 13px; padding: 16px 18px;
  border: 1px solid rgba(81,211,154,0.4); border-radius: var(--radius-lg); background: var(--ok-soft);
}
.success-panel .sp-ic {
  width: 36px; height: 36px; flex-shrink: 0; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center;
  background: rgba(81,211,154,0.2); color: var(--ok);
}
.success-panel .sp-t { font-size: 14px; font-weight: 700; color: var(--strong); }
.success-panel .sp-d { font-size: 12.5px; color: var(--dim); margin-top: 2px; line-height: 1.55; }
.success-panel .sp-d .mono { color: var(--text); }

/* steps (how it works) */
.steps { display: flex; flex-direction: column; gap: 0; }
.step { display: flex; gap: 14px; padding: 10px 0; }
.step .sn {
  width: 26px; height: 26px; flex-shrink: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700;
}
.step .sb .st { font-size: 13.5px; font-weight: 600; color: var(--text); }
.step .sb .sd { font-size: 12.5px; color: var(--faint); }

/* ── Tools: deploy cards ───────────────────────────────────────────────── */
.deploy-head { display: flex; align-items: center; gap: 13px; margin-bottom: 16px; }
.deploy-head .dh-ic {
  width: 44px; height: 44px; flex-shrink: 0; border-radius: 13px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--grad-soft); color: var(--accent);
}
.deploy-head .dh-ic .ic { width: 21px; height: 21px; }
.deploy-head .dh-t { font-size: 16px; font-weight: 700; color: var(--strong); }
.deploy-head .dh-d { font-size: 12.5px; color: var(--faint); margin-top: 1px; }
.deploy-foot { display: flex; align-items: center; gap: 12px; margin-top: 18px; }

/* theme swatches */
.swatches { display: flex; gap: 9px; }
.swatch { width: 30px; height: 30px; border-radius: 9px; cursor: pointer; border: 2px solid transparent; transition: transform .1s ease, border-color .12s ease; }
.swatch:hover { transform: scale(1.08); }
.swatch.active { border-color: var(--strong); }

/* ── Toast ─────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(8px); z-index: 80;
  padding: 12px 18px; border-radius: var(--radius); max-width: 90vw;
  background: rgba(17,24,39,0.96); border: 1px solid rgba(255,255,255,0.14); color: #f1f5f9; font-size: 13.5px; font-weight: 500;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease;
  box-shadow: 0 12px 36px rgba(0,0,0,0.5);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok  { border-color: rgba(81,211,154,0.55); }
.toast.err { border-color: rgba(255,94,94,0.55); }

.hidden { display: none !important; }
.mt { margin-top: 14px; }
.mt-lg { margin-top: 22px; }

/* spinner (fake async) */
.spin { width: 15px; height: 15px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.35); border-top-color: #fff; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ───────────────────────────────────────────────────────────────────────
   RESPONSIVE
   ─────────────────────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .main { padding: 30px 26px 50px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }

  /* sidebar becomes an off-canvas drawer */
  #nav-toggle { display: inline-flex; }
  .side {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
    width: 248px; max-width: 84vw; padding: 16px 14px;
    background: var(--bg-2); border-right: 1px solid var(--border);
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(0,0,0,0.18); overflow-y: auto;
  }
  body.nav-open .side { transform: translateX(0); }
  body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
  .side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
  .side-head .nav-label { padding: 8px 4px 8px 12px; }
}

@media (max-width: 720px) {
  .topbar { padding: 0 15px; height: 56px; }
  .topbar .meta { display: none; }
  .top-right .user { display: none; }
  .top-right .badge { display: none; } /* status is also shown on the dashboard tiles */
  .main { padding: 22px 16px 40px; }
  .h1 { font-size: 23px; }
  .view-head { gap: 12px; margin-bottom: 18px; align-items: stretch; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: auto; }
  .btn { height: 42px; }
  .tab { height: 38px; }
  .input, .select { font-size: 16px; height: 42px; }
  .barlist .bl-row { grid-template-columns: 92px 1fr 38px; }
  .ep-desc { display: none; }
  .deploy-foot { flex-direction: column; align-items: stretch; }

  /* Wide tables → stacked label/value cards, so there's no sideways scrolling on a phone.
     Add class "stack" to the table and "stack-wrap" to its .table-wrap. */
  .stack-wrap { border: 0; background: transparent; overflow: visible; }
  .table.stack thead { display: none; }
  .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
  .table.stack tr {
    padding: 6px 14px; margin-bottom: 10px; background: var(--glass);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
  }
  .table.stack tbody tr:hover { background: var(--glass); }
  .table.stack td {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 9px 0; border: 0; border-bottom: 1px solid var(--border); text-align: right; white-space: normal;
  }
  .table.stack td:last-child { border-bottom: 0; }
  .table.stack td::before {
    content: attr(data-label); flex: 0 0 36%; text-align: left;
    color: var(--faint); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  }
}
