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

/* ═══════════════════════════════════════════════════════════════════════════
   BYOD360 Design System — v2.0
   Palette: Black · White · Red  |  Mobile-first
═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* Brand */
  --red:          #C0392B;
  --red-hover:    #A93226;
  --red-light:    #FEF2F2;
  --red-mid:      #FECACA;

  /* Neutrals */
  --black:        #0F0F0F;
  --dark:         #1A1A1A;
  --dark-2:       #242424;
  --dark-3:       #2E2E2E;
  --gray-700:     #374151;
  --gray-500:     #6B7280;
  --gray-400:     #9CA3AF;
  --gray-200:     #E5E7EB;
  --gray-100:     #F3F4F6;
  --gray-50:      #F9FAFB;
  --white:        #FFFFFF;

  /* Semantic */
  --success:      #16A34A;
  --success-light:#F0FDF4;
  --warning:      #D97706;
  --warning-light:#FFFBEB;
  --info:         #2563EB;
  --info-light:   #EFF6FF;

  /* Layout */
  --sidebar-w:    256px;
  --header-h:     56px;
  --radius-sm:    4px;
  --radius:       6px;
  --radius-lg:    10px;
  --radius-xl:    16px;

  /* Surface */
  --bg:           #F3F4F6;
  --surface:      #FFFFFF;
  --surface-2:    #F9FAFB;
  --border:       #E5E7EB;
  --border-focus: #C0392B;

  /* Shadow */
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:       0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-md:    0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --shadow-lg:    0 20px 25px -5px rgba(0,0,0,0.10), 0 10px 10px -5px rgba(0,0,0,0.04);

  /* Typography */
  --font:         'Inter', 'Segoe UI', -apple-system, sans-serif;
  --transition:   0.15s ease;
}

/* ── Dark Mode ─────────────────────────────────────────────────────────── */
.dark {
  /* Backgrounds */
  --bg:        #111111;
  --surface:   #1C1C1E;
  --surface-2: #2C2C2E;
  --border:    #3A3A3C;

  /* Text — in dark mode, "dark" text becomes light */
  --text-primary:  #F2F2F7;
  --text-secondary:#AEAEB2;

  /* Grays inverted for dark */
  --gray-700:  #E5E5EA;
  --gray-500:  #AEAEB2;
  --gray-400:  #636366;
  --gray-200:  #3A3A3C;
  --gray-100:  #2C2C2E;
  --gray-50:   #1C1C1E;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow:    0 4px 6px rgba(0,0,0,0.4);
  --shadow-md: 0 10px 15px rgba(0,0,0,0.5);
}

/* ── Dark mode explicit overrides ───────────────────────────────────────── */
.dark body { color: #F2F2F7; }
.dark .topbar { background: #1C1C1E; border-color: #3A3A3C; }
.dark .topbar-title { color: #F2F2F7; }
.dark .topbar-btn { color: #AEAEB2; }
.dark .topbar-btn:hover { background: #2C2C2E; color: #F2F2F7; }
.dark .card { background: #1C1C1E; border-color: #3A3A3C; }
.dark .card-header { border-color: #3A3A3C; }
.dark .card-header h3 { color: #F2F2F7; }
.dark .card-footer { background: #2C2C2E; border-color: #3A3A3C; }
.dark .card-body { background: #1C1C1E; }
.dark .kpi { background: #1C1C1E; border-color: #3A3A3C; }
.dark .kpi-label { color: #AEAEB2; }
.dark .kpi-value { color: #F2F2F7; }
.dark .kpi.kpi-red .kpi-value    { color: var(--red); }
.dark .kpi.kpi-green .kpi-value  { color: #34C759; }
.dark .kpi.kpi-orange .kpi-value { color: #FF9F0A; }
.dark .kpi-sub { color: #AEAEB2; }
.dark .data-table thead th { background: #2C2C2E; color: #AEAEB2; border-color: #3A3A3C; }
.dark .data-table tbody tr { border-color: #3A3A3C; }
.dark .data-table tbody tr:hover { background: #2C2C2E; }
.dark .data-table tbody td { color: #F2F2F7; }
.dark .page-header-text h1 { color: #F2F2F7; }
.dark .page-header-text p  { color: #AEAEB2; }
.dark .form-control { background: #2C2C2E; border-color: #3A3A3C; color: #F2F2F7; }
.dark .form-control::placeholder { color: #636366; }
.dark .form-label { color: #E5E5EA; }
.dark .form-hint  { color: #AEAEB2; }
.dark .btn-outline { background: transparent; color: #E5E5EA; border-color: #3A3A3C; }
.dark .btn-outline:hover { background: #2C2C2E; }
.dark .btn-ghost  { color: #AEAEB2; }
.dark .btn-ghost:hover { background: #2C2C2E; color: #F2F2F7; }
.dark .btn-dark   { background: #F2F2F7; color: #111; border-color: #F2F2F7; }
.dark .btn-dark:hover { background: #E5E5EA; }
.dark .modal      { background: #1C1C1E; }
.dark .modal-header { border-color: #3A3A3C; }
.dark .modal-header h3 { color: #F2F2F7; }
.dark .modal-footer { background: #2C2C2E; border-color: #3A3A3C; }
.dark .modal-close { color: #AEAEB2; }
.dark .modal-close:hover { background: #2C2C2E; color: #F2F2F7; }
.dark .overlay    { background: rgba(0,0,0,0.7); }
.dark .panel      { background: #1C1C1E; border-color: #3A3A3C; }
.dark .panel-header { border-color: #3A3A3C; }
.dark .panel-footer { border-color: #3A3A3C; }
.dark .filter-select { background: #1C1C1E; color: #F2F2F7; border-color: #3A3A3C; }
.dark .search-wrap input { background: #1C1C1E; color: #F2F2F7; border-color: #3A3A3C; }
.dark .detail-row { border-color: #3A3A3C; }
.dark .detail-label { color: #AEAEB2; }
.dark .detail-value { color: #F2F2F7; }
.dark .detail-section-title { color: #AEAEB2; border-color: #3A3A3C; }
.dark .tabs { border-color: #3A3A3C; }
.dark .tab-btn { color: #AEAEB2; }
.dark .tab-btn.active { color: var(--red); border-bottom-color: var(--red); }
.dark .tab-btn:hover:not(.active) { color: #F2F2F7; }
.dark .empty h3 { color: #F2F2F7; }
.dark .tl-time { color: #636366; }
.dark .notif-drop { background: #1C1C1E; border-color: #3A3A3C; }
.dark .notif-header { border-color: #3A3A3C; color: #F2F2F7; }
.dark .notif-item { border-color: #3A3A3C; }
.dark .notif-item:hover { background: #2C2C2E; }
.dark .cookie-banner { background: #1C1C1E; border-top: 1px solid #3A3A3C; }
/* Sidebar always stays dark — never affected by dark mode toggle */
.sidebar { background: #0F0F0F !important; }

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--dark);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; }

/* ── Layout ────────────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; transition: margin var(--transition); }

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: #0F0F0F;
  position: fixed; top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 200;
  transition: transform var(--transition);
  overflow-y: auto;
}
.sidebar-brand {
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}
.sidebar-brand img { height: 24px; width: auto; }
.sidebar-brand .portal-label {
  font-size: 10px; font-weight: 600; letter-spacing: 1.4px;
  text-transform: uppercase; color: rgba(255,255,255,0.3);
  margin-top: 8px;
}
.sidebar-client-badge {
  margin: 0 12px 8px;
  background: rgba(192,57,43,0.15);
  border: 1px solid rgba(192,57,43,0.3);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 11px; color: rgba(255,255,255,0.7);
}
.sidebar-client-badge strong { display: block; color: #fff; font-size: 12px; margin-bottom: 1px; }

.nav-section { padding: 12px 0 4px; }
.nav-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: rgba(255,255,255,0.25);
  padding: 0 20px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,0.6);
  font-size: 13px; font-weight: 400;
  cursor: pointer; border: none; background: none;
  width: 100%; text-align: left;
  transition: background var(--transition), color var(--transition);
  position: relative;
  border-radius: 0;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.9); }
.nav-item.active {
  background: var(--red);
  color: #fff;
  font-weight: 500;
}
.nav-item .nav-badge {
  margin-left: auto; background: var(--red);
  color: #fff; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 10px; min-width: 18px; text-align: center;
}
.nav-item.active .nav-badge { background: rgba(255,255,255,0.25); }

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,0.07);
  padding: 12px 16px;
  flex-shrink: 0;
}
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.s-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--red); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.s-name  { font-size: 12.5px; font-weight: 600; color: #fff; }
.s-role  { font-size: 11px; color: rgba(255,255,255,0.35); }
.s-logout {
  margin-left: auto; background: none; border: none;
  color: rgba(255,255,255,0.35); cursor: pointer; padding: 4px;
  transition: color var(--transition); font-size: 14px;
}
.s-logout:hover { color: var(--red); }

/* ── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 20px; gap: 12px;
  position: sticky; top: 0; z-index: 100;
}
.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); border: none; background: none;
  color: var(--gray-500); cursor: pointer;
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.topbar-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.topbar-btn:hover { background: var(--gray-100); color: var(--dark); }
.topbar-btn .dot {
  position: absolute; top: 5px; right: 5px;
  width: 7px; height: 7px; background: var(--red);
  border-radius: 50%; border: 2px solid var(--surface);
}
.hamburger { display: none; }

/* ── Page ───────────────────────────────────────────────────────────────── */
.page { padding: 24px; flex: 1; }
.page-header { margin-bottom: 20px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-header-text h1 { font-size: 20px; font-weight: 700; }
.page-header-text p  { font-size: 13px; color: var(--gray-500); margin-top: 2px; }
.page-header-actions { margin-left: auto; display: flex; gap: 8px; }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.card-header h3 { font-size: 13.5px; font-weight: 600; }
.card-actions { margin-left: auto; display: flex; gap: 6px; }
.card-body { padding: 18px; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ── KPI Grid ───────────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 20px; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  position: relative; overflow: hidden;
}
.kpi::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 3px; border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.kpi.kpi-red::after    { background: var(--red); }
.kpi.kpi-black::after  { background: var(--dark); }
.kpi.kpi-green::after  { background: var(--success); }
.kpi.kpi-orange::after { background: var(--warning); }
.kpi-label { font-size: 11px; font-weight: 600; letter-spacing: 0.3px; text-transform: uppercase; color: var(--gray-500); margin-bottom: 6px; }
.kpi-value { font-size: 30px; font-weight: 800; line-height: 1; color: var(--dark); }
.kpi-sub   { font-size: 11.5px; color: var(--gray-500); margin-top: 4px; }
.kpi.kpi-red .kpi-value    { color: var(--red); }
.kpi.kpi-green .kpi-value  { color: var(--success); }
.kpi.kpi-orange .kpi-value { color: var(--warning); }

/* ── Table ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th {
  background: var(--surface-2);
  padding: 10px 14px;
  text-align: left; white-space: nowrap;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--gray-500);
  border-bottom: 1px solid var(--border);
}
.data-table tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody td { padding: 11px 14px; vertical-align: middle; color: var(--dark); }

/* ── Status badges ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 100px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge::before { content: '●'; font-size: 7px; }
.badge-open         { background: var(--info-light);    color: var(--info); }
.badge-in_review    { background: var(--warning-light); color: var(--warning); }
.badge-in_progress  { background: #EFF6FF; color: #1D4ED8; }
.badge-pending_client { background: #FDF4FF; color: #7C3AED; }
.badge-resolved     { background: var(--success-light); color: var(--success); }
.badge-closed       { background: var(--gray-100); color: var(--gray-500); }
.badge-archived     { background: var(--gray-100); color: var(--gray-400); }
.badge-critical     { background: var(--red-light);    color: var(--red); }
.badge-attention    { background: var(--warning-light); color: var(--warning); }
.badge-normal       { background: var(--success-light); color: var(--success); }
.badge-paid         { background: var(--success-light); color: var(--success); }
.badge-sent         { background: var(--info-light);    color: var(--info); }
.badge-overdue      { background: var(--red-light);    color: var(--red); }
.badge-draft        { background: var(--gray-100);     color: var(--gray-500); }

.badge-priority-urgent { background: var(--red-light);    color: var(--red); font-weight: 700; }
.badge-priority-high   { background: var(--warning-light); color: var(--warning); }
.badge-priority-normal { background: var(--gray-100);     color: var(--gray-700); }
.badge-priority-low    { background: var(--gray-50);      color: var(--gray-400); }

/* ── Progress ───────────────────────────────────────────────────────────── */
.progress { display: flex; align-items: center; gap: 8px; }
.progress-track { flex: 1; height: 5px; background: var(--gray-200); border-radius: 3px; overflow: hidden; min-width: 50px; }
.progress-fill  { height: 100%; border-radius: 3px; }
.progress-fill.status-critical  { background: var(--red); }
.progress-fill.status-attention { background: var(--warning); }
.progress-fill.status-normal    { background: var(--success); }
.progress-label { font-size: 12px; font-weight: 600; white-space: nowrap; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  cursor: pointer; border: 1px solid transparent;
  transition: all var(--transition); white-space: nowrap;
  text-decoration: none; line-height: 1;
}
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; flex-shrink: 0; }
.btn-primary   { background: var(--red);  color: #fff; border-color: var(--red); }
.btn-primary:hover   { background: var(--red-hover); border-color: var(--red-hover); }
.btn-dark      { background: var(--dark); color: #fff; border-color: var(--dark); }
.btn-dark:hover { background: var(--dark-2); }
.btn-outline   { background: transparent; color: var(--dark); border-color: var(--border); }
.btn-outline:hover { background: var(--gray-100); }
.btn-ghost     { background: transparent; color: var(--gray-500); border-color: transparent; }
.btn-ghost:hover { background: var(--gray-100); color: var(--dark); }
.btn-danger    { background: var(--red-light); color: var(--red); border-color: var(--red-mid); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-success   { background: var(--success-light); color: var(--success); border-color: #BBF7D0; }
.btn-sm        { padding: 5px 10px; font-size: 12px; }
.btn-lg        { padding: 11px 22px; font-size: 14.5px; }
.btn-icon      { padding: 7px; width: 32px; height: 32px; }
.btn:disabled  { opacity: 0.5; cursor: not-allowed; }
.btn-block     { width: 100%; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-group  { margin-bottom: 16px; }
.form-row    { display: grid; gap: 14px; }
.form-row-2  { grid-template-columns: 1fr 1fr; }
.form-row-3  { grid-template-columns: 1fr 1fr 1fr; }
.form-label  { display: block; font-size: 12px; font-weight: 600; color: var(--gray-700); margin-bottom: 5px; }
.form-hint   { font-size: 11px; color: var(--gray-500); margin-top: 4px; }
.form-control {
  width: 100%; padding: 9px 12px;
  background: var(--surface); color: var(--dark);
  border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 13.5px;
  font-family: var(--font);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(192,57,43,0.1);
}
.form-control::placeholder { color: var(--gray-400); }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control   { cursor: pointer; }
.form-control.error   { border-color: var(--red); }
.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius) 0 0 var(--radius); }
.input-group .btn  { border-radius: 0 var(--radius) var(--radius) 0; border-left: none; }

/* ── Modal ──────────────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; padding: 16px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(8px) scale(0.98);
  transition: transform 0.2s ease;
}
.overlay.open .modal { transform: none; }
.modal-lg { max-width: 700px; }
.modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.modal-header h3 { font-size: 15px; font-weight: 700; }
.modal-close { margin-left: auto; background: none; border: none; cursor: pointer; color: var(--gray-500); padding: 4px; border-radius: var(--radius); }
.modal-close svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }
.modal-close:hover { background: var(--gray-100); color: var(--dark); }
.modal-body   { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); border-radius: 0 0 var(--radius-xl) var(--radius-xl); }

/* ── Slide panel ────────────────────────────────────────────────────────── */
.panel {
  position: fixed; right: 0; top: 0; bottom: 0; width: 440px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
}
.panel.open { transform: translateX(0); }
.panel-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.panel-body   { flex: 1; overflow-y: auto; padding: 20px; }
.panel-footer { padding: 14px 20px; border-top: 1px solid var(--border); }
.panel-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 299; display: none; }
.panel-backdrop.open { display: block; }

/* ── Alerts / Toast ─────────────────────────────────────────────────────── */
.alert { padding: 11px 14px; border-radius: var(--radius); font-size: 13px; display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-error   { background: var(--red-light);    color: var(--red);    border-left: 3px solid var(--red); }
.alert-success { background: var(--success-light); color: var(--success); border-left: 3px solid var(--success); }
.alert-info    { background: var(--info-light);    color: var(--info);   border-left: 3px solid var(--info); }
.alert-warning { background: var(--warning-light); color: var(--warning); border-left: 3px solid var(--warning); }

.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--dark); color: #fff;
  padding: 11px 16px; border-radius: var(--radius-lg);
  font-size: 13px; box-shadow: var(--shadow-md);
  display: flex; align-items: center; gap: 10px;
  min-width: 240px; max-width: 340px;
  animation: toastIn 0.2s ease, toastOut 0.3s ease 3.5s forwards;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--info); }
@keyframes toastIn  { from { transform: translateX(20px); opacity: 0; } }
@keyframes toastOut { to   { transform: translateX(10px); opacity: 0; } }

/* ── Filter bar ─────────────────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.search-wrap { position: relative; flex: 1; min-width: 180px; }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; stroke: var(--gray-400); fill: none; stroke-width: 2; pointer-events: none; }
.search-wrap input { padding-left: 32px; width: 100%; height: 36px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; background: var(--surface); color: var(--dark); }
.search-wrap input:focus { outline: none; border-color: var(--red); }
.filter-select { height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--dark); font-size: 13px; cursor: pointer; }
.filter-select:focus { outline: none; border-color: var(--red); }

/* ── Empty state ────────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 48px 24px; color: var(--gray-500); }
.empty svg { width: 40px; height: 40px; stroke: var(--gray-400); fill: none; stroke-width: 1.5; margin: 0 auto 12px; }
.empty h3 { font-size: 15px; color: var(--dark); margin-bottom: 6px; }

/* ── Detail section ─────────────────────────────────────────────────────── */
.detail-section { margin-bottom: 20px; }
.detail-section-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--gray-500); padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.detail-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-size: 13px; border-bottom: 1px solid var(--border); }
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--gray-500); }
.detail-value { font-weight: 500; text-align: right; }

/* ── Timeline ───────────────────────────────────────────────────────────── */
.timeline { padding-left: 24px; position: relative; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 1px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 16px; font-size: 13px; }
.tl-item::before { content: ''; position: absolute; left: -21px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--red); }
.tl-time { font-size: 11px; color: var(--gray-400); margin-top: 2px; }

/* ── Notification bell ──────────────────────────────────────────────────── */
.notif-drop {
  position: absolute; right: 0; top: calc(100% + 8px);
  width: 340px; background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  z-index: 200; display: none;
}
.notif-drop.open { display: block; }
.notif-header { padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13px; display: flex; justify-content: space-between; }
.notif-item { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 12.5px; display: flex; gap: 10px; transition: background var(--transition); }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: var(--red-light); }
.notif-dot { width: 7px; height: 7px; background: var(--red); border-radius: 50%; flex-shrink: 0; margin-top: 5px; }

/* ── Dark mode toggle ───────────────────────────────────────────────────── */
.dark-toggle {
  width: 36px; height: 20px; background: var(--gray-200);
  border-radius: 10px; position: relative; cursor: pointer;
  border: none; transition: background var(--transition);
}
.dark-toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; background: #fff;
  border-radius: 50%; transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.dark .dark-toggle { background: var(--red); }
.dark .dark-toggle::after { transform: translateX(16px); }

/* ── Cookie banner ──────────────────────────────────────────────────────── */
.cookie-banner {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--dark); color: rgba(255,255,255,0.85);
  padding: 14px 20px; z-index: 800;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  font-size: 12.5px;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}
.cookie-banner.show { transform: translateY(0); }
.cookie-banner a { color: var(--red); text-decoration: underline; }

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 20px; gap: 0; }
.tab-btn {
  padding: 10px 16px; font-size: 13px; font-weight: 500;
  border: none; background: none; cursor: pointer; color: var(--gray-500);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn.active { color: var(--red); border-bottom-color: var(--red); }
.tab-btn:hover:not(.active) { color: var(--dark); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── FAB (Floating Action Button) ───────────────────────────────────────── */
.fab {
  position: fixed; bottom: 24px; right: 24px;
  width: 52px; height: 52px;
  background: var(--red); color: #fff;
  border-radius: 50%; border: none;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-md);
  cursor: pointer; z-index: 100;
  transition: transform var(--transition), box-shadow var(--transition);
}
.fab:hover { transform: scale(1.06); box-shadow: var(--shadow-lg); }
.fab svg { width: 22px; height: 22px; stroke: #fff; fill: none; stroke-width: 2.2; }

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ─── RESPONSIVE — Mobile first ─────────────────────────────────────────── */

/* Prevent horizontal scroll on ALL screens */
html, body {
  overflow-x: hidden;
  max-width: 100%;
}
* { max-width: 100%; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  /* Sidebar hidden off-screen left, slides in */
  .sidebar {
    transform: translateX(-100%);
    width: 260px;
    position: fixed;
    z-index: 300;
    transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
  }
  .sidebar.mobile-open { transform: translateX(0); }

  /* Backdrop overlay when sidebar open */
  #sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 299;
  }
  #sidebar-backdrop.open { display: block; }

  .main { margin-left: 0 !important; width: 100%; overflow-x: hidden; }
  .hamburger { display: flex !important; }
  .topbar { padding: 0 14px; }

  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
  .panel { width: 100%; }
  .page { padding: 12px; overflow-x: hidden; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-header-actions { margin-left: 0; width: 100%; }
  .modal { border-radius: var(--radius-lg); margin: 8px; width: calc(100% - 16px); }
  .modal-lg { max-width: 100%; }

  /* Tables — horizontal scroll within card */
  .card { overflow: hidden; }
  .data-table { min-width: 600px; }

  /* Footer responsive */
  footer { flex-direction: column; gap: 8px; padding: 14px; text-align: center; }
  footer > div { justify-content: center !important; flex-wrap: wrap; }

  /* Notification dropdown */
  .notif-drop { width: 300px; right: -60px; }

  /* Login page */
  .login-brand { display: none; }
  .login-form-wrap { padding: 24px 16px; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .search-wrap { min-width: 100%; }
  .filter-select { width: 100% !important; }
  .topbar-title { font-size: 13px; }
  .fab { bottom: 16px; right: 16px; width: 46px; height: 46px; }
  .notif-drop { width: 280px; right: -40px; }
}

