/* ==========================================================================
   Generator Depot Ohio — portal design system (staff + client + auth)
   FOUNDATION owns this base. Module agents: APPEND page-specific rules at
   the END of this file under a comment block:  /* === [module] === * /
   Never edit existing rules.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */
:root {
    --navy-950: #081a33;
    --navy-900: #0b2344;
    --navy-800: #0e2c55;
    --navy-700: #1d3f6e;
    --ink: #12233c;
    --orange-600: #e05f00;
    --orange-500: #f47b20;
    --orange-100: #fdebdc;
    --bg: #f6f8fb;
    --card: #ffffff;
    --line: #e3e9f2;
    --slate-600: #4a5b73;
    --slate-500: #64748b;
    --green-600: #15803d;
    --red-600: #b91c1c;
    --amber-600: #b45309;

    --font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
    --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

    --radius-card: 14px;
    --radius-btn: 10px;
    --shadow-sm: 0 1px 2px rgba(8, 26, 51, .06), 0 1px 3px rgba(8, 26, 51, .08);
    --shadow-md: 0 4px 14px rgba(8, 26, 51, .08), 0 2px 4px rgba(8, 26, 51, .05);
    --shadow-lg: 0 18px 40px rgba(8, 26, 51, .14), 0 6px 14px rgba(8, 26, 51, .08);

    --sidebar-w: 262px;
    --topbar-h: 64px;
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; }

a { color: var(--orange-600); }
a:hover { color: var(--navy-700); }

::selection { background: var(--orange-500); color: #fff; }

:focus-visible {
    outline: 3px solid var(--orange-500);
    outline-offset: 2px;
    border-radius: 4px;
}

.icon { width: 20px; height: 20px; flex: 0 0 auto; vertical-align: middle; }

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 300;
    background: var(--navy-950);
    color: #fff;
    padding: 10px 18px;
    border-radius: 0 0 10px 0;
    text-decoration: none;
    font-weight: 600;
}
.skip-link:focus { left: 0; color: #fff; }

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.2; color: var(--ink); }

h1, .page-title {
    font-family: var(--font-display);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .02em;
    font-size: clamp(26px, 3vw, 34px);
}

h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 600; }

p { margin: 0 0 1em; }
.text-muted { color: var(--slate-500); }
.text-right { text-align: right; }

/* --------------------------------------------------------------------------
   3. App shell
   -------------------------------------------------------------------------- */
.portal-shell { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(ellipse 120% 30% at 50% 0%, rgba(244, 123, 32, .10), transparent 60%),
        linear-gradient(180deg, var(--navy-950) 0%, var(--navy-900) 100%);
    color: rgba(255, 255, 255, .78);
    z-index: 120;
    overflow-y: auto;
}

.sidebar__brand {
    display: block;
    padding: 24px 22px 20px;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, .09);
}

.sidebar__wordmark {
    display: block;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 23px;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: #fff;
    line-height: 1.05;
}
.sidebar__wordmark em { font-style: normal; color: var(--orange-500); }

.sidebar__portal-tag {
    display: inline-block;
    margin-top: 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--orange-500);
    background: rgba(244, 123, 32, .12);
    border: 1px solid rgba(244, 123, 32, .35);
    border-radius: 999px;
    padding: 3px 10px;
}

.sidebar__nav { flex: 1; padding: 16px 12px; }

.sidebar__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }

.sidebar__link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 10px;
    color: rgba(255, 255, 255, .74);
    font-size: 14.5px;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}
.sidebar__link .icon { width: 19px; height: 19px; opacity: .8; }
.sidebar__link:hover { background: rgba(255, 255, 255, .07); color: #fff; }

.sidebar__link.is-active {
    background: rgba(244, 123, 32, .14);
    color: #fff;
    font-weight: 600;
}
.sidebar__link.is-active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 8px;
    bottom: 8px;
    width: 4px;
    border-radius: 0 4px 4px 0;
    background: var(--orange-500);
}
.sidebar__link.is-active .icon { color: var(--orange-500); opacity: 1; }

.sidebar__label { flex: 1; }

.sidebar__badge {
    background: var(--orange-500);
    color: #fff;
    font-size: 11.5px;
    font-weight: 700;
    border-radius: 999px;
    min-width: 21px;
    height: 21px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-inline: 6px;
}

.sidebar__foot {
    padding: 14px 12px 20px;
    border-top: 1px solid rgba(255, 255, 255, .09);
    display: grid;
    gap: 3px;
}
.sidebar__link--muted { color: rgba(255, 255, 255, .5); font-size: 13.5px; }

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 26, 51, .55);
    z-index: 110;
    backdrop-filter: blur(2px);
}
.sidebar-overlay[hidden] { display: none; }

.portal-body {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* --------------------------------------------------------------------------
   4. Topbar
   -------------------------------------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 18px;
    min-height: var(--topbar-h);
    padding-inline: 28px;
    background: rgba(255, 255, 255, .94);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}

.topbar__menu {
    display: none;
    background: none;
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 8px;
    cursor: pointer;
    color: var(--navy-900);
}
.topbar__menu .icon { display: block; }

.topbar__spacer { flex: 1; }

.crumbs__list {
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 13.5px;
    flex-wrap: wrap;
}
.crumbs__item { display: inline-flex; align-items: center; gap: 8px; color: var(--slate-500); }
.crumbs__item + .crumbs__item::before { content: '/'; color: #cbd5e1; }
.crumbs__item a { color: var(--slate-500); text-decoration: none; }
.crumbs__item a:hover { color: var(--orange-600); }
.crumbs__item span[aria-current] { color: var(--ink); font-weight: 600; }

.topbar__user {
    display: flex;
    align-items: center;
    gap: 11px;
    background: none;
    border: 0;
    padding: 6px 8px;
    border-radius: 12px;
    cursor: pointer;
    font-family: var(--font-body);
    transition: background .15s ease;
}
.topbar__user:hover { background: var(--bg); }
.topbar__user > .icon { width: 16px; height: 16px; color: var(--slate-500); }

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(150deg, var(--navy-800), var(--navy-950));
    color: #fff;
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: .04em;
}

.topbar__user-meta { text-align: left; line-height: 1.25; }
.topbar__user-name { display: block; font-size: 14px; font-weight: 600; color: var(--ink); }
.topbar__user-role { display: block; font-size: 12px; color: var(--slate-500); }

/* Dropdown (generic, used in topbar + tables) */
.dropdown { position: relative; }

.dropdown__menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 190px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 150;
}
.dropdown__menu[hidden] { display: none; }

.dropdown__item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-radius: 8px;
    background: none;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
}
.dropdown__item:hover { background: var(--bg); color: var(--orange-600); }
.dropdown__item .icon { width: 17px; height: 17px; color: var(--slate-500); }
.dropdown__item:hover .icon { color: var(--orange-600); }

/* --------------------------------------------------------------------------
   5. Main area / page scaffolding
   -------------------------------------------------------------------------- */
.portal-main {
    flex: 1;
    padding: 30px 28px 44px;
    max-width: 1320px;
    width: 100%;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 26px;
    flex-wrap: wrap;
}
.page-head h1 { margin-bottom: 4px; }
.page-head__sub { color: var(--slate-500); font-size: 14.5px; margin: 0; }
.page-head__actions { display: flex; gap: 12px; flex-wrap: wrap; }

.portal-footer {
    padding: 18px 28px 26px;
    border-top: 1px solid var(--line);
    background: transparent;
}

.powered-by { margin: 0; text-align: center; }
.powered-by a {
    color: var(--slate-500);
    text-decoration: none;
    font-size: 13px;
    transition: color .15s ease;
}
.powered-by a:hover { color: var(--navy-900); text-decoration: underline; }
.powered-by--dark a { color: rgba(255, 255, 255, .55); }
.powered-by--dark a:hover { color: #fff; }

/* --------------------------------------------------------------------------
   6. Buttons
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-btn);
    font-family: var(--font-body);
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background .18s ease, color .18s ease, border-color .18s ease,
        transform .18s ease, box-shadow .18s ease;
}
.btn .icon { width: 17px; height: 17px; }
.btn:active { transform: translateY(1px); }

.btn--primary {
    background: var(--orange-500);
    color: #fff;
    box-shadow: 0 4px 12px rgba(224, 95, 0, .25);
}
.btn--primary:hover { background: var(--orange-600); color: #fff; transform: translateY(-1px); }

.btn--navy { background: var(--navy-900); color: #fff; }
.btn--navy:hover { background: var(--navy-700); color: #fff; transform: translateY(-1px); }

.btn--outline { background: #fff; border-color: #cbd5e1; color: var(--ink); }
.btn--outline:hover { border-color: var(--navy-900); color: var(--navy-900); }

.btn--danger { background: #fff; border-color: #f3c1c1; color: var(--red-600); }
.btn--danger:hover { background: var(--red-600); border-color: var(--red-600); color: #fff; }

.btn--ghost { background: transparent; color: var(--slate-600); }
.btn--ghost:hover { background: var(--bg); color: var(--ink); }

.btn--sm { padding: 7px 14px; font-size: 13.5px; }
.btn--sm .icon { width: 15px; height: 15px; }
.btn--lg { padding: 15px 30px; font-size: 16px; }
.btn--block { width: 100%; }

/* --------------------------------------------------------------------------
   7. Cards, KPI cards, panels
   -------------------------------------------------------------------------- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

.card--flush { padding: 0; overflow: hidden; }

.card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.card__head h2, .card__head h3 { margin: 0; }
.card--flush .card__head { padding: 18px 20px 0; }

.card-grid { display: grid; gap: 22px; }
.card-grid--2 { grid-template-columns: repeat(2, 1fr); }
.card-grid--3 { grid-template-columns: repeat(3, 1fr); }

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

.kpi {
    position: relative;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    padding: 20px 20px 18px;
    overflow: hidden;
    transition: transform .2s ease, box-shadow .2s ease;
    text-decoration: none;
    display: block;
    color: inherit;
}
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.kpi::after {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--orange-500);
    border-radius: 4px 0 0 4px;
}
.kpi--navy::after { background: var(--navy-700); }
.kpi--green::after { background: var(--green-600); }
.kpi--red::after { background: var(--red-600); }
.kpi--amber::after { background: var(--amber-600); }

.kpi__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.kpi__label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--slate-500);
}

.kpi__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--orange-100);
    color: var(--orange-600);
}
.kpi__icon .icon { width: 19px; height: 19px; }

.kpi__value {
    font-family: var(--font-display);
    font-size: 34px;
    font-weight: 800;
    line-height: 1;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.kpi__meta { margin-top: 6px; font-size: 12.5px; color: var(--slate-500); }

/* --------------------------------------------------------------------------
   8. Badges
   -------------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .02em;
    line-height: 1.6;
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--slate-600);
    white-space: nowrap;
}

.badge--new,
.badge--scheduled,
.badge--sent { background: #e8f1fd; border-color: #c9defa; color: #1d4ed8; }

.badge--contacted,
.badge--in-progress { background: #e6f4f9; border-color: #c4e5f0; color: #0e7490; }

.badge--quote-sent,
.badge--draft,
.badge--unscheduled { background: #f1f5f9; border-color: #e2e8f0; color: var(--slate-600); }

.badge--won,
.badge--active,
.badge--paid,
.badge--completed,
.badge--passed { background: #e9f7ee; border-color: #c8ebd4; color: var(--green-600); }

.badge--lost,
.badge--failed,
.badge--overdue,
.badge--emergency,
.badge--canceled { background: #fdecec; border-color: #f8d0d0; color: var(--red-600); }

.badge--attention,
.badge--needs-service,
.badge--on-hold,
.badge--paused,
.badge--high { background: #fdf3e3; border-color: #f8e2bb; color: var(--amber-600); }

.badge--void,
.badge--inactive,
.badge--decommissioned { background: #f1f5f9; border-color: #e2e8f0; color: #94a3b8; text-decoration: line-through; }

.badge--prospect { background: var(--orange-100); border-color: #fad9bc; color: var(--orange-600); }

.badge--residential,
.badge--commercial,
.badge--maintenance,
.badge--financing,
.badge--other,
.badge--normal,
.badge--essential,
.badge--priority,
.badge--total-care { background: #eef2f9; border-color: var(--line); color: var(--navy-700); }

/* --------------------------------------------------------------------------
   9. Forms
   -------------------------------------------------------------------------- */
.field { margin-bottom: 18px; }

.field label {
    display: block;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 6px;
}

.field .req { color: var(--red-600); }

.field input[type="text"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="date"],
.field input[type="number"],
.field input[type="password"],
.field select,
.field textarea {
    width: 100%;
    padding: 10px 13px;
    font-family: var(--font-body);
    font-size: 14.5px;
    color: var(--ink);
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    transition: border-color .15s ease, box-shadow .15s ease;
    appearance: none;
}

.field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234a5b73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.field textarea { min-height: 110px; resize: vertical; }

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--orange-500);
    box-shadow: 0 0 0 3px rgba(244, 123, 32, .18);
}

.field .hint { font-size: 12.5px; color: var(--slate-500); margin-top: 4px; }
.field .error { font-size: 12.5px; color: var(--red-600); margin-top: 4px; font-weight: 500; }
.field.is-invalid input,
.field.is-invalid select,
.field.is-invalid textarea { border-color: var(--red-600); }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    column-gap: 18px;
}
.form-grid--3 { grid-template-columns: repeat(3, 1fr); }
.form-grid .field--full { grid-column: 1 / -1; }

.form-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 8px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    flex-wrap: wrap;
}

/* Inline table search */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.search-box { position: relative; min-width: 240px; flex: 1; max-width: 360px; }
.search-box .icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 17px;
    height: 17px;
    color: var(--slate-500);
    pointer-events: none;
}
.search-box input {
    width: 100%;
    padding: 10px 13px 10px 38px;
    font-family: var(--font-body);
    font-size: 14.5px;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.search-box input:focus {
    outline: none;
    border-color: var(--orange-500);
    box-shadow: 0 0 0 3px rgba(244, 123, 32, .18);
}

/* Filter tabs (lead pipeline etc.) */
.tab-row {
    display: flex;
    gap: 6px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 20px;
    overflow-x: auto;
    flex-wrap: nowrap;
}
.tab {
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--slate-500);
    text-decoration: none;
    border-bottom: 2.5px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: color .15s ease, border-color .15s ease;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--orange-600); border-bottom-color: var(--orange-500); }
.tab__count {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    padding: 1px 8px;
    color: var(--slate-600);
}
.tab.is-active .tab__count { background: var(--orange-100); border-color: #fad9bc; color: var(--orange-600); }

/* --------------------------------------------------------------------------
   10. Tables
   -------------------------------------------------------------------------- */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.table { width: 100%; border-collapse: collapse; font-size: 14px; }

.table th {
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--slate-500);
    background: var(--bg);
    padding: 11px 16px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.table td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover { background: #fbfcfe; }

.table a { font-weight: 600; text-decoration: none; }
.table a:hover { text-decoration: underline; }

.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions-cell { text-align: right; white-space: nowrap; }

/* Mobile stacking: give each td a data-label attribute */
@media (max-width: 640px) {
    .table--stack thead { display: none; }
    .table--stack tr {
        display: block;
        border-bottom: 1px solid var(--line);
        padding: 10px 0;
    }
    .table--stack td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 16px;
        border: 0;
        padding: 6px 16px;
        text-align: right;
    }
    .table--stack td::before {
        content: attr(data-label);
        font-size: 12px;
        font-weight: 700;
        letter-spacing: .06em;
        text-transform: uppercase;
        color: var(--slate-500);
        text-align: left;
    }
    .table--stack .actions-cell { justify-content: flex-end; }
}

/* --------------------------------------------------------------------------
   11. Alerts / flash
   -------------------------------------------------------------------------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 13px 15px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fff;
    margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
}

.alert > .icon { margin-top: 2px; }
.alert__body { flex: 1; font-size: 14px; }
.alert__body strong { display: block; margin-bottom: 2px; }
.alert__list { margin: 6px 0 0; padding-left: 18px; }
.alert__list li { margin-bottom: 2px; }

.alert__close {
    background: none;
    border: 0;
    padding: 2px;
    cursor: pointer;
    color: inherit;
    opacity: .55;
    transition: opacity .15s ease;
}
.alert__close:hover { opacity: 1; }
.alert__close .icon { width: 16px; height: 16px; }

.alert--success { background: #f0faf3; border-color: #c8ebd4; color: #14532d; }
.alert--success > .icon { color: var(--green-600); }
.alert--error { background: #fdf1f1; border-color: #f8d0d0; color: #7f1d1d; }
.alert--error > .icon { color: var(--red-600); }
.alert--info { background: #eff6ff; border-color: #cfe0fa; color: #1e3a8a; }
.alert--info > .icon { color: #1d4ed8; }

/* --------------------------------------------------------------------------
   12. Empty states
   -------------------------------------------------------------------------- */
.empty-state {
    text-align: center;
    padding: 56px 24px;
    color: var(--slate-500);
}

.empty-state__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--slate-500);
    margin-bottom: 18px;
}
.empty-state__icon .icon { width: 32px; height: 32px; }

.empty-state h3 { color: var(--ink); margin-bottom: 6px; }
.empty-state p { max-width: 380px; margin: 0 auto 20px; font-size: 14.5px; }

/* --------------------------------------------------------------------------
   13. Pager
   -------------------------------------------------------------------------- */
.pager { margin-top: 22px; }
.pager__list {
    display: flex;
    gap: 6px;
    justify-content: center;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}
.pager__link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 36px;
    height: 36px;
    padding-inline: 11px;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
    color: var(--ink);
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.pager__link:hover { border-color: var(--orange-500); color: var(--orange-600); }
.pager__link.is-current { background: var(--navy-900); border-color: var(--navy-900); color: #fff; }
.pager__link .icon { width: 15px; height: 15px; }

/* --------------------------------------------------------------------------
   14. Messages thread
   -------------------------------------------------------------------------- */
.thread { display: grid; gap: 14px; }

.msg {
    max-width: 72%;
    padding: 13px 16px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    font-size: 14.5px;
}
.msg--mine {
    margin-left: auto;
    background: var(--navy-900);
    border-color: var(--navy-900);
    color: rgba(255, 255, 255, .92);
    border-bottom-right-radius: 4px;
}
.msg--theirs { margin-right: auto; border-bottom-left-radius: 4px; }
.msg__meta { display: block; margin-top: 6px; font-size: 11.5px; opacity: .65; }

/* --------------------------------------------------------------------------
   15. Invoice builder & printable invoice
   -------------------------------------------------------------------------- */
.invoice-builder .table td { padding: 8px 10px; }
.invoice-builder .field { margin-bottom: 0; }

.invoice-totals {
    margin-left: auto;
    max-width: 320px;
    display: grid;
    gap: 8px;
    padding-top: 16px;
}
.invoice-totals__row {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    font-size: 14.5px;
}
.invoice-totals__row--grand {
    border-top: 2px solid var(--ink);
    padding-top: 10px;
    font-size: 17px;
    font-weight: 700;
}

.invoice-doc {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    padding: 44px 48px;
    max-width: 860px;
}

.invoice-doc__head {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--navy-950);
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.invoice-doc__wordmark {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 26px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--navy-950);
    line-height: 1.1;
}
.invoice-doc__wordmark em { font-style: normal; color: var(--orange-500); }

.invoice-doc__title {
    font-family: var(--font-display);
    font-size: 38px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--line);
    line-height: 1;
    text-align: right;
}

.invoice-doc .table th { background: var(--navy-950); color: #fff; border-color: var(--navy-950); }

/* --------------------------------------------------------------------------
   16. Auth pages (client/staff login) — uses body.auth-page
   -------------------------------------------------------------------------- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
    background:
        radial-gradient(ellipse 80% 60% at 80% -10%, rgba(244, 123, 32, .14), transparent 60%),
        radial-gradient(ellipse 60% 60% at 0% 100%, rgba(29, 63, 110, .5), transparent 65%),
        linear-gradient(160deg, var(--navy-950) 0%, var(--navy-900) 55%, var(--navy-800) 100%);
}

.auth-wrap { width: 100%; max-width: 440px; text-align: center; }

.auth-brand {
    display: inline-block;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 27px;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: #fff;
    text-decoration: none;
    margin-bottom: 26px;
}
.auth-brand em { font-style: normal; color: var(--orange-500); }
.auth-brand__state { color: rgba(255, 255, 255, .55); letter-spacing: .3em; font-size: 20px; }

.auth-card {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .4);
    padding: 36px 34px;
    text-align: left;
}

.auth-card h1 {
    font-size: 26px;
    margin-bottom: 4px;
}
.auth-card .auth-sub { color: var(--slate-500); font-size: 14.5px; margin-bottom: 24px; }

.auth-back { margin-top: 24px; }
.auth-back a {
    color: rgba(255, 255, 255, .65);
    font-size: 14px;
    text-decoration: none;
}
.auth-back a:hover { color: #fff; }

.auth-wrap .powered-by { margin-top: 10px; }

/* --------------------------------------------------------------------------
   17. Misc utilities
   -------------------------------------------------------------------------- */
.stack-sm > * + * { margin-top: 10px; }
.stack > * + * { margin-top: 20px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.mb-0 { margin-bottom: 0 !important; }
.mt-24 { margin-top: 24px; }
.w-full { width: 100%; }

.divider { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }

.def-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px 24px;
    margin: 0;
    font-size: 14.5px;
}
.def-list dt { font-weight: 600; color: var(--slate-500); }
.def-list dd { margin: 0; }

/* --------------------------------------------------------------------------
   18. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1200px) {
    .card-grid--3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-105%);
        transition: transform .28s ease;
        box-shadow: 24px 0 60px rgba(8, 26, 51, .25);
    }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open { overflow: hidden; }

    .portal-body { margin-left: 0; }
    .topbar { padding-inline: 18px; }
    .topbar__menu { display: inline-flex; }
    .portal-main { padding: 22px 18px 36px; }
    .card-grid--2, .card-grid--3 { grid-template-columns: 1fr; }
    .form-grid--3 { grid-template-columns: repeat(2, 1fr); }
    .topbar__user-meta { display: none; }
    .crumbs { display: none; }
    .invoice-doc { padding: 28px 22px; }
}

@media (max-width: 640px) {
    .form-grid,
    .form-grid--3 { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
    .page-head { flex-direction: column; align-items: stretch; }
    .page-head__actions .btn { flex: 1; }
    .msg { max-width: 88%; }
    .auth-card { padding: 28px 22px; }
}

/* --------------------------------------------------------------------------
   19. Print (invoices & records)
   -------------------------------------------------------------------------- */
@media print {
    body { background: #fff !important; font-size: 12.5pt; }
    .sidebar,
    .sidebar-overlay,
    .topbar,
    .portal-footer,
    .page-head__actions,
    .alert,
    .btn,
    .no-print { display: none !important; }
    .portal-body { margin-left: 0 !important; }
    .portal-main { padding: 0 !important; max-width: none; }
    .card,
    .invoice-doc,
    .table-wrap {
        border: 0 !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }
    .invoice-doc { padding: 0; max-width: none; }
    .invoice-doc .table th {
        background: #fff !important;
        color: #000 !important;
        border-bottom: 2px solid #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .table td, .table th { padding: 8px 6px; }
    a { color: #000 !important; text-decoration: none !important; }
    .badge { border: 1px solid #999 !important; background: #fff !important; color: #000 !important; }
    @page { margin: 18mm 16mm; }
}

/* === auth (AUTH module) === */
.auth-head { text-align: center; margin-bottom: 24px; }
.auth-head__icon { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 16px; background: var(--orange-100); color: var(--orange-600); margin-bottom: 14px; }
.auth-head__icon .icon { width: 28px; height: 28px; }
.auth-head--staff .auth-head__icon { background: #e3ecf7; color: var(--navy-700); }
.auth-head__icon--warn { background: #fdf1e3; color: var(--amber-600); }
.auth-head__title { font-family: 'Barlow Condensed', sans-serif; font-size: 32px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; color: var(--ink); margin: 0 0 6px; }
.auth-head__sub { color: var(--slate-600); font-size: 15px; margin: 0; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form__row { display: flex; align-items: center; justify-content: space-between; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--slate-600); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--orange-500); }
.auth-alt { text-align: center; font-size: 14px; color: var(--slate-600); margin: 20px 0 0; }
.auth-alt a { color: var(--orange-600); font-weight: 600; text-decoration: none; }
.auth-alt a:hover { text-decoration: underline; }
.auth-help { text-align: center; font-size: 13px; color: var(--slate-500); margin: 10px 0 0; }

/* === staff (STAFF modules) === */
.activity-feed { list-style: none; margin: 0; padding: 8px 24px 20px; display: grid; gap: 14px; }
.activity-feed li { display: flex; gap: 12px; font-size: 14px; color: var(--slate-600); }
.activity-feed__dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--orange-500); margin-top: 6px; }
.activity-feed strong { color: var(--ink); }
.activity-feed__time { display: block; font-size: 12px; color: var(--slate-500); margin-top: 2px; }
.check--inline { margin-right: 10px; }
.page-head__actions form { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.lead-message { background: var(--bg); border-radius: 10px; padding: 14px 16px; font-size: 14.5px; color: var(--ink); }
.field--check { display: flex; align-items: flex-end; padding-bottom: 10px; }
.num-input { text-align: right; }
.invoice-items-table input { width: 100%; }
.invoice-doc__billto { margin: 22px 0; }
.invoice-doc__billto h4 { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 6px; }
.invoice-doc__foot { margin-top: 26px; font-size: 13px; }
@media print {
  .sidebar, .topbar, .portal-footer, .page-head, .alert, .print-hide { display: none !important; }
  .portal-main { padding: 0 !important; }
  .portal-body { margin: 0 !important; }
  .card.invoice-doc { box-shadow: none !important; border: 0 !important; }
  body { background: #fff !important; }
}

/* === staff profile / avatars === */
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
.avatar--xl { width: 112px; height: 112px; border-radius: 26px; font-size: 34px; flex: 0 0 auto; }
.avatar-editor { display: flex; gap: 24px; align-items: flex-start; }
.avatar-editor__actions { display: grid; gap: 12px; }
.avatar-editor__actions form { display: grid; gap: 10px; }
.avatar-editor__fine { font-size: 12.5px; margin: 0; }
.file-drop { display: block; cursor: pointer; }
.file-drop input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-drop__hint { display: inline-flex; align-items: center; gap: 8px; padding: 11px 18px; border: 1.5px dashed var(--line); border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--slate-600); transition: border-color .15s ease, color .15s ease; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-drop:hover .file-drop__hint { border-color: var(--orange-500); color: var(--orange-600); }
.file-drop input:focus-visible + .file-drop__hint { outline: 2px solid var(--orange-500); outline-offset: 2px; }
.field__hint { font-size: 12.5px; margin-top: 6px; }
@media (max-width: 640px) { .avatar-editor { flex-direction: column; } }

/* === team + staff enhancements === */
.avatar--sm { width: 34px; height: 34px; font-size: 13px; border-radius: 10px; flex: 0 0 auto; }
.member-cell { display: flex; align-items: center; gap: 10px; }
.inline-form { display: inline-block; margin: 0 0 0 6px; }
.copy-row { display: flex; gap: 10px; }
.copy-row input { flex: 1; font-size: 13px; color: var(--slate-600); background: var(--bg); }
.invite-link-card { border-color: var(--orange-500); margin-bottom: 22px; }
.badge--superadmin { background: #ede9fe; color: #6d28d9; border-color: #ddd6fe; }
.badge--staff { background: #e0f2fe; color: #0369a1; border-color: #bae6fd; }
.age-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.age-dot--fresh { background: var(--green-600); }
.age-dot--warm { background: var(--amber-600); }
.age-dot--stale { background: var(--red-600); }
.quick-status select { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.agenda-day { padding: 12px 24px 6px; font-family: 'Barlow Condensed', sans-serif; font-size: 17px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--navy-700); border-bottom: 1px solid var(--line); background: var(--bg); }
.mini-form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 900px) { .mini-form-grid { grid-template-columns: 1fr; } }
.tab-row + .tab-row { margin-top: -8px; }

/* === settings page === */
.settings-card { max-width: 860px; }
.tab-row .tab .icon { width: 16px; height: 16px; margin-right: 6px; vertical-align: -3px; }
.check--switch { position: relative; padding-left: 52px; min-height: 26px; display: flex; align-items: center; }
.check--switch input[type="checkbox"] { position: absolute; left: 0; width: 44px; height: 24px; margin: 0; appearance: none; background: var(--line); border-radius: 999px; cursor: pointer; transition: background .18s ease; }
.check--switch input[type="checkbox"]::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(8,26,51,.3); transition: transform .18s ease; }
.check--switch input[type="checkbox"]:checked { background: var(--green-600); }
.check--switch input[type="checkbox"]:checked::after { transform: translateX(20px); }
.check--switch input[type="checkbox"]:focus-visible { outline: 2px solid var(--orange-500); outline-offset: 2px; }
.field--social label .social-label { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.field--social .icon { width: 18px; height: 18px; color: var(--navy-700); }
.rev-key { font-size: 12.5px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; }
.rev-diff { font-size: 13px; max-width: 420px; }
.rev-old { color: var(--red-600); text-decoration: line-through; text-decoration-color: rgba(185,28,28,.4); }
.rev-new { color: var(--green-600); font-weight: 600; }
.rev-arrow { color: var(--slate-500); margin: 0 6px; }

/* === ops map === */
#ops-map { height: 420px; border-radius: 0 0 14px 14px; }
.map-legend { display: flex; gap: 16px; flex-wrap: wrap; }
.map-legend__item { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--slate-600); }
.map-legend__dot { width: 11px; height: 11px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(8,26,51,.15); }
.leaflet-popup-content { font-family: 'Inter', sans-serif; font-size: 13.5px; }
