/* =============================================================
   Factory Control Panel — Dark NOC theme
   Built on Material Tailwind tokens (colors/type/radius/shadow).
   Light MT is the source palette; surfaces are re-anchored dark.
   ============================================================= */

@font-face {
  font-family: "Roboto";
  src: url("fonts/Roboto-VariableFont_wdth_wght.ttf") format("truetype-variations"),
       url("fonts/Roboto-VariableFont_wdth_wght.ttf") format("truetype");
  font-weight: 100 900;
  font-stretch: 75% 100%;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Roboto Slab";
  src: url("fonts/RobotoSlab-VariableFont_wght.ttf") format("truetype-variations"),
       url("fonts/RobotoSlab-VariableFont_wght.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* ---- Material Tailwind source accents (500s) ---- */
  --mt-success: #4caf50;
  --mt-info:    #2196f3;
  --mt-warning: #ff9800;
  --mt-error:   #f44336;
  --mt-green:   #4caf50;
  --mt-blue:    #2196f3;
  --mt-light-blue: #03a9f4;
  --mt-cyan:    #00bcd4;
  --mt-teal:    #009688;
  --mt-amber:   #ffc107;
  --mt-orange:  #ff9800;
  --mt-deep-orange: #ff5722;
  --mt-red:     #f44336;
  --mt-purple:  #9c27b0;
  --mt-deep-purple: #673ab7;
  --mt-indigo:  #3f51b5;
  --mt-pink:    #e91e63;
  --mt-lime:    #cddc39;
  --mt-light-green: #8bc34a;
  --mt-brown:   #795548;
  --mt-blue-gray-300: #90a4ae;
  --mt-blue-gray-400: #78909c;
  --mt-blue-gray-500: #607d8b;

  /* ---- Dark NOC surfaces (anchored on slate / blue-gray) ---- */
  --bg:        #090d13;
  --bg-grad-a: #0b1018;
  --bg-grad-b: #080b11;
  --surface:   #11171f;   /* cards / panels */
  --surface-2: #161d27;   /* raised within a card */
  --surface-3: #1d2531;   /* hover / inset rows */
  --surface-inset: #0c1117;
  --sidebar:   #0c1118;

  --border:        rgba(176, 190, 197, 0.12);  /* blue-gray tint */
  --border-2:      rgba(176, 190, 197, 0.08);
  --border-strong: rgba(176, 190, 197, 0.22);

  --fg:   #e8edf2;
  --fg-2: #9aabba;   /* blue-gray secondary */
  --fg-3: #677787;   /* tertiary */
  --fg-4: #4a5663;   /* faint / disabled */

  /* ---- Type ---- */
  --font-sans: "Roboto", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Roboto Slab", ui-serif, Georgia, serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  --fw-light: 300;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  /* ---- Radius (MT) ---- */
  --r-sm: 0.125rem;
  --r:    0.25rem;
  --r-md: 0.375rem;
  --r-lg: 0.5rem;
  --r-xl: 0.75rem;
  --r-2xl: 1rem;
  --r-full: 9999px;

  --border-w: 1.5px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur: 200ms;

  /* tinted glows */
  --glow-green: 0 0 0 1px rgba(76,175,80,.25), 0 4px 16px -4px rgba(76,175,80,.35);
  --shadow-card: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-weight: var(--fw-light);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#root { height: 100%; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #2a3543; background-clip: content-box; }

/* ============================================================
   LAYOUT SHELL
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  height: 100%;
  overflow: hidden;
}
.app.collapsed { grid-template-columns: 72px 1fr; }

/* ---- Sidebar ---- */
.sidebar {
  background: var(--sidebar);
  border-right: var(--border-w) solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px;
  border-bottom: var(--border-w) solid var(--border);
  min-height: 65px;
}
.brand-mark {
  width: 34px; height: 34px; flex: none;
  border-radius: var(--r-lg);
  background: linear-gradient(150deg, var(--mt-green), #2e7d32);
  display: grid; place-items: center;
  box-shadow: 0 0 0 1px rgba(76,175,80,.35), 0 4px 14px -4px rgba(76,175,80,.5);
  position: relative;
}
.brand-mark svg { width: 20px; height: 20px; color: #08130b; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-title { font-size: 14px; font-weight: var(--fw-bold); letter-spacing: .2px; color: var(--fg); white-space: nowrap; }
.brand-sub { font-size: 11px; color: var(--fg-3); font-weight: var(--fw-regular); white-space: nowrap; }
.collapsed .brand-text { display: none; }

.nav { padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; min-height: 0; }
.nav-label { font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--fg-4); font-weight: var(--fw-semibold); padding: 14px 12px 6px; }
.collapsed .nav-label { text-align: center; padding: 14px 0 6px; font-size: 8px; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: var(--r-lg);
  color: var(--fg-2);
  font-size: 13.5px; font-weight: var(--fw-medium);
  cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--fg); }
.nav-item.active { background: linear-gradient(90deg, rgba(76,175,80,.16), rgba(76,175,80,.04)); color: #cdeccf; }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 3px;
  background: var(--mt-green); border-radius: 0 3px 3px 0;
}
.nav-item svg { width: 19px; height: 19px; flex: none; }
.nav-item .nav-badge {
  margin-left: auto; font-size: 11px; font-weight: var(--fw-bold);
  background: var(--surface-3); color: var(--fg-2);
  border-radius: var(--r-full); padding: 1px 8px; min-width: 22px; text-align: center;
}
.nav-item.active .nav-badge { background: rgba(76,175,80,.22); color: #bfe6c1; }
.nav-item .nav-badge.alert { background: rgba(244,67,54,.2); color: #ff9b91; }
.collapsed .nav-item { justify-content: center; padding: 11px 0; }
.collapsed .nav-item span.nav-text, .collapsed .nav-item .nav-badge { display: none; }
.collapsed .nav-item.active::before { left: -12px; }

.sidebar-foot { padding: 12px; border-top: var(--border-w) solid var(--border); }

/* ---- Main column ---- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }

.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 0 24px;
  min-height: 65px;
  border-bottom: var(--border-w) solid var(--border);
  background: linear-gradient(180deg, rgba(20,27,37,.6), rgba(11,16,24,.4));
  backdrop-filter: none;
}
.topbar h1 { font-size: 19px; font-weight: var(--fw-semibold); margin: 0; letter-spacing: .2px; }
.topbar .crumb-sub { font-size: 12.5px; color: var(--fg-3); margin-top: 1px; }
.topbar-spacer { flex: 1; }

.icon-btn {
  width: 36px; height: 36px; border-radius: var(--r-lg);
  display: grid; place-items: center; cursor: pointer;
  background: var(--surface-2); border: var(--border-w) solid var(--border); color: var(--fg-2);
  transition: all var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--fg); border-color: var(--border-strong); }
.icon-btn svg { width: 18px; height: 18px; }

.content {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(33,150,243,.05), transparent 60%),
    radial-gradient(900px 500px at -5% 110%, rgba(76,175,80,.05), transparent 55%);
}
.content-inner { max-width: 1640px; margin: 0 auto; }

/* ============================================================
   CONNECTION / LIVE INDICATOR
   ============================================================ */
.conn {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 13px 7px 11px; border-radius: var(--r-full);
  background: var(--surface-2); border: var(--border-w) solid var(--border);
  font-size: 12.5px; font-weight: var(--fw-medium); color: var(--fg-2);
}
.conn .dot { width: 9px; height: 9px; border-radius: 50%; position: relative; }
.conn.live .dot { background: var(--mt-green); box-shadow: 0 0 0 0 rgba(76,175,80,.6); animation: pulse 2s infinite; }
.conn.stalled .dot { background: var(--mt-orange); }
.conn.live { color: #bfe6c1; }
.conn .conn-meta { color: var(--fg-3); font-weight: var(--fw-regular); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(76,175,80,.55); }
  70% { box-shadow: 0 0 0 7px rgba(76,175,80,0); }
  100% { box-shadow: 0 0 0 0 rgba(76,175,80,0); }
}

/* ============================================================
   CARDS / PRIMITIVES
   ============================================================ */
.card {
  background: var(--surface);
  border: var(--border-w) solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-card);
}
.card-pad { padding: 18px 20px; }
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 20px; border-bottom: var(--border-w) solid var(--border);
}
.card-head h3 { margin: 0; font-size: 14px; font-weight: var(--fw-semibold); letter-spacing: .2px; }
.card-head .sub { font-size: 12px; color: var(--fg-3); }

.section-title { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }
.section-title h2 { font-size: 15px; font-weight: var(--fw-semibold); margin: 0; letter-spacing: .3px; }
.section-title .kicker {
  font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--fg-4); font-weight: var(--fw-semibold);
}

/* ---- Badge / pill ---- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: var(--fw-bold); letter-spacing: .4px;
  padding: 3px 9px; border-radius: var(--r-full);
  text-transform: uppercase; white-space: nowrap;
  border: 1px solid transparent;
}
.badge svg { width: 12px; height: 12px; }
.badge.green  { background: rgba(76,175,80,.14);  color: #74d27a; border-color: rgba(76,175,80,.3); }
.badge.red    { background: rgba(244,67,54,.14);  color: #ff8a7d; border-color: rgba(244,67,54,.3); }
.badge.amber  { background: rgba(255,193,7,.14);  color: #ffcf4d; border-color: rgba(255,193,7,.3); }
.badge.orange { background: rgba(255,152,0,.14);  color: #ffb24d; border-color: rgba(255,152,0,.3); }
.badge.blue   { background: rgba(33,150,243,.14); color: #67b6f7; border-color: rgba(33,150,243,.3); }
.badge.cyan   { background: rgba(0,188,212,.14);  color: #46d3e6; border-color: rgba(0,188,212,.3); }
.badge.purple { background: rgba(156,39,176,.16); color: #d088e0; border-color: rgba(156,39,176,.32); }
.badge.gray   { background: rgba(176,190,197,.1); color: var(--fg-2); border-color: var(--border-strong); }
.badge.slate  { background: var(--surface-3); color: var(--fg-2); border-color: var(--border); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: var(--fw-medium);
  padding: 4px 10px; border-radius: var(--r-full);
  background: var(--surface-2); border: var(--border-w) solid var(--border); color: var(--fg-2);
}

/* ---- LLM credit pill (topbar) ---- */
.credit-pill { font-variant-numeric: tabular-nums; cursor: default; }
.credit-green  { color: var(--mt-green); border-color: color-mix(in srgb, var(--mt-green) 45%, transparent); background: color-mix(in srgb, var(--mt-green) 12%, var(--surface-2)); }
.credit-amber  { color: var(--mt-amber); border-color: color-mix(in srgb, var(--mt-amber) 55%, transparent); background: color-mix(in srgb, var(--mt-amber) 16%, var(--surface-2)); }
.credit-red    { color: var(--mt-red);   border-color: color-mix(in srgb, var(--mt-red) 60%, transparent);   background: color-mix(in srgb, var(--mt-red) 18%, var(--surface-2)); animation: creditPulse 1.6s ease-in-out infinite; }
.credit-unknown { color: var(--fg-3); }

/* ---- PRD Council form controls ---- */
.cn-input, .cn-textarea {
  width: 100%; box-sizing: border-box; background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 8px; color: var(--fg);
  font-size: 13px; padding: 9px 11px; outline: none; font-family: inherit;
}
.cn-textarea { resize: vertical; line-height: 1.5; font-family: var(--font-mono); }
.cn-input:focus, .cn-textarea:focus { border-color: var(--mt-cyan, #4dd0e1); }
.cn-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-3); margin: 6px 0; }
.cn-btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  background: var(--surface-3); border: 1px solid var(--border); color: var(--fg-2);
  border-radius: 8px; padding: 8px 14px; font-size: 13px; font-weight: var(--fw-medium);
}
.cn-btn:hover { background: var(--surface-2); color: var(--fg); }
.cn-btn.primary { background: var(--mt-green); border-color: var(--mt-green); color: #06281a; }
.cn-btn.primary:hover { filter: brightness(1.08); }
.cn-btn:disabled { opacity: .5; cursor: default; }
@keyframes creditPulse { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--mt-red) 55%, transparent); } 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--mt-red) 0%, transparent); } }

/* ---- Status dot ---- */
.sdot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.sdot.green  { background: var(--mt-green); }
.sdot.red    { background: var(--mt-red); }
.sdot.amber  { background: var(--mt-amber); }
.sdot.orange { background: var(--mt-orange); }
.sdot.blue   { background: var(--mt-blue); }
.sdot.gray   { background: var(--fg-4); }
.sdot.pulsing { animation: dotpulse 1.6s infinite; }
@keyframes dotpulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  font-family: var(--font-sans); font-size: 12.5px; font-weight: var(--fw-bold);
  text-transform: capitalize; letter-spacing: .2px;
  padding: 8px 15px; border-radius: var(--r-lg); cursor: pointer;
  border: var(--border-w) solid var(--border); background: var(--surface-2); color: var(--fg);
  transition: all var(--dur) var(--ease); white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn svg { width: 15px; height: 15px; }
.btn.sm { padding: 5px 11px; font-size: 11.5px; }
.btn.active { background: rgba(76,175,80,.16); border-color: rgba(76,175,80,.4); color: #bfe6c1; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--fg-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--fg); }

/* segmented control */
.seg { display: inline-flex; background: var(--surface-inset); border: var(--border-w) solid var(--border); border-radius: var(--r-lg); padding: 3px; gap: 2px; }
.seg button {
  border: none; background: none; cursor: pointer; color: var(--fg-3);
  font-family: var(--font-sans); font-size: 12px; font-weight: var(--fw-medium);
  padding: 5px 12px; border-radius: var(--r-md); transition: all var(--dur) var(--ease);
  display: inline-flex; align-items: center; gap: 6px;
}
.seg button:hover { color: var(--fg); }
.seg button.on { background: var(--surface-3); color: var(--fg); box-shadow: var(--shadow-card); }

/* ---- Stat tile ---- */
.statgrid { display: grid; gap: 14px; }
.stat {
  background: var(--surface); border: var(--border-w) solid var(--border);
  border-radius: var(--r-xl); padding: 16px 18px; position: relative; overflow: hidden;
}
.stat .stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat .stat-label { font-size: 11.5px; color: var(--fg-3); font-weight: var(--fw-medium); text-transform: uppercase; letter-spacing: .6px; }
.stat .stat-ico { width: 30px; height: 30px; border-radius: var(--r-lg); display: grid; place-items: center; }
.stat .stat-ico svg { width: 17px; height: 17px; }
.stat .stat-num { font-size: 30px; font-weight: var(--fw-bold); margin-top: 8px; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.stat .stat-foot { font-size: 12px; color: var(--fg-3); margin-top: 2px; }
.stat .stat-foot strong { font-weight: var(--fw-semibold); }

/* ---- Tables / rows ---- */
.row-list { display: flex; flex-direction: column; }
.lrow {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px; border-bottom: var(--border-w) solid var(--border-2);
  transition: background var(--dur) var(--ease);
}
.lrow:last-child { border-bottom: none; }
.lrow:hover { background: var(--surface-2); }

.mono { font-family: var(--font-mono); }
.tnum { font-variant-numeric: tabular-nums; }

/* code chip */
.code {
  font-family: var(--font-mono); font-size: 12px;
  background: var(--surface-inset); border: 1px solid var(--border);
  color: #b9c6d3; padding: 1px 6px; border-radius: var(--r); white-space: nowrap;
}

/* progress / meter */
.meter { height: 7px; border-radius: var(--r-full); background: var(--surface-inset); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: var(--r-full); transition: width 400ms var(--ease); }

/* utility */
.flex { display: flex; }
.col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--fg-3); }
.muted2 { color: var(--fg-4); }
.tiny { font-size: 11.5px; }
.sm { font-size: 12.5px; }
.semib { font-weight: var(--fw-semibold); }
.bold { font-weight: var(--fw-bold); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }

.grid { display: grid; }
.gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; }
.gap-12 { gap: 12px; } .gap-14 { gap: 14px; } .gap-16 { gap: 16px; } .gap-20 { gap: 20px; }
.mt-2 { margin-top: 2px; } .mt-4 { margin-top: 4px; } .mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; } .mt-24 { margin-top: 24px; }
.mb-4 { margin-bottom: 4px; } .mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }

/* entrance for streamed items */
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-6px); background: rgba(76,175,80,.08); }
  to { opacity: 1; transform: translateY(0); }
}
.stream-in { animation: slideIn 360ms var(--ease); }

@keyframes flash {
  0% { background: rgba(76,175,80,.18); }
  100% { background: transparent; }
}
.flash { animation: flash 900ms var(--ease); }

/* count tick */
@keyframes tick { 0% { transform: translateY(4px); opacity: .3; } 100% { transform: translateY(0); opacity: 1; } }
.ticked { animation: tick 280ms var(--ease); }

/* fade for tab switches */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.panel-enter { animation: fadeUp 280ms var(--ease); }

/* tooltip-ish helper */
.dim-line { opacity: .42; }

/* log controls */
.log-select {
  font-family: var(--font-sans); font-size: 12px; font-weight: 500;
  background: var(--surface-inset); color: var(--fg-2);
  border: var(--border-w) solid var(--border); border-radius: var(--r-lg);
  padding: 6px 10px; cursor: pointer; outline: none;
}
.log-search {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface-inset); border: var(--border-w) solid var(--border);
  border-radius: var(--r-lg); padding: 0 10px; color: var(--fg-3);
}
.log-search input {
  background: none; border: none; outline: none; color: var(--fg);
  font-family: var(--font-mono); font-size: 12px; padding: 7px 0; width: 110px;
}
.log-search input::placeholder { color: var(--fg-4); }
.logline:hover { background: rgba(176,190,197,.05); }

/* tree */
.tree-row { display: flex; align-items: center; gap: 9px; padding: 7px 0; cursor: default; }
.tree-toggle { width: 18px; height: 18px; display: grid; place-items: center; color: var(--fg-3); cursor: pointer; border-radius: 4px; flex: none; }
.tree-toggle:hover { background: var(--surface-3); color: var(--fg); }
.tree-guide { border-left: 1.5px solid var(--border); margin-left: 9px; padding-left: 14px; }

/* ───────── responsive: mobile & iPad (Claude Design handoff 2026-06-06) ───────── */
/* bottom tab bar — hidden on desktop, shown on phone */
.mobile-tabbar { display: none; }

/* Tablet rail collapse: ≤1100px the side rail goes icon-only */
@media (max-width: 1100px) {
  .app { grid-template-columns: 72px 1fr; }
  .brand-text { display: none; }
  .nav-item { justify-content: center; padding: 11px 0; }
  .nav-item span.nav-text, .nav-item .nav-badge { display: none; }
  .nav-label { text-align: center; padding: 14px 0 6px; }
}
/* iPad: stat grids + split layouts ease down (inline grids need !important) */
@media (max-width: 1024px) {
  .statgrid { grid-template-columns: repeat(3, 1fr) !important; }
}
@media (max-width: 920px) {
  .lanes, .split-lessons, .split-2 { grid-template-columns: 1fr !important; }
  /* the panel's two-column inner grids (1fr 360px/380px etc.) stack on tablet */
  .grid.gap-20 { grid-template-columns: 1fr !important; }
}

/* ───────── Phone: ≤720px → bottom tab bar, no side rail ───────── */
@media (max-width: 720px) {
  .app, .app.collapsed { grid-template-columns: 1fr !important; }
  .sidebar { display: none; }

  .topbar { padding: 0 16px; min-height: 58px; gap: 12px; }
  .topbar h1 { font-size: 16px; }
  .topbar .crumb-sub { display: none; }
  .topbar .icon-btn { display: none; }
  .topbar .pill { display: none; }   /* hide uptime/:port pills; keep credit + conn */
  .topbar .credit-pill { display: inline-flex; }

  .content { padding: 14px 13px calc(76px + env(safe-area-inset-bottom, 0px)); }

  .statgrid { grid-template-columns: repeat(2, 1fr) !important; gap: 11px; }
  /* any 2-col inner layout stacks on phone */
  .grid.gap-20 { grid-template-columns: 1fr !important; }
  .stat { padding: 13px 14px; }
  .stat .stat-num { font-size: 25px; }
  .card { padding: 15px !important; }

  /* bottom tab bar */
  .mobile-tabbar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 900;
    background: rgba(12,17,24,.94);
    border-top: var(--border-w, 1px) solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    backdrop-filter: blur(8px);
  }
  .mtab {
    border: none; background: none; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 2px; border-radius: 10px; color: var(--fg-3);
    font-size: 9.5px; font-weight: 600; letter-spacing: .1px;
    position: relative;
  }
  .mtab svg { width: 21px; height: 21px; }
  .mtab.active { color: #9fe3a3; }
  .mtab.active::after {
    content: ""; position: absolute; top: 2px; height: 3px; width: 22px;
    border-radius: 0 0 3px 3px; background: var(--mt-green);
    box-shadow: 0 0 10px rgba(76,175,80,.6);
  }
  .mtab .mtab-badge {
    position: absolute; top: 2px; right: 50%; transform: translateX(16px);
    background: var(--mt-red); color: #fff; font-size: 8.5px; font-weight: 700;
    min-width: 15px; height: 15px; border-radius: 999px; display: grid; place-items: center;
    padding: 0 3px; border: 1.5px solid #0c1118;
  }
}

/* Very small phones: stats single-column */
@media (max-width: 380px) {
  .statgrid { grid-template-columns: 1fr !important; }
  .mtab { font-size: 8.5px; }
  .mtab svg { width: 19px; height: 19px; }
}
/* Touch niceties */
@media (hover: none) and (pointer: coarse) {
  .cn-btn, .nav-item, .seg button, .mtab, .icon-btn { -webkit-tap-highlight-color: transparent; }
}
