/* ==========================================================================
   Design tokens. Light is the default; every colour below is routed through a
   var so the dark theme only has to redefine this one block.
   ========================================================================== */
:root {
  color-scheme: light dark;
  --autofill-bg: #FFFFFF;
  --autofill-text: #17181C;
  --bg: #F7F8FA;
  --panel: #FFFFFF;
  --surface: #FAFAFB;
  --hover: #F4F5F8;
  --border: #ECEDF1;
  --border-strong: #DEE0E7;
  --text: #17181C;
  --muted: #83858F;
  --primary: #2563EB;
  --primary-light: #E8F0FE;
  --primary-dark: #1D4ED8;
  --success: #22C55E;
  --success-light: #DCFCE7;
  --danger: #EF4444;
  --danger-light: #FEE2E2;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --info: #3B82F6;
  --info-light: #DBEAFE;
  --purple: #8B5CF6;
  --purple-light: #EDE9FE;
  --gray: #9CA3AF;
  --gray-light: #F3F4F6;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --sidebar: 76px;
  --header: 64px;
  --shadow: 0 2px 6px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.06);
  --shadow-md: 0 6px 20px rgba(16,24,40,.10), 0 2px 6px rgba(16,24,40,.08);
  --shadow-lg: 0 18px 48px -10px rgba(16,24,40,.22), 0 8px 20px rgba(16,24,40,.10);
  --overlay: rgba(17,24,39,.45);
  --glass: rgba(255,255,255,0.72);
  --glass-strong: rgba(255,255,255,0.92);
}

[data-theme="dark"] {
  color-scheme: dark;
  --autofill-bg: #14161A;
  --autofill-text: #EDEEF0;
  --bg: #0B0C0E;
  --panel: #14161A;
  --surface: #191C21;
  --hover: #1B1E24;
  --border: #23262D;
  --border-strong: #2E323B;
  --text: #EDEEF0;
  --muted: #8A8F9A;
  --primary: #6E8BFF;
  --primary-light: #1B2338;
  --primary-dark: #93A9FF;
  --success-light: #123021;
  --danger-light: #33171A;
  --warning-light: #33260C;
  --info-light: #16233A;
  --purple-light: #241B3A;
  --gray-light: #1B1E24;
  --shadow: 0 2px 6px rgba(0,0,0,.5), 0 1px 2px rgba(0,0,0,.45);
  --shadow-md: 0 6px 22px rgba(0,0,0,.6), 0 2px 6px rgba(0,0,0,.5);
  --shadow-lg: 0 18px 48px -10px rgba(0,0,0,.75), 0 8px 20px rgba(0,0,0,.55);
  --overlay: rgba(0,0,0,.65);
  --glass: rgba(20,22,26,0.72);
  --glass-strong: rgba(20,22,26,0.88);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  position: relative;
  z-index: 1;
}
.login-card {
  width: 500px;
  max-width: calc(100vw - 32px);
  padding: 48px 44px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.login-logo-icon {
  width: 48px; height: 48px;
  background: var(--primary);
  border-radius: var(--radius-lg);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 20px;
}
.login-logo-img {
  height: 48px; width: auto;
  border-radius: 12px;
  flex-shrink: 0;
}
.login-logo h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.login-logo p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.login-card label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}
.login-card input {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
}
.login-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.login-card .err { color: var(--danger); font-size: 12px; min-height: 18px; margin-bottom: 12px; }
/* Release footer on the login card — reads like a product, not a build tag. */
.login-version {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.login-version .lv-main {
  font-size: 12px; font-weight: 600; color: var(--text);
  letter-spacing: -0.01em;
}
.login-version .lv-sub {
  font-size: 10px; color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.login-card .muted { color: var(--muted); font-size: 12px; margin-top: 18px; }

/* Layout */
.app-shell { display: flex; min-height: 100vh; position: relative; z-index: 1; }
/* Icon rail: 76px wide, everything centred. */
.sidebar {
  width: var(--sidebar);
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-right: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 20;
}
.sidebar-brand {
  height: var(--header);
  width: 100%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-brand img { max-width: 34px; max-height: 34px; object-fit: contain; }
.sidebar-brand-icon {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 11px;
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 14px;
}
.sidebar-nav {
  flex: 1; width: 100%;
  overflow-y: auto;
  padding: 8px 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.sidebar-group { margin-bottom: 16px; }
.sidebar-group-title {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 0 14px; margin-bottom: 6px;
}
/* Square icon button. The label stays in the DOM (screen readers + tests)
   but is visually clipped; the tooltip is rendered from data-tip. */
.nav-item {
  position: relative;
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--muted);
  transition: background .15s, color .15s;
  overflow: hidden;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-item svg { width: 20px; height: 20px; }
.nav-item .nav-label {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.nav-item::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 12px); top: 50%; transform: translateY(-50%);
  background: var(--text); color: var(--panel);
  padding: 6px 10px; border-radius: 8px;
  font-size: 12px; font-weight: 600; line-height: 1;
  white-space: nowrap;
  opacity: 0; pointer-events: none; z-index: 40;
  transition: opacity .12s;
}
.nav-item:hover::after { opacity: 1; }

.sidebar-footer {
  width: 100%;
  padding: 12px 0 14px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  overflow: hidden;  /* hide any visual residue (focus bars, native decorations) */
  max-width: 100%;
}
.sidebar-user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.sidebar-user #userName {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.sidebar-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  cursor: pointer;
}
/* Build-version pill, sits under the avatar in the rail footer. */
.app-version {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  color: var(--muted);
  background: var(--gray-light);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 7px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.main { flex: 1; margin-left: var(--sidebar); min-width: 0; }
.topbar {
  height: var(--header);
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 14px;
  position: sticky; top: 0; z-index: 15;
}
.topbar h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.topbar-spacer { flex: 1; }
#topbarActions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}
#topbarActions .badge { flex-shrink: 0; }
#topbarActions .btn { flex-shrink: 0; }

/* Right-hand tool cluster: search pill, theme toggle, avatar. */
.topbar-tools { display: flex; align-items: center; gap: 8px; }
.search-pill {
  display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 14px;
  min-width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  transition: border-color .15s, background .15s;
}
.search-pill:focus-within { border-color: var(--primary); background: var(--panel); }
.search-pill svg { width: 16px; height: 16px; flex-shrink: 0; }
.search-pill input {
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: transparent;
  font-size: 13px; font-family: inherit; color: var(--text);
}
.search-pill input::placeholder { color: var(--muted); }
.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:focus { outline: none; }
.icon-btn:focus-visible { box-shadow: 0 0 0 3px var(--primary-light); }
.icon-btn svg { width: 18px; height: 18px; }

/* Section tabs rendered as pills under the topbar. */
.tabs-bar {
  position: sticky; top: var(--header); z-index: 12;
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  padding: 14px 24px 12px;
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.tab-pill {
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px; font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
  white-space: nowrap;
}
.tab-pill:hover { background: var(--hover); color: var(--text); }
.tab-pill.active { background: var(--glass-strong); color: var(--text); box-shadow: var(--shadow); }

.content { padding: 24px; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}
.page-title h2 { margin: 0 0 4px; font-size: 20px; }
.page-title p { margin: 0; color: var(--muted); font-size: 13px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-family: inherit;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--hover); border-color: var(--border-strong); }
.btn svg { width: 14px; height: 14px; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #6366F1 55%, #7C3AED 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 14px -4px rgba(37, 99, 235, 0.45), 0 1px 2px rgba(15, 23, 42, 0.06);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #1D4ED8 0%, #4F46E5 55%, #6D28D9 100%);
  box-shadow: 0 8px 20px -4px rgba(37, 99, 235, 0.55), 0 1px 2px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); box-shadow: 0 3px 8px -2px rgba(37, 99, 235, 0.4); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #DC2626; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--gray-light); }
.btn-sm { padding: 6px 10px; font-size: 12px; }

/* Filters / toolbar */
.toolbar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.toolbar .group { display: flex; align-items: center; gap: 8px; }
.toolbar label { font-size: 13px; color: var(--muted); }
select, .search {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  background: var(--panel);
  font-size: 13px;
  outline: none;
}
select:focus, .search:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.search { min-width: 220px; color: var(--text); }
.search::placeholder { color: var(--muted); opacity: 1; }

/* Cards grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}
.card {
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  color: var(--text);
  box-shadow: var(--shadow-md);
  transition: box-shadow .15s, transform .05s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 14px;
}
.card-title { font-size: 16px; font-weight: 700; margin: 0 0 4px; color: var(--text); }
.card-sub { font-size: 12px; color: var(--muted); }
.card-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text);
  margin-bottom: 6px;
}
.card-row svg { width: 14px; height: 14px; color: var(--muted); }
.card-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 16px;
}

/* Bay Details — status banner + 3-up stat tiles + usage table */
.bay-meta {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.bay-meta-info {
  margin-left: auto; font-size: 12px; color: var(--muted);
  letter-spacing: 0.01em;
}

/* Status banner — color-coded based on bay state */
.bay-status-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  border: 1.5px solid transparent;
  font-weight: 600; font-size: 14px;
}
.bay-status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(255,255,255,0.25);
}
.bay-status-title { line-height: 1.2; }
.bay-status-banner.is-inuse {
  background: linear-gradient(135deg, rgba(34,197,94,0.10) 0%, rgba(16,185,129,0.10) 100%);
  border-color: rgba(34,197,94,0.35);
  color: #15803D;
}
.bay-status-banner.is-inuse .bay-status-dot { background: #22C55E; }
.bay-status-banner.is-attention {
  background: linear-gradient(135deg, rgba(245,158,11,0.10) 0%, rgba(234,88,12,0.10) 100%);
  border-color: rgba(245,158,11,0.35);
  color: #B45309;
}
.bay-status-banner.is-attention .bay-status-dot { background: #F59E0B; }
.bay-status-banner.is-registered {
  background: linear-gradient(135deg, rgba(94,106,210,0.08) 0%, rgba(124,58,237,0.08) 100%);
  border-color: rgba(94,106,210,0.30);
  color: var(--primary);
}
.bay-status-banner.is-registered .bay-status-dot { background: var(--primary); }
.bay-status-banner.is-idle {
  background: var(--surface);
  border-color: var(--border);
  color: var(--muted);
}
.bay-status-banner.is-idle .bay-status-dot { background: var(--muted); opacity: 0.5; }

/* 3-up stat tiles — mirrors .stats-row visual language from the Overview */
.bay-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
@media (max-width: 640px) {
  .bay-stats-row { grid-template-columns: 1fr; }
}
.bay-stat-tile {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--glass-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 2px 6px rgba(16,24,40,0.05), 0 1px 2px rgba(16,24,40,0.04);
  min-height: 64px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.bay-stat-tile:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(16,24,40,0.08), 0 2px 4px rgba(16,24,40,0.05);
}
.bay-stat-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.bay-stat-icon svg { width: 18px; height: 18px; }
.bay-stat-body { flex: 1; min-width: 0; }
.bay-stat-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin-bottom: 2px;
}
.bay-stat-value {
  font-size: 17px; font-weight: 700;
  color: var(--text); line-height: 1.25;
  display: flex; align-items: center; gap: 8px;
  word-break: break-word;
}
/* Bay Details stat values — use the same default font as the rest of the
   dashboard (NOT monospace) and prevent flex-shrink so the value text
   doesn't get squeezed vertically when the inline select opens next to it. */
.bay-stat-value code,
.bay-stat-value b {
  font-family: inherit;        /* match the page font instead of monospace */
  font-weight: 700;
  white-space: nowrap;         /* don't wrap a value like "4 hours" mid-word */
  flex-shrink: 0;             /* don't squeeze under flex pressure */
  overflow-wrap: normal;       /* no need to break inside a single word */
}
.bay-stat-sub {
  font-size: 12px; color: var(--muted);
  margin-top: 2px; font-weight: 500;
}
.bay-stat-muted { color: var(--muted); font-weight: 600; font-size: 14px; }
.bay-stat-over { color: #B45309; font-weight: 600; font-size: 12px; }

/* Allotted tile hosts the inline gear button + select */
.bay-stat-allotted-row { gap: 6px; flex-wrap: nowrap; }
.bay-stat-gear {
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  padding: 0;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.bay-stat-gear:hover { background: var(--primary); color: #fff; transform: rotate(45deg); box-shadow: 0 2px 6px rgba(94,106,210,0.35); }
.bay-stat-gear:focus-visible { outline: 2px solid var(--primary-light); outline-offset: 2px; }
.bay-stat-gear svg { width: 12px; height: 12px; color: inherit; }
.bay-stat-select {
  font-size: 12px;
  padding: 3px 6px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  min-width: 90px;
  margin-left: 4px;
}

/* Block / Unblock Bay button — admin can block a problematic bay or unblock it */
.bay-block-row { margin-bottom: 18px; display: flex; }
.bay-block-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  font-size: 13px; font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease, transform .1s ease, box-shadow .15s ease;
}
.bay-block-btn svg { width: 16px; height: 16px; }
.bay-block-btn.is-normal {
  background: rgba(239, 68, 68, 0.08);
  color: #B91C1C;
  border-color: rgba(239, 68, 68, 0.30);
}
.bay-block-btn.is-normal:hover { background: var(--danger); color: #fff; border-color: var(--danger); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(239,68,68,0.30); }
.bay-block-btn.is-blocked {
  background: rgba(34, 197, 94, 0.10);
  color: #15803D;
  border-color: rgba(34, 197, 94, 0.40);
}
.bay-block-btn.is-blocked:hover { background: var(--success); color: #fff; border-color: var(--success); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(34,197,94,0.30); }
.bay-block-btn:focus-visible { outline: 2px solid var(--primary-light); outline-offset: 2px; }
.bay-block-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }
[data-theme="dark"] .bay-block-btn.is-normal { background: rgba(239,68,68,0.16); color: #f87171; border-color: rgba(239,68,68,0.40); }
[data-theme="dark"] .bay-block-btn.is-blocked { background: rgba(34,197,94,0.18); color: #4ade80; border-color: rgba(34,197,94,0.45); }

/* Usage Record section */
.bay-section-title { font-size: 14px; font-weight: 700; margin: 0 0 10px; color: var(--text); }
.bay-usage-note { font-size: 12px; margin-bottom: 8px; }
.bay-usage-wrap { margin-bottom: 0; }
.bay-usage-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.bay-usage-table thead th {
  text-align: left; font-weight: 700; font-size: 12px;
  color: var(--muted); padding: 8px 10px;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.bay-usage-table tbody td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.bay-usage-table tbody tr:last-child td { border-bottom: 0; }
.bay-usage-table tbody tr:hover { background: var(--surface); }
.bay-usage-table code {
  background: var(--primary-light); color: var(--primary-dark);
  padding: 2px 8px; border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.bay-usage-empty { text-align: center; padding: 24px 12px !important; color: var(--muted); font-style: italic; }

/* Badges */
.badge {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-online { background: var(--success-light); color: #15803D; }
.badge-offline { background: var(--gray-light); color: var(--muted); }
.badge-healthy { background: var(--primary-light); color: var(--primary-dark); }
.badge-attention { background: var(--warning-light); color: #B45309; }
.badge-critical { background: var(--danger-light); color: #B91C1C; }
.badge-inuse { background: var(--success-light); color: #15803D; }
.badge-inbay { background: var(--primary-light); color: var(--primary-dark); }
.badge-blocked { background: var(--danger-light); color: #B91C1C; }
.badge-unassigned { background: var(--warning-light); color: #B45309; }
.badge-mode-public { color: var(--success); }
.badge-mode-private { color: var(--danger); }
.badge-mode-hybrid { color: var(--primary); }

/* Stats */
/* Stat row sits at full content width so the four cards line up horizontally
   regardless of the dashboard column underneath. */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 900px) { .stats-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .stats-row { grid-template-columns: 1fr; } }
/* Match .card's surface so the stat row reads as the same component family. */
.stat-card {
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
  transition: box-shadow .15s, transform .05s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card .icon {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  margin-bottom: 14px;
}
.stat-card .icon svg { width: 20px; height: 20px; }
.stat-card .n { font-size: 28px; font-weight: 700; margin-bottom: 4px; letter-spacing: -0.02em; line-height: 1.1; }
.stat-card .l { color: var(--muted); font-size: 13px; }

/* Bay grid */
.bay-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
@media (max-width: 1200px) { .bay-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px) { .bay-grid { grid-template-columns: repeat(2, 1fr); } }
.bay-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  cursor: pointer;
  transition: box-shadow .15s, transform .05s;
}
.bay-card:hover { box-shadow: var(--shadow-md); }
.bay-card.selected { outline: 2px solid var(--primary); }
.bay-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.bay-card-head .num { font-weight: 700; font-size: 15px; }
.bay-card .user {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; margin-bottom: 4px;
}
.bay-card .user svg { width: 14px; height: 14px; color: var(--muted); }
.bay-card .time {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted);
  margin-bottom: 12px;
}
.bay-card .time svg { width: 14px; height: 14px; color: var(--muted); flex-shrink: 0; }
.bay-card .actions { display: flex; justify-content: space-between; align-items: center; }

/* Tables */
.table-wrap {
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 12px 16px; background: var(--surface); color: var(--muted); font-weight: 600; font-size: 12px; }
td { padding: 14px 16px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--hover); }
.table-actions { display: flex; gap: 6px; }

/* Pagination */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; padding: 16px;
}
.pagination button {
  width: 30px; height: 30px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--panel); cursor: pointer; color: var(--text);
  display: grid; place-items: center; font-family: inherit;
}
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* Modal */
.modal-mask {
  position: fixed; inset: 0;
  background: var(--overlay);
  display: none; align-items: center; justify-content: center;
  z-index: 50;
}
.modal-mask.show { display: flex; }
.modal {
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 720px; max-width: 92vw; max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,.12);
  display: flex; flex-direction: column;
}
.modal-sm { width: 400px; }
.modal-lg { width: 820px; }

/* Org-detail modal — three stat columns + an add-locker inline form. */
.org-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 18px 0 6px;
}
@media (max-width: 900px) { .org-stats { grid-template-columns: repeat(2, 1fr); } }

.org-head {
  display: flex; align-items: center; gap: 14px;
  padding: 4px 0 16px;
  border-bottom: 1px solid var(--border);
}
.org-head h3 { margin: 0; }
.add-mode {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--text);
  cursor: pointer;
}
.add-mode input[type="radio"] { accent-color: var(--primary); }
.add-mode:has(input[disabled]) { color: var(--muted); cursor: not-allowed; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 17px; }
.modal-close { background: transparent; border: none; cursor: pointer; color: var(--muted); }
.modal-close svg { width: 20px; height: 20px; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 22px; border-top: 1px solid var(--border);
}

/* Two columns inside modal */
.modal-split { display: grid; grid-template-columns: 1.2fr .8fr; gap: 22px; }
@media (max-width: 720px) { .modal-split { grid-template-columns: 1fr; } }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.form-group input, .form-group select {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px;
  background: var(--panel);
  color: var(--text);
}
.form-group input:disabled { background: var(--gray-light); color: var(--muted); }
.form-group .hint { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.form-group .req { color: var(--danger); }

/* Form rows for modal forms (label + field side-by-side) */
.form-row { display: flex; align-items: flex-start; gap: 18px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.form-row:last-of-type { border-bottom: 0; }
.form-row label { width: 140px; font-weight: 600; padding-top: 6px; flex-shrink: 0; }
.form-row .field { flex: 1; }
.form-row .hint { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.4; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; font-family: inherit; background: var(--panel); color: var(--text);
}
.form-row input:disabled { background: var(--gray-light); color: var(--muted); }

/* Modal footer button row (right-aligned) */
.modal-buttons { display: flex; justify-content: flex-end; gap: 8px; padding-top: 18px; }
.modal-buttons .btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ---- Enroll a New Device popup ---- */
.enroll-sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; line-height: 1.5; }
.enroll-section { margin-bottom: 4px; }
.enroll-section-title { font-size: 14px; font-weight: 700; margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.enroll-recommended, .enroll-fallback {
  font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap;
}
.enroll-recommended { background: var(--success-light); color: #15803D; }
.enroll-fallback { background: var(--gray-light); color: var(--muted); }
.enroll-desc { color: var(--muted); font-size: 13px; margin: 0 0 12px; line-height: 1.5; }
.enroll-divider { border: 0; border-top: 1px dashed var(--border); margin: 20px 0; }

.otp-box {
  margin: 14px 0 0; padding: 16px; border: 2px solid var(--success);
  border-radius: var(--radius); background: var(--success-light); text-align: center;
}
.otp-label { font-size: 12px; color: #15803D; margin-bottom: 6px; }
.otp-value {
  font-size: 38px; font-weight: 800; letter-spacing: 6px; color: #15803D;
  font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.otp-countdown { font-size: 12px; color: #15803D; font-weight: 600; margin-top: 8px; }

.enroll-kiosk {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-top: 14px;
}
.enroll-kiosk-title { font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.enroll-kiosk-steps { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.enroll-kiosk-steps code {
  background: var(--primary-light); color: var(--primary-dark); padding: 1px 6px; border-radius: 6px; font-size: 12px;
}
.enroll-kiosk-note { color: var(--success); font-weight: 600; font-size: 12px; margin-top: 8px; }

/* ---- Server URL box (Step 0 in Enroll modal) ---- */
.enroll-server-url-box {
  background: linear-gradient(135deg, rgba(94,106,210,0.06) 0%, rgba(124,58,237,0.05) 100%);
  border: 1.5px solid rgba(94,106,210,0.35);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.enroll-server-url-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.enroll-server-url-tag {
  font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px;
  background: linear-gradient(135deg, var(--primary) 0%, #6366F1 55%, #7C3AED 100%);
  color: #fff; letter-spacing: 0.04em; white-space: nowrap;
  box-shadow: 0 2px 6px rgba(94,106,210,0.35);
}
.enroll-server-url-label { font-size: 14px; font-weight: 700; color: var(--text); }
.enroll-server-url-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}
.enroll-server-url-value {
  flex: 1; min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: var(--text);
  background: transparent;
  border: 0;
  padding: 4px 6px;
  user-select: all;
  word-break: break-all;
  overflow-wrap: anywhere;
}
.enroll-copy-btn {
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  padding: 0;
  background: var(--primary);
  color: #fff;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color .15s ease, transform .1s ease, box-shadow .15s ease;
  box-shadow: 0 2px 6px rgba(94,106,210,0.30);
}
.enroll-copy-btn:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(94,106,210,0.40); }
.enroll-copy-btn:active { transform: translateY(0); box-shadow: 0 1px 3px rgba(94,106,210,0.25); }
.enroll-copy-btn:focus-visible { outline: 2px solid var(--primary-light); outline-offset: 2px; }
.enroll-copy-btn svg { width: 16px; height: 16px; display: block; }
.enroll-copy-btn.is-copied { background: var(--success); box-shadow: 0 2px 6px rgba(22,163,74,0.35); }
.enroll-server-url-hint {
  font-size: 12px; color: var(--muted); line-height: 1.5; margin-top: 10px;
}
.enroll-server-url-hint strong { color: var(--text); font-weight: 600; }
.enroll-server-url-details {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
.enroll-server-url-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
  padding: 4px 0;
  user-select: none;
  list-style: none;
}
.enroll-server-url-details summary::-webkit-details-marker { display: none; }
.enroll-server-url-details summary::before {
  content: '▸ ';
  display: inline-block;
  transition: transform .15s ease;
  margin-right: 2px;
}
.enroll-server-url-details[open] summary::before { content: '▾ '; }
.enroll-server-url-endpoints {
  margin: 8px 0 6px;
  padding-left: 18px;
  line-height: 1.7;
}
.enroll-server-url-endpoints code {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 11.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.enroll-server-url-note {
  font-size: 11.5px;
  color: var(--success);
  margin-top: 6px;
  padding: 6px 8px;
  background: var(--success-light);
  border-radius: 6px;
}
.enroll-server-url-note code {
  background: rgba(22,163,74,0.10);
  color: var(--success);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.enroll-success { text-align: center; padding: 18px 8px 4px; }
.enroll-success-icon {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 14px;
  background: var(--success); color: #fff; font-size: 30px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.enroll-success h3 { margin: 0 0 8px; font-size: 20px; }
.enroll-success .muted { margin: 0; }

/* Logs */
.log-list { max-height: 420px; overflow-y: auto; }
.log-row {
  display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.log-row:last-child { border-bottom: none; }
.log-ts { color: var(--muted); white-space: nowrap; min-width: 140px; }
.log-tag {
  font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 999px; height: fit-content;
}

/* Toast */
.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--text); color: var(--panel);
  padding: 12px 18px; border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 60; opacity: 0; transform: translateY(10px);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: var(--danger); }

/* Empty state */
.empty {
  text-align: center; padding: 48px 20px; color: var(--muted);
}
.empty svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: .5; }

/* Section tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 10px 16px; font-size: 14px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--primary); border-color: var(--primary); font-weight: 600; }

/* Checkbox */
/* Custom checkbox — UA dark mode was painting it as a near-invisible
 * black blob in the bay cards. Reset appearance, give it a visible
 * border + background that match the theme, and draw the check with ::before
 * so it works in every browser regardless of OS color scheme. */
input[type="checkbox"],
input[type="checkbox"].bay-checkbox {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  background: var(--panel);
  border: 1.5px solid var(--border-strong);
  border-radius: 5px;
  display: inline-grid;
  place-content: center;
  transition: background-color .12s, border-color .12s, box-shadow .12s;
  flex-shrink: 0;
}
input[type="checkbox"]:hover {
  border-color: var(--primary);
}
input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}
input[type="checkbox"]:checked::before {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2.5px solid #fff;
  border-bottom: 2.5px solid #fff;
  transform: rotate(-45deg) translate(1px, -1px);
}
input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--primary-light);
  outline-offset: 2px;
}

/* Hidden */
.hidden { display: none !important; }

/* ---- Organization image upload & cropper ---- */
.thumb-upload { display: flex; align-items: center; gap: 14px; }
.thumb {
  width: 84px; height: 84px; border-radius: 12px; background: var(--surface);
  color: var(--muted); display: flex; align-items: center; justify-content: center;
  font-size: 12px; overflow: hidden; flex-shrink: 0; border: 1px solid var(--border);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .org-badge {
  width: 100%; height: 100%; border-radius: inherit;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 22px;
}
.upload-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); font-size: 13px; cursor: pointer;
}
.upload-btn:hover { background: var(--hover); }
.upload-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

.entity-card .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.entity-card .org-thumb {
  width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex-shrink: 0; border: 1px solid var(--border);
}
.entity-card .org-badge {
  width: 56px; height: 56px; border-radius: 10px; background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; flex-shrink: 0;
}

.cropper-wrap {
  position: relative; display: inline-block; max-width: 100%; user-select: none; touch-action: none;
  background: #0b0b0b; border-radius: var(--radius); overflow: hidden;
}
.cropper-wrap img { display: block; max-width: 100%; max-height: 60vh; }
.cropper-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.55);
  pointer-events: none;
}
.cropper-box {
  position: absolute; border: 2px dashed #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,0.55);
  cursor: move; min-width: 40px; min-height: 40px;
}
.cropper-handle {
  position: absolute; width: 10px; height: 10px; background: #fff; border-radius: 50%;
  border: 1px solid #000; box-shadow: 0 0 0 1px #fff;
}
.cropper-handle.nw { top: -5px; left: -5px; cursor: nw-resize; }
.cropper-handle.ne { top: -5px; right: -5px; cursor: ne-resize; }
.cropper-handle.sw { bottom: -5px; left: -5px; cursor: sw-resize; }
.cropper-handle.se { bottom: -5px; right: -5px; cursor: se-resize; }
.cropper-info {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.7); color: #fff; font-size: 12px; padding: 4px 10px; border-radius: 999px;
  pointer-events: none;
}
.cropper-hint { font-size: 12px; color: var(--muted); margin-bottom: 12px; }

/* ==========================================================================
   Redesigned Overview — greeting banner, quick actions, activity feed.
   ========================================================================== */
.ov-greeting {
  background: linear-gradient(120deg, #2563EB 0%, #7C3AED 100%);
  border-radius: var(--radius-xl);
  padding: 26px 28px;
  color: #fff;
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
  margin-bottom: 22px;
}
.ov-greeting h3 { margin: 0 0 6px; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.ov-greeting p { margin: 0; font-size: 13px; opacity: .88; }
.ov-greeting-stats { display: flex; gap: 24px; flex-wrap: wrap; align-items: baseline; }
.ov-gstat { text-align: right; display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.ov-gstat .v { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.ov-gstat .k { font-size: 11px; opacity: .85; text-transform: uppercase; letter-spacing: .06em; }

.ov-cols {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 20px;
  align-items: start;
}
@media (max-width: 1100px) { .ov-cols { grid-template-columns: minmax(0, 1fr); } }

.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}
.quick-tile {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: box-shadow .15s, border-color .15s, transform .05s;
}
.quick-tile:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.quick-tile:active { transform: translateY(1px); }
.quick-tile .qi {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center; flex-shrink: 0;
}
.quick-tile .qi svg { width: 18px; height: 18px; }
/* Defensive text layout — child flex item must shrink so the icon doesn't
   get squeezed when the tile is narrow. */
.quick-tile > span:nth-child(2) { min-width: 0; flex: 1; }
.quick-tile .qt { display: block; font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick-tile .qs { display: block; font-size: 12px; color: var(--muted); line-height: 1.3; margin-top: 2px; }


.feed { display: flex; flex-direction: column; }
.feed-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.feed-item:last-child { border-bottom: 0; }
.feed-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex-shrink: 0; }
.feed-body { flex: 1; min-width: 0; }
/* Allow long event details (e.g. "device X unassigned (was Y)") to wrap
   to two lines and ellipsis past that — the column is narrow and a single
   no-wrap line clips into ellipsis way too early. */
.feed-title {
  font-size: 13px; font-weight: 600; line-height: 1.4;
  word-break: break-word;
  overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  white-space: normal;
}
.feed-meta { font-size: 12px; color: var(--muted); margin-top: 2px; word-break: break-word; }
.feed-time { font-size: 12px; color: var(--muted); white-space: nowrap; flex-shrink: 0; min-width: 56px; text-align: right; }

/* Lighter card heading used across the redesigned pages */
.card-title-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.card-title-row .card-title { margin: 0; }
.link-btn {
  background: none; border: 0; padding: 0;
  color: var(--primary); font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.link-btn:hover { text-decoration: underline; }

/* ==========================================================================
   Organic plexus network canvas — fixed behind every dashboard surface.
   The canvas itself is sized by Three.js, we only own positioning + a11y.
   ========================================================================== */
.network-bg {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  display: block;
}

/* ==========================================================================
   Dark-mode polish — the light-theme badges use saturated foregrounds
   (e.g. #15803D, #B45309) that disappear on the dark semantic surfaces.
   Override only what doesn't carry over with the base vars.
   ========================================================================== */
[data-theme="dark"] .badge-online { background: rgba(34,197,94,.18); color: #4ade80; }
[data-theme="dark"] .badge-inuse { background: rgba(34,197,94,.18); color: #4ade80; }
[data-theme="dark"] .badge-healthy { background: rgba(96,165,250,.20); color: #93C5FD; }
[data-theme="dark"] .badge-inbay { background: rgba(96,165,250,.20); color: #93C5FD; }
[data-theme="dark"] .badge-attention { background: rgba(245,158,11,.18); color: #fbbf24; }
[data-theme="dark"] .badge-unassigned { background: rgba(245,158,11,.18); color: #fbbf24; }
[data-theme="dark"] .badge-critical { background: rgba(239,68,68,.18); color: #f87171; }
[data-theme="dark"] .badge-blocked { background: rgba(239,68,68,.18); color: #f87171; }

/* Bay Details — dark-mode status banner tints */
[data-theme="dark"] .bay-status-banner.is-inuse { background: linear-gradient(135deg, rgba(34,197,94,0.18) 0%, rgba(16,185,129,0.12) 100%); border-color: rgba(34,197,94,0.45); color: #4ade80; }
[data-theme="dark"] .bay-status-banner.is-attention { background: linear-gradient(135deg, rgba(245,158,11,0.18) 0%, rgba(234,88,12,0.12) 100%); border-color: rgba(245,158,11,0.45); color: #fbbf24; }
[data-theme="dark"] .bay-status-banner.is-registered { background: linear-gradient(135deg, rgba(94,106,210,0.18) 0%, rgba(124,58,237,0.12) 100%); border-color: rgba(94,106,210,0.45); color: #a5b4fc; }
[data-theme="dark"] .bay-status-banner.is-idle { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.10); color: var(--muted); }
[data-theme="dark"] .bay-stat-over { color: #fbbf24; }
[data-theme="dark"] .bay-usage-table tbody tr:hover { background: rgba(255,255,255,0.03); }

/* OTP code box in the Enroll popup uses success greens that go dark. */
[data-theme="dark"] .otp-box { background: rgba(34,197,94,.10); border-color: #4ade80; }
[data-theme="dark"] .otp-value,
[data-theme="dark"] .otp-label,
[data-theme="dark"] .otp-countdown { color: #4ade80; }

/* Native form controls (placeholder, option dropdowns) — let the UA know. */
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea { color-scheme: dark; }

/* ==========================================================================
   UA-saved-credentials highlight override.
   Without this, Chrome paints a yellow/blue overlay on top of the themed
   background and the three password fields end up looking inconsistent
   (Current vs New vs Confirm). Force the saved-value highlight to match
   our themed tokens instead.
   ========================================================================== */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
select:-webkit-autofill,
textarea:-webkit-autofill {
  -webkit-text-fill-color: var(--text) !important;
  -webkit-box-shadow: 0 0 0 1000px var(--panel) inset !important;
  caret-color: var(--text);
  transition: background-color 9999s ease-in-out 0s;
}

/* ==========================================================================
   Default: nobody gets a drag handle unless the component explicitly opts
   in. We saw a stray resize gripper leaking out of the rail/network-bg
   stack in headless screenshots; the safest fix is to forbid it everywhere
   and let only the rules that actually need a handle re-enable it.
   ========================================================================== */
*, *::before, *::after { resize: none; }
textarea { resize: vertical; }

/* ==========================================================================
   Responsive — mobile & tablet polish (v4.3)
   Three tiers, additive (never override existing desktop rules):
   - ≤ 900px (tablet): collapse sidebar, shrink search pill
   - ≤ 720px (phone landscape): stack topbar, scrollable tabs, single-column
   - ≤ 480px (phone portrait): hide greeting stats, tighter padding,
     smaller type, hide search pill entirely (replaced by magnifier button)
   ========================================================================== */

/* --- ≤ 900px: tablet --- */
@media (max-width: 900px) {
  :root { --sidebar: 60px; }
  .topbar { padding: 0 16px; }
  .topbar h2 { font-size: 18px; }
  .search-pill { min-width: 200px; }
  .ov-greeting { padding: 22px 22px; }
  .ov-greeting h3 { font-size: 20px; }
  .quick-grid { grid-template-columns: repeat(3, 1fr) !important; }
  .card { padding: 18px !important; }
}

/* --- ≤ 720px: phone landscape --- */
@media (max-width: 720px) {
  :root { --sidebar: 56px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar h2 { font-size: 17px; }
  .search-pill { min-width: 0; max-width: 180px; padding: 0 10px; height: 34px; font-size: 13px; }
  /* Tabs become a horizontal scroll strip instead of wrapping. */
  .tabs-bar {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 12px 8px;
    gap: 4px;
    scrollbar-width: none;
  }
  .tabs-bar::-webkit-scrollbar { display: none; }
  .tab-pill { flex-shrink: 0; font-size: 13px; padding: 7px 12px; }
  /* Greeting: stats drop below on narrow screens. */
  .ov-greeting {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 14px;
    padding: 18px 18px;
  }
  .ov-greeting-stats { gap: 18px; }
  .ov-gstat { text-align: left; }
  .stats-row { gap: 10px !important; }
  .stat-card { padding: 14px !important; }
  .stat-card .n { font-size: 24px !important; }
  .stat-card .l { font-size: 11px !important; }
  .card { padding: 16px !important; }
  .card-title { font-size: 15px !important; }
  /* Tables: scroll horizontally rather than overflow the page. */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { min-width: 600px; }
  /* Modal takes most of the screen. */
  .modal { width: 96vw !important; max-width: 96vw !important; }
  .modal-split { grid-template-columns: 1fr !important; }
  /* Quick actions in 2 columns. */
  .quick-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* --- ≤ 480px: phone portrait --- */
@media (max-width: 480px) {
  :root { --sidebar: 52px; }
  .topbar { padding: 0 10px; gap: 6px; }
  .topbar h2 { font-size: 15px; }
  /* Hide the search pill entirely on phones — the magnifier button in the
     topbar opens a slide-down search overlay. This keeps the topbar at
     2 controls (Refresh + menu) instead of 4. */
  .search-pill { display: none !important; }
  .ov-greeting { padding: 16px 16px; border-radius: 16px; }
  .ov-greeting h3 { font-size: 17px; }
  .ov-greeting p { font-size: 12px; }
  /* Hide greeting stats entirely on phones (charging + orgs are in stat cards
     below — duplicate info). */
  .ov-greeting-stats { display: none !important; }
  .stat-card { padding: 12px !important; gap: 10px !important; }
  .stat-card .n { font-size: 20px !important; }
  .stat-card .l { font-size: 10px !important; }
  .stat-card .icon { width: 32px !important; height: 32px !important; }
  .card { padding: 12px !important; border-radius: 12px !important; }
  .card-title { font-size: 14px !important; }
  .btn { font-size: 13px !important; padding: 7px 12px !important; }
  .feed-item { padding: 9px 0 !important; }
  .feed-title { font-size: 12px !important; }
  .feed-meta, .feed-time { font-size: 11px !important; }
  .quick-grid { gap: 8px !important; }
  .quick-tile { padding: 12px !important; }
  .quick-tile .qt { font-size: 12px !important; }
  .quick-tile .qs { font-size: 11px !important; }
  /* Pagination: tighter. */
  .pagination button { width: 28px !important; height: 28px !important; font-size: 12px; }
  /* Form: bigger tap targets on touch. */
  .form-row input, .form-row select, .form-row textarea,
  .form-group input, .form-group select {
    font-size: 16px !important;  /* iOS won't zoom on 16px+ inputs */
    padding: 11px 12px !important;
  }
  /* Toast: anchor to bottom on phones, away from the hamburger area. */
  #toast { bottom: 12px; top: auto; right: 12px; left: 12px; text-align: center; }
}
