@import url("https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,300..900;1,300..900&display=swap");

/* ==========================================================================
   A1 Admin — Standalone shadcn/ui design system (token-driven, Pico-free)
   Mobile-first: base = small screens; desktop via min-width media queries.
   Dark mode: .dark on <html> (data-theme="dark" honored as a legacy alias).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. TOKENS — reference :root block, verbatim (HSL channels)
   -------------------------------------------------------------------------- */
:root {
  --background: 0 0% 100%;
  --foreground: 217 33% 17%;
  --card: 0 0% 100%; --card-foreground: 217 33% 17%;
  --popover: 0 0% 100%; --popover-foreground: 217 33% 17%;
  --primary: 217 91% 60%; --primary-foreground: 0 0% 100%;
  --secondary: 210 40% 96%; --secondary-foreground: 217 33% 17%;
  --muted: 210 40% 96%; --muted-foreground: 215 19% 35%;
  --accent: 210 40% 96%; --accent-foreground: 217 33% 17%;
  --destructive: 0 84% 60%; --destructive-foreground: 0 0% 100%;
  --border: 214 32% 91%; --input: 214 32% 91%; --ring: 217 91% 60%;
  --success: 142 71% 45%; --warning: 38 92% 50%;
  --radius: 0.5rem;

  /* Derived neutrals */
  --border-strong: 215 16% 65%;   /* slate-400-ish */
  --subtle: 210 40% 98%;          /* slate-50 */
  --sidebar-bg: 217 33% 17%;
  --sidebar-header-bg: 222 47% 11%;

  /* Radius scale */
  --radius-md: calc(var(--radius) - 2px);
  --radius-sm: calc(var(--radius) - 4px);
  --radius-lg: var(--radius);

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --ring-soft: hsl(var(--ring) / 0.25);
  --transition: background-color .15s, color .15s, border-color .15s, box-shadow .15s, opacity .15s;

  /* ---- Legacy aliases (inline style="" consumers) ---- */
  --primary-color: hsl(var(--primary));
  --primary-hover: hsl(var(--primary) / 0.9);
  --secondary-color: hsl(var(--muted-foreground));
  --bg-light: hsl(var(--muted));
  --bg-sidebar: hsl(var(--sidebar-bg));
  --border-color: hsl(var(--border));
  --text-main: hsl(var(--foreground));
  --text-muted: hsl(var(--muted-foreground));
  --accent-edit: hsl(var(--warning));
  --accent-edit-hover: hsl(38 92% 42%);
  --accent-delete: hsl(var(--destructive));
  --accent-delete-hover: hsl(0 84% 52%);
  --accent-success: hsl(var(--success));
  --pico-font-family: "Rubik", system-ui, -apple-system, sans-serif;
  --pico-border-radius: var(--radius-md);
  --pico-primary: hsl(var(--primary));
  --pico-primary-hover: hsl(var(--primary) / 0.9);
  --pico-primary-background: hsl(var(--primary));
  --pico-primary-hover-background: hsl(var(--primary) / 0.9);
  --pico-primary-focus: var(--ring-soft);
  --pico-primary-inverse: hsl(var(--primary-foreground));
  --pico-form-element-spacing-horizontal: 0.75rem;
  --pico-form-element-spacing-vertical: 0.5rem;
  --pico-font-size: 0.875rem;
  --pico-line-height: 1.5;
  --pico-form-element-border-color: hsl(var(--input));
  --pico-form-element-active-border-color: hsl(var(--primary));
  --pico-form-element-focus-color: transparent;
  --pico-box-shadow: var(--shadow-sm);
  --pico-muted-color: hsl(var(--muted-foreground));
  --pico-muted-border-color: hsl(var(--border));
  --pico-border-color: hsl(var(--border));
  --pico-color: hsl(var(--foreground));
  --pico-background-color: hsl(var(--background));
  --pico-card-background-color: hsl(var(--card));
  --pico-card-border-color: hsl(var(--border));
  --pico-card-sectioning-background-color: hsl(var(--muted));
  --pico-h1-color: hsl(var(--foreground));
  --pico-h2-color: hsl(var(--foreground));
  --pico-h3-color: hsl(var(--foreground));
  --pico-h4-color: hsl(var(--foreground));
  --pico-h5-color: hsl(var(--foreground));
  --pico-h6-color: hsl(var(--foreground));
}

/* ---- Dark mode: reference .dark block, verbatim; data-theme is a legacy alias ---- */
.dark,
[data-theme="dark"] {
  --background: 240 10% 3.9%; --foreground: 0 0% 98%;
  --card: 240 6% 6%; --card-foreground: 0 0% 98%;
  --popover: 240 6% 6%; --popover-foreground: 0 0% 98%;
  --primary: 217 91% 60%; --primary-foreground: 0 0% 100%;
  --secondary: 240 3.7% 15.9%; --secondary-foreground: 0 0% 98%;
  --muted: 240 3.7% 15.9%; --muted-foreground: 240 5% 64.9%;
  --accent: 240 3.7% 15.9%; --accent-foreground: 0 0% 98%;
  --destructive: 0 72% 50%; --destructive-foreground: 0 0% 98%;
  --border: 240 3.7% 15.9%; --input: 240 3.7% 15.9%; --ring: 217 91% 60%;
  --success: 142 71% 45%; --warning: 38 92% 50%;

  --border-strong: 240 5% 34%;
  --subtle: 240 6% 10%;
  --sidebar-bg: 222 47% 11%;
  --sidebar-header-bg: 229 84% 5%;
  --bg-light: hsl(var(--subtle));
  --bg-sidebar: hsl(var(--sidebar-bg));
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.4);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.5), 0 1px 2px -1px rgb(0 0 0 / 0.5);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.5), 0 2px 4px -2px rgb(0 0 0 / 0.5);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.55), 0 4px 6px -4px rgb(0 0 0 / 0.5);
}

/* --------------------------------------------------------------------------
   2. BASE — reset + native element styling (replaces Pico base layer)
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { width: 100%; overflow-x: hidden; font-size: clamp(13px, 0.9vw + 0.4vh, 16px); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; padding: 0; width: 100%; min-height: 100%; overflow-x: hidden;
  font-family: var(--pico-font-family);
  background: hsl(var(--background)); color: hsl(var(--foreground));
  font-size: 0.875rem; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, h5, h6 { color: hsl(var(--foreground)); font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.1rem; }
p { margin: 0 0 0.75rem; }
a { color: hsl(var(--primary)); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { margin: 0 0 0.75rem; padding-left: 1.25rem; }
hr { border: none; border-top: 1px solid hsl(var(--border)); margin: 1rem 0; }
img, svg { max-width: 100%; }
nav ul { list-style: none; padding: 0; margin: 0; }
:focus-visible { outline: none; }
[hidden] { display: none !important; }
[aria-busy="true"] { cursor: progress; }
::selection { background: hsl(var(--primary) / 0.25); }

/* Subtle scrollbars */
* { scrollbar-width: thin; scrollbar-color: hsl(var(--border)) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: hsl(var(--border)); border-radius: 999px; }
::-webkit-scrollbar-track { background: transparent; }

/* Disable Pico's native tooltip pseudo-elements (custom JS tooltip is used) */
[data-tooltip]:not([data-tooltip=""])::before,
[data-tooltip]:not([data-tooltip=""])::after { display: none; }

/* Responsive grid utility */
.grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 768px) { .grid { grid-auto-flow: column; grid-auto-columns: 1fr; } }

/* --------------------------------------------------------------------------
   3. BUTTONS — one canonical recipe; raw <button>/[role=button] = .btn
   -------------------------------------------------------------------------- */
.btn, :where(button, [role="button"], a[role="button"]), .btn-ui,
.btn-primary, .btn-secondary, .btn-icon, .logout-btn,
.pagination-btn, .copy-btn, .search-btn, .mdr-select-all-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  height: 34px; padding: 0 0.875rem; margin: 0; white-space: nowrap; user-select: none;
  border: 1px solid transparent; border-radius: var(--radius-md);
  font-family: inherit; font-size: 0.8125rem; font-weight: 500; line-height: 1;
  cursor: pointer; text-decoration: none; transition: var(--transition);
  /* default = secondary variant */
  background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground));
}
.btn:hover, :where(button, [role="button"], a[role="button"]):hover,
.btn-ui:hover, .btn-secondary:hover, .logout-btn:hover {
  background: hsl(var(--secondary) / 0.7); color: hsl(var(--secondary-foreground)); text-decoration: none;
}
.btn:focus-visible, button:focus-visible, [role="button"]:focus-visible, a[role="button"]:focus-visible,
.btn-icon:focus-visible, .copy-btn:focus-visible, .pagination-btn:focus-visible {
  outline: none; box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring));
}
.btn:disabled, button:disabled, button[aria-disabled="true"],
[role="button"][aria-disabled="true"], a[role="button"][aria-disabled="true"], .btn-ui:disabled {
  opacity: 0.5; pointer-events: none; cursor: not-allowed; box-shadow: none;
}
button i, button svg, [role="button"] i, [role="button"] svg,
a[role="button"] i, a[role="button"] svg, .btn i, .btn svg, .btn-icon i, .btn-icon svg {
  width: 1.125rem; height: 1.125rem; stroke-width: 2; flex-shrink: 0;
}

/* Variants */
.btn-primary, button[type="submit"]:not(.btn-success):not(.btn-destructive):not(.btn-warning):not(.btn-info):not(.btn-secondary):not(.btn-outline):not(.btn-ghost):not(.delete):not(.danger), .btn-icon.view {
  background: hsl(var(--primary)); border-color: hsl(var(--primary)); color: hsl(var(--primary-foreground));
}
.btn-primary:hover, button[type="submit"]:not(.btn-success):not(.btn-destructive):not(.btn-warning):not(.btn-info):not(.btn-secondary):not(.btn-outline):not(.btn-ghost):not(.delete):not(.danger):hover, .btn-icon.view:hover {
  background: hsl(var(--primary) / 0.9); border-color: hsl(var(--primary) / 0.9); color: hsl(var(--primary-foreground));
}
.btn-outline, .btn-icon, .pagination-btn, .mdr-select-all-btn, .copy-btn {
  background: hsl(var(--background)); border-color: hsl(var(--border)); color: hsl(var(--foreground));
}
.btn-outline:hover, .btn-icon:hover, .mdr-select-all-btn:hover {
  background: hsl(var(--accent)); color: hsl(var(--accent-foreground));
}
.btn-ghost, .menu-toggle { background: transparent; border-color: transparent; color: hsl(var(--foreground)); box-shadow: none; }
.btn-ghost:hover, .menu-toggle:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.btn-destructive, .btn-icon.delete, .btn-icon.danger { background: hsl(var(--destructive)); border-color: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
.btn-destructive:hover, .btn-icon.delete:hover { background: hsl(var(--destructive) / 0.9); border-color: hsl(var(--destructive) / 0.9); }
.btn-warning, .btn-icon.edit { background: hsl(var(--warning)); border-color: hsl(var(--warning)); color: #fff; }
.btn-warning:hover, .btn-icon.edit:hover { background: hsl(38 92% 42%); border-color: hsl(38 92% 42%); }
.btn-success { background: hsl(var(--success)); border-color: hsl(var(--success)); color: #fff; }
.btn-success:hover { background: hsl(var(--success) / 0.9); border-color: hsl(var(--success) / 0.9); }
.btn-info { background: hsl(217 91% 55%); border-color: hsl(217 91% 55%); color: #fff; }
.btn-info:hover { background: hsl(217 91% 48%); border-color: hsl(217 91% 48%); }
.btn-sm { height: 28px; padding: 0 0.625rem; font-size: 0.75rem; }
.btn-icon { width: 34px; height: 34px; padding: 0; flex-shrink: 0; }

/* Icons inside FILLED/colored buttons are always white (outline/ghost keep foreground for contrast) */
.btn-primary i, .btn-primary svg, button[type="submit"] i, button[type="submit"] svg,
.btn-success i, .btn-success svg, .btn-info i, .btn-info svg,
.btn-warning i, .btn-warning svg, .btn-destructive i, .btn-destructive svg,
.btn-icon.view i, .btn-icon.view svg, .btn-icon.edit i, .btn-icon.edit svg,
.btn-icon.delete i, .btn-icon.delete svg, .btn-icon.danger i, .btn-icon.danger svg { color: #fff; }

/* Link-styled buttons must NEVER show underlined text (incl. hover) */
a.btn, a.btn-ui, a[role="button"], a.btn-primary, a.btn-secondary, a.btn-success,
a.btn-info, a.btn-warning, a.btn-destructive, a.btn-outline, a.btn-ghost,
.list-actions a, .detail-actions a, .wizard-nav a, .pagination a,
a.btn:hover, a.btn-ui:hover, a[role="button"]:hover, a.btn-primary:hover, a.btn-secondary:hover,
a.btn-success:hover, a.btn-info:hover, a.btn-warning:hover, a.btn-destructive:hover,
.list-actions a:hover, .detail-actions a:hover, .wizard-nav a:hover, .pagination a:hover { text-decoration: none; }

/* --------------------------------------------------------------------------
   4. FORMS — inputs / selects / textarea / labels (raw = .input recipe)
   -------------------------------------------------------------------------- */
.input, .select, .searchable-select-input, .rows-limit-select,
input:where(:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="hidden"])),
select, textarea {
  display: flex; width: 100%; height: 34px;
  padding: 0.5rem 0.75rem; margin-bottom: 0.75rem;
  font-family: inherit; font-size: 0.875rem; line-height: 1.25rem;
  background: hsl(var(--background)); color: hsl(var(--foreground));
  border: 1px solid hsl(var(--input)); border-radius: var(--radius-md);
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 34px; resize: vertical; }
select { cursor: pointer; }
input::placeholder, textarea::placeholder { color: hsl(var(--muted-foreground)); opacity: 1; }
.input:focus, .select:focus, input:focus, select:focus, textarea:focus,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: hsl(var(--ring)); box-shadow: 0 0 0 3px var(--ring-soft);
}
input:disabled, select:disabled, textarea:disabled { opacity: 0.5; cursor: not-allowed; }
input[type="checkbox"], input[type="radio"] { width: auto; height: auto; margin: 0; accent-color: hsl(var(--primary)); }
label, .field-label { display: block; margin-bottom: 0.375rem; font-size: 0.875rem; font-weight: 500; color: hsl(var(--foreground)); }

/* Search field native chrome off */
input[type="search"] { background-image: none; }
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration { display: none; }

/* Validation states */
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: hsl(var(--destructive)); }
input[aria-invalid="false"], select[aria-invalid="false"], textarea[aria-invalid="false"] { border-color: hsl(var(--success)); }

/* Inputs inside tables / filter rows: identical look to all other inputs, just no bottom margin */
table input:not([type="checkbox"]):not([type="radio"]), table select, table textarea,
.filter-row input, .filter-row select, td input, td select, th input, th select { margin-bottom: 0; }

/* --------------------------------------------------------------------------
   5. CARD — surfaces: figure / article / .mini-card / .filters / .login-card
   -------------------------------------------------------------------------- */
.card, article, figure, .filters, .login-card, .mini-card,
.switch-multiselect-container, .detail-table, .mdr-traffic-type-card {
  background: hsl(var(--card)); color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border)); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
/* Form/view cards (e.g. /edit, /create, /view) get inner padding so content isn't flush to the border */
article:has(form), article:has(.wizard-panel) { padding: 1.5rem; }
@media (min-width: 768px) { article:has(form), article:has(.wizard-panel) { padding: 1.75rem 2rem; } }

article header, .detail-section-header {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.75rem 1rem; background: hsl(var(--muted)); color: hsl(var(--foreground)); font-weight: 600;
}
article header i { width: 24px; height: 24px; }

/* --------------------------------------------------------------------------
   6. TABLE — list tables + striped + sticky columns
   -------------------------------------------------------------------------- */
figure { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0; width: 100%; max-width: 100%; position: relative; }
/* Fill the container; columns size to content (table-layout auto). figure scrolls if content overflows. */
.table, table { width: 100%; max-width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.875rem; background: transparent; }
.table thead th, table thead th, table thead tr {
  background: hsl(var(--muted)); text-align: left; padding: 0.75rem 0.875rem; font-weight: 500;
  font-size: 0.75rem; letter-spacing: 0.05em; text-transform: uppercase;
  color: hsl(var(--muted-foreground)); border-bottom: 1px solid hsl(var(--border)); white-space: nowrap;
}
.table tbody td, table th, table td {
  padding: 0.65rem 0.75rem; font-size: 0.825rem; line-height: 1.4;
  border-bottom: 1px solid hsl(var(--border)); color: hsl(var(--foreground)); vertical-align: middle;
}
.table tbody tr:hover, table tbody tr:hover td, .table tbody tr:hover td { background: hsl(var(--accent) / 0.5); }
table.striped th, table.striped td, .table.striped th, .table.striped td { white-space: nowrap; }
table.striped tbody tr:nth-child(even) td, .table.striped tbody tr:nth-child(even) td { background: hsl(var(--subtle)); }
table.striped td:has(.tag-list) { white-space: normal; overflow: visible; max-width: 420px; }
.row-inactive { background: hsl(var(--subtle)); opacity: 0.8; }

/* Sticky columns */
/* Sticky columns blend with the rest of the row — no distinct shadow/tint, so Actions looks like any other column */
.sticky-col { position: sticky; z-index: 20; background: hsl(var(--card)); }
.sticky-col.sticky-col-right { border-left: 1px solid hsl(var(--border)); }
thead tr:first-child th.sticky-col, thead tr.filter-row th.sticky-col {
  z-index: 30; background: hsl(var(--muted));
  border-left: 1px solid hsl(var(--border)); border-right: 1px solid hsl(var(--border));
}
table.striped tbody tr:nth-child(even) td.sticky-col { background: hsl(var(--subtle)); }
table tbody tr:hover td.sticky-col, .table tbody tr:hover td.sticky-col { background: hsl(var(--accent) / 0.5); }

/* Actions cell */
td.actions, th.actions-col { width: 1%; white-space: nowrap; text-align: center; vertical-align: middle; }
.actions-wrapper { display: flex; align-items: center; justify-content: center; gap: 0.75rem; width: 100%; height: 100%; }
.actions form, .actions-wrapper form { margin: 0; display: contents; }

/* --------------------------------------------------------------------------
   7. BADGES — pill: .role-badge / .status-badge / .tag-badge / .tag-item
   -------------------------------------------------------------------------- */
.badge, .role-badge, .status-badge, .tag-badge, .tag-item, .mdr-tt-badge, .multiselect-count .count-number {
  display: inline-flex; align-items: center; padding: 0.125rem 0.5rem;
  font-size: 0.6875rem; font-weight: 600; line-height: 1.25; border-radius: 999px;
  border: 1px solid hsl(var(--border)); white-space: nowrap;
}
.badge-success, .status-active, .role-manager { background: hsl(var(--success) / 0.12); color: hsl(142 71% 32%); border-color: hsl(var(--success) / 0.25); }
.badge-danger, .status-inactive, .role-admin { background: hsl(var(--destructive) / 0.12); color: hsl(0 72% 45%); border-color: hsl(var(--destructive) / 0.25); }
.badge-warning { background: hsl(var(--warning) / 0.12); color: hsl(38 92% 38%); border-color: hsl(var(--warning) / 0.25); }
.badge-muted, .role-badge, .role-none, .mdr-tt-badge { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); border-color: hsl(var(--border)); }
.role-user { background: hsl(258 90% 92%); color: hsl(263 70% 35%); border-color: hsl(258 90% 85%); }
.tag-badge, .tag-item, .mdr-tt-badge.has-selection { background: hsl(214 95% 93%); color: hsl(224 64% 40%); border-color: hsl(213 97% 85%); font-weight: 500; }
.tag-list { display: flex; flex-wrap: wrap; gap: 0.3rem; max-width: 400px; }
/* Dark-mode badge contrast: lighten fixed text + tint pastel backgrounds so badges stay readable on dark surfaces */
.dark .badge-success, .dark .status-active, .dark .role-manager { color: hsl(142 60% 62%); }
.dark .badge-danger, .dark .status-inactive, .dark .role-admin { color: hsl(0 84% 70%); }
.dark .badge-warning { color: hsl(38 92% 62%); }
.dark .role-user { background: hsl(263 70% 60% / 0.18); color: hsl(263 85% 80%); border-color: hsl(263 70% 60% / 0.35); }
.dark .tag-badge, .dark .tag-item, .dark .mdr-tt-badge.has-selection { background: hsl(214 90% 60% / 0.18); color: hsl(214 95% 80%); border-color: hsl(214 90% 60% / 0.35); }

/* --------------------------------------------------------------------------
   8. LOGIN
   -------------------------------------------------------------------------- */
.login-card { max-width: 420px; margin: 2rem auto; display: block; padding: 1.5rem; }
.login-card > header { text-align: center; padding-bottom: 2rem; }
.login-card > header h1 { margin: 0; }
.login-logo-container { display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0 auto; gap: 1rem; padding: 1rem; background: hsl(var(--sidebar-bg)); border-radius: var(--radius-md); }
.login-logo { height: auto; display: block; }
.login-text { display: block; text-align: center; color: hsl(var(--foreground)); font-size: 1.5rem; font-weight: 700; margin-bottom: 1.5rem; }
.buttons-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.buttons-grid > * { width: 100%; white-space: nowrap; }

/* --------------------------------------------------------------------------
   9. ALERTS / MESSAGES — error-message, alert-box, field-error/hint/help
   -------------------------------------------------------------------------- */
.error-message, .alert-box.alert-error, .alert-error {
  padding: 0.875rem 1rem; margin-bottom: 1rem; border-radius: var(--radius-md);
  background: hsl(var(--destructive) / 0.1); border: 1px solid hsl(var(--destructive) / 0.3); color: hsl(0 72% 45%);
}
.error-message { border-left: 4px solid hsl(var(--destructive)); }
.alert-box { display: none; align-items: center; gap: 0.75rem; padding: 0.875rem 1rem; margin-bottom: 1rem; border-radius: var(--radius-md); font-weight: 500; font-size: 0.875rem; border: 1px solid hsl(var(--border)); animation: fadeIn .3s ease-in-out; }
.alert-success { background: hsl(var(--success) / 0.1); border: 1px solid hsl(var(--success) / 0.3); color: hsl(142 71% 32%); }
.alert-box.alert-error ul { margin: 0.5rem 0 0; padding-left: 1.25rem; }
.alert-box.alert-error ul li { margin-bottom: 0.25rem; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

.field-help, .field-hint, .step-counter, .step-info-alert { font-size: 0.8rem; color: hsl(var(--muted-foreground)); margin-top: 0.25rem; }
.field-hint { font-style: italic; }
.step-counter { text-align: center; }
.step-info-alert { padding: 0.75rem 1rem; background: hsl(var(--muted)); border: 1px solid hsl(var(--border)); border-radius: var(--radius-md); }
.field-error { display: none; align-items: center; gap: 0.25rem; margin-top: 0.25rem; font-size: 0.75rem; color: hsl(var(--destructive)); }
.field-error.visible { display: flex; }
.field-error i { width: 14px; height: 14px; flex-shrink: 0; }

/* --------------------------------------------------------------------------
   10. DASHBOARD — section-divider, dashboard-grid, mini-card
   -------------------------------------------------------------------------- */
.section-divider { display: flex; align-items: center; gap: 0.75rem; margin: 1rem 0 0.75rem; padding-bottom: 0.5rem; font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; color: hsl(var(--foreground)); border-bottom: 1px solid hsl(var(--border)); }
.dashboard-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.mini-card { display: flex; align-items: center; padding: 1.25rem 1.5rem; text-decoration: none; color: inherit; transition: var(--transition); }
.mini-card:hover { border-color: hsl(var(--primary)); background: hsl(var(--muted)); box-shadow: var(--shadow-md); text-decoration: none; }
.mini-card, .mini-card:hover, .mini-card * { text-decoration: none; }
.mini-card-icon { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-right: 1rem; background: hsl(var(--muted)); border-radius: var(--radius-md); color: hsl(var(--primary)); flex-shrink: 0; }
.mini-card-icon i { width: 20px; height: 20px; }
.mini-card-content { flex: 1; }
.mini-card-title { display: block; margin-bottom: 0.2rem; font-weight: 600; font-size: 0.95rem; color: hsl(var(--foreground)); }
.mini-card-action { display: flex; align-items: center; gap: 0.25rem; font-size: 0.75rem; color: hsl(var(--muted-foreground)); }
.mini-card-action i { width: 14px; height: 14px; }

/* --------------------------------------------------------------------------
   11. LAYOUT — app-layout, sidebar, main-content, top-header, footer
   -------------------------------------------------------------------------- */
.app-layout { display: flex; min-height: 100vh; overflow-x: hidden; }

.sidebar {
  position: fixed; top: 0; left: 0; width: 16.25rem; height: 100vh; z-index: 100;
  padding: 0; overflow-y: auto; overflow-x: hidden;
  background: hsl(var(--sidebar-bg)); color: hsl(214 32% 80%);
  transform: translateX(-100%); transition: transform 0.3s ease-in-out;
}
.sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgb(0 0 0 / 0.15); }
.sidebar-header { padding: 1.5rem 1.25rem; background: hsl(var(--sidebar-header-bg)); border-bottom: 1px solid rgb(255 255 255 / 0.08); }
.sidebar-header h2 { margin: 0; font-size: 1.5rem; color: #fff; font-weight: 600; }
.logo-wrapper { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 0.75rem; width: 100%; }
.sidebar-logo { max-width: 60px; height: auto; display: block; }
.logo-text { font-size: 1.25rem; font-weight: 700; color: #fff; letter-spacing: 0.025em; }
.sidebar-nav { padding: 0.75rem 0; }
.sidebar-nav ul { list-style: none; padding: 0; margin: 0; }
.sidebar-nav li { margin: 0; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 0.75rem; margin: 0.125rem 0.5rem;
  padding: 0.5rem 0.75rem; min-height: 34px; border-radius: var(--radius-md);
  color: hsl(214 32% 80%); text-decoration: none; font-size: 0.875rem; font-weight: 500;
  transition: background-color .15s, color .15s;
}
.sidebar-nav a:hover { background: rgb(255 255 255 / 0.08); color: #fff; text-decoration: none; }
.sidebar-nav a.active { background: hsl(var(--primary) / 0.22); color: #fff; }
.sidebar-nav a:focus-visible { outline: none; box-shadow: 0 0 0 2px hsl(var(--sidebar-bg)), 0 0 0 4px hsl(var(--ring)); }
.sidebar-nav i { display: flex; align-items: center; justify-content: center; width: 1.25rem; height: 1.25rem; flex-shrink: 0; }

.sidebar-category { display: flex; align-items: center; gap: 0.5rem; padding: 1.25rem 1.25rem 0.5rem; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: hsl(var(--muted-foreground)); pointer-events: none; user-select: none; }
.sidebar-category::after { content: ""; flex: 1; height: 1px; background: rgb(255 255 255 / 0.06); }
.sidebar-nav .submenu-toggle { display: flex; align-items: center; width: auto; cursor: pointer; }
.sidebar-nav .submenu-toggle .chevron { width: 1rem; height: 1rem; margin-left: auto; flex-shrink: 0; transition: transform 0.3s ease; }
.sidebar-nav .has-submenu.active .submenu-toggle .chevron { transform: rotate(180deg); }
.sidebar-nav .submenu-items { list-style: none; padding: 0; margin: 0; max-height: 0; overflow: hidden auto; transition: max-height 0.3s ease-out; }
.sidebar-nav .has-submenu.active .submenu-items { max-height: 400px; transition: max-height 0.5s ease-in; }
.sidebar-nav .submenu-items a { font-size: 0.85rem; padding-left: 1.75rem; margin: 0.125rem 0.5rem; }
.sidebar-nav .submenu-items a:hover { background: rgb(255 255 255 / 0.08); color: #fff; }
.sidebar-nav .submenu-items a.active { background: hsl(var(--primary) / 0.22); color: #fff; }

.main-content { display: flex; flex-direction: column; margin-left: 0; width: 100%; min-width: 0; min-height: 100vh; transition: margin-left 0.3s ease, width 0.3s ease; }
.sidebar-overlay { position: fixed; inset: 0; z-index: 90; background: hsl(222 47% 11% / 0.5); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.sidebar-overlay.open { opacity: 1; pointer-events: auto; }

.top-header {
  position: sticky; top: 0; z-index: 50; height: 4rem; padding: 0 1rem;
  display: flex; align-items: center; justify-content: space-between;
  background: hsl(var(--background) / 0.85); backdrop-filter: saturate(180%) blur(8px); -webkit-backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid hsl(var(--border));
}
.user-menu { display: flex; align-items: center; justify-content: center; gap: 0.75rem; width: 100%; margin-left: auto; }
.user-info { display: flex; align-items: center; justify-content: center; gap: 0.5rem; color: hsl(var(--muted-foreground)); font-weight: 500; }
.user-info i { display: none; width: 20px; height: 20px; color: hsl(var(--muted-foreground)); }
.user-details { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; }
.user-name { font-weight: 600; color: hsl(var(--foreground)); }
/* Logout is destructive (red); icon inherits the white destructive-foreground */
.logout-btn { position: absolute; right: 1rem; width: 34px; padding: 0; background: hsl(var(--destructive)); border-color: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); box-shadow: none; }
.logout-btn:hover { background: hsl(var(--destructive) / 0.9); border-color: hsl(var(--destructive) / 0.9); color: hsl(var(--destructive-foreground)); }
.logout-btn span { display: none; }
.menu-toggle { display: inline-flex; margin-right: 0.5rem; }
/* Mobile: place the theme toggle right beside the (absolute) logout button */
.top-header .theme-toggle { position: absolute; right: 3.5rem; }

.content-container, body[data-page-type="list"] .content-container { display: flex; flex-direction: column; flex: 1; width: 100%; max-width: 100%; margin: 0; padding: 1rem; }
.page-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; width: 100%; margin-bottom: 1rem; }
.page-header h1 { display: flex; align-items: center; gap: 0.5rem; margin: 0; color: hsl(var(--foreground)); }

.app-footer { margin-top: auto; padding: 1rem; text-align: center; font-size: 0.875rem; color: hsl(var(--muted-foreground)); background: hsl(var(--card)); border-top: 1px solid hsl(var(--border)); }
.app-footer .footer-content { justify-content: center; }

/* --------------------------------------------------------------------------
   12. LIST VIEW — list-page-header, search group, pagination, filters
   -------------------------------------------------------------------------- */
.list-page-header { display: flex; flex-direction: column; gap: 1.25rem; margin-bottom: 1.5rem; }
.list-header-main { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; width: 100%; }
.list-title-group { display: flex; flex-direction: column; gap: 0.25rem; }
.list-title { display: flex; align-items: center; gap: 0.65rem; margin: 0; font-size: 1.5rem; color: hsl(var(--foreground)); }
.list-title-icon-wrapper { display: inline-flex; align-items: center; }
.list-subtitle { margin: 0; font-size: 0.875rem; color: hsl(var(--muted-foreground)); }
.list-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem; }

.list-search-wrapper, .search-input-wrapper { display: flex; align-items: center; width: 100%; max-width: 100%; }
.search-input-group { position: relative; display: flex; align-items: center; width: 100%; max-width: 500px; }
.search-icon-fixed { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); width: 1.125rem; height: 1.125rem; color: hsl(var(--muted-foreground)); pointer-events: none; z-index: 10; }
.search-input-group input[type="search"], .search-input-wrapper input[type="search"] { width: 100%; height: 34px; padding: 0.5rem 1rem 0.5rem 2.75rem; margin: 0; }
.search-btn {
  position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
  width: 1.5rem; height: 1.5rem; padding: 0; min-width: 0;
  background: transparent; border-color: transparent; color: hsl(var(--muted-foreground)); box-shadow: none;
}
.search-btn:hover { background: transparent; color: hsl(var(--foreground)); }
.search-btn i, .search-btn svg { width: 1.125rem; height: 1.125rem; display: block; }
#clear-search { cursor: pointer; }
#clear-search:hover { color: hsl(var(--destructive)); background: hsl(var(--destructive) / 0.1); border-radius: 50%; }

.input-with-icon-wrapper { position: relative; display: flex; align-items: center; width: 100%; }
.input-with-icon-wrapper .field-prefix-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); display: flex; align-items: center; justify-content: center; width: 16px; height: 16px; color: hsl(var(--muted-foreground)); pointer-events: none; z-index: 2; }
.input-with-icon-wrapper input { padding-left: 38px; }
.input-addon-symbol { width: auto; padding: 0 1rem; font-weight: 600; background: hsl(var(--muted)); color: hsl(var(--foreground)); border: 1px solid hsl(var(--border-strong)); cursor: default; pointer-events: none; }

.pagination-container { display: flex; flex-direction: column; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; padding-top: 1.5rem; margin-top: 0.5rem; border-top: 1px solid hsl(var(--border)); }
.pagination-info { font-size: 0.875rem; color: hsl(var(--muted-foreground)); text-align: center; }
.pagination-controls { display: flex; gap: 0.5rem; }
.pagination-btn { min-width: 34px; height: 34px; padding: 0 0.5rem; font-size: 0.875rem; }
.pagination-btn:hover:not(:disabled) { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.pagination-btn.active { background: hsl(var(--primary)); border-color: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.pagination-btn:disabled, .pagination-btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; background: hsl(var(--muted)); }
.pagination-btn i, .pagination-btn svg { width: 16px; height: 16px; }
.rows-limit-select { width: auto; min-width: 85px; margin: 0; padding: 0 1.75rem 0 0.75rem; font-size: 0.825rem; display: inline-flex; align-items: center; }

/* Legacy pill pagination */
.pagination { display: flex; justify-content: center; align-items: center; margin-top: 1.5rem; }
.pagination ul { display: flex; align-items: center; list-style: none; margin: 0; gap: 1rem; padding: 0.5rem 1rem; background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: 999px; box-shadow: var(--shadow-sm); }
.pagination a, .pagination span { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border-radius: 50%; color: hsl(var(--muted-foreground)); transition: var(--transition); }
.pagination a:hover { background: hsl(var(--muted)); color: hsl(var(--foreground)); text-decoration: none; }
.pagination span[aria-disabled="true"] { opacity: 0.3; cursor: not-allowed; }
.pagination li:nth-child(2) { font-weight: 600; color: hsl(var(--secondary-foreground)); font-size: 0.9rem; }

.filters { padding: 1.25rem; margin-bottom: 1.5rem; }
.filter-form .grid { display: grid; grid-template-columns: 1fr; gap: 1rem; align-items: end; }
.filter-form label { font-weight: 500; color: hsl(var(--foreground)); font-size: 0.875rem; margin-bottom: 0.375rem; }
.filter-form input, .filter-form select { margin-bottom: 0; }

/* --------------------------------------------------------------------------
   Filter bar (logs & similar) — CSS grid keeps every field aligned into
   columns; labels on top, controls + action buttons bottom-aligned.
   -------------------------------------------------------------------------- */
.logs-filters {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem 1rem; align-items: end;
  padding: 1rem 1.25rem; margin-bottom: 1rem;
  background: hsl(var(--card)); border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.filter-group { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.filter-group label { margin-bottom: 0; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: hsl(var(--muted-foreground)); }
.filter-group select, .filter-group input { height: 36px; margin-bottom: 0; }
.filter-actions { display: flex; align-items: end; gap: 0.5rem; }
.filter-actions .btn { flex: 1; height: 36px; }
@media (max-width: 560px) { .logs-filters { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------------------
   13. DETAIL VIEW — detail-grid, detail-item, detail-table, copy-btn
   -------------------------------------------------------------------------- */
.detail-grid { display: grid; grid-template-columns: 1fr; gap: 0; }
.detail-item { padding: 0.875rem 1rem; border-bottom: 1px solid hsl(var(--border)); }
.detail-item:hover { background: hsl(var(--muted)); }
.detail-label { margin-bottom: 0.25rem; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: hsl(var(--muted-foreground)); }
.detail-value { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; width: 100%; font-size: 0.95rem; font-weight: 500; color: hsl(var(--foreground)); }
.detail-value.empty { color: hsl(var(--muted-foreground)); font-style: italic; }
.value-text, .value-content { flex: 1; word-break: break-word; }
.detail-section { margin-bottom: 1.5rem; }
.detail-section-header { border-radius: var(--radius-lg) var(--radius-lg) 0 0; border: 1px solid hsl(var(--border)); border-bottom: none; }
.detail-section-header h3 { margin: 0; font-size: 1rem; color: hsl(var(--foreground)); }
.detail-section-header i { width: 18px; height: 18px; color: hsl(var(--primary)); }
.section-content { margin-bottom: 1.5rem; overflow: hidden; background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.detail-actions { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1.5rem; }

.detail-table { width: 100%; min-width: 0; border-collapse: collapse; overflow: hidden; }
.detail-table tr { display: flex; align-items: center; border-bottom: 1px solid hsl(var(--border)); transition: background-color 0.2s ease; }
.detail-table tr:hover { background: hsl(var(--muted)); }
.detail-table tr:last-child { border-bottom: none; }
.detail-table td { width: 50%; padding: 0.75rem 1rem; display: block; }
.detail-table .detail-label { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.075em; border-right: 1px solid hsl(var(--border)); margin-bottom: 0; }
.detail-table .detail-value { min-height: 1.5rem; font-size: 1rem; gap: 1rem; }
.copy-btn { width: 2rem; height: 2rem; padding: 0; color: hsl(var(--muted-foreground)); border-radius: var(--radius-sm); flex-shrink: 0; box-shadow: none; }
.copy-btn:hover { background: hsl(var(--accent)); color: hsl(var(--primary)); border-color: hsl(var(--border-strong)); }
.copy-btn i, .copy-btn svg { width: 14px; height: 14px; }

/* --------------------------------------------------------------------------
   14. WIZARD — stepper, panels, navigation
   -------------------------------------------------------------------------- */
.wizard-stepper { display: flex; align-items: stretch; gap: 0.25rem; width: 100%; margin-bottom: 1.5rem; padding: 0.25rem; overflow-x: auto; -webkit-overflow-scrolling: touch; background: hsl(var(--muted)); border: 1px solid hsl(var(--border)); border-radius: var(--radius-lg); }
.wizard-step { position: relative; display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.75rem 0.5rem; border-radius: var(--radius-md); cursor: pointer; white-space: nowrap; text-align: center; font-size: 0.8rem; font-weight: 500; color: hsl(var(--muted-foreground)); transition: var(--transition); }
.wizard-step:hover { color: hsl(var(--foreground)); background: hsl(var(--background) / 0.7); }
.wizard-step .step-number { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: hsl(var(--border-strong)); color: #fff; font-weight: 700; font-size: 0.7rem; flex-shrink: 0; transition: all 0.3s ease; }
.wizard-step .step-icon { width: 14px; height: 14px; }
.wizard-step .step-label { display: none; }
.wizard-step.active { color: hsl(var(--primary)); background: hsl(var(--card)); border: 1px solid hsl(var(--primary)); box-shadow: var(--shadow-sm); }
.wizard-step.active .step-number { background: hsl(var(--primary)); color: #fff; }
.wizard-step.active .step-label { display: inline-block; }
.wizard-step.completed { color: hsl(142 71% 38%); }
.wizard-step.completed .step-number { background: hsl(var(--success)); }
.wizard-step-connector { display: none; }
.wizard-step-connector.completed { background: hsl(var(--success)); }

.wizard-panel { display: none; animation: fadeInPanel 0.35s ease-in-out; }
.wizard-panel.active { display: block; }
@keyframes fadeInPanel { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.wizard-panel-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1.5rem; padding-bottom: 0.75rem; border-bottom: 1px solid hsl(var(--border)); }
.wizard-panel-header h3 { margin: 0; font-size: 1.1rem; color: hsl(var(--foreground)); }
.wizard-panel-header i { color: hsl(var(--primary)); }
.wizard-nav { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid hsl(var(--border)); }
.wizard-nav button, .wizard-nav a[role="button"] { display: inline-flex; align-items: center; gap: 0.5rem; margin-bottom: 0; }
.wizard-nav .btn-prev { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); border-color: hsl(var(--border)); }
.wizard-nav .btn-prev:hover { background: hsl(var(--secondary) / 0.7); }

.form-field-grid { display: grid; grid-template-columns: 1fr; gap: 0.75rem 1.5rem; }
.form-field-grid .field-full-width { grid-column: 1 / -1; }
.pl-field-label-cell { position: sticky; left: 0; z-index: 1; padding: 8px 14px; font-weight: 500; color: hsl(var(--foreground)); background: hsl(var(--card)); border-right: 1px solid hsl(var(--border)); }
.pl-field-label-wrapper { display: flex; align-items: center; gap: 0.5rem; }
.pl-field-label-wrapper i { color: hsl(var(--muted-foreground)); flex-shrink: 0; }

/* --------------------------------------------------------------------------
   15. MULTISELECT (switch style) + SEARCHABLE SELECT (popover)
   -------------------------------------------------------------------------- */
.switch-multiselect-container { max-height: 300px; overflow-y: auto; padding: 0.25rem; }
.switch-multiselect-item { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 0.75rem; border-bottom: 1px solid hsl(var(--border)); border-radius: var(--radius-md); transition: background-color 0.15s; }
.switch-multiselect-item:last-child { border-bottom: none; }
.switch-multiselect-item:hover { background: hsl(var(--muted)); }
.switch-multiselect-item label, .switch-label { display: flex; align-items: center; gap: 0.75rem; flex: 1; margin-bottom: 0; cursor: pointer; font-size: 0.875rem; color: hsl(var(--foreground)); }
.multiselect-search { margin-bottom: 0.5rem; font-size: 0.85rem; }
.multiselect-count { display: flex; align-items: center; gap: 0.25rem; margin-top: 0.375rem; font-size: 0.75rem; color: hsl(var(--muted-foreground)); }
.multiselect-count .count-number { font-weight: 600; color: hsl(var(--primary)); background: hsl(var(--primary) / 0.12); border-color: hsl(var(--primary) / 0.3); }

.searchable-select-wrapper { position: relative; width: 100%; }
.searchable-select-input { width: 100%; height: 34px; margin-bottom: 0; padding: 0.5rem 2.5rem 0.5rem 0.75rem; line-height: 1.25; text-align: left; direction: ltr; cursor: text; }
.searchable-select-clear { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); z-index: 5; width: auto; height: auto; min-width: 0; padding: 5px; margin: 0; display: none; align-items: center; justify-content: center; background: transparent; border-color: transparent; box-shadow: none; color: hsl(var(--muted-foreground)); cursor: pointer; }
.searchable-select-clear:hover { background: transparent; color: hsl(var(--destructive)); }
.searchable-select-clear svg { width: 16px; height: 16px; }
.searchable-select-dropdown { display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 2000; max-height: 300px; margin-top: 4px; padding: 0.25rem; overflow-y: auto; background: hsl(var(--popover)); color: hsl(var(--popover-foreground)); border: 1px solid hsl(var(--border)); border-radius: var(--radius-md); box-shadow: var(--shadow-md); }
.searchable-select-wrapper.open .searchable-select-dropdown { display: block; }
.searchable-select-option { padding: 0.5rem 0.75rem; font-size: 0.875rem; color: hsl(var(--popover-foreground)); border-radius: var(--radius-sm); cursor: pointer; text-align: left; transition: background-color .15s, color .15s; }
.searchable-select-option:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.searchable-select-option.selected { background: hsl(var(--primary) / 0.12); color: hsl(var(--primary)); font-weight: 600; }

/* --------------------------------------------------------------------------
   16. MDR MATRIX (traffic type accordion)
   -------------------------------------------------------------------------- */
.mdr-matrix-container { display: flex; flex-direction: column; gap: 0.5rem; }
.mdr-traffic-type-card { overflow: hidden; transition: box-shadow 0.2s ease; }
.mdr-traffic-type-card[open] { border-color: hsl(var(--border-strong)); box-shadow: var(--shadow-md); }
.mdr-tt-header { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1rem; list-style: none; cursor: pointer; user-select: none; transition: background-color 0.15s; }
.mdr-tt-header::-webkit-details-marker { display: none; }
.mdr-tt-header:hover { background: hsl(var(--muted)); }
.mdr-tt-header-left { display: flex; align-items: center; gap: 0.75rem; width: 100%; }
.mdr-tt-name { font-weight: 600; font-size: 0.9rem; color: hsl(var(--foreground)); }
.mdr-tt-badge { justify-content: center; transition: all 0.2s; }
.mdr-tt-body { padding: 0 1rem 0.75rem; border-top: 1px solid hsl(var(--border)); }
.mdr-tt-actions { display: flex; gap: 0.5rem; padding: 0.5rem 0; }
.mdr-select-all-btn { height: auto; padding: 0.25rem 0.75rem; font-size: 0.72rem; font-weight: 500; border-radius: var(--radius-sm); width: auto; margin-bottom: 0; }
.mdr-brands-list { display: grid; grid-template-columns: 1fr; gap: 0; }
.mdr-brand-item { display: flex; align-items: center; padding: 0.4rem 0.5rem; border-radius: var(--radius-sm); transition: background-color 0.15s; }
.mdr-brand-item:hover { background: hsl(var(--muted)); }
.mdr-brand-item label { display: flex; align-items: center; gap: 0.75rem; flex: 1; margin-bottom: 0; cursor: pointer; font-size: 0.85rem; color: hsl(var(--foreground)); }

/* --------------------------------------------------------------------------
   17. PASSWORD FIELD + REQUIREMENTS (change/reset password)
   -------------------------------------------------------------------------- */
.password-input-wrapper { position: relative; display: flex; align-items: center; width: 100%; }
.password-input-wrapper input { padding-right: 2.75rem; }
.toggle-password { position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%); width: 1.75rem; height: 1.75rem; padding: 0; min-width: 0; background: transparent; border-color: transparent; color: hsl(var(--muted-foreground)); box-shadow: none; }
.toggle-password:hover { background: hsl(var(--accent)); color: hsl(var(--foreground)); }
.eye-icon { width: 1.125rem; height: 1.125rem; }
.password-requirements { margin: 0.5rem 0; padding: 0.75rem 1rem; list-style: none; background: hsl(var(--muted)); border: 1px solid hsl(var(--border)); border-radius: var(--radius-md); font-size: 0.8rem; }
.requirement { display: flex; align-items: center; gap: 0.5rem; padding: 0.15rem 0; color: hsl(var(--muted-foreground)); }
.requirement.valid { color: hsl(142 71% 38%); }

/* --------------------------------------------------------------------------
   18. MISC — tooltip, pin icon, no-perm, countdowns
   -------------------------------------------------------------------------- */
.pin-icon-wrapper { display: inline-flex; align-items: center; justify-content: center; margin-left: 0.25rem; color: hsl(var(--foreground)); opacity: 0.5; cursor: pointer; transition: var(--transition); }
.pin-icon-wrapper:hover { color: hsl(var(--primary)); opacity: 1; }
.pin-icon-wrapper.active { color: hsl(var(--primary)); opacity: 1; transform: rotate(-45deg); }
.pin-icon-wrapper svg { width: 15px; height: 15px; }
.no-perm-wrapper { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; padding: 3rem 1rem; text-align: center; color: hsl(var(--muted-foreground)); }
#permTooltip { position: absolute; z-index: 3000; padding: 0.375rem 0.625rem; font-size: 0.75rem; background: hsl(var(--popover)); color: hsl(var(--popover-foreground)); border: 1px solid hsl(var(--border)); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); pointer-events: none; }
#resetCountdown, #resetPageCountdown { font-weight: 600; color: hsl(var(--primary)); }

/* ==========================================================================
   19. DESKTOP ENHANCEMENTS (mobile-first min-width layering)
   ========================================================================== */
@media (min-width: 640px) {
  .buttons-grid, .mdr-brands-list { grid-template-columns: 1fr 1fr; }
  .pagination-container { flex-direction: row; }
  .pagination-info { text-align: left; }
}
@media (min-width: 768px) {
  .sidebar { transform: translateX(0); }
  .main-content { margin-left: 16.25rem; width: calc(100% - 16.25rem); }
  .sidebar-overlay, .menu-toggle { display: none; }
  .top-header { padding: 0 2rem; }
  .user-menu { width: auto; justify-content: flex-end; gap: 1.5rem; }
  .user-info { align-items: flex-start; gap: 0.75rem; }
  .user-info i { display: block; }
  .user-details { align-items: flex-start; }
  .logout-btn { position: static; right: auto; width: auto; padding: 0 0.875rem; background: hsl(var(--destructive)); border: 1px solid hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); box-shadow: var(--shadow-sm); }
  .logout-btn:hover { background: hsl(var(--destructive) / 0.9); border-color: hsl(var(--destructive) / 0.9); }
  .top-header .theme-toggle { position: static; right: auto; }
  .logout-btn span { display: inline; }
  .content-container { padding: 1.5rem 2rem; }
  body[data-page-type="list"] .content-container { padding: 1rem 1.5rem; }
  .app-footer { padding: 1rem 2rem; text-align: right; }
  .form-field-grid, .detail-grid { grid-template-columns: 1fr 1fr; }
  .wizard-stepper { justify-content: space-between; }
  .wizard-step .step-label { display: inline-block; }
  .filter-form .grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); grid-auto-flow: row; gap: 1.5rem; }
  .list-search-wrapper { max-width: 400px; }
}
@media (min-width: 1024px) {
  .content-container { padding: 1.75rem 2.5rem; }
  .dashboard-grid { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 1.25rem; }
  .mini-card { padding: 1.5rem 1.75rem; }
}

/* ==========================================================================
   20. OS PREFERENCE FALLBACK — only when no explicit theme is pinned
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  :root:not(.dark):not([data-theme]) {
    --background: 240 10% 3.9%; --foreground: 0 0% 98%;
    --card: 240 6% 6%; --card-foreground: 0 0% 98%;
    --popover: 240 6% 6%; --popover-foreground: 0 0% 98%;
    --secondary: 240 3.7% 15.9%; --secondary-foreground: 0 0% 98%;
    --muted: 240 3.7% 15.9%; --muted-foreground: 240 5% 64.9%;
    --accent: 240 3.7% 15.9%; --accent-foreground: 0 0% 98%;
    --destructive: 0 72% 50%; --destructive-foreground: 0 0% 98%;
    --border: 240 3.7% 15.9%; --input: 240 3.7% 15.9%;
    --border-strong: 240 5% 34%; --subtle: 240 6% 10%;
    --sidebar-bg: 222 47% 11%; --sidebar-header-bg: 229 84% 5%;
  }
}
