/* ============================================================
   ITIPE — Intelligent Trade Incentive & Provisioning Engine
   Design System: Dark industrial palette + warm amber accents
   Fonts: DM Sans (body) + JetBrains Mono (data)
   ============================================================ */

:root {
  /* Core palette */
  --bg-root: #0c0e14;
  --bg-surface: #13151e;
  --bg-card: #191c28;
  --bg-card-hover: #1e2130;
  --bg-input: #1a1d29;
  --bg-sidebar: #10121a;

  /* Borders */
  --border: #262a3a;
  --border-light: #1e2130;
  --border-focus: #d4a056;

  /* Text */
  --text-primary: #e8e6e1;
  --text-secondary: #9b97a0;
  --text-muted: #6b6775;
  --text-accent: #d4a056;

  /* Accent — warm amber */
  --accent: #d4a056;
  --accent-glow: rgba(212, 160, 86, 0.15);
  --accent-subtle: rgba(212, 160, 86, 0.08);

  /* Semantic */
  --emerald: #3ecf8e;
  --emerald-bg: rgba(62, 207, 142, 0.1);
  --blue: #5b9cf5;
  --blue-bg: rgba(91, 156, 245, 0.1);
  --amber: #d4a056;
  --amber-bg: rgba(212, 160, 86, 0.1);
  --violet: #a78bfa;
  --violet-bg: rgba(167, 139, 250, 0.1);
  --danger: #ef6461;
  --danger-bg: rgba(239, 100, 97, 0.1);

  /* Sizing */
  --sidebar-w: 260px;
  --header-h: 56px;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-xs: 4px;

  /* Shadows */
  --shadow-card: 0 1px 3px rgba(0,0,0,0.3), 0 0 0 1px var(--border);
  --shadow-elevated: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 24px rgba(212, 160, 86, 0.08);

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

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

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg-root);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s var(--ease); }
a:hover { color: #e6b46a; }

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

/* ---- Typography helpers ---- */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-mono { font-family: 'JetBrains Mono', monospace; }
.text-xs { font-size: 0.73rem; }
.text-sm { font-size: 0.85rem; }
.text-medium { font-weight: 500; }
.text-success { color: var(--emerald); }
.text-danger { color: var(--danger); }
.text-amber { color: var(--amber); }
.text-emerald { color: var(--emerald); }
.mt-sm { margin-top: 0.5rem; }
.mt-lg { margin-top: 1.5rem; }

/* ============================================================
   AUTH PAGE
   ============================================================ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-root);
  position: relative;
  overflow: hidden;
}

.auth-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 80%, rgba(212,160,86,0.06), transparent),
    radial-gradient(ellipse 60% 50% at 80% 20%, rgba(91,156,245,0.04), transparent),
    var(--bg-root);
  z-index: 0;
}

.auth-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 960px;
  margin: 2rem;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-elevated);
}

.auth-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.auth-form-wrap {
  padding: 3rem 2.5rem;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: var(--bg-root);
}

.brand-icon.lg {
  width: 48px;
  height: 48px;
  font-size: 1.3rem;
  border-radius: var(--radius);
}

.auth-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  letter-spacing: -0.02em;
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.auth-form { margin-top: 1.5rem; }

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input,
.form-group select,
.form-group textarea,
.filter-select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.filter-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group input::placeholder { color: var(--text-muted); }

.demo-hint {
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--accent-subtle);
  border: 1px solid rgba(212,160,86,0.15);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
}

.demo-hint strong { color: var(--accent); }

/* Auth features panel */
.auth-features {
  background: linear-gradient(160deg, #161926, #111420);
  padding: 3rem 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-left: 1px solid var(--border);
}

.auth-tagline {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 2rem;
  line-height: 1.35;
  letter-spacing: -0.015em;
}

.auth-feature {
  display: flex;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  transition: background 0.2s var(--ease);
}

.auth-feature:hover {
  background: rgba(255,255,255,0.02);
}

.auth-feature .feat-icon {
  width: 32px;
  height: 32px;
  background: var(--accent-subtle);
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.auth-feature h4 {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.auth-feature p {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.auth-footer-text {
  margin-top: 1.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg-root);
  border-color: var(--accent);
}
.btn-primary:hover {
  background: #e6b46a;
  border-color: #e6b46a;
  color: var(--bg-root);
  box-shadow: 0 4px 16px rgba(212,160,86,0.25);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.04);
}

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.78rem; }
.btn-full { width: 100%; }

/* ============================================================
   APP SHELL (Sidebar + Main)
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Mobile header */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
  align-items: center;
  justify-content: space-between;
  z-index: 200;
}

.menu-toggle {
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s var(--ease);
}
.menu-toggle:hover { border-color: var(--accent); color: var(--accent); }

.mobile-brand {
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mobile-brand .brand-icon {
  width: 28px;
  height: 28px;
  font-size: 0.8rem;
}

.mobile-actions { display: flex; gap: 0.5rem; }

.icon-btn {
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 300;
  transition: transform 0.3s var(--ease);
}

.sidebar-brand {
  padding: 1.25rem 1.25rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.brand-name {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0;
}

.nav-section { margin-bottom: 0.25rem; }

.nav-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 0.75rem 1.25rem 0.35rem;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 1.25rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: all 0.15s var(--ease);
  border-left: 2px solid transparent;
  margin: 1px 0;
}

.nav-item:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.03);
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-subtle);
  border-left-color: var(--accent);
  font-weight: 500;
}

.nav-item .nav-icon { width: 18px; text-align: center; font-size: 0.95rem; }

/* Sidebar footer */
.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-subtle);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 0.82rem; font-weight: 600; }
.user-role { font-size: 0.7rem; color: var(--text-muted); }

.logout-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.25rem;
  transition: color 0.15s;
}
.logout-btn:hover { color: var(--danger); }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 250;
  backdrop-filter: blur(2px);
}

/* ---- Main Content ---- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 2rem 2.25rem;
  min-height: 100vh;
}

/* ---- Flash messages ---- */
.flash-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: flashIn 0.3s var(--ease);
  box-shadow: var(--shadow-elevated);
  max-width: 380px;
}

@keyframes flashIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.flash-success { background: #142b1e; border: 1px solid #1a3d26; color: var(--emerald); }
.flash-error, .flash-danger { background: #2b1416; border: 1px solid #3d1a1c; color: var(--danger); }
.flash-info { background: #141e2b; border: 1px solid #1a2b3d; color: var(--blue); }
.flash-warning { background: #2b2214; border: 1px solid #3d301a; color: var(--amber); }

.flash-close {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.5;
  cursor: pointer;
  font-size: 1.1rem;
  margin-left: auto;
  padding: 0;
}
.flash-close:hover { opacity: 1; }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 0.15rem;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}
.back-link:hover { color: var(--accent); }

/* ============================================================
   KPI CARDS
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.kpi-grid.kpi-3 { grid-template-columns: repeat(3, 1fr); }
.kpi-grid.kpi-2 { grid-template-columns: repeat(2, 1fr); }

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: all 0.2s var(--ease);
  position: relative;
  overflow: hidden;
}

.kpi-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}

.kpi-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-glow);
}
.kpi-card:hover::after { opacity: 1; }

.kpi-card.compact { padding: 1rem; }

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.kpi-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}

.kpi-icon.amber { background: var(--amber-bg); color: var(--amber); }
.kpi-icon.emerald { background: var(--emerald-bg); color: var(--emerald); }
.kpi-icon.blue { background: var(--blue-bg); color: var(--blue); }
.kpi-icon.violet { background: var(--violet-bg); color: var(--violet); }

.kpi-label {
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

.kpi-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.kpi-value.sm { font-size: 1.1rem; }

.kpi-meta {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 0.9rem;
}

.card-body {
  padding: 1.25rem;
}

/* ============================================================
   DATA TABLES
   ============================================================ */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

.data-table thead th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: rgba(0,0,0,0.15);
}

.data-table tbody td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background 0.1s;
}

.data-table tbody tr:hover {
  background: rgba(255,255,255,0.015);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* ============================================================
   STATUS & TYPE BADGES
   ============================================================ */
.badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.status-badge.status-active,
.badge.badge-live {
  background: var(--emerald-bg);
  color: var(--emerald);
}

.status-badge.status-draft { background: rgba(255,255,255,0.05); color: var(--text-muted); }
.status-badge.status-closed { background: var(--blue-bg); color: var(--blue); }
.status-badge.status-settled { background: var(--violet-bg); color: var(--violet); }
.status-badge.status-pending { background: var(--amber-bg); color: var(--amber); }
.status-badge.status-booked { background: var(--emerald-bg); color: var(--emerald); }
.status-badge.status-reversed { background: var(--danger-bg); color: var(--danger); }
.status-badge.status-paid { background: var(--emerald-bg); color: var(--emerald); }

.status-badge.lg { font-size: 0.74rem; padding: 0.3rem 0.85rem; }

.badge-danger { background: var(--danger-bg); color: var(--danger); }

/* Channel badges */
.channel-badge {
  display: inline-flex;
  padding: 0.15rem 0.55rem;
  border-radius: 100px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.channel-badge.ch-distributor { background: var(--blue-bg); color: var(--blue); }
.channel-badge.ch-wholesaler { background: var(--violet-bg); color: var(--violet); }
.channel-badge.ch-retailer { background: var(--amber-bg); color: var(--amber); }

/* Credit note type badge */
.cn-type-badge {
  display: inline-flex;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.68rem;
  font-weight: 600;
}

.cn-gst { background: var(--emerald-bg); color: var(--emerald); }
.cn-fin { background: var(--blue-bg); color: var(--blue); }

/* Tier badges */
.tier-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.tier-badge.tier-1 { background: var(--amber-bg); color: var(--amber); }
.tier-badge.tier-2 { background: var(--blue-bg); color: var(--blue); }
.tier-badge.tier-3 { background: var(--emerald-bg); color: var(--emerald); }
.tier-badge.tier-4 { background: var(--violet-bg); color: var(--violet); }

/* Pulse dot */
.pulse-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(62,207,142,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(62,207,142,0); }
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.filter-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-select {
  padding: 0.45rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-family: inherit;
  min-width: 130px;
}

.search-input-wrap {
  position: relative;
}

.search-input {
  padding: 0.5rem 0.75rem 0.5rem 2rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.84rem;
  width: 220px;
  transition: border-color 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-input-wrap::before {
  content: '⌕';
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ============================================================
   SCHEME CARDS GRID
   ============================================================ */
.schemes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1rem;
}

.scheme-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: all 0.2s var(--ease);
  display: flex;
  flex-direction: column;
}

.scheme-card:hover {
  border-color: rgba(212,160,86,0.2);
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.scheme-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.scheme-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 0.15rem;
}

.scheme-name a { color: inherit; }
.scheme-name a:hover { color: var(--accent); }

.scheme-period {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.scheme-dates {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 0.75rem;
}

.scheme-meta-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.scheme-meta-item {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.scheme-meta-item strong {
  color: var(--text-secondary);
  font-weight: 600;
}

/* Slab mini-bars */
.scheme-slabs { margin-top: auto; }

.slab-bars {
  display: flex;
  gap: 3px;
  margin-top: 0.5rem;
}

.slab-bar {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.3;
  transition: opacity 0.2s;
}

.scheme-card:hover .slab-bar { opacity: 0.6; }

/* ============================================================
   SCHEME DETAIL — SLAB CONFIG TABLE
   ============================================================ */
.slab-config-section {
  margin-top: 1.25rem;
}

.slab-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border-light);
}

.slab-row:last-child { border-bottom: none; }

.slab-label {
  font-size: 0.82rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
}

.slab-rate {
  font-size: 0.82rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--accent);
  text-align: right;
}

/* ============================================================
   DETAIL GRID (Scheme/Client detail pages)
   ============================================================ */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.25rem;
}

.detail-item {}

.detail-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.detail-value {
  font-size: 0.95rem;
  font-weight: 600;
}

/* ============================================================
   GRID LAYOUTS
   ============================================================ */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

/* ============================================================
   ACCUMULATOR CARDS (Client detail)
   ============================================================ */
.accumulator-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
  transition: all 0.2s var(--ease);
}

.accumulator-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-glow);
}

.acc-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.acc-scheme-name {
  font-weight: 600;
  font-size: 0.88rem;
}

.acc-meta {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.acc-stats {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
}

.acc-stats span { color: var(--text-secondary); }
.acc-stats strong { color: var(--text-primary); font-weight: 600; }

/* Progress bar */
.acc-progress { margin-top: 0.5rem; }

.progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-wrap.lg { height: 8px; border-radius: 4px; }

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #e6b46a);
  border-radius: inherit;
  transition: width 0.6s var(--ease);
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.acc-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ============================================================
   CLIENT LIST
   ============================================================ */
.client-cell {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.client-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-subtle);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

/* ============================================================
   TOP CLIENTS LIST (Dashboard)
   ============================================================ */
.top-clients-list { display: flex; flex-direction: column; gap: 0.5rem; }

.top-client-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border-light);
}

.top-client-item:last-child { border-bottom: none; }

.top-client-rank {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
}

.top-client-info { flex: 1; min-width: 0; }
.top-client-name { font-size: 0.84rem; font-weight: 600; }
.top-client-state { font-size: 0.72rem; color: var(--text-muted); }

.top-client-vol {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  text-align: right;
}

/* ============================================================
   ACTIVITY TIMELINE (Dashboard)
   ============================================================ */
.activity-timeline { position: relative; }

.activity-item {
  display: flex;
  gap: 1rem;
  padding: 0.65rem 0;
  position: relative;
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 0.45rem;
  flex-shrink: 0;
  position: relative;
}

.activity-item:not(:last-child) .activity-dot::after {
  content: '';
  position: absolute;
  top: 12px;
  left: 3px;
  width: 2px;
  height: calc(100% + 10px);
  background: var(--border);
}

.activity-content { flex: 1; }
.activity-msg { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.45; }
.activity-time { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.15rem; }

/* ============================================================
   ALERT LIST (Dashboard)
   ============================================================ */
.alert-list { display: flex; flex-direction: column; }

.alert-item {
  display: flex;
  gap: 0.7rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.1s;
}

.alert-item:last-child { border-bottom: none; }
.alert-item.unread { background: rgba(212,160,86,0.03); }

.alert-severity {
  width: 6px;
  border-radius: 3px;
  flex-shrink: 0;
}

.alert-severity.sev-high { background: var(--danger); }
.alert-severity.sev-medium { background: var(--amber); }
.alert-severity.sev-low { background: var(--blue); }

.alert-content { flex: 1; }

.alert-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

.alert-badge {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.45rem;
  border-radius: 100px;
  font-weight: 600;
}

.alert-badge.cat-anomaly { background: var(--danger-bg); color: var(--danger); }
.alert-badge.cat-threshold { background: var(--amber-bg); color: var(--amber); }
.alert-badge.cat-compliance { background: var(--blue-bg); color: var(--blue); }

.alert-msg { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.4; }
.alert-time { font-size: 0.68rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ============================================================
   FORM — SCHEME CREATE
   ============================================================ */
.create-form {
  max-width: 720px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-grid .span-2 { grid-column: span 2; }

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.btn-remove {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.3rem;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.btn-remove:hover { opacity: 1; }

/* ============================================================
   ANALYTICS CHARTS
   ============================================================ */
.chart-container {
  position: relative;
  height: 260px;
  width: 100%;
}

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.empty-state::before {
  content: '📭';
  display: block;
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

/* ============================================================
   ERROR PAGES
   ============================================================ */
.error-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  gap: 1rem;
}

.error-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 6rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.05em;
  line-height: 1;
  opacity: 0.3;
}

.error-message {
  font-size: 1.15rem;
  color: var(--text-secondary);
}

/* ============================================================
   RESPONSIVE — TABLET (<1024)
   ============================================================ */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2col { grid-template-columns: 1fr; }
  .chart-grid { grid-template-columns: 1fr; }
  .auth-grid { grid-template-columns: 1fr; }
  .auth-features { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
}

/* ============================================================
   RESPONSIVE — MOBILE (<768)
   ============================================================ */
@media (max-width: 768px) {
  .mobile-header { display: flex; }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

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

  .main-content {
    margin-left: 0;
    padding: 1.25rem;
    padding-top: calc(var(--header-h) + 1.25rem);
  }

  .page-title { font-size: 1.2rem; }

  .kpi-grid,
  .kpi-grid.kpi-2,
  .kpi-grid.kpi-3 {
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
  }

  .kpi-value { font-size: 1.15rem; }
  .kpi-card { padding: 0.85rem; }

  .schemes-grid {
    grid-template-columns: 1fr;
  }

  .data-table { font-size: 0.78rem; }
  .data-table thead th, .data-table tbody td { padding: 0.55rem 0.65rem; }

  .filter-bar { gap: 0.5rem; }
  .filter-select { min-width: 100px; font-size: 0.75rem; }
  .search-input { width: 160px; }

  .detail-grid { grid-template-columns: 1fr 1fr; }

  .page-header { flex-direction: column; }
  .header-actions { width: 100%; }

  .flash { max-width: calc(100vw - 2rem); }
}

/* ============================================================
   RESPONSIVE — SMALL PHONE (<480)
   ============================================================ */
@media (max-width: 480px) {
  html { font-size: 14px; }

  .kpi-grid,
  .kpi-grid.kpi-2,
  .kpi-grid.kpi-3 {
    grid-template-columns: 1fr;
  }

  .main-content { padding: 1rem; padding-top: calc(var(--header-h) + 1rem); }
  .detail-grid { grid-template-columns: 1fr; }
  .auth-form-wrap { padding: 2rem 1.5rem; }
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.kpi-card { animation: fadeInUp 0.4s var(--ease) both; }
.kpi-card:nth-child(1) { animation-delay: 0.05s; }
.kpi-card:nth-child(2) { animation-delay: 0.1s; }
.kpi-card:nth-child(3) { animation-delay: 0.15s; }
.kpi-card:nth-child(4) { animation-delay: 0.2s; }

.scheme-card { animation: fadeInUp 0.35s var(--ease) both; }
.card { animation: fadeInUp 0.35s var(--ease) both; }

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Selection */
::selection { background: var(--accent); color: var(--bg-root); }
