/* ============================================================
   Registre PeL — Design System (Dark Mode OLED)
   Single CSS file for the entire application.
   ============================================================ */

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

/* Alpine.js x-cloak: hide elements until Alpine initializes */
[x-cloak] { display: none !important; }

/* ============================================================
   1. Design Tokens
   ============================================================ */
:root {
  /* Backgrounds */
  --bg-deep: #0A0A0A;
  --bg-base: #121212;
  --bg-elevated: #1E1E2E;
  --bg-card: #1A1A2E;

  /* Text */
  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;

  /* Colors */
  --primary: #2563EB;
  --primary-hover: #3B82F6;
  --secondary: #334155;
  --accent: #F97316;
  --success: #22C55E;
  --danger: #EF4444;
  --warning: #F59E0B;
  --info: #0EA5E9;

  /* Borders */
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --ring: #2563EB;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Typography */
  --font-sans: 'Fira Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'Fira Code', monospace;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;

  /* Shadows */
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.6);
}

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

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

body {
  font-family: var(--font-sans);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

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

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

ul, ol {
  list-style: none;
}

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

/* ============================================================
   3. Navigation Bar
   ============================================================ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 24px;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.navbar-brand {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.navbar-brand span {
  color: var(--primary);
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.navbar-nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.navbar-nav a:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.navbar-nav a.active {
  color: var(--primary);
  background: rgba(37, 99, 235, 0.1);
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.navbar-user {
  font-size: 14px;
  color: var(--text-secondary);
}

.navbar-user strong {
  color: var(--text-primary);
  font-weight: 600;
}

.navbar-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.navbar-hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all var(--transition-base);
}

.navbar-hamburger[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.navbar-hamburger[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.navbar-hamburger[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ============================================================
   4. Cards
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: border-color var(--transition-base);
}

.card:hover {
  border-color: var(--border-hover);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  color: var(--text-secondary);
}

/* ============================================================
   5. Stat Cards
   ============================================================ */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.stat-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.stat-number {
  font-family: var(--font-mono);
  font-size: 48px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-primary);
}

.stat-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-card.stat-primary .stat-number { color: var(--primary); }
.stat-card.stat-success .stat-number { color: var(--success); }
.stat-card.stat-danger .stat-number { color: var(--danger); }
.stat-card.stat-warning .stat-number { color: var(--warning); }
.stat-card.stat-accent .stat-number { color: var(--accent); }

/* ============================================================
   6. Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.4);
}

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

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

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

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

.btn-accent:hover:not(:disabled) {
  background: #FB923C;
  border-color: #FB923C;
}

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

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

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

.btn-danger:hover:not(:disabled) {
  background: #F87171;
  border-color: #F87171;
}

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

.btn-success:hover:not(:disabled) {
  background: #4ADE80;
  border-color: #4ADE80;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
}

.btn-icon {
  padding: 8px;
  width: 36px;
  height: 36px;
}

.btn-icon.btn-sm {
  width: 28px;
  height: 28px;
  padding: 4px;
}

/* ============================================================
   7. Forms
   ============================================================ */
.form-group {
  margin-bottom: 16px;
}

.label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.input,
.select,
.textarea {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-size: 16px;
  color: var(--text-primary);
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  appearance: none;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

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

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
  cursor: pointer;
}

.textarea {
  min-height: 100px;
  resize: vertical;
}

.input-error {
  border-color: var(--danger);
}

.input-error:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

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

.checkbox-label,
.radio-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
}

.checkbox-label input,
.radio-label input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ============================================================
   8. Tables
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: var(--bg-elevated);
}

th {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  text-align: left;
  white-space: nowrap;
  user-select: none;
}

th.sortable {
  cursor: pointer;
  transition: color var(--transition-fast);
}

th.sortable:hover {
  color: var(--text-primary);
}

th.sortable::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 6px;
  vertical-align: middle;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid var(--text-muted);
  opacity: 0.4;
  transition: opacity var(--transition-fast);
}

th.sortable:hover::after {
  opacity: 0.8;
}

th.sort-asc::after {
  border-top: none;
  border-bottom: 4px solid var(--primary);
  opacity: 1;
}

th.sort-desc::after {
  border-top: 4px solid var(--primary);
  opacity: 1;
}

td {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-primary);
  vertical-align: middle;
}

tr:hover td {
  background: var(--bg-elevated);
}

td.mono {
  font-family: var(--font-mono);
}

.table-empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ============================================================
   9. Badges
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 9999px;
  white-space: nowrap;
}

.badge-success {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

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

.badge-info {
  background: rgba(14, 165, 233, 0.15);
  color: var(--info);
}

.badge-primary {
  background: rgba(37, 99, 235, 0.15);
  color: var(--primary);
}

.badge-secondary {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-secondary);
}

/* ============================================================
   10. Dot Indicators (document status)
   ============================================================ */
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-ok {
  background: var(--success);
  box-shadow: 0 0 4px rgba(34, 197, 94, 0.4);
}

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

.dot-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ============================================================
   11. Confidence Bar
   ============================================================ */
.confidence-bar {
  height: 8px;
  background: var(--bg-base);
  border-radius: 9999px;
  overflow: hidden;
  width: 100%;
}

.confidence-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width var(--transition-base);
}

.confidence-high {
  background: var(--success);
}

.confidence-medium {
  background: var(--warning);
}

.confidence-low {
  background: var(--danger);
}

.confidence-label {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  margin-top: 4px;
}

.confidence-label.confidence-high { color: var(--success); }
.confidence-label.confidence-medium { color: var(--warning); }
.confidence-label.confidence-low { color: var(--danger); }

/* ============================================================
   12. Modals
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
}

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

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 20px;
}

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

.modal-close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.4);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.modal-lg {
  max-width: 720px;
}

/* ============================================================
   13. Alerts / Toast
   ============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border-left: 4px solid;
  font-size: 14px;
  line-height: 1.5;
}

.alert-success {
  background: rgba(34, 197, 94, 0.08);
  border-left-color: var(--success);
  color: var(--success);
}

.alert-danger {
  background: rgba(239, 68, 68, 0.08);
  border-left-color: var(--danger);
  color: var(--danger);
}

.alert-warning {
  background: rgba(245, 158, 11, 0.08);
  border-left-color: var(--warning);
  color: var(--warning);
}

.alert-info {
  background: rgba(14, 165, 233, 0.08);
  border-left-color: var(--info);
  color: var(--info);
}

/* Toast container */
.toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 400px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  border-left: 4px solid;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 200ms ease-out;
}

.toast-success {
  background: var(--bg-elevated);
  border-left-color: var(--success);
  color: var(--success);
}

.toast-danger {
  background: var(--bg-elevated);
  border-left-color: var(--danger);
  color: var(--danger);
}

.toast-warning {
  background: var(--bg-elevated);
  border-left-color: var(--warning);
  color: var(--warning);
}

.toast-info {
  background: var(--bg-elevated);
  border-left-color: var(--info);
  color: var(--info);
}

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

/* ============================================================
   14. Upload / Dropzone
   ============================================================ */
.dropzone {
  border: 2px dashed var(--border-hover);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  transition: all var(--transition-base);
  cursor: pointer;
}

.dropzone:hover {
  border-color: var(--text-muted);
  background: rgba(255, 255, 255, 0.02);
}

.dropzone-active {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.05);
}

.dropzone-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  color: var(--text-muted);
}

.dropzone-text {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.dropzone-hint {
  font-size: 13px;
  color: var(--text-muted);
}

/* ============================================================
   15. Layout Utilities
   ============================================================ */
.container {
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 24px;
  padding-right: 24px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

.flex {
  display: flex;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-wrap {
  flex-wrap: wrap;
}

.items-center {
  align-items: center;
}

.gap-xs { gap: 4px; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }
.gap-xl { gap: 32px; }

.mt-xs { margin-top: 4px; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mt-xl { margin-top: 32px; }

.mb-xs { margin-bottom: 4px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 24px; }

.ml-auto { margin-left: auto; }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-lg { font-size: 18px; }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }

.hidden { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.w-full { width: 100%; }

/* ============================================================
   16. Page Layout
   ============================================================ */
.page-content {
  padding-top: 32px;
  padding-bottom: 48px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 32px;
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ============================================================
   17. Search Bar
   ============================================================ */
.search-bar {
  position: relative;
  max-width: 400px;
  width: 100%;
}

.search-bar .input {
  padding-left: 40px;
}

.search-bar-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

/* ============================================================
   18. Pagination
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 24px;
}

.pagination-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 4px 12px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.pagination-btn.active {
  color: #FFFFFF;
  background: var(--primary);
  border-color: var(--primary);
}

.pagination-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.pagination-info {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: 12px;
}

/* ============================================================
   19. Loading States
   ============================================================ */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

.spinner-lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

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

.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-card) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  padding: 64px 24px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ============================================================
   20. Tabs
   ============================================================ */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: -1px;
}

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

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.4);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

/* ============================================================
   21. Divider
   ============================================================ */
.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

/* ============================================================
   22. Responsive
   ============================================================ */
@media (max-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  /* Navigation */
  .navbar-hamburger {
    display: flex;
  }

  .navbar-nav {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--bg-base);
    border-bottom: 1px solid var(--border);
    padding: 8px;
    gap: 0;
  }

  .navbar-nav.open {
    display: flex;
  }

  .navbar-nav a {
    padding: 12px 16px;
    border-radius: var(--radius-md);
  }

  .navbar-right {
    gap: 8px;
  }

  .navbar-user span {
    display: none;
  }

  /* Grids */
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  /* Page layout */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-title {
    font-size: 22px;
  }

  /* Stat cards */
  .stat-number {
    font-size: 36px;
  }

  /* Forms */
  .form-row {
    grid-template-columns: 1fr;
  }

  /* Modals */
  .modal-overlay {
    padding: 16px;
    align-items: flex-end;
  }

  .modal {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 85vh;
  }

  /* Tables — card layout */
  .table-responsive-cards thead {
    display: none;
  }

  .table-responsive-cards tbody tr {
    display: block;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    background: var(--bg-card);
  }

  .table-responsive-cards tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border: none;
    font-size: 13px;
  }

  .table-responsive-cards tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    margin-right: 16px;
  }

  .table-responsive-cards tbody td:first-child {
    padding-top: 0;
  }

  .table-responsive-cards tbody td:last-child {
    padding-bottom: 0;
  }

  /* Container */
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Toast */
  .toast-container {
    right: 16px;
    left: 16px;
    max-width: none;
  }

  /* Dropzone */
  .dropzone {
    padding: 32px 16px;
  }

  /* Cards */
  .card {
    padding: 16px;
  }

  .stat-card {
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .page-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .page-actions .btn {
    flex: 1;
    min-width: 0;
  }

  .pagination {
    flex-wrap: wrap;
  }
}

/* ============================================================
   23. Accessibility
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* Remove default focus ring for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .spinner {
    animation: none;
    border-top-color: var(--primary);
    opacity: 0.6;
  }

  .skeleton {
    animation: none;
    background: var(--bg-elevated);
  }
}

/* ============================================================
   24. Print
   ============================================================ */
@media print {
  body {
    background: white;
    color: black;
  }

  .navbar,
  .toast-container,
  .page-actions,
  .btn {
    display: none !important;
  }

  .card,
  .stat-card {
    border: 1px solid #ccc;
    background: white;
  }

  .table-wrapper {
    border: 1px solid #ccc;
  }

  td, th {
    border: 1px solid #ccc;
  }
}
