/* ═══════════════════════════════════════════════════════════════
   1. FONTS
   ═══════════════════════════════════════════════════════════════ */
@font-face {
    font-family: 'JuliettaMessie';
    src: url('../fonts/JuliettaMessie.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'IBM Plex Sans';
    src: url('../fonts/ibm-plex-sans-latin.woff2') format('woff2');
    font-weight: 400 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'IBM Plex Sans';
    src: url('../fonts/ibm-plex-sans-latin-ext.woff2') format('woff2');
    font-weight: 400 600;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Rubik';
    src: url('../fonts/rubik-latin.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Rubik';
    src: url('../fonts/rubik-latin-ext.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ═══════════════════════════════════════════════════════════════
   2. CSS VARIABLES
   ═══════════════════════════════════════════════════════════════ */
:root {
    --bg:         #edf1fb;
    --surface:    #ffffff;
    --surface2:   #f0f2f6;
    --border:     #dfe5ee;
    --accent:     #5a8dee;
    --accent-dim: rgb(81, 127, 214);
    --text:       rgb(103, 119, 136);
    --heading:    rgb(81, 99, 119);
    --muted:      rgba(103, 119, 136, 0.75);
    --emphasis:   #263c55;
    --success:    #39da8a;
    --warning:    #d97706;
    --danger:     #ff5b5c;
    --font:       'IBM Plex Sans', system-ui, -apple-system, sans-serif;
    --sidebar-w:  240px;
}

/* ═══════════════════════════════════════════════════════════════
   3. BASE ELEMENTS
   ═══════════════════════════════════════════════════════════════ */
body {
    font-family: var(--font);
    font-size: 0.9375rem;
    font-weight: 400;
    background:
        radial-gradient(circle at top left, rgba(90, 141, 238, 0.12), transparent 30%),
        radial-gradient(circle at bottom right, rgba(111, 66, 193, 0.10), transparent 28%),
        linear-gradient(135deg, #f8f9fa 0%, #eef3ff 46%, #f8f9fa 100%);
    color: var(--text);
    line-height: 1.47;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Rubik', 'Times New Roman', serif;
    font-weight: 500;
    color: var(--heading);
}

/* ═══════════════════════════════════════════════════════════════
   4. FORMS (Bootstrap overrides)
   ═══════════════════════════════════════════════════════════════ */
.form-label {
    font-size: 0.75rem;
    color: var(--text);
    margin-bottom: 0.25rem;
    font-weight: 400;
}

.form-check-label {
    color: var(--text);
    font-size: 0.9375rem;
}

.form-control,
.form-select {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.9375rem;
    font-family: var(--font);
    font-weight: 400;
    line-height: 1.4;
}

.form-control:focus,
.form-select:focus {
    background: #fff;
    /* outline:none always needs a real replacement — a keyboard user
       tabbing through a form needs to see which field is active. */
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(90, 141, 238, 0.2);
    outline: none;
    color: var(--text);
}

.form-control::placeholder {
    color: rgb(168, 177, 187);
    opacity: 1;
}

.form-control:disabled,
.form-select:disabled,
.form-control:read-only:not(.money-input) {
    background-color: rgb(233, 235, 238);
    color: var(--text);
    opacity: 1;
}

.input-group {
    display: flex;
}
.input-group > .form-control,
.input-group > .form-select {
    border-radius: 0;
    margin-left: -1px;
    position: relative;
}
.input-group > .form-control:first-child,
.input-group > .form-select:first-child {
    border-radius: 6px 0 0 6px;
    margin-left: 0;
}
.input-group > .form-control:last-child,
.input-group > .form-select:last-child {
    border-radius: 0 6px 6px 0;
}
.input-group > .form-control:focus,
.input-group > .form-select:focus {
    z-index: 1;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    width: 20px;
    height: 100%;
    opacity: 1;
    cursor: pointer;
}

/* ── Money input ── */
.input-money {
    position: relative;
}
.input-money::before {
    content: '$';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 0.875rem;
    pointer-events: none;
    z-index: 4;
}
.input-money .form-control {
    padding-left: 24px;
}

/* ── Lead status select ── */
.lead-status-select {
    height: 38px;
    padding: 0 32px 0 10px;
    font-size: 0.875rem;
    font-family: var(--font);
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center;
    color: var(--text);
    cursor: pointer;
    appearance: none;
}

/* ── Toggle switch ── */
.admin-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}
.admin-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
}
.admin-toggle-slider {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    background: #9ca3af;
    border-radius: 12px;
    transition: background .2s;
}
.admin-toggle-slider::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 3px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,.25);
    transition: left .2s;
}
.admin-toggle input:checked ~ .admin-toggle-slider {
    background: var(--accent);
}
.admin-toggle input:checked ~ .admin-toggle-slider::before {
    left: 23px;
}
.admin-toggle-label {
    font-size: 0.8125rem;
    color: var(--text);
}

/* ── Honeypot ── */
.hp-field {
    position: absolute;
    left: -9999px;
    height: 0;
    overflow: hidden;
    opacity: 0;
}

/* ═══════════════════════════════════════════════════════════════
   5. BUTTONS
   ═══════════════════════════════════════════════════════════════ */
.btn {
    font-family: var(--font);
    font-weight: 400;
    box-shadow: none;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
}
.btn-primary:hover,
.btn-primary:focus {
    background: var(--accent-dim);
    border-color: var(--accent-dim);
}

.btn-label-secondary {
    background: rgba(90, 141, 238, .08);
    color: var(--accent);
    border-color: rgba(90, 141, 238, .2);
}
.btn-label-secondary:hover,
.btn-label-secondary:focus {
    background: rgba(90, 141, 238, .15);
    color: var(--accent);
    border-color: rgba(90, 141, 238, .3);
}

.btn-label-danger {
    background: rgba(255, 91, 92, .08);
    color: var(--danger);
    border-color: rgba(255, 91, 92, .2);
}
.btn-label-danger:hover,
.btn-label-danger:focus {
    background: rgba(255, 91, 92, .15);
    color: var(--danger);
    border-color: rgba(255, 91, 92, .3);
}

.copy-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    padding: 0;
    margin-left: 4px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    position: relative;
    top: -2px;
    opacity: .6;
    height: auto;
}
.copy-btn:hover { opacity: 1; color: var(--accent); }
.copy-btn svg { width: 16px; height: 16px; }
.click-copy[readonly] { cursor: copy; }
.click-copy.copied { border-color: #39da8a; box-shadow: 0 0 0 2px rgba(57, 218, 138, 0.25); }

.row-action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    color: var(--muted);
    transition: background .15s, color .15s;
}
.row-action-icon:hover { background: rgba(90,141,238,.08); color: var(--accent); }
.row-action-icon svg { width: 22px; height: 22px; }

/* ═══════════════════════════════════════════════════════════════
   6. ALERTS
   ═══════════════════════════════════════════════════════════════ */
.alert-success { --bs-alert-color: var(--emphasis); }
.alert-danger   { --bs-alert-color: var(--danger); }
.alert-info     { --bs-alert-color: var(--accent); }

/* ═══════════════════════════════════════════════════════════════
   7. CARDS & TABLES
   ═══════════════════════════════════════════════════════════════ */
.card {
    border-color: var(--border);
    border-radius: 10px;
    overflow: hidden;
}

/* Matches AfterPlan's real .records-card .table-responsive exactly:
   white table, thin pale-blue border — not a blue background/frame.
   The outer .card's own border is suppressed here (:has) so it doesn't
   stack with this one at zero gap and render as one thick/doubled line
   — AfterPlan's outer .records-card has no border of its own either,
   only this inner box does. */
.card:has(> .table-responsive),
.card:has(> table):not(:has(> .card-form-table)) {
    border: none;
}
.card > .table-responsive,
.card > table:not(.card-form-table) {
    background: var(--surface);
    border: 1px solid #d8dff0;
    border-radius: 10px;
    overflow: hidden;
}

/* border-collapse:collapse (Bootstrap's table default) draws each
   cell's own square-cornered border independently of the wrapper's
   border-radius — the classic cause of a rounded box with square
   corners poking through at the very corner cells. Switching to
   separate + rounding the actual corner cells is the correct fix,
   not just overflow:hidden on the wrapper (which doesn't reliably
   clip collapsed-border table corners in every browser). */
.card > .table-responsive table,
.card > table:not(.card-form-table) {
    border-collapse: separate;
    border-spacing: 0;
}
.card > .table-responsive thead tr:first-child th:first-child,
.card > table:not(.card-form-table) thead tr:first-child th:first-child {
    border-top-left-radius: 9px;
}
.card > .table-responsive thead tr:first-child th:last-child,
.card > table:not(.card-form-table) thead tr:first-child th:last-child {
    border-top-right-radius: 9px;
}
.card > .table-responsive tbody tr:last-child td:first-child,
.card > table:not(.card-form-table) tbody tr:last-child td:first-child {
    border-bottom-left-radius: 9px;
}
.card > .table-responsive tbody tr:last-child td:last-child,
.card > table:not(.card-form-table) tbody tr:last-child td:last-child {
    border-bottom-right-radius: 9px;
}

/* The table's own last-row border was stacking on top of the card's
   own bottom border, making that one edge render thicker/different
   than the single-line left/top/right borders. */
.card .table tbody tr:last-child > * {
    border-bottom: none;
}

.card-header {
    background: #f5f7fc;
    border-bottom-color: var(--border);
    font-size: 0.9375rem;
    color: var(--heading);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
}

.card-footer-link {
    padding: 11px 20px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.8125rem;
}
.card-footer-link a { color: var(--accent); text-decoration: none; }
.card-footer-link a:hover { color: var(--accent-dim); text-decoration: underline; }

.table th {
    font-size: 0.6875rem;
    font-weight: 400;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .07em;
    border-bottom-width: 1px;
    border-color: var(--border);
    padding: 10px 22px;
    /* Bootstrap sets an explicit white background-color on every cell
       (--bs-table-bg), which was painting over the card's own blue
       background regardless of what the card itself was set to. */
    background-color: transparent;
}

.table td {
    padding: 12px 22px;
    border-color: var(--border);
    color: var(--text);
    background-color: transparent;
    vertical-align: middle;
}

.table td a:not(.btn) {
    font-weight: 400;
    color: var(--accent);
    text-decoration: none;
}

.table-hover > tbody > tr:hover > * {
    --bs-table-bg-state: rgba(90, 141, 238, 0.04);
}

.row-overdue > td { --bs-table-bg-state: rgba(255, 91, 92, 0.04); }

.template-row.drag-over td { background: #eff4ff; }
.drag-handle { user-select: none; }

/* ── Table cell helpers ── */
.td-shrink { width: 1%; white-space: nowrap; }
.table .td-client { padding-left: 71px; }
.td-email { padding-left: 10px !important; }
.td-amount {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--heading);
    font-weight: 400;
    white-space: nowrap;
}

.inv-num-cell { white-space: nowrap; width: 1%; }
.inv-num {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--accent);
    font-size: 0.875rem;
}
.inv-num svg { color: var(--muted); flex-shrink: 0; position: relative; top: -1px; }

.inv-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border-radius: 99px;
    background: rgba(90,141,238,.1);
    color: var(--accent);
    font-size: 0.75rem;
}

/* ── Client cell (used in list/table rows) ── */
.client-cell {
    display: inline-flex;
    align-items: center;
    gap: 24px;
}
.client-avatar-sm {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(90,141,238,.1);
    color: var(--accent);
    font-size: 0.625rem;
    font-weight: 500;
    letter-spacing: .02em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.client-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(90,141,238,.1);
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: .02em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.client-cell-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.client-cell-name    { font-size: 0.9375rem; color: var(--accent); }
.client-cell-company { font-size: 0.875rem; color: var(--muted); }
.client-address       { font-size: 0.875rem; color: var(--text); }

.client-email-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color .15s;
    cursor: pointer;
}
.client-email-link:hover { color: var(--accent); }

.client-meta-strip {
    display: flex;
    gap: 32px;
    flex-wrap: wrap;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.client-meta-item  { display: flex; flex-direction: column; gap: 2px; }
.client-meta-label { font-size: 0.75rem; font-weight: 400; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.client-meta-value { font-size: 1.0625rem; color: var(--heading); display: flex; align-items: center; gap: 6px; }

/* ── Invoice line items ── */
.line-items-table { width: 100%; margin-bottom: 16px; table-layout: fixed; }
.line-items-table th { font-size: 0.6875rem; color: var(--muted); padding: 6px 8px; text-align: left; }
.line-items-table td { padding: 6px 8px; }
.line-items-table .form-control,
.line-items-table .form-select { margin-bottom: 0; }
.line-items-table .input-money { margin-bottom: 0; }
.line-items-table .input-money::before { left: 6px; }
.line-items-table .input-money .form-control { padding-left: 20px; }
.line-items-table .dragging-row { opacity: 0.4; }
.line-items-table .drag-handle:active { cursor: grabbing; }

.line-items-total {
    text-align: right;
    font-size: 1.125rem;
    color: var(--heading);
    margin-top: 4px;
}
.line-items-total span { color: var(--accent); }

/* ── Invoice line presets ── */
.preset-item {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    min-width: 0;
    cursor: pointer;
    transition: background .15s;
}
.preset-item:hover { background: var(--border); }
.preset-item-body { flex: 1; min-width: 0; }
.preset-desc { font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preset-meta { font-size: 0.9rem; color: var(--muted); margin-top: 2px; }
.preset-delete {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
    flex-shrink: 0;
}
.preset-delete:hover { color: var(--danger); }

.preset-pill {
    padding: 4px 12px;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.preset-pill:hover { background: var(--surface2); color: var(--text); }
.preset-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.desc-field .item-desc-custom { display: none; margin-top: 4px; }
.desc-field.is-custom .item-desc-select { display: none; }
.desc-field.is-custom .item-desc-custom { display: block; }

/* ═══════════════════════════════════════════════════════════════
   8. BADGES
   ═══════════════════════════════════════════════════════════════ */
.badge-draft   { background: rgba(122,132,163,.2) !important; color: var(--muted) !important; }
.badge-sent    { background: rgba(79,124,255,.2)  !important; color: var(--accent) !important; }
.badge-paid    { background: rgba(52,201,138,.2)  !important; color: var(--success) !important; }
.badge-overdue { background: rgba(224,90,90,.2)   !important; color: var(--danger) !important; }
.badge-voided  { background: rgba(107,117,144,.15) !important; color: var(--muted) !important; }
.badge-written-off { background: rgba(217,119,6,.15) !important; color: var(--warning) !important; }
.badge-refunded { background: rgba(224,90,90,.15) !important; color: var(--danger) !important; }

/* Lead source/status badges — shared by leads/index.php and leads/view.php
   via App\Support\LeadSource::badge(). Distinct hues per Michael's ask
   (2026-10-19) since the generic badge-draft/badge-paid palette collided
   across Quote·Custom/Contact Form and Referral/Contacted. */
.badge-source-contact  { background: rgba(79,124,255,.2)  !important; color: var(--accent) !important; }
.badge-source-package  { background: rgba(110,99,255,.18) !important; color: #6e63ff !important; }
.badge-source-custom   { background: rgba(217,119,6,.18)  !important; color: #d97706 !important; }
.badge-source-referral { background: rgba(219,39,119,.15) !important; color: #db2777 !important; }
.badge-status-contacted { background: rgba(13,148,136,.18) !important; color: #0d9488 !important; }

.hosting-chip-paid {
    display:inline-flex;align-items:center;gap:5px;
    background:rgba(57,218,138,.13);color:#1fa864;
    font-size:0.6875rem;font-weight:600;padding:4px 10px;
    border-radius:20px;white-space:nowrap;
}
.hosting-chip-unpaid {
    display:inline-flex;align-items:center;gap:5px;
    background:rgba(255,91,92,.10);color:#d94444;
    font-size:0.6875rem;font-weight:600;padding:4px 10px;
    border-radius:20px;white-space:nowrap;
}
.hosting-btn-pay {
    font-size:0.6875rem;padding:4px 12px;
    background:#5a8dee;color:#fff;border:none;
    border-radius:4px;cursor:pointer;white-space:nowrap;
    font-weight:600;letter-spacing:.01em;
}
.hosting-btn-pay:hover { background:#4477d4; }
.hosting-undo {
    background:none;border:none;color:var(--muted);font-size:0.625rem;
    cursor:pointer;padding:0;text-decoration:underline;text-underline-offset:2px;
}
.hosting-month-current { background:rgba(90,141,238,.05); }
th.hosting-month-current { background:rgba(90,141,238,.08); }

/* ═══════════════════════════════════════════════════════════════
   9. TABS
   ═══════════════════════════════════════════════════════════════ */
/* Underline style, not the old box-pop-up active tab — a floating white
   box reads as "unfinished" unless it's flush-merged into real content
   directly below it. Default here is a complete standalone rounded
   panel (all 4 corners) since most tab bars on this site aren't merged
   into a single following card. Pages that DO merge (one .tab-body with
   exactly one .card right after) keep that via .tab-body > .card:first-child
   below — add the `.nav-tabs-merged` modifier to the <ul> in that case
   so the radius stays top-only and the seam stays flush. */
.nav-tabs {
    display: flex;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 16px;
}
.nav-tabs.nav-tabs-merged {
    border-bottom: 1px solid var(--border);
    border-radius: 10px 10px 0 0;
}
.nav-tabs .nav-item {
    height: 44px;
    display: flex;
}
.nav-tabs .nav-link {
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
    box-sizing: border-box;
    padding: 0 8px;
    font-size: 0.9375rem;
    color: var(--muted);
    text-decoration: none;
    border: none;
    border-radius: 0;
    background: transparent;
}
.nav-tabs .nav-link:hover {
    color: var(--accent);
}
.nav-tabs .nav-link.active {
    color: var(--heading);
    font-weight: 500;
    background: transparent;
}
.nav-tabs .nav-link.active::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
}
.tab-body {
    padding-top: 1.25rem;
}
.nav-tabs-merged + .tab-body > .card:first-child {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-top-color: transparent;
    margin-top: -1.25rem;
}

/* ═══════════════════════════════════════════════════════════════
   10. SIDEBAR
   ═══════════════════════════════════════════════════════════════ */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: #fff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar.sidebar-local {
    border-right: 1px solid var(--danger);
}

.sb-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 20px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    text-decoration: none;
}

.sb-logo { height: 38px; width: auto; flex-shrink: 0; }

.sb-brand-name {
    font-family: 'Rubik', sans-serif;
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--heading);
    line-height: 1.2;
}

.sb-brand-sub { font-size: 0.8125rem; color: var(--muted); }

.sb-nav {
    flex: 1;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.sb-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--text);
    text-decoration: none;
    transition: background .15s, color .15s;
    white-space: nowrap;
}

.sb-item svg { flex-shrink: 0; }

.sb-item:hover { background: rgba(90,141,238,.07); color: var(--accent); }

.sb-item.active {
    background: rgba(90,141,238,.12);
    color: var(--accent);
    font-weight: 500;
}

.sb-divider {
    margin: 8px 12px;
    border: none;
    border-top: 1px solid var(--border);
}

.sb-section-label {
    padding: 14px 12px 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
}

.sb-logout:hover { background: rgba(255,91,92,.07); color: var(--danger); }

.sb-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.sb-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: .03em;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sb-user-info { flex: 1; min-width: 0; }

.sb-user-name {
    font-size: 0.8125rem;
    color: var(--heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sb-user-role { font-size: 0.6875rem; color: var(--muted); }

.sb-signout {
    color: var(--muted);
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: color .15s;
}

.sb-signout:hover { color: var(--danger); }

/* Logout is a form/button now (CSRF-protected POST, not a bare GET
   link) — reset default button chrome so it still looks identical to
   the <a> it replaced. width:100% belongs to .sb-item (full-width nav
   rows) only — .sb-signout is the small icon-only footer button and
   must keep sizing to its content, or it stretches across the footer
   row and overlaps the avatar/username next to it. */
button.sb-item, button.sb-signout {
    background: none;
    border: none;
    font: inherit;
    cursor: pointer;
    text-align: left;
}
button.sb-item {
    width: 100%;
}

/* The <form> wrapper shouldn't participate in box layout — the button
   inside it needs to behave exactly like the plain <a> it replaced,
   including .sb-signout's flex-shrink:0 inside the .sb-footer flex row. */
.sb-nav form, .sb-footer form { display: contents; }

/* ═══════════════════════════════════════════════════════════════
   11. MAIN LAYOUT
   ═══════════════════════════════════════════════════════════════ */
.main-content {
    /* Bounded white "page card" floating on the light blue page
       background. Values match AfterPlan's actual CSS: .app-shell's
       1.25rem (20px) outer padding on top/right/bottom, and Bootstrap's
       g-4 gutter (1.5rem/24px) as the gap between the sidebar and the
       content panel on the left. */
    margin: 20px 20px 20px calc(var(--sidebar-w) + 24px);
    padding: 36px 40px;
    min-height: calc(100vh - 40px);
    /* Matches AfterPlan's real .content-panel: translucent white with
       blur (not flat solid white) and a soft, large, low-opacity shadow
       — this is what makes it read as a floating glass panel instead of
       a flat rectangle. */
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 14px;
    box-shadow: 0 1rem 3rem rgba(33, 37, 41, 0.10);
}

/* AfterPlan never floats stat cards/tables directly on the white
   .content-panel — each logical group that contains a data table (and
   standalone data-entry forms) sits inside this gradient tray first.
   Stat-card/KPI rows and sidebar action widgets do NOT get this wrapper
   — see Standards > Admin Panels. Values match AfterPlan's
   .card.records-card exactly (afterplan.css, verified 2026-10-11). */
.panel {
    background: linear-gradient(180deg, #fafbfe 0%, #f5f7fc 45%, #f5f7fc 100%);
    border: 1px solid var(--border);
    box-shadow: 0 4px 6px -4px rgba(0, 0, 0, 0.08);
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 24px;
}
.panel:last-child { margin-bottom: 0; }
.panel > .row:last-child,
.panel > .card:last-child { margin-bottom: 0 !important; }

.page-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.page-title {
    font-family: 'Rubik', 'Times New Roman', serif;
    font-size: 1.375rem;
    font-weight: 500;
    color: var(--heading);
    margin: 0;
}

.section-label {
    font-size: 0.6875rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .07em;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.empty-state {
    padding: 48px;
    text-align: center;
    color: var(--muted);
}

/* ═══════════════════════════════════════════════════════════════
   12. STAT CARDS
   ═══════════════════════════════════════════════════════════════ */
.stat-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.stat-info { flex: 1; min-width: 0; }

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon-warning { background: rgba(217,119,6,.1);  color: var(--warning); }
.stat-icon-success { background: rgba(57,218,138,.1); color: var(--success); }
.stat-icon-accent  { background: rgba(90,141,238,.1); color: var(--accent);  }
.stat-icon-danger  { background: rgba(255,91,92,.1);  color: var(--danger);  }

.card-header-icon {
    display: inline-flex;
    align-items: center;
    margin-right: 6px;
    position: relative;
    top: -1px;
    color: var(--muted);
}

.stat-label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    margin-bottom: 4px;
    display: block;
}

.stat-value {
    font-size: 1.75rem;
    color: var(--heading);
    font-weight: 400;
    line-height: 1.2;
    margin-bottom: 4px;
}

.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-value.danger  { color: var(--danger); }

.stat-sublabel {
    font-size: 0.6875rem;
    color: var(--muted);
}

/* ═══════════════════════════════════════════════════════════════
   13. ACTIVITY CARD & QUICK ACTIONS
   ═══════════════════════════════════════════════════════════════ */
.act-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.act-icon-success { background: rgba(57,218,138,.1);  color: var(--success); }
.act-icon-warning { background: rgba(217,119,6,.1);   color: var(--warning); }
.act-icon-danger  { background: rgba(255,91,92,.1);   color: var(--danger);  }
.act-icon-accent  { background: rgba(90,141,238,.1);  color: var(--accent);  }

.act-label    { font-size: 0.875rem; color: var(--text); }
.act-value    { font-size: 0.875rem; color: var(--heading); font-weight: 500; white-space: nowrap; }
.act-sublabel { font-size: 0.6875rem; color: var(--muted); margin-top: 4px; }

.progress { background: var(--surface2); border-radius: 99px; }

.qa-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    transition: background .15s;
}
.qa-item:hover { background: var(--surface2); color: var(--text); }

.qa-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.qa-icon-accent  { background: rgba(90,141,238,.1); color: var(--accent);  }
.qa-icon-success { background: rgba(57,218,138,.1); color: var(--success); }
.qa-icon-warning { background: rgba(217,119,6,.1);  color: var(--warning); }

.qa-label { font-size: 0.875rem; color: var(--heading); }
.qa-sub   { font-size: 0.6875rem; color: var(--muted); }

/* ═══════════════════════════════════════════════════════════════
   14. CHECKLIST
   ═══════════════════════════════════════════════════════════════ */
.cl-progress-wrap  { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.cl-progress-bg    { flex: 1; height: 8px; background: var(--surface2); border-radius: 99px; border: 1px solid var(--border); overflow: hidden; }
.cl-progress-fill  { height: 100%; background: var(--accent); border-radius: 99px; transition: width .35s; }
.cl-progress-label { font-size: 12.5px; color: var(--muted); white-space: nowrap; }

.cl-phase-group { margin-bottom: 16px; }
.cl-phase-label { font-size: 0.6875rem; font-weight: 400; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 0 0 7px; border-bottom: 1px solid var(--border); margin-bottom: 2px; }

.cl-row { display: flex; align-items: flex-start; gap: 12px; padding: 10px 8px; border-radius: 7px; transition: background .12s; }
.cl-row:hover { background: var(--surface2); }
.cl-row.cl-done .cl-title { text-decoration: line-through; color: var(--muted); }

.cl-num   { font-size: 11.5px; color: var(--muted); width: 24px; text-align: right; padding-top: 3px; flex-shrink: 0; }
.cl-check { width: 18px; height: 18px; border-radius: 5px; border: 2px solid var(--border); background: var(--surface); flex-shrink: 0; margin-top: 2px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .15s, border-color .15s; padding: 0; }
.cl-check svg { display: none; }
.cl-row.cl-done .cl-check { background: var(--accent); border-color: var(--accent); }
.cl-row.cl-done .cl-check svg { display: block; }

.cl-body       { flex: 1; min-width: 0; }
.cl-title      { font-size: 0.9375rem; line-height: 1.4; }
.cl-note-text  { font-size: 0.75rem; color: var(--muted); margin-top: 3px; white-space: pre-wrap; }
.cl-note-input { display: none; width: 100%; font-size: 0.9375rem; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; font-family: var(--font); color: var(--text); resize: none; background: var(--surface); margin-top: 6px; margin-bottom: 0; }
.cl-note-input:focus { border-color: var(--accent); outline: none; }
.cl-note-input.cl-note-visible { display: block; }

.cl-note-btn { background: var(--surface2); border: 1px solid var(--border); cursor: pointer; color: var(--muted); padding: 3px 7px; border-radius: 5px; font-size: 0.8125rem; height: auto; flex-shrink: 0; margin-top: 1px; }
.cl-note-btn:hover { color: var(--text); background: var(--border); }

/* ═══════════════════════════════════════════════════════════════
   15. LOGIN
   ═══════════════════════════════════════════════════════════════ */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 48px 40px;
    width: 360px;
}

.login-logo {
    font-size: 1.375rem;
    color: var(--accent);
    letter-spacing: .04em;
    margin-bottom: 4px;
}

.login-sub {
    color: var(--muted);
    font-size: 0.8125rem;
    margin-bottom: 32px;
}

/* ═══════════════════════════════════════════════════════════════
   16. UTILITIES
   ═══════════════════════════════════════════════════════════════ */
.text-muted    { color: var(--muted) !important; }
.text-success  { color: var(--success) !important; }
.text-danger   { color: var(--danger) !important; }
.clickable-row { cursor: pointer; }

/* Info tooltip — hover/focus icon that reveals a .note explanation */
.pricing-info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-left: 6px;
    color: var(--muted);
    opacity: .6;
    cursor: help;
    position: relative;
    vertical-align: middle;
    transition: opacity .15s;
}
.pricing-info:hover,
.pricing-info:focus-visible { opacity: 1; color: #5a8dee; outline: none; }
.pricing-info::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 8px);
    left: 8px;
    width: 320px;
    max-width: calc(100vw - 48px);
    background: #263c55;
    color: #fff;
    font-size: .95rem;
    font-weight: 400;
    line-height: 1.55;
    text-transform: none;
    letter-spacing: normal;
    padding: 10px 12px;
    border-radius: 6px;
    box-shadow: 0 0.25rem 1rem rgba(147, 158, 170, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity .15s;
    z-index: 20;
    pointer-events: none;
    /* Last-resort safety net — if a viewport is too short for the up/down
       flip (see smartTooltips() in admin.js) to find a side with full
       room, scroll instead of silently clipping. */
    max-height: min(320px, 70vh);
    overflow-y: auto;
}
.pricing-info:hover::after,
.pricing-info:focus-visible::after { opacity: 1; visibility: visible; }

/* The Project tab's items sit in narrow 1/3-width columns, often close to
   the right edge of the viewport — a left-anchored 320px tooltip there
   runs off-screen and (since the card has overflow:visible so the tooltip
   isn't clipped) widens the whole page, creating a horizontal scrollbar.
   Flip it to grow leftward from the icon instead, scoped to this card only
   — the Pricing page's icon sits near the left edge of a wide row, where
   the original left-anchored version is still correct. */
#pj-project-card .pricing-info::after {
    left: auto;
    right: 0;
    width: 260px;
}

/* Dynamic up/down flip — see smartTooltips() in admin.js. A static
   nth-last-child rule used to live here but missed rows hidden by a live
   filter (display:none siblings still count toward :nth-child); this is
   measured live at hover time instead. (A position:fixed JS-pixel-math
   version replaced this briefly, chasing a table-row clipping bug that
   was actually caused by .pricing-table's border-collapse — fixed there
   instead. The fixed-position version broke under 125% Windows display
   scaling, so it's reverted back to this simpler CSS-driven flip.) */
.pricing-info.tt-flip::after {
    top: auto;
    bottom: calc(100% + 8px);
}
