/* =========================================================
   iRawda Central Database — Design System
   ========================================================= */

:root {
  /* Brand */
  --navy: #053270;
  --navy-dark: #021E46;
  --royal: #0B4DA2;
  --gold: #FFC60B;
  --gold-soft: #FFE38A;
  --white: #FEFEFE;
  --bg: #F4F7FC;
  --text: #172033;

  /* Semantic surface tokens (light) */
  --surface: #FFFFFF;
  --surface-2: #F7F9FD;
  --surface-3: #EEF2FA;
  --border: #E2E8F5;
  --text-primary: var(--text);
  --text-secondary: #5B6478;
  --text-muted: #8B93A7;
  --shadow-sm: 0 1px 2px rgba(5, 50, 112, 0.06);
  --shadow-md: 0 6px 20px rgba(5, 50, 112, 0.08);
  --shadow-lg: 0 16px 40px rgba(5, 50, 112, 0.14);

  /* Status colors */
  --ok: #157A4D;
  --ok-bg: #E4F6EC;
  --warn: #A16207;
  --warn-bg: #FFF4D9;
  --danger: #B3261E;
  --danger-bg: #FCE8E6;
  --info: #0B4DA2;
  --info-bg: #E8F0FC;
  --neutral: #5B6478;
  --neutral-bg: #EEF1F6;

  /* Layout */
  --sidebar-w: 264px;
  --sidebar-w-collapsed: 84px;
  --topnav-h: 72px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --gap: 20px;

  /* Type */
  --font-main: 'Inter', 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --fs-body: 15px;
  --density: 1;
}

[data-density="compact"] {
  --density: 0.8;
}

/* Dark theme */
[data-theme="dark"] {
  --surface: #0E1B33;
  --surface-2: #0A1428;
  --surface-3: #14233F;
  --border: #223154;
  --bg: #071224;
  --text-primary: #EAF0FC;
  --text-secondary: #A9B6D2;
  --text-muted: #7784A3;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.35);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.45);
  --shadow-lg: 0 20px 48px rgba(0,0,0,0.55);
  --ok-bg: #103826; --ok: #4ADE94;
  --warn-bg: #3A2C08; --warn: #FFC94D;
  --danger-bg: #3B1512; --danger: #FF8A80;
  --info-bg: #102A4E; --info: #7DB2F5;
  --neutral-bg: #17233C; --neutral: #A9B6D2;
}

[data-contrast="high"] {
  --border: #000;
  --text-secondary: var(--text-primary);
}
[data-theme="dark"][data-contrast="high"] {
  --border: #fff;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
[data-motion="reduce"] * { animation: none !important; transition: none !important; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-main);
  font-size: var(--fs-body);
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font-family: inherit; }
img { max-width: 100%; display: block; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Focus states */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--royal);
  outline-offset: 2px;
  border-radius: 6px;
}

/* =========================================================
   App shell
   ========================================================= */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.2s ease;
}
.app-shell.sidebar-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* ---- Sidebar ---- */
.sidebar {
  background: linear-gradient(180deg, var(--navy-dark) 0%, var(--navy) 100%);
  color: #EAF1FF;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  border-right: 1px solid rgba(255,255,255,0.06);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  white-space: nowrap;
  overflow: hidden;
}
.brand-mark {
  width: 40px; height: 40px; flex: 0 0 auto;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-soft) 100%);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: var(--navy-dark);
  box-shadow: 0 4px 14px rgba(255,198,11,0.35);
}
.brand-text .brand-title { font-weight: 700; font-size: 16px; line-height: 1.2; }
.brand-text .brand-sub { font-size: 11.5px; color: #A9C1EA; letter-spacing: 0.3px; }
.app-shell.sidebar-collapsed .brand-text { display: none; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.nav-item {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 14px;
  border-radius: 10px;
  color: #C9D8F5;
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
  margin-bottom: 2px;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item svg { flex: 0 0 auto; width: 19px; height: 19px; }
.nav-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-shell.sidebar-collapsed .nav-item span { display: none; }
.app-shell.sidebar-collapsed .nav-item { justify-content: center; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(255,198,11,0.16), rgba(255,198,11,0.03));
  color: #fff;
  border-color: rgba(255,198,11,0.35);
}
.nav-item.active svg { color: var(--gold); }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
}
.app-shell.sidebar-collapsed .nav-badge { display: none; }

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 16px;
}
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.user-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--royal), var(--navy));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex: 0 0 auto;
  border: 2px solid rgba(255,198,11,0.5);
}
.user-meta { overflow: hidden; }
.user-name { font-size: 13.5px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11.5px; color: #9FB6DE; }
.app-shell.sidebar-collapsed .user-meta, .app-shell.sidebar-collapsed .sidebar-status-text { display: none; }
.sidebar-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: #9FE3B7;
  margin-bottom: 10px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #34D399; box-shadow: 0 0 0 3px rgba(52,211,153,0.2); }
.btn-logout {
  width: 100%; padding: 9px; border-radius: 9px;
  background: rgba(255,255,255,0.06); color: #EAF1FF; border: 1px solid rgba(255,255,255,0.12);
  cursor: pointer; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-logout:hover { background: rgba(255,255,255,0.12); }

.sidebar-collapse-btn {
  position: absolute; top: 20px; right: -12px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--gold); color: var(--navy-dark); border: none; cursor: pointer;
  display: none; align-items: center; justify-content: center; box-shadow: var(--shadow-md);
}
@media (min-width: 1025px) { .sidebar-collapse-btn { display: flex; } }

/* Mobile sidebar */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; background: rgba(2,10,25,0.55);
  z-index: 39; backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-collapse-btn { display: none; }
}

/* ---- Main column ---- */
.main-col { display: flex; flex-direction: column; min-width: 0; }

/* ---- Top nav ---- */
.topnav {
  height: var(--topnav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 30;
  box-shadow: var(--shadow-sm);
}
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-primary); position: relative;
  flex: 0 0 auto;
}
.icon-btn:hover { background: var(--surface-3); }
.icon-btn svg { width: 18px; height: 18px; }
.hamburger { display: none; }
@media (max-width: 1024px) { .hamburger { display: flex; } }

.topnav-titles { min-width: 0; }
.topnav-titles .page-title { font-size: 18px; font-weight: 700; line-height: 1.2; }
.breadcrumb { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.breadcrumb span:not(:last-child)::after { content: '/'; margin: 0 6px; color: var(--text-muted); }

.topnav-search { flex: 1; max-width: 420px; position: relative; }
.topnav-search input {
  width: 100%; padding: 10px 14px 10px 38px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-primary); font-size: 14px;
}
.topnav-search svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-muted); pointer-events: none;
}
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); max-height: 320px; overflow-y: auto; z-index: 50; display: none;
}
.search-results.open { display: block; }
.search-result-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border); }
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover, .search-result-item.active-result { background: var(--surface-2); }
.search-result-item .sr-name { font-weight: 600; font-size: 13.5px; }
.search-result-item .sr-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.search-empty { padding: 16px; text-align: center; color: var(--text-muted); font-size: 13px; }

.topnav-spacer { flex: 1; }
.topnav-date { font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; }
@media (max-width: 900px) { .topnav-date { display: none; } }

.avatar-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--royal), var(--navy));
  color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.btn-primary-gold {
  background: linear-gradient(135deg, var(--gold) 0%, #F5B300 100%);
  color: var(--navy-dark); border: none; font-weight: 700;
  padding: 10px 18px; border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; gap: 8px; font-size: 13.5px;
  box-shadow: 0 4px 14px rgba(255,198,11,0.3);
  white-space: nowrap;
}
.btn-primary-gold:hover { filter: brightness(1.03); transform: translateY(-1px); }
.btn-primary-gold svg { width: 16px; height: 16px; }
@media (max-width: 700px) { .btn-primary-gold span { display: none; } .btn-primary-gold { padding: 10px; } }

/* ---- Content area ---- */
.content {
  flex: 1;
  padding: calc(24px * var(--density)) calc(28px * var(--density));
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================================
   Reusable components
   ========================================================= */

/* Hero banner */
.hero-banner {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: linear-gradient(120deg, var(--navy-dark) 0%, var(--navy) 45%, var(--royal) 100%);
  color: #fff;
  padding: 34px 36px;
  margin-bottom: calc(24px * var(--density));
  box-shadow: var(--shadow-lg);
}
.hero-banner::before, .hero-banner::after {
  content: ''; position: absolute; border-radius: 50%;
  filter: blur(40px); opacity: 0.35; pointer-events: none;
}
.hero-banner::before { width: 260px; height: 260px; background: var(--gold); top: -100px; right: -60px; }
.hero-banner::after { width: 180px; height: 180px; background: var(--royal); bottom: -80px; left: 20%; opacity: 0.25; }
.hero-banner h1 { margin: 0 0 6px; font-size: 24px; font-weight: 700; position: relative; }
.hero-banner p { margin: 0; color: #C9DCF7; font-size: 14.5px; position: relative; max-width: 560px; }
.hero-meta { display: flex; gap: 28px; margin-top: 20px; flex-wrap: wrap; position: relative; }
.hero-meta-item .hm-val { font-size: 20px; font-weight: 800; color: var(--gold); }
.hero-meta-item .hm-label { font-size: 12px; color: #B9CFEF; }

/* Section headers */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 12px; flex-wrap: wrap;
}
.section-header h2 { font-size: 16.5px; font-weight: 700; margin: 0; }
.section-header .sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: calc(16px * var(--density));
  margin-bottom: calc(24px * var(--density));
}
@media (max-width: 1200px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .kpi-grid { grid-template-columns: 1fr; } }

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: calc(18px * var(--density));
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.kpi-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--info-bg); color: var(--info);
}
.kpi-icon svg { width: 18px; height: 18px; }
.kpi-delta { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.kpi-delta.up { color: var(--ok); background: var(--ok-bg); }
.kpi-delta.down { color: var(--danger); background: var(--danger-bg); }
.kpi-value { font-size: 26px; font-weight: 800; line-height: 1.1; }
.kpi-label { font-size: 12.5px; color: var(--text-secondary); margin-top: 4px; }

/* Generic card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: calc(20px * var(--density));
  margin-bottom: calc(20px * var(--density));
}

.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: calc(20px * var(--density)); }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: calc(20px * var(--density)); }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: 1fr; } }

/* Progress rows */
.progress-row { margin-bottom: 14px; }
.progress-row:last-child { margin-bottom: 0; }
.progress-row-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.progress-row-top .pr-label { color: var(--text-secondary); }
.progress-row-top .pr-value { font-weight: 700; }
.progress-track { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--royal), var(--gold)); }

/* Data source chips */
.source-list { display: flex; flex-direction: column; gap: 10px; }
.source-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; }
.source-item .si-name { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.source-dot { width: 8px; height: 8px; border-radius: 50%; }
.source-item .si-count { font-weight: 700; font-size: 14px; }

/* Critical action list */
.action-list { display: flex; flex-direction: column; gap: 10px; }
.action-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2);
}
.action-item .ai-priority {
  width: 6px; align-self: stretch; border-radius: 4px; flex: 0 0 auto;
}
.priority-critical { background: var(--danger); }
.priority-high { background: var(--warn); }
.priority-medium { background: var(--info); }
.priority-low { background: var(--neutral); }
.ai-body { flex: 1; min-width: 0; }
.ai-name { font-weight: 700; font-size: 13.5px; }
.ai-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.ai-badge {
  font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap;
}
.btn-mini {
  padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn-mini:hover { background: var(--surface-3); }
.btn-mini.primary { background: var(--royal); color: #fff; border-color: var(--royal); }

/* Badges / status pills */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { color: var(--ok); background: var(--ok-bg); }
.badge-warn { color: var(--warn); background: var(--warn-bg); }
.badge-danger { color: var(--danger); background: var(--danger-bg); }
.badge-info { color: var(--info); background: var(--info-bg); }
.badge-neutral { color: var(--neutral); background: var(--neutral-bg); }

/* Program cards */
.program-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: calc(18px * var(--density)); }
.program-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 18px; box-shadow: var(--shadow-sm); cursor: pointer; position: relative; overflow: hidden;
}
.program-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); transition: 0.15s; }
.program-card .pc-band { height: 5px; border-radius: 4px; background: linear-gradient(90deg, var(--navy), var(--royal), var(--gold)); margin-bottom: 12px; }
.program-card h3 { margin: 0 0 4px; font-size: 15px; }
.pc-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.pc-stats { display: flex; gap: 14px; margin-bottom: 10px; }
.pc-stat { text-align: left; }
.pc-stat .val { font-weight: 800; font-size: 16px; }
.pc-stat .lbl { font-size: 11px; color: var(--text-muted); }

/* Table */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
table.data-table { width: 100%; border-collapse: collapse; min-width: 900px; font-size: 13.5px; }
table.data-table th {
  text-align: left; padding: 12px 14px; background: var(--surface-2);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted);
  border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; cursor: pointer; user-select: none;
}
table.data-table th.sortable:hover { color: var(--text-primary); }
table.data-table td { padding: calc(12px * var(--density)) 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tbody tr:hover { background: var(--surface-2); }
table.data-table tbody tr:last-child td { border-bottom: none; }
.cell-name { font-weight: 700; }
.cell-sub { font-size: 12px; color: var(--text-muted); }
.row-actions { display: flex; gap: 6px; }

/* Toolbar */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px;
}
.toolbar-search { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.toolbar-search input { width: 100%; padding: 9px 12px 9px 34px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); font-size: 13.5px; }
.toolbar-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-muted); }

select, .input {
  padding: 9px 12px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); font-size: 13.5px; color: var(--text-primary);
}
.btn {
  padding: 9px 14px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 13.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { background: var(--surface-3); }
.btn svg { width: 15px; height: 15px; }
.btn.btn-blue { background: var(--royal); border-color: var(--royal); color: #fff; }
.btn.btn-blue:hover { filter: brightness(1.05); }
.btn.btn-ghost-danger { color: var(--danger); }

.filter-panel {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 10px;
  padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); margin-bottom: 14px;
}
.filter-panel label { font-size: 11.5px; color: var(--text-muted); display: block; margin-bottom: 4px; }
.filter-panel select, .filter-panel input { width: 100%; }

.pagination { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; font-size: 13px; color: var(--text-secondary); flex-wrap: wrap; gap: 10px; }
.pagination-controls { display: flex; gap: 6px; }
.page-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 13px; }
.page-btn.active { background: var(--royal); color: #fff; border-color: var(--royal); }

/* Customer cards (mobile table replacement) */
.customer-cards { display: none; flex-direction: column; gap: 12px; }
.customer-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; box-shadow: var(--shadow-sm);
}
.cc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.cc-name { font-weight: 700; font-size: 14.5px; }
.cc-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.cc-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.cc-footer { margin-top: 12px; display: flex; justify-content: flex-end; }

@media (max-width: 820px) {
  .table-wrap.responsive-to-cards { display: none; }
  .customer-cards.responsive-to-cards { display: flex; }
}

/* Drawer / Modal */
.overlay-scrim { position: fixed; inset: 0; background: rgba(2,10,25,0.5); z-index: 60; display: none; }
.overlay-scrim.open { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 460px; max-width: 100vw;
  background: var(--surface); z-index: 61; box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform 0.25s ease;
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
@media (max-width: 700px) { .drawer { width: 100vw; } }
.drawer-header { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.drawer-header h2 { margin: 0; font-size: 16px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; flex-wrap: wrap; }

.modal-center-wrap { position: fixed; inset: 0; z-index: 61; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-center-wrap.open { display: flex; }
.modal-box {
  background: var(--surface); border-radius: var(--radius-lg); width: 560px; max-width: 100%;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-header { padding: 20px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { margin: 0; font-size: 16.5px; }
.modal-body { padding: 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.form-field input, .form-field select, .form-field textarea {
  padding: 10px 12px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); font-size: 13.5px; color: var(--text-primary);
}
.form-field textarea { resize: vertical; min-height: 70px; }
.form-error { font-size: 12px; color: var(--danger); display: none; }
.form-field.invalid input, .form-field.invalid select { border-color: var(--danger); }
.form-field.invalid .form-error { display: block; }
.field-hint { font-size: 11.5px; color: var(--text-muted); }

.dup-warning {
  background: var(--warn-bg); color: var(--warn); border: 1px solid rgba(161,98,7,0.25);
  border-radius: 10px; padding: 12px 14px; font-size: 13px; margin-bottom: 12px; display: none;
}
.dup-warning.show { display: block; }

/* Profile blocks in drawer */
.profile-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; gap: 10px; }
.profile-row:last-child { border-bottom: none; }
.profile-row .pr-k { color: var(--text-muted); }
.profile-row .pr-v { font-weight: 600; text-align: right; }

.mini-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 10px; background: var(--surface-2); }
.mini-card-title { font-weight: 700; font-size: 13.5px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }

/* Exceptions */
.exception-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 16px; }
.exception-card { border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface); padding: 16px; box-shadow: var(--shadow-sm); }
.exception-card .ec-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.exception-card h3 { margin: 0; font-size: 14px; }
.exception-card .ec-count { font-size: 26px; font-weight: 800; margin: 4px 0; }
.exception-card p { font-size: 12.5px; color: var(--text-secondary); margin: 6px 0 12px; }

/* Import dropzone */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius-md); padding: 40px 20px;
  text-align: center; background: var(--surface-2); cursor: pointer;
}
.dropzone.dragover { border-color: var(--royal); background: var(--info-bg); }
.dropzone svg { width: 40px; height: 40px; color: var(--royal); margin-bottom: 10px; }

/* Toasts */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
@media (max-width: 600px) { .toast-container { left: 16px; right: 16px; } }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  padding: 13px 16px; display: flex; align-items: center; gap: 10px; min-width: 260px;
  animation: toastIn 0.2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.toast .t-icon { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.toast.success .t-icon { background: var(--ok-bg); color: var(--ok); }
.toast.error .t-icon { background: var(--danger-bg); color: var(--danger); }
.toast.info .t-icon { background: var(--info-bg); color: var(--info); }
.toast .t-msg { font-size: 13.5px; font-weight: 600; }

/* Settings */
.settings-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 16px; }
@media (max-width: 700px) { .settings-grid { grid-template-columns: 1fr; } }
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: none; }
.option-chip-group { display: flex; gap: 8px; flex-wrap: wrap; }
.option-chip { padding: 7px 13px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; cursor: pointer; font-weight: 600; }
.option-chip.active { background: var(--royal); border-color: var(--royal); color: #fff; }

.switch { position: relative; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider-toggle {
  position: absolute; cursor: pointer; inset: 0; background: var(--surface-3); border-radius: 999px; transition: 0.2s;
}
.slider-toggle::before { content: ''; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.switch input:checked + .slider-toggle { background: var(--royal); }
.switch input:checked + .slider-toggle::before { transform: translateX(20px); }

.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state svg { width: 46px; height: 46px; margin-bottom: 12px; opacity: 0.6; }
.empty-state h3 { font-size: 15px; color: var(--text-primary); margin-bottom: 4px; }

.demo-tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700;
  background: rgba(255,198,11,0.15); color: var(--gold); border: 1px solid rgba(255,198,11,0.4);
  padding: 2px 8px; border-radius: 999px; letter-spacing: 0.3px;
}

.audit-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.audit-item:last-child { border-bottom: none; }
.audit-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--royal); margin-top: 6px; flex: 0 0 auto; }
.audit-text { font-size: 13.5px; }
.audit-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

.tab-bar { display: flex; gap: 8px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab-btn { padding: 10px 4px; margin-right: 18px; border: none; background: none; cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab-btn.active { color: var(--royal); border-color: var(--royal); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
