/* ============================================================
   ANPR Management Platform — app.css
   Material Design 3 · Teal/Blue Theme
   ============================================================ */

/* ── 1. CSS Reset / Normalize ─────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Roboto', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--primary-dark);
}

img, svg {
  display: block;
  max-width: 100%;
}

ul, ol {
  list-style: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

/* ── 2. CSS Custom Properties ─────────────────────────────── */
:root {
  /* Brand colours */
  --primary:         #1565C0;
  --primary-light:   #1976D2;
  --primary-dark:    #0D47A1;
  --secondary:       #00897B;
  --secondary-light: #26A69A;
  --secondary-dark:  #00695C;

  /* State colours */
  --error:   #C62828;
  --success: #2E7D32;
  --warning: #E65100;
  --info:    #0277BD;

  /* Neutral */
  --bg:             #F5F7FA;
  --surface:        #FFFFFF;
  --border:         #E0E0E0;
  --border-light:   #EEEEEE;
  --divider:        rgba(0, 0, 0, 0.12);

  /* Text */
  --text-primary:   #212121;
  --text-secondary: #616161;
  --text-disabled:  #9E9E9E;
  --text-hint:      #BDBDBD;

  /* Sidebar */
  --sidebar-bg:          #1A237E;
  --sidebar-bg-hover:    rgba(255, 255, 255, 0.08);
  --sidebar-bg-active:   rgba(255, 255, 255, 0.15);
  --sidebar-text:        rgba(255, 255, 255, 0.87);
  --sidebar-text-dim:    rgba(255, 255, 255, 0.55);
  --sidebar-active-bar:  #64B5F6;
  --sidebar-width:       260px;

  /* Layout */
  --topbar-height:  64px;

  /* Elevation shadows (Material 3) */
  --shadow-1: 0 1px 2px rgba(0,0,0,0.12), 0 1px 3px rgba(0,0,0,0.08);
  --shadow-2: 0 2px 4px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.08);
  --shadow-3: 0 4px 8px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.08);
  --shadow-4: 0 8px 16px rgba(0,0,0,0.12), 0 8px 24px rgba(0,0,0,0.08);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.10), 0 1px 6px rgba(0,0,0,0.06);

  /* Border radius */
  --radius-sm:  4px;
  --radius:     8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-pill: 999px;

  /* Transitions */
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);

  /* Z-index scale */
  --z-sidebar:  200;
  --z-topbar:   100;
  --z-overlay:  190;
  --z-dropdown: 300;
  --z-modal:    400;
  --z-toast:    500;
}

/* ── 3. Layout ────────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  overflow: hidden;
  transition: transform var(--transition-slow), width var(--transition-slow);
  box-shadow: var(--shadow-3);
}

/* ── Main content ─────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-slow);
}

.page-content {
  flex: 1;
  padding: 1.5rem;
  margin-top: var(--topbar-height);
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  z-index: var(--z-topbar);
  box-shadow: var(--shadow-1);
  transition: left var(--transition-slow);
}

/* ── 4. Sidebar internals ─────────────────────────────────── */

/* Logo / brand */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem;
  height: var(--topbar-height);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
  text-decoration: none;
  color: #FFFFFF;
  overflow: hidden;
}

.sidebar-logo .logo-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.sidebar-logo .logo-sub {
  font-size: 0.6875rem;
  color: var(--sidebar-text-dim);
  margin-top: 1px;
  white-space: nowrap;
}

/* Scrollable nav area */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.75rem 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

/* Group labels */
.nav-group-label {
  padding: 1rem 1.25rem 0.375rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-text-dim);
  white-space: nowrap;
}

/* Nav items */
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1.25rem;
  margin: 0.125rem 0.625rem;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: 0.875rem;
  font-weight: 400;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  position: relative;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--sidebar-bg-hover);
  color: #FFFFFF;
}

.nav-item.active {
  background: var(--sidebar-bg-active);
  color: #FFFFFF;
  font-weight: 500;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -0.625rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--sidebar-active-bar);
  border-radius: 0 2px 2px 0;
}

/* Nav icons */
.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity var(--transition);
  font-size: 1.125rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-item:hover .nav-icon,
.nav-item.active .nav-icon {
  opacity: 1;
}

/* Badge on nav item */
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--sidebar-active-bar);
  color: #000;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.125rem 0.4rem;
  border-radius: var(--radius-pill);
  line-height: 1.4;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

/* ── 5. Topbar internals ──────────────────────────────────── */
.topbar-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  margin-right: auto;
}

.topbar-search {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.topbar-search input {
  width: 100%;
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg);
  font-size: 0.875rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.topbar-search input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.15);
}

.topbar-search .search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
  font-size: 1rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Icon button in topbar */
.topbar-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 1.25rem;
  transition: background var(--transition), color var(--transition);
}

.topbar-btn:hover {
  background: var(--bg);
  color: var(--text-primary);
}

/* User avatar */
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #FFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: box-shadow var(--transition);
}

.user-avatar:hover {
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.25);
}

/* Dropdown */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-4);
  min-width: 200px;
  z-index: var(--z-dropdown);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
}

.dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  text-decoration: none;
  transition: background var(--transition);
  cursor: pointer;
}

.dropdown-item:hover {
  background: var(--bg);
}

.dropdown-item.danger {
  color: var(--error);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0;
}

/* ── 6. Cards ─────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border-light);
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  flex: 1;
}

.card-subtitle {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.125rem;
}

.card-body {
  padding: 1.25rem;
}

.card-footer {
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--border-light);
  background: var(--bg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Elevated variants */
.card-elevated-1 { box-shadow: var(--shadow-1); }
.card-elevated-2 { box-shadow: var(--shadow-2); }
.card-elevated-3 { box-shadow: var(--shadow-3); }
.card-elevated-4 { box-shadow: var(--shadow-4); }

/* ── 7. Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), box-shadow var(--transition),
              transform 0.1s;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  user-select: none;
  letter-spacing: 0.01em;
}

.btn:active {
  transform: translateY(1px);
}

/* Ripple */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.35) 1%, transparent 70%);
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.4s, transform 0.4s;
}

.btn:active::after {
  opacity: 1;
  transform: scale(2.5);
  transition: opacity 0s, transform 0s;
}

/* Variants */
.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
}

.btn-primary:hover {
  background: var(--primary-light);
  box-shadow: var(--shadow-2);
  color: #FFFFFF;
}

.btn-secondary {
  background: var(--secondary);
  color: #FFFFFF;
}

.btn-secondary:hover {
  background: var(--secondary-light);
  box-shadow: var(--shadow-2);
  color: #FFFFFF;
}

.btn-danger {
  background: var(--error);
  color: #FFFFFF;
}

.btn-danger:hover {
  background: #B71C1C;
  box-shadow: var(--shadow-2);
  color: #FFFFFF;
}

.btn-success {
  background: var(--success);
  color: #FFFFFF;
}

.btn-success:hover {
  background: #1B5E20;
  box-shadow: var(--shadow-2);
  color: #FFFFFF;
}

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

.btn-outline:hover {
  background: var(--bg);
  border-color: var(--primary-light);
  color: var(--primary);
}

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

.btn-outline-primary:hover {
  background: rgba(21, 101, 192, 0.08);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg);
  color: var(--text-primary);
}

/* Sizes */
.btn-sm {
  padding: 0.3125rem 0.875rem;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.75rem 1.75rem;
  font-size: 1rem;
  border-radius: var(--radius);
}

/* Icon button */
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  font-size: 1rem;
}

.btn-icon.btn-sm {
  width: 28px;
  height: 28px;
  font-size: 0.875rem;
}

.btn-icon.btn-lg {
  width: 48px;
  height: 48px;
  font-size: 1.25rem;
}

/* Disabled */
.btn:disabled,
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Loading state */
.btn.btn-loading {
  pointer-events: none;
  opacity: 0.75;
}

.btn.btn-loading::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 0.375rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── 8. Tables ────────────────────────────────────────────── */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
}

.table {
  width: 100%;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.table thead {
  background: var(--bg);
}

.table th {
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  text-align: left;
}

.table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.table tfoot td {
  padding: 0.875rem 1rem;
  border-top: 2px solid var(--border);
  font-weight: 600;
}

/* Striped */
.table-striped tbody tr:nth-child(even) td {
  background: rgba(245, 247, 250, 0.7);
}

/* Hover */
.table-hover tbody tr {
  transition: background var(--transition);
}

.table-hover tbody tr:hover td {
  background: rgba(21, 101, 192, 0.04);
}

/* Clickable rows */
.table tbody tr[data-href] {
  cursor: pointer;
}

.table tbody tr[data-href]:hover td {
  background: rgba(21, 101, 192, 0.06);
}

/* ── 9. Forms ─────────────────────────────────────────────── */
.form-group {
  margin-bottom: 1.25rem;
  position: relative;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
  transition: color var(--transition);
}

.form-label.required::after {
  content: ' *';
  color: var(--error);
}

.form-control,
.form-select {
  display: block;
  width: 100%;
  padding: 0.5625rem 0.875rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}

.form-control::placeholder {
  color: var(--text-hint);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.15);
}

.form-control:focus + .form-label,
.form-group:focus-within .form-label {
  color: var(--primary);
}

.form-control.is-invalid,
.form-select.is-invalid {
  border-color: var(--error);
  box-shadow: none;
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.15);
}

.form-control.is-valid {
  border-color: var(--success);
}

.invalid-feedback {
  display: none;
  font-size: 0.8125rem;
  color: var(--error);
  margin-top: 0.25rem;
}

.form-control.is-invalid ~ .invalid-feedback,
.form-select.is-invalid ~ .invalid-feedback {
  display: block;
}

.form-hint {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* Select arrow */
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23616161' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

/* Textarea */
textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

/* Checkbox & Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.form-check-input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.form-check-label {
  font-size: 0.875rem;
  color: var(--text-primary);
  cursor: pointer;
}

/* Input group */
.input-group {
  display: flex;
}

.input-group .form-control {
  border-radius: 0;
  flex: 1;
}

.input-group .form-control:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
}

.input-group .form-control:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
}

.input-group-text {
  display: flex;
  align-items: center;
  padding: 0.5625rem 0.875rem;
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.875rem;
  white-space: nowrap;
}

.input-group .input-group-text:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
  border-right: none;
}

.input-group .input-group-text:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
  border-left: none;
}

/* Plate input */
.plate-input {
  text-transform: uppercase;
  font-family: 'Roboto Mono', 'Courier New', monospace;
  font-weight: 600;
  letter-spacing: 0.08em;
  font-size: 1rem;
}

/* ── 10. Badges ───────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1875rem 0.5625rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  letter-spacing: 0.02em;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-primary {
  background: rgba(21, 101, 192, 0.12);
  color: var(--primary);
}

.badge-success {
  background: rgba(46, 125, 50, 0.12);
  color: var(--success);
}

.badge-warning {
  background: rgba(230, 81, 0, 0.12);
  color: var(--warning);
}

.badge-danger {
  background: rgba(198, 40, 40, 0.12);
  color: var(--error);
}

.badge-secondary {
  background: rgba(97, 97, 97, 0.12);
  color: var(--text-secondary);
}

.badge-info {
  background: rgba(2, 119, 189, 0.12);
  color: var(--info);
}

/* Solid variants */
.badge-primary-solid   { background: var(--primary);   color: #FFF; }
.badge-success-solid   { background: var(--success);   color: #FFF; }
.badge-warning-solid   { background: var(--warning);   color: #FFF; }
.badge-danger-solid    { background: var(--error);     color: #FFF; }
.badge-secondary-solid { background: var(--text-secondary); color: #FFF; }
.badge-info-solid      { background: var(--info);      color: #FFF; }

/* ── 11. Alerts / Flash messages ──────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius);
  border-left: 4px solid transparent;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  animation: alertIn 0.3s ease;
  position: relative;
}

@keyframes alertIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.alert.fade-out {
  animation: alertOut 0.4s ease forwards;
}

@keyframes alertOut {
  to { opacity: 0; transform: translateY(-6px); max-height: 0; margin: 0; padding: 0; }
}

.alert-icon {
  font-size: 1.125rem;
  flex-shrink: 0;
  margin-top: 0.0625rem;
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-weight: 600;
  margin-bottom: 0.125rem;
}

.alert-close {
  margin-left: auto;
  opacity: 0.6;
  cursor: pointer;
  padding: 0.125rem;
  border-radius: var(--radius-sm);
  transition: opacity var(--transition);
  flex-shrink: 0;
}

.alert-close:hover {
  opacity: 1;
}

.alert-success {
  background: rgba(46, 125, 50, 0.08);
  border-left-color: var(--success);
  color: #1B5E20;
}

.alert-error {
  background: rgba(198, 40, 40, 0.08);
  border-left-color: var(--error);
  color: #B71C1C;
}

.alert-warning {
  background: rgba(230, 81, 0, 0.08);
  border-left-color: var(--warning);
  color: #BF360C;
}

.alert-info {
  background: rgba(2, 119, 189, 0.08);
  border-left-color: var(--info);
  color: #01579B;
}

/* ── 12. Stat cards ───────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: box-shadow var(--transition), transform var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-3);
  transform: translateY(-2px);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.stat-icon-primary   { background: rgba(21, 101, 192, 0.12); color: var(--primary); }
.stat-icon-secondary { background: rgba(0, 137, 123, 0.12);  color: var(--secondary); }
.stat-icon-success   { background: rgba(46, 125, 50, 0.12);  color: var(--success); }
.stat-icon-warning   { background: rgba(230, 81, 0, 0.12);   color: var(--warning); }
.stat-icon-danger    { background: rgba(198, 40, 40, 0.12);  color: var(--error); }
.stat-icon-info      { background: rgba(2, 119, 189, 0.12);  color: var(--info); }

.stat-body {
  flex: 1;
  min-width: 0;
}

.stat-number {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.stat-change {
  font-size: 0.8125rem;
  margin-top: 0.375rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--error); }

/* ── 13. Confidence bar ───────────────────────────────────── */
.confidence-bar-wrapper {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.confidence-bar {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--success);
}

.confidence-fill.high   { background: var(--success); }
.confidence-fill.medium { background: var(--warning); }
.confidence-fill.low    { background: var(--error); }

.confidence-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 2.5rem;
  text-align: right;
}

/* ── 14. Pagination ───────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.page-item {
  display: inline-flex;
}

.page-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition);
  cursor: pointer;
}

.page-link:hover {
  background: var(--bg);
  color: var(--primary);
  border-color: var(--primary-light);
}

.page-item.active .page-link {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
  font-weight: 600;
}

.page-item.disabled .page-link {
  opacity: 0.45;
  pointer-events: none;
}

/* ── 15. Modal ────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-4);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: scale(0.92) translateY(12px);
  transition: transform var(--transition);
}

.modal-backdrop.open .modal-dialog {
  transform: scale(1) translateY(0);
}

.modal-dialog-lg  { max-width: 720px; }
.modal-dialog-xl  { max-width: 960px; }
.modal-dialog-sm  { max-width: 360px; }

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  margin: 0;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 1.125rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--bg);
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ── 16. Sidebar toggle + overlay ─────────────────────────── */
.sidebar-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 1.375rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}

.sidebar-toggle:hover {
  background: var(--bg);
  color: var(--text-primary);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: var(--z-overlay);
  opacity: 0;
  transition: opacity var(--transition-slow);
}

/* ── Toast notifications ──────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  background: #323232;
  color: #FFFFFF;
  border-radius: var(--radius);
  box-shadow: var(--shadow-3);
  font-size: 0.875rem;
  min-width: 260px;
  max-width: 380px;
  pointer-events: auto;
  animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast.toast-out {
  animation: toastOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(40px); }
}

.toast-success { background: #1B5E20; }
.toast-error   { background: #B71C1C; }
.toast-warning { background: #E65100; }
.toast-info    { background: var(--primary-dark); }

.toast-icon { font-size: 1rem; flex-shrink: 0; }

.toast-action {
  margin-left: auto;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--sidebar-active-bar);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Page header ──────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.page-header-title {
  flex: 1;
}

.page-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.page-breadcrumb {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: 0.25rem;
}

.page-breadcrumb a {
  color: var(--text-secondary);
}

.page-breadcrumb a:hover {
  color: var(--primary);
}

.page-breadcrumb .separator {
  opacity: 0.5;
}

/* ── Filter bar ───────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.filter-bar .form-control,
.filter-bar .form-select {
  max-width: 200px;
}

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.empty-state-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.375rem;
}

.empty-state-text {
  font-size: 0.875rem;
  max-width: 340px;
}

/* ── Copy button ──────────────────────────────────────────── */
.copy-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.copy-btn {
  flex-shrink: 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.copy-btn:hover {
  background: var(--primary);
  color: #FFF;
  border-color: var(--primary);
}

/* ── Code / plate display ─────────────────────────────────── */
.plate-display {
  font-family: 'Roboto Mono', 'Courier New', monospace;
  font-weight: 700;
  letter-spacing: 0.1em;
  background: #1A237E;
  color: #FFFFFF;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  display: inline-block;
}

/* ── Chart wrapper ────────────────────────────────────────── */
.chart-wrapper {
  position: relative;
  width: 100%;
}

/* ── 17. Responsive breakpoints ───────────────────────────── */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 240px;
  }
}

@media (max-width: 768px) {
  .sidebar-toggle {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar-overlay {
    display: block;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-overlay {
    opacity: 1;
  }

  .main-content {
    margin-left: 0;
  }

  .topbar {
    left: 0;
    padding: 0 1rem;
  }

  .topbar-search {
    display: none;
  }

  .page-content {
    padding: 1rem;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal-dialog {
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .filter-bar .form-control,
  .filter-bar .form-select {
    max-width: 100%;
  }

  .toast-container {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
  }

  .toast {
    min-width: unset;
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stat-number {
    font-size: 1.375rem;
  }

  .btn-group {
    flex-direction: column;
  }
}

/* ── 18. Print styles ─────────────────────────────────────── */
@media print {
  .sidebar,
  .topbar,
  .sidebar-toggle,
  .sidebar-overlay,
  .toast-container,
  .modal-backdrop,
  .btn-group,
  .pagination,
  .filter-bar {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
  }

  .page-content {
    margin-top: 0 !important;
    padding: 0 !important;
  }

  .card {
    box-shadow: none !important;
    border: 1px solid #CCC !important;
    break-inside: avoid;
  }

  body {
    font-size: 11pt;
    color: #000 !important;
    background: #FFF !important;
  }

  a[href]::after {
    content: ' (' attr(href) ')';
    font-size: 0.75em;
    color: #555;
  }

  .table th,
  .table td {
    padding: 0.375rem 0.5rem;
    font-size: 10pt;
  }
}

/* ── 19. Utilities ────────────────────────────────────────── */

/* Text */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-left    { text-align: left; }
.text-muted   { color: var(--text-secondary); }
.text-primary-c { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger  { color: var(--error); }
.text-warning { color: var(--warning); }
.text-info    { color: var(--info); }
.text-sm      { font-size: 0.8125rem; }
.text-xs      { font-size: 0.75rem; }
.text-lg      { font-size: 1.0625rem; }
.text-xl      { font-size: 1.25rem; }
.fw-normal    { font-weight: 400; }
.fw-medium    { font-weight: 500; }
.fw-semibold  { font-weight: 600; }
.fw-bold      { font-weight: 700; }
.text-truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.text-mono    { font-family: 'Roboto Mono', monospace; }

/* Display */
.d-flex      { display: flex; }
.d-block     { display: block; }
.d-inline    { display: inline; }
.d-inline-flex { display: inline-flex; }
.d-grid      { display: grid; }
.d-none      { display: none; }

/* Flex */
.flex-1      { flex: 1; }
.flex-row    { flex-direction: row; }
.flex-col    { flex-direction: column; }
.flex-wrap   { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.items-end    { align-items: flex-end; }
.justify-center  { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.justify-start   { justify-content: flex-start; }

/* Gap */
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

/* Margin top */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.5rem; }
.mt-6 { margin-top: 2rem; }

/* Margin bottom */
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.5rem; }
.mb-6 { margin-bottom: 2rem; }

/* Margin left/right */
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }

/* Padding */
.p-0  { padding: 0; }
.p-1  { padding: 0.25rem; }
.p-2  { padding: 0.5rem; }
.p-3  { padding: 0.75rem; }
.p-4  { padding: 1rem; }
.p-5  { padding: 1.5rem; }
.px-1 { padding-left: 0.25rem; padding-right: 0.25rem; }
.px-2 { padding-left: 0.5rem;  padding-right: 0.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem;    padding-right: 1rem; }
.py-1 { padding-top: 0.25rem;  padding-bottom: 0.25rem; }
.py-2 { padding-top: 0.5rem;   padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem;  padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem;     padding-bottom: 1rem; }

/* Width */
.w-100  { width: 100%; }
.w-auto { width: auto; }
.w-50   { width: 50%; }

/* Rounded */
.rounded    { border-radius: var(--radius); }
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-pill { border-radius: var(--radius-pill); }
.rounded-circle { border-radius: 50%; }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-auto   { overflow: auto; }

/* Position */
.position-relative { position: relative; }
.position-absolute { position: absolute; }

/* Visibility */
.invisible { visibility: hidden; }
.visible   { visibility: visible; }

/* Separator */
.divider {
  height: 1px;
  background: var(--border);
  margin: 1rem 0;
}

/* Section spacing */
.section { margin-bottom: 2rem; }

/* Btn group */
.btn-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════════════════════
   COMPATIBILITY LAYER
   Implements the class vocabulary used by templates/ and modules/ that was
   not covered by the sections above. Kept in the same design language
   (CSS variables, radii, shadows defined in :root).
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Sidebar: brand ──────────────────────────────────────────────────────── */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: var(--topbar-height);
  padding: 0 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: #FFFFFF;
  flex-shrink: 0;
}
.sidebar-brand-icon { font-size: 28px; color: var(--sidebar-active-bar); }
.sidebar-brand-name { font-size: 1.125rem; font-weight: 500; letter-spacing: 0.01em; }

/* ── Sidebar: nav links (markup: ul.nav-list > li.nav-item > a.nav-link) ── */
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-list .nav-item { display: block; padding: 0; margin: 0; border-radius: 0; }
.nav-list .nav-item:hover { background: transparent; }
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1.25rem;
  margin: 0.125rem 0.625rem;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: 0.875rem;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover { background: var(--sidebar-bg-hover); color: #FFFFFF; }
.nav-link.active { background: var(--sidebar-bg-active); color: #FFFFFF; font-weight: 500; }
.nav-link.active::before {
  content: '';
  position: absolute;
  left: -0.625rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  border-radius: 2px;
  background: var(--sidebar-active-bar);
}
.nav-icon  { font-size: 20px; flex-shrink: 0; }
.nav-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-group { margin-bottom: 0.25rem; }

/* ── Sidebar: user block at the bottom ───────────────────────────────────── */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--sidebar-text);
  flex-shrink: 0;
}
.sidebar-user-avatar { font-size: 34px; color: var(--sidebar-text-dim); }
.sidebar-user-info   { display: flex; flex-direction: column; min-width: 0; }
.sidebar-user-name   {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role   { font-size: 0.6875rem; color: var(--sidebar-text-dim); text-transform: capitalize; }

/* ── Topbar: layout & widgets ────────────────────────────────────────────── */
.topbar-left  { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }
.topbar-title-wrap { min-width: 0; }
.topbar-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition);
}
.topbar-icon-btn:hover { background: rgba(0, 0, 0, 0.06); color: var(--text-primary); }
.topbar-badge {
  position: absolute;
  top: 4px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--error);
  color: #FFFFFF;
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
.topbar-user-menu { position: relative; }
.topbar-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.625rem;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition);
}
.topbar-user-btn:hover { background: rgba(0, 0, 0, 0.06); }
.topbar-user-name { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-chevron { font-size: 20px; color: var(--text-secondary); transition: transform var(--transition); }
.dropdown.open .topbar-chevron { transform: rotate(180deg); }

/* Dropdown ul reset + items (inherits show/hide from .dropdown-menu rules) */
.topbar-dropdown { list-style: none; margin: 0; padding: 0.375rem 0; }
.topbar-dropdown li { display: block; }
.topbar-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  text-decoration: none;
  transition: background var(--transition);
}
.topbar-dropdown-item:hover { background: rgba(0, 0, 0, 0.05); }
.topbar-dropdown-item .material-icons { font-size: 20px; color: var(--text-secondary); }
.topbar-dropdown-item--danger,
.topbar-dropdown-item--danger .material-icons { color: var(--error); }
.topbar-dropdown-divider { height: 1px; margin: 0.375rem 0; background: var(--border-light); }

/* ── Flash messages (top-right, auto-dismissed by app.js) ────────────────── */
.flash-container {
  position: fixed;
  top: calc(var(--topbar-height) + 12px);
  right: 16px;
  z-index: var(--z-toast, 1080);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 380px;
}
.flash {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--surface);
  border-left: 4px solid var(--info);
  box-shadow: var(--shadow-3);
  font-size: 0.875rem;
  animation: flashIn 0.25s ease;
}
@keyframes flashIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.flash--success { border-left-color: var(--success); }
.flash--success .flash-icon { color: var(--success); }
.flash--error   { border-left-color: var(--error); }
.flash--error .flash-icon   { color: var(--error); }
.flash--warning { border-left-color: var(--warning); }
.flash--warning .flash-icon { color: var(--warning); }
.flash--info    { border-left-color: var(--info); }
.flash--info .flash-icon    { color: var(--info); }
.flash-icon    { font-size: 20px; flex-shrink: 0; }
.flash-message { flex: 1; color: var(--text-primary); }
.flash-close {
  display: inline-flex;
  border: none;
  background: transparent;
  color: var(--text-disabled);
  cursor: pointer;
  padding: 2px;
  border-radius: 50%;
}
.flash-close:hover { color: var(--text-primary); background: rgba(0,0,0,0.06); }
.flash.fade-out { opacity: 0; transition: opacity 0.3s ease; }

/* ── Page header variants ────────────────────────────────────────────────── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-header-content { min-width: 0; }
.page-header-title,
.page-heading {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin: 0 0 0.25rem;
  font-size: 1.375rem;
  font-weight: 500;
  color: var(--text-primary);
}
.page-header-icon,
.page-heading-icon { font-size: 26px; color: var(--primary); }
.page-header-subtitle,
.page-subheading { margin: 0; font-size: 0.875rem; color: var(--text-secondary); }
.page-header-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

/* ── Filters ─────────────────────────────────────────────────────────────── */
.card-filter { margin-bottom: 1.25rem; }
.filter-form { width: 100%; }
.filter-row,
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.875rem 1rem;
  align-items: end;
}
.filter-grid--wide { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.filter-group { display: flex; flex-direction: column; gap: 0.375rem; min-width: 0; }
.filter-group--checkbox { flex-direction: row; align-items: center; gap: 0.5rem; padding-bottom: 0.625rem; }
.filter-label { font-size: 0.8125rem; font-weight: 500; color: var(--text-secondary); }
.filter-actions { display: flex; align-items: center; gap: 0.5rem; grid-column: 1 / -1; margin-top: 0.25rem; }
.filter-row .form-group,
.filter-form .form-group { margin-bottom: 0; }

/* ── Simple responsive grid (Bootstrap-like, used by forms/detail pages) ── */
.row { display: flex; flex-wrap: wrap; margin: 0 -0.625rem; }
.row > [class*="col-"] { padding: 0 0.625rem; width: 100%; min-width: 0; margin-bottom: 1.25rem; }
@media (min-width: 576px) {
  .row > .col-sm-6 { width: 50%; }
}
@media (min-width: 768px) {
  .row > .col-md-2 { width: 16.6667%; }
  .row > .col-md-3 { width: 25%; }
  .row > .col-md-4 { width: 33.3333%; }
  .row > .col-md-5 { width: 41.6667%; }
  .row > .col-md-6 { width: 50%; }
  .row > .col-md-7 { width: 58.3333%; }
  .row > .col-md-8 { width: 66.6667%; }
  .row > .col-md-9 { width: 75%; }
  .row > .col-md-12 { width: 100%; }
}
@media (min-width: 992px) {
  .row > .col-lg-4 { width: 33.3333%; }
  .row > .col-lg-5 { width: 41.6667%; }
  .row > .col-lg-7 { width: 58.3333%; }
  .row > .col-lg-8 { width: 66.6667%; }
}
.container-fluid { width: 100%; }

/* ── Forms: rows, states, extras ─────────────────────────────────────────── */
.form-row { display: flex; flex-wrap: wrap; gap: 0 1.25rem; }
.form-col { flex: 1 1 220px; min-width: 0; }
.form-field { margin-bottom: 1rem; }
.form-input { /* alias of .form-control for pages using the older name */
  display: block;
  width: 100%;
  padding: 0.5625rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.15); }
.form-control-sm { padding: 0.375rem 0.625rem; font-size: 0.8125rem; }
.form-range { width: 100%; accent-color: var(--primary); }
.form-text { display: block; margin-top: 0.25rem; font-size: 0.75rem; color: var(--text-secondary); }
.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.625rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}
.form-group--actions { display: flex; align-items: flex-end; gap: 0.5rem; }
.has-error .form-control,
.has-error .form-select,
.form-control.is-invalid,
.form-select.is-invalid { border-color: var(--error); }
.has-error .form-label { color: var(--error); }
.input-wrap { position: relative; }
.input-icon {
  position: absolute;
  left: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--text-disabled);
  pointer-events: none;
}
.input-wrap .form-control { padding-left: 2.375rem; }
.has-pw-toggle .form-control { padding-right: 2.5rem; }
.pw-toggle {
  position: absolute;
  right: 0.375rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  border: none;
  background: transparent;
  color: var(--text-disabled);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
}
.pw-toggle:hover { color: var(--text-primary); }
.input-group-append { display: inline-flex; }

/* ── Tables: helpers ─────────────────────────────────────────────────────── */
.table-sm th, .table-sm td { padding: 0.5rem 0.75rem; font-size: 0.8125rem; }
.th-id, .td-id { width: 56px; color: var(--text-secondary); }
.th-center, .td-center { text-align: center; }
.th-actions, .td-actions, .actions-cell { text-align: right; white-space: nowrap; width: 1%; }
.td-actions .btn, .actions-cell .btn { margin-left: 0.25rem; }
.row-inactive { opacity: 0.55; }
.row-inactive:hover { opacity: 0.8; }
.text-nowrap { white-space: nowrap; }
.table-reads td { vertical-align: middle; }

/* ── Pagination wrapper ──────────────────────────────────────────────────── */
.pagination-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--border-light);
}
.pagination-info { font-size: 0.8125rem; color: var(--text-secondary); }
.pagination-nav { display: flex; align-items: center; gap: 0.25rem; }

/* ── Status dot ──────────────────────────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-disabled);
  margin-right: 0.375rem;
  vertical-align: middle;
}
.status-dot--online  { background: var(--success); box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.18); }
.status-dot--offline { background: var(--error);   box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.15); }

/* ── Plate components ────────────────────────────────────────────────────── */
.plate-badge,
.plate-number,
.plate-text {
  font-family: 'Roboto Mono', 'Courier New', monospace;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.plate-badge {
  display: inline-block;
  padding: 0.25rem 0.625rem;
  background: #FFFFFF;
  border: 2px solid var(--text-primary);
  border-left-width: 8px;
  border-left-color: #003399;
  border-radius: 4px;
  font-size: 0.9375rem;
  color: var(--text-primary);
  white-space: nowrap;
}
.plate-badge--sm { padding: 0.125rem 0.4375rem; font-size: 0.8125rem; border-left-width: 6px; }
.plate-number-hero,
.plate-hero-display,
.plate-display {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  background: #FFFFFF;
  border: 3px solid var(--text-primary);
  border-left: 14px solid #003399;
  border-radius: 6px;
  font-family: 'Roboto Mono', 'Courier New', monospace;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-primary);
  white-space: nowrap;
}

/* ── Images & code blocks (detail pages) ─────────────────────────────────── */
.img-fluid { max-width: 100%; height: auto; }
.img-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-disabled);
}
.img-placeholder .material-icons { font-size: 44px; }
.img-placeholder--plate { min-height: 90px; }
.img-plate-preview {
  display: block;
  max-width: 100%;
  max-height: 340px;
  object-fit: contain;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #000;
}
.img-plate-zoom { cursor: zoom-in; }
.code-block {
  margin: 0;
  padding: 1rem;
  background: #263238;
  color: #ECEFF1;
  font-family: 'Roboto Mono', 'Courier New', monospace;
  font-size: 0.8125rem;
  line-height: 1.55;
  border-radius: var(--radius);
  overflow: auto;
  max-height: 420px;
  white-space: pre-wrap;
  word-break: break-word;
}
.code-block--json { tab-size: 2; }
.break-all { word-break: break-all; }
.font-mono, .text-mono { font-family: 'Roboto Mono', 'Courier New', monospace; }

/* ── Detail pages ────────────────────────────────────────────────────────── */
.detail-section-title {
  margin: 1.25rem 0 0.625rem;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}
.detail-list { margin: 0; }
.detail-list > div { display: flex; gap: 0.75rem; padding: 0.4375rem 0; border-bottom: 1px solid var(--border-light); font-size: 0.875rem; }
.detail-table { width: 100%; border-collapse: collapse; }
.detail-table td { padding: 0.5rem 0.625rem; font-size: 0.875rem; border-bottom: 1px solid var(--border-light); vertical-align: top; }
.detail-table td:first-child { width: 38%; color: var(--text-secondary); font-weight: 500; }
.map-coords-bar { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8125rem; color: var(--text-secondary); margin-top: 0.5rem; }
.map-embed-wrapper { position: relative; width: 100%; padding-top: 56.25%; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.map-embed-wrapper iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  text-decoration: none;
}
.back-link:hover { color: var(--primary); }

/* ── Stat card variants ──────────────────────────────────────────────────── */
/* Dashboard structure: .stat-card > .card-body (icon+content) + .card-footer (link).
   The base .stat-card is a flex ROW for bare icon+body markup; when the card
   wraps its content in .card-body, switch to column and lay the row inside. */
.stat-card { flex-direction: column; align-items: stretch; gap: 0; padding: 0; }
.stat-card > .card-body {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  flex: 1;
}
.stat-card > .card-footer {
  padding: 0.5rem 1.25rem;
  background: transparent;
  border-top: 1px solid var(--border-light);
}
.stat-card .stat-icon { background: rgba(21, 101, 192, 0.10); color: var(--primary); }
.stat-card--green .stat-icon  { background: rgba(46, 125, 50, 0.10);  color: var(--success); }
.stat-card--purple .stat-icon { background: rgba(106, 27, 154, 0.10); color: #6A1B9A; }
.stat-card--orange .stat-icon { background: rgba(230, 81, 0, 0.10);   color: var(--warning); }
.stat-card--red .stat-icon    { background: rgba(198, 40, 40, 0.10);  color: var(--error); }
.stat-card--grey .stat-icon   { background: rgba(0, 0, 0, 0.06);      color: var(--text-secondary); }
.stat-content { flex: 1; min-width: 0; }
.stat-value { font-size: 1.75rem; font-weight: 600; color: var(--text-primary); line-height: 1.2; }
.stat-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--primary);
  text-decoration: none;
}
.stat-link:hover { text-decoration: underline; }
.stat-link .material-icons { font-size: 16px; }
.stat-card--blue   { border-left: 4px solid var(--primary); }
.stat-card--green  { border-left: 4px solid var(--success); }
.stat-card--purple { border-left: 4px solid #6A1B9A; }
.stat-card--orange { border-left: 4px solid var(--warning); }
.stat-card--red    { border-left: 4px solid var(--error); }
.stat-card--grey   { border-left: 4px solid var(--text-disabled); }

/* ── Alert list (module alerts) ──────────────────────────────────────────── */
.alert-list { display: flex; flex-direction: column; gap: 0.625rem; }
.alert-item {
  padding: 0.875rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--info);
  border-radius: var(--radius);
}
.alert-item-header { display: flex; align-items: center; justify-content: space-between; gap: 0.625rem; font-weight: 500; font-size: 0.875rem; }
.alert-item-meta { font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.125rem; }
.alert-item-msg { font-size: 0.875rem; margin-top: 0.375rem; }
.alert-danger { border-left-color: var(--error); }
.badge-lg { font-size: 0.8125rem; padding: 0.3125rem 0.75rem; }

/* ── Buttons: aliases & variants ─────────────────────────────────────────── */
.btn--primary   { background: var(--primary); color: #FFFFFF; }
.btn--primary:hover { background: var(--primary-dark); }
.btn--secondary { background: var(--surface); color: var(--text-primary); border: 1px solid var(--border); }
.btn--secondary:hover { background: var(--bg); }
.btn-warning { background: var(--warning); color: #FFFFFF; }
.btn-warning:hover { background: #BF360C; }
.btn-block { display: flex; width: 100%; justify-content: center; }

/* ── Card extras ─────────────────────────────────────────────────────────── */
.card-actions { display: flex; align-items: center; gap: 0.5rem; }
.card-header-title { display: flex; align-items: center; gap: 0.5rem; font-size: 1rem; font-weight: 500; margin: 0; }
.card-title-icon { font-size: 20px; color: var(--primary); }
.card-top { margin-bottom: 1.25rem; }
.empty-state--sm { padding: 1.5rem 1rem; }
.empty-state--sm .empty-state-icon { font-size: 36px; }

/* ── App footer ──────────────────────────────────────────────────────────── */
.app-footer {
  margin-top: auto;
  padding: 1rem 1.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-disabled);
}
.app-footer-sep { margin: 0 0.375rem; }
.app-footer-name { font-weight: 500; }

/* ── Utility aliases (Bootstrap-style names used in some modules) ────────── */
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.ms-1, .ml-1 { margin-left: 0.25rem; }
.ms-2, .ml-2 { margin-left: 0.5rem; }
.small { font-size: 0.8125rem; }
.link-primary { color: var(--primary); text-decoration: none; }
.link-primary:hover { text-decoration: underline; }
.icon { vertical-align: middle; }
