:root {
    /* DESIGN.md Warm Light Palette — the guided estimator's look, applied to the
       whole app. Charcoal ink on warm paper, orange used sparingly as the single
       accent, Plus Jakarta Sans throughout. */
    --bg: #faf9f7;
    --bg-secondary: #ffffff;
    --bg-hover: #f2f0ec;
    --text: #0e0e0e;
    --text-secondary: #6c6a64;
    --text-muted: #9c9990;
    --primary: #c2410c;        /* carries white text — 5.18:1, AA */
    --primary-hover: #9a3412;
    --accent: #ea580c;         /* graphics only: dots, numerals, the brand mark */
    --accent-soft: #fb923c;
    --on-primary: #ffffff;
    --secondary: #f2f0ec;
    --secondary-hover: #e7e5e2;
    --green: #10723a;
    --green-hover: #0b5c2e;
    --blue: #1d4ed8;
    --blue-hover: #1e40af;
    --red: #c2410c;
    --red-hover: #9a3412;
    --purple: #6d28d9;
    --purple-hover: #5b21b6;
    --border: #e7e5e2;
    --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.05);
    --shadow: 0 1px 3px rgba(28, 25, 23, 0.08), 0 1px 2px rgba(28, 25, 23, 0.04);
    --shadow-md: 0 4px 10px -2px rgba(28, 25, 23, 0.10);
    --shadow-lg: 0 10px 24px -6px rgba(28, 25, 23, 0.12);
    --shadow-xl: 0 20px 40px -12px rgba(28, 25, 23, 0.16);
    --border-radius: 10px;
    --border-radius-xs: 6px;
    --border-radius-sm: 10px;
    --border-radius-lg: 14px;
    --transition: all 0.2s ease;
    /* DESIGN.md Status Tokens — light-ground versions, same five stages */
    --status-inspected-bg: #dbeafe;
    --status-inspected-fg: #1d4ed8;
    --status-estimating-bg: #fff1e6;
    --status-estimating-fg: #b45309;
    --status-sent-bg: #fef3c7;
    --status-sent-fg: #92400e;
    --status-approved-bg: #dff5e6;
    --status-approved-fg: #10723a;
    --status-paid-bg: #e0e7ff;
    --status-paid-fg: #4338ca;
    /* DESIGN.md Workflow Tokens */
    --workflow-pending: #a8a29e;
    --workflow-in-progress: #b45309;
    --workflow-awaiting-repair: #1d4ed8;
    --workflow-awaiting-approval: #10723a;
    --workflow-awaiting-payment: #6d28d9;
    --workflow-completed: #4338ca;
}

/* DESIGN.md token aliases — use these names in new code */
:root {
    --background:        var(--bg);
    --surface:           var(--bg-secondary);
    --surface-elevated:  #f7f6f3;
    --on-surface:        var(--text);
    --on-surface-variant: var(--text-secondary);
    --on-surface-muted:  var(--text-muted);
    --positive:          var(--green);
    --positive-hover:    var(--green-hover);
    --negative:          var(--red);
    --negative-hover:    var(--red-hover);
    --info:              var(--blue);
    --info-hover:        var(--blue-hover);
    --special:           var(--purple);
    --special-hover:     var(--purple-hover);
    --rounded-sm:        var(--border-radius-sm);
    --rounded-md:        var(--border-radius-lg);
    --rounded-full:      9999px;
    /* Derived tints — avoids hardcoded rgba() throughout */
    --primary-bg:        rgba(194, 65, 12, 0.08);
    --primary-tint:      rgba(194, 65, 12, 0.14);
    --negative-tint:     rgba(194, 65, 12, 0.10);
    --positive-tint:     rgba(16, 114, 58, 0.10);
    --special-tint:      rgba(109, 40, 217, 0.10);
    --overlay:           rgba(28, 25, 23, 0.35);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    color-scheme: dark;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

.hidden {
    display: none !important;
}

/* Header */
.app-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    box-shadow: var(--shadow-sm);
}

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

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

.brand-logo {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: white;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
}

.brand-tagline {
    font-size: 11px;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-btn {
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 13px;
    transition: 0.25s;
    border-radius: var(--border-radius-sm);
}

.nav-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text);
}

.nav-btn.active {
    background-color: var(--bg-hover);
    border-color: var(--border);
    color: var(--text);
}

.nav-icon {
    font-size: 16px;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-danger {
    cursor: pointer;
    border: none;
    font-weight: 600;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary);
    color: var(--on-primary);
    padding: 10px 20px;
    font-size: 13px;
}

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

.btn-secondary {
    background: var(--secondary);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 14px;
    font-size: 13px;
}

.btn-secondary:hover {
    background: var(--secondary-hover);
    color: var(--text);
}

.btn-danger {
    background: var(--red);
    color: var(--text);
    padding: 10px 16px;
    font-size: 13px;
}

.btn-danger:hover {
    background: var(--red-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Search Bar */
.search-bar {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.search-bar input {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    padding: 8px 12px;
    font-size: 14px;
    border-radius: var(--border-radius-sm);
}

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

.search-bar input:focus {
    background-color: var(--bg-hover);
    border-color: var(--primary);
    outline: none;
}

/* Stats Bar */
.stats-bar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    font-size: 13px;
}

.stat-card {
    display: flex;
    align-items: baseline;
    gap: 4px;
    border-right: 1px solid var(--border);
    padding-right: 24px;
    transition: var(--transition);
}

.stat-card:hover {
    background-color: var(--bg-hover);
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
}

.stat-label {
    color: var(--text-secondary);
}

/* Main Content */
.main-content {
    padding: 20px;
    display: flex;
    height: calc(100vh - 120px);
}

/* Kanban Board */
.kanban-board {
    display: flex;
    gap: 16px;
    height: 100%;
    width: 100%;
    overflow-x: auto;
}

.kanban-column {
    flex: 1;
    min-width: 300px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
}

.kanban-header {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
}

.kanban-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

/* Kanban column dot colors (FIX 5) */
.dot-pending    { background: var(--workflow-pending); }
.dot-progress   { background: var(--workflow-in-progress); }
.dot-repair     { background: var(--workflow-awaiting-repair); }
.dot-approval   { background: var(--workflow-awaiting-approval); }
.dot-completed  { background: var(--workflow-completed); }

/* Ollama status classes (FIX 1) */
.ollama-online  { color: var(--green); }
.ollama-offline { color: var(--red); }

.kanban-column h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.kanban-cards {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    overflow-y: auto;
}

.kanban-card.dragging { opacity: 0.5; cursor: grabbing; }

.kanban-card {
    background: var(--bg-secondary);
    color: var(--text);
    border-radius: var(--border-radius-sm);
    padding: 12px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}

.kanban-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.kanban-card-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    margin-bottom: 4px;
}

.kanban-card-address {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.kanban-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

.kanban-card-amount {
    font-weight: 600;
    color: var(--text);
}

.kanban-card-photo-count {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* List View */
.list-view {
    width: 100%;
    overflow-y: auto;
    height: 100%;
}

.list-table {
    width: 100%;
    border-collapse: collapse;
}

.list-header {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.list-row {
    display: flex;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}

.list-row:hover {
    background-color: var(--bg-hover);
}

.list-cell {
    flex: 1;
    font-size: 13px;
}

.list-cell a {
    color: var(--blue);
    text-decoration: none;
    font-weight: 500;
}

.list-cell a:hover {
    text-decoration: underline;
}

.list-cell .subtext {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 2px;
}

/* Status Badges - DESIGN.md colors */
.status-badge {
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
    align-items: center;
    gap: 4px;
    justify-content: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 5 status states using DESIGN.md palette */
.status-badge.inspected,
.status-inspected {
    background-color: var(--status-inspected-bg);
    color: var(--status-inspected-fg);
}

.status-badge.estimating,
.status-estimating {
    background-color: var(--status-estimating-bg);
    color: var(--status-estimating-fg);
}

.status-badge.sent,
.status-sent {
    background-color: var(--status-sent-bg);
    color: var(--status-sent-fg);
}

.status-badge.approved,
.status-approved {
    background-color: var(--status-approved-bg);
    color: var(--status-approved-fg);
}

.status-badge.paid,
.status-paid {
    background-color: var(--status-paid-bg);
    color: var(--status-paid-fg);
}

.status-select {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.status-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    font-size: 12px;
    font-weight: 500;
    transition: var(--transition);
}

.status-btn:hover {
    background: var(--bg-hover);
}

.status-btn.active {
    background: var(--primary);
    color: var(--on-primary);
    border-color: var(--primary);
}

/* Form Inputs */
.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    transition: var(--transition);
    background: var(--bg);
    color: var(--text);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-tint);
}

.form-row {
    margin-bottom: 12px;
}

.form-row label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* Photo Gallery */
.photo-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.photo-wrapper {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--border-radius);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-hover);
}

.photo-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.photo-wrapper::before {
    content: '📷 Image';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    opacity: 0;
    transition: opacity 0.2s;
}

.photo-wrapper:hover::before {
    opacity: 0.15;
}

.photo-overlay {
    position: absolute;
    inset: 0;
    background: var(--overlay);
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-wrapper:hover .photo-overlay {
    opacity: 1;
}

.photo-remove-btn {
    background: var(--red);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.photo-remove-btn:hover {
    background: var(--red-hover);
}

.photo-number-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: var(--overlay);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 999px;
    pointer-events: none;
    z-index: 1;
}

/* Drop Zone */
.photo-drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--border-radius);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 12px;
}

.photo-drop-zone:hover {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.photo-drop-zone.drag-over {
    border-color: var(--primary);
    background: var(--primary-tint);
}

/* Estimate Builder */
.estimate-header-row {
    display: grid;
    grid-template-columns: 2fr 80px 80px 80px 80px 40px;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.estimate-row {
    display: grid;
    grid-template-columns: 2fr 80px 80px 80px 80px 40px;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    align-items: center;
}

.estimate-item-input,
.estimate-unit-input,
.estimate-qty-input,
.estimate-price-input {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    font-size: 13px;
    background: var(--bg);
    color: var(--text);
    width: 100%;
}

.estimate-item-input:focus,
.estimate-unit-input:focus,
.estimate-qty-input:focus,
.estimate-price-input:focus {
    outline: none;
    border-color: var(--primary);
}

.estimate-add-row {
    display: grid;
    grid-template-columns: 2fr 80px 80px 80px 40px;
    gap: 8px;
    margin-top: 12px;
}

.btn-add-item {
    background: var(--primary);
    color: var(--on-primary);
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 16px;
    display: inline-block;
    margin-top: 12px;
    transition: var(--transition);
}

.btn-add-item:hover {
    background: var(--primary-hover);
}

.btn-remove-item {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
    color: var(--text-muted);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-remove-item:hover {
    color: var(--red);
}

/* Comparison Chart */
.comparison-chart {
    margin-top: 24px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
}

.chart-bar-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.chart-bar-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 120px;
}

.chart-bar-container {
    flex: 1;
    background: var(--bg);
    border-radius: var(--border-radius-sm);
    overflow: hidden;
}

.chart-bar {
    height: 32px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.chart-bar-offer {
    background: var(--blue);
    width: 60%;
}

.chart-bar-estimate {
    background: var(--green);
    width: 80%;
}

/* Gap Alert */
.gap-alert {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-hover);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    gap: 12px;
}

.gap-amount {
    font-size: 18px;
    font-weight: 700;
    color: var(--red);
}

.gap-label {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Justification */
.justification-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 12px;
}

.justification-edit {
    position: relative;
}

.justification-edit textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    background: var(--bg);
    color: var(--text);
}

.justification-edit textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.justify-edit {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-top: 8px;
}

/* AI Analysis */
.ai-placeholder {
    padding: 24px;
    border: 1px dashed var(--border);
    border-radius: var(--border-radius);
    text-align: center;
}

.ai-content {
    margin-top: 12px;
}

.ai-badge {
    display: inline-block;
    background: var(--bg-hover);
    padding: 4px 8px;
    border-radius: var(--border-radius-sm);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.ai-detectors {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.ai-detectors span {
    padding: 4px 8px;
    border-radius: var(--border-radius-sm);
    background: var(--bg-hover);
    font-size: 12px;
    color: var(--text-secondary);
}

/* Export Actions */
.export-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.btn-export {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary);
    color: var(--text);
}

.btn-export:hover {
    background: var(--bg-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-export span:first-child {
    font-size: 24px;
}

.export-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

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

/* Detail Panel - now also uses variables for consistency */
.detail-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--overlay);
    display: flex;
    justify-content: flex-end;
    z-index: 1000;
}

.detail-panel {
    width: 100%;
    max-width: 800px;
    background: var(--bg-secondary);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.detail-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.detail-header h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.detail-header p {
    font-size: 14px;
    color: var(--text-muted);
}

.detail-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    background: var(--bg-secondary);
}

.detail-section {
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 24px;
}

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

.section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}

.section-subtitle {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 16px 0 8px;
}

/* Info Grid */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.info-item {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
}

.info-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-top: 4px;
}

/* Detail Actions */
.detail-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

/* Share Link Modal */
.share-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
}

.share-modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: min(560px, 94vw);
    padding: 24px;
}

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

.share-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.share-modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.share-modal-hint {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
}

.share-modal-note {
    margin: 0;
    font-size: 12px;
    color: var(--primary);
}

.share-url-row {
    display: flex;
    gap: 8px;
}

.share-url-input {
    flex: 1;
    font-family: monospace;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg);
    color: var(--text);
    padding: 12px 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 2000;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    pointer-events: none;
}

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

.toast-success { background: var(--green); color: white; }
.toast-error { background: var(--red); color: white; }
.toast-info { background: var(--blue); color: white; }

.toast-icon {
    font-size: 16px;
}

.toast-text {
    font-size: 14px;
    font-weight: 500;
}

/* Settings Modal */
.settings-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    /* A tall modal must scroll inside the overlay — centring alone pushes the
       header (and its close button) off the top of the screen. */
    overflow-y: auto;
    padding: 24px 16px;
}

.settings-modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    width: 100%;
    max-width: 520px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 48px);
    margin: auto;
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-shrink: 0;   /* the close button stays reachable however long the body gets */
}

.settings-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.settings-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    min-height: 0;    /* lets the flex child actually shrink and scroll */
    padding-right: 4px;
}

.api-key-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.4;
}

.settings-backup {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.backup-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.backup-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.settings-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* Backend Toggle */
.backend-toggle-group {
    display: flex;
    gap: 8px;
}

.backend-toggle-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--border-radius);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.backend-toggle-btn:hover {
    border-color: var(--text-muted);
}

.backend-toggle-btn.active {
    border-color: var(--primary);
    background: var(--primary-bg);
    color: var(--primary);
}

.backend-icon {
    font-size: 16px;
}

.backend-status {
    font-size: 10px;
    font-weight: 400;
    opacity: 0.7;
    margin-left: 4px;
}

/* Model Select Row */
.model-select-row {
    display: flex;
    gap: 8px;
}

.model-select-row select {
    flex: 1;
}

.btn-small {
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

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

/* AI Status Badge in Header */
.ai-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
    margin-top: 4px;
}

.ai-status-badge.ollama-online {
    background: var(--positive-tint);
    color: var(--green);
}

.ai-status-badge.ollama-offline {
    background: var(--negative-tint);
    color: var(--red);
}

.ai-status-badge.anthropic {
    background: var(--special-tint);
    color: var(--purple);
}

.btn-loading {
    opacity: 0.65;
    cursor: not-allowed;
    pointer-events: none;
}

/* Utility classes replacing inline styles */
.input-large { font-size: 18px; font-weight: 600; }
.gap-icon { font-size: 24px; }
.drop-zone-icon { font-size: 36px; margin-bottom: 8px; }
.drop-zone-hint { font-size: 14px; color: var(--text-secondary); }
.estimate-total-row { margin-top: 16px; font-size: 18px; font-weight: 600; }
.textarea-justification { min-height: 120px; resize: vertical; }
.repair-items-list { list-style: disc; padding-left: 20px; font-size: 14px; color: var(--text-secondary); margin-top: 12px; }
.estimate-cell-total { font-weight: 600; }
.kanban-card-status { margin-top: 6px; }

/* Photo card: thumbnail + caption */
.photo-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.photo-caption-input {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--rounded-sm);
    background: var(--surface-elevated);
    color: var(--on-surface);
    font-size: 12px;
    font-family: inherit;
    width: 100%;
}

.photo-caption-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Estimate controls (add + template picker) */
.estimate-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 12px;
}

.template-picker-wrapper {
    position: relative;
}

.btn-templates {
    white-space: nowrap;
    font-size: 13px;
}

.template-picker {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 200;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--rounded-md);
    padding: 6px;
    min-width: 240px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-shadow: var(--shadow-md);
}

.template-option {
    text-align: left;
    padding: 8px 12px;
    background: none;
    border: none;
    border-radius: var(--rounded-sm);
    color: var(--on-surface);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.template-option:hover {
    background: var(--surface-elevated);
}

.template-unit {
    color: var(--on-surface-variant);
    font-size: 11px;
    white-space: nowrap;
}

.template-group-label {
    padding: 6px 12px 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--primary);
    background: var(--surface);
    border-top: 1px solid var(--border);
    margin-top: 2px;
}
.template-group-label:first-child {
    border-top: none;
    margin-top: 0;
}

/* ACV vs RCV table */
.acv-rcv-table {
    margin-top: 12px;
}

.acv-rcv-row {
    display: grid;
    grid-template-columns: 1fr 90px 110px;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    align-items: center;
}

.acv-rcv-head {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--on-surface-variant);
    border-bottom: 2px solid var(--border);
}

.acv-rcv-qty {
    color: var(--on-surface-variant);
    font-size: 12px;
}

.acv-rcv-amount {
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.acv-rcv-empty {
    padding: 16px 0;
    color: var(--on-surface-muted);
    font-size: 13px;
    font-style: italic;
}

.acv-rcv-totals {
    margin-top: 8px;
    padding: 12px 16px;
    background: var(--surface-elevated);
    border-radius: var(--rounded-md);
}

.acv-rcv-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

.acv-rcv-total-row:last-child {
    border-bottom: none;
}

.acv-rcv-total-rcv {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.acv-rcv-total-acv {
    font-weight: 600;
    color: var(--info);
    font-variant-numeric: tabular-nums;
}

.acv-rcv-gap-row {
    font-weight: 700;
}

.gap-positive {
    color: var(--negative);
    font-variant-numeric: tabular-nums;
}

.gap-negative {
    color: var(--positive);
    font-variant-numeric: tabular-nums;
}

.acv-rcv-no-offer {
    padding: 10px 0;
    color: var(--on-surface-muted);
    font-size: 13px;
    font-style: italic;
}

/* ===== Detail Panel — Tab System ===== */
.detail-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.detail-tab-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: color 0.2s, border-color 0.2s;
    white-space: nowrap;
    margin-bottom: -1px;
}

.detail-tab-btn:hover {
    color: var(--text);
}

.detail-tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.detail-tab-pane {
    display: block;
}

/* ===== Header & Kanban Badges ===== */
.detail-header-badges {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.header-overdue-badge {
    background: var(--negative-tint);
    color: var(--negative);
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--rounded-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kanban-overdue-badge {
    display: inline-block;
    background: var(--negative-tint);
    color: var(--negative);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--rounded-full);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-left: 4px;
    vertical-align: middle;
}

.kanban-dep-badge {
    display: inline-block;
    background: var(--primary-tint);
    color: var(--primary);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--rounded-full);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-left: 4px;
    vertical-align: middle;
}

/* ===== Kanban Gap Badge ===== */
.kanban-gap-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--rounded-full);
    margin-top: 6px;
    display: inline-block;
}
.kanban-gap-open {
    background: var(--negative-tint);
    color: var(--negative);
}
.kanban-gap-covered {
    background: var(--positive-tint);
    color: var(--positive);
}

/* ===== Depreciation Calculator ===== */
.dep-calc-card {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--rounded);
    padding: 14px 16px;
    margin-top: 12px;
}
.dep-calc-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 10px;
}
.dep-calc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
}
.dep-calc-item { display: flex; flex-direction: column; gap: 2px; }
.dep-calc-label { font-size: 11px; color: var(--text-muted); }
.dep-calc-value { font-size: 15px; font-weight: 700; color: var(--text); }
.dep-calc-positive { color: var(--positive); }
.dep-calc-deadline { color: var(--primary); }
.dep-calc-warning {
    margin-top: 10px;
    font-size: 12px;
    color: var(--negative);
    background: var(--negative-tint);
    border-radius: var(--rounded-sm);
    padding: 6px 10px;
    font-weight: 600;
}

/* ===== Supplement Rounds ===== */
.supp-round-card {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--rounded);
    padding: 14px 16px;
    margin-bottom: 12px;
}
.supp-round-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.supp-round-num {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}
.supp-round-date { max-width: 140px; }
.supp-round-status-sel { max-width: 160px; }
.supp-round-amounts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}
.supp-round-field { display: flex; flex-direction: column; gap: 4px; }
.supp-round-field label { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.supp-round-narrative { min-height: 60px; resize: vertical; }

/* ===== NOAA Button ===== */
.btn-noaa {
    display: inline-block;
    margin-top: 10px;
    padding: 6px 14px;
    background: var(--primary-tint);
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: var(--rounded);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-noaa:hover { background: var(--primary-bg); }

/* ===== Overdue Indicators ===== */
.overdue-text {
    color: var(--negative);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-left: 6px;
}

.input-overdue {
    border-color: var(--negative) !important;
    color: var(--negative);
}

.input-overdue:focus {
    box-shadow: 0 0 0 3px var(--negative-tint) !important;
}

/* ===== Field Hint ===== */
.field-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.4;
}

/* ===== Checkbox Label ===== */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    margin-top: 6px;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ===== Roof Squares Display ===== */
.roof-squares-display {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    padding: 6px 0;
}

/* ===== Estimate Row with Code Column (7-col) ===== */
.estimate-row-with-code {
    grid-template-columns: 90px 2fr 80px 80px 80px 80px 40px !important;
}

.estimate-code-input {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    font-size: 12px;
    font-family: ui-monospace, 'Cascadia Code', monospace;
    background: var(--bg);
    color: var(--text-muted);
    width: 100%;
}

.estimate-code-input:focus {
    outline: none;
    border-color: var(--primary);
    color: var(--text);
}

/* Adjuster Add Button — styled differently from primary add */
.btn-add-adj {
    background: var(--secondary);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-add-adj:hover {
    background: var(--secondary-hover);
}

/* ===== ACV/RCV 3-Column Comparison ===== */
.acv-rcv-3col {
    grid-template-columns: 1fr 110px 110px !important;
}

.row-missing {
    background: var(--negative-tint);
    border-radius: var(--border-radius-xs);
}

.missing-badge {
    display: inline-block;
    background: var(--negative);
    color: white;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: var(--rounded-full);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    vertical-align: middle;
    margin-left: 4px;
}

.amount-none {
    color: var(--text-muted);
    font-weight: 400;
}

/* ===== Communication Log ===== */
.comm-add-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.comm-date-input {
    flex: 0 0 140px;
}

.comm-note-input {
    flex: 1;
    min-width: 180px;
}

.comm-entry {
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    margin-bottom: 8px;
}

.comm-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.comm-date {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.comm-note {
    font-size: 13px;
    color: var(--text);
    line-height: 1.5;
}

.comm-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    font-style: italic;
}

.comm-delete {
    font-size: 14px;
    padding: 2px 4px;
}

.comm-amount {
    margin-left: auto;
    font-weight: 600;
    color: var(--text);
    font-size: 13px;
}

.log-summary-row {
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    border-radius: 0 0 8px 8px;
}

.badge-billable {
    display: inline-block;
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.badge-nonbillable {
    display: inline-block;
    background: rgba(100, 116, 139, 0.2);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.badge-category {
    display: inline-block;
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 999px;
}

/* ===== Photo Overlay Actions ===== */
.photo-overlay-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
}

.photo-action-btn {
    background: var(--overlay);
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
    backdrop-filter: blur(4px);
}

.photo-action-btn:hover {
    background: var(--bg-hover);
    transform: scale(1.1);
}

.photo-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* AI analysis result below caption */
.photo-analysis {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
    padding: 4px 6px;
    background: var(--bg);
    border-left: 2px solid var(--primary);
    border-radius: 0 var(--border-radius-xs) var(--border-radius-xs) 0;
    margin-top: 4px;
    font-style: italic;
}

/* ===== Annotation Modal ===== */
.annotation-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.annotation-modal {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 100%;
    max-height: 100%;
}

.annotation-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    padding: 10px 16px;
    flex-wrap: wrap;
}

.ann-tools {
    display: flex;
    gap: 4px;
}

.ann-tool {
    width: 36px;
    height: 36px;
    background: none;
    border: 2px solid transparent;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s, background 0.15s;
}

.ann-tool:hover {
    background: var(--bg-hover);
}

.ann-tool.active {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.ann-colors {
    display: flex;
    gap: 6px;
    align-items: center;
}

.ann-color {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s;
    padding: 0;
}

.ann-color[data-color="#ef4444"] { background: #ef4444; }
.ann-color[data-color="#fbbf24"] { background: #fbbf24; }
.ann-color[data-color="#ffffff"] { background: #ffffff; box-shadow: inset 0 0 0 1px var(--border); }
.ann-color[data-color="#3b82f6"] { background: #3b82f6; }

.ann-color:hover {
    transform: scale(1.15);
}

.ann-color.active {
    border-color: var(--text);
    transform: scale(1.15);
}

.ann-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
    flex-wrap: wrap;
}

.annotation-canvas-wrapper {
    overflow: auto;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 160px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border);
    background: #000;
}

#annotation-canvas {
    display: block;
    cursor: crosshair;
    max-width: 100%;
    touch-action: none;
}

/* Responsive */
@media (max-width: 768px) {
    .app-header {
        padding: 8px 16px;
        padding-top: max(8px, env(safe-area-inset-top));
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    .header-top {
        flex-direction: column;
        gap: 8px;
    }

    .brand-tagline { display: none; }

    .main-nav {
        width: 100%;
        justify-content: space-between;
        gap: 6px;
    }

    .nav-label { display: none; }

    .nav-btn { padding: 8px 10px; min-width: 40px; }

    .btn-new-estimate, .btn-add-project {
        flex: 1;
        justify-content: center;
        font-size: 13px;
        padding: 8px 10px;
    }

    .search-bar { margin: 0; }

    .stats-bar {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .stat-card {
        flex: 1;
        min-width: 80px;
    }

    .main-content {
        padding: 16px;
        overflow-y: auto;
    }

    .kanban-board {
        flex-direction: column;
        overflow-y: auto;
    }

    .kanban-column {
        min-width: 100%;
    }

    .kanban-cards {
        max-height: 400px;
    }

    .list-header {
        display: none;
    }

    .list-row {
        flex-direction: column;
        gap: 4px;
    }

    .detail-panel {
        max-width: 100%;
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .estimate-header-row,
    .estimate-row,
    .estimate-add-row {
        grid-template-columns: 1fr;
    }

    .export-actions {
        grid-template-columns: 1fr;
    }

    .detail-actions {
        flex-direction: column;
    }

    .detail-actions button {
        width: 100%;
    }

    .detail-tabs {
        gap: 2px;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }

    .detail-tab-btn {
        padding: 8px 10px;
        font-size: 12px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .estimate-row-with-code {
        grid-template-columns: 1fr !important;
    }

    .photo-gallery {
        grid-template-columns: repeat(2, 1fr);
    }

    .export-actions {
        grid-template-columns: 1fr 1fr;
    }

    .code-upgrade-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .btn-upgrade-add {
        width: 100%;
    }

    .acv-rcv-3col {
        grid-template-columns: 1fr 80px 80px !important;
    }

    .comm-add-row {
        flex-direction: column;
    }

    .comm-date-input {
        flex: none;
        width: 100%;
    }
}

/* ===== Code Upgrade Checklist ===== */
.code-upgrade-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.code-upgrade-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
}

.code-upgrade-info {
    flex: 1;
    min-width: 0;
}

.code-upgrade-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

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

.btn-upgrade-add {
    flex-shrink: 0;
    background: var(--surface);
    color: var(--primary);
    border: 1px solid var(--primary);
    font-weight: 700;
}

.btn-upgrade-add:hover {
    background: var(--primary);
    color: var(--on-primary);
}

/* O&P auto-calculated row highlight */
.oap-item {
    color: var(--primary) !important;
    font-weight: 600;
    background: transparent !important;
}

.oap-total {
    color: var(--primary);
    font-weight: 700;
}

/* ===== Quick Estimator Overlay ===== */
/* Field direction: warm-white, signal-orange accent, Plus Jakarta Sans + JetBrains Mono */

.est-overlay {
    position: fixed; inset: 0; z-index: 3000;
    background: rgba(0,0,0,0.65);
    display: flex; align-items: flex-end; justify-content: center;
    backdrop-filter: blur(3px);
}
.est-overlay.hidden { display: none !important; }

.est-panel {
    width: 100%; max-width: 420px;
    height: calc(93vh - env(safe-area-inset-bottom));
    background: #f7f6f3;
    border-radius: 20px 20px 0 0;
    display: flex; flex-direction: column;
    overflow: hidden; position: relative;
    box-shadow: 0 -20px 60px rgba(0,0,0,0.4);
}
@media (min-width: 640px) {
    .est-overlay { align-items: center; }
    .est-panel { height: 92vh; border-radius: 20px; }
}

.est-header {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 18px; background: #fff;
    border-bottom: 1px solid #e7e5e2; flex-shrink: 0;
}
.est-logo-mark {
    width: 36px; height: 36px; border-radius: 9px;
    background: #0e0e0e; color: #fb923c;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.est-back-btn {
    width: 36px; height: 36px;
    border: 1px solid #e7e5e2; border-radius: 9px;
    background: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; color: #0e0e0e; flex-shrink: 0; line-height: 1;
}
.est-hd-meta { flex: 1; min-width: 0; }
.est-hd-sub {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10.5px; color: #6c6a64;
    letter-spacing: 0.4px; text-transform: uppercase;
}
.est-hd-title {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 17px; font-weight: 700; color: #0e0e0e; letter-spacing: -0.3px;
}
.est-close-btn {
    width: 32px; height: 32px; border-radius: 50%;
    border: 1px solid #e7e5e2; background: #fff;
    cursor: pointer; color: #6c6a64; font-size: 13px;
    display: flex; align-items: center; justify-content: center;
}
.est-progress { height: 3px; background: #e7e5e2; flex-shrink: 0; }
.est-progress.hidden { display: none; }
.est-progress-fill { height: 100%; background: var(--primary); transition: width 0.35s ease; }
.est-body { flex: 1; overflow-y: auto; overflow-x: hidden; padding-bottom: 160px; }
.est-footer {
    position: absolute;
    bottom: calc(78px + env(safe-area-inset-bottom));
    left: 0; right: 0;
    padding: 14px 16px 8px;
    background: linear-gradient(to top, #f7f6f3 70%, transparent);
    pointer-events: none;
}
.est-footer > * { pointer-events: auto; }

/* ── Bottom nav ── */
.est-bottom-nav {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: #fff; border-top: 1px solid #e7e5e2;
    padding: 8px 16px max(20px, env(safe-area-inset-bottom));
    display: grid; grid-template-columns: 1fr auto 1fr;
    gap: 4px; align-items: center; z-index: 20;
}
.est-nav-item {
    background: transparent; border: none; cursor: pointer; padding: 6px 0;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    color: #9c9990;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 10.5px; font-weight: 600; letter-spacing: 0.1px;
    transition: color 0.15s;
}
.est-nav-item.active { color: var(--primary); }
.est-nav-item--primary {
    width: 52px; height: 52px; border-radius: 15px;
    background: #0e0e0e; color: #fff !important;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 12px rgba(234,88,12,0.28);
    padding: 0; margin: 0 auto; flex-direction: row; gap: 0;
}
.est-nav-item--primary.active { background: var(--primary); }

/* ── Dashboard ── */
.est-header.hidden, .est-progress.hidden { display: none; }
.est-dash-wrap { padding: 0 0 16px; }
.est-dash-greeting {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 18px 14px;
}
.est-dash-date { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: #6c6a64; letter-spacing: 0.4px; text-transform: uppercase; }
.est-dash-name { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 24px; font-weight: 700; color: #0e0e0e; margin-top: 4px; letter-spacing: -0.5px; }
.est-dash-avatar {
    width: 40px; height: 40px; border-radius: 12px;
    background: #0e0e0e; color: #fb923c;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-weight: 700; font-size: 15px;
    display: flex; align-items: center; justify-content: center;
}
.est-dash-cta-wrap { padding: 0 16px; }
.est-dash-cta {
    width: 100%; background: #0e0e0e; color: #fff; border: none;
    border-radius: 16px; padding: 16px; cursor: pointer; text-align: left;
    display: flex; align-items: center; gap: 14px;
    box-shadow: 0 6px 20px rgba(14,14,14,0.18);
}
.est-dash-cta-icon {
    width: 50px; height: 50px; border-radius: 12px; background: var(--primary);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.est-dash-cta-text { flex: 1; }
.est-dash-cta-label { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 11px; color: #fb923c; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase; }
.est-dash-cta-title { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 18px; font-weight: 700; color: #fff; margin-top: 2px; }
.est-dash-cta-sub { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 12px; color: rgba(255,255,255,0.6); margin-top: 2px; }
.est-stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 14px 16px 0; }
.est-stat-card { background: #fff; border: 1px solid #e7e5e2; border-radius: 12px; padding: 12px 10px; }
.est-stat-label { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 10px; color: #6c6a64; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.est-stat-value { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 18px; font-weight: 700; margin-top: 4px; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.est-dash-jobs-header { display: flex; align-items: baseline; justify-content: space-between; padding: 22px 20px 8px; }
.est-dash-jobs-title { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 13px; font-weight: 700; color: #0e0e0e; letter-spacing: -0.2px; }
.est-dash-all-btn { background: transparent; border: none; cursor: pointer; font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 12px; color: var(--primary); font-weight: 600; }
.est-dash-jobs { padding: 0 12px; display: flex; flex-direction: column; gap: 8px; }
.est-dash-empty { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 13px; color: #9c9990; padding: 24px 16px; text-align: center; }
.est-job-row {
    background: #fff; border: 1px solid #e7e5e2; border-radius: 14px;
    padding: 10px; cursor: pointer; text-align: left;
    display: flex; gap: 12px; align-items: center; width: 100%;
}
.est-job-thumb { width: 56px; height: 56px; border-radius: 10px; overflow: hidden; background: #fafaf9; flex-shrink: 0; }
.est-job-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.est-job-thumb-ph { width: 100%; height: 100%; background: #0e0e0e; color: #fb923c; display: flex; align-items: center; justify-content: center; font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 700; font-size: 18px; }
.est-job-info { flex: 1; min-width: 0; }
.est-job-name { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 14px; font-weight: 700; color: #0e0e0e; letter-spacing: -0.2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.est-job-svc { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 11.5px; color: #6c6a64; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.est-job-chip { display: inline-block; margin-top: 6px; padding: 3px 8px; border-radius: 999px; font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 10px; font-weight: 600; letter-spacing: 0.2px; }
.est-job-meta { text-align: right; flex-shrink: 0; }
.est-job-price { font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 500; color: #0e0e0e; font-variant-numeric: tabular-nums; }

/* ── You screen ── */
.est-you-profile { display: flex; align-items: center; gap: 14px; padding: 20px 16px 0; }
.est-you-avatar { width: 56px; height: 56px; border-radius: 16px; background: #0e0e0e; color: #fb923c; font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 700; font-size: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.est-you-name { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 16px; font-weight: 700; color: #0e0e0e; letter-spacing: -0.2px; }
.est-you-role { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 12px; color: #6c6a64; margin-top: 2px; }

.est-section { padding: 18px 16px 0; }
.est-section-label {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 12px; font-weight: 700; color: #0e0e0e;
    letter-spacing: -0.1px; margin-bottom: 8px;
}
.est-section-label-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.est-section-label-row .est-section-label { margin-bottom: 0; }
.est-section-meta { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: #6c6a64; letter-spacing: 0.3px; }
.est-card { background: #fff; border: 1px solid #e7e5e2; border-radius: 14px; overflow: hidden; }

.est-input, .est-select, .est-textarea {
    width: 100%; padding: 13px 14px;
    border: 1px solid #e7e5e2; border-radius: 10px;
    background: #fff; color: #0e0e0e;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 15px; font-weight: 500;
    box-sizing: border-box; outline: none; transition: border-color 0.15s;
}
.est-input:focus, .est-select:focus, .est-textarea:focus { border-color: var(--primary); }
.est-input::placeholder, .est-textarea::placeholder { color: #9c9990; }
.est-select { appearance: none; cursor: pointer; background-repeat: no-repeat; background-position: right 14px center; }
.est-textarea { resize: none; line-height: 1.5; }

.est-btn {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 15px 16px; border-radius: 12px;
    cursor: pointer; border: none;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 15px; font-weight: 600; letter-spacing: -0.1px;
}
.est-btn--accent { background: var(--primary); color: #fff; }
.est-btn--accent:hover { background: #c2410c; }
.est-btn--primary { background: #0e0e0e; color: #fff; }
.est-btn--ghost { background: #fff; color: #0e0e0e; border: 1px solid #e7e5e2; }
.est-btn--success { background: #10723a; color: #fff; }
.est-btn .spacer { flex: 1; }

.est-upload-zone {
    border: 2px dashed #d6d3ce; border-radius: 14px;
    background: #fff; padding: 28px 16px; text-align: center;
    cursor: pointer; transition: border-color 0.2s, background 0.2s; user-select: none;
}
.est-upload-zone:hover, .est-upload-zone.dragover { border-color: var(--primary); background: #fff1e6; }
.est-upload-icon { font-size: 32px; margin-bottom: 8px; }
.est-upload-text { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 14px; font-weight: 600; color: #0e0e0e; margin-bottom: 4px; }
.est-upload-sub { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 12px; color: #6c6a64; }

.est-photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.est-photo-thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #fafaf9; }
.est-photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.est-photo-label { position: absolute; bottom: 4px; left: 4px; font-family: 'JetBrains Mono', monospace; font-size: 9.5px; padding: 2px 6px; border-radius: 4px; background: rgba(0,0,0,0.6); color: #fff; backdrop-filter: blur(4px); }
.est-photo-remove { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,0.6); color: #fff; border: none; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; line-height: 1; }

.est-pct { text-align: center; padding: 40px 24px 0; }
.est-pct-num { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 88px; font-weight: 700; line-height: 0.85; letter-spacing: -3px; color: #0e0e0e; font-variant-numeric: tabular-nums; display: inline-block; }
.est-pct-sym { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 24px; color: var(--primary); font-weight: 700; display: inline-block; vertical-align: bottom; margin-bottom: 14px; }
.est-pct-label { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 15px; color: #6c6a64; margin-top: 8px; font-weight: 500; }
.est-prog-bar { height: 8px; border-radius: 4px; background: #e7e5e2; overflow: hidden; margin: 32px 24px 0; }
.est-prog-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.4s ease; }
.est-steps-card { margin: 24px 16px 0; background: #fff; border: 1px solid #e7e5e2; border-radius: 14px; overflow: hidden; }
.est-step-row { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid #e7e5e2; }
.est-step-row:last-child { border-bottom: none; }
.est-step-icon { width: 24px; height: 24px; border-radius: 7px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 12px; }
.est-step-icon--done { background: #10723a; color: #fff; }
.est-step-icon--active { background: #fff1e6; color: var(--primary); }
.est-step-icon--pending { background: #fafaf9; color: #9c9990; font-family: 'JetBrains Mono', monospace; font-size: 10px; }
.est-step-label { flex: 1; font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 14px; color: #6c6a64; }
.est-step-label--active { color: #0e0e0e; font-weight: 600; }
.est-pulse-dots { display: flex; gap: 3px; align-items: center; }
.est-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--primary); animation: estPulse 1.4s ease-in-out infinite; }
.est-dot:nth-child(2) { animation-delay: 0.2s; }
.est-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes estPulse { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

.est-ai-card { background: #0e0e0e; color: #fff; border-radius: 14px; padding: 14px 16px; display: flex; gap: 12px; }
.est-ai-icon { width: 32px; height: 32px; border-radius: 9px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.est-ai-label { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 11px; color: #fb923c; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.est-ai-summary { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 13.5px; color: #fff; margin-top: 4px; line-height: 1.45; }

.est-scope-num { width: 22px; height: 22px; border-radius: 7px; background: var(--primary); color: #fff; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 11px; font-weight: 700; }
.est-scope-name { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 14px; font-weight: 600; color: #0e0e0e; letter-spacing: -0.1px; }
.est-scope-detail { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 12px; color: #6c6a64; margin-top: 2px; line-height: 1.4; }

.est-paint-grid { display: flex; gap: 8px; }
.est-paint-chip { flex: 1; background: transparent; border: none; padding: 0; cursor: pointer; }
.est-paint-swatch { aspect-ratio: 1; border-radius: 10px; border: 2px solid #d6d3ce; transition: box-shadow 0.15s, border-color 0.15s; display: block; }
.est-paint-swatch.active { border-color: var(--primary); box-shadow: 0 0 0 4px #fff1e6; }
.est-paint-code { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: #6c6a64; margin-top: 6px; font-weight: 500; text-align: center; display: block; }
.est-paint-name { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 11px; color: #0e0e0e; margin-top: 1px; font-weight: 600; letter-spacing: -0.1px; text-align: center; display: block; }

.est-tier-card { width: 100%; background: #fff; border: 1px solid #e7e5e2; border-radius: 14px; padding: 14px; cursor: pointer; text-align: left; display: flex; align-items: center; gap: 14px; transition: all 0.15s; box-sizing: border-box; }
.est-tier-card + .est-tier-card { margin-top: 8px; }
.est-tier-card.active { background: #0e0e0e; border-color: #0e0e0e; }
.est-tier-num { width: 44px; height: 44px; border-radius: 11px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-weight: 700; font-size: 17px; background: #fafaf9; border: 1px solid #e7e5e2; color: #6c6a64; }
.est-tier-card.active .est-tier-num { background: var(--primary); border-color: transparent; color: #fff; }
.est-tier-name { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 17px; font-weight: 700; letter-spacing: -0.3px; color: #0e0e0e; }
.est-tier-card.active .est-tier-name { color: #fff; }
.est-tier-price { font-family: 'JetBrains Mono', monospace; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; color: #0e0e0e; }
.est-tier-card.active .est-tier-price { color: #fb923c; }
.est-tier-tag { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 12.5px; color: #6c6a64; margin-top: 3px; line-height: 1.35; }
.est-tier-card.active .est-tier-tag { color: rgba(255,255,255,0.6); }

.est-total-card { background: #0e0e0e; color: #fff; border-radius: 16px; padding: 18px; overflow: hidden; }
.est-total-sub { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 11px; color: #fb923c; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.est-total-amount { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 38px; font-weight: 700; margin-top: 4px; letter-spacing: -1.5px; font-variant-numeric: tabular-nums; }
.est-total-note { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 12px; color: rgba(255,255,255,0.5); margin-top: 2px; }

.est-line-table { background: #fff; border: 1px solid #e7e5e2; border-radius: 14px; overflow: hidden; }
.est-line-row { display: flex; align-items: baseline; gap: 12px; padding: 12px 14px; border-bottom: 1px solid #e7e5e2; }
.est-line-row:last-child { border-bottom: none; }
.est-line-name { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 14px; font-weight: 500; color: #0e0e0e; letter-spacing: -0.1px; }
.est-line-sub { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: #6c6a64; margin-top: 2px; }
.est-line-total { font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 500; color: #0e0e0e; font-variant-numeric: tabular-nums; white-space: nowrap; }
.est-line-subtotal-row { display: flex; justify-content: space-between; padding: 12px 14px; border-top: 1px solid #e7e5e2; background: #fafaf9; }
.est-line-subtotal-label { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 12px; font-weight: 600; color: #6c6a64; text-transform: uppercase; letter-spacing: 0.4px; }
.est-line-subtotal-val { font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 700; color: #0e0e0e; font-variant-numeric: tabular-nums; }

.est-breakdown-row { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px; border-bottom: 1px solid #e7e5e2; }
.est-breakdown-row:last-child { border-bottom: none; }
.est-breakdown-key { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 13px; font-weight: 500; color: #6c6a64; }
.est-breakdown-key.big { font-size: 15px; font-weight: 700; color: #0e0e0e; }
.est-breakdown-val { font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 500; color: #0e0e0e; font-variant-numeric: tabular-nums; }
.est-breakdown-val.big { font-size: 19px; font-weight: 700; }

.est-method-btn { width: 100%; background: #fff; border: 1.5px solid #e7e5e2; border-radius: 12px; padding: 12px 14px; cursor: pointer; text-align: left; display: flex; align-items: center; gap: 12px; margin-bottom: 8px; transition: border-color 0.15s; box-sizing: border-box; }
.est-method-btn.active { border-color: var(--primary); }
.est-method-icon { width: 36px; height: 36px; border-radius: 10px; background: #fafaf9; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.est-method-btn.active .est-method-icon { background: #fff1e6; }
.est-method-label { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 14px; font-weight: 600; color: #0e0e0e; letter-spacing: -0.1px; }
.est-method-sub { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 12px; color: #6c6a64; margin-top: 2px; }
.est-radio { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid #e7e5e2; margin-left: auto; display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; }
.est-method-btn.active .est-radio { border-color: var(--primary); background: var(--primary); color: #fff; }

.est-photo-preview { position: relative; border-radius: 14px; overflow: hidden; background: #000; aspect-ratio: 4/3; }
.est-photo-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.paint-tint { position: absolute; inset: 0; mix-blend-mode: multiply; opacity: 0.45; transition: background 0.3s; }
.est-photo-overlay-chip { position: absolute; top: 10px; left: 10px; padding: 5px 9px; border-radius: 8px; background: rgba(255,255,255,0.92); backdrop-filter: blur(6px); font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: #0e0e0e; font-weight: 500; }

.btn-new-estimate { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 10px; background: var(--primary); color: #fff; border: none; cursor: pointer; font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 14px; font-weight: 600; letter-spacing: -0.1px; white-space: nowrap; transition: background 0.15s; }
.btn-new-estimate:hover { background: #c2410c; }

/* ===== Repair & Maintenance Forecast (ported from Prop AI) ===== */
.forecast-add-row { display: flex; gap: 8px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.forecast-add-row .form-input { flex: 1; min-width: 200px; }
.forecast-row { background: var(--surface-elevated, #253349); border: 1px solid var(--border); border-radius: var(--border-radius-sm); padding: 10px 12px; margin-bottom: 8px; }
.forecast-row-head { display: flex; align-items: center; gap: 8px; }
.forecast-label-input { flex: 1; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: var(--border-radius-xs); padding: 6px 9px; font-size: 13px; }
.forecast-row-fields { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.forecast-mini { display: flex; flex-direction: column; gap: 3px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); }
.forecast-mini .form-input { width: 110px; padding: 5px 7px; font-size: 13px; }
.forecast-cat-badge { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; padding: 3px 7px; border-radius: 6px; white-space: nowrap; }
.fc-cat-safety { background: rgba(239,68,68,0.18); color: #fca5a5; }
.fc-cat-repair { background: rgba(59,130,246,0.18); color: #93c5fd; }
.fc-cat-repaint { background: rgba(139,92,246,0.18); color: #c4b5fd; }
.fc-cat-maintenance { background: rgba(251,191,36,0.18); color: #fde68a; }
.forecast-ai-badge { font-size: 9px; font-weight: 700; letter-spacing: 0.5px; padding: 2px 6px; border-radius: 5px; background: rgba(16,185,129,0.18); color: #6ee7b7; }
.forecast-totals { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0 8px; }
.forecast-total-card { border: 1px solid var(--border); border-radius: var(--border-radius-sm); padding: 12px 14px; }
.forecast-now { border-left: 3px solid var(--red); }
.forecast-later { border-left: 3px solid var(--status-sent-fg, #fef08a); }
.forecast-total-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.forecast-total-val { font-size: 20px; font-weight: 800; color: var(--text); margin-top: 2px; font-variant-numeric: tabular-nums; }
.forecast-disclaimer { font-size: 11px; color: var(--text-muted); font-style: italic; margin-top: 8px; }

/* ===== Structured photo findings (ported from Christian Construction) ===== */
.photo-findings { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.finding-chips { display: flex; gap: 5px; flex-wrap: wrap; }
.finding-chip { font-size: 10px; font-weight: 600; text-transform: capitalize; padding: 2px 7px; border-radius: 6px; background: var(--bg-hover); color: var(--text-secondary); }
.finding-chip.sev-high { background: rgba(239,68,68,0.2); color: #fca5a5; }
.finding-chip.sev-medium { background: rgba(251,191,36,0.2); color: #fde68a; }
.finding-chip.sev-low { background: rgba(16,185,129,0.2); color: #6ee7b7; }
.finding-chip.cond-damaged, .finding-chip.cond-poor { background: rgba(239,68,68,0.14); color: #fca5a5; }
.finding-suggests { display: flex; flex-direction: column; gap: 4px; }
.finding-suggest-btn, .finding-forecast-btn { text-align: left; background: var(--bg); border: 1px dashed var(--border); color: var(--text-secondary); border-radius: var(--border-radius-xs); padding: 5px 8px; font-size: 11.5px; cursor: pointer; transition: var(--transition); }
.finding-suggest-btn:hover, .finding-forecast-btn:hover { border-color: var(--primary); color: var(--text); background: var(--bg-hover); }
.finding-forecast-btn { border-color: rgba(16,185,129,0.4); }
.finding-unit { color: var(--text-muted); font-size: 10px; }

/* ===== App footer — Conard Technologies licensing credit ===== */
.app-footer { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; padding: 18px 20px calc(18px + env(safe-area-inset-bottom)); margin-top: 12px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 12px; text-align: center; }
.app-footer-sep { opacity: 0.5; }
.app-footer-brand { color: var(--text-secondary); font-weight: 600; }

/* ===== Auth / login gate (multi-user accounts) ===== */
.auth-overlay { position: fixed; inset: 0; z-index: 4000; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(15,23,42,0.92); backdrop-filter: blur(8px); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--border-radius-lg); box-shadow: var(--shadow-xl); padding: 26px 24px calc(22px + env(safe-area-inset-bottom)); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-logo { width: 44px; height: 44px; border-radius: 10px; }
.auth-title { font-size: 17px; font-weight: 700; color: var(--text); }
.auth-sub { font-size: 12px; color: var(--text-secondary); }
.auth-tabs { display: flex; gap: 6px; background: var(--bg); border-radius: var(--border-radius-sm); padding: 4px; margin-bottom: 16px; }
.auth-tab { flex: 1; padding: 8px; border: none; background: transparent; color: var(--text-secondary); font-size: 13px; font-weight: 600; border-radius: var(--border-radius-xs); cursor: pointer; transition: var(--transition); }
.auth-tab.active { background: var(--primary); color: var(--on-primary); }
.auth-field { margin-bottom: 12px; }
.auth-field label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 5px; }
.auth-optional { color: var(--text-muted); font-weight: 400; }
.auth-error { background: rgba(239,68,68,0.14); color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); border-radius: var(--border-radius-xs); padding: 8px 10px; font-size: 12.5px; margin-bottom: 12px; }
.auth-submit { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }
.auth-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 12px; line-height: 1.5; }
.account-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--border-radius-sm); padding: 10px 12px; }
.account-name { font-size: 14px; font-weight: 600; color: var(--text); }
.account-role { font-size: 12px; color: var(--text-secondary); }

/* ===== Job profitability ===== */
.profit-pos { color: var(--green); }
.profit-neg { color: var(--red); }
.stat-margin-neg { color: var(--red); }
.profit-bar { height: 8px; border-radius: 4px; background: var(--green); overflow: hidden; margin: 10px 0 4px; }
.profit-bar-cost { height: 100%; background: var(--secondary-hover); border-radius: 4px 0 0 4px; }
.profit-bar-over { background: var(--red); }

/* ===== Section header with action button ===== */
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.section-title-row .section-title { margin-bottom: 0; }

/* ===== Voice dictation ===== */
.btn-dictate.dictating { background: var(--red); color: var(--on-primary); border-color: var(--red); animation: dictate-pulse 1.2s ease-in-out infinite; }
@keyframes dictate-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.65; } }

/* ===== Room measurement calculator ===== */
.room-calc-panel { background: var(--surface-elevated, #253349); border: 1px solid var(--border); border-radius: var(--border-radius-sm); padding: 12px 14px; margin: 10px 0; }
.room-calc-inputs { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.room-calc-inputs .form-input { width: 84px; padding: 5px 7px; font-size: 13px; }
.room-calc-results { display: flex; gap: 8px; flex-wrap: wrap; }
.room-calc-add { display: inline-flex; align-items: center; gap: 6px; background: var(--bg); border: 1px dashed var(--border); color: var(--text-secondary); border-radius: var(--border-radius-xs); padding: 7px 10px; font-size: 12.5px; cursor: pointer; transition: var(--transition); }
.room-calc-add:hover { border-color: var(--primary); color: var(--text); background: var(--bg-hover); }
.room-calc-add span { font-weight: 700; color: var(--text); }

/* ===== Estimator: job size + scope quantities ===== */
.est-size-row { display: flex; gap: 10px; }
.est-size-field { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.est-size-field > span { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 11.5px; font-weight: 600; color: #6c6a64; }
.est-size-field em { font-style: normal; font-weight: 500; opacity: 0.75; }
.est-size-hint { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 11.5px; color: #6c6a64; line-height: 1.45; margin-top: 8px; }
.est-size-basis { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 11.5px; color: #fdba74; margin-top: 6px; line-height: 1.4; }
.est-scope-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; }
.est-scope-row--divided { border-bottom: 1px solid #e7e5e2; }
.est-scope-body { flex: 1; }
.est-scope-hours { flex-shrink: 0; padding: 4px 9px; border-radius: 999px; background: #fff1e6; color: #b45309; font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 600; }

/* ===== Client-facing quote view (public, no account) ===== */
body.client-quote-mode { background: #f5f4f2; overflow-y: auto; }
body.client-quote-mode > *:not(#client-quote-view):not(#toast-container) { display: none !important; }
.client-quote-view { position: absolute; inset: 0; background: #f5f4f2; overflow-y: auto; z-index: 900; }
.cq-wrap { max-width: 720px; margin: 0 auto; padding: 28px 18px 56px; font-family: 'Plus Jakarta Sans', system-ui, sans-serif; }
.cq-loading { padding: 60px 20px; text-align: center; color: #6c6a64; font-family: 'Plus Jakarta Sans', system-ui, sans-serif; }
.cq-head { text-align: center; margin-bottom: 22px; }
.cq-co { font-size: 20px; font-weight: 800; color: #0e0e0e; letter-spacing: -0.3px; }
.cq-co-contact { font-size: 12.5px; color: #6c6a64; margin-top: 3px; }
.cq-card { background: #fff; border: 1px solid #e7e5e2; border-radius: 14px; padding: 20px 22px; margin-bottom: 14px; }
.cq-card--msg { text-align: center; margin-top: 60px; }
.cq-card--msg h2 { font-size: 18px; color: #0e0e0e; margin-bottom: 8px; }
.cq-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: #a8a29e; margin-bottom: 8px; }
.cq-title { font-size: 25px; font-weight: 800; color: #0e0e0e; letter-spacing: -0.5px; line-height: 1.2; }
.cq-sub { font-size: 13.5px; color: #57534e; margin-top: 4px; }
.cq-sub--dim { color: #a8a29e; font-size: 12.5px; }
.cq-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.cq-table th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.5px; color: #a8a29e; padding: 0 0 9px; border-bottom: 1px solid #e7e5e2; }
.cq-table td { padding: 11px 0; border-bottom: 1px solid #f0eeec; color: #292524; vertical-align: top; }
.cq-num { text-align: right; font-family: 'JetBrains Mono', monospace; font-size: 12.5px; white-space: nowrap; }
.cq-table td.cq-num, .cq-table th.cq-num { text-align: right; padding-left: 18px; }
.cq-total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 15px; font-size: 15px; color: #57534e; }
.cq-total strong { font-family: 'JetBrains Mono', monospace; font-size: 23px; color: #0e0e0e; font-weight: 700; }
.cq-notes { font-size: 13.5px; color: #44403c; line-height: 1.6; white-space: pre-wrap; }
.cq-actions { text-align: center; }
.cq-input { width: 100%; padding: 13px 14px; border: 1px solid #d6d3d1; border-radius: 10px; font-size: 15px; font-family: inherit; color: #0e0e0e; background: #fff; margin-bottom: 10px; }
.cq-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(234,88,12,0.12); }
.cq-btn { display: block; width: 100%; padding: 15px; border-radius: 11px; font-family: inherit; font-size: 15.5px; font-weight: 700; cursor: pointer; border: none; transition: filter 0.15s ease; }
.cq-btn:hover { filter: brightness(0.94); }
.cq-btn--accept { background: #10723a; color: #fff; }
.cq-btn--decline { background: transparent; color: #6c6a64; border: 1px solid #d6d3d1; margin-top: 9px; font-weight: 600; }
.cq-fine { font-size: 11.5px; color: #a8a29e; line-height: 1.55; margin-top: 13px; }
.cq-banner { border-radius: 12px; padding: 15px 18px; margin-bottom: 14px; font-size: 14px; line-height: 1.5; }
.cq-banner--ok { background: #dff5e6; color: #10723a; border: 1px solid #a7e5c0; }
.cq-banner--no { background: #fef3c7; color: #92400e; border: 1px solid #fcd9a0; }
.cq-foot { text-align: center; font-size: 11px; color: #a8a29e; margin-top: 26px; }

/* ===== Contractor side: acceptance badges ===== */
.quote-accepted-card { display: flex; align-items: center; gap: 13px; background: rgba(16,114,58,0.12); border: 1px solid rgba(16,114,58,0.4); border-radius: var(--border-radius-sm); padding: 14px 16px; }
.quote-accepted-icon { width: 30px; height: 30px; border-radius: 50%; background: var(--green); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.quote-accepted-title { font-weight: 600; color: var(--text); font-size: 14px; }
.quote-accepted-sub { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }
.quote-declined-card { background: rgba(180,83,9,0.12); border: 1px solid rgba(180,83,9,0.4); border-radius: var(--border-radius-sm); padding: 14px 16px; }

/* ===== Client-visible field marker ===== */
.client-visible-tag { display: inline-block; margin-left: 8px; padding: 3px 8px; border-radius: 999px; background: rgba(16,114,58,0.16); color: var(--green); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; vertical-align: middle; }

/* ===== Offline AI queue ===== */
.ai-queue-badge { margin: 0 24px 10px; padding: 9px 14px; border-radius: var(--border-radius-sm); background: rgba(180,83,9,0.14); border: 1px solid rgba(180,83,9,0.45); color: var(--text); font-size: 12.5px; cursor: pointer; transition: var(--transition); }
.ai-queue-badge:hover { background: rgba(180,83,9,0.22); }
.photo-queued { margin-top: 6px; padding: 6px 9px; border-radius: var(--border-radius-xs); background: rgba(180,83,9,0.14); color: var(--text-secondary); font-size: 11.5px; }

/* ===== Account: change password ===== */
.account-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pw-form { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.pw-form code { background: var(--bg); padding: 2px 5px; border-radius: 4px; font-size: 11.5px; }

/* ===== Settings: advanced (collapsed) block ===== */
.advanced-block { border: 1px solid var(--border); border-radius: var(--border-radius-sm); padding: 10px 14px; margin-bottom: 16px; }
.advanced-block > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-secondary); list-style: revert; }
.advanced-block[open] > summary { margin-bottom: 10px; }

/* ===== Estimator: explicit exit from the dashboard ===== */
.est-dash-head-actions { display: flex; align-items: center; gap: 10px; }
.est-dash-close { width: 34px; height: 34px; border-radius: 50%; border: 1px solid #e7e5e2; background: #fff; color: #6c6a64; font-size: 15px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: var(--transition); }
.est-dash-close:hover { background: #f2f0ec; color: #0e0e0e; }

/* ===== Team & invites ===== */
.team-box { display: flex; flex-direction: column; gap: 14px; }
.team-list { display: flex; flex-direction: column; gap: 8px; }
.team-member { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--border-radius-sm); flex-wrap: wrap; }
.team-name { font-weight: 600; font-size: 13.5px; color: var(--text); }
.team-you { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--primary); background: var(--primary-bg); padding: 2px 6px; border-radius: 999px; }
.team-email { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.team-role { width: auto; min-width: 190px; font-size: 12.5px; padding: 6px 8px; }
.invite-box { padding: 12px 14px; border: 1px dashed var(--border); border-radius: var(--border-radius-sm); display: flex; flex-direction: column; gap: 8px; }
.invite-title { font-weight: 700; font-size: 13px; color: var(--text); }
.invite-fields { display: flex; gap: 8px; flex-wrap: wrap; }
.invite-fields .form-input { flex: 1; min-width: 180px; font-size: 12.5px; }
.invite-code { max-width: 160px; font-family: 'JetBrains Mono', monospace; font-weight: 600; }
