/* ═══════════════════════════════════════════════════════════════════════
   DNCP Monitor — Design System v2  |  Sidebar + Dark Mode
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── CSS Custom Properties (light) ──────────────────────────────────── */
:root {
  /* Sidebar */
  --sidebar-bg:          #0f172a;
  --sidebar-width:       240px;
  --sidebar-border:      rgba(255,255,255,.06);
  --sidebar-text:        #64748b;
  --sidebar-text-hover:  #cbd5e1;
  --sidebar-text-active: #f1f5f9;
  --sidebar-item-hover:  rgba(255,255,255,.05);
  --sidebar-item-active: rgba(59,130,246,.18);
  --sidebar-accent:      #3b82f6;

  /* Topbar */
  --topbar-bg:      #ffffff;
  --topbar-border:  #e2e8f0;
  --topbar-height:  56px;

  /* Page */
  --page-bg:        #f1f5f9;
  --surface:        #ffffff;
  --surface-2:      #f8fafc;
  --surface-hover:  #eff6ff;
  --border:         #e2e8f0;
  --border-focus:   #3b82f6;

  /* Typography */
  --text-1:   #0f172a;
  --text-2:   #475569;
  --text-3:   #94a3b8;

  /* Brand */
  --blue:          #2563eb;
  --blue-dark:     #1d4ed8;
  --blue-light:    #dbeafe;
  --blue-ring:     rgba(37,99,235,.2);
  --blue-subtle:   #eff6ff;

  /* Status */
  --status-open-fg:    #065f46; --status-open-bg:    #dcfce7; --status-open-dot:    #10b981;
  --status-award-fg:   #0c4a6e; --status-award-bg:   #e0f2fe; --status-award-dot:   #0ea5e9;
  --status-cancel-fg:  #7f1d1d; --status-cancel-bg:  #fee2e2; --status-cancel-dot:  #ef4444;
  --status-pending-fg: #78350f; --status-pending-bg: #fef3c7; --status-pending-dot: #f59e0b;
  --status-default-fg: #334155; --status-default-bg: #f1f5f9; --status-default-dot: #94a3b8;

  /* Shape */
  --radius-xs: 4px;  --radius-sm: 6px;  --radius: 10px;
  --radius-lg: 14px; --radius-xl: 20px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgb(15 23 42/.06);
  --shadow-sm: 0 2px 6px -1px rgb(15 23 42/.08), 0 1px 2px -1px rgb(15 23 42/.05);
  --shadow-md: 0 4px 14px -2px rgb(15 23 42/.1),  0 2px 4px  -2px rgb(15 23 42/.06);
  --shadow-lg: 0 10px 28px -4px rgb(15 23 42/.12), 0 4px 8px  -4px rgb(15 23 42/.08);
  --shadow-xl: 0 20px 48px -8px rgb(15 23 42/.16), 0 8px 16px -8px rgb(15 23 42/.1);

  /* Transitions */
  --t-fast: .1s ease;  --t-base: .18s ease;  --t-slow: .3s ease;
}

/* ─── Dark mode overrides ─────────────────────────────────────────────── */
[data-theme="dark"] {
  --topbar-bg:    #1e293b;
  --topbar-border: #334155;
  --page-bg:      #0f172a;
  --surface:      #1e293b;
  --surface-2:    #263348;
  --surface-hover:#1d3258;
  --border:       #334155;
  --border-focus: #60a5fa;
  --text-1:       #f1f5f9;
  --text-2:       #94a3b8;
  --text-3:       #475569;
  --blue-light:   #1e3a5f;
  --blue-subtle:  #1e3a5f;
  --blue-ring:    rgba(96,165,250,.25);
  --status-open-bg:    #064e3b; --status-open-fg:    #6ee7b7;
  --status-award-bg:   #0c4a6e; --status-award-fg:   #7dd3fc;
  --status-cancel-bg:  #7f1d1d; --status-cancel-fg:  #fca5a5;
  --status-pending-bg: #78350f; --status-pending-fg: #fcd34d;
  --status-default-bg: #334155; --status-default-fg: #94a3b8;
}

/* ─── Reset ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--page-bg);
  color: var(--text-1);
  font-size: .875rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  margin: 0;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #334155; }

/* ══════════════════════════════════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════════════════════════════════ */

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

/* ─── Sidebar ─────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  position: fixed;
  left: 0; top: 0;
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--t-slow);
  border-right: 1px solid var(--sidebar-border);
}

.sidebar-header {
  padding: 0;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  width: 100%;
}

.sidebar-brand-icon {
  width: 30px; height: 30px;
  background: var(--blue);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-brand-text {
  display: flex; flex-direction: column; overflow: hidden;
}

.sidebar-brand-name {
  font-size: .82rem;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: -.01em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand-org {
  font-size: .68rem;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  scrollbar-width: thin;
}

.sidebar-nav-section {
  margin-bottom: 4px;
}

.sidebar-nav-label {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: rgba(255,255,255,.25);
  padding: 12px 8px 4px;
  display: block;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text) !important;
  text-decoration: none !important;
  font-size: .81rem;
  font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast);
  margin-bottom: 1px;
}

.sidebar-nav-item:hover {
  background: var(--sidebar-item-hover);
  color: var(--sidebar-text-hover) !important;
}

.sidebar-nav-item.active {
  background: var(--sidebar-item-active);
  color: #60a5fa !important;
}

.sidebar-nav-item i {
  font-size: .88rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  opacity: .7;
}

.sidebar-nav-item.active i { opacity: 1; }

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  position: relative;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t-fast);
}

.sidebar-user:hover { background: var(--sidebar-item-hover); }

.sidebar-user-avatar {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar-user-name {
  font-size: .78rem;
  font-weight: 600;
  color: #cbd5e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.sidebar-user-role {
  font-size: .62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.sidebar-user-more {
  color: var(--sidebar-text);
  font-size: .78rem;
  flex-shrink: 0;
}

.sidebar-user-menu {
  bottom: 100%;
  top: auto !important;
  left: 8px !important;
  right: 8px !important;
  width: auto !important;
  min-width: 0;
  transform: none !important;
  margin-bottom: 4px;
}

/* ─── Main wrapper ─────────────────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: calc(100vw - var(--sidebar-width));
}

/* ─── Topbar ───────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  box-shadow: var(--shadow-xs);
  flex-shrink: 0;
}

.topbar-toggle {
  background: transparent;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  padding: 4px;
  display: none;
}

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

.topbar-search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-3);
  font-size: .82rem;
  pointer-events: none;
}

.topbar-search-input {
  width: 100%;
  height: 34px;
  padding: 0 12px 0 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-1);
  font-size: .82rem;
  font-family: inherit;
  transition: var(--t-base);
  outline: none;
}

.topbar-search-input::placeholder { color: var(--text-3); }

.topbar-search-input:focus {
  border-color: var(--border-focus);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--blue-ring);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.topbar-icon-btn {
  width: 34px; height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: var(--t-fast);
  font-size: .88rem;
}

.topbar-icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-focus);
  color: var(--blue);
}

.topbar-notif-wrap { position: relative; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: var(--t-fast);
}

.topbar-user:hover { background: var(--surface-2); }

.topbar-avatar {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700; color: #fff;
}

.topbar-chevron { font-size: .68rem; color: var(--text-3); }

.topbar-user-menu { min-width: 200px; }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 190;
}

.sidebar-overlay.visible { display: block; }

/* Flash container */
.flash-container {
  padding: 12px 20px 0;
}

/* ─── Main content ─────────────────────────────────────────────────────── */
.app-main {
  padding: 24px 28px;
  flex: 1;
}

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

/* ─── Page Header ─────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -.02em;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-title-icon {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem;
  flex-shrink: 0;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  background: var(--blue-light);
  color: var(--blue);
  border-radius: 99px;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .02em;
}

/* ─── Cards ───────────────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-sm) !important;
  background: var(--surface) !important;
  overflow: hidden;
}

.card-header {
  background: var(--surface) !important;
  border-bottom: 1px solid var(--border) !important;
  border-radius: 0 !important;
  padding: 14px 20px !important;
}

.card-header h6 {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: .02em;
  margin: 0;
}

/* ─── KPI / Metric cards ──────────────────────────────────────────────── */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  transition: box-shadow var(--t-base), transform var(--t-base);
  overflow: hidden;
  position: relative;
}

.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.kpi-card-accent {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.kpi-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-bottom: 12px;
}

.kpi-value {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1;
  color: var(--text-1);
}

.kpi-label {
  font-size: .72rem;
  color: var(--text-3);
  font-weight: 500;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: .72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
  margin-top: 8px;
}

.kpi-trend.up   { background: #dcfce7; color: #15803d; }
.kpi-trend.down { background: #fee2e2; color: #dc2626; }
.kpi-trend.flat { background: var(--surface-2); color: var(--text-3); }

/* ─── Filter Panel ────────────────────────────────────────────────────── */
.filter-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  padding: 14px 18px;
  margin-bottom: 14px;
}

.filter-panel .form-label {
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-3);
  margin-bottom: 5px;
}

.filter-panel .form-control,
.filter-panel .form-select {
  border-color: var(--border);
  border-radius: var(--radius-sm);
  font-size: .82rem;
  color: var(--text-1);
  height: 34px;
  padding: 4px 10px;
  background: var(--surface-2);
  transition: var(--t-base);
  box-shadow: none;
}

.filter-panel .form-select { padding-right: 28px; }

.filter-panel .form-control:focus,
.filter-panel .form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--blue-ring) !important;
  background: var(--surface);
}

.filter-panel .form-control::placeholder { color: var(--text-3); }

/* ─── Active Filter Chips ─────────────────────────────────────────────── */
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  background: var(--blue-light);
  color: var(--blue);
  border-radius: 99px;
  font-size: .74rem;
  font-weight: 500;
  border: 1px solid rgba(37,99,235,.15);
  animation: chipIn .15s ease;
}

@keyframes chipIn { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }

.filter-chip .chip-label { color: var(--text-3); font-weight: 400; }

.filter-chip a {
  width: 15px; height: 15px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--blue);
  text-decoration: none;
  background: rgba(37,99,235,.15);
  font-size: .66rem;
  flex-shrink: 0;
  transition: var(--t-fast);
}

.filter-chip a:hover { background: rgba(37,99,235,.3); }

/* ─── Data Table ──────────────────────────────────────────────────────── */
.data-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.data-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  min-height: 46px;
  gap: 12px;
  flex-wrap: wrap;
}

.result-count { font-size: .78rem; color: var(--text-2); font-weight: 500; }
.result-count strong { color: var(--text-1); }
.toolbar-actions { display: flex; align-items: center; gap: 8px; }

.table-scroll { overflow-x: auto; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}

table.data-table thead { position: sticky; top: 0; z-index: 10; }

table.data-table thead th {
  background: var(--surface-2);
  color: var(--text-3);
  font-size: .67rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 9px 16px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  user-select: none;
}

table.data-table thead th.sortable { cursor: pointer; }
table.data-table thead th.sortable:hover { background: #eef2f7; color: var(--text-2); }
[data-theme="dark"] table.data-table thead th.sortable:hover { background: #2d3f55; }
table.data-table thead th.sort-asc,
table.data-table thead th.sort-desc { color: var(--blue); background: var(--blue-light); }

.sort-icon { display: inline-flex; flex-direction: column; gap: 1px; margin-left: 4px; vertical-align: middle; opacity: .4; }
.sort-icon span { display: block; width: 0; height: 0; }
.sort-icon .arrow-up  { border-left: 3px solid transparent; border-right: 3px solid transparent; border-bottom: 3px solid currentColor; }
.sort-icon .arrow-dn  { border-left: 3px solid transparent; border-right: 3px solid transparent; border-top:    3px solid currentColor; }
th.sort-asc  .sort-icon, th.sort-desc .sort-icon { opacity: 1; }
th.sort-asc  .sort-icon .arrow-dn  { opacity: .25; }
th.sort-desc .sort-icon .arrow-up  { opacity: .25; }

table.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast);
  cursor: pointer;
}

table.data-table tbody tr:last-child { border-bottom: none; }
table.data-table tbody tr:hover { background: var(--surface-hover); }
table.data-table tbody tr:active { background: var(--blue-light); }

table.data-table tbody td {
  padding: 10px 16px;
  color: var(--text-1);
  vertical-align: middle;
}

.td-id {
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
  font-size: .72rem;
  color: var(--blue) !important;
  white-space: nowrap;
  font-weight: 500;
}

.td-title { font-weight: 500; color: var(--text-1); max-width: 320px; }
.td-title .title-text {
  display: block;
  color: var(--text-1);
  text-decoration: none;
  transition: color var(--t-fast);
  line-height: 1.4;
}
.td-title .title-text:hover { color: var(--blue); }

.td-muted {
  color: var(--text-2);
  font-size: .79rem;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.td-amount {
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
  font-size: .79rem;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
}

.td-amount .currency { font-weight: 400; color: var(--text-3); margin-left: 3px; font-size: .72rem; }
.td-date { font-size: .78rem; color: var(--text-2); white-space: nowrap; }

/* ─── Status Badges ───────────────────────────────────────────────────── */
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}

.status-dot::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-open    { background: var(--status-open-bg);    color: var(--status-open-fg);    }
.status-open::before    { background: var(--status-open-dot);    box-shadow: 0 0 0 2px rgba(16,185,129,.2); }
.status-award   { background: var(--status-award-bg);   color: var(--status-award-fg);   }
.status-award::before   { background: var(--status-award-dot);   box-shadow: 0 0 0 2px rgba(14,165,233,.2); }
.status-cancel  { background: var(--status-cancel-bg);  color: var(--status-cancel-fg);  }
.status-cancel::before  { background: var(--status-cancel-dot);  box-shadow: 0 0 0 2px rgba(239,68,68,.2); }
.status-pending { background: var(--status-pending-bg); color: var(--status-pending-fg); }
.status-pending::before { background: var(--status-pending-dot); box-shadow: 0 0 0 2px rgba(245,158,11,.2); }
.status-default { background: var(--status-default-bg); color: var(--status-default-fg); }
.status-default::before { background: var(--status-default-dot); }

/* ─── Category Tags ───────────────────────────────────────────────────── */
.category-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  font-size: .7rem;
  font-weight: 500;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Role badges ─────────────────────────────────────────────────────── */
.role-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: var(--radius-xs);
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.role-superadmin { background: #f3e8ff; color: #7e22ce; }
.role-admin      { background: #dbeafe; color: #1d4ed8; }
.role-analyst    { background: #dcfce7; color: #15803d; }
.role-viewer     { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }

/* User avatar (tables) */
.user-avatar {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

/* ─── Pagination ──────────────────────────────────────────────────────── */
.data-table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  gap: 12px;
  flex-wrap: wrap;
}

.pagination-info { font-size: .78rem; color: var(--text-2); }
.pagination-nav { display: flex; align-items: center; gap: 3px; }

.pg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 5px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: .78rem;
  font-weight: 500;
  text-decoration: none;
  transition: var(--t-fast);
  cursor: pointer;
}

.pg-btn:hover { background: var(--surface-hover); border-color: var(--blue); color: var(--blue); }
.pg-btn.active { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.pg-btn.disabled { opacity: .35; pointer-events: none; }
.pg-btn.pg-dots { border-color: transparent; background: transparent; cursor: default; }
.pg-btn.pg-dots:hover { background: transparent; border-color: transparent; color: var(--text-3); }

/* ─── Buttons ─────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--blue) !important;
  border-color: var(--blue) !important;
  font-weight: 500;
  font-size: .82rem;
  border-radius: var(--radius-sm) !important;
  height: 36px;
  padding: 0 16px !important;
  transition: var(--t-base);
}

.btn-primary:hover { background: var(--blue-dark) !important; border-color: var(--blue-dark) !important; }
.btn-primary:focus { box-shadow: 0 0 0 3px var(--blue-ring) !important; }

.btn-outline-secondary {
  border-color: var(--border) !important;
  color: var(--text-2) !important;
  font-size: .82rem;
  font-weight: 500;
  border-radius: var(--radius-sm) !important;
  height: 36px;
  padding: 0 12px !important;
  background: var(--surface) !important;
  transition: var(--t-base);
}

.btn-outline-secondary:hover {
  background: var(--surface-2) !important;
  border-color: var(--border-focus) !important;
  color: var(--blue) !important;
}

/* ─── Form controls ───────────────────────────────────────────────────── */
.form-control, .form-select {
  border-color: var(--border);
  border-radius: var(--radius-sm) !important;
  font-size: .82rem;
  color: var(--text-1);
  background: var(--surface);
  box-shadow: none !important;
  transition: border-color var(--t-base), box-shadow var(--t-base);
}

.form-control:focus, .form-select:focus {
  border-color: var(--border-focus) !important;
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--blue-ring) !important;
}

.form-control[readonly] { background: var(--surface-2); color: var(--text-2); }
.form-label { color: var(--text-1); font-size: .82rem; }

/* ─── Breadcrumb ──────────────────────────────────────────────────────── */
.breadcrumb {
  font-size: .78rem;
  color: var(--text-3);
  gap: 6px;
  margin-bottom: 20px;
}
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-3); }
.breadcrumb-item a { color: var(--text-2); text-decoration: none; }
.breadcrumb-item a:hover { color: var(--blue); }
.breadcrumb-item.active { color: var(--text-1); font-weight: 500; }

/* ─── Empty state ─────────────────────────────────────────────────────── */
.empty-state { padding: 64px 24px; text-align: center; color: var(--text-3); }

.empty-state-icon {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  margin: 0 auto 16px;
  color: var(--text-3);
}

.empty-state-title { font-size: .95rem; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.empty-state-sub   { font-size: .82rem; color: var(--text-3); }

/* ─── Alerts ──────────────────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius-sm) !important;
  font-size: .82rem;
  border: none !important;
  padding: 12px 16px !important;
}

.alert-warning { background: #fffbeb; color: #92400e; }
.alert-danger  { background: #fef2f2; color: #991b1b; }
.alert-info    { background: var(--blue-subtle); color: #1e40af; }
.alert-success { background: #f0fdf4; color: #14532d; }

[data-theme="dark"] .alert-warning { background: #422006; color: #fcd34d; }
[data-theme="dark"] .alert-danger  { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .alert-info    { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .alert-success { background: #052e16; color: #86efac; }

/* ─── Code ────────────────────────────────────────────────────────────── */
code {
  font-size: .78rem;
  color: #7c3aed;
  background: #f5f3ff;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
}

[data-theme="dark"] code { color: #c4b5fd; background: #2d1b69; }

/* ─── Progress ────────────────────────────────────────────────────────── */
.progress { border-radius: 99px; background: var(--surface-2); }
.progress-bar { border-radius: 99px; }

/* ─── Dropdown (dark theme fix) ───────────────────────────────────────── */
[data-theme="dark"] .dropdown-menu {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-1);
}
[data-theme="dark"] .dropdown-item { color: var(--text-1); }
[data-theme="dark"] .dropdown-item:hover { background: var(--surface-hover); }
[data-theme="dark"] .dropdown-header { color: var(--text-3); }
[data-theme="dark"] .dropdown-divider { border-color: var(--border); }

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

.auth-body {
  background: #f1f5f9;
  min-height: 100vh;
  display: flex;
  align-items: stretch;
}

.auth-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.auth-brand {
  width: 440px;
  flex-shrink: 0;
  background: linear-gradient(145deg, #0f172a 0%, #1e3a5f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  position: relative;
  overflow: hidden;
}

.auth-brand::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 50%, rgba(59,130,246,.2) 0%, transparent 60%);
}

.auth-brand-inner { position: relative; z-index: 1; }

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-logo-icon {
  width: 40px; height: 40px;
  background: var(--blue);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  color: #fff;
}

.auth-logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: -.01em;
}

.auth-tagline {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.04em;
  line-height: 1.15;
  margin: 32px 0 16px;
}

.auth-sub { color: #64748b; font-size: .9rem; line-height: 1.6; margin-bottom: 32px; }

.auth-features { display: flex; flex-direction: column; gap: 10px; }
.auth-feature { color: #94a3b8; font-size: .85rem; display: flex; align-items: center; }

.auth-steps { display: flex; flex-direction: column; gap: 12px; }
.auth-step {
  display: flex; align-items: center; gap: 12px;
  color: #64748b; font-size: .85rem;
}
.auth-step span {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700; color: #64748b;
  flex-shrink: 0;
}
.auth-step.active { color: #94a3b8; }
.auth-step.active span { background: var(--blue); color: #fff; }

.auth-form-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
  background: #fff;
}

.auth-form-inner { width: 100%; max-width: 380px; }

.auth-mobile-logo { display: flex; align-items: center; gap: 10px; }

.auth-form-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -.03em;
  margin: 0 0 6px;
}

.auth-form-sub { color: #64748b; font-size: .88rem; margin-bottom: 24px; }

.auth-alert {
  border-radius: 8px !important;
  font-size: .82rem;
  padding: 10px 14px !important;
  margin-bottom: 16px;
}

.auth-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
  letter-spacing: .01em;
}

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input-icon {
  position: absolute;
  left: 11px;
  color: #94a3b8;
  font-size: .82rem;
  pointer-events: none;
  z-index: 1;
}

.auth-input {
  padding-left: 33px !important;
  height: 42px;
  border-color: #e2e8f0;
  border-radius: 8px !important;
  font-size: .88rem;
  color: #0f172a;
  background: #f8fafc;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}

.auth-input:focus {
  border-color: var(--blue) !important;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,.15) !important;
}

.auth-eye {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: .82rem;
  padding: 2px;
  z-index: 1;
}

.auth-eye:hover { color: #475569; }

.auth-check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: .82rem;
  color: #475569;
  cursor: pointer;
}

.auth-btn-primary {
  height: 44px;
  font-size: .9rem;
  font-weight: 600;
  background: var(--blue) !important;
  border-color: var(--blue) !important;
  border-radius: 8px !important;
  transition: var(--t-base);
  letter-spacing: .01em;
}

.auth-btn-primary:hover {
  background: var(--blue-dark) !important;
  border-color: var(--blue-dark) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37,99,235,.35);
}

.auth-footer-link {
  text-align: center;
  font-size: .82rem;
  color: #64748b;
  margin: 0;
}

.auth-footer-link a { color: var(--blue); font-weight: 600; text-decoration: none; }
.auth-footer-link a:hover { text-decoration: underline; }

.auth-invite-badge {
  background: #eff6ff;
  color: #1d4ed8;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 500;
}

/* ══════════════════════════════════════════════════════════════════════
   TRANSITIONS & ANIMATIONS
   ══════════════════════════════════════════════════════════════════════ */

.fade-in { animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

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

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }
  .main-wrapper {
    margin-left: 0;
    max-width: 100vw;
  }
  .topbar-toggle { display: flex !important; }
}

@media (max-width: 768px) {
  .app-main { padding: 16px; }
  .auth-form-panel { padding: 32px 20px; }
  table.data-table { font-size: .78rem; }
  table.data-table tbody td { padding: 8px 12px; }
  .data-table-toolbar { padding: 8px 12px; }
  .kpi-value { font-size: 1.5rem; }
}

@media (max-width: 576px) {
  .auth-layout { flex-direction: column; }
  .auth-form-panel { min-height: 100vh; }
  .topbar-search { max-width: 160px; }
}

/* ── select-sm ─────────────────────────────────────────────────────────── */
.select-sm {
  height: 30px !important;
  padding: 2px 24px 2px 8px !important;
  font-size: .75rem !important;
  border-color: var(--border) !important;
  color: var(--text-2) !important;
  background: var(--surface) !important;
  border-radius: var(--radius-sm) !important;
  cursor: pointer;
}
.select-sm:focus { border-color: var(--border-focus) !important; box-shadow: 0 0 0 3px var(--blue-ring) !important; }

/* ── list-group ────────────────────────────────────────────────────────── */
.list-group-item {
  font-size: .82rem;
  border-color: var(--border) !important;
  padding: 10px 16px;
  color: var(--text-2);
  background: var(--surface);
}
.list-group-item:hover { background: var(--surface-2); }

/* ── Metric card (alias) ───────────────────────────────────────────────── */
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  padding: 20px;
  transition: box-shadow var(--t-base);
}
.metric-card:hover { box-shadow: var(--shadow-md); }
.metric-value { font-size: 2rem; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.metric-label { font-size: .75rem; color: var(--text-3); font-weight: 500; margin-top: 4px; text-transform: uppercase; letter-spacing: .05em; }
.metric-icon  { width: 44px; height: 44px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 1.15rem; flex-shrink: 0; }
