/* DBC Estimate Builder — base styles + responsive system */
/* MudBlazor handles component-level styling via its theme system */

/* ─── Design Tokens (Option F mockup) ─── */
:root {
    --dbc-green: #5C9A42;
    --dbc-green-light: #e8f5e3;
    --dbc-green-dark: #4a8235;
    --dbc-green-bg: #f0f7ec;
    --dbc-green-accent: #8FDB72;
    --dbc-red: #D12430;
    --dbc-dark: #1A1A2E;
    --dbc-gray: #4A4A68;
    --dbc-gray2: #7C7C99;
    --dbc-gray-light: #F4F5F7;
    --dbc-gray-mid: #E2E4E9;
    --dbc-white: #FFFFFF;
    --dbc-glass: rgba(255, 255, 255, 0.92);
    --dbc-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    --dbc-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);

    --radius: 14px;
    --radius-sm: 10px;
    --sidebar-width: 280px;
    --sidebar-compact-width: 0px;
    --topbar-height: 56px;
    --bottomnav-height: 80px;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* ─── MudBlazor Drawer Nav Overrides ─── */
/* Active nav link: green text on dark bg for readability (WCAG AA) */
.mud-drawer .mud-nav-link.active {
    background-color: rgba(91, 154, 66, 0.15) !important;
    color: var(--dbc-green-accent) !important;
}

.mud-drawer .mud-nav-link.active .mud-nav-link-text {
    color: var(--dbc-green-accent) !important;
    font-weight: 600;
}

.mud-drawer .mud-nav-link.active .mud-nav-link-icon {
    color: var(--dbc-green-accent) !important;
}

/* Hover state for drawer nav links */
.mud-drawer .mud-nav-link:hover {
    background-color: rgba(255, 255, 255, 0.06) !important;
}

/* Non-active drawer links: ensure readable contrast */
.mud-drawer .mud-nav-link-text {
    color: rgba(255, 255, 255, 0.85) !important;
}

.mud-drawer .mud-nav-link-icon {
    color: rgba(255, 255, 255, 0.7) !important;
}

/* ─── Global Reset ─── */
html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', 'Roboto', Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

* {
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}

body {
    overscroll-behavior: none;
}

/* Blazor error UI */
.blazor-error-boundary {
    background: var(--dbc-red);
    padding: 1rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred. Please reload the page."
}

/* ═══════════════════════════════════════════════════
   ESTIMATE DETAIL PAGE — Responsive Layout
   ═══════════════════════════════════════════════════ */

/* Make MudMainContent fill the remaining viewport below the app bar.
   MudBlazor auto-sets padding-top for the app bar; we convert that to
   a full-height flex column so child pages can use flex:1 to fill it. */
.main-content-fill {
    display: flex;
    flex-direction: column;
    height: 100vh;
    box-sizing: border-box;
}

/* ─── Root Container ─── */
/* Fills the remaining height inside MudMainContent. The MudDrawer pushes
   this naturally — no position:fixed, so drawer state is respected. */
.estimate-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ─── Sidebar ─── */
.estimate-sidebar {
    width: var(--sidebar-width);
    background: var(--dbc-dark);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    height: 100%;
    z-index: 30;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.estimate-sidebar .sidebar-info {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.estimate-sidebar .sidebar-logo {
    font-size: 15px;
    font-weight: 800;
    color: white;
    letter-spacing: -0.3px;
    margin-bottom: 12px;
}

.estimate-sidebar .sidebar-estimate-card {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 12px;
}

.estimate-sidebar .sidebar-estimate-title {
    font-size: 14px;
    font-weight: 600;
    color: white;
}

.estimate-sidebar .sidebar-estimate-meta {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
}

.estimate-sidebar .sidebar-total-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.estimate-sidebar .sidebar-total-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: rgba(255, 255, 255, 0.6);
}

.estimate-sidebar .sidebar-total-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--dbc-green-accent);
    letter-spacing: -0.5px;
}

.estimate-sidebar .sidebar-section-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.4);
    padding: 20px 20px 8px;
}

.estimate-sidebar .sidebar-steps {
    flex: 1;
    padding: 0 8px;
    overflow-y: auto;
}

.sidebar-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    margin-bottom: 2px;
    min-height: 52px;
    transition: background 0.15s ease;
}

.sidebar-step:hover {
    background: rgba(255, 255, 255, 0.04);
}

.sidebar-step.active {
    background: rgba(91, 154, 66, 0.15);
}

.sidebar-step-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-step-icon.done {
    background: var(--dbc-green);
    color: white;
}

.sidebar-step-icon.pending {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.65);
}

.sidebar-step-icon.active {
    background: var(--dbc-green);
    color: white;
    box-shadow: 0 0 0 3px rgba(91, 154, 66, 0.3);
}

.sidebar-step-text {
    flex: 1;
    min-width: 0;
}

.sidebar-step-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: rgba(255, 255, 255, 0.7);
}

.sidebar-step.active .sidebar-step-name,
.sidebar-step.completed .sidebar-step-name {
    color: white;
    font-weight: 600;
}

.sidebar-step-detail {
    font-size: 11px;
    margin-top: 1px;
    color: rgba(255, 255, 255, 0.55);
}

.sidebar-step.active .sidebar-step-detail {
    color: rgba(255, 255, 255, 0.75);
}

.sidebar-step-subtotal {
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.65);
}

.sidebar-step.active .sidebar-step-subtotal {
    color: var(--dbc-green-accent);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-save-state {
    font-size: 11px;
    text-align: center;
    margin-bottom: 8px;
}

.sidebar-btn {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    min-height: 48px;
    transition: transform 0.1s, opacity 0.1s;
}
.sidebar-btn:active {
    transform: scale(0.96);
    opacity: 0.85;
}

.sidebar-btn-primary {
    background: var(--dbc-green);
    color: white;
    margin-bottom: 6px;
}
.sidebar-btn-primary:active {
    background: #4a8636;
}

.sidebar-btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.8);
}
.sidebar-btn-secondary:active {
    background: rgba(255, 255, 255, 0.15);
}

/* Global button press feedback (iPad tap) */
.mud-button-root:active,
button:active {
    transform: scale(0.97);
    transition: transform 0.08s;
}

/* Save state animation */
.sidebar-save-state {
    transition: color 0.3s;
}
.sidebar-save-pulse {
    animation: save-pulse 1.5s ease;
}
@keyframes save-pulse {
    0% { color: rgba(255,255,255,0.6); }
    30% { color: #81C784; transform: scale(1.05); }
    100% { color: var(--dbc-green-light); transform: scale(1); }
}

/* Sidebar overlay backdrop (tablet/phone) */
.sidebar-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 29;
}

/* Overlay only activates on tablet/phone where sidebar is a slide-out drawer */
@media (max-width: 1023px) {
    .sidebar-overlay.open {
        display: block;
    }
}

/* Sidebar toggle button (visible on tablet/phone) */
.sidebar-toggle {
    display: none;
    width: 44px;
    height: 44px;
    border: none;
    background: var(--dbc-dark);
    color: white;
    border-radius: 0 8px 8px 0;
    font-size: 18px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 28;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
}

/* ─── Main Content ─── */
.estimate-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.estimate-topbar {
    background: var(--dbc-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.12);
    padding: 0 28px;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    z-index: 10;
}

/* iOS-style back button */
.back-btn {
    display: flex;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--dbc-green);
    font-size: 15px;
    font-weight: 500;
    padding: 8px 4px;
    min-height: 44px;
    border-radius: 8px;
    transition: background 0.15s;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.back-btn:hover {
    background: var(--dbc-green-light);
}

.back-btn:active {
    background: rgba(91, 154, 66, 0.15);
}

@media (max-width: 767px) {
    /* Phone: hide "Estimates" text, just show chevron */
    .back-btn span:last-child {
        display: none;
    }
}

.estimate-topbar-step {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--dbc-gray2);
}

.estimate-topbar-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--dbc-dark);
    letter-spacing: -0.3px;
    margin: 0;
}

.estimate-topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.estimate-progress {
    height: 2px;
    background: var(--dbc-gray-mid);
    flex-shrink: 0;
}

.estimate-progress-bar {
    height: 100%;
    background: var(--dbc-green);
    border-radius: 1px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.estimate-cost-banner {
    background: #FFF3E0;
    padding: 6px 28px;
    font-size: 12px;
    color: #E65100;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.estimate-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px 28px 220px;
    -webkit-overflow-scrolling: touch;
}

/* ─── Bottom Nav ─── */
.estimate-bottomnav {
    position: absolute;
    bottom: 0;
    left: var(--sidebar-width);
    right: 0;
    background: var(--dbc-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 0.5px solid rgba(0, 0, 0, 0.12);
    padding: 14px 28px calc(14px + var(--safe-area-bottom));
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 50;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bottomnav-stats {
    display: flex;
    gap: 24px;
    flex-shrink: 0;
}

.bottomnav-stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--dbc-gray2);
}

.bottomnav-stat-value {
    font-size: 15px;
    font-weight: 700;
    margin-top: 2px;
}

.bottomnav-nav {
    display: flex;
    gap: 10px;
    align-items: center;
    min-width: 0;
}

.bottomnav-progress {
    font-size: 13px;
    color: var(--dbc-gray2);
    font-weight: 500;
    flex-shrink: 0;
}

.bottomnav-btn {
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    min-height: 48px;
    min-width: 48px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.bottomnav-btn-prev {
    background: var(--dbc-gray-light);
    color: var(--dbc-gray);
}

.bottomnav-btn-next {
    background: var(--dbc-green);
    color: white;
    max-width: 220px;
    padding: 12px 24px;
}

.bottomnav-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.bottomnav-btn-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── Line Item Table ─── */
.line-item-row:hover {
    background: var(--dbc-green-bg);
}

.line-item-row:active {
    background: rgba(91, 154, 66, 0.08);
}

.line-item-toggle {
    width: 44px;
    height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}

.line-item-toggle-dot {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    transition: background 0.15s ease;
}

.line-item-toggle-dot.included {
    background: var(--dbc-green);
    border: none;
}

.line-item-toggle-dot.excluded {
    background: transparent;
    border: 2px solid #C4C6CF;
}

/* Flex row layout — description + notes wrap when narrow */
.line-item-header-row {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.line-item-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
    transition: background 0.15s;
}

.line-item-text-wrap {
    display: flex;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}

.line-item-desc-col {
    flex: 1 1 280px;
    min-width: 280px;
    padding: 14px 16px;
}

.line-item-notes-col {
    flex: 1 1 200px;
    min-width: 200px;
    padding: 14px 16px;
}

.line-item-qty-col {
    flex-shrink: 0;
    padding: 14px 16px;
    text-align: right;
    white-space: nowrap;
}

/* Note indicator dot (per mockup: green = has note, empty = no note) */
/* Include/exclude dot — tap to toggle quantity between 0 and 1 */
/* 44px touch target (Apple HIG minimum) with visible 18px dot centered inside */
.qty-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    flex-shrink: 0;
    cursor: pointer;
    padding: 0;
    border: none;
    background: none;
    -webkit-tap-highlight-color: transparent;
}

.qty-dot::after {
    content: '';
    display: block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    transition: background 0.15s, border-color 0.15s;
}

.qty-dot.included::after {
    background: var(--dbc-green);
}

.qty-dot.excluded::after {
    background: transparent;
    border: 2px solid #C4C6CF;
}

/* Note input (per mockup: focus ring) */
.line-item-note-input {
    width: 100%;
    padding: 10px 14px;
    border: 0.5px solid var(--dbc-gray-mid);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    min-height: 52px;
    max-height: 120px;
    color: var(--dbc-gray);
    background: var(--dbc-gray-light);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    resize: vertical;
    overflow-y: auto;
}

.line-item-note-input:focus {
    outline: none;
    border-color: var(--dbc-green);
    box-shadow: 0 0 0 3px rgba(91, 154, 66, 0.1);
    background: var(--dbc-white);
}

/* Topbar action buttons (per mockup: green text on light bg) */
.topbar-action-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    background: var(--dbc-gray-light);
    color: var(--dbc-green);
    cursor: pointer;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s;
}

.topbar-action-btn:hover {
    background: var(--dbc-green-light);
}

.topbar-action-btn:active {
    background: rgba(91, 154, 66, 0.15);
}

.topbar-action-btn.active {
    background: var(--dbc-dark);
    color: white;
}

/* ─── Customer Info Grid ─── */
.customer-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE: iPad Portrait (768px – 1023px)
   ═══════════════════════════════════════════════════ */
@media (max-width: 1023px) {
    :root {
        --sidebar-width: 0px;
    }

    /* Sidebar becomes an overlay drawer */
    .estimate-sidebar {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        transform: translateX(-100%);
        z-index: 30;
    }

    .estimate-sidebar.open {
        transform: translateX(0);
    }

    /* Show toggle button */
    .sidebar-toggle {
        display: flex;
    }

    .sidebar-toggle.open {
        left: 280px;
    }

    /* Bottom nav spans full width */
    .estimate-bottomnav {
        left: 0;
    }

    /* Topbar padding slightly reduced */
    .estimate-topbar {
        padding: 0 20px;
    }

    /* Scrollable content padding reduced */
    .estimate-scroll {
        padding: 20px 20px 200px;
    }

    /* Cost banner padding */
    .estimate-cost-banner {
        padding: 6px 20px;
    }

    /* Notes wrap below description naturally via flex-wrap */

    /* Customer info stacks on portrait */
    .customer-info-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    /* Bottom nav stats reduce gap */
    .bottomnav-stats {
        gap: 16px;
    }
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE: Phone (< 768px)
   ═══════════════════════════════════════════════════ */
@media (max-width: 767px) {
    /* Sidebar stays as overlay (inherited from tablet) */
    .estimate-sidebar {
        width: 280px;
    }

    /* Hide section stat in bottom nav, keep only running total */
    .bottomnav-stat-section {
        display: none;
    }

    .bottomnav-stats {
        gap: 12px;
    }

    /* Hide previous button — only show Next */
    .bottomnav-btn-prev {
        display: none;
    }

    /* Bottom nav progress text hidden */
    .bottomnav-progress {
        display: none;
    }

    /* Reduce padding */
    .estimate-topbar {
        padding: 0 16px;
    }

    .estimate-scroll {
        padding: 16px 16px 180px;
    }

    .estimate-cost-banner {
        padding: 6px 16px;
    }

    /* Stack customer info to single column */
    .customer-info-grid {
        grid-template-columns: 1fr;
    }

    /* Line items: card layout instead of table */
    .line-item-table-view {
        display: none !important;
    }

    .line-item-card-view {
        display: block !important;
    }

    /* Bottom nav shrinks */
    .estimate-bottomnav {
        padding: 10px 16px calc(10px + var(--safe-area-bottom));
    }

    .bottomnav-btn {
        padding: 10px 16px;
        font-size: 14px;
    }
}

/* Hide card view by default (shown only on phone) */
.line-item-card-view {
    display: none;
}

/* ─── Line Item Card (phone layout) ─── */
.line-item-card {
    padding: 16px;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
}

.line-item-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.line-item-card-desc {
    font-weight: 500;
    color: var(--dbc-dark);
    font-size: 14px;
    flex: 1;
    min-width: 0;
}

.line-item-card-explanation {
    font-size: 12px;
    color: var(--dbc-gray2);
    margin-top: 2px;
}

.line-item-card-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.line-item-card-price {
    text-align: right;
}

.line-item-card-unit {
    font-size: 12px;
    color: var(--dbc-gray2);
}

.line-item-card-total {
    font-size: 16px;
    font-weight: 600;
    color: var(--dbc-dark);
}

.line-item-card-note {
    width: 100%;
    margin-top: 8px;
    padding: 8px 10px;
    border: 0.5px solid var(--dbc-gray-mid);
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    color: var(--dbc-gray);
    background: var(--dbc-gray-light);
}
.line-item-card-note:focus {
    outline: none;
    border-color: var(--dbc-green);
    background: var(--dbc-white);
}
.line-item-card-note-readonly {
    margin-top: 6px;
    font-size: 12px;
    color: var(--dbc-gray2);
    font-style: italic;
}

/* ─── Home / Dashboard ─── */
.dashboard-container {
    padding: 16px 28px 28px;
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.dashboard-search {
    max-width: 480px;
    width: 100%;
}

.dashboard-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

@media (max-width: 767px) {
    .dashboard-container {
        padding: 8px 16px 16px;
    }

    .dashboard-header {
        margin-bottom: 16px;
    }

    .dashboard-search {
        max-width: 100%;
    }

    /* Hide less important columns on phone */
    .datagrid-col-hide-phone {
        display: none;
    }
}

/* ─── Utility: flex row helpers ─── */
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-wrap-gap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ─── Review & Totals ─── */
.review-section-header {
    padding: 14px 16px;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
}

.review-table-header {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--dbc-gray2);
    padding: 10px 16px;
}

.review-cat-row {
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
    cursor: pointer;
}

.review-cat-row:hover {
    background: var(--dbc-gray-light);
}

.review-cat-name {
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--dbc-dark);
}

.review-cat-count {
    padding: 12px 8px;
    text-align: center;
    font-size: 13px;
    color: var(--dbc-gray2);
}

.review-cat-subtotal {
    padding: 12px 16px;
    text-align: right;
    font-size: 14px;
    font-weight: 600;
    color: var(--dbc-dark);
}

.review-summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.review-summary-row-border {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    padding-top: 6px;
    border-top: 0.5px solid var(--dbc-gray-mid);
}

.review-total-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-top: 0.5px solid var(--dbc-gray-mid);
    margin-top: 8px;
}

.review-commission-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.review-commission-input {
    width: 64px;
    padding: 4px 8px;
    border: 0.5px solid var(--dbc-gray-mid);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    font-family: inherit;
    min-height: 44px;
}

.review-status-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.review-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.review-delete-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
}

/* ─── Quantity Stepper ─── */
.qty-stepper {
    display: inline-flex;
    align-items: center;
    border-radius: 8px;
    overflow: hidden;
    border: 0.5px solid var(--dbc-gray-mid);
    background: var(--dbc-gray-light);
    user-select: none;
}

.qty-stepper-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 600;
    color: var(--dbc-green);
    background: none;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.qty-stepper-divider {
    width: 0.5px;
    height: 20px;
    background: var(--dbc-gray-mid);
    flex-shrink: 0;
}

.qty-stepper-value {
    min-width: 72px;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    color: var(--dbc-dark);
    background: var(--dbc-white);
    border-left: 0.5px solid var(--dbc-gray-mid);
    border-right: 0.5px solid var(--dbc-gray-mid);
    padding: 10px 6px;
    min-height: 44px;
}

.qty-stepper-input {
    width: 72px;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    color: var(--dbc-dark);
    background: var(--dbc-white);
    border: none;
    border-left: 0.5px solid var(--dbc-gray-mid);
    border-right: 0.5px solid var(--dbc-gray-mid);
    padding: 10px 6px;
    min-height: 44px;
    outline: none;
}

/* Hide browser default number spinners — we have - / + buttons */
.qty-stepper-input::-webkit-inner-spin-button,
.qty-stepper-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.qty-stepper-input[type=number] {
    -moz-appearance: textfield;
}

.qty-stepper-display {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: text;
}

/* ─── Address autocomplete input ─── */
.address-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--dbc-gray-mid);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    min-height: 48px;
    color: var(--dbc-dark);
    background: var(--dbc-white);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.address-input:focus {
    outline: none;
    border-color: var(--dbc-green);
    box-shadow: 0 0 0 3px rgba(91, 154, 66, 0.1);
}

.address-input:disabled {
    background: var(--dbc-gray-light);
    color: var(--dbc-gray2);
}

/* Google Maps autocomplete dropdown styling */
.pac-container {
    border-radius: 8px;
    box-shadow: var(--dbc-shadow-md);
    border: 1px solid var(--dbc-gray-mid);
    font-family: inherit;
    z-index: 10000;
}

.pac-item {
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
}

.pac-item:hover {
    background: var(--dbc-green-bg);
}

.pac-item-query {
    font-weight: 500;
    color: var(--dbc-dark);
}

/* ─── Admin inline editing ─── */
.admin-cell-input {
    width: 100%;
    min-width: 80px;
    padding: 6px 8px;
    border: 0.5px solid var(--dbc-gray-mid);
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    min-height: 36px;
    color: var(--dbc-dark);
    background: var(--dbc-white);
    transition: border-color 0.15s;
}

.admin-cell-input:focus {
    outline: none;
    border-color: var(--dbc-green);
    box-shadow: 0 0 0 2px rgba(91, 154, 66, 0.1);
}

/* ─── Audit log header styling ─── */
.audit-header th { font-weight: 700 !important; font-size: 13px !important; text-transform: uppercase; letter-spacing: 0.5px; color: var(--dbc-dark) !important; }

/* ─── Admin line item editor sidebar layout ─── */
.li-editor-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 0;
    min-height: 500px;
    border: 1px solid var(--dbc-gray-mid);
    border-radius: 10px;
    overflow: hidden;
    background: var(--dbc-white);
    margin-bottom: 24px;
}
.li-sidebar {
    background: #f8f9fa;
    border-right: 1px solid var(--dbc-gray-mid);
    overflow-y: auto;
    max-height: 80vh;
    padding: 8px 0;
}
.li-sidebar-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--dbc-dark);
    text-align: left;
    transition: background 0.1s;
    border-left: 3px solid transparent;
}
.li-sidebar-item:hover { background: rgba(91, 154, 66, 0.06); }
.li-sidebar-item.active {
    background: rgba(91, 154, 66, 0.1);
    border-left-color: var(--dbc-green);
    font-weight: 700;
    color: var(--dbc-green);
}
.li-sidebar-name { flex: 1; min-width: 0; }
.li-sidebar-count {
    flex-shrink: 0;
    background: var(--dbc-gray-mid);
    color: var(--dbc-gray2);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
}
.li-sidebar-add {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border-top: 1px dashed var(--dbc-gray-mid);
    margin-top: 4px;
}
.li-sidebar-item.active .li-sidebar-count {
    background: var(--dbc-green);
    color: white;
}
.li-main {
    overflow-y: auto;
    max-height: 80vh;
    padding: 16px 20px;
}
.li-card-index {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    color: var(--dbc-gray2);
    background: var(--dbc-gray-light);
    padding: 3px 10px;
    border-radius: 10px;
    white-space: nowrap;
}
.li-main-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--dbc-gray-mid);
}

/* On narrow screens, stack sidebar above content */
@media (max-width: 768px) {
    .li-editor-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    .li-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--dbc-gray-mid);
        max-height: 200px;
        display: flex;
        flex-wrap: wrap;
        padding: 8px;
        gap: 4px;
    }
    .li-sidebar-item {
        width: auto;
        padding: 6px 12px;
        border-left: none;
        border-radius: 6px;
        font-size: 12px;
    }
    .li-sidebar-item.active { border-left: none; }
}

/* ─── Admin line item card layout (premium) ─── */
:root { --font-mono: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', 'Liberation Mono', monospace; }

.li-card {
    border: 1px solid var(--dbc-gray-mid);
    border-radius: 10px;
    margin-bottom: 12px;
    background: var(--dbc-white);
    overflow: hidden;
    transition: box-shadow 0.15s;
}
.li-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.06); }

/* Section 1: Description + Delete */
.li-card-top {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 16px 20px 12px;
}
.li-card-left {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding-right: 4px;
}
.li-card-top-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Section 2: K/B Pricing Grid */
.li-pricing-section {
    padding: 0 20px 12px;
    border-top: 1px solid var(--dbc-gray-mid);
    background: #fafbfc;
}
.li-pricing-grid {
    display: grid;
    grid-template-columns: 50px repeat(5, 1fr);
    gap: 4px 10px;
    align-items: center;
    padding-top: 10px;
}
.li-pricing-header {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--dbc-gray2);
    text-align: right;
    padding-bottom: 2px;
}
.li-pricing-header:first-child { text-align: left; }
.li-kb-label { display: flex; align-items: center; justify-content: center; min-height: 40px; }
.li-kb-tag { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 6px; font-size: 12px; font-weight: 700; color: white; }
.li-kb-k { background: var(--mud-palette-primary); }
.li-kb-b { background: var(--mud-palette-secondary); }
.li-textarea { resize: vertical; overflow-y: auto; min-height: 36px; max-height: 120px; font-family: inherit; line-height: 1.4; }
.li-textarea-sm { font-size: 13px; color: var(--dbc-gray2); min-height: 30px; }
.li-pricing-input {
    width: 100%;
    padding: 7px 8px;
    border: 1px solid var(--dbc-gray-mid);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    text-align: right;
    color: var(--dbc-dark);
    background: var(--dbc-white);
    min-height: 36px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.li-pricing-input:focus {
    outline: none;
    border-color: var(--dbc-green);
    box-shadow: 0 0 0 3px rgba(91, 154, 66, 0.12);
}
.li-pricing-computed {
    font-size: 13px;
    font-family: inherit;
    color: var(--dbc-gray2);
    text-align: right;
    padding: 7px 4px;
    white-space: nowrap;
}
.li-pricing-markup {
    font-size: 18px;
    font-weight: 800;
    color: var(--dbc-green);
    text-align: right;
    padding: 4px 0;
    white-space: nowrap;
    letter-spacing: -0.3px;
}

/* Flat Fee mode */
.li-flat-fee-section {
    padding: 12px 0;
}

/* Section 3: Footer (Qty + Flat Fee) */
.li-card-bottom {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 20px 14px;
    border-top: 1px solid var(--dbc-gray-mid);
}
.li-field-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--dbc-gray2);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* iPad portrait: tighten spacing */
@media (max-width: 820px) {
    .li-pricing-grid { gap: 4px 6px; }
    .li-pricing-markup { font-size: 16px; }
    .li-card-top { padding: 12px 14px 10px; }
    .li-pricing-section { padding: 0 14px 10px; }
    .li-card-bottom { padding: 8px 14px 12px; }
}

/* ─── Step intro text ─── */
.step-intro {
    font-size: 14px;
    color: var(--dbc-gray2);
    margin-top: 4px;
    margin-bottom: 0;
}

/* ─── Customer info header ─── */
.customer-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 16px;
}

@media (max-width: 767px) {
    .customer-header {
        flex-direction: column;
        gap: 12px;
    }

    .review-commission-input {
        min-height: 44px;
    }

    .review-actions-row {
        gap: 6px;
    }
}

/* ─── Admin numeric inputs right-aligned ─── */
.admin-numeric-right .mud-input-root input {
    text-align: right;
}

/* ─── Admin Layout (left sidebar + content) ─── */
.admin-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 0;
    min-height: calc(100vh - 64px);
}

.admin-sidebar {
    background: #f8f9fa;
    border-right: 0.5px solid rgba(0, 0, 0, 0.08);
    padding: 16px 0;
    position: sticky;
    top: 64px;
    height: calc(100vh - 64px);
    overflow-y: auto;
}

.admin-sidebar-header {
    padding: 0 20px 12px;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
    margin-bottom: 8px;
}

.admin-sidebar-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 8px;
}

.admin-sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    color: var(--dbc-dark);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    min-height: 40px;
    transition: background 0.15s;
}

.admin-sidebar-link:hover {
    background: rgba(91, 154, 66, 0.06);
    color: var(--dbc-dark);
    text-decoration: none;
}

.admin-sidebar-link.active {
    background: var(--dbc-green);
    color: white;
}

.admin-sidebar-link.active .mud-icon-root {
    color: white;
}

.admin-content {
    padding: 0;
    min-width: 0;
}

/* Stack on narrow screens */
@media (max-width: 768px) {
    .admin-layout {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        position: static;
        height: auto;
        border-right: none;
        border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
    }

    .admin-sidebar-items {
        flex-direction: row;
        overflow-x: auto;
        padding: 0 12px 8px;
    }

    .admin-sidebar-link {
        flex-shrink: 0;
    }
}

/* ─── Document Designer ─── */
.designer-container {
    display: flex;
    flex-direction: column;
    flex: 1;       /* Fill remaining height inside MudMainContent, not full viewport */
    min-height: 0; /* Allow flex children to shrink and scroll */
    overflow: hidden;
}

.designer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: white;
    flex-shrink: 0;
}

.designer-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.designer-palette {
    width: 180px;
    padding: 16px 12px;
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    overflow-y: auto;
    flex-shrink: 0;
}

.designer-canvas-area {
    flex: 1;
    overflow: auto;
    padding: 24px;
    background: #E8E8E8;
    display: flex;
    justify-content: center;
}

.designer-canvas-wrapper {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    background: white;
}

.designer-properties {
    width: 220px;
    padding: 16px 12px;
    border-left: 1px solid rgba(0, 0, 0, 0.08);
    overflow-y: auto;
    flex-shrink: 0;
}

.designer-field {
    position: absolute;
    border: 2px dashed;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: box-shadow 0.15s;
    min-height: 20px;
}

.designer-field:hover {
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.designer-field.selected {
    border-style: solid;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.3);
}

.designer-field-label {
    font-size: 10px;
    font-weight: 600;
    pointer-events: none;
    white-space: nowrap;
}

.designer-field-delete {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #c62828;
    color: white;
    border: none;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* --- Public Signing Page --- */
.sign-container {
    max-width: 900px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.sign-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 2px solid var(--dbc-green);
}

.sign-pdf-area {
    padding: 24px;
    background: #E8E8E8;
    text-align: center;
    flex: 1;
    overflow: auto;
}

.sign-capture-section {
    padding: 24px;
    background: white;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.sign-pad-wrapper {
    position: relative;
    max-width: 600px;
    border-radius: 8px;
    overflow: hidden;
}
