/* ============================================================
   CRM-RFM System | Premium UI v2.0
   Design: Refined Enterprise Dark-Sidebar
   Font: Plus Jakarta Sans (modern, readable) + Instrument Serif (display)
   Theme: Deep navy sidebar, clean white content, amber gold accents
   Mobile: Fully responsive with slide-in sidebar
   Performance: Pure CSS, no runtime overhead, GPU-accelerated transitions
   ============================================================ */

/* ── Google Fonts ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Instrument+Serif:ital@0;1&display=swap');

/* ── Design Tokens ────────────────────────────────────────── */
:root {
  /* Core palette */
  --ink:          #0C1220;
  --ink-soft:     #1A2435;
  --ink-mid:      #2D3A4E;
  --muted:        #64748B;
  --muted-light:  #94A3B8;
  --border:       #E8EDF2;
  --border-soft:  #F1F5F9;

  /* Brand */
  --accent:       #2563EB;
  --accent-hover: #1D4ED8;
  --accent-light: #EFF6FF;
  --gold:         #F59E0B;
  --gold-hover:   #D97706;
  --gold-light:   #FFFBEB;

  /* Status */
  --success:      #10B981;
  --success-light:#ECFDF5;
  --danger:       #EF4444;
  --danger-light: #FEF2F2;
  --warning:      #F97316;
  --warning-light:#FFF7ED;
  --info:         #06B6D4;
  --info-light:   #ECFEFF;

  /* Surfaces */
  --surface:      #F8FAFC;
  --white:        #FFFFFF;

  /* Sidebar */
  --sidebar-bg:   #0C1220;
  --sidebar-w:    248px;
  --sidebar-w-collapsed: 0px;

  /* Layout */
  --topbar-h:     56px;
  --radius:       10px;
  --radius-sm:    7px;
  --radius-lg:    14px;

  /* Shadows — layered for depth */
  --shadow-xs: 0 1px 2px rgba(12,18,32,.05);
  --shadow-sm: 0 1px 4px rgba(12,18,32,.06), 0 2px 8px rgba(12,18,32,.04);
  --shadow:    0 4px 16px rgba(12,18,32,.08), 0 1px 4px rgba(12,18,32,.04);
  --shadow-lg: 0 8px 32px rgba(12,18,32,.12), 0 2px 8px rgba(12,18,32,.06);
  --shadow-xl: 0 20px 60px rgba(12,18,32,.16), 0 4px 16px rgba(12,18,32,.08);

  /* Typography */
  --font-body:    'Plus Jakarta Sans', -apple-system, sans-serif;
  --font-display: 'Instrument Serif', Georgia, serif;

  /* Transitions */
  --t-fast:   0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --t-base:   0.2s  cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow:   0.3s  cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ── SIDEBAR ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--t-slow);
  overflow: hidden;

  /* Subtle texture */
  background-image:
    radial-gradient(ellipse at 0% 0%, rgba(37,99,235,.12) 0%, transparent 60%),
    radial-gradient(ellipse at 100% 100%, rgba(245,158,11,.06) 0%, transparent 50%);
}

/* Brand */
.sidebar-brand {
  padding: 18px 20px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}

.brand-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--gold), #D97706);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(245,158,11,.4);
}

.sidebar-brand span {
  font-size: 15px;
  color: rgba(255,255,255,.6);
  font-weight: 400;
  letter-spacing: .01em;
}
.sidebar-brand b { color: var(--white); font-weight: 700; }

/* Nav */
.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.nav-section-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.25);
  padding: 14px 10px 5px;
  user-select: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.55);
  text-decoration: none;
  font-size: 13px;
  font-weight: 400;
  transition: background var(--t-fast), color var(--t-fast);
  margin-bottom: 1px;
  position: relative;
  white-space: nowrap;
}

.nav-item svg {
  width: 16px; height: 16px;
  fill: currentColor;
  flex-shrink: 0;
  opacity: .8;
}

.nav-item:hover {
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.9);
}

.nav-item.active {
  background: rgba(245,158,11,.14);
  color: var(--gold);
  font-weight: 500;
}

.nav-item.active svg { opacity: 1; }

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 2.5px;
  background: var(--gold);
  border-radius: 0 2px 2px 0;
}

/* Sidebar user */
.sidebar-user {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.user-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), #7C3AED);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  color: var(--white);
  flex-shrink: 0;
  letter-spacing: -.01em;
}

.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: 12.5px; font-weight: 600;
  color: var(--white);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role { font-size: 11px; color: rgba(255,255,255,.35); text-transform: capitalize; }

.logout-btn { color: rgba(255,255,255,.3); transition: color var(--t-fast); flex-shrink: 0; }
.logout-btn:hover { color: var(--danger); }

/* ── MAIN WRAP ────────────────────────────────────────────── */
.main-wrap {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--t-slow);
}

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

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background var(--t-fast), color var(--t-fast);
}
.sidebar-toggle:hover { background: var(--surface); color: var(--ink); }

.topbar-title {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--ink);
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted-light);
}

.badge-live {
  font-size: 11px;
  color: var(--success);
  font-weight: 600;
  display: flex; align-items: center; gap: 4px;
}

.badge-live::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--success);
  border-radius: 50%;
  display: inline-block;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .6; transform: scale(.85); }
}

/* ── PAGE CONTENT ─────────────────────────────────────────── */
.page-content { padding: 22px 24px; flex: 1; }

/* ── FLASH MESSAGES ───────────────────────────────────────── */
.flash {
  margin: 12px 24px 0;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 500;
  animation: slide-down .2s ease-out;
}

@keyframes slide-down {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.flash button { background: none; border: none; cursor: pointer; font-size: 16px; opacity: .6; }
.flash button:hover { opacity: 1; }

.flash-success { background: var(--success-light); color: #065F46; border: 1px solid #A7F3D0; }
.flash-error   { background: var(--danger-light);  color: #991B1B; border: 1px solid #FECACA; }
.flash-warning { background: var(--warning-light); color: #92400E; border: 1px solid #FED7AA; }
.flash-info    { background: var(--accent-light);  color: #1E40AF; border: 1px solid #BFDBFE; }

/* ── CARDS ────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.card-body { padding: 20px; }

/* ── METRIC CARDS ─────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.metric-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
  transition: transform var(--t-base), box-shadow var(--t-base);
}

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

.metric-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  border-radius: var(--radius) var(--radius) 0 0;
}
.metric-card.gold::before   { background: linear-gradient(90deg, var(--gold), #FCD34D); }
.metric-card.green::before  { background: linear-gradient(90deg, var(--success), #6EE7B7); }
.metric-card.red::before    { background: linear-gradient(90deg, var(--danger), #FCA5A5); }
.metric-card.purple::before { background: linear-gradient(90deg, #7C3AED, #A78BFA); }

.metric-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted-light);
  margin-bottom: 7px;
}

.metric-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.15;
  font-family: var(--font-display);
  letter-spacing: -.02em;
}

.metric-sub   { font-size: 12px; color: var(--muted); margin-top: 3px; }
.metric-change { font-size: 12px; margin-top: 5px; font-weight: 500; }
.metric-change.up   { color: var(--success); }
.metric-change.down { color: var(--danger); }

/* ── DASHBOARD GRID ───────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
.dashboard-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}

/* ── TABLES ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  padding: 9px 14px;
  background: var(--surface);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--ink);
  vertical-align: middle;
  transition: background var(--t-fast);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #FAFBFD; }

.text-right  { text-align: right; }
.text-center { text-align: center; }

/* ── BADGES ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}

.badge-segment { color: var(--white); }

/* Role badges */
.badge-superadmin { background: linear-gradient(135deg, #7C3AED, #5B21B6); color:#fff; }
.badge-admin      { background: linear-gradient(135deg, var(--accent), #1D4ED8); color:#fff; }
.badge-cs         { background: linear-gradient(135deg, var(--success), #059669); color:#fff; }
.badge-viewer     { background: #F1F5F9; color: var(--muted); }

/* Tier badges */
.tier-Platinum    { background: linear-gradient(135deg,#F59E0B,#D97706); color:#fff; }
.tier-Gold        { background: linear-gradient(135deg,#3B82F6,#2563EB); color:#fff; }
.tier-Silver      { background: linear-gradient(135deg,#10B981,#059669); color:#fff; }
.tier-Blue        { background: linear-gradient(135deg,#F97316,#EA580C); color:#fff; }
.tier-Hibernating { background: linear-gradient(135deg,#94A3B8,#64748B); color:#fff; }

/* Status badges */
.badge-draft     { background:#F1F5F9;      color:var(--muted); }
.badge-sent      { background:#D1FAE5;      color:#065F46; }
.badge-scheduled { background:var(--accent-light); color:var(--accent); }
.badge-failed    { background:#FEE2E2;      color:#991B1B; }

/* Channel badges */
.badge-wa    { background:#DCFCE7; color:#166534; }
.badge-email { background:var(--accent-light); color:var(--accent-hover); }
.badge-sms   { background:var(--warning-light); color:#92400E; }

/* ── FORMS ────────────────────────────────────────────────── */
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .05em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 8.5px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--ink);
  background: var(--white);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  outline: none;
  appearance: auto;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
  background: var(--white);
}

.form-control:hover:not(:focus) { border-color: #C4CDDA; }

textarea.form-control { resize: vertical; min-height: 100px; line-height: 1.6; }

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1.5px solid transparent;
  text-decoration: none;
  transition: all var(--t-fast);
  white-space: nowrap;
  line-height: 1;
  user-select: none;
}

.btn:active { transform: scale(.98); }
.btn svg { width: 14px; height: 14px; fill: currentColor; flex-shrink: 0; }

.btn-primary { background: var(--ink); color: var(--white); }
.btn-primary:hover { background: var(--ink-soft); }

.btn-accent  { background: var(--accent); color: var(--white); box-shadow: 0 1px 4px rgba(37,99,235,.3); }
.btn-accent:hover { background: var(--accent-hover); box-shadow: 0 2px 8px rgba(37,99,235,.4); }

.btn-gold    { background: var(--gold); color: var(--white); box-shadow: 0 1px 4px rgba(245,158,11,.3); }
.btn-gold:hover { background: var(--gold-hover); }

.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: #059669; }

.btn-danger  { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #DC2626; }

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--ink);
}
.btn-outline:hover { background: var(--surface); border-color: #C4CDDA; }

.btn-sm  { padding: 5px 12px; font-size: 12px; }
.btn-xs  { padding: 3px 8px;  font-size: 11px; border-radius: 5px; }

/* ── SEGMENT CARDS ────────────────────────────────────────── */
.segment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}

.segment-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: transform var(--t-base), box-shadow var(--t-base);
  cursor: default;
}

.segment-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

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

.segment-count {
  font-size: 30px;
  font-weight: 700;
  font-family: var(--font-display);
  line-height: 1;
  margin-bottom: 5px;
  letter-spacing: -.03em;
}

.segment-name {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.segment-pct { font-size: 11.5px; color: var(--muted-light); margin-top: 5px; }

/* ── COHORT TABLE ─────────────────────────────────────────── */
.cohort-table { font-size: 12px; }
.cohort-table th, .cohort-table td { padding: 7px 10px; }

.cohort-cell {
  padding: 5px 8px;
  border-radius: 5px;
  font-weight: 600;
  text-align: center;
  font-size: 11.5px;
}

/* ── PAGINATION ───────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.page-link {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: all var(--t-fast);
  border: 1px solid transparent;
}

.page-link:hover {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border);
}

.page-link.active {
  background: var(--ink);
  color: var(--white);
  border-color: var(--ink);
  font-weight: 600;
}

.page-info { flex: 1; text-align: right; font-size: 12px; color: var(--muted-light); }

/* ── MODAL ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(12,18,32,.55);
  backdrop-filter: blur(3px);
  z-index: 300;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-base);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-xl);
  transform: translateY(16px) scale(.99);
  transition: transform var(--t-base);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title  { font-size: 15px; font-weight: 600; }
.modal-close  {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 20px; line-height: 1;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; transition: all var(--t-fast);
}
.modal-close:hover { background: var(--surface); color: var(--ink); }
.modal-body   { padding: 22px; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ── SEARCH BAR ───────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.search-input-wrap { position: relative; flex: 1; min-width: 200px; max-width: 320px; }

.search-input-wrap input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: var(--white);
  color: var(--ink);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.search-input-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted-light);
  pointer-events: none;
}

/* ── RFM SCORE PILLS ──────────────────────────────────────── */
.rfm-scores { display: flex; gap: 3px; }

.rfm-pill {
  width: 25px; height: 25px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700;
  color: var(--white);
  letter-spacing: 0;
}

.rfm-r { background: var(--accent); }
.rfm-f { background: var(--success); }
.rfm-m { background: var(--gold); }

/* ── EMPTY STATE ──────────────────────────────────────────── */
.empty-state {
  padding: 56px 24px;
  text-align: center;
  color: var(--muted);
}

.empty-state svg {
  width: 44px; height: 44px;
  fill: var(--border);
  margin-bottom: 14px;
}

.empty-state p { font-size: 14px; line-height: 1.7; }

/* ── UTILS ────────────────────────────────────────────────── */
.flex            { display: flex; }
.items-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2           { gap: 8px; }
.gap-3           { gap: 12px; }
.mb-4            { margin-bottom: 16px; }
.mb-6            { margin-bottom: 24px; }
.text-muted      { color: var(--muted); }
.text-sm         { font-size: 12px; }
.font-bold       { font-weight: 700; }
.text-success    { color: var(--success); }
.text-danger     { color: var(--danger); }
.text-warning    { color: var(--warning); }
.truncate        { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── CHART CONTAINERS ─────────────────────────────────────── */
.chart-container { position: relative; display: block; width: 100%; }

/* ── OVERLAY (mobile sidebar) ─────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(12,18,32,.5);
  z-index: 190;
  backdrop-filter: blur(2px);
}

/* ── LOGIN PAGE ───────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(37,99,235,.12) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(245,158,11,.08) 0%, transparent 50%),
    var(--surface);
  padding: 20px;
}

.login-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-xl);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.login-logo .brand-icon {
  width: 38px; height: 38px;
  box-shadow: 0 3px 12px rgba(245,158,11,.4);
}

/* ── ALERTS / INLINE INFO ─────────────────────────────────── */
.alert {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 12px;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-light); color: #065F46; border-color: #A7F3D0; }
.alert-danger  { background: var(--danger-light);  color: #991B1B; border-color: #FECACA; }
.alert-warning { background: var(--warning-light); color: #92400E; border-color: #FED7AA; }
.alert-info    { background: var(--accent-light);  color: #1E40AF; border-color: #BFDBFE; }

/* ── MOBILE OVERLAY CLOSE ─────────────────────────────────── */
@media (max-width: 900px) {
  /* Show toggle, hide sidebar by default */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }
  .sidebar-overlay { display: block; opacity: 0; pointer-events: none; transition: opacity var(--t-slow); }
  .sidebar.open ~ .sidebar-overlay,
  body.sidebar-open .sidebar-overlay { opacity: 1; pointer-events: all; }

  .main-wrap {
    margin-left: 0;
  }

  .sidebar-toggle { display: flex; }

  /* Collapse grids to single column */
  .dashboard-grid,
  .dashboard-grid-3,
  .form-row,
  .form-row-3 {
    grid-template-columns: 1fr;
  }

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

  .page-content { padding: 16px; }
  .topbar { padding: 0 16px; }

  .search-bar { flex-direction: column; align-items: stretch; }
  .search-input-wrap { max-width: 100%; }
}

@media (max-width: 480px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .login-card { padding: 28px 20px; }
  .segment-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── PRINT ────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .sidebar-toggle, .btn, .pagination { display: none !important; }
  .main-wrap { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; }
}
