/* ============================================================
   BidManager components. Tokens only — no hex literals here.
   All classes are app-prefixed to avoid Bootstrap collisions
   while both are loaded (Bootstrap is removed in Wave 4).
   ============================================================ */

/* --- Shell --- */
/* NOTE: on base.html pages Bootstrap's reboot (loaded after app.css) overrides this body rule until Wave 4 removes Bootstrap — that is expected; do not add !important. Fullscreen pages get these styles today. */
body {
    font-family: var(--font-sans);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: var(--surface-sunken);
    color: var(--text-primary);
}

.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    vertical-align: middle;
    margin-right: var(--space-1);
}

.main-content {
    min-height: calc(100vh - 100px);
    background-color: var(--surface);
}

.footer {
    background-color: var(--surface-inverse);
    color: var(--on-inverse);
    text-align: center;
    padding: var(--space-4);
    width: 100%;
}

/* Navbar polish (legacy Bootstrap shell; the navbar's own dropdowns/badge were
   converted to app-* in Wave 4e-1, so these target the app-* names — NOT the
   Bootstrap ones, which would be dead selectors. Revisit at Wave 4e teardown. */
.navbar { box-shadow: var(--shadow-2); }
.navbar .nav-link {
    color: rgba(255, 255, 255, 0.85) !important;
    padding: var(--space-2) var(--space-3);
    font-size: 0.9rem;
    transition: color 0.2s ease;
}
.navbar .nav-link:hover,
.navbar .nav-link:focus { color: var(--on-accent) !important; }
.navbar .app-dropdown-menu {
    border: none;
    box-shadow: var(--shadow-2);
    border-radius: var(--radius-md);
    margin-top: var(--space-1);
}
.navbar .app-dropdown-item {
    padding: var(--space-2) var(--space-4);
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
    margin: 0 var(--space-1);
}
.navbar .app-dropdown-item:hover { background-color: var(--accent-soft); }
.navbar .app-badge { font-size: 0.65rem; vertical-align: top; }

/* --- app-navbar (Wave 4e-final): value-preserving replacement for base.html's
   Bootstrap `navbar navbar-expand-lg navbar-dark bg-dark` global chrome. This
   PR is PURE-ADDITIVE — base.html still uses the Bootstrap names until PR2/PR4
   converts the markup (task-6 report holds the old->new class map + the Alpine
   state-class contract: `.app-navbar__collapse--open`).
   The bar is an INVERSE (dark) surface, mapped to --surface-inverse exactly like
   the `.bg-dark` utility (utilities.css) and `.footer`. NOTE: --surface-inverse
   flips per theme (dark bar in light theme, lighter bar in dark theme), matching
   the established bg-dark convention; no new always-dark token is added in this
   additive PR. Responsive expand mirrors navbar-expand-lg at the 992px (lg)
   breakpoint used across utilities.css. --- */
.app-navbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-4);
    background-color: var(--surface-inverse);
    color: var(--on-inverse);
    box-shadow: var(--shadow-2);
}
.app-navbar__brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--on-inverse);
    text-decoration: none;
    white-space: nowrap;
}
/* Hamburger toggler — visible only below the lg breakpoint. PR2 should place a
   Material Symbols `menu` glyph inside it (house icon style):
   <span class="material-symbols-outlined app-navbar__toggler-icon">menu</span> */
.app-navbar__toggler {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    padding: var(--space-1) var(--space-2);
    background: transparent;
    /* Derive overlays from --on-inverse (not literal white): --surface-inverse
       flips to a light bar in dark theme, where a white border would wash out.
       --on-inverse always contrasts the bar, so the overlay reads in both. */
    border: 1px solid color-mix(in srgb, var(--on-inverse) 35%, transparent);
    border-radius: var(--radius-sm);
    color: var(--on-inverse);
    line-height: 1;
    cursor: pointer;
}
.app-navbar__toggler:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.app-navbar__toggler-icon {
    display: inline-block;
    font-size: 1.5rem;
    line-height: 1;
}
/* Collapsible region holding the nav lists. Below lg it is HIDDEN until the
   open-state class `.app-navbar__collapse--open` is present (PR2 wires this via
   Alpine: :class="{ 'app-navbar__collapse--open': navOpen }"). */
.app-navbar__collapse {
    display: none;
    flex-basis: 100%;
    flex-grow: 1;
    align-items: center;
}
.app-navbar__collapse--open {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}
.app-navbar__nav {
    display: flex;
    flex-direction: column;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: var(--space-1);
}
.app-navbar__link {
    display: inline-flex;
    align-items: center;
    padding: var(--space-2) var(--space-3);
    color: var(--on-inverse);
    font-size: 0.9rem;
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: background-color 0.2s ease, color 0.2s ease;
}
.app-navbar__link:hover,
.app-navbar__link:focus {
    /* --on-inverse-derived so the hover reads on both the dark bar (light
       theme) and the light bar (dark theme) — see toggler note above. */
    background-color: color-mix(in srgb, var(--on-inverse) 12%, transparent);
    color: var(--on-inverse);
}
.app-navbar__link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}
/* Expand at lg (992px) — mirror navbar-expand-lg: the toggler hides, the
   collapse is ALWAYS a horizontal row (regardless of the open class), and the
   nav lists lay out inline. `me-auto` on the left <ul> (a utility) still splits
   left/right groups because the collapse is a flex row here. */
@media (min-width: 992px) {
    .app-navbar__toggler { display: none; }
    .app-navbar__collapse,
    .app-navbar__collapse--open {
        display: flex;
        flex-direction: row;
        flex-basis: auto;
        flex-grow: 1;
        align-items: center;
        gap: var(--space-4);
    }
    .app-navbar__nav {
        flex-direction: row;
        align-items: center;
    }
}

/* Wave 4d5: position dropdown menus without Bootstrap's Popper.
   Bootstrap gates `top:100%; left:0` behind `.dropdown-menu[data-bs-popper]`,
   an attribute only bootstrap.bundle's JS sets. With the bundle removed,
   Alpine toggles `.show` but the menu would render unpositioned -- restore
   the default placement here so converted dropdowns need no Popper. Relies
   on Bootstrap's base `.dropdown-menu{position:absolute}` /
   `.dropdown{position:relative}` (CSS retained until Wave 4e). */
.dropdown-menu.show {
    top: 100%;
    left: 0;
}
.dropdown-menu.dropdown-menu-end.show {
    right: 0;
    left: auto;
}

/* Django messages */
.messages { padding: 0; margin: 0; }
.message {
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-1);
    border: 1px solid var(--border);
    background-color: var(--surface-raised);
    color: var(--text-primary);
}
.message.success { background-color: var(--success-soft); border-color: var(--success); }
.message.error { background-color: var(--danger-soft); border-color: var(--danger); }
.message.info { background-color: var(--info-soft); }

/* Snackbar */
#snackbar {
    visibility: hidden;
    min-width: 250px;
    background-color: var(--text-primary);
    color: var(--surface);
    text-align: center;
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    position: fixed;
    z-index: 9999;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    box-shadow: var(--shadow-3);
}
#snackbar.show { visibility: visible; animation: app-fadein 0.5s, app-fadeout 0.5s 2.5s; }
@keyframes app-fadein { from { bottom: 0; opacity: 0; } to { bottom: 30px; opacity: 1; } }
@keyframes app-fadeout { from { bottom: 30px; opacity: 1; } to { bottom: 0; opacity: 0; } }

/* htmx loading indicator */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }
.htmx-request.htmx-indicator { display: inline-block; }

/* Toasts (fullscreen shell) */
.toast-messages {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.toast {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-3);
    animation: app-slidein 0.3s ease;
    max-width: 350px;
    border: 1px solid var(--border);
    background-color: var(--surface-raised);
    color: var(--text-primary);
}
.toast.success { background-color: var(--success-soft); border-color: var(--success); }
.toast.error { background-color: var(--danger-soft); border-color: var(--danger); }
.toast.info { background-color: var(--info-soft); }
@keyframes app-slidein {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Fullscreen shell */
.app-fullscreen {
    overflow: hidden;
    height: 100vh;
}
.app-fullscreen * { box-sizing: border-box; }
.app-fullscreen .btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}
.app-fullscreen .btn-primary { background: var(--accent); color: var(--on-accent); }
.app-fullscreen .btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }

/* --- Components --- */

.app-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-5) 0 var(--space-4);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-5);
}
.app-page-header h1 {
    font-size: 1.375rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}
.app-page-header .app-page-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: var(--space-1) 0 0;
}

.app-page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
}

.app-card {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-1);
}

/* --- Card sub-regions (app-card has no header/body/footer split by default).
   Promoted from the near-identical per-page card sub-region classes that
   used to live in estimate-packages.css, estimates.css, and
   estimate-structures.css. Cards using these sub-regions should set
   padding: 0 on the outer .app-card. */
.app-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border);
}
.app-card__header h5, .app-card__header h6 { margin: 0; display: flex; align-items: center; gap: var(--space-2); }
.app-card__body { padding: var(--space-5); }
.app-card__body--flush { padding: 0; }
.app-card__body--tight { padding: var(--space-2); }
.app-card__footer {
    padding: var(--space-3) var(--space-5);
    border-top: 1px solid var(--border);
}
.app-card__title { font-size: 1.05rem; font-weight: 600; margin: 0; color: var(--text-primary); }

/* --- Callouts (replace Bootstrap .alert-info/.alert-success/.alert-warning/
   .alert-danger/.alert-secondary). Promoted from the near-identical
   per-page callout classes that used to live in estimate-packages.css,
   estimates.css, and estimate-structures.css. --- */
.app-callout {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}
.app-callout--info { background: var(--accent-soft); border-color: var(--accent); }
.app-callout--success { background: var(--success-soft); border-color: var(--success); }
.app-callout--warning { background: var(--warning-soft); border-color: var(--warning); }
.app-callout--danger { background: var(--danger-soft); border-color: var(--danger); }
.app-callout--light { background: var(--surface-sunken); }
.app-callout__heading { font-weight: 600; margin: 0 0 var(--space-1); color: var(--text-primary); }
/* Fixed-position success toast raised above modals/overlays. Lives here (not a
   page stylesheet) because the shared tasks/_task_create_modal.html renders it
   on non-task pages (project_detail, bid_items list/detail) that load app.css
   but not css/pages/tasks.css. */
.task-success-toast { z-index: 9999; }

/* --- Icon sizing utilities (Material Symbols). Only sizes agreed on by 2+
   pages are promoted here; page-specific sizes (lg/xl/inline) stay put. --- */
.app-icon-sm { font-size: 0.9rem; }
.app-icon-md { font-size: 1rem; }
/* Large decorative icon (e.g. empty-state placeholders). Pair with a color
   utility such as .text-muted. */
.app-icon-xl { font-size: 4rem; }

/* Brand marks (self-hosted SVG; Material Symbols has no brand glyphs).
   Sized to track adjacent text; colored marks carry their own path fills. */
.app-brand-icon {
    width: 1em;
    height: 1em;
    vertical-align: middle;
    margin-right: var(--space-1);
}

.app-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: var(--font-sans);
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.app-btn--primary { background: var(--accent); color: var(--on-accent); }
.app-btn--primary:hover { background: var(--accent-hover); color: var(--on-accent); }
.app-btn--secondary {
    background: var(--surface-raised);
    color: var(--text-primary);
    border-color: var(--border-strong);
}
.app-btn--secondary:hover { background: var(--surface-sunken); }
.app-btn--ghost { background: transparent; color: var(--text-secondary); }
.app-btn--ghost:hover { background: var(--surface-sunken); color: var(--text-primary); }
.app-btn--danger { background: var(--danger); color: var(--on-accent); }
.app-btn--danger:hover { filter: brightness(0.9); }
.app-btn:disabled { opacity: 0.5; cursor: not-allowed; }
/* Compact size modifier -- added for bid-results.html's subcontractors.html
   Expand All/Collapse All toolbar buttons (Wave 3c Task 4), the first
   consumer of a smaller .app-btn anywhere in the codebase. */
.app-btn--sm {
    padding: var(--space-1) var(--space-3);
    font-size: 0.8rem;
    gap: var(--space-1);
}

/* Wave 4e: outline + status + link + lg variants and a button group,
   replacing Bootstrap .btn-outline-*/.btn-success/.btn-warning/.btn-info/
   .btn-link/.btn-lg/.btn-group. */
.app-btn--outline-secondary {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border-strong);
}
.app-btn--outline-secondary:hover { background: var(--surface-sunken); }
.app-btn--outline-primary {
    background: transparent;
    color: var(--accent);
    border-color: var(--accent);
}
.app-btn--outline-primary:hover { background: var(--accent-soft); }
.app-btn--outline-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}
.app-btn--outline-danger:hover { background: var(--danger-soft); }
.app-btn--outline-success {
    background: transparent;
    color: var(--success);
    border-color: var(--success);
}
.app-btn--outline-success:hover { background: var(--success-soft); }
.app-btn--outline-info {
    background: transparent;
    color: var(--accent);
    border-color: var(--accent-soft);
}
.app-btn--outline-info:hover { background: var(--accent-soft); }
.app-btn--success { background: var(--success); color: var(--on-accent); }
.app-btn--success:hover { filter: brightness(0.95); }
.app-btn--warning { background: var(--warning); color: var(--on-accent); }
.app-btn--warning:hover { filter: brightness(0.95); }
.app-btn--info { background: var(--accent-soft); color: var(--accent); }
.app-btn--info:hover { filter: brightness(0.95); }
.app-btn--link {
    background: transparent;
    color: var(--accent);
    border-color: transparent;
    padding-left: var(--space-1);
    padding-right: var(--space-1);
}
.app-btn--link:hover { text-decoration: underline; }
.app-btn--lg {
    padding: var(--space-3) var(--space-5);
    font-size: 1rem;
}
.app-btn-group {
    display: inline-flex;
    gap: var(--space-1);
    flex-wrap: wrap;
}
/* Small button group -- scopes its .app-btn children to .app-btn--sm sizing
   without requiring the modifier on every child (value-preserving of
   Bootstrap .btn-group-sm). */
.app-btn-group--sm .app-btn {
    padding: var(--space-1) var(--space-3);
    font-size: 0.8rem;
    gap: var(--space-1);
}
/* Vertically-stacked button group (value-preserving of Bootstrap
   .btn-group-vertical). */
.app-btn-group--vertical { flex-direction: column; }

/* Light-surface button + light/warning outline variants (value-preserving of
   Bootstrap .btn-light/.btn-outline-light/.btn-outline-warning). */
.app-btn--light {
    background: var(--surface);
    color: var(--text-primary);
    border-color: var(--border);
}
.app-btn--light:hover { background: var(--surface-sunken); }
/* Intended for dark hero sections built on var(--surface-inverse): on-inverse
   is the token pair that always contrasts with it, in both themes. */
.app-btn--outline-light {
    background: transparent;
    color: var(--on-inverse);
    border-color: var(--on-inverse);
}
/* Translucent white wash for the hover state only -- same exemption as the
   modal backdrop above (deliberately theme-independent overlay, not a
   themable surface); no token expresses "light wash over a dark hero". */
.app-btn--outline-light:hover { background: rgba(255, 255, 255, 0.15); }
.app-btn--outline-warning {
    background: transparent;
    color: var(--warning);
    border-color: var(--warning);
}
.app-btn--outline-warning:hover { background: var(--warning-soft); }

.app-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: var(--surface-raised);
}
.app-table th {
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-strong);
}
.app-table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}
.app-table tbody tr:hover { background: var(--surface-sunken); }
.app-table--dense th, .app-table--dense td { padding: var(--space-1) var(--space-2); }
.app-table .app-num { font-family: var(--font-mono); text-align: right; }
.app-table--striped tbody tr:nth-child(odd) { background: var(--surface-sunken); }
.app-table-responsive { width: 100%; overflow-x: auto; }
/* Cell borders on all sides (value-preserving of Bootstrap .table-bordered). */
.app-table--bordered { border: 1px solid var(--border); }
.app-table--bordered th,
.app-table--bordered td { border: 1px solid var(--border); }

.app-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}
.app-input, .app-select, .app-textarea {
    display: block;
    width: 100%;
    padding: var(--space-2) var(--space-3);
    font-size: 0.9rem;
    font-family: var(--font-sans);
    color: var(--text-primary);
    background: var(--surface-raised);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
}
.app-input:focus, .app-select:focus, .app-textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    border-color: var(--accent);
}
/* Compact size modifier -- mirrors .app-btn--sm's sizing (value-preserving
   of Bootstrap .form-control-sm/.form-select-sm). */
.app-input--sm, .app-select--sm {
    padding: var(--space-1) var(--space-3);
    font-size: 0.8rem;
}
.app-help-text { font-size: 0.8rem; color: var(--text-muted); margin-top: var(--space-1); }

.app-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px var(--space-2);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--info-soft);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.app-badge--success { background: var(--success-soft); color: var(--success); }
.app-badge--warning { background: var(--warning-soft); color: var(--warning); }
.app-badge--danger { background: var(--danger-soft); color: var(--danger); }
.app-badge--info { background: var(--accent-soft); color: var(--accent); }
.app-badge--secondary { background: var(--surface-sunken); color: var(--text-secondary); }
.app-badge--primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.app-badge--light { background: var(--surface-sunken); color: var(--text-secondary); }
.app-badge--dark { background: var(--surface-inverse); color: var(--on-inverse); border-color: var(--surface-inverse); }

.app-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-7) var(--space-5);
    color: var(--text-secondary);
}
.app-empty-state .material-symbols-outlined {
    font-size: 40px;
    color: var(--text-muted);
    margin: 0 0 var(--space-3);
}
.app-empty-state h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 var(--space-1);
}
.app-empty-state p { margin: 0 0 var(--space-4); font-size: 0.9rem; }

/* --- Modal (hand-rolled overlays; Bootstrap-JS modals keep .modal until Wave 4) --- */

.app-modal-backdrop {
    position: fixed;
    inset: 0;
    /* Translucent scrim, deliberately theme-independent — not a themable
       surface, so it is exempt from the tokens-only rule. */
    background: rgba(2, 6, 23, 0.55);
    z-index: 1050;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: var(--space-6) var(--space-4);
    overflow-y: auto;
}
.app-modal {
    background: var(--surface-raised);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-3);
    width: 100%;
    max-width: 560px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 2 * var(--space-6));
}
.app-modal--wide { max-width: 900px; }
.app-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border);
}
.app-modal__title {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
}
.app-modal__body {
    padding: var(--space-5);
    overflow-y: auto;
}
.app-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border);
}

/* --- Stat card (dashboard tiles, task stats) --- */

.app-stat-card {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-1);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}
.app-stat-card__number {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}
.app-stat-card__label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.app-stat-card--accent .app-stat-card__number { color: var(--accent); }
.app-stat-card--warning .app-stat-card__number { color: var(--warning); }
.app-stat-card--success .app-stat-card__number { color: var(--success); }
.app-stat-card--danger .app-stat-card__number { color: var(--danger); }

/* --- Breadcrumb (replaces Bootstrap .breadcrumb / .breadcrumb-item). --- */
.app-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    list-style: none;
    padding: 0;
    margin: 0 0 var(--space-4);
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.app-breadcrumb__item { display: inline-flex; align-items: center; gap: var(--space-2); }
.app-breadcrumb__item a { color: var(--accent); text-decoration: none; }
.app-breadcrumb__item a:hover { text-decoration: underline; }
.app-breadcrumb__item[aria-current="page"] { color: var(--text-muted); }
.app-breadcrumb__sep { color: var(--text-muted); }

/* --- Tabs (CSS only; Alpine drives active state — Wave 4d tab convention).
   Replaces Bootstrap .nav-tabs/.nav-link/.nav-item + .tab-content/.tab-pane. --- */
.app-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    list-style: none;
    padding: 0;
    margin: 0 0 var(--space-4);
    border-bottom: 1px solid var(--border);
}
.app-tab {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    text-decoration: none;
}
.app-tab:hover { color: var(--text-primary); }
.app-tab--active { color: var(--accent); border-bottom-color: var(--accent); }
.app-tab-pane { padding: var(--space-4) 0; }

/* Floating theme toggle (injected by theme-manager.js) */
.app-theme-toggle {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--accent);
    color: var(--on-accent);
    border: none;
    box-shadow: var(--shadow-3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 1000;
}
.app-theme-toggle:hover {
    transform: scale(1.08);
    box-shadow: var(--shadow-3);
}

/* Hide Alpine-controlled elements until Alpine initializes (prevents FOUC on
   x-show/x-collapse). Global rule; per-page [x-cloak] duplicates can be
   removed in a follow-up. */
[x-cloak] { display: none !important; }

/* --- List group (replaces Bootstrap .list-group / .list-group-item). --- */
.app-list-group {
    list-style: none;
    padding: 0;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--surface-raised);
}
.app-list-group-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}
.app-list-group-item:last-child { border-bottom: none; }
a.app-list-group-item { text-decoration: none; }
a.app-list-group-item:hover { background: var(--surface-sunken); }
/* Interactive modifier (value-preserving of Bootstrap .list-group-item-action)
   for non-<a> items (e.g. <button>) that still need the hover/focus affordance. */
.app-list-group-item--action { cursor: pointer; }
.app-list-group-item--action:hover,
.app-list-group-item--action:focus { background: var(--surface-sunken); }
/* Selected/active row (value-preserving of Bootstrap .list-group-item.active).
   The estimate-breakdown editor's JS toggles the `active` class on its
   dynamically-generated .app-list-group-item rows via classList; this styles
   that selected state. Placed after the --action:hover rule so it wins the
   equal-specificity tie and the selection stays visible on hover. */
.app-list-group-item.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
}

/* --- Spinner (replaces Bootstrap .spinner-border). --- */
.app-spinner {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: var(--radius-full);
    animation: app-spin 0.7s linear infinite;
    vertical-align: middle;
}
.app-spinner--sm { width: 0.9rem; height: 0.9rem; border-width: 2px; }
@keyframes app-spin { to { transform: rotate(360deg); } }

/* --- Close button (replaces Bootstrap .btn-close). Pair with a
   <span class="material-symbols-outlined">close</span> child. --- */
.app-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-1);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    line-height: 1;
}
.app-close:hover { background: var(--surface-sunken); color: var(--text-primary); }
.app-close .material-symbols-outlined { margin-right: 0; }

/* --- Progress (replaces Bootstrap .progress / .progress-bar). --- */
.app-progress {
    height: var(--space-2);
    background: var(--surface-sunken);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.app-progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--on-accent);
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
}
/* 45deg stripe overlay (value-preserving of Bootstrap .progress-bar-striped).
   Translucent white overlay only -- no token expresses "highlight stripe on
   top of whatever fill color the bar already has" (accent/warning/etc.); same
   exemption as the modal backdrop's scrim above. */
.app-progress-bar--striped {
    background-image: linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.15) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.15) 50%,
        rgba(255, 255, 255, 0.15) 75%,
        transparent 75%,
        transparent
    );
    background-size: 1rem 1rem;
}
.app-progress-bar--animated { animation: app-progress-stripes 1s linear infinite; }
@keyframes app-progress-stripes {
    from { background-position: 1rem 0; }
    to { background-position: 0 0; }
}

/* --- Input group (replaces Bootstrap .input-group). Wrap an addon + control;
   the control keeps .app-input/.app-select. --- */
.app-input-group {
    display: flex;
    align-items: stretch;
    width: 100%;
}
.app-input-group > .app-input,
.app-input-group > .app-select { flex: 1 1 auto; width: 1%; }
.app-input-group > *:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.app-input-group > *:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: -1px; }
.app-input-group__addon {
    display: inline-flex;
    align-items: center;
    padding: var(--space-2) var(--space-3);
    background: var(--surface-sunken);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.9rem;
    white-space: nowrap;
}
/* Small input-group -- scopes the control + addon to .app-input--sm sizing
   (value-preserving of Bootstrap .input-group-sm). */
.app-input-group--sm > .app-input,
.app-input-group--sm > .app-select,
.app-input-group--sm .app-input-group__addon {
    padding: var(--space-1) var(--space-3);
    font-size: 0.8rem;
}

/* --- Check / radio (replaces Bootstrap .form-check / .form-check-input). --- */
.app-check {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.app-check__input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--accent);
    cursor: pointer;
    margin: 0;
}
.app-check__label { font-size: 0.9rem; color: var(--text-primary); cursor: pointer; margin: 0; }
.app-radio .app-check__input { border-radius: var(--radius-full); }
/* Inline modifier (value-preserving of Bootstrap .form-check-inline). */
.app-check--inline {
    display: inline-flex;
    margin-right: var(--space-4);
}
/* Switch modifier -- renders the checkbox as a pill track + knob (value-
   preserving of Bootstrap .form-switch). Custom-drawn via ::before since a
   native checkbox has no track/knob parts to theme. */
.app-check--switch .app-check__input {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    width: 2rem;
    height: 1.15rem;
    background: var(--border-strong);
    border-radius: var(--radius-full);
    transition: background-color 0.15s ease;
}
.app-check--switch .app-check__input::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: calc(1.15rem - 4px);
    height: calc(1.15rem - 4px);
    background: var(--surface);
    border-radius: var(--radius-full);
    transition: transform 0.15s ease;
}
.app-check--switch .app-check__input:checked { background: var(--accent); }
.app-check--switch .app-check__input:checked::before {
    transform: translateX(calc(2rem - 1.15rem));
}

/* --- Dropdown (replaces Bootstrap .dropdown / .dropdown-menu / .dropdown-item).
   Self-positioned: does NOT depend on Bootstrap base rules, which are removed
   in the teardown slice. Alpine toggles .show (Wave 4d convention). --- */
.app-dropdown { position: relative; display: inline-block; }
.app-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    display: none;
    min-width: 10rem;
    margin: var(--space-1) 0 0;
    padding: var(--space-1);
    list-style: none;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-2);
}
.app-dropdown-menu.show { display: block; }
.app-dropdown-menu--end { left: auto; right: 0; }
.app-dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    padding: var(--space-2) var(--space-3);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-primary);
    text-decoration: none;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
}
.app-dropdown-item:hover { background: var(--surface-sunken); }
.app-dropdown-divider { height: 0; margin: var(--space-1) 0; border-top: 1px solid var(--border); }
/* Section header inside a menu (value-preserving of Bootstrap .dropdown-header). */
.app-dropdown-header {
    display: block;
    padding: var(--space-2) var(--space-3);
    margin: 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

/* --- Pagination (replaces Bootstrap .pagination / .page-item / .page-link).
   Wave 4e-final PR1 Task 3: value-preserving of Bootstrap 5.3 pagination
   proportions; theme-aware via tokens. See templates/components/_pagination.html
   for the reusable Django page_obj include that renders this markup. --- */
.app-pagination {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    list-style: none;
    padding: 0;
    margin: 0;
}
.app-page-item { display: flex; }
.app-page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    height: 2.25rem;
    padding: var(--space-1) var(--space-3);
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.app-page-link:hover { background: var(--surface-sunken); color: var(--text-primary); }
.app-page-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
}
.app-page-item--active .app-page-link {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
}
.app-page-item--disabled .app-page-link {
    color: var(--text-muted);
    pointer-events: none;
    opacity: 0.6;
}

/* --- Accordion (replaces Bootstrap .accordion/.accordion-item/
   .accordion-button/.accordion-collapse/.accordion-body). Wave 4e-final PR1
   Task 4: value-preserving of Bootstrap 5.3's accordion; theme-aware via
   tokens. Behavior stays template-driven (Alpine x-show/x-collapse on
   .app-accordion__body) -- this component only styles.

   EXPANDED-STATE SELECTOR (for PR2's markup conversion): the chevron
   rotation below keys off `[aria-expanded="true"]` on .app-accordion__button
   itself. All 3 current accordion usages (extension_docs.html,
   extension_settings.html, _import_breakdowns_modal.html) already bind this
   with Alpine as `:aria-expanded="open"`, so PR2 just needs to keep that
   binding on the button (do not rely solely on a `.collapsed`/`:class`
   toggle -- the real `aria-expanded` attribute is what this CSS reads). --- */
.app-accordion {
    display: flex;
    flex-direction: column;
}
.app-accordion__item {
    background: var(--surface);
    border: 1px solid var(--border);
}
.app-accordion__item + .app-accordion__item {
    border-top: none;
}
.app-accordion__item:first-child {
    border-top-left-radius: var(--radius-md);
    border-top-right-radius: var(--radius-md);
}
.app-accordion__item:first-child .app-accordion__button {
    border-top-left-radius: var(--radius-md);
    border-top-right-radius: var(--radius-md);
}
.app-accordion__item:last-child {
    border-bottom-left-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
}
.app-accordion__item:last-child .app-accordion__body {
    border-bottom-left-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
}
.app-accordion__header {
    margin: 0;
}
.app-accordion__button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--surface);
    color: var(--text-primary);
    border: none;
    margin: 0;
    font: inherit;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.app-accordion__button:hover {
    background: var(--surface-sunken);
}
.app-accordion__button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}
/* Chevron indicator: Material Symbols "expand_more" glyph rendered via the
   font ligature in a ::after (no template markup change required). Rotates
   180deg when the button reports aria-expanded="true". */
.app-accordion__button::after {
    content: "expand_more";
    font-family: "Material Symbols Outlined";
    font-weight: normal;
    font-style: normal;
    font-size: 1.25rem;
    line-height: 1;
    flex-shrink: 0;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
    -webkit-font-feature-settings: 'liga';
    font-feature-settings: 'liga';
}
.app-accordion__button[aria-expanded="true"]::after {
    transform: rotate(180deg);
}
.app-accordion__body {
    padding: var(--space-4);
    background: var(--surface);
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
}

/* --- Toggle button-check (replaces Bootstrap .btn-check + .btn toggle
   pattern used by the estimate editors' radio-style toggle buttons). Wave
   4e-final PR1 Task 5.

   Markup: a visually-hidden native radio/checkbox <input class="app-btn-check">
   immediately followed by its sibling <label class="app-btn app-btn--outline-*">
   -- the label is the visible toggle surface, the input drives state via the
   adjacent-sibling combinator below. Works standalone or inside
   .app-btn-group/.app-btn-group--sm since the label stays a plain .app-btn.

   The input is hidden with the standard sr-only clip-rect pattern (not
   display:none/visibility:hidden), so it remains keyboard-focusable and Tab
   still lands on it -- :focus-visible below reflects that onto the label. */
.app-btn-check {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
/* Checked highlight: filled accent, mirroring Bootstrap's checked .btn-check
   + .btn look. Specificity (0,3,0) beats any single .app-btn--outline-*
   modifier (0,1,0) it's paired with, so this wins regardless of source
   order without needing a per-outline-variant override. */
.app-btn-check:checked + .app-btn {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
}
.app-btn-check:checked + .app-btn:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: var(--on-accent);
}
/* Focus ring on the label, since the real input is visually hidden --
   otherwise keyboard users tabbing through the group get no visible focus
   indicator at all. */
.app-btn-check:focus-visible + .app-btn {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.app-btn-check:disabled + .app-btn {
    opacity: 0.5;
    cursor: not-allowed;
}
