/* ============================================================
   IT Artificer — Business Suite · Design System v1.1
   Inspired by Linear, Stripe, Vercel — clean, dense, premium.
   ============================================================ */

:root {
  /* Brand */
  --brand-50:  #eef4fb;
  --brand-100: #d6e3f3;
  --brand-200: #adc6e7;
  --brand-300: #7ea3d6;
  --brand-400: #4f80c4;
  --brand-500: #2c63ac;
  --brand-600: #1f4e79;   /* primary */
  --brand-700: #163b5f;
  --brand-800: #102a44;
  --brand-900: #0a1c2e;

  /* Neutrals */
  --gray-25:  #fcfcfd;
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-150: #e8edf3;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Accents */
  --success-50:  #ecfdf5; --success-200: #a7f3d0; --success-500: #10b981; --success-700: #047857;
  --warning-50:  #fffbeb; --warning-200: #fde68a; --warning-500: #f59e0b; --warning-700: #b45309;
  --danger-50:   #fef2f2; --danger-200:  #fecaca; --danger-500:  #ef4444; --danger-700:  #b91c1c;
  --info-50:     #eff6ff; --info-200:    #bfdbfe; --info-500:    #3b82f6; --info-700:    #1d4ed8;
  --purple-50:   #faf5ff; --purple-200:  #e9d5ff; --purple-500:  #a855f7; --purple-700:  #7e22ce;

  /* Surface / shadows */
  --bg-app:    #f5f7fa;
  --surface:   #ffffff;
  --border:    var(--gray-200);
  --border-strong: var(--gray-300);

  --shadow-xs: 0 1px 2px 0 rgba(16, 24, 40, .05);
  --shadow-sm: 0 1px 3px 0 rgba(16, 24, 40, .06), 0 1px 2px -1px rgba(16, 24, 40, .04);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, .08), 0 2px 4px -2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 24px -6px rgba(16, 24, 40, .10), 0 4px 6px -2px rgba(16, 24, 40, .04);
  --shadow-xl: 0 24px 48px -12px rgba(16, 24, 40, .18);

  --radius-sm: 6px;
  --radius:    8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Typography */
  --font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
}

/* ----------------- Base ----------------- */
* { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

html, body {
  font-family: var(--font-sans);
  background: var(--bg-app);
  color: var(--gray-800);
  font-size: 14px;
  letter-spacing: -0.005em;
}

body { font-feature-settings: 'cv11', 'ss01', 'ss03'; }

h1, h2, h3, h4, h5, h6 {
  letter-spacing: -0.02em;
  color: var(--gray-900);
  font-weight: 600;
}
h3 { font-size: 1.375rem; }
h4 { font-size: 1.125rem; }

.text-muted { color: var(--gray-500) !important; }
small, .small { font-size: 0.8125rem; }
code, kbd { font-family: var(--font-mono); font-size: 0.85em; background: var(--gray-100); padding: 1px 6px; border-radius: 4px; color: var(--gray-700); }

a { color: var(--brand-600); text-decoration: none; transition: color .12s ease; }
a:hover { color: var(--brand-700); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

/* ----------------- Top bar ----------------- */
.app-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(180%) blur(10px);
}
.app-brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; color: var(--gray-900);
  letter-spacing: -0.02em;
  font-size: 0.98rem;
  text-decoration: none;
}
.app-brand:hover { text-decoration: none; color: var(--gray-900); }
.app-brand .logo-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-500) 0%, var(--brand-700) 100%);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px;
  box-shadow: 0 2px 4px rgba(31, 78, 121, .25), inset 0 1px 0 rgba(255,255,255,.2);
}
.app-brand .brand-meta {
  font-size: 0.7rem; color: var(--gray-500); font-weight: 500;
  letter-spacing: 0.04em; text-transform: uppercase;
  margin-top: 1px;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.version-chip {
  background: var(--gray-100); color: var(--gray-600);
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 500; letter-spacing: 0.02em;
  border: 1px solid var(--border);
}

/* User menu */
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 10px 5px 5px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; transition: all .12s ease;
  font-size: 0.85rem; color: var(--gray-700);
}
.user-chip:hover { background: var(--gray-50); border-color: var(--border-strong); }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff; font-weight: 600; font-size: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  letter-spacing: 0;
}
.role-tag {
  font-size: 0.68rem; padding: 2px 7px; border-radius: 4px;
  background: var(--brand-50); color: var(--brand-700);
  font-weight: 500; letter-spacing: 0.02em; text-transform: uppercase;
}

/* ----------------- Layout ----------------- */
.app-shell { display: flex; min-height: calc(100vh - 60px); }
.app-sidebar {
  width: 248px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  position: sticky; top: 60px; height: calc(100vh - 60px);
  overflow-y: auto;
}
.app-main { flex: 1; min-width: 0; padding: 28px 32px; }

@media (max-width: 991.98px) {
  .app-sidebar { width: 100%; position: static; height: auto; }
  .app-shell { flex-direction: column; }
  .app-main { padding: 20px; }
}

/* Sidebar navigation */
.nav-section {
  font-size: 0.7rem; color: var(--gray-400);
  font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 14px 12px 6px;
}
.nav-section:first-child { padding-top: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; margin: 1px 0;
  border-radius: var(--radius-sm);
  color: var(--gray-700); font-size: 0.875rem; font-weight: 500;
  text-decoration: none; transition: all .12s ease;
  border: 1px solid transparent;
}
.nav-item:hover {
  background: var(--gray-50); color: var(--gray-900);
  text-decoration: none;
}
.nav-item.active {
  background: var(--brand-50); color: var(--brand-700);
  border-color: var(--brand-100);
  font-weight: 600;
}
.nav-item i { font-size: 1.05rem; color: var(--gray-400); width: 18px; text-align: center; }
.nav-item.active i { color: var(--brand-600); }
.nav-item:hover i { color: var(--gray-600); }

/* ----------------- Cards ----------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}
.card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  font-weight: 600;
  color: var(--gray-900);
  font-size: 0.9rem;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.card-body { padding: 20px; }

/* Stat cards (KPI tiles) */
.stat-card {
  padding: 18px 20px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  transition: all .15s ease;
  position: relative; overflow: hidden;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card .stat-label {
  color: var(--gray-500); font-size: 0.7rem;
  text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 600; margin-bottom: 8px;
}
.stat-card .stat-value {
  font-size: 1.625rem; font-weight: 700; color: var(--gray-900);
  letter-spacing: -0.025em; line-height: 1.15;
}
.stat-card .stat-meta { color: var(--gray-500); font-size: 0.78rem; margin-top: 6px; }
.stat-card .stat-icon {
  width: 36px; height: 36px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.05rem; margin-bottom: 12px;
}
.stat-card.tone-brand   .stat-icon { background: var(--brand-50);   color: var(--brand-600); }
.stat-card.tone-success .stat-icon { background: var(--success-50); color: var(--success-700); }
.stat-card.tone-danger  .stat-icon { background: var(--danger-50);  color: var(--danger-700); }
.stat-card.tone-warning .stat-icon { background: var(--warning-50); color: var(--warning-700); }
.stat-card.tone-info    .stat-icon { background: var(--info-50);    color: var(--info-700); }
.stat-card.tone-purple  .stat-icon { background: var(--purple-50);  color: var(--purple-500); }

.stat-card .stat-value.text-success { color: var(--success-700); }
.stat-card .stat-value.text-danger  { color: var(--danger-700); }
.stat-card .stat-value.text-warning { color: var(--warning-700); }
.stat-card .stat-value.text-primary { color: var(--brand-600); }

/* ----------------- Buttons ----------------- */
.btn {
  font-weight: 500; font-size: 0.875rem;
  border-radius: var(--radius-sm); padding: 7px 14px;
  border: 1px solid transparent;
  letter-spacing: -0.005em;
  transition: all .12s ease;
  display: inline-flex; align-items: center; gap: 6px;
  line-height: 1.4;
}
.btn-sm { padding: 4px 10px; font-size: 0.8rem; border-radius: 5px; }
.btn-lg { padding: 10px 18px; font-size: 0.95rem; border-radius: 8px; }

.btn-primary {
  background: var(--brand-600); border-color: var(--brand-600); color: #fff;
  box-shadow: 0 1px 2px rgba(31, 78, 121, .15), inset 0 1px 0 rgba(255,255,255,.1);
}
.btn-primary:hover, .btn-primary:focus { background: var(--brand-700); border-color: var(--brand-700); color: #fff; box-shadow: 0 2px 4px rgba(31, 78, 121, .2); }
.btn-primary:active { background: var(--brand-800); border-color: var(--brand-800); }

.btn-light {
  background: var(--surface); border-color: var(--border-strong); color: var(--gray-700);
  box-shadow: var(--shadow-xs);
}
.btn-light:hover { background: var(--gray-50); border-color: var(--gray-400); color: var(--gray-900); }

.btn-outline-primary { color: var(--brand-600); border-color: var(--border-strong); background: var(--surface); }
.btn-outline-primary:hover { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-300); }

.btn-outline-secondary { color: var(--gray-700); border-color: var(--border-strong); background: var(--surface); }
.btn-outline-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); color: var(--gray-900); }

.btn-outline-danger { color: var(--danger-700); border-color: var(--border-strong); background: var(--surface); }
.btn-outline-danger:hover { background: var(--danger-50); border-color: var(--danger-500); color: var(--danger-700); }

.btn-success { background: var(--success-500); border-color: var(--success-500); color: #fff; }
.btn-success:hover { background: var(--success-700); border-color: var(--success-700); color: #fff; }

/* ----------------- Forms ----------------- */
.form-label {
  font-size: 0.8rem; font-weight: 500; color: var(--gray-700);
  margin-bottom: 5px; letter-spacing: -0.005em;
}
.form-control, .form-select {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  padding: 7px 11px;
  color: var(--gray-900);
  background: var(--surface);
  transition: border-color .12s ease, box-shadow .12s ease;
  box-shadow: var(--shadow-xs);
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand-400);
  box-shadow: 0 0 0 3px rgba(44, 99, 172, .12);
  outline: none;
}
.form-control::placeholder { color: var(--gray-400); }
.form-control:disabled, .form-control[readonly] { background: var(--gray-50); color: var(--gray-500); }

.form-control-lg { padding: 11px 14px; font-size: 0.95rem; border-radius: 8px; }
.form-control-sm, .form-select-sm { padding: 5px 9px; font-size: 0.8rem; }

.form-check-input { border-color: var(--border-strong); }
.form-check-input:checked { background-color: var(--brand-600); border-color: var(--brand-600); }
.form-check-input:focus { box-shadow: 0 0 0 3px rgba(44, 99, 172, .15); border-color: var(--brand-400); }

/* ----------------- Tables ----------------- */
.table { color: var(--gray-800); margin-bottom: 0; }
.table > :not(caption) > * > * { padding: 11px 14px; vertical-align: middle; }
.table thead th {
  background: var(--gray-50);
  font-weight: 600; color: var(--gray-600);
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
}
.table tbody tr { border-bottom: 1px solid var(--gray-100); transition: background .1s ease; }
.table tbody tr:hover { background: var(--gray-25); }
.table tbody tr:last-child { border-bottom: none; }
.table tbody td { font-size: 0.875rem; }
.table.table-soft thead th { background: var(--gray-50); }
.table tfoot th { background: var(--gray-50); font-weight: 600; border-top: 1px solid var(--border); }

.table .text-end { font-variant-numeric: tabular-nums; }

/* ----------------- Badges ----------------- */
.badge {
  font-weight: 500; font-size: 0.7rem;
  padding: 3px 8px; border-radius: 4px;
  letter-spacing: 0.01em; line-height: 1.4;
  border: 1px solid transparent;
}
.badge.bg-success-soft   { background: var(--success-50); color: var(--success-700); border-color: rgba(16,185,129,.18); }
.badge.bg-warning-soft   { background: var(--warning-50); color: var(--warning-700); border-color: rgba(245,158,11,.18); }
.badge.bg-danger-soft    { background: var(--danger-50);  color: var(--danger-700);  border-color: rgba(239,68,68,.18); }
.badge.bg-info-soft      { background: var(--info-50);    color: var(--info-700);    border-color: rgba(59,130,246,.18); }
.badge.bg-secondary-soft { background: var(--gray-100);   color: var(--gray-700);    border-color: var(--border); }
.badge.bg-secondary      { background: var(--gray-500) !important; }

/* ----------------- Alerts ----------------- */
.alert {
  border-radius: var(--radius); border-width: 1px; padding: 12px 16px;
  font-size: 0.88rem; box-shadow: var(--shadow-xs);
  display: flex; align-items: flex-start; gap: 10px;
}
.alert-success { background: var(--success-50); color: var(--success-700); border-color: rgba(16,185,129,.22); }
.alert-danger  { background: var(--danger-50);  color: var(--danger-700);  border-color: rgba(239,68,68,.22); }
.alert-warning { background: var(--warning-50); color: var(--warning-700); border-color: rgba(245,158,11,.22); }
.alert-info    { background: var(--info-50);    color: var(--info-700);    border-color: rgba(59,130,246,.22); }

/* ----------------- Misc ----------------- */
.dropdown-menu {
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px;
  font-size: 0.875rem;
}
.dropdown-item { border-radius: var(--radius-sm); padding: 7px 10px; color: var(--gray-700); }
.dropdown-item:hover { background: var(--gray-50); color: var(--gray-900); }
.dropdown-divider { margin: 4px 0; border-color: var(--border); }

.page-header { margin-bottom: 22px; }
.page-header h3 { margin-bottom: 4px; }
.page-header .subtitle { color: var(--gray-500); font-size: 0.875rem; }

/* Subtle utility */
.hover-lift { transition: all .15s ease; }
.hover-lift:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

/* ----------------- Login page ----------------- */
.auth-shell {
  min-height: 100vh;
  display: grid; grid-template-columns: 1fr;
  background: var(--bg-app);
}
@media (min-width: 992px) {
  .auth-shell { grid-template-columns: 1.05fr 1fr; }
}
.auth-hero {
  display: none;
  background:
    radial-gradient(ellipse at top left, rgba(255,255,255,.08) 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(255,255,255,.06) 0%, transparent 50%),
    linear-gradient(135deg, var(--brand-800) 0%, var(--brand-600) 60%, var(--brand-500) 100%);
  color: #fff; position: relative; overflow: hidden;
  padding: 56px 64px;
}
.auth-hero::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.08) 0, transparent 25%),
    radial-gradient(circle at 80% 80%, rgba(255,255,255,.05) 0, transparent 30%);
  pointer-events: none;
}
@media (min-width: 992px) { .auth-hero { display: flex; flex-direction: column; justify-content: space-between; } }

.auth-hero .hero-brand {
  display: flex; align-items: center; gap: 12px;
  font-size: 1.05rem; font-weight: 600; letter-spacing: -0.02em;
  position: relative;
}
.auth-hero .hero-brand .logo-mark {
  width: 36px; height: 36px; border-radius: 9px;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.2);
  display: inline-flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px);
}
.auth-hero .hero-content { position: relative; max-width: 480px; }
.auth-hero h1 {
  color: #fff; font-size: 2.5rem; font-weight: 700;
  letter-spacing: -0.03em; line-height: 1.15; margin-bottom: 16px;
}
.auth-hero p { color: rgba(255,255,255,.78); font-size: 1rem; line-height: 1.6; }
.auth-hero .hero-features {
  list-style: none; padding: 0; margin: 28px 0 0;
  display: grid; gap: 14px; position: relative;
}
.auth-hero .hero-features li {
  display: flex; gap: 12px; align-items: flex-start;
  color: rgba(255,255,255,.92); font-size: 0.92rem;
}
.auth-hero .hero-features .check {
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(255,255,255,.18); display: inline-flex;
  align-items: center; justify-content: center; flex-shrink: 0;
  font-size: 12px;
}
.auth-hero .hero-footer { position: relative; color: rgba(255,255,255,.55); font-size: 0.8rem; }

.auth-pane {
  display: flex; flex-direction: column; justify-content: center;
  padding: 40px 24px;
}
.auth-card {
  width: 100%; max-width: 420px; margin: 0 auto;
}
.auth-card .hint {
  background: var(--gray-50); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
  font-size: 0.78rem; color: var(--gray-600); margin-top: 20px;
  line-height: 1.5;
}
.auth-card .hint code { background: var(--surface); border: 1px solid var(--border); }

/* ============================================================
   Refined tables & forms (v1.2)
   ============================================================ */

/* ---- Tables: density, avatars, action groups ---- */
.card > .table-responsive { border-radius: 0 0 var(--radius-md) var(--radius-md); }
.card > .table-responsive > .table { margin-bottom: 0; }

.table thead th {
  position: sticky; top: 0; z-index: 1;
  background: linear-gradient(to bottom, var(--gray-50) 0%, #fbfcfd 100%);
}
.table thead th.sortable { cursor: pointer; user-select: none; }
.table thead th.sortable:hover { color: var(--gray-800); background: var(--gray-100); }

.table-row-link { color: var(--gray-900); font-weight: 500; text-decoration: none; }
.table-row-link:hover { color: var(--brand-700); text-decoration: none; }
.table-row-link .sub { display: block; color: var(--gray-500); font-size: 0.78rem; font-weight: 400; margin-top: 1px; }

.cell-amount { font-variant-numeric: tabular-nums; font-weight: 500; color: var(--gray-900); }
.cell-amount.negative { color: var(--danger-700); }
.cell-amount.positive { color: var(--success-700); }
.cell-amount.muted { color: var(--gray-500); }

.cell-id { font-family: var(--font-mono); font-size: 0.78rem; color: var(--gray-500); letter-spacing: -0.01em; }

/* Avatar circle for people-type tables */
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: #fff; letter-spacing: 0.02em;
  background: var(--gray-400); flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
.avatar.avatar-sm { width: 26px; height: 26px; font-size: 10px; }
.avatar.tone-brand   { background: linear-gradient(135deg, var(--brand-500),   var(--brand-700)); }
.avatar.tone-success { background: linear-gradient(135deg, #34d399,             var(--success-700)); }
.avatar.tone-warning { background: linear-gradient(135deg, #fbbf24,             var(--warning-700)); }
.avatar.tone-danger  { background: linear-gradient(135deg, #f87171,             var(--danger-700)); }
.avatar.tone-purple  { background: linear-gradient(135deg, #c084fc,             #7e22ce); }
.avatar.tone-info    { background: linear-gradient(135deg, #60a5fa,             var(--info-700)); }
.avatar.tone-pink    { background: linear-gradient(135deg, #f472b6,             #be185d); }
.avatar.tone-teal    { background: linear-gradient(135deg, #2dd4bf,             #0f766e); }

.row-with-avatar { display: flex; align-items: center; gap: 11px; }
.row-with-avatar .name { font-weight: 500; color: var(--gray-900); line-height: 1.25; }
.row-with-avatar .meta { color: var(--gray-500); font-size: 0.78rem; line-height: 1.25; }

/* Pill — fuller-bodied status indicator with dot */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px 3px 8px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 500; letter-spacing: 0.01em;
  border: 1px solid transparent; line-height: 1.4;
  white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.pill-success { background: var(--success-50); color: var(--success-700); border-color: rgba(16,185,129,.2); }
.pill-success .dot { background: var(--success-500); box-shadow: 0 0 0 3px rgba(16,185,129,.12); }
.pill-warning { background: var(--warning-50); color: var(--warning-700); border-color: rgba(245,158,11,.2); }
.pill-warning .dot { background: var(--warning-500); box-shadow: 0 0 0 3px rgba(245,158,11,.12); }
.pill-danger  { background: var(--danger-50);  color: var(--danger-700);  border-color: rgba(239,68,68,.2); }
.pill-danger .dot { background: var(--danger-500); box-shadow: 0 0 0 3px rgba(239,68,68,.12); }
.pill-info    { background: var(--info-50);    color: var(--info-700);    border-color: rgba(59,130,246,.2); }
.pill-info .dot { background: var(--info-500); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.pill-muted   { background: var(--gray-100);   color: var(--gray-600);    border-color: var(--border); }
.pill-muted .dot { background: var(--gray-400); }
.pill-brand   { background: var(--brand-50);   color: var(--brand-700);   border-color: var(--brand-100); }
.pill-brand .dot { background: var(--brand-500); box-shadow: 0 0 0 3px rgba(31,78,121,.12); }

/* Compact tag for service categories */
.tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 4px;
  font-size: 0.7rem; font-weight: 500; letter-spacing: 0.01em;
  background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--border);
}
.tag + .tag { margin-left: 4px; }

/* Action button group — icon-only, in tables */
.row-actions {
  display: inline-flex; gap: 4px; opacity: .55; transition: opacity .12s ease;
}
tr:hover .row-actions, .row-actions:hover, .row-actions:focus-within { opacity: 1; }
.row-actions .btn {
  padding: 4px 7px; line-height: 1; font-size: 0.85rem;
  border-radius: 5px;
}
.row-actions form { display: inline-block; margin: 0; }

/* Table toolbar (filter bar above tables) */
.table-toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border); border-bottom: 0;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.table-toolbar + .table-responsive { border-radius: 0; }
.table-toolbar + .table-responsive > .table { border-radius: 0; }
.table-toolbar .search {
  position: relative; flex: 1; min-width: 220px; max-width: 380px;
}
.table-toolbar .search input {
  padding-left: 34px;
  background: var(--gray-50); border-color: transparent;
}
.table-toolbar .search input:focus { background: var(--surface); border-color: var(--brand-400); }
.table-toolbar .search i {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--gray-400); font-size: 0.95rem; pointer-events: none;
}
.table-toolbar .table-toolbar-end { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.table-wrap { /* parent containing toolbar + table responsive */
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); box-shadow: var(--shadow-xs); overflow: hidden;
}
.table-wrap > .table-toolbar { border: 0; border-bottom: 1px solid var(--border); }
.table-wrap > .table-responsive { border-radius: 0; }
.table-wrap > .table-responsive > .table tbody tr:last-child { border-bottom: none; }

/* Empty state */
.empty-state { padding: 48px 16px; text-align: center; color: var(--gray-500); }
.empty-state .icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--gray-50); border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--gray-400); font-size: 1.5rem; margin-bottom: 14px;
}
.empty-state .title { color: var(--gray-700); font-weight: 600; margin-bottom: 4px; }
.empty-state .desc { font-size: 0.85rem; }

/* ---- Forms: sections, input groups, helpers ---- */
.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  margin-bottom: 18px;
  overflow: hidden;
}
.form-section-header {
  padding: 16px 22px; border-bottom: 1px solid var(--border);
  background: linear-gradient(to bottom, var(--gray-25), var(--surface));
  display: flex; align-items: flex-start; gap: 12px;
}
.form-section-header .icon,
.form-section-header > i.bi {
  width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0;
  background: var(--brand-50); color: var(--brand-600);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.05rem;
}
/* Support both .title/.subtitle (old) and .form-section-title/.form-section-sub (new) */
.form-section-header .title,
.form-section-header .form-section-title { font-weight: 600; color: var(--gray-900); font-size: 0.95rem; margin: 0; line-height: 1.3; }
.form-section-header .subtitle,
.form-section-header .form-section-sub { color: var(--gray-500); font-size: 0.8rem; margin-top: 2px; }
.form-section-body { padding: 22px; }

.form-label-required::after { content: ' *'; color: var(--danger-500); }
.form-helper { font-size: 0.78rem; color: var(--gray-500); margin-top: 5px; line-height: 1.4; }

/* Input group with leading icon */
.input-with-icon { position: relative; }
.input-with-icon .form-control { padding-left: 38px; }
.input-with-icon > i {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--gray-400); font-size: 1rem; pointer-events: none;
}
.input-with-icon .form-control:focus + i,
.input-with-icon:focus-within > i { color: var(--brand-500); }

/* Sticky form footer */
.form-footer {
  position: sticky; bottom: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 22px;
  box-shadow: 0 -1px 0 var(--border), var(--shadow-md);
  display: flex; align-items: center; gap: 10px;
  margin-top: 20px; z-index: 10;
}
.form-footer .form-hint { font-size: 0.8rem; color: var(--gray-500); margin-left: auto; }
.form-footer .actions { display: flex; gap: 8px; }

/* Switch styling */
.form-switch .form-check-input {
  width: 2.2em; height: 1.25em; margin-top: .1em;
  background-color: var(--gray-200); border-color: var(--gray-300);
}
.form-switch .form-check-input:checked { background-color: var(--brand-600); border-color: var(--brand-600); }

/* Show-on-hover utility */
.show-on-hover { opacity: 0; transition: opacity .12s ease; }
tr:hover .show-on-hover, .show-on-hover:focus-within { opacity: 1; }

/* ----------------- Print ----------------- */
@media print {
  .app-sidebar, .app-topbar, .alert, .btn { display: none !important; }
  .app-main { padding: 0; }
  body { background: #fff; }
}

/* ============================================================
   Phase 1: Header nav + notifications bell + photo avatar
   ============================================================ */

.header-nav { display:flex; align-items:center; gap:4px; margin:0 24px; flex:1; }
.header-nav-link {
  display:inline-flex; align-items:center; gap:6px;
  padding:8px 12px; border-radius:8px;
  background:transparent; border:0;
  color:var(--gray-600); font-weight:500; font-size:.88rem;
  cursor:pointer; transition:all .15s ease; white-space:nowrap;
}
.header-nav-link:hover  { background:var(--gray-100); color:var(--gray-900); }
.header-nav-link.is-active,
.header-nav-link[aria-expanded="true"] { background:var(--brand-50); color:var(--brand-700); }

.notif-bell {
  position:relative;
  background:transparent; border:1px solid var(--border);
  width:38px; height:38px; border-radius:10px;
  display:inline-flex; align-items:center; justify-content:center;
  cursor:pointer; transition:all .15s ease;
}
.notif-bell:hover { background:var(--gray-50); border-color:var(--gray-300); }
.notif-bell .notif-badge {
  position:absolute; top:-6px; right:-6px;
  min-width:18px; height:18px; padding:0 5px; border-radius:9px;
  background:var(--danger-500); color:#fff;
  font-size:.66rem; font-weight:700; line-height:18px; text-align:center;
  border:2px solid var(--surface);
}

.notif-dropdown { box-shadow:var(--shadow-lg); border:1px solid var(--border); }

.user-avatar {
  width:32px; height:32px; border-radius:8px;
  background:linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color:#fff; font-weight:600; font-size:.78rem;
  display:inline-flex; align-items:center; justify-content:center;
  flex-shrink:0;
}

/* ============================================================
   Phase 1b: Header nav polish + bell refinement
   ============================================================ */

.header-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0 24px;
  flex: 1;
  justify-content: flex-start;
}
.header-nav-item { display: inline-block; }

.header-nav-link {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--gray-600);
  font-weight: 500;
  font-size: 0.875rem;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
  white-space: nowrap;
  line-height: 1;
}
.header-nav-link .hnl-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  color: var(--gray-400);
  font-size: 0.95rem;
  transition: color .15s ease;
}
.header-nav-link .hnl-caret {
  font-size: 0.62rem;
  color: var(--gray-400);
  margin-left: 1px;
  transition: transform .15s ease, color .15s ease;
}
.header-nav-link:hover {
  background: var(--gray-50);
  color: var(--gray-900);
}
.header-nav-link:hover .hnl-icon,
.header-nav-link:hover .hnl-caret { color: var(--gray-600); }

.header-nav-link.is-active {
  background: var(--brand-50);
  color: var(--brand-700);
  border-color: var(--brand-100);
}
.header-nav-link.is-active .hnl-icon,
.header-nav-link.is-active .hnl-caret { color: var(--brand-600); }

.header-nav-link[aria-expanded="true"] {
  background: var(--gray-100);
  color: var(--gray-900);
}
.header-nav-link[aria-expanded="true"] .hnl-caret { transform: rotate(180deg); }

/* Dropdown panels under header nav */
.header-nav-menu {
  min-width: 240px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px -8px rgba(15, 23, 42, .15), 0 4px 8px -2px rgba(15, 23, 42, .06);
  margin-top: 6px !important;
}
.header-nav-menu .dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--gray-700);
  font-size: 0.86rem;
  font-weight: 500;
  transition: background-color .12s ease, color .12s ease;
}
.header-nav-menu .dropdown-item i {
  width: 18px; text-align: center;
  font-size: 0.98rem;
  color: var(--gray-400);
  flex-shrink: 0;
}
.header-nav-menu .dropdown-item:hover {
  background: var(--brand-50);
  color: var(--brand-700);
}
.header-nav-menu .dropdown-item:hover i { color: var(--brand-600); }
.header-nav-menu .dropdown-item:active {
  background: var(--brand-100);
  color: var(--brand-700);
}
.header-nav-menu .dropdown-divider {
  margin: 6px 0;
  border-color: var(--gray-150);
}

/* ----------- Notification bell ----------- */
.notif-bell {
  position: relative;
  background: transparent;
  border: 1px solid var(--border);
  width: 38px; height: 38px;
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .15s ease;
  color: var(--gray-600);
}
.notif-bell i { font-size: 1.05rem; }
.notif-bell:hover {
  background: var(--gray-50);
  border-color: var(--border-strong);
  color: var(--gray-900);
}
.notif-bell.has-unread {
  color: var(--brand-600);
  border-color: var(--brand-200);
  background: var(--brand-50);
  animation: bell-pulse 2.4s ease-in-out infinite;
}
.notif-bell.has-unread:hover {
  background: var(--brand-100);
  border-color: var(--brand-300);
}
@keyframes bell-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(31, 78, 121, 0); }
  50%      { box-shadow: 0 0 0 4px rgba(31, 78, 121, .08); }
}

.notif-bell .notif-badge {
  position: absolute;
  top: -5px; right: -5px;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger-500);
  color: #fff;
  font-size: 0.66rem; font-weight: 700;
  line-height: 18px; text-align: center;
  border: 2px solid var(--surface);
  box-shadow: 0 1px 2px rgba(0,0,0,.1);
}

.notif-dropdown {
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 16px 40px -8px rgba(15, 23, 42, .18), 0 4px 12px -2px rgba(15, 23, 42, .08);
  margin-top: 6px !important;
  overflow: hidden;
}

/* Phase 1c: shift header nav rightward for better balance */
.header-nav {
  margin-left: 56px;  /* extra breathing room after brand */
  padding-left: 12px;
  border-left: 1px solid var(--gray-150);
}

/* Phase 1d: nudge nav further right + tighten menu item spacing */
.header-nav {
  margin-left: 110px;
  padding-left: 16px;
  gap: 0;
}
.header-nav-link {
  padding: 7px 10px;
  gap: 6px;
}
.header-nav-link .hnl-icon { width: 16px; height: 16px; font-size: 0.9rem; }

/* ============================================================
   Phase 1e: dropdown section headers + hover-to-open
   ============================================================ */

/* Section title at the top of each dropdown */
.dropdown-section-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px 9px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--brand-600);
  border-bottom: 1px solid var(--gray-150);
  margin: 0 0 6px;
}
.dropdown-section-header i {
  font-size: 0.85rem;
  color: var(--brand-500);
}
/* Sub-section divider header (e.g. "Procurement" inside Sales) */
.dropdown-section-header.subsection {
  color: var(--gray-500);
  margin-top: 8px;
  border-top: 1px solid var(--gray-150);
  border-bottom: none;
  padding-top: 12px;
}
.dropdown-section-header.subsection i { color: var(--gray-400); }

/* Hover-to-open on header nav (desktop only, mouse-capable devices) */
@media (hover: hover) and (pointer: fine) and (min-width: 992px) {
  .header-nav-item:hover > .dropdown-menu.header-nav-menu {
    display: block;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0 !important;
  }
  /* Hover bridge — invisible strip above the menu so cursor can travel from
     button to menu without losing :hover */
  .header-nav-menu::before {
    content: '';
    position: absolute;
    left: 0; right: 0;
    top: -8px;
    height: 10px;
  }
  /* Visual offset stays but hover area extends up */
  .header-nav-menu {
    margin-top: 8px !important;
  }
  /* Light highlight on the parent button when its menu is hover-open */
  .header-nav-item:hover > .header-nav-link {
    background: var(--gray-100);
    color: var(--gray-900);
  }
  .header-nav-item:hover > .header-nav-link .hnl-caret {
    transform: rotate(180deg);
  }
  .header-nav-item:hover > .header-nav-link .hnl-icon,
  .header-nav-item:hover > .header-nav-link .hnl-caret { color: var(--gray-600); }
}

/* ============================================================
   Phase 1f: cascading submenus (Reports menu)
   ============================================================ */

.submenu-parent { position: relative; }
.submenu-trigger {
  display: flex !important; align-items: center; gap: 10px;
  padding-right: 22px !important;
}
.submenu-trigger .submenu-caret {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--gray-400);
  transition: transform .12s ease, color .12s ease;
}
.submenu-parent:hover > .submenu-trigger .submenu-caret { color: var(--brand-600); transform: translateX(2px); }

.submenu-flyout {
  display: none;
  position: absolute !important;
  top: -8px !important; left: 100% !important;
  min-width: 240px;
  margin-left: 4px !important;
  margin-top: 0 !important;
  z-index: 1100;
}
@media (hover: hover) and (pointer: fine) and (min-width: 992px) {
  .submenu-parent:hover > .submenu-flyout {
    display: block;
  }
  /* Hover bridge to keep cursor connected */
  .submenu-flyout::before {
    content: '';
    position: absolute;
    left: -10px; top: 0; bottom: 0;
    width: 12px;
  }
}
/* Fallback: tap to toggle on small screens (no hover) */
.submenu-parent.show > .submenu-flyout { display: block; }

/* Phase 1g: compact user chip (avatar only — name/email moved to dropdown header) */
.user-chip-compact { padding: 4px 8px 4px 4px; gap: 6px; }
.user-chip-compact .user-avatar { width: 28px; height: 28px; }

/* Extended pill palette — for richer status differentiation */
.pill-purple  { background: var(--purple-50);   color: var(--purple-700);  border-color: var(--purple-200); }
.pill-purple .dot { background: var(--purple-500); box-shadow: 0 0 0 3px rgba(168,85,247,.14); }

.pill-teal    { background: #ecfeff;            color: #0e7490;            border-color: #a5f3fc; }
.pill-teal .dot { background: #06b6d4; box-shadow: 0 0 0 3px rgba(6,182,212,.14); }

.pill-pink    { background: #fdf2f8;            color: #be185d;            border-color: #fbcfe8; }
.pill-pink .dot { background: #ec4899; box-shadow: 0 0 0 3px rgba(236,72,153,.14); }

.pill-amber   { background: #fffbeb;            color: #92400e;            border-color: #fde68a; }
.pill-amber .dot { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.14); }

.pill-dark    { background: var(--gray-800);    color: #fff;               border-color: var(--gray-900); }
.pill-dark .dot { background: var(--gray-400); }
