/* ═══════════════════════════════════════════════════════════════════════════
   NEXUS CRM — Complete Stylesheet
   Theme:  Industrial dark · molten amber accents
   Fonts:  Syne (display) · DM Sans (body) · DM Mono (data)
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

/* ── Custom Properties ───────────────────────────────────────────────────── */
:root {
  /* Backgrounds — layered depth */
  --bg-void:    #07090e;
  --bg-base:    #0c0f17;
  --bg-raised:  #111520;
  --bg-card:    #161c2b;
  --bg-hover:   #1b2233;
  --bg-input:   #0e111a;
  --bg-overlay: rgba(7, 9, 14, 0.75);

  /* Borders */
  --border:       #1d2438;
  --border-light: #273049;
  --border-focus: #f59e0b;

  /* Amber accent — the brand soul */
  --amber:        #f59e0b;
  --amber-bright: #fbbf24;
  --amber-muted:  #d97706;
  --amber-dim:    rgba(245, 158, 11, 0.12);
  --amber-glow:   rgba(245, 158, 11, 0.22);
  --amber-ring:   rgba(245, 158, 11, 0.35);

  /* Semantic colours */
  --emerald:     #10b981;
  --emerald-dim: rgba(16, 185, 129, 0.12);
  --rose:        #f43f5e;
  --rose-dim:    rgba(244, 63, 94, 0.12);
  --sky:         #38bdf8;
  --sky-dim:     rgba(56, 189, 248, 0.12);
  --violet:      #a78bfa;
  --violet-dim:  rgba(167, 139, 250, 0.12);
  --slate:       #64748b;

  /* Text hierarchy */
  --text-1:   #e2e8f5;   /* headings, primary values */
  --text-2:   #7d8fa8;   /* labels, secondary */
  --text-3:   #3d4d63;   /* muted, placeholders */
  --text-inv: #07090e;   /* on amber bg */

  /* Typography */
  --font-display: 'Syne',    sans-serif;
  --font-body:    'DM Sans', sans-serif;
  --font-mono:    'DM Mono', monospace;

  /* Radii */
  --r-xs: 3px;
  --r-sm: 6px;
  --r:    9px;
  --r-lg: 13px;
  --r-xl: 18px;
  --r-2xl: 24px;

  /* Layout */
  --sidebar-w:   248px;
  --header-h:    58px;
  --content-max: 1440px;

  /* Shadows */
  --shadow-sm: 0 1px 4px rgba(0,0,0,.4);
  --shadow:    0 4px 18px rgba(0,0,0,.5);
  --shadow-lg: 0 12px 48px rgba(0,0,0,.7);
  --shadow-amber: 0 0 0 3px var(--amber-ring);

  /* Easing */
  --ease:      150ms cubic-bezier(.4,0,.2,1);
  --ease-slow: 280ms cubic-bezier(.4,0,.2,1);
  --ease-spring: 420ms cubic-bezier(.34,1.56,.64,1);
}

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

html { height: 100%; font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-1);
  line-height: 1.55;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--amber); text-decoration: none; transition: color var(--ease); }
a:hover { color: var(--amber-bright); }

img, svg { display: block; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, select, textarea { font-family: inherit; }
ul, ol { list-style: none; }

::-webkit-scrollbar            { width: 5px; height: 5px; }
::-webkit-scrollbar-track      { background: transparent; }
::-webkit-scrollbar-thumb      { background: var(--border-light); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover{ background: var(--slate); }

/* ── Utility classes ─────────────────────────────────────────────────────── */
.hidden       { display: none !important; }
.w-full       { width: 100%; }
.text-sm      { font-size: 12px; }
.text-muted   { color: var(--text-2); }
.font-mono    { font-family: var(--font-mono); }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flex         { display: flex; }
.items-center { align-items: center; }
.gap-2        { gap: 8px; }
.gap-3        { gap: 12px; }
.gap-4        { gap: 16px; }
.mt-4         { margin-top: 16px; }
.mb-4         { margin-bottom: 16px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr;   gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }


/* ═══════════════════════════════════════════════════════════════════════════
   AUTH PAGE
   ═══════════════════════════════════════════════════════════════════════════ */
#auth-page {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-void);
  background-image:
    radial-gradient(ellipse 70% 55% at 50% 50%, var(--auth-glow-colour, rgba(245,158,11,.07)) 0%, transparent 70%);
  overflow: hidden;
}
#auth-page.hidden { display: none; }

/* Grid lines — full-screen, behind canvas */
#auth-page::before {
  content: '';
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-image:
    linear-gradient(var(--auth-grid-colour, rgba(255,255,255,0.06)) 1px, transparent 1px),
    linear-gradient(90deg, var(--auth-grid-colour, rgba(255,255,255,0.06)) 1px, transparent 1px);
  background-size: var(--auth-grid-size, 48px) var(--auth-grid-size, 48px);
  opacity: var(--auth-grid-opacity, 0.35);
  pointer-events: none;
  z-index: 0;
}

.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 44px 40px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,.03);
  animation: auth-rise .5s var(--ease-spring) both;
}

@keyframes auth-rise {
  from { opacity: 0; transform: translateY(24px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)  scale(1); }
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 36px;
}

.auth-logo-icon {
  width: 75px;
  height: 75px;
  background: var(--amber);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 19px;
  color: var(--text-inv);
  box-shadow: 0 4px 16px var(--amber-glow);
  padding: 10px;
}

img {
  display: flex;
  width: 65px;
  height: 65px;
  min-width: 60px;
  min-height: 60px;
  padding: 10px 10px 10px 10px;
}

.auth-logo-text {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -.02em;
  display: block;
  overflow-wrap: break-word;
  white-space: nowrap;
  line-height: 30px;
}
.auth-logo-text span { color: var(--amber); }

.auth-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 28px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   APP SHELL — CSS Grid layout
   ═══════════════════════════════════════════════════════════════════════════ */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  height: 100vh;
  overflow: hidden;
  transition: grid-template-columns var(--ease-slow);
}

#app.sidebar-collapsed {
  --sidebar-w: 60px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════════════════════ */
#header {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0px 5px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 200;
}

/* Logo block */
.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(var(--sidebar-w) - 32px);
  overflow: hidden;
  flex-shrink: 0;
  transition: width var(--ease-slow);
}

.logo-icon {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  background: var(--amber);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  color: var(--text-inv);
  box-shadow: 0 2px 8px var(--amber-glow);
}

.logo-text {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-1);
  white-space: nowrap;
  letter-spacing: -.02em;
}
.logo-text span { color: var(--amber); }

/* Sidebar toggle */
#btn-toggle-sidebar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--text-2);
  border-radius: var(--r-sm);
  transition: color var(--ease), background var(--ease);
}
#btn-toggle-sidebar:hover {
  color: var(--text-1);
  background: var(--bg-hover);
}

/* Global search */
.header-search {
  flex: 1;
  max-width: 400px;
  position: relative;
}

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

.header-search input {
  width: 100%;
  height: 34px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text-1);
  font-size: 13px;
  padding: 0 12px 0 32px;
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.header-search input::placeholder { color: var(--text-3); }
.header-search input:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-amber);
}

/* Search results dropdown */
.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  overflow: hidden;
  max-height: 400px;
  overflow-y: auto;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background var(--ease);
  font-size: 13px;
}
.search-result-item:hover { background: var(--bg-hover); }

.search-result-type {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: var(--r-xs);
  background: var(--amber-dim);
  color: var(--amber);
  flex-shrink: 0;
}

/* Header right-side actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

/* WS status dot */
.ws-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
  transition: background var(--ease), box-shadow var(--ease);
  flex-shrink: 0;
}
.ws-indicator.connected {
  background: var(--emerald);
  box-shadow: 0 0 8px rgba(16,185,129,.5);
}
.ws-indicator.error { background: var(--rose); }

/* Avatar */
.header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border-light);
  background: var(--amber-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--amber);
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--ease);
  flex-shrink: 0;
}
.header-avatar:hover { border-color: var(--amber); }
.header-avatar img { width: 100%; height: 100%; object-fit: cover; }


/* ═══════════════════════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════════════════════ */
#sidebar {
  grid-column: 1;
  grid-row: 2;
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 10px 0 16px;
  overflow: hidden;
  overflow-y: auto;
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  max-width: var(--sidebar-w);
  transition: width var(--ease-slow), min-width var(--ease-slow), max-width var(--ease-slow);
}

.nav-section-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 16px 16px 5px;
  white-space: nowrap;
  transition: opacity var(--ease-slow);
}
#app.sidebar-collapsed .nav-section-label { opacity: 0; pointer-events: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--text-2);
  font-size: 13.5px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: color var(--ease), background var(--ease), border-color var(--ease);
  user-select: none;
  white-space: nowrap;
  position: relative;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.nav-item:hover {
  color: var(--text-1);
  background: var(--bg-hover);
}

/* Collapsed sidebar: hover highlights appear/disappear instantly (no fade linger) */
#app.sidebar-collapsed .nav-item {
  transition: color var(--ease);  /* strip background from transition */
  width: 100%;                    /* constrain to sidebar width, not label content width */
  overflow: hidden;               /* clip label text so it can't push the item wider */
}
#app.sidebar-collapsed .nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-1);
}
#app.sidebar-collapsed .nav-item:not(:hover) {
  background: transparent;
}

.nav-item.active {
  color: var(--amber);
  background: var(--amber-dim);
  border-left-color: var(--amber);
}

.nav-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.nav-label {
  transition: opacity var(--ease-slow), transform var(--ease-slow);
}
#app.sidebar-collapsed .nav-label {
  opacity: 0;
  transform: translateX(-6px);
  pointer-events: none;
}

.nav-badge {
  margin-left: auto;
  background: var(--rose);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
  flex-shrink: 0;
  transition: opacity var(--ease-slow);
}
#app.sidebar-collapsed .nav-badge { opacity: 0; }

.nav-spacer { flex: 1; }


/* ═══════════════════════════════════════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════════════════════════════════════ */
#main-content {
  grid-column: 2;
  grid-row: 2;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 28px 28px 48px;
  background: var(--bg-base);
}

/* Page sections — only one visible at a time */
.page-section { animation: page-in .2s var(--ease) both; }

@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 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-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -.03em;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 3px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}


/* ═══════════════════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 14px;
  height: 34px;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  border: 1px solid transparent;
  transition: background var(--ease), border-color var(--ease),
              color var(--ease), box-shadow var(--ease), transform var(--ease);
  white-space: nowrap;
  cursor: pointer;
  outline: none;
  position: relative;
}
.btn:focus-visible { box-shadow: var(--shadow-amber); }
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* Variants */
.btn-primary {
  background: var(--amber);
  color: var(--text-inv);
  border-color: var(--amber);
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--amber-bright);
  border-color: var(--amber-bright);
  box-shadow: 0 4px 16px var(--amber-glow);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-1);
  border-color: var(--border-light);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-focus);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-1);
}

.btn-danger {
  background: var(--rose-dim);
  color: var(--rose);
  border-color: var(--rose);
}
.btn-danger:hover { background: var(--rose); color: #fff; }

/* Sizes */
.btn-sm  { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-icon { width: 34px; height: 34px; padding: 0; }
.btn-sm.btn-icon { width: 28px; height: 28px; }


/* ═══════════════════════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════════════════════ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -.01em;
}


/* ═══════════════════════════════════════════════════════════════════════════
   STAT CARDS
   ═══════════════════════════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px 16px;
  cursor: default;
  transition: border-color var(--ease), transform var(--ease), box-shadow var(--ease);
  position: relative;
  overflow: hidden;
}

/* Subtle top-edge accent */
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--amber) 0%, transparent 100%);
  opacity: 0;
  transition: opacity var(--ease);
}

.stat-card[data-navigate] { cursor: pointer; }
.stat-card[data-navigate]:hover,
.stat-card:hover { border-color: var(--border-light); transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card[data-navigate]:hover::before { opacity: 1; }

.stat-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1;
  letter-spacing: -.03em;
}

.stat-label {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 5px;
}

.stat-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 500;
  margin-top: 8px;
  min-height: 16px;
}
.stat-delta.up   { color: var(--emerald); }
.stat-delta.down { color: var(--rose); }


/* ═══════════════════════════════════════════════════════════════════════════
   DASHBOARD LAYOUT
   ═══════════════════════════════════════════════════════════════════════════ */
.dashboard-charts {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  margin-bottom: 16px;
}

.dashboard-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Funnel bars */
#funnel-container { display: flex; flex-direction: column; gap: 10px; }

.funnel-row { display: flex; flex-direction: column; gap: 5px; }

.funnel-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-2);
}

.funnel-bar-track {
  height: 8px;
  background: var(--bg-hover);
  border-radius: 99px;
  overflow: hidden;
}

.funnel-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}

/* Top performers list */
.performer-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.performer-row:last-child { border-bottom: none; }

.performer-rank {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  width: 18px;
  flex-shrink: 0;
  text-align: center;
}
.performer-rank.gold { color: var(--amber); }

.performer-info { flex: 1; min-width: 0; }
.performer-name { font-size: 13px; font-weight: 500; }
.performer-sub  { font-size: 11px; color: var(--text-2); margin-top: 1px; }

.performer-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--amber);
  flex-shrink: 0;
}

/* Activity legend */
#activity-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--text-2);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Pipeline stats */
.pipeline-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pipeline-stat-value {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -.03em;
}
.pipeline-stat-label { font-size: 12px; color: var(--text-2); }

/* Chart containers */
.chart-container {
  position: relative;
  width: 100%;
  min-height: 200px;
}
.chart-container canvas { max-width: 100%; }


/* ═══════════════════════════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════════════════════════ */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

table { width: 100%; border-collapse: collapse; }

thead th {
  padding: 9px 14px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-3);
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

thead th input[type="checkbox"] { margin: 0; cursor: pointer; accent-color: var(--amber); }

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

tbody td {
  padding: 11px 14px;
  font-size: 13px;
  color: var(--text-1);
  vertical-align: middle;
}

tbody td input[type="checkbox"] { cursor: pointer; accent-color: var(--amber); }

/* Row action buttons — hidden until hover */
.row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--ease);
}
tr:hover .row-actions { opacity: 1; }

/* Pagination */
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-2);
  flex-wrap: wrap;
  gap: 8px;
}

.page-btn {
  height: 28px;
  min-width: 28px;
  padding: 0 8px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.page-btn:hover { background: var(--bg-card); color: var(--text-1); border-color: var(--border-light); }
.page-btn.active {
  background: var(--amber-dim);
  color: var(--amber);
  border-color: var(--amber);
  font-weight: 600;
}
.page-btn:disabled { opacity: .4; cursor: not-allowed; }


/* ═══════════════════════════════════════════════════════════════════════════
   BADGES / STATUS PILLS
   ═══════════════════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.4;
}

.badge-amber   { background: var(--amber-dim);   color: var(--amber); }
.badge-emerald { background: var(--emerald-dim); color: var(--emerald); }
.badge-rose    { background: var(--rose-dim);    color: var(--rose); }
.badge-sky     { background: var(--sky-dim);     color: var(--sky); }
.badge-violet  { background: var(--violet-dim);  color: var(--violet); }
.badge-muted   { background: rgba(255,255,255,.05); color: var(--text-2); }

/* Lead score bar pill */
.score-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-family: var(--font-mono);
}
.score-track {
  width: 48px;
  height: 4px;
  background: var(--bg-hover);
  border-radius: 99px;
  overflow: hidden;
}
.score-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .5s;
}


/* ═══════════════════════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════════════════════ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}
.form-group:last-child { margin-bottom: 0; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: .03em;
}
.form-label.required::after { content: ' *'; color: var(--rose); }

.form-input,
.form-select,
.form-textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text-1);
  font-size: 13px;
  font-family: var(--font-body);
  padding: 8px 11px;
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
  width: 100%;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-amber);
}

.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-3); }

.form-input.error,
.form-select.error,
.form-textarea.error { border-color: var(--rose); }

/* Custom select chevron */
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%233d4d63' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}
.form-select option { background: var(--bg-card); color: var(--text-1); }

.form-textarea { resize: vertical; min-height: 76px; line-height: 1.5; }

.form-error {
  font-size: 11px;
  color: var(--rose);
  display: none;
}
.form-error.visible,
.form-error:not(:empty) { display: block; }


/* ═══════════════════════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: var(--bg-overlay);
  backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ease-slow);
}
.modal-overlay.open {
  display: flex;
  opacity: 1;
  pointer-events: all;
}

.modal {
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,.03);
  overflow-y: auto;
  transform: translateY(20px) scale(.97);
  transition: transform var(--ease-slow);
}
.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 10;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -.02em;
}

.modal-close {
  color: var(--text-2);
  transition: color var(--ease);
}
.modal-close:hover { color: var(--text-1); }

.modal-body { padding: 20px 24px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: var(--bg-card);
}


/* ═══════════════════════════════════════════════════════════════════════════
   DROPDOWN MENUS
   ═══════════════════════════════════════════════════════════════════════════ */
.dropdown-menu {
  position: fixed;
  z-index: 600;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  overflow: hidden;
  animation: dropdown-in .15s var(--ease) both;
}

@keyframes dropdown-in {
  from { opacity: 0; transform: scale(.95) translateY(-6px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}

.dropdown-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text-1);
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
  text-align: left;
  background: none;
  border: none;
}
.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item.danger { color: var(--rose); }
.dropdown-item.danger:hover { background: var(--rose-dim); }

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}


/* ═══════════════════════════════════════════════════════════════════════════
   PIPELINE / KANBAN BOARD
   ═══════════════════════════════════════════════════════════════════════════ */
.pipeline-board {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 20px;
  align-items: flex-start;
}

.pipeline-column {
  flex-shrink: 0;
  width: 272px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pipeline-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: var(--r);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-left: 3px solid var(--stage-color, var(--amber));
}

.column-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}

.column-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-2);
  font-family: var(--font-mono);
}

/* Drop zone */
.pipeline-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 64px;
  padding: 4px 0;
  border-radius: var(--r);
  transition: background var(--ease);
}
.pipeline-cards.drag-over {
  background: var(--amber-dim);
  outline: 2px dashed var(--amber);
  outline-offset: -2px;
}

/* Deal card */
.deal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px;
  cursor: grab;
  transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
  user-select: none;
  position: relative;
}
.deal-card::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: var(--r) 0 0 var(--r);
  background: var(--stage-color, var(--amber));
  opacity: 0;
  transition: opacity var(--ease);
}
.deal-card:hover { border-color: var(--border-light); box-shadow: var(--shadow); transform: translateY(-1px); }
.deal-card:hover::after { opacity: 1; }
.deal-card.dragging { opacity: .45; cursor: grabbing; box-shadow: var(--shadow-lg); }

.deal-card-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
  margin-bottom: 8px;
  line-height: 1.35;
}

.deal-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-2);
}

.deal-card-value {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--amber);
}

.deal-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-2);
}

/* Add deal button in column */
.btn-add-deal-to-col {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 32px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--r);
  color: var(--text-3);
  font-size: 12px;
  cursor: pointer;
  transition: border-color var(--ease), color var(--ease), background var(--ease);
}
.btn-add-deal-to-col:hover {
  border-color: var(--amber);
  color: var(--amber);
  background: var(--amber-dim);
}


/* ═══════════════════════════════════════════════════════════════════════════
   TABS
   ═══════════════════════════════════════════════════════════════════════════ */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--ease), border-color var(--ease);
  white-space: nowrap;
  font-family: var(--font-body);
}
.tab:hover { color: var(--text-1); }
.tab.active {
  color: var(--amber);
  border-bottom-color: var(--amber);
}


/* ═══════════════════════════════════════════════════════════════════════════
   REPORTS
   ═══════════════════════════════════════════════════════════════════════════ */
.report-panel { animation: page-in .2s var(--ease) both; }


/* ═══════════════════════════════════════════════════════════════════════════
   SETTINGS
   ═══════════════════════════════════════════════════════════════════════════ */
.settings-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  align-items: start;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 8px;
  position: sticky;
  top: 0;
}

.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  background: none;
  border: none;
  text-align: left;
  font-family: var(--font-body);
  transition: color var(--ease), background var(--ease);
}
.settings-nav-item:hover { color: var(--text-1); background: var(--bg-hover); }
.settings-nav-item.active { color: var(--amber); background: var(--amber-dim); }

.settings-content { min-width: 0; }

.settings-panel { animation: page-in .2s var(--ease) both; }

.settings-section-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -.02em;
  margin-bottom: 4px;
}

.settings-section-desc {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 24px;
}

/* Users list in settings */
.user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.user-row:last-child { border-bottom: none; }

.user-row-info { flex: 1; min-width: 0; }
.user-row-name { font-size: 13px; font-weight: 500; }
.user-row-email { font-size: 11px; color: var(--text-2); margin-top: 2px; }

/* Pipeline settings list */
.pipeline-settings-row {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.pipeline-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.pipeline-settings-name {
  font-weight: 600;
  font-size: 14px;
}
.pipeline-stages-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.stage-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-2);
}
.stage-chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

/* Notification preferences */
.notification-prefs { display: flex; flex-direction: column; gap: 0; }

.notif-pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.notif-pref-row:last-child { border-bottom: none; }
.notif-pref-row strong { font-size: 13px; font-weight: 500; display: block; margin-bottom: 2px; }

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--bg-hover);
  border: 1px solid var(--border-light);
  border-radius: 99px;
  transition: background var(--ease), border-color var(--ease);
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-3);
  transition: transform var(--ease-spring), background var(--ease);
}
.toggle input:checked ~ .toggle-track {
  background: var(--amber-dim);
  border-color: var(--amber);
}
.toggle input:checked ~ .toggle-track::after {
  transform: translateX(18px);
  background: var(--amber);
}

/* Pipeline stage builder */
.stage-builder-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 6px;
}
.stage-builder-row input[type="text"] { min-width: 0; }
.stage-builder-color {
  width: 28px;
  height: 28px;
  padding: 2px;
  border-radius: var(--r-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  cursor: pointer;
}
.stage-builder-check {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
}

/* Detail drawer */
.detail-tab-panel { animation: page-in .18s var(--ease) both; }

.detail-field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.detail-field {
  padding: 0;
 }
.detail-field-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 4px;
}
.detail-field-value {
  font-size: 13px;
  color: var(--text-1);
}

.activity-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }

.activity-type-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--amber-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.activity-item-body { flex: 1; min-width: 0; }
.activity-item-title { font-size: 13px; font-weight: 500; }
.activity-item-meta  { font-size: 11px; color: var(--text-2); margin-top: 2px; }

.note-item {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 14px;
  margin-bottom: 8px;
  position: relative;
}
.note-item.pinned { border-color: var(--amber); }
.note-item.pinned::before {
  content: '📌';
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 13px;
}
.note-content { font-size: 13px; line-height: 1.6; white-space: pre-wrap; }
.note-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-2);
}

.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 6px;
}
.file-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: var(--amber-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--amber);
  flex-shrink: 0;
}
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 13px; font-weight: 500; }
.file-size { font-size: 11px; color: var(--text-2); font-family: var(--font-mono); }


/* ═══════════════════════════════════════════════════════════════════════════
   LOADING STATES
   ═══════════════════════════════════════════════════════════════════════════ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-raised) 25%,
    var(--bg-hover)  50%,
    var(--bg-raised) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
  border-radius: var(--r);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-light);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin .65s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Full-page loader */
.page-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 80px 20px;
  color: var(--text-2);
  font-size: 13px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════════════════ */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  pointer-events: all;
  max-width: 360px;
  animation: toast-in .3s var(--ease-spring) both;
}
.toast.hiding { animation: toast-out .25s var(--ease) forwards; }

.toast-icon {
  font-size: 15px;
  flex-shrink: 0;
  line-height: 1.4;
}
.toast-body { flex: 1; min-width: 0; }
.toast-msg  { color: var(--text-1); line-height: 1.4; }
.toast-close {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
  line-height: 1;
  transition: color var(--ease);
}
.toast-close:hover { color: var(--text-1); }

.toast-success { border-left: 3px solid var(--emerald); }
.toast-error   { border-left: 3px solid var(--rose); }
.toast-info    { border-left: 3px solid var(--sky); }
.toast-warn    { border-left: 3px solid var(--amber); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px) scale(.95); }
  to   { opacity: 1; transform: translateX(0)   scale(1); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0)   scale(1); max-height: 80px; }
  to   { opacity: 0; transform: translateX(16px) scale(.95); max-height: 0; padding: 0; margin: 0; }
}


/* ═══════════════════════════════════════════════════════════════════════════
   AVATAR HELPERS
   ═══════════════════════════════════════════════════════════════════════════ */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  background: var(--amber-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--amber);
  flex-shrink: 0;
  font-family: var(--font-display);
  border: 1px solid var(--border);
}
.avatar-sm { width: 26px; height: 26px; font-size: 10px; }
.avatar-md { width: 34px; height: 34px; font-size: 13px; }
.avatar-lg { width: 48px; height: 48px; font-size: 17px; }


/* ═══════════════════════════════════════════════════════════════════════════
   EMPTY STATES
   ═══════════════════════════════════════════════════════════════════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-2);
}

.empty-icon {
  color: var(--text-3);
  margin-bottom: 16px;
  opacity: .6;
}

.empty-state h3 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 20px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   PROGRESS BARS
   ═══════════════════════════════════════════════════════════════════════════ */
.progress-bar {
  height: 5px;
  background: var(--bg-hover);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--amber);
  transition: width .5s cubic-bezier(.4,0,.2,1);
}


/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1200px) {
  .dashboard-charts { grid-template-columns: 1fr; }
  .dashboard-bottom { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { flex-direction: row; overflow-x: auto; position: static; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .detail-field-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  #app { grid-template-columns: 0 1fr; }
  #app.mobile-open { grid-template-columns: 0 1fr; }  /* fixed overlay — grid stays 0 1fr */

  /* Release the width cage we set on #sidebar for desktop — mobile uses position:fixed */
  #sidebar {
    width: 264px;
    min-width: 0;
    max-width: none;
    transition: transform .28s cubic-bezier(.4, 0, .2, 1), box-shadow .28s ease;
  }

  #main-content { padding: 16px 16px 40px; }

  .page-title { font-size: 20px; }

  .form-row { grid-template-columns: 1fr; }

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

  .header-search { display: none; }

  .table-toolbar { gap: 6px; }

  .modal { border-radius: var(--r-lg); }
  .modal-body { padding: 16px 18px; }
  .modal-header { padding: 16px 18px 12px; }
  .modal-footer { padding: 12px 18px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .auth-card { padding: 32px 24px; }
}


/* ═══════════════════════════════════════════════════════════════════════════
   MISC POLISH
   ═══════════════════════════════════════════════════════════════════════════ */

/* Focus ring */
:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* Selection */
::selection {
  background: var(--amber-dim);
  color: var(--text-1);
}

/* Monospace numbers in table cells */
td .mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

/* Clickable table row */
tr.clickable { cursor: pointer; }

/* Right-align numeric columns */
.col-number { text-align: right; font-family: var(--font-mono); font-size: 12px; }

/* Inline dot separator */
.dot-sep {
  display: inline-block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-3);
  vertical-align: middle;
  margin: 0 5px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   IMPORT / EXPORT  —  Settings panel
   ═══════════════════════════════════════════════════════════════════════════ */

.import-export-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  padding: 20px 22px;
}

.ie-section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  color: var(--text-1);
}

.ie-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.ie-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 28px 20px;
  border: 2px dashed var(--border-light);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color .18s, background .18s;
  text-align: center;
  color: var(--text-2);
  font-size: 13px;
}
.ie-dropzone:hover,
.ie-dropzone.drag-over {
  border-color: var(--amber);
  background: rgba(245,158,11,.04);
}

/* ═══════════════════════════════════════════════════════════════════════════
   APPEARANCE / CUSTOMISATION  —  Settings panel
   ═══════════════════════════════════════════════════════════════════════════ */

.appearance-preview-wrap {
  position: relative;
  margin-bottom: 24px;
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--bg-void);
}

.appearance-section {
  margin-bottom: 22px;
}

.appearance-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-2);
  margin: 0 0 10px;
}

/* Colour swatches */
.colour-swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .15s, border-color .15s;
  flex-shrink: 0;
}
.swatch:hover  { transform: scale(1.15); }
.swatch.active { border-color: var(--text-1); transform: scale(1.1); }

.swatch-custom {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  padding: 0;
  background: none;
  cursor: pointer;
  overflow: hidden;
}

/* Theme previews */
.theme-options {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 11px;
  color: var(--text-2);
  transition: color .15s;
  padding: 6px;
  border-radius: var(--r-md);
  border: 2px solid transparent;
}
.theme-option:hover  { color: var(--text-1); }
.theme-option.active { border-color: var(--amber); color: var(--text-1); }

.theme-preview {
  width: 64px;
  height: 40px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}

.theme-preview-dark     { background: linear-gradient(135deg, #07090e 50%, #111827 100%); }
.theme-preview-midnight { background: linear-gradient(135deg, #020818 50%, #0b1535 100%); }
.theme-preview-slate    { background: linear-gradient(135deg, #0a0e14 50%, #1c2840 100%); }
.theme-preview-forest   { background: linear-gradient(135deg, #030c06 50%, #0d2018 100%); }
.theme-preview-light    { background: linear-gradient(135deg, #f8fafb 50%, #ffffff 100%); }

/* Font options */
.font-options { display: flex; gap: 8px; flex-wrap: wrap; }

.font-opt {
  padding: 6px 14px;
  border: 1px solid var(--border-light);
  border-radius: 99px;
  background: var(--bg-elevated);
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.font-opt:hover  { border-color: var(--amber); color: var(--text-1); }
.font-opt.active { border-color: var(--amber); color: var(--amber); background: rgba(245,158,11,.08); }

/* Density buttons */
.density-btn {
  padding: 6px 16px;
  border: 1px solid var(--border-light);
  border-radius: 99px;
  background: var(--bg-elevated);
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.density-btn:hover  { border-color: var(--amber); color: var(--text-1); }
.density-btn.active { border-color: var(--amber); color: var(--amber); background: rgba(245,158,11,.08); }
/* ── Auth page Three.js background ───────────────────────────────────────── */
#auth-bg-canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  pointer-events: none;
  z-index: 1;
}
.auth-card {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
}

/* ── Header logo canvas ───────────────────────────────────────────────────── */
.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
#header-logo-canvas {
  flex-shrink: 0;
}
#header-logo-text {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-1);
}
#header-logo-text span {
  color: var(--brand-primary, var(--amber));
  margin-left: 2px;
}

/* ── Branding preview canvas ──────────────────────────────────────────────── */
.appearance-preview-wrap {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--bg-void);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}
#brand-preview-canvas {
  display: block;
  width: 100% !important;
}

/* ── Brand colour swatches (reuse existing .swatch) ──────────────────────── */
#brand-colour-swatches,
#brand-secondary-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   BRANDING SYSTEM — data-attribute driven deep theme overrides
   Applied dynamically by Branding.js applyBranding()
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Density ────────────────────────────────────────────────────────────── */
body.density-compact  .stat-card       { padding: calc(12px * var(--density, 1)) calc(14px * var(--density, 1)); }
body.density-compact  .nav-item        { padding: 6px 14px; font-size: 13px; }
body.density-compact  .table-row td,
body.density-compact  .table-row th    { padding: 6px 12px; }
body.density-compact  .form-group      { margin-bottom: 10px; }
body.density-compact  .form-input,
body.density-compact  .form-select     { padding: 7px 10px; font-size: 13px; }
body.density-spacious .stat-card       { padding: 26px 28px 22px; }
body.density-spacious .nav-item        { padding: 12px 20px; font-size: 14px; }

/* ── Reduced motion ─────────────────────────────────────────────────────── */
body.reduced-motion *, body.reduced-motion *::before, body.reduced-motion *::after {
  animation-duration:   0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration:  0.01ms !important;
}

/* ── Card styles ────────────────────────────────────────────────────────── */
body[data-card-style="glass"] .stat-card,
body[data-card-style="glass"] .card {
  background: rgba(22, 28, 43, 0.6);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border-color: rgba(255,255,255,0.06);
}
body[data-card-glass="true"] .stat-card,
body[data-card-glass="true"] .card {
  background: rgba(22, 28, 43, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
body[data-card-style="flat"] .stat-card,
body[data-card-style="flat"] .card {
  box-shadow: none;
  border: 1px solid var(--border);
}
body[data-card-style="outline"] .stat-card,
body[data-card-style="outline"] .card {
  background: transparent;
  border: 1.5px solid var(--border-light);
  box-shadow: none;
}
body[data-card-style="elevated"] .stat-card,
body[data-card-style="elevated"] .card {
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 2px 8px rgba(0,0,0,0.4);
  border-color: transparent;
}

/* ── Stat card accent mode ─────────────────────────────────────────────── */
body[data-stat-accent="glow"] .stat-card::before      { opacity: 1 !important; }
body[data-stat-accent="bar"]  .stat-card::before      { height: 3px; opacity: 1 !important; background: var(--amber); }
body[data-stat-accent="border"] .stat-card            { border-left: 3px solid var(--amber); }
body[data-stat-accent="none"] .stat-card::before      { display: none; }

/* ── Badge shapes ───────────────────────────────────────────────────────── */
body[data-badge-shape="square"] .badge  { border-radius: var(--r-xs) !important; }
body[data-badge-shape="pill"]   .badge  { border-radius: 99px !important; }

/* ── Badge fill mode ────────────────────────────────────────────────────── */
body[data-badge-fill="ghost"] .badge {
  background: transparent !important;
  border: 1px solid currentColor;
}
body[data-badge-fill="outline"] .badge {
  background: transparent !important;
  border: 1.5px solid currentColor;
  font-weight: 600;
}

/* ── Button style ───────────────────────────────────────────────────────── */
body[data-btn-style="outline"] .btn-primary {
  background: transparent;
  border: 1.5px solid var(--amber);
  color: var(--amber);
}
body[data-btn-style="outline"] .btn-primary:hover {
  background: var(--amber-dim);
}
body[data-btn-style="ghost"] .btn-primary {
  background: transparent;
  color: var(--amber);
  box-shadow: none;
}
body[data-btn-style="ghost"] .btn-primary:hover {
  background: var(--amber-dim);
}

/* ── Table styles ───────────────────────────────────────────────────────── */
body[data-table-stripe="true"] .data-table tbody tr:nth-child(even),
body[data-table-stripe="true"] .table-body .table-row:nth-child(even) {
  background: rgba(255,255,255,0.015);
}
body[data-row-hover="glow"] .data-table tbody tr:hover,
body[data-row-hover="glow"] .table-row:hover {
  box-shadow: inset 0 0 0 1px var(--amber);
  background: var(--amber-dim);
}
body[data-row-hover="none"] .data-table tbody tr:hover,
body[data-row-hover="none"] .table-row:hover {
  background: inherit;
}

/* ── Chart colour schemes (applied via CSS vars read by Dashboard.js) ───── */
body[data-chart-scheme="warm"]  { --chart-1:#f59e0b; --chart-2:#f43f5e; --chart-3:#fb923c; --chart-4:#fbbf24; --chart-5:#f97316; }
body[data-chart-scheme="cool"]  { --chart-1:#38bdf8; --chart-2:#a78bfa; --chart-3:#34d399; --chart-4:#60a5fa; --chart-5:#2dd4bf; }
body[data-chart-scheme="mono"]  { --chart-1:#e2e8f5; --chart-2:#7d8fa8; --chart-3:#3d4d63; --chart-4:#1d2438; --chart-5:#64748b; }
body[data-chart-scheme="neon"]  { --chart-1:#00ffcc; --chart-2:#ff00aa; --chart-3:#ffee00; --chart-4:#00aaff; --chart-5:#ff6600; }
body[data-chart-scheme="brand"] { --chart-1:var(--brand-primary); --chart-2:var(--brand-secondary); --chart-3:var(--brand-accent); --chart-4:var(--emerald); --chart-5:var(--rose); }

/* ── Imported logo tint system ────────────────────────────────────────────── */
/* The SVG filter is injected by Branding.js and referenced here */
#header-logo-img {
  transition: filter var(--ease);
}
/* Tint overlays — driven by data-logo-tint-mode on body */
body[data-logo-tint="none"]       #header-logo-img { filter: none; }
body[data-logo-tint="colour"]     #header-logo-img { filter: var(--logo-tint-filter); }
body[data-logo-tint="greyscale"]  #header-logo-img { filter: grayscale(1) brightness(1.1); }
body[data-logo-tint="invert"]     #header-logo-img { filter: invert(1); }
body[data-logo-tint="sepia"]      #header-logo-img { filter: sepia(1) saturate(2) hue-rotate(var(--logo-hue-rotate, 0deg)); }
body[data-logo-tint="brand"]      #header-logo-img { filter: var(--logo-brand-filter); }

/* Auth card style variations */
body[data-auth-card="solid"]   .auth-card { background: var(--bg-card); backdrop-filter: none; }
body[data-auth-card="glass"]   .auth-card {
  background: rgba(22,28,43,0.55);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border-color: rgba(255,255,255,0.08);
}
body[data-auth-card="dark"]    .auth-card { background: var(--bg-void); border-color: var(--border-light); }
body[data-auth-card="outline"] .auth-card {
  background: transparent;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid var(--amber);
}
body[data-auth-card="minimal"] .auth-card { background: transparent; border-color: transparent; box-shadow: none; }