/* ==========================================================================
   Premium Dark Theme for JOUD SRL Fleet Dashboard
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

:root {
  /* Core Colors */
  --bg: #090B10;
  /* Very deep dark blue/black */
  --surface: #10141D;
  /* Slightly lighter for cards */
  --surface-hover: #151A26;
  --surface-glass: rgba(16, 20, 29, 0.7);

  /* Borders & Dividers */
  --border: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(255, 255, 255, 0.15);

  /* Accents */
  --accent-primary: #3b82f6;
  --accent-secondary: #8b5cf6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.35);
  --gradient-primary: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));

  /* Status Colors */
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);

  /* Typography */
  --text-main: #f8fafc;
  --text-muted: #94a3b8;

  /* Layout & Spacing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border);
  --shadow-glow: 0 0 20px var(--accent-glow);

  /* Animations */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  position: relative;
}

/* Subtle background glow effect */
body::before {
  content: '';
  position: fixed;
  top: -20vh;
  left: -10vw;
  width: 50vw;
  height: 50vh;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 60%);
  opacity: 0.5;
  z-index: -1;
  pointer-events: none;
}

/* ── HEADER ── */
header {
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--gradient-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.logo h1 {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo span {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.1);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  margin-left: 0.5rem;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--success);
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse 2.5s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.5;
    transform: scale(0.9);
  }
}

/* ── ADVANCED STATS TAB ── */
.stats-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-bottom: 2rem;
}

.custom-date-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  animation: slideDown 0.2s ease-out forwards;
}

.date-input {
  background: var(--surface-light);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
}

.date-input:focus {
  outline: none;
  border-color: var(--accent);
}

.adv-stats-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1.5rem;
}

.adv-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  grid-column: span 4;
}

.adv-stat-card.hero-card {
  grid-column: span 12;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.4) 0%, rgba(15, 23, 42, 0.8) 100%);
  border: 1px solid var(--border-highlight);
}

.adv-stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-highlight);
  box-shadow: var(--shadow-md);
}

.adv-stat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.adv-stat-title {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.adv-stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.adv-stat-icon.amber {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.adv-stat-icon.purple {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
}

.adv-stat-icon.blue {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.adv-stat-value {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.adv-stat-subtext {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
}

/* Fleet Health Specific inside Stats */
.fleet-health-stats {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: auto;
}

.health-item {
  display: flex;
  align-items: center;
  font-size: 0.95rem;
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.75rem;
}

.health-dot.green {
  background: var(--success);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

.health-dot.blue {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
}

.health-dot.red {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

.health-label {
  color: var(--text-muted);
  flex: 1;
}

.health-val {
  font-weight: 600;
  color: var(--text);
}

/* Stats Loading */
.stats-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  color: var(--text-dim);
  gap: 1rem;
}

/* ── TABS ── */
.tabs {
  display: flex;
  gap: 0.5rem;
  padding: 0 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  padding: 0.875rem 1.25rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: var(--transition-fast);
}

.tab-btn::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-primary);
  transform: scaleX(0);
  transition: var(--transition-fast);
  border-radius: 2px 2px 0 0;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--text-main);
}

.tab-btn.active::after {
  transform: scaleX(1);
}

/* ── SECTIONS ── */
.section {
  padding: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  display: none;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section.active {
  display: block;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-main);
}

/* ── BUTTONS ── */
.btn {
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
  border: none;
}

.btn-primary:hover {
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.5);
  filter: brightness(1.1);
}

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-main);
}

.btn-outline:hover {
  background: var(--surface-hover);
  border-color: var(--border-highlight);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.2);
}

.btn-success:hover {
  background: rgba(16, 185, 129, 0.25);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
}

/* ── TABLE WRAPPER & TOOLBAR ── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.01);
}

.toolbar input {
  flex: 1;
  min-width: 200px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  transition: var(--transition-fast);
}

.toolbar input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.toolbar input::placeholder {
  color: var(--text-muted);
}

.chip-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.chip {
  padding: 0.375rem 1rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.chip:hover {
  border-color: var(--text-muted);
  color: var(--text-main);
}

.chip.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* ── DESKTOP TABLE ── */
.desktop-view {
  overflow-x: auto;
}

.desktop-view table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  text-align: left;
}

.desktop-view thead tr {
  background: rgba(255, 255, 255, 0.02);
}

th {
  padding: 0.875rem 1.25rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-main);
}

.desktop-view tbody tr {
  transition: background-color var(--transition-fast);
}

.desktop-view tbody tr:hover {
  background-color: var(--surface-hover);
}

.desktop-view tbody tr:last-child td {
  border-bottom: none;
}

.empty-row td {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}

.badge.avail {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.2);
}

.badge.inuse {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.2);
}

.badge.ok {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.2);
}

.badge.warning {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.2);
}

.badge.expired {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
}

.badge.active {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.2);
}

.badge.completed {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border-color: var(--border);
}

.badge.missing {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border-color: var(--border);
}

/* ── MOBILE CARDS ── */
.mobile-view {
  display: none;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg);
}

.entity-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  transition: var(--transition-smooth);
}

.entity-card:active {
  transform: scale(0.99);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.card-plate {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 1rem;
  color: var(--text-main);
  font-weight: 700;
}

.card-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
}

.card-row:last-child {
  border-bottom: none;
}

.card-row .label {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.card-row .val {
  font-weight: 500;
  color: var(--text-main);
  text-align: right;
}

.card-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  background: var(--surface);
}

.page-info {
  color: var(--text-muted);
}

.page-btns {
  display: flex;
  gap: 0.5rem;
}

.page-btn {
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.page-btn:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--text-muted);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-btn.current {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

/* ── MODALS ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 11, 16, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 1;
  visibility: visible;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: scale(1) translateY(0);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.hidden .modal {
  transform: scale(0.95) translateY(20px);
}

/* Wide document viewer modal */
.modal-xl {
  max-width: 900px;
}

.doc-modal-body {
  padding: 0 !important;
  height: 72vh;
  overflow: hidden;
}

/* Inline doc action links (view / download) for car table rows */
.doc-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.doc-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-sub);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.doc-chip:hover {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
}

.doc-chip.no-doc {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

/* ── Current file preview card inside the car modal ── */
.file-current {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(59, 130, 246, 0.07);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.file-current.hidden {
  display: none;
}

.file-current-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.file-current-name {
  flex: 1;
  font-size: 0.78rem;
  color: var(--accent-primary);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.file-current-name:hover {
  text-decoration: underline;
}

.file-current-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.file-replace-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.file-replace-label.hidden {
  display: none;
}

.file-input-styled {
  display: block;
  width: 100%;
  padding: 0.5rem;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-sub);
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.2s;
}

.file-input-styled:hover {
  border-color: var(--accent-primary);
}

/* Extra-small button variant */
.btn-xs {
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
  border-radius: var(--radius-sm);
}


.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-main);
}

.modal-close {
  background: rgba(255, 255, 255, 0.05);
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-group input,
.form-group select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  width: 100%;
  transition: var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.modal-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ── TOASTS ── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  font-size: 0.875rem;
  color: var(--text-main);
  min-width: 280px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transform: translateX(100%);
  opacity: 0;
  animation: toastSlideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes toastSlideIn {
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--danger);
}

/* ── RESPONSIVENESS ── */
@media(max-width: 768px) {
  header {
    padding: 0 1rem;
  }

  .logo span {
    display: none;
  }

  /* Hide 'Fleet Dashboard' subtitle */
  #db-status {
    display: none;
  }

  /* Hide 'Database Connected' text */
  .header-status button {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    margin-left: 0.5rem !important;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    padding: 1rem;
    gap: 0.75rem;
  }

  .stat-card {
    padding: 0.75rem;
    gap: 0.75rem;
    border-radius: var(--radius-sm);
  }

  .stat-icon {
    width: 38px;
    height: 38px;
    font-size: 18px;
  }

  .stat-value {
    font-size: 1.35rem;
  }

  .stat-label {
    font-size: 0.65rem;
    margin-bottom: 0.1rem;
    letter-spacing: 0.02em;
  }

  /* Advanced Stats Mobile layout */
  .adv-stats-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .adv-stat-card,
  .adv-stat-card.hero-card {
    grid-column: 1 / -1;
  }

  .hero-card .adv-stat-value {
    font-size: 2rem;
  }

  .section {
    padding: 1rem;
  }

  /* Make tabs smooth scrollable horizontally without scrollbar */
  .tabs {
    padding: 0 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .desktop-view {
    display: none !important;
  }

  .mobile-view {
    display: flex !important;
    margin-top: 1rem;
    gap: 0.75rem;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 1rem;
  }

  .toolbar input {
    min-width: 100%;
  }

  .custom-date-group {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .custom-date-group input {
    flex: 1 1 40%;
  }

  .custom-date-group button {
    flex: 1 1 100%;
  }

  /* Make filter chips smooth scrollable horizontally */
  .chip-group {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.25rem;
  }

  .chip-group::-webkit-scrollbar {
    display: none;
  }

  /* Tighten Modals on mobile */
  .modal-overlay {
    padding: 0.5rem;
  }

  .modal-header {
    padding: 1rem;
  }

  .modal-body {
    padding: 1rem;
    gap: 1rem;
  }

  .modal-footer {
    padding: 1rem;
    flex-direction: column-reverse;
    gap: 0.5rem;
  }

  .modal-footer .btn {
    width: 100%;
  }

  /* Stack Pagination Actions */
  .pagination {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }

  .page-btns {
    justify-content: center;
    width: 100%;
  }

  .page-btn {
    flex: 1;
    text-align: center;
  }

  /* Toasts stretch to screen edges */
  .toast-container {
    right: 1rem;
    left: 1rem;
    bottom: 1rem;
  }

  .toast {
    min-width: 0;
    width: 100%;
  }
}

/* Tiny screens (e.g., iPhone SE, older Androids, Samsung S25) */
@media(max-width: 480px) {
  header {
    padding: 0 0.75rem;
    height: 56px;
  }

  .logo {
    gap: 0.4rem;
  }

  .logo-icon {
    width: 28px;
    height: 28px;
    font-size: 14px;
    border-radius: 6px;
  }

  .logo h1 {
    font-size: 0.95rem;
  }

  .header-status {
    gap: 0.25rem;
  }

  .header-status button {
    padding: 0.25rem 0.4rem;
    font-size: 0.65rem;
    margin-left: auto !important;
  }

  .section {
    padding: 1rem 0;
  }

  .tabs {
    padding: 0 0.5rem;
  }

  .table-wrap {
    border: none;
    border-radius: 0;
  }

  .toolbar {
    padding: 1rem 0.5rem;
  }

  .mobile-view {
    padding: 0 0.5rem;
  }

  .entity-card {
    border-radius: var(--radius-sm);
    padding: 1rem;
  }

  .login-box {
    padding: 2.5rem 1.5rem;
    margin: 0 1rem;
  }

  .login-box h2 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
  }

  .card-plate {
    font-size: 0.95rem;
  }

  .card-row .val {
    max-width: 60%;
    text-align: right;
    word-break: break-word;
    /* Prevent long emails/phones from blowing out the card view */
  }
}

@media(min-width: 769px) {
  .mobile-view {
    display: none !important;
  }
}

/* ── LOGIN ── */
#login-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% -20%, var(--surface) 0%, var(--bg) 80%);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  transition: opacity 0.4s ease, visibility 0.4s;
}

#login-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.login-box {
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg), 0 0 40px rgba(59, 130, 246, 0.1);
  text-align: center;
  animation: loginPop 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes loginPop {
  0% {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }

  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.login-box h2 {
  margin-top: 1.5rem;
  margin-bottom: 2.5rem;
  font-weight: 700;
  color: var(--text-main);
  font-size: 1.5rem;
  letter-spacing: -0.03em;
}

.login-box .form-group {
  text-align: left;
  margin-bottom: 1.5rem;
}

.login-box input {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  padding: 0.875rem 1rem;
  border-radius: var(--radius-sm);
  width: 100%;
  color: var(--text-main);
  font-size: 1rem;
  transition: var(--transition-fast);
}

.login-box input:focus {
  border-color: var(--accent-primary);
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  outline: none;
}

.login-box button {
  width: 100%;
  padding: 0.875rem;
  margin-top: 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--gradient-primary);
  color: white;
  border: none;
  cursor: pointer;
  transition: var(--transition-fast);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.login-box button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.5);
}

.login-box button:active {
  transform: translateY(0);
}

#app-content {
  transition: opacity 0.4s ease;
}