/* ==========================================================================
   Lead Portal — Design System
   Concept: "Signal" — leads move from cold to hot; the product's visual
   language is built around clear status signals on a calm, dense-data
   surface. One accent (Signal Blue), used with restraint.
   ========================================================================== */

:root {
    /* ---- Color tokens ---- */
    --ink: #12151c;
    --ink-soft: #1b1f28;
    --ink-softer: #242938;
    --paper: #f5f6f8;
    --surface: #ffffff;
    --border: #e4e7ec;
    --border-soft: #edeff2;

    --text: #1a1d24;
    --text-muted: #667085;
    --text-faint: #98a0ae;
    --text-inverse: #e9ebf1;
    --text-inverse-muted: #8b93a7;

    --signal: #2954e5;
    --signal-dark: #1e3fb8;
    --signal-soft: #eaf0ff;
    --ember: #dc4c3e;
    --ember-soft: #fdeceb;
    --sage: #17845b;
    --sage-soft: #e7f6ef;
    --amber: #b5750a;
    --amber-soft: #fbf1de;

    /* ---- Scale ---- */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;

    /* ---- Type ---- */
    --font-display: 'Space Grotesk', 'Inter', sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;

    /* Bootstrap variable overrides (Bootstrap 5.3 consumes these) */
    --bs-body-font-family: var(--font-body);
    --bs-body-color: var(--text);
    --bs-body-bg: var(--paper);
    --bs-border-color: var(--border);
    --bs-border-radius: var(--radius-sm);
    --bs-border-radius-lg: var(--radius);
    --bs-primary: var(--signal);
    --bs-primary-rgb: 41, 84, 229;
    --bs-link-color: var(--signal);
    --bs-link-hover-color: var(--signal-dark);
}

body {
    background: var(--paper);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14.5px;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, .font-display {
    font-family: var(--font-display);
    letter-spacing: -0.01em;
}

code, .font-mono {
    font-family: var(--font-mono);
    font-size: 0.85em;
}

a { color: var(--signal); }
a:hover { color: var(--signal-dark); }

/* ---- App Shell ---- */
.app-shell { min-height: 100vh; }

.app-sidebar {
    width: 248px;
    flex-shrink: 0;
    background: var(--ink);
    color: var(--text-inverse);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 20px 18px;
}

.app-brand-mark {
    display: inline-flex;
    align-items: flex-end;
    gap: 2.5px;
    height: 20px;
}
.app-brand-mark span {
    display: block;
    width: 4px;
    background: var(--signal);
    border-radius: 2px;
}
.app-brand-mark span:nth-child(1) { height: 8px; }
.app-brand-mark span:nth-child(2) { height: 14px; background: #5b7cf0; }
.app-brand-mark span:nth-child(3) { height: 20px; background: var(--text-inverse); }

.app-brand-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.05rem;
    color: #fff;
    line-height: 1.1;
}

.nav-group-label {
    padding: 20px 20px 6px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-inverse-muted);
}

.app-nav { padding: 4px 12px; display: flex; flex-direction: column; gap: 1px; }

.app-nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-inverse-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    position: relative;
    transition: background 0.12s ease, color 0.12s ease;
}
.app-nav-link i { width: 16px; text-align: center; font-size: 0.85rem; opacity: 0.85; }
.app-nav-link:hover { background: var(--ink-soft); color: #fff; text-decoration: none; }
.app-nav-link.active { background: var(--ink-softer); color: #fff; }
.app-nav-link.active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: var(--signal);
    border-radius: 0 3px 3px 0;
}

/* ---- Topbar ---- */
.app-topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}
.app-topbar-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.15rem;
    color: var(--text);
}

.role-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: capitalize;
    background: var(--signal-soft);
    color: var(--signal-dark);
}
.role-chip.role-owner { background: var(--ember-soft); color: var(--ember); }
.role-chip.role-admin { background: var(--amber-soft); color: var(--amber); }

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--ink);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: var(--font-display);
}

.app-content { padding: 26px 28px 60px; }

/* ---- Cards ---- */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: none;
}
.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border-soft);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.95rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--signal);
}
.stat-card .stat-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 6px;
}
.stat-card .stat-value {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text);
}

/* ---- Buttons ---- */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 550;
    font-size: 0.87rem;
    padding: 7px 15px;
}
.btn-primary {
    background: var(--signal);
    border-color: var(--signal);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--signal-dark);
    border-color: var(--signal-dark);
}
.btn-outline-primary {
    color: var(--signal);
    border-color: var(--signal);
}
.btn-outline-primary:hover {
    background: var(--signal);
    border-color: var(--signal);
}
.btn-outline-danger { color: var(--ember); border-color: var(--ember); }
.btn-outline-danger:hover { background: var(--ember); border-color: var(--ember); }
.btn-light { background: var(--paper); border: 1px solid var(--border); color: var(--text); }
.btn-light:hover { background: var(--border-soft); }
.btn-success { background: var(--sage); border-color: var(--sage); }
.btn-secondary { background: var(--text-faint); border-color: var(--text-faint); }

/* ---- Forms ---- */
.form-control, .form-select {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    padding: 8px 12px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--signal);
    box-shadow: 0 0 0 3px var(--signal-soft);
}
.form-label {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text);
    margin-bottom: 5px;
}
.form-text { color: var(--text-faint); font-size: 0.78rem; }

/* ---- Tables ---- */
.table { font-size: 0.87rem; }
.table thead th {
    background: var(--paper);
    border-bottom: 1px solid var(--border);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
    padding: 10px 14px;
}
.table td { padding: 11px 14px; vertical-align: middle; border-color: var(--border-soft); }
.table-hover tbody tr:hover { background: var(--paper); }

/* ---- Badges / status pills ---- */
.badge { font-weight: 600; font-size: 0.7rem; letter-spacing: 0.02em; border-radius: 5px; }
.status-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-right: 6px;
}
.status-dot.on { background: var(--sage); }
.status-dot.off { background: var(--text-faint); }

/* ---- Lead status pills ---- */
.lead-status { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }
.lead-status.pending    { background: var(--border-soft); color: var(--text-muted); }
.lead-status.assigned   { background: var(--signal-soft); color: var(--signal-dark); }
.lead-status.contacted  { background: var(--amber-soft); color: var(--amber); }
.lead-status.interested { background: #eafaf3; color: #0f7a4f; }
.lead-status.converted  { background: var(--sage-soft); color: var(--sage); }
.lead-status.lost       { background: var(--ember-soft); color: var(--ember); }

.masked-field { color: var(--text-faint); font-style: italic; font-size: 0.82rem; }
.timeline-item { border-left: 2px solid var(--border); padding: 0 0 16px 16px; position: relative; }
.timeline-item::before { content: ''; position: absolute; left: -5px; top: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--signal); }
.timeline-item:last-child { padding-bottom: 0; }

/* ---- Notification bell ---- */
.bell-btn { position: relative; background: none; border: none; color: var(--text-muted); font-size: 1.05rem; padding: 6px 8px; border-radius: var(--radius-sm); }
.bell-btn:hover { background: var(--paper); color: var(--text); }
.bell-count {
    position: absolute; top: 1px; right: 1px;
    background: var(--ember); color: #fff;
    font-size: 0.62rem; font-weight: 700;
    min-width: 15px; height: 15px; border-radius: 999px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 3px; line-height: 1;
}
.notif-dropdown { width: 340px; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(20,25,35,0.14); }
.notif-item { display: block; padding: 11px 16px; border-bottom: 1px solid var(--border-soft); text-decoration: none; color: var(--text); }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--paper); color: var(--text); }
.notif-item.unread { background: var(--signal-soft); }
.notif-item .notif-title { font-weight: 600; font-size: 0.85rem; }
.notif-item .notif-msg { font-size: 0.78rem; color: var(--text-muted); margin-top: 1px; }
.notif-item .notif-time { font-size: 0.7rem; color: var(--text-faint); margin-top: 2px; }
.notif-empty { padding: 28px 16px; text-align: center; color: var(--text-faint); font-size: 0.85rem; }

/* ---- Access grid (permissions display) ---- */
.access-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 2px; }
.access-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.76rem;
    color: var(--text-muted);
}
.access-item .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.access-item.allowed .dot { background: var(--sage); }
.access-item.allowed { color: var(--text); }
.access-item.denied .dot { background: var(--border); }
.access-item.denied { color: var(--text-faint); }

/* ---- Alerts ---- */
.alert { border-radius: var(--radius); border: 1px solid transparent; font-size: 0.88rem; }
.alert-success { background: var(--sage-soft); color: var(--sage); border-color: #cfeee0; }
.alert-danger { background: var(--ember-soft); color: var(--ember); border-color: #f7d9d5; }
.alert-info { background: var(--signal-soft); color: var(--signal-dark); border-color: #d7e2fc; }

/* ---- Nav tabs ---- */
.nav-tabs { border-bottom: 1px solid var(--border); gap: 4px; }
.nav-tabs .nav-link {
    border: none;
    color: var(--text-muted);
    font-weight: 550;
    font-size: 0.88rem;
    padding: 9px 4px;
    margin-right: 20px;
    border-radius: 0;
    border-bottom: 2px solid transparent;
}
.nav-tabs .nav-link.active {
    color: var(--text);
    background: transparent;
    border-bottom: 2px solid var(--signal);
}

/* ---- Misc ---- */
.text-muted { color: var(--text-muted) !important; }
.section-eyebrow {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
}

@media (max-width: 900px) {
    .app-sidebar { position: fixed; z-index: 40; transform: translateX(-100%); transition: transform 0.2s ease; }
    .app-sidebar.open { transform: translateX(0); }
}
