/* ═══════════════════════════════════════════
   TRIVIA — Ground-Based SAR Monitoring
   IRIS-Aligned Dark Theme
   ═══════════════════════════════════════════ */

/* ── CSS Custom Properties ── */
:root {
  /* Fonts — system stack (matches IRIS) */
  --font-mono: 'Consolas', 'Monaco', monospace;

  /* Brand */
  --brand-primary: #0b2954;
  --brand-secondary: #00ffff;
  --brand-secondary-rgb: 0, 255, 255;
  --brand-accent: #4cc9f0;

  /* Surfaces — IRIS dark progression */
  --surface-0: #0b141f;
  --surface-1: #1a1d20;
  --surface-2: #212529;
  --surface-3: #2b3035;
  --surface-4: #343a40;

  /* Action — blue (IRIS primary) */
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-active: #1e40af;
  --accent-dim: rgba(37, 99, 235, 0.15);
  --accent-subtle: rgba(37, 99, 235, 0.06);

  /* Secondary accent */
  --clr-accent: #4dc9f6;
  --clr-disp: #20c997;

  /* Status */
  --status-active: #1a936f;
  --status-warning: #ffc107;
  --status-error: #d64550;
  --status-inactive: #6c757d;
  --status-processing: #3b82f6;

  /* Text */
  --text-0: #ffffff;
  --text-1: #adb5bd;
  --text-2: #6c757d;
  --text-3: #495057;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);

  /* Layout */
  --sidebar-width: 240px;
  --sidebar-collapsed: 56px;
  --topbar-height: 48px;

  /* Motion */
  --ease-fast: 120ms ease;
  --ease-normal: 200ms ease;
  --ease-slow: 350ms ease;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}


/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 14px; }

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-0);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0;
}

.mono, code, .data-value {
  font-family: var(--font-mono);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--ease-fast);
}
a:hover { color: var(--accent-hover); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-2); }


/* ── Layout — Sidebar + Topbar Grid ── */
body.has-sidebar {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
  min-height: 100dvh;
}

body.has-sidebar.sidebar-collapsed {
  grid-template-columns: var(--sidebar-collapsed) 1fr;
}


/* ── Sidebar ── */
.app-sidebar {
  grid-area: sidebar;
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface-1);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1040;
  transition: width 0.25s ease;
}

/* Collapsed state (icon-only) */
body.sidebar-collapsed .app-sidebar-brand-text,
body.sidebar-collapsed .app-sidebar-link span,
body.sidebar-collapsed .app-sidebar-section-label,
body.sidebar-collapsed .app-sidebar-user span {
  display: none;
}

body.sidebar-collapsed .app-sidebar-link {
  justify-content: center;
  padding: 8px 0;
  margin: 1px 4px;
  width: calc(100% - 8px);
}

body.sidebar-collapsed .app-sidebar-link i {
  margin: 0;
}

body.sidebar-collapsed .app-sidebar-section {
  padding: 16px 0 4px;
}

body.sidebar-collapsed .app-sidebar-user {
  justify-content: center;
  padding: 8px 0;
  margin: 1px 4px;
}

body.sidebar-collapsed .app-sidebar-brand {
  justify-content: center;
  padding: 0 8px;
}

body.sidebar-collapsed .app-sidebar-projects {
  display: none;
}

/* ---- Brand ---- */
.app-sidebar-brand {
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.app-sidebar-logo {
  height: 28px;
  width: auto;
  flex-shrink: 0;
}

.app-sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.app-sidebar-brand-link:hover {
  text-decoration: none;
  color: inherit;
  opacity: 0.85;
}

.app-sidebar-brand-text {
  font-size: 17.6px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

/* Collapse button in brand area — shown only when expanded */
.app-sidebar-collapse-btn {
  display: none;
  margin-left: auto;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.5);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12.8px;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.app-sidebar-collapse-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

body:not(.sidebar-collapsed):not(.viewer-page) .app-sidebar-collapse-btn {
  display: flex;
}

/* ---- Section labels ---- */
.app-sidebar-section {
  padding: 20px 16px 4px;
}

.app-sidebar-section-label {
  font-size: 10.4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.35);
  white-space: nowrap;
}

/* ---- Links ---- */
.app-sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 14px;
  border-radius: 6px;
  margin: 1px 8px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  width: calc(100% - 16px);
}

.app-sidebar-link:link,
.app-sidebar-link:visited,
.app-sidebar-link:active {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
}

.app-sidebar-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  text-decoration: none;
}

.app-sidebar-link.active,
.app-sidebar-link.active:link,
.app-sidebar-link.active:visited,
.app-sidebar-link.active:active,
.app-sidebar-link.active:hover {
  background: var(--accent-dim);
  color: var(--accent);
}

.app-sidebar-link i {
  font-size: 17.6px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

/* ---- Nav scroll area ---- */
.app-sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.app-sidebar-nav::-webkit-scrollbar { width: 4px; }
.app-sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.app-sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 2px; }
.app-sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3); }

/* ---- Projects list (TRIVIA-specific) ---- */
.app-sidebar-projects { padding: 0; }

.app-sidebar-project-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 16px 5px 24px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
}

.app-sidebar-project-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.app-sidebar-project-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.app-sidebar-project-dot.active { background: var(--status-active); }
.app-sidebar-project-dot.inactive { background: var(--status-inactive); }

/* ---- Footer ---- */
.app-sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 8px 0;
  flex-shrink: 0;
}

.app-sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  margin: 1px 8px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  border-radius: 6px;
  transition: background 0.15s;
}

.app-sidebar-user:hover {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.7);
}

.app-sidebar-user > i {
  font-size: 20.8px;
  flex-shrink: 0;
}

.app-sidebar-user-email {
  font-size: 12.8px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.app-sidebar-user-role {
  font-size: 10.4px;
  color: rgba(255, 255, 255, 0.45);
}

/* ── Topbar ── */
.app-topbar {
  grid-area: topbar;
  background: var(--surface-0);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 1030;
}

.app-topbar-toggle {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 20px;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.app-topbar-toggle:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }

.app-topbar-context {
  font-size: 14.4px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.75);
  white-space: nowrap;
}

.app-topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.app-topbar-sse {
  font-size: 8px;
  color: var(--status-inactive);
  display: flex;
  align-items: center;
}
.app-topbar-sse.connected { color: var(--status-active); }
.app-topbar-sse.error { color: var(--status-error); }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  border: none;
  background: none;
  transition: color 0.15s, background 0.15s;
}
.topbar-user:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }


/* ── Main Content ── */
.app-main {
  grid-area: main;
  overflow-y: auto;
  padding: 24px;
}


/* ── Stats Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: border-color var(--ease-normal);
}
.stat-card:hover { border-color: var(--border-default); }

.stat-value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 500;
  color: var(--text-0);
  line-height: 1.1;
}

.stat-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-top: 4px;
}


/* ── Project Cards ── */
.projects-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.projects-header h2 { font-size: 18px; }

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.project-card {
  background: var(--surface-2);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  opacity: 0;
  animation: fadeInUp 0.4s ease forwards;
  overflow: hidden;
}
.project-card:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 12px 35px rgba(11, 41, 84, 0.28), 0 0 20px rgba(0, 255, 255, 0.18);
  border-color: rgba(0, 255, 255, 0.45);
}

.project-card-body {
  padding: 16px;
}

.project-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.project-card-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-0);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.project-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 12px;
}

.project-card-stats {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.project-card-stats .stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.project-card-stats .stat-num {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text-0);
  font-size: 14px;
}

.project-card-stats .stat-lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
}

.project-card-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.project-card-footer .btn {
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
  color: var(--text-2);
  border-color: rgba(255, 255, 255, 0.12);
  background: transparent;
}
.project-card-footer .btn:hover {
  color: var(--text-0);
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06);
}
.project-card-footer .btn-outline-danger:hover {
  color: var(--status-error);
  border-color: var(--status-error);
  background: rgba(214, 69, 80, 0.1);
}


/* ── Badges ── */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-status .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.badge-active { background: rgba(26, 147, 111, 0.12); color: var(--status-active); }
.badge-active .dot { background: var(--status-active); animation: status-pulse 2s ease-in-out infinite; }
.badge-processing { background: rgba(59, 130, 246, 0.12); color: var(--status-processing); }
.badge-processing .dot { background: var(--status-processing); animation: pulse 1.5s infinite; }
.badge-inactive { background: rgba(108, 117, 125, 0.12); color: var(--status-inactive); }
.badge-inactive .dot { background: var(--status-inactive); }
.badge-error { background: rgba(214, 69, 80, 0.12); color: var(--status-error); }
.badge-error .dot { background: var(--status-error); }

.badge-sensor {
  background: var(--accent-dim);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
}


/* ── Buttons ── */
.btn-primary {
  background: var(--accent);
  border: none;
  color: #ffffff;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--ease-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary:hover { background: var(--accent-hover); color: #ffffff; filter: brightness(1.08); }
.btn-primary:active { background: var(--accent-active); }
.btn-primary:disabled { opacity: 0.65; cursor: not-allowed; }

.btn-outline-primary {
  background: transparent;
  color: #60a5fa;
  border: 1px solid #60a5fa;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--ease-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-outline-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-danger {
  background-color: var(--status-error);
  border: none;
  color: #ffffff;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--ease-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(214, 69, 80, 0.18);
}
.btn-danger:hover { background-color: #b13842; box-shadow: 0 6px 16px rgba(214, 69, 80, 0.25); }
.btn-danger:active { background-color: #8c222a; }
.btn-danger:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }


/* ── Forms ── */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: 6px;
}

.form-control,
.form-select {
  background: var(--surface-1) !important;
  border: 1px solid var(--border-default) !important;
  color: var(--text-0) !important;
  border-radius: var(--radius-sm) !important;
  padding: 8px 12px !important;
  font-size: 13px !important;
  transition: border-color var(--ease-fast) !important;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px var(--accent-dim) !important;
  outline: none !important;
}

.form-control::placeholder { color: var(--text-3) !important; }


/* ── Modal ── */
.modal-content {
  background: var(--surface-2) !important;
  border: 1px solid var(--border-default) !important;
  border-radius: var(--radius-lg) !important;
}
.modal-header { border-bottom: 1px solid var(--border-subtle) !important; padding: 16px 20px !important; }
.modal-title { font-size: 18px !important; font-weight: 600 !important; }
.modal-body { padding: 20px !important; }
.modal-footer { border-top: 1px solid var(--border-subtle) !important; padding: 12px 20px !important; }


/* ── Dropdown ── */
.dropdown-menu {
  background: var(--surface-3) !important;
  border: 1px solid var(--border-default) !important;
  border-radius: var(--radius-md) !important;
  padding: 4px !important;
}

.dropdown-item {
  color: var(--text-1) !important;
  font-size: 13px !important;
  border-radius: var(--radius-sm) !important;
  padding: 6px 12px !important;
}
.dropdown-item:hover { background: var(--surface-4) !important; color: var(--text-0) !important; }


/* ── Toast Container ── */
#alerts-container {
  position: fixed;
  top: 56px;
  right: 16px;
  z-index: 11000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}


/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-2);
}
.empty-state i { font-size: 48px; color: var(--text-3); margin-bottom: 16px; display: block; }
.empty-state h3 { font-size: 18px; color: var(--text-1); margin-bottom: 8px; }
.empty-state p { font-size: 13px; max-width: 300px; margin: 0 auto 20px; }


/* ── Loading ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 20, 31, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-default);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}


/* ── Tables ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-2);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-default);
  text-align: left;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-1);
}

.data-table tr:hover td { background: var(--surface-3); }


/* ── Tabs (IRIS pattern) ── */
.nav-tabs {
  border-color: rgba(37, 99, 235, 0.2);
}

.nav-tabs .nav-link {
  color: var(--accent);
  font-weight: 600;
  transition: all 0.2s ease;
  border: none;
  border-bottom: 3px solid transparent;
  background: transparent;
}

.nav-tabs .nav-link:hover,
.nav-tabs .nav-link:focus {
  color: var(--accent-hover);
  border-bottom-color: rgba(37, 99, 235, 0.5);
  background-color: rgba(37, 99, 235, 0.08);
}

.nav-tabs .nav-link.active {
  color: var(--text-0);
  background-color: rgba(37, 99, 235, 0.12);
  border: none;
  border-bottom: 3px solid var(--accent);
  box-shadow: none;
}


/* ── Animations ── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}


/* ── Login Page ── */
.login-page {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--surface-0);
  font-size: 16px;
}

.login-bg {
  position: absolute;
  inset: 0;
  background: url('../img/login-bg.webp') center/cover no-repeat;
  filter: brightness(0.55) saturate(1.2);
  z-index: 0;
}

.login-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.6) 100%);
}

.login-card {
  position: relative;
  z-index: 1;
  width: 420px;
  max-width: 92vw;
  border-radius: 16px;
  background: rgba(15, 28, 46, 0.18);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  padding: 2.5rem 2rem;
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

.login-card:hover {
  border-color: rgba(var(--brand-secondary-rgb), 0.25);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.3),
    0 0 20px rgba(var(--brand-secondary-rgb), 0.06);
}

.login-brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-brand img {
  height: 44px;
  margin-bottom: 0.75rem;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

.login-brand h3 {
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}

.login-brand p {
  color: rgba(255, 255, 255, 0.45);
  font-size: 13.6px;
  margin: 0;
}

.login-card .form-label {
  color: rgba(255, 255, 255, 0.6);
  font-size: 12.8px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.login-card .form-control {
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  color: #fff !important;
  border-radius: 8px !important;
  padding: 9.6px 13.6px !important;
  font-size: 16px !important;
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}

.login-card .form-control::placeholder {
  color: rgba(255, 255, 255, 0.25) !important;
}

.login-card .form-control:focus {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(var(--brand-secondary-rgb), 0.4) !important;
  box-shadow: 0 0 0 3px rgba(var(--brand-secondary-rgb), 0.1) !important;
  color: #fff !important;
}

.login-card .btn-primary {
  border-radius: 8px;
  padding: 9.6px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-top: 8px;
  justify-content: center;
}

.login-card .password-toggle {
  color: rgba(255, 255, 255, 0.35);
  text-decoration: none;
  padding: 0;
  line-height: 1;
  border: none;
  box-shadow: none !important;
}

.login-card .password-toggle:hover {
  color: rgba(255, 255, 255, 0.7);
}

.login-card .alert {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.85rem;
}


/* ── Filter Controls ── */
.filter-row { margin-bottom: 10px; }

.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.filter-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-1);
}

.filter-toggle input[type="checkbox"] {
  accent-color: var(--accent);
  width: 13px;
  height: 13px;
  cursor: pointer;
}

.filter-name { font-weight: 500; }

.filter-range-text {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-2);
}

.filter-slider {
  height: 4px;
  margin: 6px 0 2px;
}

.filter-slider.disabled { opacity: 0.35; pointer-events: none; }

.filter-slider .noUi-target {
  background: var(--surface-3);
  border: none;
  border-radius: 2px;
  box-shadow: none;
  height: 4px;
}

.filter-slider .noUi-connect { background: var(--accent); }

.filter-slider .noUi-handle {
  background: var(--accent);
  border: none;
  border-radius: 50%;
  width: 10px !important;
  height: 10px !important;
  right: -5px !important;
  top: -3px !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  cursor: grab;
}

.filter-slider .noUi-handle::before,
.filter-slider .noUi-handle::after { display: none; }

.filter-stats {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.filter-stats-text {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-2);
}


/* ── Viewer page: auto-collapse sidebar ── */
body.viewer-page.has-sidebar {
  grid-template-columns: var(--sidebar-collapsed) 1fr;
}

body.viewer-page .app-sidebar-brand-text,
body.viewer-page .app-sidebar-link span,
body.viewer-page .app-sidebar-section-label,
body.viewer-page .app-sidebar-user span,
body.viewer-page .app-sidebar-projects {
  display: none;
}

body.viewer-page .app-sidebar-link {
  justify-content: center;
  padding: 8px 0;
  margin: 1px 4px;
  width: calc(100% - 8px);
}

body.viewer-page .app-sidebar-link i {
  margin: 0;
}

body.viewer-page .app-sidebar-section {
  padding: 16px 0 4px;
}

body.viewer-page .app-sidebar-user {
  justify-content: center;
  padding: 8px 0;
  margin: 1px 4px;
}

body.viewer-page .app-sidebar-brand {
  justify-content: center;
  padding: 0 8px;
}

/* Viewer: expanded overlay (toggled via hamburger) — overlays, does not push content */
body.viewer-page.sidebar-viewer-expanded .app-sidebar {
  position: fixed;
  width: var(--sidebar-width);
  height: 100%;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  z-index: 1050;
}

body.viewer-page.sidebar-viewer-expanded .app-sidebar-brand-text,
body.viewer-page.sidebar-viewer-expanded .app-sidebar-link span,
body.viewer-page.sidebar-viewer-expanded .app-sidebar-section-label,
body.viewer-page.sidebar-viewer-expanded .app-sidebar-user span,
body.viewer-page.sidebar-viewer-expanded .app-sidebar-projects {
  display: unset;
}

body.viewer-page.sidebar-viewer-expanded .app-sidebar-link {
  justify-content: flex-start;
  padding: 8px 16px;
  margin: 1px 8px;
  width: calc(100% - 16px);
}

body.viewer-page.sidebar-viewer-expanded .app-sidebar-section {
  padding: 20px 16px 4px;
}

body.viewer-page.sidebar-viewer-expanded .app-sidebar-user {
  justify-content: flex-start;
  padding: 8px 16px;
  margin: 1px 8px;
}

body.viewer-page.sidebar-viewer-expanded .app-sidebar-brand {
  justify-content: flex-start;
  padding: 0 16px;
}

body.viewer-page.sidebar-viewer-expanded .app-sidebar-collapse-btn {
  display: flex;
}

body.viewer-page.sidebar-viewer-expanded .app-sidebar-backdrop {
  display: block;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  background: rgba(0, 0, 0, 0.35);
}


/* ── Sidebar backdrop ── */
.app-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1039;
}

/* ── Responsive (< 1200px) ── */
@media (max-width: 1199.98px) {
  body.has-sidebar {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-height) 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }

  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: auto;
    width: 240px;
    transform: translateX(-100%);
    box-shadow: none;
  }

  .app-sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
  }

  .app-sidebar.mobile-open ~ .app-sidebar-backdrop {
    display: block;
  }

  /* On mobile, sidebar-collapsed class shouldn't affect layout */
  body.sidebar-collapsed .app-sidebar { width: 240px; }

  body.sidebar-collapsed .app-sidebar-brand-text,
  body.sidebar-collapsed .app-sidebar-link span,
  body.sidebar-collapsed .app-sidebar-section-label,
  body.sidebar-collapsed .app-sidebar-user span {
    display: unset;
  }

  body.sidebar-collapsed .app-sidebar-link {
    justify-content: flex-start;
    padding: 8px 16px;
    margin: 1px 8px;
    width: calc(100% - 16px);
  }

  body.sidebar-collapsed .app-sidebar-section {
    padding: 20px 16px 4px;
  }

  body.sidebar-collapsed .app-sidebar-user {
    justify-content: flex-start;
    padding: 8px 16px;
    margin: 1px 8px;
  }

  body.sidebar-collapsed .app-sidebar-brand {
    justify-content: flex-start;
    padding: 0 16px;
  }

  body.sidebar-collapsed .app-sidebar-projects {
    display: block;
  }

  /* On mobile, viewer-page uses standard mobile sidebar */
  body.viewer-page.has-sidebar {
    grid-template-columns: 1fr;
  }

  body.viewer-page .app-sidebar-brand-text,
  body.viewer-page .app-sidebar-link span,
  body.viewer-page .app-sidebar-section-label,
  body.viewer-page .app-sidebar-user span,
  body.viewer-page .app-sidebar-projects {
    display: unset;
  }

  body.viewer-page .app-sidebar-link {
    justify-content: flex-start;
    padding: 8px 16px;
    margin: 1px 8px;
    width: calc(100% - 16px);
  }

  body.viewer-page .app-sidebar-section {
    padding: 20px 16px 4px;
  }

  body.viewer-page .app-sidebar-user {
    justify-content: flex-start;
    padding: 8px 16px;
    margin: 1px 8px;
  }

  body.viewer-page .app-sidebar-brand {
    justify-content: flex-start;
    padding: 0 16px;
  }

  .projects-grid { grid-template-columns: 1fr; }
  .app-main { padding: 16px; }
}

/* ── Print ── */
@media print {
  .app-sidebar,
  .app-topbar,
  .app-sidebar-backdrop {
    display: none !important;
  }
  body.has-sidebar {
    grid-template-columns: 1fr;
  }
  .app-main { margin: 0 !important; width: 100% !important; }
}

/* View-only ("viewer") accounts: controls that would change data are hidden.
   The server refuses those changes anyway (auth/access.py). */
.role-viewer .viewer-hide { display: none !important; }
