/* ════════════════════════════════════════════════════════════════
   ORACLE PORTALS — Unified Design System
   Aesthetic: Clean dark with warm copper accents.
   Blend of Redwood enterprise clarity + Command warmth + subtle tactical edge.
   ════════════════════════════════════════════════════════════════ */

/* Oracle Sans (variable, weights 275–800) served from /portals/css/fonts/.
   Source: https://www.oracle.com/asset/sequoia/fonts/ */
@font-face {
  font-display: swap;
  font-family: 'OracleSansVF';
  src: url('fonts/oraclesansvf.woff2') format('woff2');
  font-weight: 275 800;
  font-style: normal;
}
@font-face {
  font-display: swap;
  font-family: 'OracleSansVF';
  src: url('fonts/oraclesansvf-it.woff2') format('woff2');
  font-weight: 275 800;
  font-style: italic;
}
@font-face {
  font-display: swap;
  font-family: 'OracleSansVFCyGr';
  src: url('fonts/oraclesansvf-cygr.woff2') format('woff2');
  font-weight: 275 800;
  font-style: normal;
}
@font-face {
  font-display: swap;
  font-family: 'OracleSansVFCyGr';
  src: url('fonts/oraclesansvf-cygr-it.woff2') format('woff2');
  font-weight: 275 800;
  font-style: italic;
}

/* IBM Plex Mono (OFL). Placeholder mono — swap to Oracle Sans Mono when
   available by dropping oraclesansmono.woff2 in /fonts/, adding a matching
   @font-face block, and prepending 'OracleSansMono' to --font-mono below. */
@font-face {
  font-display: swap;
  font-family: 'IBM Plex Mono';
  src: url('fonts/IBMPlexMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
}
@font-face {
  font-display: swap;
  font-family: 'IBM Plex Mono';
  src: url('fonts/IBMPlexMono-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
}
@font-face {
  font-display: swap;
  font-family: 'IBM Plex Mono';
  src: url('fonts/IBMPlexMono-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
}

/* ═══ 1. Design Tokens ═══ */
:root {
  /* Surfaces */
  --bg-deep:      #08090E;
  --bg-base:      #0D0F17;
  --bg-surface:   #13151F;
  --bg-elevated:  #1A1D2A;
  --bg-hover:     #1F2233;
  --bg-active:    #262940;
  --bg-input:     #10121B;

  /* Borders */
  --border-subtle:  rgba(255,255,255,0.04);
  --border-default: rgba(255,255,255,0.08);
  --border-strong:  rgba(255,255,255,0.14);
  --border-accent:  rgba(198,142,96,0.35);
  --border-focus:   rgba(198,142,96,0.6);

  /* Accent — Warm Copper */
  --accent:       #C68E60;
  --accent-light: #D4A67A;
  --accent-dim:   rgba(198,142,96,0.14);
  --accent-glow:  rgba(198,142,96,0.06);

  /* Semantic */
  --blue:   #5B8DEF;
  --green:  #4ADE80;
  --red:    #EF4444;
  --amber:  #F59E0B;
  --cyan:   #22D3EE;
  --purple: #A78BFA;

  /* Aliases used by portal scripts */
  --danger:  #EF4444;
  --success: #4ADE80;
  --warning: #F59E0B;
  --info:    #5B8DEF;

  --green-dim:  rgba(74,222,128,0.10);
  --red-dim:    rgba(239,68,68,0.10);
  --amber-dim:  rgba(245,158,11,0.10);
  --blue-dim:   rgba(91,141,239,0.10);
  --cyan-dim:   rgba(34,211,238,0.10);
  --purple-dim: rgba(167,139,250,0.10);

  /* Text */
  --text-primary:   #E4E0DB;
  --text-secondary: #8B8B96;
  --text-muted:     #52525C;
  --text-inverse:   #08090E;

  /* Typography */
  --font-display: 'OracleSansVF', 'OracleSansVFCyGr', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --font-body:    'OracleSansVF', 'OracleSansVFCyGr', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --font-mono:    'IBM Plex Mono', 'SF Mono', ui-monospace, monospace;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Sidebar */
  --sidebar-width: 256px;
  --portal-status-offset: 72px;

  /* Shared portal backdrop */
  --portal-backdrop-image: url('/portals/images/btn_admin.png');
  --portal-app-backdrop-size: clamp(460px, 46vw, 760px) auto;
  --portal-app-backdrop-position: right -80px top 18%;
  --portal-app-backdrop-opacity: 0.07;
  --portal-login-backdrop-size: clamp(420px, 42vw, 700px) auto;
  --portal-login-backdrop-position: right -60px center;
  --portal-login-backdrop-opacity: 0.18;
  --portal-backdrop-filter: blur(26px) saturate(0.55) brightness(0.72);
}

[data-theme="light"] {
  --bg-deep:      #F4EFE8;
  --bg-base:      #FBF8F3;
  --bg-surface:   #FFFFFF;
  --bg-elevated:  #F4EDE4;
  --bg-hover:     #EFE4D6;
  --bg-active:    #E7D7C3;
  --bg-input:     #FFFDF9;

  --border-subtle:  rgba(75, 49, 25, 0.08);
  --border-default: rgba(75, 49, 25, 0.14);
  --border-strong:  rgba(75, 49, 25, 0.22);
  --border-accent:  rgba(198, 142, 96, 0.45);
  --border-focus:   rgba(198, 142, 96, 0.7);

  --accent:       #A15D2E;
  --accent-light: #BC7A49;
  --accent-dim:   rgba(161, 93, 46, 0.10);
  --accent-glow:  rgba(161, 93, 46, 0.08);

  --green-dim:  rgba(34, 197, 94, 0.12);
  --red-dim:    rgba(239, 68, 68, 0.12);
  --amber-dim:  rgba(245, 158, 11, 0.14);
  --blue-dim:   rgba(59, 130, 246, 0.12);
  --cyan-dim:   rgba(6, 182, 212, 0.12);
  --purple-dim: rgba(139, 92, 246, 0.12);

  --text-primary:   #20160E;
  --text-secondary: #66584B;
  --text-muted:     #8E7D6D;
  --text-inverse:   #FFF8F1;

  --portal-app-backdrop-opacity: 0.05;
  --portal-login-backdrop-opacity: 0.12;
  --portal-backdrop-filter: blur(24px) saturate(0.42) brightness(0.98);

  --success: #16a34a;
  --warning: #d97706;
  --info:    #2563eb;
  --danger:  #dc2626;
}

/* ═══ 2. Reset & Base ═══ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 18px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Keep JS-rendered inline px typography aligned with the shared 3px size bump. */
:where([style*="font-size:9px"], [style*="font-size: 9px"]) { font-size: 12px !important; }
:where([style*="font-size:11px"], [style*="font-size: 11px"]) { font-size: 14px !important; }
:where([style*="font-size:12px"], [style*="font-size: 12px"]) { font-size: 15px !important; }
:where([style*="font-size:13px"], [style*="font-size: 13px"]) { font-size: 16px !important; }
:where([style*="font-size:14px"], [style*="font-size: 14px"]) { font-size: 17px !important; }
:where([style*="font-size:16px"], [style*="font-size: 16px"]) { font-size: 19px !important; }
:where([style*="font-size:18px"], [style*="font-size: 18px"]) { font-size: 21px !important; }
:where([style*="font-size:20px"], [style*="font-size: 20px"]) { font-size: 23px !important; }
:where([style*="font-size:22px"], [style*="font-size: 22px"]) { font-size: 25px !important; }
:where([style*="font-size:26px"], [style*="font-size: 26px"]) { font-size: 29px !important; }

a { color: var(--accent-light); text-decoration: none; }
a:hover { color: var(--accent); }

::selection { background: rgba(198,142,96,0.25); color: #fff; }

/* ═══ 3. Skip Link ═══ */
.skip-link {
  position: absolute; left: -999px; top: auto;
  z-index: 99999; padding: 8px 16px;
  background: var(--accent); color: var(--text-inverse);
  font-weight: 600; border-radius: var(--radius-sm);
}
.skip-link:focus { left: 16px; top: 16px; }

/* ═══ 4. Noise & Grid Overlays ═══ */
.noise-overlay {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
}
.bg-grid-overlay {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.02;
  background-image:
    linear-gradient(rgba(198,142,96,0.15) 1px, transparent 1px),
    linear-gradient(90deg, rgba(198,142,96,0.15) 1px, transparent 1px);
  background-size: 60px 60px;
}

/* ═══ 5. Login Overlay ═══ */
.login-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-deep);
  overflow: hidden;
}
.login-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--portal-backdrop-image) var(--portal-login-backdrop-position) / var(--portal-login-backdrop-size) no-repeat;
  opacity: var(--portal-login-backdrop-opacity);
  filter: var(--portal-backdrop-filter);
  transform: scale(1.04);
  transform-origin: center center;
}
.login-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 50% 40%, rgba(198,142,96,0.05) 0%, transparent 70%),
    linear-gradient(180deg, rgba(8, 9, 14, 0.84) 0%, rgba(8, 9, 14, 0.94) 100%);
}
.login-card {
  position: relative; width: 100%; max-width: 380px; padding: var(--space-xl);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  z-index: 1;
}
.login-logo { text-align: center; margin-bottom: var(--space-lg); }

.logo-mark {
  width: 36px; height: 36px; margin: 0 auto var(--space-md);
  background: var(--accent);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.login-title {
  font-family: var(--font-display);
  font-size: 1.35rem; font-weight: 700;
  letter-spacing: 0.04em; color: var(--text-primary);
}
.login-subtitle {
  font-size: 0.8rem; color: var(--text-secondary);
  letter-spacing: 0.08em; text-transform: uppercase;
  margin-top: 4px;
}
.login-error {
  background: var(--red-dim); color: var(--red);
  border: 1px solid rgba(239,68,68,0.2);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: 0.82rem; margin-bottom: var(--space-md);
}
.login-success {
  background: var(--green-dim); color: var(--green);
  border: 1px solid rgba(74,222,128,0.2);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: 0.82rem; margin-bottom: var(--space-md);
}
.login-divider {
  display: flex; align-items: center; gap: var(--space-md);
  color: var(--text-muted); font-size: 0.75rem;
  margin: var(--space-lg) 0;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.login-divider::before, .login-divider::after {
  content: ''; flex: 1; height: 1px;
  background: var(--border-default);
}

/* ═══ 6. App Shell ═══ */
.app-shell {
  display: flex; min-height: 100vh; position: relative; z-index: 1; isolation: isolate;
}

.app-shell::before,
.portal-landing::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background: var(--portal-backdrop-image) var(--portal-app-backdrop-position) / var(--portal-app-backdrop-size) no-repeat;
  opacity: var(--portal-app-backdrop-opacity);
  filter: var(--portal-backdrop-filter);
  transform: scale(1.04);
  transform-origin: center center;
}

/* ═══ 7. Sidebar ═══ */
.sidebar {
  width: var(--sidebar-width); min-width: var(--sidebar-width);
  background: var(--bg-base);
  border-right: 1px solid var(--border-default);
  display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0;
  z-index: 100; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--bg-hover) transparent;
}

.sidebar-header {
  padding: var(--space-lg) var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
}
.sidebar-logo {
  display: flex; align-items: center; gap: var(--space-sm);
}
.sidebar-logo .logo-mark { width: 24px; height: 24px; margin: 0; flex-shrink: 0; }
.sidebar-title {
  font-family: var(--font-display);
  font-size: 0.9rem; font-weight: 700;
  letter-spacing: 0.03em;
}
.sidebar-subtitle {
  font-size: 0.68rem; color: var(--text-secondary);
  letter-spacing: 0.06em; text-transform: uppercase;
}

/* Nav menu */
.nav-menu { flex: 1; padding: var(--space-sm) 0; overflow-y: auto; }

.nav-section { margin-bottom: 2px; }

.nav-section-title {
  display: flex; align-items: center; gap: 6px;
  padding: 8px var(--space-md);
  font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer; user-select: none;
  transition: color 0.15s;
}
.nav-section-title:hover { color: var(--text-secondary); }

.nav-section-chevron {
  width: 12px; height: 12px; flex-shrink: 0;
  transition: transform 0.2s;
}
.nav-section-title.collapsed .nav-section-chevron { transform: rotate(-90deg); }
.nav-section-title.collapsed + .nav-section-items { display: none; }

.nav-section-items { padding-bottom: 4px; }

.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px var(--space-md) 7px 28px;
  font-size: 0.82rem; color: var(--text-secondary);
  cursor: pointer; transition: all 0.12s;
  border-left: 2px solid transparent;
}
.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}
.nav-item.active {
  color: var(--accent-light);
  background: var(--accent-dim);
  border-left-color: var(--accent);
}
.nav-item-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active .nav-item-icon { opacity: 1; }

.nav-item .badge {
  margin-left: auto; font-size: 0.6rem;
  padding: 1px 6px; border-radius: 8px;
  background: var(--accent-dim); color: var(--accent);
}

/* Sidebar footer */
.sidebar-footer {
  padding: var(--space-md);
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}
.user-info {
  display: flex; align-items: center; gap: var(--space-sm);
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-dim); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700;
  font-size: 0.8rem; flex-shrink: 0;
}
.user-details { flex: 1; min-width: 0; }
.user-name {
  font-size: 0.78rem; font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role {
  font-size: 0.65rem; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ═══ 8. Main Content Area ═══ */
.app-content {
  flex: 1; margin-left: var(--sidebar-width);
  display: flex; flex-direction: column;
  min-height: 100vh;
}

/* Header */
.header {
  display: flex; align-items: center; gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-default);
  position: sticky; top: 0; z-index: 50;
}
.header-title {
  font-family: var(--font-display);
  font-size: 1.05rem; font-weight: 600;
  letter-spacing: 0.02em; flex: 1;
}
.header-actions { display: flex; align-items: center; gap: var(--space-sm); }

/* Page help button */
.page-help-btn {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg-hover); border: 1px solid var(--border-default);
  color: var(--text-muted); font-size: 0.7rem; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.15s; margin-left: 6px; vertical-align: middle;
  font-family: var(--font-body);
}
.page-help-btn:hover {
  background: var(--accent-dim); color: var(--accent);
  border-color: var(--border-accent);
}

/* Page help popover */
.page-help-popover {
  position: absolute; top: 100%; left: 0; margin-top: 8px;
  width: 340px; padding: var(--space-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
  font-size: 0.8rem; color: var(--text-secondary);
  line-height: 1.6; z-index: 200;
  animation: helpFadeIn 0.15s ease;
}
.page-help-popover::before {
  content: ''; position: absolute; top: -6px; left: 20px;
  width: 10px; height: 10px; background: var(--bg-elevated);
  border-top: 1px solid var(--border-strong);
  border-left: 1px solid var(--border-strong);
  transform: rotate(45deg);
}
@keyframes helpFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Mobile menu */
.mobile-menu-btn {
  display: none; background: none; border: none;
  color: var(--text-secondary); cursor: pointer;
  padding: 4px;
}

/* ═══ 9. Main Content ═══ */
.main-content {
  flex: 1; padding: var(--space-lg);
  max-width: 1400px; width: 100%;
}

/* ═══ 10. Cards ═══ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.card-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 {
  font-family: var(--font-display);
  font-size: 0.88rem; font-weight: 600;
  letter-spacing: 0.02em;
}
.card-body { padding: var(--space-lg); }

/* ── Page Section (card variant used by command/officer portals) ── */
.page-section {
  margin-bottom: var(--space-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
  padding: var(--space-lg);
}
.page-section > .section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  /* Stretch header edge-to-edge over the card padding */
  margin: calc(-1 * var(--space-lg)) calc(-1 * var(--space-lg)) var(--space-lg);
}
.page-section > .section-header .section-title {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
/* Full-bleed children stretch over the card padding */
.page-section > .table-wrap {
  margin: 0 calc(-1 * var(--space-lg)) calc(-1 * var(--space-lg));
  border: none;
  border-radius: 0;
}
.page-section > .section-header + .table-wrap {
  margin-top: calc(-1 * var(--space-lg));
}
@media (max-width: 768px) {
  .page-section > .section-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* ═══ 11. Stat Cards ═══ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  transition: border-color 0.15s;
}
.stat-card:hover { border-color: var(--border-strong); }
.stat-label {
  font-size: 0.7rem; font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.06em; text-transform: uppercase;
  margin-bottom: 6px;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 1.6rem; font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.stat-change {
  font-size: 0.72rem; color: var(--text-secondary);
  margin-top: 4px;
}

/* ── Table Wrap ── */
.table-wrap {
  overflow: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}

/* ═══ 12. Data Tables ═══ */
.data-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.8rem;
}
.data-table th {
  text-align: left; padding: 10px var(--space-md);
  font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-base);
  white-space: nowrap;
}
.data-table td {
  padding: 10px var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}
.data-table tr:hover td { background: var(--bg-hover); }
.data-table tr:last-child td { border-bottom: none; }

/* ═══ 13. Buttons ═══ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.82rem; font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer; transition: all 0.15s;
  white-space: nowrap; text-decoration: none;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--accent); color: var(--text-inverse);
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-light); }

.btn-secondary {
  background: var(--bg-elevated); color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--border-accent); }

.btn-ghost {
  background: transparent; color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { color: var(--text-primary); background: var(--bg-hover); }

.btn-danger {
  background: var(--red-dim); color: var(--red);
  border-color: rgba(239,68,68,0.2);
}
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,0.18); }

.btn-xs { padding: 3px 8px; font-size: 0.68rem; }
.btn-sm { padding: 5px 12px; font-size: 0.75rem; }
.btn-lg { padding: 10px 20px; font-size: 0.88rem; }
.btn-full { width: 100%; justify-content: center; }

.btn-icon {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  padding: 4px; display: inline-flex;
  transition: color 0.15s;
}
.btn-icon:hover { color: var(--text-primary); }

/* ═══ 14. Forms ═══ */
.form-group { margin-bottom: var(--space-md); }
.form-label {
  display: block; font-size: 0.75rem; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.82rem;
  transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--accent-glow);
}
.form-input::placeholder { color: var(--text-muted); }
.form-select { appearance: none; cursor: pointer; }
.form-textarea { resize: vertical; min-height: 80px; }
.form-check {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.82rem; color: var(--text-secondary);
  cursor: pointer;
}
.form-check input[type="checkbox"] { accent-color: var(--accent); }

/* ═══ 15. Badges ═══ */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 10px;
  font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.02em; white-space: nowrap;
}
.badge-success { background: var(--green-dim); color: var(--green); }
.badge-danger  { background: var(--red-dim);   color: var(--red); }
.badge-warning { background: var(--amber-dim); color: var(--amber); }
.badge-info    { background: var(--blue-dim);  color: var(--blue); }
.badge-muted   { background: rgba(255,255,255,0.05); color: var(--text-muted); }
.badge-ios     { background: var(--blue-dim);   color: var(--blue); }
.badge-android { background: var(--green-dim);  color: var(--green); }
.badge-linux   { background: var(--amber-dim);  color: var(--amber); }
.badge-purple  { background: var(--purple-dim); color: var(--purple); }
.badge-cyan    { background: var(--cyan-dim);   color: var(--cyan); }

.badge .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; margin-right: 4px;
}

/* ═══ 16. Toasts ═══ */
.toast-container {
  position: fixed; top: var(--space-lg); right: var(--space-lg);
  z-index: 10000; display: flex; flex-direction: column;
  gap: var(--space-sm); pointer-events: none;
}
.toast {
  padding: 10px var(--space-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 0.8rem; pointer-events: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  animation: toastIn 0.3s ease;
}
.toast-success { border-left: 3px solid var(--green); }
.toast-error   { border-left: 3px solid var(--red); }
.toast-warning { border-left: 3px solid var(--amber); }
.toast-info    { border-left: 3px solid var(--blue); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ═══ 17. Modals ═══ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 8000;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.modal {
  width: 95%; max-width: 640px; max-height: 90vh;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-default);
}
.modal-header h3 {
  font-family: var(--font-display);
  font-size: 0.95rem; font-weight: 600;
}
.modal-body { padding: var(--space-lg); }
.modal-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-default);
  display: flex; justify-content: flex-end; gap: var(--space-sm);
}

/* ═══ 18. Loading / Spinner ═══ */
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 60px 0;
}
.spinner {
  width: 28px; height: 28px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══ 19. Empty State ═══ */
.empty-state {
  text-align: center; padding: 48px var(--space-lg);
  color: var(--text-muted); font-size: 0.85rem;
}

/* ═══ 20. Pagination ═══ */
.pagination {
  display: flex; align-items: center; gap: 4px;
  justify-content: center; margin-top: var(--space-lg);
}
.page-btn {
  padding: 5px 10px; border-radius: var(--radius-sm);
  background: var(--bg-elevated); border: 1px solid var(--border-default);
  color: var(--text-secondary); font-size: 0.75rem;
  cursor: pointer; transition: all 0.12s;
}
.page-btn:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--border-strong); }
.page-btn.active { background: var(--accent-dim); color: var(--accent); border-color: var(--border-accent); }
.page-btn:disabled { opacity: 0.3; cursor: default; }

/* ═══ 21. Portal Switcher ═══ */
.portal-switcher { position: relative; }
.portal-menu {
  display: none; position: absolute; top: 100%; right: 0;
  margin-top: 8px; width: 240px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
  padding: var(--space-sm) 0;
  z-index: 200;
  /* Long menu (8 sections × 3+ items) overflows the viewport on
     phones, and the dropdown isn't its own scroll container. Give
     it a height cap + internal scroll so every entry stays
     reachable. overscroll-behavior keeps the page underneath from
     scrolling when the menu hits its end. */
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.portal-menu.show { display: block; }

/* On phones the header anchor sits too close to the right edge for
   a 240px dropdown — detach from it and span the viewport instead. */
@media (max-width: 600px) {
  .portal-menu {
    position: fixed;
    top: 56px; right: 8px; left: 8px;
    width: auto; max-width: none;
    max-height: calc(100vh - 72px);
  }
}
.portal-menu a {
  display: block; padding: 7px var(--space-md);
  font-size: 0.8rem; color: var(--text-secondary);
  transition: all 0.12s;
}
.portal-menu a:hover { background: var(--bg-hover); color: var(--text-primary); }
.portal-menu-disabled {
  display: block; padding: 7px var(--space-md);
  font-size: 0.8rem; color: var(--text-muted);
  opacity: 0.45; cursor: not-allowed;
  pointer-events: none;
}
.portal-menu-section {
  padding: 8px var(--space-md) 4px;
  font-size: 0.62rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted);
}
.portal-menu-divider {
  height: 1px; background: var(--border-default);
  margin: var(--space-xs) 0;
}

/* ═══ 22. Utility Classes ═══ */
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.flex-gap     { display: flex; align-items: center; gap: var(--space-sm); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.text-xs { font-size: 0.7rem; }
.text-sm { font-size: 0.8rem; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-success { color: var(--green); }
.text-danger  { color: var(--red); }
.text-warning { color: var(--amber); }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* ═══ 23. Filter Bar ═══ */
.filter-bar {
  display: flex; align-items: center; gap: var(--space-sm);
  flex-wrap: wrap; margin-bottom: var(--space-md);
}
.filter-bar .form-input,
.filter-bar .form-select { width: auto; min-width: 160px; }

/* ═══ 24. Action Bar ═══ */
.action-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-md);
}
.action-bar-title {
  font-family: var(--font-display);
  font-size: 0.9rem; font-weight: 600;
}

/* ═══ 25. Detail Grid ═══ */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-md);
}
.detail-item {}
.detail-label {
  font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 4px;
}
.detail-value { font-size: 0.85rem; color: var(--text-primary); }

/* ═══ 26. Tab Bar ═══ */
.tab-bar {
  display: flex; gap: 0; border-bottom: 1px solid var(--border-default);
  margin-bottom: var(--space-lg);
}
.tab-btn {
  padding: 10px var(--space-lg);
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-muted); font-size: 0.8rem; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
}
.tab-btn:hover { color: var(--text-secondary); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ═══ 27. Portal Selector (index.html) ═══ */
.portal-header {
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-default);
  padding: 0 var(--space-lg);
  position: sticky; top: 0; z-index: 100;
}
.portal-header-inner {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1400px; margin: 0 auto;
  height: 56px;
}
.portal-header-logo {
  display: flex; align-items: center; gap: var(--space-sm);
}
.portal-header-logo .logo-mark { width: 22px; height: 22px; margin: 0; }
.portal-header-title {
  font-family: var(--font-display);
  font-size: 0.95rem; font-weight: 700;
  letter-spacing: 0.03em;
}
.portal-header-div {
  width: 1px; height: 20px; background: var(--border-default);
  margin: 0 var(--space-sm);
}
.portal-header-sub {
  font-size: 0.72rem; color: var(--text-secondary);
  letter-spacing: 0.06em; text-transform: uppercase;
}
.portal-header-right { display: flex; align-items: center; gap: var(--space-lg); }

.portal-header-status {
  display: flex; align-items: center; gap: 6px;
}
.portal-status-dot {
  font-size: 0.72rem; color: var(--text-muted);
  display: flex; align-items: center; gap: 6px;
}
.portal-status-dot::before {
  content: ''; width: 6px; height: 6px;
  border-radius: 50%; background: var(--green);
}

.portal-header-user {
  display: flex; align-items: center; gap: var(--space-sm);
}
.portal-header-user .user-avatar { width: 28px; height: 28px; font-size: 0.7rem; }
.portal-header-user-info { display: flex; flex-direction: column; }
.portal-header-user-name { font-size: 0.78rem; font-weight: 500; }
.portal-header-user-role { font-size: 0.62rem; color: var(--text-muted); }

.portal-header-clock {
  display: flex; flex-direction: column; align-items: flex-end;
}
.portal-clock-local {
  font-family: var(--font-mono); font-size: 0.78rem;
  color: var(--text-primary); letter-spacing: 0.04em;
}
.portal-clock-utc {
  font-family: var(--font-mono); font-size: 0.62rem;
  color: var(--text-muted); letter-spacing: 0.04em;
}

/* Portal landing — stack header / grid / footer vertically */
.portal-landing { flex-direction: column; position: relative; isolation: isolate; }

/* Portal container */
.portal-container {
  max-width: 1200px; margin: 0 auto;
  padding: var(--space-xl) var(--space-lg) calc(var(--space-xl) + var(--portal-status-offset));
  position: relative; z-index: 1;
}

/* Hero */
.portal-hero { margin-bottom: var(--space-xl); }
.portal-hero-label {
  font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent); margin-bottom: var(--space-sm);
}
.portal-hero h1 {
  font-family: var(--font-display);
  font-size: 2.2rem; font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-sm);
}
.portal-hero p {
  font-size: 0.9rem; color: var(--text-secondary);
  max-width: 560px; line-height: 1.6;
}

/* Portal Grid */
.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-md);
}
.portal-section-label {
  grid-column: 1 / -1;
  font-family: var(--font-display);
  font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-muted);
  padding: var(--space-md) 0 var(--space-xs);
  border-bottom: 1px solid var(--border-subtle);
}

/* Portal Card */
.portal-card {
  display: flex; flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none; color: inherit;
}
.portal-card:hover {
  border-color: var(--border-accent);
  background: var(--bg-elevated);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.portal-card--disabled {
  opacity: 0.4;
  filter: grayscale(1);
  cursor: not-allowed;
  pointer-events: none;
}
.portal-card--disabled:hover { transform: none; border-color: var(--border-default); }
.portal-card--featured {
  grid-column: span 2;
  border-color: var(--border-accent);
  background: linear-gradient(135deg, var(--bg-surface) 0%, rgba(198,142,96,0.04) 100%);
}
.portal-card--wide { grid-column: span 2; }

.portal-card-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: var(--space-md);
}
.portal-card-icon {
  width: 40px; height: 40px; color: var(--accent);
}
.portal-card-sector {
  font-family: var(--font-mono);
  font-size: 0.62rem; color: var(--text-muted);
  letter-spacing: 0.06em;
}
.portal-card-content { flex: 1; margin-bottom: var(--space-md); }
.portal-card-title {
  font-family: var(--font-display);
  font-size: 1.05rem; font-weight: 700;
  margin-bottom: 6px; letter-spacing: 0.01em;
}
.portal-card-desc {
  font-size: 0.78rem; color: var(--text-secondary);
  line-height: 1.55;
}
.portal-card-meta {
  display: flex; align-items: center; gap: var(--space-sm);
}
.portal-card-tag {
  display: flex; align-items: center; gap: 4px;
  font-size: 0.65rem; color: var(--text-muted);
  letter-spacing: 0.04em; text-transform: uppercase;
}
.portal-card-arrow {
  margin-left: auto; color: var(--text-muted);
  transition: transform 0.2s;
}
.portal-card:hover .portal-card-arrow { transform: translateX(4px); color: var(--accent); }

/* ═══ 28. Status Bar (Footer) ═══ */
.portal-status-bar {
  display: flex; align-items: center; justify-content: center;
  gap: var(--space-lg); padding: var(--space-md) var(--space-lg);
  background: var(--bg-base);
  border-top: 1px solid var(--border-default);
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 100;
}
.portal-status-item { display: flex; flex-direction: column; align-items: center; }
.portal-status-label {
  font-size: 0.58rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted);
}
.portal-status-value {
  font-family: var(--font-mono);
  font-size: 0.82rem; font-weight: 500;
  color: var(--text-primary);
}
.portal-status-meta {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.portal-status-sep {
  width: 1px; height: 24px;
  background: var(--border-default);
}

/* ═══ 29. Radio Widget Styles ═══ */
.rw {
  position: fixed; bottom: 20px; right: 20px; z-index: 9000;
  font-family: var(--font-body);
}
.rw-toggle {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  position: relative; transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.rw-toggle:hover { background: var(--bg-hover); border-color: var(--border-accent); color: var(--accent); }
.rw-toggle--expanded { opacity: 0; pointer-events: none; }

.rw-toggle-dot {
  position: absolute; top: 4px; right: 4px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted);
}
.rw-dot-online     { background: var(--green); }
.rw-dot-tx         { background: var(--red); animation: rwPulse 0.5s infinite; }
.rw-dot-rx         { background: var(--blue); animation: rwPulse 0.8s infinite; }
.rw-dot-connecting { background: var(--amber); animation: rwPulse 1s infinite; }
.rw-dot-offline    { background: var(--text-muted); }
@keyframes rwPulse { 50% { opacity: 0.4; } }

.rw-panel {
  position: fixed; bottom: 20px; right: 20px;
  width: 320px; max-height: 560px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 48px rgba(0,0,0,0.4);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.rw-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-default);
}
.rw-header-title {
  font-family: var(--font-display);
  font-size: 0.82rem; font-weight: 600;
}
.rw-header-actions { display: flex; gap: 4px; }
.rw-header-btn {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  padding: 4px; display: flex; transition: color 0.15s;
}
.rw-header-btn:hover { color: var(--text-primary); }

.rw-body { flex: 1; padding: var(--space-md); overflow-y: auto; }

.rw-channel-row {
  display: flex; align-items: center; gap: var(--space-sm);
  margin-bottom: var(--space-md);
}
.rw-channel-select {
  flex: 1; padding: 6px 8px;
  background: var(--bg-input); border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 0.78rem;
}
.rw-status-text {
  font-family: var(--font-mono);
  font-size: 0.62rem; font-weight: 600;
  letter-spacing: 0.08em; color: var(--text-muted);
}
.rw-st-tx { color: var(--red); }
.rw-st-rx { color: var(--blue); }
.rw-st-connecting { color: var(--amber); }
.rw-st-err { color: var(--red); }

.rw-ptt {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--bg-elevated);
  border: 2px solid var(--border-strong);
  color: var(--text-secondary);
  cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  margin: 0 auto var(--space-md);
  transition: all 0.15s; user-select: none;
}
.rw-ptt:hover { border-color: var(--accent); color: var(--accent); }
.rw-ptt-tx { background: var(--red-dim) !important; border-color: var(--red) !important; color: var(--red) !important; }
.rw-ptt-rx { border-color: var(--blue) !important; color: var(--blue) !important; }
.rw-ptt-label { font-size: 0.52rem; font-weight: 700; letter-spacing: 0.1em; margin-top: 2px; }

.rw-section-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-sm); margin: 0 0 var(--space-sm);
}
.rw-section-row--history { margin-top: var(--space-md); }
.rw-section-title {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-muted);
}
.rw-section-actions { display: flex; gap: 6px; }
.rw-mini-btn {
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 0.68rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.rw-mini-btn:hover,
.rw-mini-btn.is-active {
  border-color: var(--border-accent);
  color: var(--accent);
}
.rw-compose {
  display: none;
  margin-bottom: var(--space-sm);
  padding: 10px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}
.rw-textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-input);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.76rem;
}
.rw-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
}
.rw-inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 0.72rem;
  color: var(--text-secondary);
}
.rw-compose-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-top: 10px;
}
.rw-compose-status {
  min-height: 1em;
  font-size: 0.68rem;
  color: var(--text-muted);
}
.rw-compose-status--err { color: var(--red); }
.rw-message-history {
  max-height: 148px;
  overflow-y: auto;
  padding-right: 2px;
}
.rw-msg-item {
  padding: 7px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.rw-msg-item:last-child { border-bottom: none; }
.rw-msg-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.rw-msg-user {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-primary);
}
.rw-msg-meta {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-align: right;
}
.rw-msg-text {
  margin-top: 3px;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text-secondary);
  word-break: break-word;
}
.rw-msg-critical {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(255, 93, 108, 0.14);
  color: var(--red);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.rw-feed { max-height: 160px; overflow-y: auto; }
.rw-feed-empty { font-size: 0.72rem; color: var(--text-muted); text-align: center; padding: var(--space-md); }
.rw-feed-item {
  display: flex; gap: 8px; padding: 4px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.72rem;
}
.rw-feed-icon { font-size: 0.8rem; }
.rw-feed-content { flex: 1; min-width: 0; }
.rw-feed-user { font-weight: 600; color: var(--text-primary); }
.rw-feed-ch { background: var(--accent-dim); color: var(--accent); padding: 0 4px; border-radius: 3px; font-size: 0.62rem; }
.rw-feed-time { color: var(--text-muted); font-size: 0.62rem; }
.rw-feed-text { color: var(--text-secondary); margin-top: 2px; }

/* Settings overlay */
.rw-settings-overlay {
  position: fixed; inset: 0; z-index: 9500;
  background: rgba(0,0,0,0.5);
  display: none; align-items: center; justify-content: center;
}
.rw-settings {
  width: 360px; max-height: 80vh;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.rw-settings-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-md); border-bottom: 1px solid var(--border-default);
  font-family: var(--font-display); font-size: 0.85rem; font-weight: 600;
}
.rw-settings-body { padding: var(--space-md); overflow-y: auto; }
.rw-settings-footer {
  padding: var(--space-md);
  border-top: 1px solid var(--border-default);
  display: flex; justify-content: flex-end; gap: var(--space-sm);
}
.rw-label {
  display: block; font-size: 0.7rem; font-weight: 500;
  color: var(--text-secondary); margin: var(--space-sm) 0 4px;
}
.rw-input {
  width: 100%; padding: 6px 10px;
  background: var(--bg-input); border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 0.78rem;
}
.rw-input:focus { outline: none; border-color: var(--border-focus); }
.rw-conn-status {
  font-size: 0.72rem; color: var(--text-muted);
  margin: var(--space-sm) 0;
}
.rw-conn-ok   { color: var(--green); }
.rw-conn-warn { color: var(--amber); }
.rw-conn-err  { color: var(--red); }
.rw-channel-checks {
  display: flex; flex-wrap: wrap; gap: 4px;
  max-height: 100px; overflow-y: auto;
}
.rw-check-label {
  display: flex; align-items: center; gap: 4px;
  font-size: 0.72rem; color: var(--text-secondary);
}

/* ═══ 30. Responsive ═══ */
@media (max-width: 768px) {
  :root {
    --portal-app-backdrop-size: min(78vw, 560px) auto;
    --portal-app-backdrop-position: center 14%;
    --portal-app-backdrop-opacity: 0.055;
    --portal-login-backdrop-size: min(72vw, 500px) auto;
    --portal-login-backdrop-position: center 12%;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .app-content { margin-left: 0; }
  .mobile-menu-btn { display: flex; }
  .portal-grid { grid-template-columns: 1fr; }
  .portal-card--featured, .portal-card--wide { grid-column: span 1; }
  .portal-header-clock, .portal-header-status { display: none; }
  .portal-status-bar { gap: var(--space-md); }
}

@media (max-width: 480px) {
  .portal-hero h1 { font-size: 1.6rem; }
  .main-content { padding: var(--space-md); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ═══ 31. Scrollbar ═══ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-active); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ═══ 32. Situation Room specific ═══ */
.sr-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr; gap: var(--space-md);
  height: calc(100vh - 120px);
}
.sr-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden; display: flex; flex-direction: column;
}
.sr-panel-header {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: space-between;
}
.sr-panel-body { flex: 1; overflow: auto; padding: var(--space-md); }

.sr-live-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.6rem; font-weight: 700;
  color: var(--red); letter-spacing: 0.08em;
}
.sr-live-badge::before {
  content: ''; width: 6px; height: 6px;
  border-radius: 50%; background: var(--red);
  animation: rwPulse 1s infinite;
}

/* ═══ 33. Dispatch specific ═══ */
.dispatch-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr; gap: var(--space-md);
  height: calc(100vh - 120px);
}
.dispatch-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden; display: flex; flex-direction: column;
}
.dispatch-panel-header {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: space-between;
}
.dispatch-panel-body { flex: 1; overflow: auto; }

/* ═══ 34. Notification Bell ═══ */
.notif-bell {
  position: relative; background: none; border: none;
  color: var(--text-muted); cursor: pointer; padding: 4px;
}
.notif-bell:hover { color: var(--text-primary); }
.notif-bell-badge {
  position: absolute; top: -2px; right: -2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--red); color: #fff;
  font-size: 0.52rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.notif-dropdown {
  position: absolute; top: 100%; right: 0;
  width: 320px; max-height: 400px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
  overflow-y: auto; z-index: 200;
  display: none;
}
.notif-dropdown.show { display: block; }
.notif-item {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.75rem; color: var(--text-secondary);
}
.notif-item:hover { background: var(--bg-hover); }

/* ═══ 35. Toggle Switch ═══ */
.toggle-switch {
  position: relative; width: 36px; height: 20px;
  display: inline-block; cursor: pointer;
}
.toggle-switch input { display: none; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--bg-active); border-radius: 10px;
  transition: background 0.2s;
}
.toggle-switch input:checked + .toggle-track { background: var(--accent); }
.toggle-track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-track::after { transform: translateX(16px); }
