/* ============================================================
   CRM — Design System v2
   ============================================================ */

:root {
    --ink:            #0d1424;
    --ink-2:          #161f33;
    --ink-3:          #1f2a42;
    --paper:          #f4f6f9;
    --surface:        #ffffff;
    --line:           #e3e8ef;
    --line-soft:      #eef1f6;

    --text:           #0d1424;
    --text-2:         #4a5769;
    --text-3:         #97a1b0;

    --accent:         #1f6feb;
    --accent-hover:   #1a5fd0;
    --accent-press:   #164fb0;
    --accent-soft:    #eaf1fe;
    --accent-ring:    rgba(31, 111, 235, .16);

    --won:     #0f766e;  --won-soft:    #e6f4f1;  --won-line:    #b9e0da;
    --lost:    #b42318;  --lost-soft:   #fdeceb;  --lost-line:   #f5c2be;
    --warn:    #b45309;  --warn-soft:   #fdf3e6;  --warn-line:   #f2d5a8;
    --info:    #175cd3;  --info-soft:   #eaf1fe;  --info-line:   #c2d8fb;
    --idle:    #5d6b82;  --idle-soft:   #eef1f5;  --idle-line:   #dde3ec;
    --violet:  #6941c6;  --violet-soft: #f2ebfd;  --violet-line: #e0d2fa;

    --r-xs: 5px;
    --r-sm: 7px;
    --r:    10px;
    --r-lg: 14px;

    /* Layered shadows — contact + diffusion reads as real depth */
    --shadow-xs: 0 1px 2px rgba(13, 20, 36, .05);
    --shadow-sm: 0 1px 2px rgba(13, 20, 36, .06), 0 1px 3px rgba(13, 20, 36, .04);
    --shadow:    0 2px 4px rgba(13, 20, 36, .05), 0 4px 12px rgba(13, 20, 36, .06);
    --shadow-md: 0 4px 8px rgba(13, 20, 36, .06), 0 12px 24px rgba(13, 20, 36, .08);
    --shadow-lg: 0 8px 16px rgba(13, 20, 36, .08), 0 24px 48px rgba(13, 20, 36, .14);

    --ease: cubic-bezier(.4, 0, .2, 1);
    --ease-out: cubic-bezier(.16, 1, .3, 1);

    --sidebar-w: 248px;
    --topbar-h:  62px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--paper);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; }
::selection { background: var(--accent-ring); }

.stat-info h3, .metric, .tabular, .rail-legend .n { font-variant-numeric: tabular-nums; }

/* Focus: one consistent ring everywhere */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--r-xs);
}

/* ============================================================
   SIDEBAR — light panel, collapsible to an icon rail
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--line);
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow: visible;   /* the toggle sits on the outer edge */
    transition: width .2s var(--ease);
}

.sidebar-logo {
    position: relative;
    height: var(--topbar-h);
    padding: 0 14px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}
.wordmark { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.wordmark .mark {
    width: 30px; height: 30px;
    border-radius: var(--r-sm);
    background: var(--accent);
    box-shadow: 0 2px 8px rgba(31,111,235,.32);
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .02em;
    flex-shrink: 0;
}
.wordmark-text { display: flex; flex-direction: column; min-width: 0; }
.wordmark-text .name { font-size: 14px; font-weight: 650; color: var(--text); letter-spacing: -.02em; line-height: 1.2; }
.wordmark-text .sub  { font-size: 10px; color: var(--text-3); letter-spacing: .02em; white-space: nowrap; }

.rail-btn {
    position: absolute;
    top: calc(var(--topbar-h) - 15px);
    right: -15px;
    z-index: 130;
    width: 30px; height: 30px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    transition: background .16s var(--ease), color .16s var(--ease),
                border-color .16s var(--ease), transform .16s var(--ease);
}
.rail-btn:hover {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--info-line);
}
.rail-btn:active { transform: scale(.92); }
.rail-btn i { transition: transform .22s var(--ease); }

.sidebar-nav { padding: 10px 0 16px; flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #dfe4ec; border-radius: 3px; }
.sidebar-nav:hover::-webkit-scrollbar-thumb { background: #cbd2dd; }

.nav-section {
    padding: 15px 20px 6px;
    font-size: 10px; font-weight: 650;
    color: var(--text-3);
    text-transform: uppercase; letter-spacing: .09em;
    white-space: nowrap;
}

.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 8px 12px;
    margin: 1px 10px;
    border-radius: var(--r-sm);
    color: var(--text-2);
    text-decoration: none;
    font-size: 13px; font-weight: 500;
    transition: background .15s var(--ease), color .15s var(--ease);
    position: relative;
    white-space: nowrap;
}
.nav-item:hover { background: var(--line-soft); color: var(--text); }
.nav-item:hover i { color: var(--text-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item.active i { color: var(--accent); }
/* Left marker on the active row — reads as position, not decoration */
.nav-item.active::before {
    content: ''; position: absolute; left: -10px; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 18px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}
.nav-item i { width: 17px; text-align: center; font-size: 13px; color: var(--text-3); flex-shrink: 0; transition: color .15s var(--ease); }
.nav-item span { overflow: hidden; text-overflow: ellipsis; }

.nav-count {
    margin-left: auto;
    background: var(--lost); color: #fff;
    font-size: 10px; font-weight: 650;
    padding: 1px 6px; border-radius: 10px;
    min-width: 18px; text-align: center;
    flex-shrink: 0;
}
.nav-item.active .nav-count { background: var(--accent); }

/* ── Collapsed rail ─────────────────────────────────────── */
body.rail { --sidebar-w: 68px; }
body.rail .nav-item span,
body.rail .nav-count,
body.rail .nav-section { display: none; }
body.rail .sidebar-logo { padding: 0; justify-content: center; }
body.rail .wordmark-text { display: none; }
body.rail .wordmark { justify-content: center; width: 100%; }
body.rail .wordmark .mark { width: 34px; height: 34px; font-size: 13px; }
body.rail .rail-btn i { transform: rotate(180deg); }

body.rail .nav-item { justify-content: center; padding: 10px; margin: 2px 10px; }
body.rail .nav-item i { width: auto; font-size: 15px; }
/* Label appears on hover so the rail stays usable */
body.rail .nav-item::after {
    content: attr(data-label);
    position: absolute; left: calc(100% + 10px);
    background: var(--ink); color: #fff;
    font-size: 12px; font-weight: 500;
    padding: 5px 9px; border-radius: var(--r-xs);
    white-space: nowrap;
    opacity: 0; pointer-events: none;
    transform: translateX(-4px);
    transition: opacity .14s var(--ease), transform .14s var(--ease);
    box-shadow: var(--shadow);
    z-index: 120;
}
body.rail .nav-item:hover::after { opacity: 1; transform: translateX(0); }
body.rail .nav-section + .nav-item { margin-top: 10px; }

/* ============================================================
   TOPBAR
   ============================================================ */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-width: 0; transition: margin-left .2s var(--ease); }

.topbar {
    background: rgba(255,255,255,.85);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    height: var(--topbar-h);
    padding: 0 20px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 6px; min-width: 0; }
.topbar-title { min-width: 0; }
.topbar h1 { font-size: 17px; font-weight: 650; color: var(--text); letter-spacing: -.025em; line-height: 1.25; }
.topbar .eyebrow { font-size: 10px; color: var(--text-3); font-weight: 650; letter-spacing: .09em; text-transform: uppercase; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.icon-btn {
    position: relative;
    width: 36px; height: 36px;
    border-radius: var(--r-sm);
    background: transparent;
    border: 1px solid transparent;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-2); font-size: 15px; text-decoration: none;
    transition: background .16s var(--ease), color .16s var(--ease);
}
.icon-btn:hover { background: var(--line-soft); color: var(--text); }
.notif-badge {
    position: absolute; top: 3px; right: 3px;
    min-width: 16px; height: 16px; padding: 0 4px;
    background: var(--lost); color: #fff;
    border: 2px solid #fff; border-radius: 8px;
    font-size: 9px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}

/* ── Account menu ───────────────────────────────────────── */
.account { position: relative; }
.account-btn {
    display: flex; align-items: center; gap: 9px;
    padding: 5px 9px 5px 5px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 40px;
    cursor: pointer;
    font-family: inherit;
    transition: background .16s var(--ease), border-color .16s var(--ease);
}
.account-btn:hover { background: var(--line-soft); border-color: #cfd6e0; }
.account-meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.account-meta .n { font-size: 13px; font-weight: 600; color: var(--text); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-meta .r { font-size: 11px; color: var(--text-3); }
.account-btn .caret { font-size: 10px; color: var(--text-3); transition: transform .18s var(--ease); }
.account-btn[aria-expanded="true"] .caret { transform: rotate(180deg); }

.avatar-circle {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #4a8bf0);
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 650; font-size: 12px;
    flex-shrink: 0; letter-spacing: .02em;
}
.avatar-circle.lg { width: 42px; height: 42px; font-size: 15px; }

.account-menu {
    position: absolute; top: calc(100% + 8px); right: 0;
    width: 272px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
    opacity: 0; visibility: hidden;
    transform: translateY(-6px);
    transition: opacity .16s var(--ease), transform .16s var(--ease), visibility .16s;
    z-index: 120;
    overflow: hidden;
}
.account-menu.open { opacity: 1; visibility: visible; transform: translateY(0); }
.account-head {
    display: flex; gap: 11px; align-items: flex-start;
    padding: 15px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, #fbfcfd, var(--surface));
}
.account-head .n { font-size: 14px; font-weight: 650; color: var(--text); }
.account-head .e { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; }
.account-links { padding: 6px; }
.account-links a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 11px;
    border-radius: var(--r-sm);
    color: var(--text-2);
    text-decoration: none;
    font-size: 13px; font-weight: 500;
    transition: background .14s var(--ease), color .14s var(--ease);
}
.account-links a:hover { background: var(--line-soft); color: var(--text); }
.account-links i { width: 15px; text-align: center; font-size: 13px; color: var(--text-3); }
.account-foot { padding: 6px; border-top: 1px solid var(--line); }
.account-foot .signout {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 11px;
    border-radius: var(--r-sm);
    color: var(--lost);
    text-decoration: none;
    font-size: 13px; font-weight: 550;
    transition: background .14s var(--ease);
}
.account-foot .signout:hover { background: var(--lost-soft); }
.account-foot .signout i { width: 15px; text-align: center; font-size: 13px; }

.content { padding: 22px 24px; flex: 1; max-width: 1640px; width: 100%; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 20px;
    box-shadow: var(--shadow-xs);
    transition: box-shadow .2s var(--ease);
}
.card:hover { box-shadow: var(--shadow-sm); }

.card-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    margin: -20px -20px 18px;
    padding: 15px 20px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, #fbfcfd, var(--surface));
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    flex-wrap: wrap;
}
.card-title {
    font-size: 14px; font-weight: 600; color: var(--text);
    letter-spacing: -.01em;
    display: flex; align-items: center; gap: 8px;
}
.card-title i { color: var(--text-3); font-size: 13px; }
.card.flush { padding: 0; }
.card.flush .card-header { margin: 0; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 7px;
    padding: 9px 15px;
    border-radius: var(--r-sm);
    font-size: 13px; font-weight: 550; line-height: 1.25;
    cursor: pointer; text-decoration: none;
    border: 1px solid transparent;
    font-family: inherit;
    white-space: nowrap;
    position: relative;
    transition: background .16s var(--ease), border-color .16s var(--ease),
                color .16s var(--ease), box-shadow .16s var(--ease),
                transform .12s var(--ease);
}
.btn i { font-size: 12px; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] {
    opacity: .5; cursor: not-allowed; transform: none;
}

.btn-primary {
    background: var(--accent); color: #fff;
    box-shadow: 0 1px 2px rgba(13,20,36,.08), 0 2px 8px rgba(31,111,235,.28);
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 2px 4px rgba(13,20,36,.1), 0 6px 16px rgba(31,111,235,.35); }
.btn-primary:active { background: var(--accent-press); }

.btn-secondary {
    background: var(--surface); color: var(--text-2);
    border-color: var(--line);
    box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: #fbfcfd; border-color: #cfd6e0; color: var(--text); box-shadow: var(--shadow-sm); }

.btn-success { background: var(--won); color: #fff; box-shadow: 0 1px 2px rgba(13,20,36,.08), 0 2px 8px rgba(15,118,110,.26); }
.btn-success:hover { background: #0c5f59; }

.btn-danger { background: var(--lost); color: #fff; box-shadow: 0 1px 2px rgba(13,20,36,.08), 0 2px 8px rgba(180,35,24,.26); }
.btn-danger:hover { background: #99201a; }

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

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--line-soft); color: var(--text); }

.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: var(--r-xs); }
.btn-lg { padding: 12px 20px; font-size: 14px; }
.btn-icon { padding: 7px 9px; }
.btn-block { width: 100%; }

/* Icon-only action buttons in table rows — quiet until hovered */
.row-actions { display: inline-flex; gap: 4px; white-space: nowrap; }
.row-actions .btn-sm { padding: 6px 8px; }
.row-actions .btn-secondary { color: var(--text-3); box-shadow: none; }
.row-actions .btn-secondary:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.row-actions .btn-danger { background: transparent; color: var(--text-3); border-color: var(--line); box-shadow: none; }
.row-actions .btn-danger:hover { background: var(--lost-soft); color: var(--lost); border-color: var(--lost-line); }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); margin-left: 0; }
.btn-group .btn:last-child  { border-radius: 0 var(--r-sm) var(--r-sm) 0; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: 12px 15px;
    border-radius: var(--r);
    margin-bottom: 18px;
    font-size: 13px; font-weight: 450;
    display: flex; align-items: center; gap: 10px;
    border: 1px solid;
    box-shadow: var(--shadow-xs);
}
.alert i { font-size: 14px; flex-shrink: 0; }
.alert-success { background: var(--won-soft);  color: #0b5d56; border-color: var(--won-line); }
.alert-error   { background: var(--lost-soft); color: #91201a; border-color: var(--lost-line); }
.alert-info    { background: var(--info-soft); color: #14448f; border-color: var(--info-line); }
.alert-warn    { background: var(--warn-soft); color: #8a4108; border-color: var(--warn-line); }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; }
th {
    background: #f8fafc;
    padding: 10px 14px;
    text-align: left;
    font-size: 11px; font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase; letter-spacing: .05em;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
    position: sticky; top: 0; z-index: 1;
}
td {
    padding: 12px 14px;
    font-size: 13px;
    color: var(--text-2);
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}
td strong { color: var(--text); font-weight: 600; }
tbody tr { transition: background .12s var(--ease); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty-state .icon { font-size: 28px; color: #cfd6e0; margin-bottom: 12px; }
.empty-state .headline { font-size: 14px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px;
    border-radius: var(--r-xs);
    font-size: 11px; font-weight: 600; line-height: 1.5;
    white-space: nowrap;
    border: 1px solid transparent;
}
.badge:not([class*="badge-"]), .badge-default { background: var(--idle-soft); color: var(--idle); border-color: var(--idle-line); }

.badge-new, .badge-leadgenerated, .badge-assigned, .badge-scheduled, .badge-rescheduled
    { background: var(--info-soft); color: var(--info); border-color: var(--info-line); }
.badge-inprogress, .badge-interviewscheduled, .badge-proposal, .badge-proposalsent, .badge-offersent
    { background: var(--violet-soft); color: var(--violet); border-color: var(--violet-line); }
.badge-contacted, .badge-firstcallscheduled, .badge-negotiation, .badge-pending, .badge-sent
    { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.badge-qualified, .badge-developershortlisted, .badge-won, .badge-closedwon, .badge-dealclosed, .badge-passed, .badge-completed
    { background: var(--won-soft); color: var(--won); border-color: var(--won-line); }
.badge-lost, .badge-closedlost, .badge-failed, .badge-notcompleted, .badge-expired, .badge-cancelled
    { background: var(--lost-soft); color: var(--lost); border-color: var(--lost-line); }
.badge-deadlead, .badge-hold, .badge-onhold, .badge-notconducted
    { background: var(--idle-soft); color: var(--idle); border-color: var(--idle-line); }

.badge-high   { background: var(--lost-soft); color: var(--lost); border-color: var(--lost-line); }
.badge-medium { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.badge-low    { background: var(--idle-soft); color: var(--idle); border-color: var(--idle-line); }

.badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 550; color: var(--text-2); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea, .input, select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    font-size: 13px; font-family: inherit; color: var(--text);
    outline: none; background: var(--surface);
    box-shadow: var(--shadow-xs);
    transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.form-group input::placeholder, .input::placeholder { color: var(--text-3); }
.form-group input:hover, .form-group select:hover, .form-group textarea:hover { border-color: #cfd6e0; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus, .input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
    outline: none;
}
.form-group input:disabled, .form-group select:disabled { background: var(--paper); color: var(--text-3); cursor: not-allowed; }
.form-group .hint { font-size: 11px; color: var(--text-3); margin-top: 5px; }
textarea { resize: vertical; min-height: 76px; }

.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-bar .input, .filter-bar select { width: auto; min-width: 150px; }
.filter-bar .grow { flex: 1; min-width: 200px; }

/* ============================================================
   STATS
   ============================================================ */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 17px 18px;
    box-shadow: var(--shadow-xs);
    display: flex; align-items: center; gap: 14px;
    position: relative;
    overflow: hidden;
    transition: box-shadow .2s var(--ease), transform .2s var(--ease);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
/* Top rule picks up the icon's hue — ties the tile to its metric */
.stat-card::before {
    content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
    background: var(--accent); opacity: .9;
}
.stat-card:has(.stat-icon.green)::before  { background: var(--won); }
.stat-card:has(.stat-icon.red)::before    { background: var(--lost); }
.stat-card:has(.stat-icon.purple)::before { background: var(--violet); }
.stat-card:has(.stat-icon.amber)::before  { background: var(--warn); }
.stat-card:has(.stat-icon.blue)::before   { background: var(--info); }

.stat-icon {
    width: 40px; height: 40px;
    border-radius: var(--r);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; flex-shrink: 0;
}
.stat-icon.blue   { background: var(--info-soft);   color: var(--info); }
.stat-icon.red    { background: var(--lost-soft);   color: var(--lost); }
.stat-icon.green  { background: var(--won-soft);    color: var(--won); }
.stat-icon.purple { background: var(--violet-soft); color: var(--violet); }
.stat-icon.amber  { background: var(--warn-soft);   color: var(--warn); }

.stat-info h3 { font-size: 23px; font-weight: 650; color: var(--text); letter-spacing: -.025em; line-height: 1.15; }
.stat-info p  { font-size: 12px; color: var(--text-3); margin-top: 2px; font-weight: 500; }

/* ============================================================
   PIPELINE RAIL
   ============================================================ */
.pipeline-rail {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 17px 19px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-xs);
}
.pipeline-rail .rail-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 13px; }
.pipeline-rail .rail-head .label { font-size: 11px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .07em; }
.pipeline-rail .rail-head .total { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.rail-track { display: flex; height: 9px; border-radius: 5px; overflow: hidden; background: var(--line-soft); gap: 2px; }
.rail-seg { height: 100%; transition: opacity .16s var(--ease); }
.rail-seg:hover { opacity: .72; }
.rail-legend { display: flex; flex-wrap: wrap; gap: 7px 20px; margin-top: 14px; }
.rail-legend .item { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.rail-legend .swatch { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.rail-legend .name { color: var(--text-2); }
.rail-legend .n { font-weight: 650; color: var(--text); }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .title { font-size: 20px; font-weight: 600; letter-spacing: -.025em; }
.page-head .desc { font-size: 13px; color: var(--text-2); margin-top: 3px; }

.scope-note {
    display: flex; align-items: center; gap: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--r) var(--r) 0;
    padding: 11px 15px;
    margin-bottom: 18px;
    font-size: 13px; color: var(--text-2);
    box-shadow: var(--shadow-xs);
}
.scope-note i { color: var(--accent); font-size: 13px; }
.scope-note strong { color: var(--text); font-weight: 600; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(13, 20, 36, .5);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 200;
    align-items: center; justify-content: center;
    padding: 20px;
}
.modal-overlay.open { display: flex; animation: fade .2s var(--ease-out); }
.modal {
    background: var(--surface);
    border-radius: var(--r-lg);
    width: 100%; max-width: 620px; max-height: 88vh;
    overflow-y: auto; padding: 24px;
    box-shadow: var(--shadow-lg);
    animation: rise .28s var(--ease-out);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title { font-size: 16px; font-weight: 600; color: var(--text); }
.modal-close {
    width: 32px; height: 32px;
    border-radius: var(--r-sm);
    background: var(--paper); border: 1px solid var(--line);
    cursor: pointer; font-size: 14px; color: var(--text-2);
    display: flex; align-items: center; justify-content: center;
    transition: background .16s var(--ease), color .16s var(--ease);
}
.modal-close:hover { background: var(--line-soft); color: var(--text); }

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.985) } to { opacity: 1; transform: none } }

/* ============================================================
   UTILITIES
   ============================================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.muted  { color: var(--text-3); }
.meta   { font-size: 11px; color: var(--text-3); }
.stack  { display: flex; flex-direction: column; gap: 16px; }
.mb-0   { margin-bottom: 0 !important; }

.progress { height: 6px; background: var(--line-soft); border-radius: 4px; overflow: hidden; flex: 1; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .4s var(--ease-out); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

@media (max-width: 900px) {
    body.rail { --sidebar-w: 248px; }
    body.rail .wordmark-text, body.rail .nav-item span,
    body.rail .nav-count, body.rail .nav-section { display: revert; }
    body.rail .nav-item { justify-content: flex-start; padding: 8px 12px; }
    body.rail .nav-item::after { display: none; }
    .account-meta { display: none; }
    .account-btn { border-radius: 50%; padding: 3px; border-color: transparent; }
    .account-btn .caret { display: none; }
    .sidebar { transform: translateX(-100%); transition: transform .26s var(--ease-out); box-shadow: var(--shadow-lg); }
    body.nav-open .sidebar { transform: translateX(0); }
    .nav-scrim { display: none; }
    body.nav-open .nav-scrim {
        display: block; position: fixed; inset: 0;
        background: rgba(13, 20, 36, .45);
        backdrop-filter: blur(2px);
        z-index: 99;
    }
    .main { margin-left: 0; }
    .nav-toggle { display: inline-flex !important; }
    .content { padding: 16px; }
    .grid-2, .grid-3, .form-row, .form-row-3 { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .stats-grid { grid-template-columns: 1fr; }
    .topbar { padding: 0 14px; }
    .topbar h1 { font-size: 15px; }
    .card { padding: 16px; }
    .card-header { margin: -16px -16px 14px; padding: 13px 16px; }
}

.nav-toggle {
    display: none;
    width: 36px; height: 36px;
    border-radius: var(--r-sm);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
    align-items: center; justify-content: center;
    font-size: 15px; margin-right: 6px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
    .sidebar, .topbar, #chatFab, #chatPanel, .btn, .nav-scrim { display: none !important; }
    .main { margin-left: 0; }
    .card { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; }
    body { background: #fff; }
}

/* ============================================================
   FILTER BAR — every list page uses this one shape
   ============================================================ */
.filters {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 12px 14px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-xs);
}
.filters form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }

.f-field { display: flex; flex-direction: column; gap: 4px; min-width: 150px; }
.f-field.grow { flex: 1 1 220px; min-width: 200px; }
.f-field.sm   { min-width: 120px; flex: 0 0 auto; }
.f-field > label {
    font-size: 10px; font-weight: 650; color: var(--text-3);
    text-transform: uppercase; letter-spacing: .07em;
}
.f-field input, .f-field select {
    width: 100%; height: 36px;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    font-size: 13px; font-family: inherit; color: var(--text);
    background: var(--surface); outline: none;
    transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.f-field input:focus, .f-field select:focus {
    border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring);
}
/* Search field with a leading icon */
.f-search { position: relative; }
.f-search i {
    position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
    color: var(--text-3); font-size: 12px; pointer-events: none;
}
.f-search input { padding-left: 31px; }

.f-actions { display: flex; gap: 8px; align-items: flex-end; margin-left: auto; }
.f-actions .btn { height: 36px; }

/* Active filter chips */
.f-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.f-chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--accent-soft); color: var(--accent);
    border: 1px solid var(--info-line);
    border-radius: 20px;
    padding: 3px 6px 3px 10px;
    font-size: 11px; font-weight: 550;
}
.f-chip a { color: inherit; text-decoration: none; opacity: .65; display: inline-flex; padding: 2px; }
.f-chip a:hover { opacity: 1; }

@media (max-width: 700px) {
    .filters form { flex-direction: column; align-items: stretch; }
    .f-field, .f-field.grow, .f-field.sm { min-width: 0; width: 100%; }
    .f-actions { margin-left: 0; }
    .f-actions .btn { flex: 1; }
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; flex-wrap: wrap;
    padding: 12px 16px;
    border-top: 1px solid var(--line);
    background: #fbfcfd;
    border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.pg-count { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.pg-count strong { color: var(--text); font-weight: 650; }
.pg-links { display: flex; align-items: center; gap: 3px; }
.pg-btn {
    min-width: 32px; height: 32px;
    padding: 0 8px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line);
    border-radius: var(--r-xs);
    background: var(--surface);
    color: var(--text-2);
    font-size: 13px; font-weight: 500;
    text-decoration: none;
    font-variant-numeric: tabular-nums;
    transition: background .14s var(--ease), border-color .14s var(--ease), color .14s var(--ease);
}
.pg-btn:hover:not(.disabled):not(.active) { background: var(--line-soft); border-color: #cfd6e0; color: var(--text); }
.pg-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 650; }
.pg-btn.disabled { opacity: .4; cursor: default; }
.pg-btn i { font-size: 10px; }
.pg-gap { padding: 0 2px; color: var(--text-3); font-size: 13px; }

/* A card that ends in a pagination bar shouldn't double up its padding */
.card.flush .pagination { margin: 0; }

@media (max-width: 600px) {
    .pagination { justify-content: center; }
    .pg-count { width: 100%; text-align: center; }
}

/* Report pages keep their own filter form; give it the shared shape */
.dpr-filter { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.dpr-filter .input, .dpr-filter select, .dpr-filter input { height: 36px; min-width: 150px; width: auto; }
.dpr-filter .btn { height: 36px; }

/* ============================================================
   COLLAPSIBLE NAV GROUPS
   ============================================================ */
.nav-group { overflow: hidden; }
.nav-section {
    display: flex; align-items: center; gap: 7px;
    cursor: pointer;
    user-select: none;
    transition: color .14s var(--ease);
}
.nav-section:hover { color: var(--text-2); }
.nav-section:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--r-xs); }
.ns-caret {
    font-size: 8px;
    color: var(--text-3);
    transition: transform .2s var(--ease);
    flex-shrink: 0;
}
.nav-group.collapsed .ns-caret { transform: rotate(-90deg); }
.nav-group.collapsed .nav-item { display: none; }

/* Sidebar logo can hold an uploaded image instead of the letter mark */
.wordmark .mark.logo { background: transparent; box-shadow: none; padding: 2px; }
.wordmark .mark.logo img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }

/* In the collapsed icon rail, section headers are hidden anyway */
body.rail .nav-group.collapsed .nav-item { display: flex; }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
    position: fixed; left: 50%; bottom: 26px;
    transform: translateX(-50%) translateY(14px);
    background: var(--ink); color: #fff;
    font-size: 13px; font-weight: 500;
    padding: 10px 16px; border-radius: var(--r);
    box-shadow: var(--shadow-lg);
    opacity: 0; pointer-events: none;
    transition: opacity .18s var(--ease), transform .18s var(--ease);
    z-index: 300; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad  { background: var(--lost); }

/* Panel used inside the lead form to group linked records */
.link-panel {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 14px;
    margin-bottom: 16px;
}
.link-panel-title {
    font-size: 13px; font-weight: 600; color: var(--text);
    margin-bottom: 12px; display: flex; align-items: center; gap: 7px;
}
.link-panel-title i { color: var(--accent); font-size: 12px; }

/* ============================================================
   COLOUR PASS
   Each nav section and metric family carries its own hue, so
   colour signals *where you are* rather than just decorating.
   ============================================================ */

/* ── Sidebar: tinted icons per section ─────────────────────── */
.nav-group:nth-of-type(1) .nav-item i { color: #1f6feb; }  /* Overview  */
.nav-group:nth-of-type(2) .nav-item i { color: #0f766e; }  /* Pipeline  */
.nav-group:nth-of-type(3) .nav-item i { color: #6941c6; }  /* Hiring    */
.nav-group:nth-of-type(4) .nav-item i { color: #b45309; }  /* Accounts  */
.nav-group:nth-of-type(5) .nav-item i { color: #0891b2; }  /* Reporting */
.nav-group:nth-of-type(6) .nav-item i { color: #be185d; }  /* Workspace */
.nav-group:nth-of-type(7) .nav-item i { color: #b42318; }  /* Admin     */
/* Active row: force white, and beat the per-section hue above */
.sidebar .nav-group .nav-item.active i,
.sidebar .nav-item.active i { color: #fff; }
.sidebar .nav-group .nav-item:hover i { color: var(--text); }
.sidebar .nav-group .nav-item.active:hover i { color: #fff; }

/* Active row keeps the accent fill but gains depth */
.nav-item.active {
    background: linear-gradient(135deg, #1657c4, #2b7bf3);
    color: #fff;
    box-shadow: 0 2px 8px rgba(22, 87, 196, .34);
}
.nav-item.active::before { background: #0b3d91; }

/* Section headings get a coloured dot matching their group */
.nav-section::after {
    content: '';
    width: 5px; height: 5px; border-radius: 50%;
    margin-left: auto; flex-shrink: 0; opacity: .55;
}
.nav-group:nth-of-type(1) .nav-section::after { background: #1f6feb; }
.nav-group:nth-of-type(2) .nav-section::after { background: #0f766e; }
.nav-group:nth-of-type(3) .nav-section::after { background: #6941c6; }
.nav-group:nth-of-type(4) .nav-section::after { background: #b45309; }
.nav-group:nth-of-type(5) .nav-section::after { background: #0891b2; }
.nav-group:nth-of-type(6) .nav-section::after { background: #be185d; }
.nav-group:nth-of-type(7) .nav-section::after { background: #b42318; }

/* ── Topbar: subtle tint so it reads as a distinct band ────── */
.topbar {
    background: linear-gradient(180deg, rgba(255,255,255,.95), rgba(248,250,253,.92));
}

/* ── KPI tiles: gradient wash keyed to the metric ──────────── */
.kpi { position: relative; overflow: hidden; }
.kpi::after {
    content: '';
    position: absolute; top: -40px; right: -40px;
    width: 130px; height: 130px; border-radius: 50%;
    opacity: .07; pointer-events: none;
    transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.kpi:hover::after { opacity: .13; transform: scale(1.12); }
.kpi:nth-child(1)::after { background: #1f6feb; }
.kpi:nth-child(2)::after { background: #0f766e; }
.kpi:nth-child(3)::after { background: #6941c6; }
.kpi:nth-child(4)::after { background: #b45309; }

.kpi:nth-child(1) .kpi-value { color: #1a5fd0; }
.kpi:nth-child(2) .kpi-value { color: #0f766e; }
.kpi:nth-child(3) .kpi-value { color: #6941c6; }
.kpi:nth-child(4) .kpi-value { color: #b45309; }

/* Stat icons get a soft gradient rather than a flat wash */
.stat-icon.blue   { background: linear-gradient(135deg, #eaf1fe, #d7e6fd); }
.stat-icon.green  { background: linear-gradient(135deg, #e6f4f1, #d0ebe6); }
.stat-icon.purple { background: linear-gradient(135deg, #f2ebfd, #e6d9fb); }
.stat-icon.red    { background: linear-gradient(135deg, #fdeceb, #fbdad7); }
.stat-icon.amber  { background: linear-gradient(135deg, #fdf3e6, #fbe7cc); }

/* ── Buttons: gradient primaries ───────────────────────────── */
.btn-primary { background: linear-gradient(135deg, #1f6feb, #3b82f6); }
.btn-primary:hover { background: linear-gradient(135deg, #1a5fd0, #2f74e8); }
.btn-success { background: linear-gradient(135deg, #0f766e, #14918a); }
.btn-danger  { background: linear-gradient(135deg, #b42318, #d32d20); }

/* ── Cards: coloured top edge on hover ─────────────────────── */
.card { position: relative; }
.card::before {
    content: '';
    position: absolute; inset: 0 0 auto 0; height: 3px;
    background: linear-gradient(90deg, #1f6feb, #6941c6, #0f766e);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    opacity: 0; transition: opacity .25s var(--ease);
}
.card:hover::before { opacity: .8; }

/* ── Avatars cycle through the palette ─────────────────────── */
.avatar-circle { background: linear-gradient(135deg, #1f6feb, #4a8bf0); }
.board-row:nth-child(2n)   .avatar-circle { background: linear-gradient(135deg, #0f766e, #14a89d); }
.board-row:nth-child(3n)   .avatar-circle { background: linear-gradient(135deg, #6941c6, #8b5cf6); }
.board-row:nth-child(4n)   .avatar-circle { background: linear-gradient(135deg, #b45309, #d97706); }
.dev-card:nth-child(2n) .dev-avatar { background: linear-gradient(135deg, #0f766e, #14a89d); }
.dev-card:nth-child(3n) .dev-avatar { background: linear-gradient(135deg, #6941c6, #8b5cf6); }
.dev-card:nth-child(4n) .dev-avatar { background: linear-gradient(135deg, #b45309, #d97706); }
.dev-card:nth-child(5n) .dev-avatar { background: linear-gradient(135deg, #be185d, #db2777); }

/* ── Table headers ─────────────────────────────────────────── */
th { background: linear-gradient(180deg, #f8fafc, #f1f5f9); }

/* ── Rank medals ───────────────────────────────────────────── */
.rank.r1 { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #fff; }
.rank.r2 { background: linear-gradient(135deg, #cbd5e1, #94a3b8); color: #fff; }
.rank.r3 { background: linear-gradient(135deg, #d8a07a, #b87333); color: #fff; }

/* ── Login brand panel ─────────────────────────────────────── */
.auth-brand { background: linear-gradient(150deg, #0d1424 0%, #14264a 55%, #1a3a6b 100%); }

/* ── Bulk action bar (reminders) ───────────────────────────── */
.bulk-bar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; flex-wrap: wrap;
    background: linear-gradient(135deg, var(--accent-soft), #f2f7ff);
    border: 1px solid var(--info-line);
    border-radius: var(--r-lg);
    padding: 11px 15px;
    margin-bottom: 14px;
}
.bulk-info { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-2); }
.bulk-info i { color: var(--accent); font-size: 14px; }
.bulk-info strong { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }
.bulk-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

@media (max-width: 700px) {
    .bulk-bar { flex-direction: column; align-items: stretch; }
    .bulk-actions { justify-content: stretch; }
    .bulk-actions .btn { flex: 1; }
}

/* ============================================================
   WIDE DATA GRIDS
   Tables with many columns shouldn't compress cells until words
   break. Give them a floor width and scroll horizontally instead.
   ============================================================ */
.grid-wide { min-width: 1500px; }
/* 9-column grids need less room than the 10-column pipeline view */
.grid-wide.grid-md { min-width: 1050px; }
.grid-wide td { vertical-align: top; }

/* Badges and pills must never wrap mid-phrase */
.badge, .chip, .grid-wide td > span[style*="border-radius:20px"] {
    white-space: nowrap;
}

/* Company / person names: break only between words, never mid-word */
.grid-wide td strong,
.grid-wide td > div:first-child {
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: none;
}

/* The scroll container needs a visible affordance */
.table-wrap { position: relative; }
.table-wrap::-webkit-scrollbar { height: 9px; }
.table-wrap::-webkit-scrollbar-track { background: var(--line-soft); border-radius: 5px; }
.table-wrap::-webkit-scrollbar-thumb { background: #cbd2dd; border-radius: 5px; }
.table-wrap::-webkit-scrollbar-thumb:hover { background: #aab3c0; }

/* Sticky first column so the row stays identifiable while scrolling */
.grid-wide thead th:nth-child(2),
.grid-wide tbody td:nth-child(2) {
    position: sticky; left: 0; z-index: 2;
    box-shadow: 1px 0 0 var(--line);
}
.grid-wide tbody td:nth-child(2) { background: var(--surface); }
.grid-wide tbody tr:nth-child(even) td:nth-child(2) { background: #f8fafc; }
.grid-wide thead th:nth-child(2) { z-index: 3; }

@media (max-width: 900px) {
    .grid-wide thead th:nth-child(2),
    .grid-wide tbody td:nth-child(2) { position: static; box-shadow: none; }
}
