/* ============================================================
   Nexus CRM — Main Stylesheet
   Clean, modern, mobile-first design
   ============================================================ */

:root {
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --primary-light: #eff6ff;
  --success:       #16a34a;
  --success-light: #f0fdf4;
  --warning:       #d97706;
  --warning-light: #fffbeb;
  --danger:        #dc2626;
  --danger-light:  #fef2f2;
  --info:          #0891b2;
  --info-light:    #ecfeff;

  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  --sidebar-w:    240px;
  --header-h:     56px;
  --radius:       8px;
  --radius-sm:    4px;
  --shadow:       0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:    0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --transition:   150ms ease;
  --font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ============================================================
   LAYOUT
   ============================================================ */

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

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--gray-900);
  color: var(--gray-300);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition);
}

.sidebar-brand {
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .brand-name {
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.5px;
}
.sidebar-brand .brand-tag {
  font-size: .65rem;
  color: var(--gray-500);
  margin-top: .1rem;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.sidebar-nav { flex: 1; padding: .75rem 0; }

.nav-section-label {
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gray-600);
  padding: .9rem 1rem .3rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem 1rem;
  color: var(--gray-400);
  font-size: .875rem;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(37,99,235,.25); color: #fff; border-right: 3px solid var(--primary); }
.nav-item .nav-icon { width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: .75rem 1rem;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: .8rem;
  color: var(--gray-600);
}
.sidebar-user { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.sidebar-avatar {
  width: 30px; height: 30px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

/* ---- Main content ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- Top bar ---- */
.topbar {
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.topbar-right { display: flex; align-items: center; gap: .75rem; }
.topbar-title { font-weight: 600; color: var(--gray-700); font-size: .95rem; }

/* Impersonation banner */
.impersonate-banner {
  background: var(--warning);
  color: #fff;
  text-align: center;
  padding: .4rem 1rem;
  font-size: .8rem;
  font-weight: 500;
}
.impersonate-banner a { color: #fff; font-weight: 700; text-decoration: underline; }

/* ---- Page content ---- */
.page-content {
  padding: 1.5rem;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: .75rem;
}
.page-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--gray-900);
}
.page-header-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.card-header {
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.card-header h2, .card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
}
.card-body { padding: 1.25rem; }
.card-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ============================================================
   STATS ROW
   ============================================================ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
}
.stat-label { font-size: .75rem; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--gray-900); margin-top: .2rem; line-height: 1.2; }
.stat-sub   { font-size: .75rem; color: var(--gray-400); margin-top: .15rem; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-success   { background: var(--success); color: #fff; border-color: var(--success); }
.btn-danger    { background: var(--danger);  color: #fff; border-color: var(--danger); }
.btn-warning   { background: var(--warning); color: #fff; border-color: var(--warning); }

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

.btn-ghost     { background: transparent; color: var(--gray-600); border-color: var(--gray-300); }
.btn-ghost:hover { background: var(--gray-100); }

.btn-sm  { padding: .3rem .7rem; font-size: .8rem; }
.btn-lg  { padding: .7rem 1.4rem; font-size: 1rem; }
.btn-icon { padding: .4rem; }

/* ============================================================
   FORMS
   ============================================================ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-full   { grid-column: 1 / -1; }

.form-group { margin-bottom: 1rem; position: relative; }
.form-group label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: .35rem;
}
.form-group label .required { color: var(--danger); margin-left: .2rem; }

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="url"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--gray-800);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: var(--font);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-group textarea { min-height: 100px; resize: vertical; }
.form-group select { cursor: pointer; }

.form-hint {
  font-size: .75rem;
  color: var(--gray-500);
  margin-top: .3rem;
  display: block;
}
.form-error {
  font-size: .75rem;
  color: var(--danger);
  margin-top: .3rem;
  display: block;
}

/* Checkbox / radio */
.form-check {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  color: var(--gray-700);
  cursor: pointer;
}
.form-check input { width: 16px; height: 16px; cursor: pointer; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  text-align: left;
  padding: .65rem 1rem;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
tbody td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .55rem;
  border-radius: 99px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .3px;
  white-space: nowrap;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-info    { background: var(--info-light);    color: var(--info); }
.badge-muted   { background: var(--gray-100);      color: var(--gray-600); }

/* ============================================================
   FLASH MESSAGES
   ============================================================ */
.flash {
  padding: .75rem 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: .875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.flash-success { background: var(--success-light); color: var(--success); border: 1px solid #bbf7d0; }
.flash-error   { background: var(--danger-light);  color: var(--danger);  border: 1px solid #fecaca; }
.flash-warning { background: var(--warning-light); color: var(--warning); border: 1px solid #fde68a; }
.flash-info    { background: var(--info-light);    color: var(--info);    border: 1px solid #a5f3fc; }

/* ============================================================
   KANBAN BOARD
   ============================================================ */
.kanban-wrap {
  overflow-x: auto;
  padding-bottom: 1rem;
}
.kanban-board {
  display: flex;
  gap: .75rem;
  min-width: max-content;
  align-items: flex-start;
}
.kanban-col {
  width: 230px;
  flex-shrink: 0;
  background: var(--gray-100);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
}
.kanban-col-header {
  padding: .65rem .85rem;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gray-600);
  background: var(--gray-200);
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kanban-col-header.won  { background: var(--success-light); color: var(--success); }
.kanban-col-header.lost { background: var(--danger-light);  color: var(--danger); }

.col-count {
  background: rgba(0,0,0,.1);
  border-radius: 99px;
  padding: .1rem .45rem;
  font-size: .7rem;
}

.kanban-col-body {
  padding: .5rem;
  min-height: 120px;
  flex: 1;
}
.kanban-col-body.drag-over { background: var(--primary-light); border-radius: 0 0 var(--radius) var(--radius); }
/* Whole-column drop highlight (the drop target is the column; see initKanban) */
.kanban-col.drag-over { outline: 2px dashed var(--primary); outline-offset: -2px; }
.kanban-col.drag-over .kanban-col-body { background: var(--primary-light); }

.kanban-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: .75rem 1.4rem .75rem .75rem; /* room on the right for the drag handle */
  margin-bottom: .5rem;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
}
.kanban-card:hover { box-shadow: var(--shadow-md); }
/* Drag handle (grab here to move the card between stages) */
.kc-drag-handle {
  position: absolute;
  top: .35rem;
  right: .3rem;
  color: var(--gray-300);
  cursor: grab;
  font-size: 1rem;
  line-height: 1;
  padding: .1rem .15rem;
  user-select: none;
  touch-action: none;
}
.kc-drag-handle:hover { color: var(--gray-500); }
.kanban-card.dragging .kc-drag-handle { cursor: grabbing; }
.kanban-card.dragging { opacity: .5; transform: rotate(2deg); cursor: grabbing; }

.kc-ref    { font-size: .65rem; color: var(--gray-400); margin-bottom: .2rem; font-family: monospace; }
.kc-title  { font-size: .82rem; font-weight: 600; color: var(--gray-800); margin-bottom: .35rem; line-height: 1.3; }
.kc-title a { color: inherit; }
.kc-title a:hover { color: var(--primary); text-decoration: none; }
.kc-company { font-size: .72rem; color: var(--gray-500); margin-bottom: .3rem; }
.kc-meta   { font-size: .7rem; color: var(--gray-500); display: flex; flex-wrap: wrap; gap: .3rem; }
.kc-value  { margin-top: .4rem; display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.kc-tcv    { font-size: .78rem; font-weight: 700; color: var(--gray-700); }
.kc-prob   { font-size: .68rem; color: var(--gray-400); }

/* ============================================================
   HELP TOOLTIPS
   ============================================================ */
.help-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--gray-300);
  color: var(--gray-600);
  font-size: .65rem;
  font-weight: 700;
  cursor: help;
  margin-left: .3rem;
  position: relative;
  vertical-align: middle;
}
.help-tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900);
  color: #fff;
  padding: .4rem .65rem;
  border-radius: var(--radius-sm);
  font-size: .72rem;
  font-weight: 400;
  white-space: normal;
  width: 200px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 200;
  line-height: 1.4;
}
.help-tip:hover::after { opacity: 1; }

/* ============================================================
   MISC UTILITIES
   ============================================================ */
.text-muted   { color: var(--gray-500); }
.text-small   { font-size: .8rem; }
.text-xs      { font-size: .72rem; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.fw-bold      { font-weight: 700; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-1 { gap: .5rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-400);
}
.empty-state h2 { font-size: 1.1rem; margin-bottom: .5rem; color: var(--gray-500); }
.empty-state p  { font-size: .875rem; margin-bottom: 1rem; }

/* Divider */
.divider { border: none; border-top: 1px solid var(--gray-200); margin: 1rem 0; }

/* Env badge in sidebar */
.env-badge {
  display: inline-block;
  padding: .1rem .4rem;
  border-radius: 3px;
  font-size: .6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.env-dev     { background: #fde68a; color: #92400e; }
.env-staging { background: #ddd6fe; color: #5b21b6; }
.env-prod    { background: #bbf7d0; color: #14532d; }

/* ============================================================
   KANBAN COLUMN METRICS (TCV / MRR / ARR / FYR sub-header)
   ============================================================ */
.kanban-col-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem .6rem;
  padding: .35rem .85rem;
  font-size: .68rem;
  font-weight: 600;
  background: rgba(0,0,0,.04);
  border-bottom: 1px solid var(--gray-200);
  color: var(--gray-700);
}
.kanban-col-metrics .text-muted { font-weight: 400; color: var(--gray-500); }

/* MRR / ARR badges on kanban cards */
.kc-mrr { font-size: .68rem; color: var(--info);    font-weight: 600; }
.kc-arr { font-size: .68rem; color: var(--success); font-weight: 600; }

/* Won stat card: compact two-column inner layout (count left, metrics right) */
.stat-card--won-inner {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  margin-top: .25rem;
}
/* 2-col label/value grid for MRR / ARR / FYR / TCV */
.won-metrics-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .05rem .4rem;
  font-size: .68rem;
  line-height: 1.55;
}
.wm-label {
  color: var(--gray-500);
  font-weight: 600;
  white-space: nowrap;
}
.wm-val {
  color: var(--success);
  font-weight: 700;
  white-space: nowrap;
}
/* Legacy: keep .won-metrics for any other uses */
.stat-card--won .won-metrics {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  font-size: .72rem;
  color: var(--gray-600);
  margin-top: .35rem;
  line-height: 1.5;
}
.stat-card--won .won-metrics span { font-weight: 600; color: var(--success); }

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Hamburger toggle: hidden on desktop (sidebar always visible),
   shown on mobile where the sidebar slides in/out */
#sidebar-toggle {
  display: none;
}

@media (max-width: 768px) {
  #sidebar-toggle {
    display: inline-flex;
  }
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .stats-row {
    grid-template-columns: 1fr 1fr;
  }
  /* Dashboard grids collapse to single column on mobile */
  .dashboard-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================================
   MOBILE KPI CAROUSEL
   On mobile (<= 640px) the stats-row--kpi class switches from a
   grid to a horizontally-scrollable, CSS scroll-snap carousel.
   Each stat card snaps to the left edge so users can swipe through
   KPIs one at a time without the grid consuming too much vertical
   space.
   ============================================================ */
@media (max-width: 768px) {
  .stats-row--kpi {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: .65rem;
    padding-bottom: .5rem;
    /* Prevent grid from overriding */
    grid-template-columns: unset !important;
  }
  .stats-row--kpi .stat-card {
    flex: 0 0 72vw;          /* Each card takes ~72% of viewport width */
    max-width: 280px;
    scroll-snap-align: start;
    /* Subtle visual cue that more cards exist off-screen */
    box-shadow: var(--shadow-md);
  }
  /* Won card is slightly wider to accommodate the 4-metric breakdown */
  .stats-row--kpi .stat-card--won {
    flex: 0 0 80vw;
    max-width: 320px;
  }
  /* Scroll indicator dots (optional visual hint) */
  .stats-row--kpi::after {
    content: '';
    flex: 0 0 1px;  /* Spacer so last card isn't flush against edge */
  }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
  .page-content { padding: 1rem; }
  .product-line {
    grid-template-columns: 1fr 60px !important;
  }
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--gray-900) 0%, #1e3a5f 100%);
}
.login-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
}
.login-brand { text-align: center; margin-bottom: 2rem; }
.login-brand .brand-name { font-size: 2rem; font-weight: 800; color: var(--gray-900); letter-spacing: -1px; }
.login-brand .brand-tag  { font-size: .7rem; color: var(--gray-400); letter-spacing: 1px; text-transform: uppercase; }

/* ============================================================
   PRODUCT LINE ITEMS (Opportunity form)
   ============================================================ */
.product-lines { margin-bottom: 1rem; }
.product-line {
  display: grid;
  grid-template-columns: 2fr 80px 120px 120px 36px;
  gap: .5rem;
  align-items: end;
  margin-bottom: .5rem;
  padding: .75rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
}
.product-line-total { font-weight: 700; font-size: .875rem; color: var(--gray-700); padding-bottom: .5rem; }
.tcv-summary {
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  margin-top: .5rem;
}
.tcv-item { font-size: .8rem; }
.tcv-item .tcv-label { color: var(--gray-500); }
.tcv-item .tcv-val   { font-weight: 700; color: var(--gray-900); font-size: 1rem; }

/* ============================================================
   COMPANY HIERARCHY TREE
   ============================================================ */
.company-tree { padding-left: 1.25rem; border-left: 2px solid var(--gray-200); }
.company-tree-item { padding: .3rem 0; font-size: .875rem; }
.company-tree-item a { color: var(--gray-700); }
.company-tree-item a:hover { color: var(--primary); }

/* ============================================================
   APPROVAL STATUS
   ============================================================ */
.approval-pending  { color: var(--warning); font-weight: 600; }
.approval-approved { color: var(--success); font-weight: 600; }
.approval-rejected { color: var(--danger);  font-weight: 600; }

/* ============================================================
   COUNTRY / GENERIC TYPEAHEAD DROPDOWN
   ============================================================ */
.typeahead-dropdown {
  position: absolute;
  z-index: 1000;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 220px;
  overflow-y: auto;
  min-width: 220px;
}
.typeahead-item {
  padding: .45rem .75rem;
  font-size: .875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.typeahead-item:hover { background: var(--primary-light); color: var(--primary); }
.typeahead-code {
  font-size: .7rem;
  font-weight: 700;
  color: var(--gray-500);
  min-width: 2.5rem;
  text-transform: uppercase;
}
/* .form-group already has position:relative — see base form styles */

/* ============================================================
   ALERT / FLASH MESSAGES (test_data.php compatibility)
   ============================================================ */
.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .9rem; }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #bbf7d0; }
.alert-danger  { background: var(--danger-light);  color: var(--danger);  border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-light); color: var(--warning); border: 1px solid #fde68a; }
.alert-info    { background: var(--info-light);    color: var(--info);    border: 1px solid #a5f3fc; }

/* ============================================================
   STATS GRID (test_data.php compatibility)
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.stat-highlight {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  display: block;
}
.badge-test { background: #fef3c7; color: #92400e; border-radius: 999px; padding: .15rem .55rem; font-size: .7rem; font-weight: 600; }

/* ============================================================
   MISC UTILITY CLASSES
   ============================================================ */
.page-subtitle { font-size: 1rem; color: var(--gray-500); margin-top: -.25rem; margin-bottom: 1rem; }
.prose { font-size: .875rem; color: var(--gray-600); line-height: 1.6; }
.prose p { margin-bottom: .75rem; }
.form-inline-group { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.help-bubble { font-size: .75rem; color: var(--gray-400); font-style: italic; }
.card-danger { border: 1px solid var(--danger); }
.card-danger .card-header { background: var(--danger-light); color: var(--danger); }

/* Disabled nav item — used when Nexus Hub is not yet configured */
.nav-item-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}
.nav-item-disabled:hover {
    background: transparent;
    color: inherit;
}


/* ============================================================
   SPRINT 3 — ACTIVITY TIMELINE (FR-0026)
   ============================================================ */
.timeline { position: relative; padding-left: 2.5rem; }
.timeline::before {
    content: '';
    position: absolute;
    left: 1rem;
    top: 0; bottom: 0;
    width: 2px;
    background: var(--gray-200);
}
.timeline-item { position: relative; margin-bottom: 1.25rem; }
.timeline-icon {
    position: absolute;
    left: -2.5rem;
    top: .1rem;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: .75rem;
    flex-shrink: 0;
}
.timeline-body {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: .75rem 1rem;
}
.timeline-header { font-size: .875rem; font-weight: 600; }
.timeline-meta   { font-size: .75rem; margin-top: .2rem; }
.timeline-notes  { font-size: .8rem; color: var(--gray-600); margin-top: .4rem; }
.timeline-task .timeline-body { border-left: 3px solid var(--warning); }

/* ============================================================
   SPRINT 3 — DETAIL TABLE
   ============================================================ */
.detail-table { width: 100%; font-size: .875rem; border-collapse: collapse; }
.detail-table th {
    width: 38%;
    text-align: left;
    padding: .4rem .5rem .4rem 0;
    color: var(--gray-500);
    font-weight: 500;
    vertical-align: top;
}
.detail-table td { padding: .4rem 0; vertical-align: top; }

/* ============================================================
   SPRINT 3 — ALERT COMPONENT
   ============================================================ */
.alert {
    padding: .75rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: .875rem;
    display: flex;
    align-items: center;
    gap: .6rem;
}
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #bbf7d0; }
.alert-danger  { background: var(--danger-light);  color: var(--danger);  border: 1px solid #fecaca; }
.alert-info    { background: var(--info-light);    color: var(--info);    border: 1px solid #a5f3fc; }

/* Sortable table headers (click to sort — see sortable_th() in core/bootstrap.php) */
a.th-sort { color: inherit; text-decoration: none; cursor: pointer; white-space: nowrap; }
a.th-sort:hover { text-decoration: underline; }
a.th-sort.is-active { font-weight: 700; }
