/* ─── Reset & Tokens ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base:      #070b14;
  --bg-surface:   #0d1220;
  --bg-card:      #111827;
  --bg-card-hover:#16202f;
  --bg-input:     #0d1627;
  --border:       #1a2840;
  --border-light: #243448;

  --accent:       #0ea5e9;
  --accent-dim:   #075985;
  --accent-glow:  rgba(14, 165, 233, 0.15);

  --success:      #22c55e;
  --success-dim:  rgba(34, 197, 94, 0.12);
  --warning:      #f59e0b;
  --warning-dim:  rgba(245, 158, 11, 0.12);
  --danger:       #ef4444;
  --danger-dim:   rgba(239, 68, 68, 0.12);
  --neutral:      #64748b;
  --neutral-dim:  rgba(100, 116, 139, 0.1);

  --text-1:   #e2eaf5;
  --text-2:   #8ba3c0;
  --text-3:   #4a6080;

  --sidebar-w: 230px;
  --topbar-h: 64px;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
}

html, body { height: 100%; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: 'JetBrains Mono', monospace; }
a { color: inherit; text-decoration: none; }

/* ─── App Shell ───────────────────────────────────────────── */
.app {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--border);
}

.logo-mark {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  flex-shrink: 0;
}

.logo-text {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.01em;
  color: var(--text-1);
}
.logo-sub {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-left: 4px;
  vertical-align: super;
}

.sidebar-section {
  padding: 16px 12px 8px;
}

.sidebar-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0 8px;
  display: block;
  margin-bottom: 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  user-select: none;
  margin-bottom: 2px;
}
.sidebar-link svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-link:hover:not(.disabled) { background: var(--bg-card-hover); color: var(--text-1); }
.sidebar-link.active { background: var(--accent-glow); color: var(--accent); }
.sidebar-link.active svg { stroke: var(--accent); }
.sidebar-link.disabled { opacity: 0.45; cursor: not-allowed; }

.badge-soon {
  margin-left: auto;
  font-size: 10px;
  font-weight: 500;
  padding: 1px 6px;
  background: var(--neutral-dim);
  color: var(--neutral);
  border-radius: 20px;
  letter-spacing: 0.04em;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text-1); }
.user-role { font-size: 11px; color: var(--text-3); }

/* ─── Main ────────────────────────────────────────────────── */
.main {
  flex: 1;
  overflow-x: hidden;
  padding-bottom: 48px;
}

/* ─── Topbar ──────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-base);
  z-index: 10;
  gap: 16px;
}
.topbar-left { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.page-title { font-size: 20px; font-weight: 600; color: var(--text-1); }
.page-meta { font-size: 13px; color: var(--text-3); }

.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot.active { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-text { font-size: 13px; color: var(--text-3); }

.back-link {
  font-size: 13px;
  color: var(--text-3);
  transition: color 0.15s;
}
.back-link:hover { color: var(--accent); }

.text-muted { color: var(--text-3); font-size: 13px; }

/* ─── Section ─────────────────────────────────────────────── */
.section { padding: 24px 28px 0; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-title { font-size: 14px; font-weight: 600; color: var(--text-1); letter-spacing: 0.01em; }

.btn-ghost {
  font-size: 13px;
  color: var(--accent);
  transition: opacity 0.15s;
}
.btn-ghost:hover { opacity: 0.75; }

/* ─── Stats Row ───────────────────────────────────────────── */
.stats-row {
  display: flex;
  gap: 12px;
  padding: 24px 28px 0;
  flex-wrap: wrap;
}
.stat-card {
  flex: 1;
  min-width: 90px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-label { font-size: 11px; font-weight: 500; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-value { font-size: 28px; font-weight: 600; font-family: 'JetBrains Mono', monospace; color: var(--text-1); }

.stat-card.accent { border-color: var(--accent-dim); background: rgba(14,165,233,0.05); }
.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.warning { border-color: rgba(245,158,11,0.3); background: var(--warning-dim); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.danger { border-color: rgba(239,68,68,0.3); background: var(--danger-dim); }
.stat-card.danger .stat-value { color: var(--danger); }
.stat-card.neutral { border-color: var(--border-light); }
.stat-card.muted .stat-value { color: var(--neutral); }

/* ─── Status Badges ───────────────────────────────────────── */
.status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}
.status-badge-lg { font-size: 13px; padding: 5px 14px; }
.status-badge.status-active   { background: var(--success-dim); color: var(--success); }
.status-badge.status-idle     { background: var(--neutral-dim); color: var(--neutral); }
.status-badge.status-heating  { background: var(--warning-dim); color: var(--warning); }
.status-badge.status-maintenance { background: rgba(99,102,241,0.12); color: #818cf8; }
.status-badge.status-offline  { background: var(--danger-dim); color: var(--danger); }

.tub-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tub-status-dot.status-active    { background: var(--success); }
.tub-status-dot.status-idle      { background: var(--neutral); }
.tub-status-dot.status-heating   { background: var(--warning); animation: pulse-warn 1.5s infinite; }
.tub-status-dot.status-maintenance { background: #818cf8; }
.tub-status-dot.status-offline   { background: var(--danger); }

@keyframes pulse-warn {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ─── Tub Grid (Dashboard) ───────────────────────────────── */
.tub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.tub-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s, background 0.15s;
}
.tub-card:hover { background: var(--bg-card-hover); border-color: var(--border-light); }
.tub-card.status-offline { opacity: 0.6; }

.tub-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tub-name-group { display: flex; align-items: center; gap: 7px; min-width: 0; }
.tub-name { font-weight: 600; font-size: 13px; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tub-metrics-row {
  display: flex;
  gap: 14px;
}
.mini-metric { display: flex; flex-direction: column; gap: 1px; }
.mini-metric-val { font-size: 15px; font-weight: 600; color: var(--text-1); }
.mini-metric-label { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }

.tub-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2px;
}
.tub-location { font-size: 11px; color: var(--text-3); }
.alert-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--danger);
  background: var(--danger-dim);
  padding: 2px 7px;
  border-radius: 20px;
}

/* ─── Alerts ──────────────────────────────────────────────── */
.alert-total-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--danger);
  background: var(--danger-dim);
  padding: 3px 9px;
  border-radius: 20px;
}

.alert-list { display: flex; flex-direction: column; gap: 8px; }
.alert-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.alert-item.alert-danger { background: var(--danger-dim); border-color: rgba(239,68,68,0.2); }
.alert-item.alert-warning { background: var(--warning-dim); border-color: rgba(245,158,11,0.2); }

.alert-icon { font-size: 14px; flex-shrink: 0; }
.alert-body { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.alert-source { font-size: 12px; font-weight: 600; }
.alert-source a { color: var(--accent); }
.alert-source a:hover { text-decoration: underline; }
.alert-message { font-size: 13px; color: var(--text-2); }
.alert-time { font-size: 11px; color: var(--text-3); flex-shrink: 0; }

/* ─── Products Grid ───────────────────────────────────────── */
.filter-row { display: flex; gap: 6px; }
.filter-btn {
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: all 0.15s;
}
.filter-btn:hover { color: var(--text-1); border-color: var(--border-light); }
.filter-btn.active { background: var(--accent-glow); border-color: var(--accent-dim); color: var(--accent); }

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: border-color 0.15s, transform 0.12s;
}
.product-card:hover { border-color: var(--border-light); transform: translateY(-1px); }
.product-card.hidden { display: none; }

.product-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.product-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.product-icon svg { width: 22px; height: 22px; }
.product-icon.type-ducktub  { background: rgba(14,165,233,0.1); color: var(--accent); }
.product-icon.type-ducktub svg { stroke: var(--accent); }
.product-icon.type-norspa   { background: rgba(34,197,94,0.1); color: var(--success); }
.product-icon.type-norspa svg { stroke: var(--success); }
.product-icon.type-tonsauna { background: rgba(245,158,11,0.1); color: var(--warning); }
.product-icon.type-tonsauna svg { stroke: var(--warning); }

.product-header-info { flex: 1; min-width: 0; }
.product-name { font-size: 14px; font-weight: 600; color: var(--text-1); }
.product-model { font-size: 11px; color: var(--text-3); }

.product-metrics { display: flex; flex-direction: column; gap: 8px; }
.product-metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.pm-label { font-size: 12px; color: var(--text-3); flex-shrink: 0; }
.pm-value { font-size: 13px; font-weight: 500; color: var(--text-1); }
.pm-value.warn { color: var(--warning); }
.pm-target { font-size: 11px; color: var(--text-3); }

.level-bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.level-bar.large { height: 6px; margin-top: 6px; }
.level-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s; }
.level-fill.hot { background: linear-gradient(90deg, var(--warning), var(--danger)); }

.product-alerts { display: flex; flex-direction: column; gap: 4px; }
.product-alert-pill {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  font-weight: 500;
}
.product-alert-pill.alert-danger { background: var(--danger-dim); color: var(--danger); }
.product-alert-pill.alert-warning { background: var(--warning-dim); color: var(--warning); }

.product-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.product-location { font-size: 12px; color: var(--text-3); }

.btn-primary {
  padding: 6px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  display: inline-block;
}
.btn-primary:hover { opacity: 0.85; }
.btn-primary.btn-sm { padding: 5px 11px; font-size: 12px; }

/* ─── Detail Layout ───────────────────────────────────────── */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 0;
  align-items: start;
}
.detail-left {}
.detail-right { border-left: 1px solid var(--border); position: sticky; top: var(--topbar-h); max-height: calc(100vh - var(--topbar-h)); overflow-y: auto; }
.detail-right .section { padding: 20px 22px 0; }

/* ─── Metrics Grid ────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  position: relative;
  overflow: hidden;
}
.metric-card.metric-warn { border-color: rgba(245,158,11,0.3); background: linear-gradient(135deg, var(--bg-card), rgba(245,158,11,0.04)); }
.metric-card.metric-danger { border-color: rgba(239,68,68,0.35); background: linear-gradient(135deg, var(--bg-card), rgba(239,68,68,0.05)); }
.metric-card.offline { opacity: 0.4; }

.metric-icon { font-size: 20px; flex-shrink: 0; margin-top: 2px; }
.metric-body { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.metric-label { font-size: 11px; font-weight: 500; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }
.metric-value { font-size: 22px; font-weight: 600; color: var(--text-1); line-height: 1.2; }
.metric-unit { font-size: 13px; color: var(--text-3); font-weight: 400; }
.metric-sub { font-size: 11px; color: var(--text-3); }

.metric-gauge {
  width: 4px;
  height: 52px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  flex-shrink: 0;
  align-self: center;
}
.gauge-fill { width: 100%; background: linear-gradient(to top, var(--accent-dim), var(--accent)); border-radius: 2px; transition: height 0.5s; }

/* Live indicator */
.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--success);
}
.pulse-dot {
  width: 7px;
  height: 7px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse-live 1.8s infinite;
}
@keyframes pulse-live {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
  50% { box-shadow: 0 0 0 5px rgba(34,197,94,0); }
}

/* ─── Actions Panel ───────────────────────────────────────── */
.actions-panel { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }

.action-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
}
.action-btn:hover:not(:disabled) { background: var(--bg-card-hover); border-color: var(--border-light); }
.action-btn.primary { border-color: var(--accent-dim); background: rgba(14,165,233,0.06); }
.action-btn.primary:hover:not(:disabled) { background: rgba(14,165,233,0.12); }
.action-btn.danger { border-color: rgba(239,68,68,0.25); background: rgba(239,68,68,0.04); }
.action-btn.danger:hover:not(:disabled) { background: rgba(239,68,68,0.1); }
.action-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.action-btn.loading { opacity: 0.6; pointer-events: none; }

.action-icon { font-size: 18px; flex-shrink: 0; }
.action-text { display: flex; flex-direction: column; gap: 1px; }
.action-name { font-size: 13px; font-weight: 600; }
.action-desc { font-size: 11px; color: var(--text-3); }

/* ─── Info Table ──────────────────────────────────────────── */
.info-table { display: flex; flex-direction: column; gap: 0; padding-bottom: 16px; }
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.info-row:last-child { border-bottom: none; }
.info-label { font-size: 12px; color: var(--text-3); flex-shrink: 0; }
.info-value { font-size: 13px; color: var(--text-1); text-align: right; }
.info-value.warn { color: var(--warning); }

/* ─── Toast ───────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}
.toast {
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-1);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  max-width: 340px;
  animation: toast-in 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.success { border-color: rgba(34,197,94,0.3); }
.toast.error { border-color: rgba(239,68,68,0.3); }
.toast-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.toast.success .toast-dot { background: var(--success); }
.toast.error .toast-dot { background: var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ─── Responsive ──────────────────────────────────────────── */

/* Hamburger toggle + close button — hidden on desktop */
.menu-toggle, .menu-close { display: none; }
.menu-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 30;
  opacity: 0;
  transition: opacity 0.2s ease;
}

/* Tablet — stack the detail layout */
@media (max-width: 1024px) {
  .detail-layout {
    grid-template-columns: 1fr;
  }
  .detail-right {
    border-left: none;
    border-top: 1px solid var(--border);
    position: static;
    max-height: none;
    overflow-y: visible;
  }
}

/* Mobile — sidebar becomes an off-canvas drawer */
@media (max-width: 768px) {
  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 25;
    width: 40px;
    height: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-1);
    cursor: pointer;
  }
  .menu-toggle svg { width: 20px; height: 20px; }

  .menu-close {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--text-2);
    cursor: pointer;
    border-radius: var(--radius-sm);
  }
  .menu-close:hover { background: var(--bg-card-hover); color: var(--text-1); }
  .menu-close svg { width: 18px; height: 18px; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    min-height: 100vh;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  }

  body.menu-open .sidebar { transform: translateX(0); }
  body.menu-open .menu-backdrop { display: block; opacity: 1; }
  body.menu-open { overflow: hidden; }

  /* Push topbar content right of the floating hamburger */
  .topbar {
    padding: 14px 16px 14px 72px;
    flex-wrap: wrap;
  }
  .topbar-left { min-width: 0; }
  .page-title { min-width: 0; word-break: break-word; }
  .topbar-right { gap: 8px; }
  .page-title { font-size: 18px; }

  .section, .stats-row { padding-left: 16px; padding-right: 16px; }
  .section { padding-top: 20px; }

  .stat-card { padding: 12px 14px; min-width: 110px; }
  .stat-value { font-size: 22px; }

  .detail-right .section { padding-left: 16px; padding-right: 16px; }

  .product-grid { grid-template-columns: 1fr; }

  .toast-container { left: 16px; right: 16px; bottom: 16px; }
  .toast { max-width: none; }
}

/* Small phones — single-column grids, tighter chrome */
@media (max-width: 480px) {
  .topbar { padding: 12px 14px 12px 64px; gap: 10px; }
  .topbar-left { gap: 8px; }
  .page-meta { font-size: 12px; }
  .page-title { font-size: 17px; }

  .section, .stats-row { padding-left: 14px; padding-right: 14px; }

  .stats-row { gap: 8px; }
  .stat-card { min-width: calc(50% - 4px); padding: 10px 12px; }
  .stat-value { font-size: 20px; }

  .tub-grid { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: 1fr; }

  .filter-row { flex-wrap: wrap; }

  .alert-item { padding: 10px 12px; gap: 10px; }
  .alert-time { display: none; }
}

/* ─── Sidebar logout ──────────────────────────────────────── */
.sidebar-logout-form { padding: 8px 18px 14px; margin: 0; }
.sidebar-logout-btn {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.sidebar-logout-btn:hover { background: var(--bg-card-hover); color: var(--text-1); }

/* ─── Auth shell (login, change-password) ─────────────────── */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: var(--bg-base);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.auth-logo { display: flex; align-items: center; gap: 10px; }
.auth-title { font-size: 20px; font-weight: 600; color: var(--text-1); }
.auth-subtitle { font-size: 13px; color: var(--text-3); margin-top: -10px; }

.auth-form { display: flex; flex-direction: column; gap: 14px; }

.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field > span { font-size: 11px; font-weight: 500; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }
.auth-field > span .muted { text-transform: none; letter-spacing: 0; }

.auth-field input,
.auth-field select,
.user-form input,
.user-form select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-family: inherit;
  font-size: 14px;
}
.auth-field input:focus,
.auth-field select:focus,
.user-form input:focus,
.user-form select:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-block { width: 100%; padding: 11px 14px; font-size: 14px; }

.auth-error,
.page-error {
  background: var(--danger-dim);
  border: 1px solid rgba(239,68,68,0.25);
  color: #fecaca;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.auth-notice,
.page-notice {
  background: var(--warning-dim);
  border: 1px solid rgba(245,158,11,0.25);
  color: #fcd34d;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

/* ─── Users / Team page ───────────────────────────────────── */
.user-form {
  display: grid;
  grid-template-columns: 1fr 1fr 160px auto;
  gap: 12px;
  align-items: end;
  padding: 16px 0 4px;
}
.user-form .btn-primary { height: 38px; }

.users-table {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  margin-top: 8px;
}
.users-row {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 1.4fr 0.9fr 1.4fr;
  gap: 12px;
  padding: 12px 16px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.users-row:last-child { border-bottom: none; }
.users-head {
  background: var(--bg-surface);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.users-empty { justify-items: center; text-align: center; padding: 24px 16px; display: block; }
.users-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.users-actions form { margin: 0; }
.users-actions .action-btn { padding: 5px 10px; font-size: 12px; }

.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.role-badge.role-admin { background: var(--accent-glow); color: var(--accent); }
.role-badge.role-user  { background: var(--neutral-dim); color: var(--text-2); }

.muted { color: var(--text-3); font-weight: 400; }

/* One-time credentials banner (used by /users) */
.creds-banner {
  background: linear-gradient(135deg, var(--bg-card), rgba(34,197,94,0.05));
  border: 1px solid rgba(34,197,94,0.25);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.creds-banner-head { display: flex; flex-direction: column; gap: 2px; }
.creds-banner-head strong { font-size: 13px; color: var(--text-1); }
.creds-banner-sub { font-size: 12px; color: var(--text-3); }
.creds-banner-row { display: flex; gap: 10px; align-items: center; font-size: 13px; }
.creds-label { color: var(--text-3); min-width: 160px; }
.creds-value {
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  user-select: all;
}

@media (max-width: 720px) {
  .user-form { grid-template-columns: 1fr; }
  .users-row { grid-template-columns: 1fr 1fr; gap: 6px; }
  .users-head { display: none; }
}

/* ── Platform console (/admin) ────────────────────────────────────── */
.orgs-row {
  display: grid;
  grid-template-columns: 2fr 0.8fr 0.8fr 1.2fr;
  gap: 12px;
  padding: 12px 16px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.orgs-row:last-child { border-bottom: none; }
.orgs-row a { color: var(--text-1); font-weight: 500; text-decoration: none; }
.orgs-row a:hover { color: var(--accent); }
.master-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--accent-glow);
  color: var(--accent);
  vertical-align: middle;
}
.org-members .users-row { grid-template-columns: 1.2fr 0.55fr 1.35fr 0.8fr 1.7fr; }
.detail-meta { display: flex; gap: 20px; flex-wrap: wrap; color: var(--text-3); font-size: 13px; }
.detail-meta strong { color: var(--text-1); font-weight: 600; }
.topbar-left .page-meta a { color: var(--accent); text-decoration: none; }
@media (max-width: 720px) {
  .orgs-row { grid-template-columns: 1fr 1fr; }
  .org-members .users-row { grid-template-columns: 1fr 1fr; }
}
.admin-form { display: flex; flex-direction: column; gap: 14px; max-width: 440px; }
.admin-actions { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
a.btn-primary, a.action-btn { display: inline-block; text-decoration: none; }
.rename-form { display: flex; gap: 10px; align-items: center; max-width: 480px; }
.rename-form input {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-size: 13px;
}
.rename-form input:focus { outline: none; border-color: var(--accent-dim); box-shadow: 0 0 0 3px var(--accent-glow); }
.status-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  vertical-align: middle;
}
.status-badge.suspended { background: var(--danger-dim); color: var(--danger); }
.btn-danger {
  padding: 6px 14px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-danger:hover { opacity: 0.85; }
.status-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  max-width: 640px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.status-panel form { margin: 0; }
.status-info { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.status-pill.active { background: var(--success-dim); color: var(--success); }
.status-pill.suspended { background: var(--danger-dim); color: var(--danger); }
.status-pill .status-dot { width: 7px; height: 7px; border-radius: 50%; box-shadow: none; }
.status-pill.active .status-dot { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-pill.suspended .status-dot { background: var(--danger); }
.status-desc { font-size: 13px; color: var(--text-2); }
.danger-zone {
  max-width: 560px;
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius);
  padding: 16px 18px;
  background: var(--danger-dim);
}
.section-title.danger { color: var(--danger); }
.delete-form { display: flex; flex-direction: column; gap: 10px; max-width: 440px; }
.delete-form .btn-danger { align-self: flex-start; }
.delete-label { font-size: 13px; color: var(--text-2); }
.delete-input {
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-size: 13px;
}
.delete-input:focus { outline: none; border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-dim); }
.btn-danger:disabled { opacity: 0.4; cursor: not-allowed; }
.impersonation-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 40px;
  padding: 0 18px;
  background: var(--warning);
  color: #1a1205;
  font-size: 13px;
  font-weight: 500;
}
/* Banner is a 40px block above .app; shrink the full-height panels to match so
   it doesn't push the page past 100vh and spawn a scrollbar. */
body.impersonating .app,
body.impersonating .sidebar { min-height: calc(100vh - 40px); }
.impersonation-bar form { margin: 0; }
.impersonation-bar button {
  padding: 5px 12px;
  background: rgba(0, 0, 0, 0.28);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.impersonation-bar button:hover { background: rgba(0, 0, 0, 0.42); }

