/* ==========================================================================
   RoofFlow CRM — "Site board" design system
   Dark surfaces, one orange accent. Barlow Condensed / Barlow.
   Fonts are loaded in index.html.
   ========================================================================== */

:root {
    color-scheme: dark;

    /* Accent: safety orange, the only accent */
    --primary: #C2410C;            /* fills: buttons, active pill, highlighted bar */
    --primary-color: #C2410C;      /* alias used by page scripts */
    --primary-hover: #E5600F;
    --primary-text: #F0763A;       /* orange as text on dark (6:1) */
    --primary-light: rgba(194, 65, 12, 0.18);
    --primary-border: rgba(240, 118, 58, 0.45);
    --accent-bright: #E5600F;

    /* Surfaces */
    --bg-page: #111316;
    --bg-body: #111316;            /* alias used by page scripts */
    --bg-card: #181B1F;            /* panels */
    --bg-raised: #1F2328;          /* raised panels, modals, menus */
    --bg-subtle: #1F2328;          /* hover rows, modal footer */
    --bg-strip: #1C1F23;           /* table header */
    --bg-input: #15181B;
    --bg-sidebar: #111316;
    --bg-sidebar-hover: #1F2328;
    --bg-sidebar-active: #1F2328;

    /* Text */
    --text-main: #ECEDEE;
    --text-muted: #9EA4AB;
    --text-light: #868C93;
    --text-white: #FFFFFF;
    --text-sidebar: #C5C9CE;

    /* Lines */
    --border-color: rgba(255, 255, 255, 0.07);
    --border-light: rgba(255, 255, 255, 0.05);
    --border-hover: rgba(255, 255, 255, 0.16);
    --border-strong: #6E747B;      /* input borders, 3.7:1 on input fill */
    --charcoal: #C5C9CE;           /* "ink": outline buttons, rules */
    --bar-grey: #50565E;           /* non-highlighted chart bars */

    /* Feedback */
    --danger: #B42318;
    --danger-hover: #9B1C1C;
    --danger-text: #F5A3A3;
    --success: #1F7A3A;
    --success-hover: #1F6B33;
    --success-text: #8FD9A8;
    --focus-ring: #F0763A;

    /* Status badges (dark): solid tinted fill + light text, all 6.5:1 or better */
    --status-new-bg: #222E3E;
    --status-new-text: #9CC3F0;
    --status-contacted-bg: #35301C;
    --status-contacted-text: #E8C468;
    --status-qualified-bg: #1B3334;
    --status-qualified-text: #7FD6C8;
    --status-proposal-bg: #2D2C40;
    --status-proposal-text: #C3B5F5;
    --status-converted-bg: #1E342C;
    --status-converted-text: #8FD9A8;
    --status-lost-bg: #37272A;
    --status-lost-text: #F5A3A3;
    --status-neutral-bg: #2A2D31;
    --status-neutral-text: #C5C9CE;

    /* Type */
    --font-heading: 'Barlow Condensed', 'Arial Narrow', system-ui, sans-serif;
    --font-body: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;

    /* Spacing (4px steps) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;

    /* Shape & depth */
    --radius-sm: 2px;
    --radius-md: 6px;
    --radius-lg: 10px;
    --radius-pill: 999px;
    --shadow-sm: none;
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
    --shadow-hover: 0 4px 14px rgba(0, 0, 0, 0.35);
    --glow: 0 0 0 1px rgba(240, 118, 58, 0.35), 0 10px 30px rgba(194, 65, 12, 0.14);

    --nav-h: 64px;

    /* Motion */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --transition: all 0.18s var(--ease);
}


/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-body);
}

body {
    background-color: var(--bg-page);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    letter-spacing: 0.01em;
}

a { color: var(--primary); }

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

/* --------------------------------------------------------------------------
   App shell
   -------------------------------------------------------------------------- */
.app-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: var(--text-white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: width 0.2s var(--ease), transform 0.2s var(--ease);
}

.sidebar-header {
    height: 72px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--accent-bright);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 22px;
    color: var(--charcoal);
    flex-shrink: 0;
}

.logo-text {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #FFFFFF;
    white-space: nowrap;
    transition: opacity 0.15s var(--ease);
}

.collapse-btn {
    background: transparent;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}

.collapse-btn:hover {
    background-color: var(--bg-sidebar-hover);
    color: var(--text-white);
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

/* Nav item: orange bar slides in from the left on hover and when active */
.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--text-sidebar);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    transition: background-color 0.18s var(--ease), color 0.18s var(--ease);
}

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

.nav-item.active {
    background-color: var(--bg-sidebar-active);
    color: var(--text-white);
    font-weight: 600;
}

.nav-item.active .nav-icon {
    color: var(--accent-bright);
}

.nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.18s var(--ease);
}

.nav-icon svg {
    width: 19px;
    height: 19px;
}

.nav-label {
    transition: opacity 0.15s var(--ease);
}

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
    transition: background-color 0.18s var(--ease);
}

.sidebar-footer:hover {
    background-color: var(--bg-sidebar-hover);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background-color: var(--bg-sidebar-hover);
    border: 1px solid rgba(255, 255, 255, 0.14);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.04em;
    color: #FF8236;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    white-space: nowrap;
    transition: opacity 0.15s var(--ease);
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: #FFFFFF;
}

.user-role {
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-light);
}

/* Collapsed sidebar (desktop) */
.sidebar.collapsed {
    width: 72px;
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .user-info {
    opacity: 0;
    width: 0;
    pointer-events: none;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 0 10px;
}

.sidebar.collapsed .collapse-btn {
    display: none;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 10px;
}

/* Main area */
.main-wrapper {
    margin-left: 260px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.2s var(--ease);
}

.sidebar.collapsed ~ .main-wrapper {
    margin-left: 72px;
}

/* Top header */
.top-header {
    height: 72px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

.page-title {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-main);
    letter-spacing: 0.01em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-box {
    position: relative;
    width: 320px;
}

.search-input {
    width: 100%;
    height: 40px;
    padding: 0 14px 0 40px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--bg-page);
    font-size: 14px;
    outline: none;
    color: var(--text-main);
    transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-input:focus {
    border-color: var(--primary-text);
    background-color: var(--bg-input);
    box-shadow: 0 0 0 3px rgba(194, 65, 12, 0.22);
}

.search-icon-inside {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 17px;
    height: 17px;
    pointer-events: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.main-content {
    padding: 32px;
    flex: 1;
}

.dashboard-grid {
    display: grid;
    gap: 24px;
    margin-top: 0;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 18px;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    background-repeat: no-repeat;
    transition:
        background-color 0.18s var(--ease),
        background-size 0.2s var(--ease),
        border-color 0.18s var(--ease),
        color 0.18s var(--ease),
        transform 0.08s var(--ease);
}

.btn svg {
    flex-shrink: 0;
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #FFFFFF;
}

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

/* Outline: orange fill sweeps in from the left on hover */
.btn-outline {
    background-color: transparent;
    background-image: linear-gradient(var(--primary), var(--primary));
    background-size: 0% 100%;
    background-position: left center;
    border-color: var(--charcoal);
    color: var(--charcoal);
}

.btn-outline:hover {
    background-size: 100% 100%;
    border-color: var(--primary);
    color: #FFFFFF;
}

/* Employee (de)activate buttons keep their meaning colour on hover */
.btn-outline.btn-deactivate-emp {
    background-image: linear-gradient(var(--danger), var(--danger));
}
.btn-outline.btn-reactivate-emp {
    background-image: linear-gradient(var(--success), var(--success));
}
.btn-outline.btn-deactivate-emp:hover {
    color: #FFFFFF !important;
    border-color: var(--danger) !important;
}
.btn-outline.btn-reactivate-emp:hover {
    color: #FFFFFF !important;
    border-color: var(--success) !important;
}

.btn-danger {
    background-color: var(--danger);
    border-color: var(--danger);
    color: #FFFFFF;
}

.btn-danger:hover {
    background-color: var(--danger-hover);
    border-color: var(--danger-hover);
}

.btn-success {
    background-color: var(--success);
    border-color: var(--success);
    color: #FFFFFF;
}

.btn-success:hover {
    background-color: var(--success-hover);
    border-color: var(--success-hover);
}

.btn-ghost {
    background-color: transparent;
    color: var(--text-main);
}

.btn-ghost:hover {
    background-color: var(--bg-strip);
}

.btn-sm {
    height: 32px;
    padding: 0 12px;
    font-size: 13px;
    gap: 6px;
}

.btn-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-icon-only {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
    padding: 6px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s var(--ease), color 0.15s var(--ease), transform 0.08s var(--ease);
}

.btn-icon-only:hover {
    background-color: var(--bg-strip);
    color: var(--text-main);
}

.btn-icon-only:active {
    transform: translateY(1px);
}

/* --------------------------------------------------------------------------
   Cards & KPIs
   -------------------------------------------------------------------------- */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.18s var(--ease);
}

.card:hover {
    border-color: var(--border-hover);
}

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

.card-title {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-main);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

/* KPI: 3px top bar grows from a charcoal stub to a full orange line on hover */
.kpi-card {
    position: relative;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.18s var(--ease);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background-color: var(--charcoal);
    transform: scaleX(0.22);
    transform-origin: left center;
    transition: transform 0.22s var(--ease), background-color 0.22s var(--ease);
}

.kpi-card:hover {
    border-color: var(--border-hover);
}

.kpi-card:hover::before {
    transform: scaleX(1);
    background-color: var(--accent-bright);
}

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

.kpi-title {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.kpi-icon-box {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background-color: var(--bg-strip);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
}

.kpi-value {
    font-family: var(--font-heading);
    font-size: 36px;
    font-weight: 700;
    line-height: 1.05;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
    margin-bottom: 8px;
}

.kpi-trend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    width: fit-content;
}

.trend-up { background-color: var(--status-converted-bg); color: var(--status-converted-text); }
.trend-down { background-color: var(--status-lost-bg); color: var(--status-lost-text); }
.trend-neutral { background-color: var(--status-neutral-bg); color: var(--status-neutral-text); }

/* --------------------------------------------------------------------------
   Filters
   -------------------------------------------------------------------------- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    background-color: var(--bg-card);
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-select {
    height: 36px;
    padding: 0 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-strong);
    background-color: var(--bg-card);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.filter-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(194, 65, 12, 0.15);
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.table th {
    padding: 12px 16px;
    background-color: var(--bg-strip);
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.table td {
    height: 48px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-main);
    vertical-align: middle;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr {
    cursor: pointer;
    transition: background-color 0.15s var(--ease);
}

.table tbody td:first-child {
    transition: box-shadow 0.15s var(--ease);
}

.table tbody tr:hover {
    background-color: var(--bg-subtle);
}

/* 3px orange edge on the hovered row */
.table tbody tr:hover td:first-child {
    box-shadow: inset 3px 0 0 var(--accent-bright);
}

/* Pagination */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-card);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --------------------------------------------------------------------------
   Badges — squared, condensed, uppercase
   -------------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1.1;
    white-space: nowrap;
    background-color: var(--status-neutral-bg);
    color: var(--status-neutral-text);
}

.badge-new       { background-color: var(--status-new-bg);       color: var(--status-new-text); }
.badge-contacted { background-color: var(--status-contacted-bg); color: var(--status-contacted-text); }
.badge-qualified { background-color: var(--status-qualified-bg); color: var(--status-qualified-text); }
.badge-proposal  { background-color: var(--status-proposal-bg);  color: var(--status-proposal-text); }
.badge-converted { background-color: var(--status-converted-bg); color: var(--status-converted-text); }
.badge-lost      { background-color: var(--status-lost-bg);      color: var(--status-lost-text); }
.badge-success   { background-color: var(--status-converted-bg); color: var(--status-converted-text); }
.badge-warning   { background-color: var(--status-contacted-bg); color: var(--status-contacted-text); }
.badge-danger    { background-color: var(--status-lost-bg);      color: var(--status-lost-text); }
.badge-info      { background-color: var(--status-new-bg);       color: var(--status-new-text); }
.badge-secondary { background-color: var(--status-neutral-bg);   color: var(--status-neutral-text); }

/* --------------------------------------------------------------------------
   Inline status dropdown
   -------------------------------------------------------------------------- */
.status-dropdown {
    display: inline-flex;
    position: relative;
    vertical-align: middle;
}

.status-dropdown-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px 5px 10px;
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1.1;
    cursor: pointer;
    border: 1px solid transparent;
    user-select: none;
    outline: none;
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.status-dropdown-btn:hover {
    border-color: rgba(255, 255, 255, 0.28);
}

.status-dropdown-btn:focus-visible {
    box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--focus-ring);
}

.status-dropdown-btn .status-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.18s var(--ease);
    opacity: 0.75;
}

.status-dropdown-btn.active .status-arrow {
    transform: rotate(180deg);
    opacity: 1;
}

.status-dropdown-btn.loading {
    opacity: 0.65;
    pointer-events: none;
}

.status-floating-menu {
    position: fixed;
    z-index: 9999;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 4px;
    min-width: 160px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    animation: statusMenuIn 0.14s var(--ease);
}

@keyframes statusMenuIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.status-option-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 34px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    text-align: left;
    width: 100%;
    transition: background-color 0.12s var(--ease);
}

.status-option-item:hover,
.status-option-item:focus {
    background-color: var(--bg-subtle);
    outline: none;
}

.status-option-item.selected {
    font-weight: 600;
    background-color: var(--primary-light);
    color: var(--primary);
}

.status-option-left {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.status-option-dot {
    width: 8px;
    height: 8px;
    border-radius: 1px;
    flex-shrink: 0;
}

.status-option-check {
    display: inline-flex;
    align-items: center;
    color: var(--primary);
}

/* --------------------------------------------------------------------------
   Quick actions
   -------------------------------------------------------------------------- */
.quick-actions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quick-action-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    width: 100%;
    overflow: hidden;
    transition: border-color 0.18s var(--ease), background-color 0.18s var(--ease), transform 0.08s var(--ease);
}


.quick-action-btn:hover {
    border-color: var(--border-hover);
    background-color: var(--bg-subtle);
}


.quick-action-btn:active {
    transform: translateY(1px);
}

/* --------------------------------------------------------------------------
   Modals
   -------------------------------------------------------------------------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(5, 6, 8, 0.72);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s var(--ease);
}

.modal-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background-color: var(--bg-card);
    width: 100%;
    max-width: 560px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transform: translateY(8px);
    transition: transform 0.2s var(--ease);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-backdrop.open .modal-card {
    transform: translateY(0);
}

.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal-title {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--text-main);
}

.modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}

.modal-close:hover {
    background-color: var(--bg-strip);
    color: var(--text-main);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    background-color: var(--bg-subtle);
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}

.form-input, .form-select, .form-textarea, .form-control {
    width: 100%;
    min-height: 40px;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-strong);
    background-color: var(--bg-input);
    font-size: 14px;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.form-textarea, textarea.form-control {
    min-height: 0;
    resize: vertical;
}

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

.form-input:focus, .form-select:focus, .form-textarea:focus, .form-control:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(194, 65, 12, 0.15);
}

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

.error-text {
    font-size: 12px;
    color: var(--danger);
    margin-top: 2px;
}

/* --------------------------------------------------------------------------
   Timeline
   -------------------------------------------------------------------------- */
.timeline {
    position: relative;
    padding-left: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 16px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background-color: var(--border-color);
}

.timeline-item {
    position: relative;
}

.timeline-dot {
    position: absolute;
    left: -23px;
    top: 4px;
    width: 14px;
    height: 14px;
    border-radius: var(--radius-sm);
    background-color: var(--primary-light);
    border: 2px solid var(--primary);
}

.timeline-content {
    background-color: var(--bg-subtle);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.timeline-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}

.timeline-time {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 11000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 380px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    transform: translateY(-12px);
    opacity: 0;
    transition: transform 0.2s var(--ease), opacity 0.2s var(--ease);
    font-size: 14px;
    font-weight: 500;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-info .toast-icon { color: var(--charcoal); }

/* --------------------------------------------------------------------------
   Skeletons, empty and error states
   -------------------------------------------------------------------------- */
.skeleton {
    background: linear-gradient(90deg, var(--bg-strip) 25%, #E3DED4 50%, var(--bg-strip) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

.skeleton-card::before {
    display: none;
}

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

.empty-state, .error-state {
    text-align: center;
    padding: 48px 24px;
    background-color: var(--bg-card);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
}

.empty-icon, .error-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px auto;
    border-radius: var(--radius-md);
    background-color: var(--bg-strip);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-title, .error-title {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-main);
    margin-bottom: 6px;
}

.empty-desc, .error-desc {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.spin {
    animation: spin 0.9s linear infinite;
}

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


/* --------------------------------------------------------------------------
   Shared page furniture
   -------------------------------------------------------------------------- */
.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.page-meta {
    font-size: 14px;
    color: var(--text-muted);
}

.page-meta strong {
    color: var(--text-main);
    font-weight: 600;
}

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

/* A plain panel: one surface, one border, no nesting */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
}

.panel-title {
    font-family: var(--font-heading);
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-main);
}

.panel-body {
    padding: 16px 20px;
}

.panel .table-container {
    border: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.text-link {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
}

.text-link:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.muted { color: var(--text-muted); }
.num { font-variant-numeric: tabular-nums; }

/* Initials chip for people */
.person {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.person-initials {
    width: 26px;
    height: 26px;
    border-radius: var(--radius-sm);
    background: var(--bg-strip);
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.person-initials.is-empty {
    background: transparent;
    border: 1px dashed var(--border-strong);
    color: var(--text-muted);
}

/* Horizontal bars: thin, square, grow in once */
.bar-track {
    height: 6px;
    background: var(--bg-strip);
    border-radius: 1px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: var(--charcoal);
    transform-origin: left center;
    animation: barGrow 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: calc(var(--i, 0) * 50ms + 120ms);
}

.bar-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 12px;
    align-items: baseline;
    margin-bottom: 12px;
}

.bar-row:last-child { margin-bottom: 0; }

.bar-row .bar-label {
    font-size: 14px;
    color: var(--text-main);
}

.bar-row .bar-value {
    font-size: 13px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.bar-row .bar-track {
    grid-column: 1 / -1;
}

/* One stacked bar for part-to-whole */
.stack {
    display: flex;
    height: 10px;
    gap: 2px;
    border-radius: 1px;
    overflow: hidden;
    background: var(--bg-strip);
}

.stack-seg {
    height: 100%;
    min-width: 3px;
    transform-origin: left center;
    animation: barGrow 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: calc(var(--i, 0) * 60ms + 120ms);
}

.legend {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    margin-top: 12px;
}

.legend li {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-main);
}

.legend .swatch {
    width: 10px;
    height: 10px;
    border-radius: 1px;
    flex-shrink: 0;
}

.legend .legend-value {
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* Entrance: sections rise in once, slightly staggered */
.reveal {
    animation: rise 0.36s cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: calc(var(--i, 0) * 70ms);
}

@keyframes rise {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

@keyframes barGrow {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
}

/* --------------------------------------------------------------------------
   Dashboard
   -------------------------------------------------------------------------- */
.dash-summary {
    display: grid;
    grid-template-columns: minmax(260px, 0.9fr) minmax(0, 2fr);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

.dash-figure {
    padding: 22px 24px;
    border-right: 1px solid var(--border-color);
}

.figure-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.figure-value {
    font-family: var(--font-heading);
    font-size: 52px;
    font-weight: 700;
    line-height: 1;
    margin: 8px 0 6px;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}

.figure-note {
    font-size: 13px;
    color: var(--text-muted);
    max-width: 34ch;
}

.stat-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat {
    padding: 22px 20px;
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat:last-child { border-right: none; }

.stat-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: 700;
    line-height: 1.05;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}

.stat-note {
    font-size: 12px;
    color: var(--text-muted);
}

.dash-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
    gap: 20px;
    align-items: start;
}

.dash-rail {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Simple divided list used in the rail */
.row-list {
    list-style: none;
}

.row-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-light);
}

.row-list li:last-child { border-bottom: none; }

.row-main {
    min-width: 0;
}

.row-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 1px;
}

.row-sub a {
    color: inherit;
}

.row-empty {
    padding: 20px;
    font-size: 14px;
    color: var(--text-muted);
}

.quick-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   Reports: reads like a printed document
   -------------------------------------------------------------------------- */
.report {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 28px 32px 36px;
}

.report-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px 24px;
    flex-wrap: wrap;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--charcoal);
    margin-bottom: 4px;
}

.report-title {
    font-family: var(--font-heading);
    font-size: 30px;
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: 0.01em;
    text-transform: uppercase;
}

.report-period {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}

.segmented {
    display: inline-flex;
    flex-wrap: wrap;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.segmented .btn {
    height: 34px;
    border-radius: 0;
    border: none;
    background-color: transparent;
    background-image: none;
    color: var(--text-main);
    font-weight: 500;
}

.segmented .btn:last-child { border-right: none; }

.segmented .btn:hover {
    background-color: var(--bg-strip);
}

.segmented .btn.btn-primary {
    background-color: var(--charcoal);
    color: #FFFFFF;
    font-weight: 600;
}

.report-dates {
    display: none;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color);
}

.report-dates label {
    font-size: 13px;
    font-weight: 600;
    margin-right: 6px;
}

.report-dates .form-control {
    width: auto;
    min-height: 36px;
    padding: 6px 10px;
}

.report-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-bottom: 1px solid var(--border-color);
}

.summary-item {
    padding: 24px 20px 22px 0;
}

.summary-item + .summary-item {
    padding-left: 20px;
    border-left: 1px solid var(--border-light);
}

.summary-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.summary-value {
    font-family: var(--font-heading);
    font-size: 38px;
    font-weight: 700;
    line-height: 1.05;
    margin: 6px 0 4px;
    font-variant-numeric: tabular-nums;
}

.summary-note {
    font-size: 13px;
    color: var(--text-muted);
}

.report-section {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr);
    gap: 16px 32px;
    padding: 28px 0;
    border-bottom: 1px solid var(--border-color);
}

.report-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.report-h {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    line-height: 1.1;
}

.report-h-note {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 6px;
}

.report-cols {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px 40px;
}

.report-sub {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* Figures as a definition list */
.figures {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px 24px;
    margin-bottom: 24px;
}

.figures div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.figures dt {
    font-size: 13px;
    color: var(--text-muted);
}

.figures dd {
    font-family: var(--font-heading);
    font-size: 26px;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.report .table-container {
    border-radius: 0;
    border-left: none;
    border-right: none;
}

/* --------------------------------------------------------------------------
   Settings: section menu + forms
   -------------------------------------------------------------------------- */
.settings-layout {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr);
    gap: 32px;
    align-items: start;
}

.settings-nav {
    position: sticky;
    top: 96px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.settings-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}

.settings-nav a svg {
    width: 16px;
    height: 16px;
}

.settings-nav a:hover {
    background: var(--bg-strip);
    color: var(--text-main);
}

.settings-nav a.active {
    background: var(--bg-card);
    color: var(--text-main);
    font-weight: 600;
    box-shadow: inset 0 0 0 1px var(--border-color);
}

.settings-nav a.active svg {
    color: var(--primary);
}

.settings-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.settings-section {
    display: grid;
    grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
    gap: 16px 32px;
    padding: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    scroll-margin-top: 92px;
}

.settings-section.is-wide {
    grid-template-columns: minmax(0, 1fr);
}

.settings-section-head h2 {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    line-height: 1.1;
}

.settings-section-head p {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 6px;
    max-width: 42ch;
}

.settings-section.is-wide .settings-section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 20px;
}

.fields .span-2 {
    grid-column: 1 / -1;
}

.field-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.section-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 16px;
    margin-top: 4px;
    border-top: 1px solid var(--border-light);
}

.account-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px 24px;
    margin-bottom: 8px;
}

.account-list dt {
    font-size: 13px;
    color: var(--text-muted);
}

.account-list dd {
    font-size: 15px;
    font-weight: 600;
    margin-top: 2px;
    overflow-wrap: anywhere;
}

.is-inactive td {
    color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Leads
   -------------------------------------------------------------------------- */
.lead-name {
    font-weight: 600;
    color: var(--text-main);
}

.lead-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 1px;
}

.row-actions {
    display: inline-flex;
    gap: 2px;
    justify-content: flex-end;
}

.lead-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: pointer;
}

.lead-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}

.contact-links {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.contact-links a,
.contact-links span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    font-size: 14px;
    color: var(--text-main);
    text-decoration: none;
    overflow-wrap: anywhere;
}

.contact-links a svg,
.contact-links span svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.lead-card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid var(--border-light);
    padding-top: 12px;
}

.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 20px;
    align-items: start;
}

.detail-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 24px;
}

.detail-fields dt {
    font-size: 13px;
    color: var(--text-muted);
}

.detail-fields dd {
    font-size: 15px;
    font-weight: 500;
    margin-top: 2px;
    overflow-wrap: anywhere;
}

.detail-block {
    border-top: 1px solid var(--border-light);
    padding-top: 16px;
    margin-top: 18px;
}

.detail-block dt {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.detail-block dd {
    font-size: 15px;
    white-space: pre-wrap;
    max-width: 70ch;
}

.detail-head {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.detail-name {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
}

/* --------------------------------------------------------------------------
   Browser surfaces
   -------------------------------------------------------------------------- */
::selection {
    background: rgba(194, 65, 12, 0.55);
    color: #FFFFFF;
}

input, textarea {
    caret-color: var(--primary);
}

.main-content ::-webkit-scrollbar,
.table-container::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #3A3F46;
    border-radius: 1px;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
.mobile-card-list {
    display: none;
    flex-direction: column;
    gap: 12px;
}

@media (max-width: 1200px) {
    .dash-summary {
        grid-template-columns: 1fr;
    }
    .dash-figure {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    .report-section {
        grid-template-columns: 1fr;
    }
    .settings-section {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1024px) {
    .dash-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }
    .report-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .summary-item:nth-child(3) {
        padding-left: 0;
        border-left: none;
    }
    .report-cols {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    .main-wrapper {
        margin-left: 0 !important;
    }
    .menu-toggle {
        display: inline-flex;
    }
    .top-header {
        height: 64px;
        padding: 0 12px;
        gap: 8px;
    }
    .page-title {
        font-size: 22px;
    }
    .main-content {
        padding: 16px;
    }
    .kpi-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    .kpi-value {
        font-size: 30px;
    }
    .form-grid,
    .fields,
    .detail-fields,
    .account-list {
        grid-template-columns: 1fr;
    }
    .card {
        padding: 16px;
    }
    .btn {
        height: 44px;
    }
    .btn-sm {
        height: 36px;
    }
    .filter-select {
        height: 40px;
    }

    /* Tables become card lists on phones */
    .table-container {
        display: none;
    }
    .mobile-card-list {
        display: flex;
    }
    /* ...except plain report and dashboard tables, which scroll */
    .report .table-container,
    .panel .table-container {
        display: block;
    }

    .stat-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .stat:nth-child(2) { border-right: none; }
    .stat:nth-child(-n+2) { border-bottom: 1px solid var(--border-light); }
    .figure-value { font-size: 44px; }

    .report {
        padding: 20px 16px 24px;
    }
    .report-title { font-size: 24px; }
    .summary-value { font-size: 30px; }

    .settings-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .settings-nav {
        position: static;
        flex-direction: row;
        overflow-x: auto;
        gap: 4px;
    }
    .settings-nav a {
        white-space: nowrap;
    }
    .settings-section {
        padding: 18px 16px;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
    .modal-backdrop {
        padding: 0;
        align-items: flex-end;
    }
    .modal-card {
        max-height: 94vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
    .report-summary {
        grid-template-columns: 1fr;
    }
    .summary-item + .summary-item {
        padding-left: 0;
        border-left: none;
        border-top: 1px solid var(--border-light);
    }
}

/* --------------------------------------------------------------------------
   Print: reports come out as a clean document
   -------------------------------------------------------------------------- */
@media print {
    .sidebar,
    .top-header,
    .toast-container,
    .no-print {
        display: none !important;
    }
    body,
    .main-wrapper,
    .main-content {
        color: #111111 !important;
        background: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    .report {
        border: none;
        padding: 0;
    }
    .reveal,
    .bar-fill,
    .stack-seg {
        animation: none !important;
    }
    .table-container {
        display: block !important;
        overflow: visible;
    }
    .report-section {
        break-inside: avoid;
    }
}

/* --------------------------------------------------------------------------
   Reduced motion: no movement, photo instead of video
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-delay: 0ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .btn:active,
    .btn-icon-only:active,
    .quick-action-btn:active,
    .login-submit-btn:active {
        transform: none;
    }
    .login-bg-video {
        display: none;
    }
}

/* Settings team table: keep every column, including actions, in view */
.settings-section .table th,
.settings-section .table td {
    padding-left: 10px;
    padding-right: 10px;
}

.settings-section .table td {
    white-space: nowrap;
}

/* Grid children may shrink below their content; tables scroll inside their own box */
@media (max-width: 1024px) {
    .dash-grid,
    .detail-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 768px) {
    /* Dashboard recent leads: keep name, service and status on phones */
    .dash-grid .table th:nth-child(2),
    .dash-grid .table td:nth-child(2),
    .dash-grid .table th:nth-child(5),
    .dash-grid .table td:nth-child(5) {
        display: none;
    }
}

/* Filter toolbars */
.filter-search {
    width: 280px;
    max-width: 100%;
}

@media (max-width: 768px) {
    .filter-bar {
        padding: 12px;
    }
    .filter-bar > .filter-group,
    .filter-bar > div:last-child {
        width: 100%;
    }
    .filter-bar .filter-search {
        width: 100%;
        flex: 1 1 100%;
    }
    .filter-bar .filter-select {
        flex: 1 1 calc(50% - 6px);
        min-width: 0;
    }
    .filter-bar > div:last-child .btn {
        width: 100%;
    }
}

/* ==========================================================================
   Login: near-black panel (left), black-and-white site footage (right).
   Orange appears only on the Sign in button and the text caret.
   ========================================================================== */
.login-screen {
    --radius-md: 4px;
    --login-bg: #141619;
    --login-field: #1C1F23;
    --login-line: #6E747B;
    --login-line-hover: #8C939B;
    --login-label: #A7ADB4;
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    background: var(--login-bg);
    color: #FFFFFF;
    z-index: 10000;
    overflow: hidden;
}

.login-screen ::selection {
    background: #3A3F45;
    color: #FFFFFF;
}

.login-panel {
    position: relative;
    z-index: 1;
    flex: 0 0 38%;
    min-width: 400px;
    max-width: 620px;
    display: flex;
    flex-direction: column;
    padding: 48px clamp(40px, 4.6vw, 72px) 40px;
    background: var(--login-bg);
    overflow-y: auto;
}

.login-wordmark {
    display: flex;
    align-items: center;
    gap: 10px;
}

.login-brand-logo {
    width: 30px;
    height: 30px;
    border: 1.5px solid #FFFFFF;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    color: #FFFFFF;
}

.login-brand-title {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #FFFFFF;
}

.login-form-block {
    width: 100%;
    max-width: 360px;
    margin-top: clamp(48px, 15vh, 140px);
}

.login-heading {
    font-family: var(--font-heading);
    font-size: 44px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.005em;
    color: #FFFFFF;
    margin-bottom: 36px;
}

.login-form-group {
    margin-bottom: 22px;
}

.login-form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--login-label);
    margin-bottom: 8px;
    transition: color 0.18s var(--ease);
}

.login-form-group:focus-within .login-form-label {
    color: #FFFFFF;
}

.login-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.login-input-icon {
    position: absolute;
    left: 16px;
    display: flex;
    align-items: center;
    color: var(--login-line-hover);
    pointer-events: none;
    transition: color 0.18s var(--ease);
}

.login-form-group:focus-within .login-input-icon {
    color: #FFFFFF;
}

.login-input {
    width: 100%;
    height: 48px;
    padding: 0 16px 0 44px;
    font-size: 15px;
    font-weight: 500;
    color: #FFFFFF;
    background: var(--login-field);
    border: 1px solid var(--login-line);
    border-radius: var(--radius-md);
    caret-color: var(--primary);
    transition: border-color 0.18s var(--ease), background-color 0.18s var(--ease);
}

.login-input::placeholder {
    color: var(--login-line-hover);
    font-weight: 400;
}

.login-input:hover {
    border-color: var(--login-line-hover);
}

.login-input:focus {
    outline: none;
    border-color: #FFFFFF;
    background: #202328;
}

/* Keep browser autofill dark instead of pale yellow */
.login-input:-webkit-autofill,
.login-input:-webkit-autofill:hover,
.login-input:-webkit-autofill:focus {
    -webkit-text-fill-color: #FFFFFF;
    -webkit-box-shadow: 0 0 0 1000px var(--login-field) inset;
    caret-color: var(--primary);
}

.login-submit-btn {
    width: 100%;
    height: 48px;
    margin-top: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #FFFFFF;
    background: var(--primary);
    border: 1px solid var(--primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color 0.18s var(--ease), border-color 0.18s var(--ease), transform 0.08s var(--ease);
}

.login-btn-arrow {
    transition: transform 0.2s var(--ease);
}

.login-submit-btn:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.login-submit-btn:hover .login-btn-arrow {
    transform: translateX(4px);
}

.login-submit-btn:active {
    transform: translateY(1px);
}

.login-submit-btn:focus-visible {
    outline: 2px solid #FFFFFF;
    outline-offset: 3px;
}

.login-submit-btn:disabled {
    opacity: 0.75;
    cursor: wait;
}

.login-error-alert {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    margin-bottom: 22px;
    border-radius: var(--radius-md);
    background: #2A1A18;
    border: 1px solid #6B2A23;
    color: #F2C4BE;
    font-size: 14px;
    font-weight: 500;
}

.login-foot {
    margin-top: auto;
    padding-top: 32px;
    font-size: 14px;
    color: var(--login-line-hover);
}

/* Right: footage, desaturated so it sits with the dark panel */
.login-media {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    background: var(--login-bg);
}

.login-media::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("../assets/roof-bg.jpg") center 55% / cover no-repeat;
    filter: grayscale(100%) contrast(1.1) brightness(0.65);
}

.login-bg-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 55%;
    filter: grayscale(100%) contrast(1.1) brightness(0.65);
}

/* Soft seam into the panel, plus a little shade behind the copy */
.login-media-shade {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, var(--login-bg) 0%, rgba(20, 22, 25, 0.72) 10%, rgba(20, 22, 25, 0.25) 26%, rgba(20, 22, 25, 0) 42%),
        linear-gradient(180deg, rgba(20, 22, 25, 0.35) 0%, rgba(20, 22, 25, 0) 45%);
}

.login-media-copy {
    position: absolute;
    top: clamp(120px, 24vh, 220px);
    left: clamp(48px, 7vw, 96px);
    right: 48px;
    max-width: 36ch;
    animation: rise 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.25s both;
}

.login-media-line {
    font-size: 19px;
    font-weight: 400;
    line-height: 1.55;
    color: #FFFFFF;
    text-wrap: balance;
}

.login-media-caption {
    display: inline-block;
    margin-top: 18px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #D5D8DC;
    text-decoration: underline;
    text-underline-offset: 4px;
    text-decoration-thickness: 1px;
}

/* Load: panel content rises in with a short stagger */
.login-rise {
    animation: rise 0.42s cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: calc(var(--i, 0) * 60ms + 60ms);
}

@media (max-width: 1024px) {
    .login-panel {
        flex-basis: 44%;
        min-width: 360px;
    }
}

/* Phones: form only, short black-and-white photo band on top, no video */
@media (max-width: 768px) {
    .login-screen {
        flex-direction: column;
        overflow-y: auto;
    }
    .login-media {
        order: -1;
        flex: 0 0 168px;
    }
    .login-bg-video,
    .login-media-copy {
        display: none;
    }
    .login-media-shade {
        background: linear-gradient(180deg, rgba(20, 22, 25, 0) 35%, var(--login-bg) 100%);
    }
    .login-panel {
        flex: 1 0 auto;
        min-width: 0;
        max-width: none;
        padding: 8px 24px 28px;
        overflow: visible;
    }
    .login-form-block {
        max-width: none;
        margin-top: 32px;
    }
    .login-heading {
        font-size: 38px;
        margin-bottom: 28px;
    }
    .login-foot {
        padding-top: 28px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .login-rise,
    .login-media-copy {
        animation: none;
    }
    .login-submit-btn:hover .login-btn-arrow {
        transform: none;
    }
}

/* ==========================================================================
   SITE BOARD — dark app shell, top navigation, dashboard hero
   (placed last so it overrides the earlier light-theme layout rules)
   ========================================================================== */

/* --------------------------------------------------------------------------
   Top navigation: the <aside class="sidebar"> laid out as a bar
   -------------------------------------------------------------------------- */
.app-container {
    flex-direction: column;
}

.sidebar,
.sidebar.collapsed {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: auto;
    width: auto;
    height: var(--nav-h);
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding: 0 20px;
    background: rgba(17, 19, 22, 0.88);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border-color);
    transform: none;
    z-index: 200;
}

.sidebar-header,
.sidebar.collapsed .sidebar-header {
    height: auto;
    padding: 0;
    border: none;
    flex: 0 0 auto;
    justify-content: flex-start;
}

.collapse-btn,
.sidebar.collapsed .collapse-btn {
    display: none !important;
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .user-info {
    opacity: 1;
    width: auto;
    pointer-events: auto;
}

.logo-icon {
    width: 30px;
    height: 30px;
    background: transparent;
    border: 1.5px solid #FFFFFF;
    border-radius: var(--radius-sm);
    color: #FFFFFF;
    font-size: 18px;
}

.logo-text {
    font-size: 18px;
    letter-spacing: 0.12em;
}

.sidebar-nav {
    position: relative;
    flex: 0 1 auto;
    flex-direction: row;
    align-items: center;
    gap: 2px;
    margin: 0 auto;
    padding: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    overflow: visible;
}

.nav-pill {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-radius: var(--radius-pill);
    background: var(--primary);
    opacity: 0;
    pointer-events: none;
    z-index: 0;
    transition:
        transform 0.32s var(--ease-out),
        width 0.32s var(--ease-out),
        opacity 0.2s var(--ease);
}

.nav-item,
.sidebar.collapsed .nav-item {
    position: relative;
    z-index: 1;
    min-height: 36px;
    padding: 0 14px;
    gap: 8px;
    justify-content: center;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-sidebar);
    font-size: 14px;
    font-weight: 500;
    overflow: visible;
}

.nav-item:hover,
.nav-item.active {
    background: transparent;
    color: #FFFFFF;
}

.nav-item.active {
    font-weight: 600;
}

.nav-item.active .nav-icon {
    color: #FFFFFF;
}

.nav-icon {
    width: 16px;
    height: 16px;
}

.nav-icon svg {
    width: 16px;
    height: 16px;
}

.sidebar-footer {
    flex: 0 0 auto;
    padding: 4px 12px 4px 4px;
    border: none;
    border-radius: var(--radius-pill);
    gap: 10px;
}

.sidebar-footer:hover {
    background: var(--bg-raised);
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-pill);
    background: var(--bg-raised);
    border: 1px solid var(--border-hover);
    color: #FFFFFF;
    font-size: 14px;
}

.user-name {
    font-size: 13px;
    line-height: 1.2;
}

.user-role {
    font-size: 11px;
    color: var(--text-muted);
}

.user-signout {
    display: inline-flex;
    color: var(--text-muted);
}

.sidebar-footer:hover .user-signout {
    color: #FFFFFF;
}

/* Page area sits under the fixed bar */
.main-wrapper,
.sidebar.collapsed ~ .main-wrapper {
    margin-left: 0 !important;
    padding-top: var(--nav-h);
}

.top-header {
    position: static;
    height: auto;
    padding: 28px 32px 0;
    background: transparent;
    border: none;
}

.menu-toggle {
    display: none !important;
}

/* Sign-out lives in the nav on desktop */
#btn-signout {
    display: none;
}

/* The dashboard's hero carries its own heading */
.main-wrapper:has(.dash-hero) .top-header {
    display: none;
}

.page-title {
    font-size: 30px;
    color: var(--text-main);
}

.main-content {
    padding: 24px 32px 40px;
}

/* Medium screens: icons only in the tabs (labels stay for screen readers) */
@media (max-width: 1280px) {
    .nav-item:not(.active) .nav-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
    .nav-item:not(.active) {
        padding: 0 11px;
    }
    .user-info {
        display: none;
    }
}

/* --------------------------------------------------------------------------
   Dark component layer
   -------------------------------------------------------------------------- */
body {
    background: var(--bg-page);
}

a,
.text-link {
    color: var(--primary-text);
}

.btn-outline {
    border-color: rgba(255, 255, 255, 0.22);
    color: var(--text-main);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: #FFFFFF;
}

.btn-ghost {
    color: var(--text-main);
}

.btn-ghost:hover {
    background-color: var(--bg-raised);
}

/* Glass button used over the hero footage */
.btn-glass {
    background: rgba(17, 19, 22, 0.45);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #FFFFFF;
}

.btn-glass:hover {
    background: rgba(17, 19, 22, 0.7);
    border-color: rgba(255, 255, 255, 0.35);
}

.btn-icon-only:hover {
    background-color: var(--bg-raised);
}

.card,
.panel,
.filter-bar,
.table-container,
.report,
.settings-section,
.empty-state,
.error-state,
.lead-card,
.quick-action-btn,
.kpi-card {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    border-radius: var(--radius-lg);
}

.panel .table-container,
.report .table-container {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    background: transparent;
}

/* Hover: only clickable panels respond, with a soft orange glow */
.card:hover,
.kpi-card:hover {
    border-color: var(--border-color);
}

.card[onclick],
.panel[onclick],
.lead-card,
.quick-action-btn {
    transition: box-shadow 0.22s var(--ease), border-color 0.22s var(--ease);
}

.card[onclick]:hover,
.panel[onclick]:hover,
.lead-card:hover,
.quick-action-btn:hover {
    border-color: var(--primary-border);
    box-shadow: var(--glow);
    background-color: var(--bg-card);
}

.kpi-card::before {
    background-color: var(--border-hover);
}

.kpi-icon-box,
.empty-icon,
.error-icon,
.person-initials {
    background-color: var(--bg-raised);
    color: var(--text-main);
}

.panel-head {
    padding: 16px 20px;
}

.panel-title,
.card-title {
    font-size: 16px;
    letter-spacing: 0.06em;
}

/* Tables */
.table th {
    background-color: var(--bg-strip);
    color: var(--text-muted);
    border-bottom-color: var(--border-color);
}

.table td {
    border-bottom-color: var(--border-light);
}

.table tbody tr:hover {
    background-color: var(--bg-subtle);
}

.table tbody tr:hover td:first-child {
    box-shadow: inset 3px 0 0 var(--primary);
}

.pagination-bar {
    background-color: var(--bg-card);
    border-top-color: var(--border-color);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Orange marker for the one most important row in a panel */
.mark-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary-text);
    margin-right: 8px;
    vertical-align: 2px;
}

/* Forms */
.form-input,
.form-select,
.form-textarea,
.form-control,
.filter-select,
.search-input {
    background-color: var(--bg-input);
    border-color: var(--border-strong);
    color: var(--text-main);
    border-radius: var(--radius-md);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover,
.form-control:hover,
.filter-select:hover {
    border-color: #8C939B;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
.form-control:focus,
.filter-select:focus,
.search-input:focus {
    border-color: #FFFFFF !important;
    box-shadow: none;
    background-color: var(--bg-input);
}

input,
textarea {
    caret-color: var(--primary-text);
}

/* Status dropdown menu, modals, toasts */
.status-floating-menu,
.modal-card,
.toast {
    background: var(--bg-raised);
    border-color: var(--border-hover);
    color: var(--text-main);
}

.status-option-item {
    color: var(--text-main);
}

.status-option-item:hover,
.status-option-item:focus {
    background-color: rgba(255, 255, 255, 0.06);
}

.status-option-item.selected,
.status-option-check {
    color: var(--primary-text);
}

.status-option-item.selected {
    background-color: var(--primary-light);
}

.modal-card {
    border-radius: var(--radius-lg);
}

.modal-header {
    border-bottom-color: var(--border-color);
}

.modal-footer {
    background-color: #1A1D21;
    border-top-color: var(--border-color);
}

.modal-close:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.toast-success .toast-icon { color: var(--success-text); }
.toast-error .toast-icon { color: var(--danger-text); }
.toast-info .toast-icon { color: var(--text-main); }

.error-text {
    color: var(--danger-text);
}

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

.skeleton {
    background: linear-gradient(90deg, #1C1F23 25%, #262A30 50%, #1C1F23 75%);
    background-size: 200% 100%;
}

.timeline-content {
    background-color: var(--bg-raised);
}

/* Reports */
.report-head {
    border-bottom: 1px solid var(--border-hover);
}

.segmented {
    border-color: var(--border-hover);
    border-radius: var(--radius-pill);
    background: var(--bg-input);
    padding: 3px;
    gap: 2px;
}

.segmented .btn {
    border: none;
    border-radius: var(--radius-pill);
    color: var(--text-sidebar);
}

.segmented .btn:hover {
    background-color: var(--bg-raised);
    color: #FFFFFF;
}

.segmented .btn.btn-primary {
    background-color: var(--primary);
    color: #FFFFFF;
}

.bar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.bar-fill {
    background: var(--bar-grey);
    border-radius: 3px;
}

.stack {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.figures dd,
.summary-value,
.report-title,
.report-h {
    color: var(--text-main);
}

/* Settings */
.settings-nav a.active {
    background: var(--bg-card);
    box-shadow: inset 0 0 0 1px var(--border-hover);
}

.settings-nav a.active svg {
    color: var(--primary-text);
}

.settings-nav a:hover {
    background: var(--bg-card);
}

/* Trend chips and misc */
.trend-neutral {
    background-color: var(--status-neutral-bg);
    color: var(--status-neutral-text);
}

/* --------------------------------------------------------------------------
   Dashboard hero band
   -------------------------------------------------------------------------- */
.dash-hero {
    position: relative;
    margin: -24px -32px 8px;
    height: 360px;
    overflow: hidden;
    background: #0C0D0F;
    /* bottom edge pitched like a roof plane */
    clip-path: polygon(0 0, 100% 0, 100% 80%, 0 100%);
}

.dash-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("../assets/dashboard-hero.jpg") center 50% / cover no-repeat;
    filter: grayscale(100%) contrast(1.1) brightness(0.5);
}

.dash-hero-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(100%) contrast(1.1) brightness(0.5);
}

.dash-hero-shade {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(180deg, rgba(17, 19, 22, 0.55) 0%, rgba(17, 19, 22, 0.05) 40%, rgba(17, 19, 22, 0.55) 100%),
        linear-gradient(90deg, rgba(17, 19, 22, 0.55) 0%, rgba(17, 19, 22, 0) 65%);
}

.dash-hero-inner {
    position: relative;
    z-index: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 20px;
    padding: 28px 32px 84px;
}

.dash-hero-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.hero-greeting {
    font-family: var(--font-heading);
    font-size: 40px;
    font-weight: 700;
    line-height: 1.05;
    color: #FFFFFF;
}

.hero-date {
    margin-top: 4px;
    font-size: 15px;
    color: #D5D8DC;
}

.hero-cards {
    display: grid;
    grid-template-columns: minmax(300px, 1.5fr) repeat(2, minmax(170px, 0.75fr));
    gap: 12px;
    max-width: 920px;
}

.glass-card {
    padding: 16px 20px;
    border-radius: 14px;
    background: rgba(17, 19, 22, 0.52);
    -webkit-backdrop-filter: blur(16px) saturate(120%);
    backdrop-filter: blur(16px) saturate(120%);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #FFFFFF;
}

.glass-label {
    font-size: 13px;
    font-weight: 600;
    color: #D5D8DC;
}

.glass-value {
    font-family: var(--font-heading);
    font-size: 36px;
    font-weight: 700;
    line-height: 1.05;
    margin: 6px 0 4px;
    font-variant-numeric: tabular-nums;
}

.glass-card.is-hero .glass-value {
    font-size: 60px;
    line-height: 0.95;
}

.glass-note {
    font-size: 13px;
    color: #C5C9CE;
}

/* Below the band */
.dash-grid {
    grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
    gap: 16px;
}

.dash-main,
.dash-rail {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.row-list li {
    border-bottom-color: var(--border-light);
}

/* Lead sources: vertical bars, only the largest in orange */
.vbar-chart {
    display: grid;
    grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr));
    gap: 14px;
    height: 200px;
    align-items: end;
}

.vbar {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
}

.vbar-col {
    display: block;
    width: 100%;
    max-width: 64px;
    background: var(--bar-grey);
    border-radius: 8px 8px 3px 3px;
    transform-origin: bottom center;
    animation: barGrowY 0.5s var(--ease-out) both;
    animation-delay: calc(var(--i, 0) * 70ms + 200ms);
}

.vbar.is-top .vbar-col {
    background: var(--primary);
}

.vbar-value {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    color: var(--text-muted);
}

.vbar-value small {
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 500;
}

.vbar.is-top .vbar-value {
    color: #FFFFFF;
}

.vbar-label {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@keyframes barGrowY {
    from { transform: scaleY(0); }
    to   { transform: scaleY(1); }
}

/* --------------------------------------------------------------------------
   Site board: responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
    .hero-cards {
        grid-template-columns: 1fr 1fr;
    }
    .glass-card.is-hero {
        grid-column: 1 / -1;
    }
    .dash-hero {
        height: auto;
        min-height: 360px;
    }
}

@media (max-width: 1024px) {
    .dash-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Phones: fixed bottom tab bar, still photo in the hero */
@media (max-width: 768px) {
    .sidebar,
    .sidebar.collapsed,
    .sidebar.open {
        top: auto;
        bottom: 0;
        height: calc(64px + env(safe-area-inset-bottom, 0px));
        padding: 0 4px env(safe-area-inset-bottom, 0px);
        border-bottom: none;
        border-top: 1px solid var(--border-color);
        transform: none !important;
        box-shadow: none;
    }
    .sidebar-header,
    .sidebar-footer {
        display: none;
    }
    .sidebar-nav {
        width: 100%;
        margin: 0;
        padding: 0;
        gap: 0;
        background: transparent;
        border: none;
        border-radius: 0;
        justify-content: space-between;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .sidebar-nav::-webkit-scrollbar {
        display: none;
    }
    .nav-pill {
        display: none;
    }
    .nav-item,
    .nav-item:not(.active),
    .sidebar.collapsed .nav-item {
        flex: 1 0 60px;
        flex-direction: column;
        gap: 3px;
        min-height: 56px;
        padding: 6px 2px;
        border-radius: 12px;
        font-size: 11px;
    }
    .nav-item:not(.active) .nav-label {
        position: static;
        width: auto;
        height: auto;
        clip: auto;
    }
    .nav-icon,
    .nav-icon svg {
        width: 20px;
        height: 20px;
    }
    .nav-item.active .nav-icon {
        color: var(--primary-text);
    }
    .main-wrapper,
    .sidebar.collapsed ~ .main-wrapper {
        padding-top: 0;
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    }
    .top-header {
        padding: 16px 16px 0;
        display: flex;
    }
    #btn-signout {
        display: inline-flex;
    }
    .main-content {
        padding: 16px 16px 24px;
    }
    .dash-hero {
        margin: -16px -16px 8px;
        min-height: 0;
        clip-path: polygon(0 0, 100% 0, 100% 92%, 0 100%);
    }
    .dash-hero-video {
        display: none;
    }
    .dash-hero-inner {
        padding: 20px 16px 48px;
    }
    .hero-greeting {
        font-size: 30px;
    }
    .glass-card.is-hero .glass-value {
        font-size: 44px;
    }
    .glass-value {
        font-size: 28px;
    }
    .vbar-chart {
        height: 170px;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .dash-hero-top .quick-row {
        width: 100%;
    }
}

/* Print stays black on white */
@media print {
    .report,
    .report * {
        color: #111111 !important;
        border-color: #CCCCCC !important;
        background-color: transparent !important;
    }
    .report .bar-fill,
    .report .stack-seg {
        background-color: #888888 !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .nav-pill,
    .vbar-col {
        transition: none;
        animation: none;
    }
    .dash-hero-video {
        display: none;
    }
}

/* Panel links stay neutral so orange marks only the one key item */
.panel-head .text-link {
    color: var(--text-muted);
}

.panel-head .text-link:hover {
    color: #FFFFFF;
}

/* Bar heights leave room for the value above and the label below */
.vbar-col {
    height: calc((100% - 58px) * var(--h, 0) / 100);
}

/* Phones: keep the sign-out button reachable on the dashboard */
@media (max-width: 768px) {
    .main-wrapper:has(.dash-hero) .top-header {
        display: flex;
        justify-content: flex-end;
        padding-bottom: 12px;
    }
    .main-wrapper:has(.dash-hero) .page-title {
        display: none;
    }
    .main-wrapper:has(.dash-hero) .dash-hero {
        margin-top: -16px;
    }
}

/* Empty states: plain icon, no tile */
.empty-icon,
.error-icon {
    background: transparent;
    width: auto;
    height: auto;
    margin-bottom: 12px;
    color: var(--text-muted);
}

.empty-icon svg,
.error-icon svg {
    width: 32px;
    height: 32px;
}

/* Settings team list sits flat inside its section */
.settings-section .table-container {
    border: none;
    border-top: 1px solid var(--border-color);
    border-radius: 0;
    background: transparent;
}

/* Empty states inside a table or panel sit flat, not as a second card */
.table-container .empty-state,
.panel .empty-state,
.card .empty-state {
    border: none;
    background: transparent;
}

/* ==========================================================================
   Cursor glow (desktop + mouse only, never on the login screen)
   JS in index.html writes --mx / --my (viewport px) and --glow-o (0 or 1)
   on <html> inside requestAnimationFrame and adds .has-cursor-glow.
   Gradients use background-attachment: fixed, so every panel reads the same
   viewport coordinates and no per-element measuring is needed.
   ========================================================================== */
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
    /* 1. Ambient glow across the page background */
    .has-cursor-glow .app-container::before {
        content: '';
        position: fixed;
        inset: 0;
        z-index: 0;
        pointer-events: none;
        background: radial-gradient(
            560px circle at var(--mx, -1000px) var(--my, -1000px),
            rgba(229, 96, 15, 0.08),
            rgba(229, 96, 15, 0.03) 35%,
            transparent 70%
        );
        opacity: var(--glow-o, 0);
        transition: opacity 0.35s var(--ease);
    }

    .has-cursor-glow .main-wrapper {
        position: relative;
        z-index: 1;
    }

    /* 2. Spotlight inside panels and cards */
    .has-cursor-glow :is(.panel, .card, .settings-section, .report, .filter-bar, .lead-card, .modal-card, .glass-card) {
        position: relative;
        isolation: isolate;
    }

    .has-cursor-glow :is(.panel, .card, .settings-section, .report, .filter-bar, .lead-card, .modal-card)::before {
        content: '';
        position: absolute;
        inset: 0;
        z-index: -1;
        border-radius: inherit;
        pointer-events: none;
        background: radial-gradient(
            420px circle at var(--mx, -1000px) var(--my, -1000px),
            rgba(229, 96, 15, 0.07),
            transparent 65%
        ) fixed;
        opacity: var(--glow-o, 0);
        transition: opacity 0.35s var(--ease);
    }

    /* 3. Border lights up near the cursor: a 1px ring masked to the edge */
    .has-cursor-glow :is(.panel, .card, .settings-section, .report, .filter-bar, .lead-card, .modal-card, .glass-card)::after {
        content: '';
        position: absolute;
        inset: -1px;
        z-index: 2;
        border-radius: inherit;
        padding: 1px;
        pointer-events: none;
        background: radial-gradient(
            240px circle at var(--mx, -1000px) var(--my, -1000px),
            rgba(240, 118, 58, 0.55),
            rgba(240, 118, 58, 0.12) 45%,
            transparent 70%
        ) fixed;
        -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
        -webkit-mask-composite: xor;
        mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
        opacity: var(--glow-o, 0);
        transition: opacity 0.35s var(--ease);
    }

    /* Fixed backgrounds need an untransformed box: the open modal rests at transform: none */
    .has-cursor-glow .modal-backdrop.open .modal-card {
        transform: none;
    }
}
