/* ===================================================
   ระบบรายงานมาตรฐาน DLTV — Global Design System
   Responsive: Mobile-first, all screen sizes
   =================================================== */

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

/* ── CSS Variables ───────────────────────────────── */
:root {
  /* Colors */
  --clr-bg-deep:      #070b14;
  --clr-bg-base:      #0d1322;
  --clr-bg-surface:   #111827;
  --clr-bg-card:      rgba(255,255,255,0.04);
  --clr-bg-hover:     rgba(255,255,255,0.07);
  --clr-border:       rgba(255,255,255,0.08);
  --clr-border-focus: rgba(124,58,237,0.6);
  --clr-primary:      #7c3aed;
  --clr-primary-lt:   #a78bfa;
  --clr-primary-gd:   linear-gradient(135deg,#7c3aed,#a78bfa);
  --clr-success:      #10b981;
  --clr-warning:      #f59e0b;
  --clr-danger:       #ef4444;
  --clr-info:         #3b82f6;
  --clr-text-primary:   #f1f5f9;
  --clr-text-secondary: #94a3b8;
  --clr-text-muted:     #475569;

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(0,0,0,.4);
  --shadow-md:   0 4px 16px rgba(0,0,0,.5);
  --shadow-lg:   0 8px 40px rgba(0,0,0,.6);
  --shadow-glow: 0 0 32px rgba(124,58,237,.25);

  /* Fluid Spacing */
  --space-xs:  clamp(3px,  0.5vw,  4px);
  --space-sm:  clamp(6px,  1vw,    8px);
  --space-md:  clamp(12px, 2vw,    16px);
  --space-lg:  clamp(16px, 3vw,    24px);
  --space-xl:  clamp(20px, 4vw,    32px);
  --space-2xl: clamp(28px, 5vw,    48px);

  /* Radius */
  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  20px;
  --radius-full: 9999px;

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

  /* Layout */
  --sidebar-w:        260px;
  --topbar-h:         64px;
  --content-max-w:    1400px;
  --touch-target:     44px;
}

/* ── Reset / Base ────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: 'Sarabun','Inter',system-ui,-apple-system,sans-serif;
  background: var(--clr-bg-deep);
  color: var(--clr-text-primary);
  line-height: 1.65;
  min-height: 100vh;
  font-size: clamp(14px, 1.8vw, 15px);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

a { color: var(--clr-primary-lt); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
ul { list-style: none; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* Focus visible for accessibility */
:focus-visible {
  outline: 2px solid var(--clr-primary-lt);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ════════════════════════════════════════════════════
   AUTH PAGES
   ════════════════════════════════════════════════════ */

.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(124,58,237,.18) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(99,102,241,.14) 0%, transparent 60%),
    var(--clr-bg-deep);
  padding: var(--space-md);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--clr-bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl) var(--space-xl);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  animation: slideUp .35s var(--ease);
}

.auth-logo {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.auth-logo .logo-icon {
  width: clamp(56px, 12vw, 72px);
  height: clamp(56px, 12vw, 72px);
  border-radius: var(--radius-lg);
  background: var(--clr-primary-gd);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.5rem, 4vw, 2rem);
  margin-bottom: var(--space-md);
  box-shadow: 0 8px 32px rgba(124,58,237,.4);
  animation: pulseGlow 3s ease-in-out infinite;
}

.auth-logo h1 {
  font-size: clamp(1.1rem, 3.5vw, 1.35rem);
  font-weight: 700;
  color: var(--clr-text-primary);
  line-height: 1.3;
}

.auth-logo p {
  font-size: clamp(.78rem, 2vw, .85rem);
  color: var(--clr-text-secondary);
  margin-top: 4px;
}

/* ════════════════════════════════════════════════════
   APP LAYOUT (Dashboard)
   ════════════════════════════════════════════════════ */

.app-layout {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ── Sidebar ─────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--clr-bg-surface);
  border-right: 1px solid var(--clr-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  height: 100dvh;
  z-index: 200;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  padding: var(--space-lg) var(--space-md);
  border-bottom: 1px solid var(--clr-border);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sidebar-brand .brand-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: var(--radius-md);
  background: var(--clr-primary-gd);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 4px 16px rgba(124,58,237,.35);
}

.sidebar-brand .brand-text h2 {
  font-size: .9rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.sidebar-brand .brand-text span {
  font-size: .7rem;
  color: var(--clr-text-secondary);
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-sm) var(--space-xs);
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-section-label {
  font-size: .68rem;
  font-weight: 700;
  color: var(--clr-text-muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: var(--space-md) var(--space-md) var(--space-xs);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px var(--space-md);
  border-radius: var(--radius-md);
  color: var(--clr-text-secondary);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  margin-bottom: 2px;
  min-height: var(--touch-target);
}

.nav-item:hover  { background: var(--clr-bg-hover); color: var(--clr-text-primary); text-decoration: none; }
.nav-item.active { background: rgba(124,58,237,.15); color: var(--clr-primary-lt); border: 1px solid rgba(124,58,237,.2); }

.nav-item .nav-icon { width: 20px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }

.sidebar-footer {
  padding: var(--space-sm) var(--space-xs) var(--space-md);
  border-top: 1px solid var(--clr-border);
  flex-shrink: 0;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px var(--space-md);
  border-radius: var(--radius-md);
  background: var(--clr-bg-hover);
  cursor: pointer;
  transition: background var(--transition);
  min-height: var(--touch-target);
}
.user-pill:hover { background: rgba(255,255,255,.1); }

.user-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: var(--radius-full);
  background: var(--clr-primary-gd);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .82rem;
  font-weight: 700;
  color: #fff;
}

.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: .85rem;
  font-weight: 600;
  color: var(--clr-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role { font-size: .7rem; color: var(--clr-text-secondary); }

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 190;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; animation: fadeIn .2s var(--ease); }

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

/* ── Topbar ──────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: 0 var(--space-lg);
  height: var(--topbar-h);
  background: var(--clr-bg-surface);
  border-bottom: 1px solid var(--clr-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left { display: flex; align-items: center; gap: var(--space-sm); min-width: 0; }

.topbar-title { min-width: 0; }
.topbar-title h2 {
  font-size: clamp(.9rem, 2.5vw, 1.05rem);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-title p {
  font-size: clamp(.72rem, 1.8vw, .8rem);
  color: var(--clr-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions { display: flex; gap: var(--space-xs); align-items: center; flex-shrink: 0; }

/* ── Page Body ───────────────────────────────────── */
.page-body {
  flex: 1;
  padding: var(--space-lg);
  max-width: var(--content-max-w);
  width: 100%;
}

/* ── Hamburger ───────────────────────────────────── */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--clr-text-primary);
  border-radius: 2px;
  transition: all var(--transition);
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ════════════════════════════════════════════════════
   FORMS
   ════════════════════════════════════════════════════ */

.form-group { margin-bottom: var(--space-lg); }

.form-group label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--clr-text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 11px 14px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  color: var(--clr-text-primary);
  font-family: inherit;
  font-size: .95rem;
  transition: all var(--transition);
  outline: none;
  min-height: var(--touch-target);
}

.form-control::placeholder { color: var(--clr-text-muted); }
.form-control:focus {
  border-color: var(--clr-border-focus);
  background: rgba(124,58,237,.07);
  box-shadow: 0 0 0 3px rgba(124,58,237,.15);
}
.form-control:disabled { opacity: .5; cursor: not-allowed; }

.input-group { position: relative; }
.input-group .input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--clr-text-muted);
  pointer-events: none;
  font-size: 1rem;
  line-height: 1;
}
.input-group .form-control { padding-left: 38px; }
.input-group .toggle-password {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--clr-text-muted);
  cursor: pointer;
  font-size: .95rem;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  min-width: 32px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition);
}
.input-group .toggle-password:hover { color: var(--clr-primary-lt); }

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

/* ════════════════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: none;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  min-height: var(--touch-target);
  user-select: none;
  -webkit-user-select: none;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-full { width: 100%; }

.btn-primary {
  background: var(--clr-primary-gd);
  color: #fff;
  box-shadow: 0 4px 16px rgba(124,58,237,.35);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(124,58,237,.45); }
.btn-primary:active:not(:disabled) { transform: none; }

.btn-secondary {
  background: rgba(255,255,255,.07);
  border: 1px solid var(--clr-border);
  color: var(--clr-text-primary);
}
.btn-secondary:hover:not(:disabled) { background: rgba(255,255,255,.12); }

.btn-danger {
  background: rgba(239,68,68,.15);
  border: 1px solid rgba(239,68,68,.3);
  color: #ef4444;
}
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,.25); }

.btn-success {
  background: rgba(16,185,129,.15);
  border: 1px solid rgba(16,185,129,.3);
  color: #10b981;
}

.btn-sm {
  padding: 8px 14px;
  font-size: .82rem;
  min-height: 36px;
}

.btn-icon {
  padding: 8px;
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  border-radius: var(--radius-md);
}

/* ════════════════════════════════════════════════════
   CARDS
   ════════════════════════════════════════════════════ */

.card {
  background: var(--clr-bg-card);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--clr-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.card-header h3 { font-size: clamp(.9rem, 2.5vw, 1rem); font-weight: 700; }
.card-body { padding: var(--space-md) var(--space-lg); }

/* ── Stat Cards ──────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.stat-card {
  background: var(--clr-bg-card);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  transition: all var(--transition);
}
.stat-card:hover { border-color: rgba(124,58,237,.3); transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-icon {
  width: clamp(44px, 8vw, 52px);
  height: clamp(44px, 8vw, 52px);
  min-width: clamp(44px, 8vw, 52px);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.2rem, 3vw, 1.4rem);
}

.stat-icon.purple { background: rgba(124,58,237,.15); }
.stat-icon.green  { background: rgba(16,185,129,.15); }
.stat-icon.blue   { background: rgba(59,130,246,.15); }
.stat-icon.amber  { background: rgba(245,158,11,.15); }

.stat-value { font-size: clamp(1.3rem, 4vw, 1.6rem); font-weight: 800; line-height: 1; }
.stat-label { font-size: clamp(.72rem, 1.8vw, .8rem); color: var(--clr-text-secondary); margin-top: 4px; }

/* ════════════════════════════════════════════════════
   TABLE (Responsive)
   ════════════════════════════════════════════════════ */

.table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-md); }

table { width: 100%; border-collapse: collapse; min-width: 600px; }

thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  color: var(--clr-text-secondary);
  text-transform: uppercase;
  letter-spacing: .07em;
  background: rgba(255,255,255,.03);
  border-bottom: 1px solid var(--clr-border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--clr-border);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--clr-bg-hover); }

tbody td { padding: 12px 14px; font-size: .875rem; vertical-align: middle; }

/* Card-view table on small screens */
@media (max-width: 640px) {
  table, thead, tbody, tr, th, td { display: block; }
  thead { display: none; }

  tbody tr {
    background: var(--clr-bg-card);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    padding: var(--space-md);
  }
  tbody tr:hover { background: var(--clr-bg-hover); }

  tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 0;
    border: none;
    font-size: .85rem;
    border-bottom: 1px solid rgba(255,255,255,.04);
  }
  tbody td:last-child { border-bottom: none; padding-top: var(--space-sm); }

  tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--clr-text-secondary);
    font-size: .75rem;
    flex-shrink: 0;
    margin-right: var(--space-sm);
  }
  /* Hide # column on mobile */
  tbody td[data-label="#"] { display: none; }

  .table-container { overflow-x: visible; }
  table { min-width: 0; }
}

/* ── Table Toolbar ───────────────────────────────── */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.search-box { flex: 1; min-width: 180px; }
.table-meta { font-size: .78rem; color: var(--clr-text-secondary); margin-bottom: var(--space-sm); }

/* ════════════════════════════════════════════════════
   BADGES
   ════════════════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-purple { background: rgba(124,58,237,.15); color: #a78bfa; border: 1px solid rgba(124,58,237,.25); }
.badge-green  { background: rgba(16,185,129,.12);  color: #34d399; border: 1px solid rgba(16,185,129,.25); }
.badge-red    { background: rgba(239,68,68,.12);   color: #f87171; border: 1px solid rgba(239,68,68,.25); }
.badge-blue   { background: rgba(59,130,246,.12);  color: #60a5fa; border: 1px solid rgba(59,130,246,.25); }
.badge-gray   { background: rgba(148,163,184,.1);  color: #94a3b8; border: 1px solid rgba(148,163,184,.2); }

/* ════════════════════════════════════════════════════
   MODAL
   ════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-md);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}

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

.modal {
  background: var(--clr-bg-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 500px;
  max-height: 92dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(.95) translateY(12px);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--clr-border);
  position: sticky;
  top: 0;
  background: var(--clr-bg-surface);
  z-index: 10;
}
.modal-header h3 { font-size: clamp(.95rem, 2.5vw, 1.05rem); font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  color: var(--clr-text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--clr-bg-hover); color: var(--clr-text-primary); }

.modal-body { padding: var(--space-lg); }
.modal-footer {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  flex-wrap: wrap;
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--clr-border);
  position: sticky;
  bottom: 0;
  background: var(--clr-bg-surface);
}

/* ════════════════════════════════════════════════════
   TOAST
   ════════════════════════════════════════════════════ */

.toast-container {
  position: fixed;
  top: var(--space-md);
  right: var(--space-md);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  pointer-events: none;
  max-width: calc(100vw - 2 * var(--space-md));
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 11px var(--space-md);
  border-radius: var(--radius-md);
  font-size: .86rem;
  font-weight: 500;
  min-width: 240px;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: toastIn .3s var(--ease);
  border: 1px solid transparent;
  word-break: break-word;
}

.toast.success { background: rgba(16,185,129,.15);  border-color: rgba(16,185,129,.3);  color: #34d399; }
.toast.error   { background: rgba(239,68,68,.15);   border-color: rgba(239,68,68,.3);   color: #f87171; }
.toast.info    { background: rgba(59,130,246,.15);  border-color: rgba(59,130,246,.3);  color: #60a5fa; }
.toast.warning { background: rgba(245,158,11,.15);  border-color: rgba(245,158,11,.3);  color: #fbbf24; }

.toast-icon { font-size: 1rem; flex-shrink: 0; }
.toast-msg  { flex: 1; }
.toast-close {
  background: none;
  border: none;
  color: inherit;
  opacity: .6;
  cursor: pointer;
  font-size: .9rem;
  min-width: 24px;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ════════════════════════════════════════════════════
   PAGINATION
   ════════════════════════════════════════════════════ */

.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  justify-content: center;
  flex-wrap: wrap;
  padding: var(--space-md) 0 0;
}

.page-btn {
  min-width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--clr-border);
  background: var(--clr-bg-card);
  color: var(--clr-text-secondary);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.page-btn:hover:not(:disabled) { background: var(--clr-bg-hover); color: var(--clr-text-primary); }
.page-btn.active { background: var(--clr-primary); border-color: var(--clr-primary); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ════════════════════════════════════════════════════
   COMPONENTS
   ════════════════════════════════════════════════════ */

/* Alerts */
.alert {
  padding: 11px var(--space-md);
  border-radius: var(--radius-md);
  font-size: .875rem;
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}
.alert-error   { background: rgba(239,68,68,.1);  border: 1px solid rgba(239,68,68,.25);  color: #fca5a5; }
.alert-success { background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.25); color: #6ee7b7; }

/* Divider */
.divider {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  color: var(--clr-text-muted);
  font-size: .8rem;
  margin: var(--space-md) 0;
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--clr-border); }

/* Empty state */
.empty-state { text-align: center; padding: var(--space-2xl) var(--space-lg); color: var(--clr-text-muted); }
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: var(--space-md); }
.empty-state h4 { color: var(--clr-text-secondary); margin-bottom: var(--space-xs); }

/* Spinner */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

/* Profile */
.profile-card {
  background: var(--clr-bg-card);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  text-align: center;
}

.profile-avatar {
  width: clamp(68px, 12vw, 88px);
  height: clamp(68px, 12vw, 88px);
  border-radius: var(--radius-full);
  background: var(--clr-primary-gd);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.6rem, 4vw, 2rem);
  font-weight: 700;
  color: #fff;
  margin: 0 auto var(--space-md);
  box-shadow: 0 8px 24px rgba(124,58,237,.35);
}

/* Utilities */
.text-muted   { color: var(--clr-text-secondary); }
.text-small   { font-size: .82rem; }
.flex         { display: flex; }
.items-center { align-items: center; }
.gap-sm       { gap: var(--space-sm); }
.mt-sm        { margin-top: var(--space-sm); }
.mt-md        { margin-top: var(--space-md); }
.mb-md        { margin-bottom: var(--space-md); }
.w-full       { width: 100%; }

/* Actions cell */
.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }

/* ════════════════════════════════════════════════════
   ANIMATIONS
   ════════════════════════════════════════════════════ */

@keyframes slideUp    { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:translateY(0); } }
@keyframes pulseGlow  { 0%,100% { box-shadow:0 8px 32px rgba(124,58,237,.4); } 50% { box-shadow:0 8px 48px rgba(124,58,237,.7); } }
@keyframes spin       { to { transform:rotate(360deg); } }
@keyframes toastIn    { from { opacity:0; transform:translateX(16px); } to { opacity:1; transform:translateX(0); } }
@keyframes fadeIn     { from { opacity:0; } to { opacity:1; } }

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ════════════════════════════════════════════════════ */

/* ── Large Desktop ≥ 1280px ─── */
@media (min-width: 1280px) {
  .page-body { padding: var(--space-xl) var(--space-2xl); }
}

/* ── Tablet / Small Desktop < 1024px ─── */
@media (max-width: 1023px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .hamburger { display: flex; }
}

/* ── Tablet < 768px ─── */
@media (max-width: 767px) {
  .form-row { grid-template-columns: 1fr; gap: var(--space-sm); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .page-body { padding: var(--space-md); }
  .card-body { padding: var(--space-md); }
  .card-header { padding: var(--space-md); }

  .table-toolbar { flex-direction: column; align-items: stretch; }
  .search-box { max-width: 100%; }

  /* Filter dropdowns in row */
  .filter-row {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
  }
  .filter-row select { flex: 1; min-width: 120px; }

  .topbar { padding: 0 var(--space-md); }
  .topbar-title p { display: none; }

  /* Dashboard profile layout */
  .profile-layout {
    grid-template-columns: 1fr !important;
  }
}

/* ── Mobile < 480px ─── */
@media (max-width: 479px) {
  :root { --sidebar-w: 240px; }

  .stat-grid { grid-template-columns: 1fr 1fr; gap: var(--space-sm); }
  .auth-card { padding: var(--space-xl) var(--space-md); border-radius: var(--radius-lg); }
  .btn { font-size: .85rem; padding: 10px 16px; }
  .btn-sm { padding: 7px 12px; font-size: .8rem; }

  /* Stack modal footer buttons */
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; }
  .modal-body { padding: var(--space-md); }
  .modal-header { padding: var(--space-sm) var(--space-md); }

  /* Full-screen modal on tiny screens */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { border-radius: var(--radius-xl) var(--radius-xl) 0 0; max-height: 95dvh; max-width: 100%; }
}

/* ── Very small < 360px ─── */
@media (max-width: 359px) {
  .stat-grid { grid-template-columns: 1fr; }
  .topbar-actions .btn span { display: none; }
  .topbar-actions .btn::before { content: '🚪'; }
}

/* ── Print ───────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .toast-container, .btn, .pagination { display: none !important; }
  .main-content { margin: 0; }
  body { background: white; color: black; }
  .card { border: 1px solid #ddd; }
}

/* ── High contrast (accessibility) ─── */
@media (prefers-contrast: high) {
  :root {
    --clr-border: rgba(255,255,255,0.3);
    --clr-text-secondary: #cbd5e1;
  }
}
