/* ── BADGES ── */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border: 1px solid transparent;
}
.badge-active   { background: #C7DEFB; color: #154E8A; border-color: #2E75B6; }
.badge-permit   { background: #FFE7B5; color: #7E5300; border-color: #C58A1F; }
.badge-inspect  { background: #C2E8D2; color: #0B5A30; border-color: #1F9D55; }
.badge-estimate { background: #DEE5F2; color: #2A4163; border-color: #5B7FB0; }
.badge-proposal { background: #E8D8F0; color: #5A2B7A; border-color: #8E44AD; }
.badge-closed   { background: #DDE0E5; color: #4B5563; border-color: #99A0AB; }

/* ── JOB BODY ── */
.job-body { padding: 0 24px 24px; border-top: 1px solid var(--gray-1); }
.section-note {
    font-size: 12px;
    color: var(--text-lt);
    background: #FFFBF0;
    border-left: 3px solid var(--gold);
    padding: 8px 12px;
    margin: 16px 0 0;
    border-radius: 0 6px 6px 0;
    font-style: italic;
}
.analytics-loading {
    text-align: center;
    padding: 40px 20px;
    color: #7A8694;
    font-size: 13px;
}
.analytics-loading::before {
    content: '';
    display: block;
    width: 28px;
    height: 28px;
    margin: 0 auto 12px;
    border: 3px solid #E4E8ED;
    border-top-color: var(--navy);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.dim-overlay .confirm-modal-box {
    animation: modalIn 0.3s ease both;
}
@keyframes modalIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-1);
    margin-bottom: 4px;
    animation: sectionSlideIn 0.3s ease both;
}
.qa-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    align-items: stretch;
}
.qa-group-label {
    grid-column: 1 / -1;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--gray-3);
    margin-bottom: 2px;
}
.qa-cell {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}
.qa-cell .qa-btn {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
}
.qa-group-icon { color: #7C3BF0; }
[data-theme="dark"] .qa-group-icon { color: #B58CFF; }
[data-theme="dark"] .qa-group-label { color: #8896A6; }

/* AI variant — soft purple tint to signal "this uses AI" without shouting */
.qa-btn.qa-ai {
    border-color: rgba(124, 59, 240, 0.4);
    color: #5E2BC8;
    background: rgba(124, 59, 240, 0.04);
}
.qa-btn.qa-ai:hover {
    background: rgba(124, 59, 240, 0.12);
    color: #4818A8;
    border-color: rgba(124, 59, 240, 0.7);
}
[data-theme="dark"] .qa-btn.qa-ai {
    border-color: rgba(181, 140, 255, 0.42);
    color: #C9B0FF;
    background: rgba(181, 140, 255, 0.06);
}
[data-theme="dark"] .qa-btn.qa-ai:hover {
    background: rgba(181, 140, 255, 0.16);
    color: #E8DAFF;
    border-color: rgba(181, 140, 255, 0.7);
}
.qa-btn {
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    font-weight: 600;
    padding: 7px 14px;
    border: 1px solid var(--navy);
    border-radius: 20px;
    background: var(--white);
    color: var(--navy);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.qa-btn:hover {
    background: var(--navy);
    color: var(--white);
}
.qa-btn.qa-secondary {
    border-color: var(--gray-2);
    color: var(--gray-3);
}
.qa-btn.qa-secondary:hover {
    background: var(--gray-2);
    color: var(--navy);
}
.qa-btn.qa-collect {
    border-color: var(--green);
    color: var(--green);
    font-weight: 700;
}
.qa-btn.qa-collect:hover {
    background: var(--green);
    color: #fff;
}
.section-block {
    margin-top: 24px;
}
.section-block:not(.collapsed-section) > *:not(.section-title):not(.scope-toggle-row) {
    animation: sectionSlideIn 0.5s ease both;
}
@keyframes sectionSlideIn {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}
.section-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 15px;
    letter-spacing: 1.5px;
    color: var(--navy);
    text-transform: uppercase;
    border-bottom: 2px solid var(--navy);
    padding-bottom: 5px;
    margin-bottom: 12px;
}
.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.scope-toggle-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease, border-color 0.15s ease;
    padding: 6px 10px 5px;
}
.scope-toggle-row > span:first-child {
    justify-self: start;
}
.scope-toggle-row > .section-chevron {
    justify-self: center;
}
.scope-toggle-row:hover {
    opacity: 0.85;
}
.section-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 10px;
}
.payments-import-footer {
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px dashed var(--gray-2);
    font-size: 12px;
    color: var(--text-lt);
    text-align: center;
}
.payments-import-footer .payments-import-link {
    color: var(--text-lt);
    text-decoration: underline;
    cursor: pointer;
    margin: 0 4px;
}
.payments-import-footer .payments-import-link:hover {
    color: var(--text);
}
.issue-receipt-row {
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    cursor: pointer;
    padding: 12px 14px;
}
.issue-receipt-row:hover {
    background: var(--gray-1);
}
.section-block.collapsed-section .section-title {
    background: #EDF1F7;
    border-bottom: 2px solid var(--gray-2);
    border-radius: 5px;
    margin-bottom: 0;
}
.section-block.collapsed-section .section-title:hover {
    background: #E3E9F2;
}
.section-chevron {
    font-size: 13px;
    color: var(--navy);
    transition: transform 0.25s ease;
}
.section-chevron.open {
    transform: rotate(0deg);
}
.collapsed-section .section-chevron {
    transform: rotate(-90deg);
}
.section-chevron.open {
    transform: rotate(180deg);
}
.doc-refresh-btn {
    background: linear-gradient(180deg, #EFF6FF, #DBEAFE);
    color: var(--navy);
    border: 1px solid rgba(41,104,166,0.42);
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 2px 6px rgba(41,104,166,0.12);
}
.doc-refresh-btn:hover {
    background: linear-gradient(180deg, #DBEAFE, #BFDBFE);
}
.doc-refresh-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* ── TABLES ── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.estimate-detail-label {
    font-weight: 700;
    color: var(--navy);
}

.estimate-detail-desc {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-lt);
    line-height: 1.45;
}

.estimate-detail-amt {
    white-space: nowrap;
    text-align: right;
    font-weight: 700;
}

.scope-narrative-item {
    margin-bottom: 8px;
}
.scope-narrative-item:last-child {
    margin-bottom: 0;
}
.scope-narrative-title {
    font-weight: 600;
    color: var(--navy);
    font-size: 13px;
    margin-bottom: 2px;
}
.scope-narrative-bullets {
    margin: 0 0 0 18px;
    padding: 0;
    color: var(--text);
    font-size: 13px;
    line-height: 1.5;
}
.scope-narrative-bullets li {
    margin: 2px 0;
}
.scope-narrative-text {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
}
.scope-narrative-notes {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.jc-totals-warn {
    margin: 0 0 12px;
    padding: 10px 12px;
    background: rgba(255, 180, 0, 0.14);
    border: 1px solid rgba(255, 180, 0, 0.28);
    border-radius: 10px;
    font-size: 13px;
    color: #8C6A00;
}
.jc-totals-warn strong {
    display: block;
    margin-bottom: 4px;
}
.jc-totals-warn ul {
    margin: 0;
    padding-left: 18px;
}
[data-theme="dark"] .jc-totals-warn {
    background: rgba(255, 180, 0, 0.18);
    border-color: rgba(255, 180, 0, 0.32);
    color: #FFD584;
}

.scope-card-list {
    display: grid;
    gap: 10px;
}
.scope-card-row {
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.96));
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 6px 18px rgba(15, 27, 45, 0.06);
}
.scope-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.scope-card-title {
    min-width: 0;
    color: var(--navy);
    font-size: 15px;
    font-weight: 750;
    line-height: 1.25;
    overflow-wrap: anywhere;
}
.scope-card-amount {
    flex: 0 0 auto;
    color: var(--navy);
    font-family: 'DM Mono', ui-monospace, monospace;
    font-size: 14px;
    font-weight: 800;
    white-space: nowrap;
}
.scope-card-amount-standalone {
    margin-top: 8px;
}
.scope-card-desc {
    margin-top: 10px;
    border-left: 3px solid rgba(71, 85, 105, 0.28);
    padding: 7px 10px;
    border-radius: 8px;
    background: rgba(71, 85, 105, 0.06);
    color: var(--text-lt);
    font-size: 13px;
    line-height: 1.45;
}
.scope-card-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    color: var(--gray-3);
    font-size: 12.5px;
    line-height: 1.35;
}
.scope-card-dot { opacity: 0.65; }
.scope-card-effect {
    margin-top: 10px;
    color: var(--gray-3);
    font-size: 12.5px;
    font-weight: 650;
}
.change-order-card-row {
    border-left: 3px solid rgba(31, 157, 85, 0.38);
}
[data-theme="dark"] .scope-card-row {
    background: linear-gradient(180deg, rgba(26, 35, 50, 0.98), rgba(18, 28, 44, 0.96));
    border-color: #2D3A4D;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}
[data-theme="dark"] .scope-card-row:hover {
    border-color: #3B4B62;
}
[data-theme="dark"] .scope-card-title,
[data-theme="dark"] .scope-card-amount {
    color: #E6EAF0;
}
[data-theme="dark"] .scope-card-desc {
    background: rgba(148, 163, 184, 0.08);
    border-left-color: rgba(148, 163, 184, 0.38);
    color: #B6BEC9;
}
[data-theme="dark"] .scope-card-meta,
[data-theme="dark"] .scope-card-effect {
    color: #8A97A8;
}
.data-table th {
    background: var(--navy);
    color: var(--white);
    padding: 8px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.data-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    background: var(--surface);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--surface-hover); }
.data-table tbody tr:hover td:first-child { box-shadow: inset 2px 0 0 var(--navy); }
.totals-row td {
    background: var(--gray-1) !important;
    font-size: 13px;
    border-bottom: 1px solid var(--gray-2);
}
.amt-received { color: var(--green); font-weight: 600; font-family: 'DM Mono', monospace; }
.amt-pending  { color: var(--gray-3); font-family: 'DM Mono', monospace; }
.amt-balance  { color: var(--red); font-weight: 600; font-family: 'DM Mono', monospace; }

.payments-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--gray-2);
    border-radius: 8px;
    overflow: hidden;
    margin-top: 14px;
}
.payments-summary-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
    background: var(--gray-1);
}
.payments-summary-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--gray-3);
}
.payments-summary-val {
    font-size: 18px;
    font-family: 'DM Mono', monospace;
}

/* ── STATUS PILLS ── */
.status-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.status-issued   { background: #EDF9F0; color: #1A8040; }
.status-pending  { background: #FFF4E0; color: #B07800; }
.status-open     { background: #F5F5F5; color: #666; }
.status-rejected { background: #FEE; color: var(--red); }

/* ── MATERIAL STATUS ── */
.mat-needed   { background: #FEE;    color: var(--red); }
.mat-quoted   { background: #FFF0D0; color: #8A5700; }
.mat-ordered  { background: #FFF4E0; color: #B07800; }
.mat-received { background: #EDF9F0; color: #1A8040; }
.mat-onhand   { background: #E8F4FE; color: var(--blue); }
.mat-installed{ background: #EDF9F0; color: #1A8040; }

.mat-btn {
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: opacity 0.15s, transform 0.1s;
}
.mat-btn:hover  { opacity: 0.8; transform: scale(1.05); }
.mat-btn:active { transform: scale(0.97); }
.mat-btn.saving { opacity: 0.5; cursor: wait; }
.utility-btn {
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.15s, transform 0.1s;
}
.utility-btn:hover {
    opacity: 0.85;
    transform: scale(1.03);
}
.utility-btn:active {
    transform: scale(0.98);
}
.utility-btn.saving {
    opacity: 0.6;
    cursor: wait;
}

/* ── REGULATORY / CHECKLIST CARDS ── */
.reg-card-list,
.checklist-card-list {
    display: grid;
    gap: 10px;
}
.reg-card-row,
.checklist-card-row {
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.96));
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 6px 18px rgba(15, 27, 45, 0.06);
}
.reg-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.reg-card-title {
    min-width: 0;
    color: var(--navy);
    font-size: 15px;
    font-weight: 750;
    line-height: 1.25;
    overflow-wrap: anywhere;
}
.reg-card-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    color: var(--gray-3);
    font-size: 12.5px;
    line-height: 1.35;
}
.reg-card-dot { opacity: 0.65; }
.reg-card-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
}
.reg-card-metric {
    min-width: 0;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 10px;
    background: rgba(248, 250, 252, 0.82);
    padding: 8px 10px;
}
.reg-card-metric span {
    display: block;
    color: var(--gray-3);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}
.reg-card-metric strong {
    display: block;
    margin-top: 2px;
    color: var(--navy);
    font-family: 'DM Mono', ui-monospace, monospace;
    font-size: 13px;
}
.reg-card-metric.deadline-overdue strong { color: var(--red); }
.reg-card-notes {
    margin-top: 10px;
    border-left: 3px solid rgba(201, 122, 0, 0.32);
    padding: 7px 10px;
    border-radius: 8px;
    background: rgba(201, 122, 0, 0.06);
    color: var(--text-lt);
    font-size: 13px;
    line-height: 1.45;
}
.reg-card-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
[data-theme="dark"] .reg-card-row,
[data-theme="dark"] .checklist-card-row {
    background: linear-gradient(180deg, rgba(26, 35, 50, 0.98), rgba(18, 28, 44, 0.96));
    border-color: #2D3A4D;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}
[data-theme="dark"] .reg-card-row:hover,
[data-theme="dark"] .checklist-card-row:hover {
    border-color: #3B4B62;
}
[data-theme="dark"] .reg-card-title { color: #E6EAF0; }
[data-theme="dark"] .reg-card-meta,
[data-theme="dark"] .reg-card-metric span { color: #8A97A8; }
[data-theme="dark"] .reg-card-metric {
    background: rgba(10, 18, 32, 0.42);
    border-color: #2A3545;
}
[data-theme="dark"] .reg-card-metric strong { color: #E6EAF0; }
[data-theme="dark"] .reg-card-metric.deadline-overdue strong { color: #F09185; }
[data-theme="dark"] .reg-card-notes {
    background: rgba(234, 162, 52, 0.10);
    border-left-color: rgba(234, 162, 52, 0.48);
    color: #B6BEC9;
}

.role-tag {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
    background: var(--gray-1);
    color: var(--gray-3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── LINKS ── */
.tel-link {
    color: var(--blue);
    text-decoration: none;
    font-family: 'DM Mono', monospace;
    font-size: 13px;
}
.tel-link:hover { text-decoration: underline; }
.addr-link {
    color: var(--text-lt);
    text-decoration: none;
    font-size: 13px;
}
.addr-link:hover { text-decoration: underline; color: var(--blue); }

/* ── GMAIL ── */
.gmail-subject {
    color: var(--navy);
    text-decoration: none;
    font-weight: 500;
}
.gmail-subject:hover { text-decoration: underline; color: var(--blue); }
.gmail-card-list {
    display: grid;
    gap: 10px;
}
.gmail-card-row {
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.96));
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 6px 18px rgba(15, 27, 45, 0.06);
}
.gmail-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.gmail-card-top .gmail-subject {
    min-width: 0;
    color: var(--navy);
    font-size: 15px;
    font-weight: 750;
    line-height: 1.25;
    overflow-wrap: anywhere;
}
.gmail-card-date,
.gmail-card-from {
    color: var(--gray-3);
    font-size: 12.5px;
}
.gmail-card-date {
    flex: 0 0 auto;
    font-family: 'DM Mono', ui-monospace, monospace;
    white-space: nowrap;
}
.gmail-card-from {
    margin-top: 6px;
}
.gmail-snippet {
    color: var(--gray-3);
    font-size: 12px;
    line-height: 1.45;
    margin-top: 8px;
}
.gmail-card-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
[data-theme="dark"] .gmail-card-row {
    background: linear-gradient(180deg, rgba(26, 35, 50, 0.98), rgba(18, 28, 44, 0.96));
    border-color: #2D3A4D;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}
[data-theme="dark"] .gmail-card-row:hover {
    border-color: #3B4B62;
}
[data-theme="dark"] .gmail-card-top .gmail-subject {
    color: #F88FAD;
}
[data-theme="dark"] .gmail-card-date,
[data-theme="dark"] .gmail-card-from,
[data-theme="dark"] .gmail-snippet {
    color: #8A97A8;
}

/* ── MILESTONES ── */
.milestone-list { display: flex; flex-direction: column; gap: 6px; }
.milestone {
    display: grid;
    grid-template-columns: 24px 1fr auto;
    align-items: baseline;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
}
.milestone-editable {
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.milestone-editable:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(27,51,80,0.08);
}
.milestone-editable.saving {
    opacity: 0.6;
    cursor: wait;
}
.milestone-locked {
    cursor: default;
}
.milestone-editable:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}
.ms-done    { background: #EBF7F0; }
.ms-pending { background: #F4F6F9; }
.ms-overdue { background: #FEF0F0; }
.ms-icon { font-family: 'DM Mono', monospace; font-weight: 600; text-align: center; }
.ms-done .ms-icon    { color: var(--green); }
.ms-pending .ms-icon { color: var(--gray-3); }
.ms-overdue .ms-icon { color: var(--red); }
.ms-label { font-weight: 500; }
.ms-date  { font-family: 'DM Mono', monospace; font-size: 12px; color: var(--gray-3); white-space: nowrap; }
.ms-note  { grid-column: 2 / -1; font-size: 11px; color: var(--text-lt); font-style: italic; }

.deadline-overdue { color: var(--red); font-weight: 600; }
.empty-state { color: var(--gray-3); font-style: italic; font-size: 13px; padding: 8px 0; }

/* ── CALENDAR ── */
.cal-list { display: flex; flex-direction: column; gap: 6px; }
.cal-event {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    align-items: start;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 13px;
    border: 1px solid transparent;
    border-left: 3px solid var(--gray-2);
    box-shadow: 0 6px 18px rgba(15, 27, 45, 0.05);
}
.cal-today  { background: #FFF8E7; border-left-color: var(--gold); }
.cal-future { background: #F0F6FF; border-left-color: var(--blue); }
.cal-past   { background: var(--gray-bg); border-left-color: var(--gray-2); opacity: 0.7; }
.cal-date   { font-family: 'DM Mono', monospace; font-size: 12px; color: var(--text-lt); white-space: nowrap; font-weight: 700; }
.cal-event-main { min-width: 0; }
.cal-event-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 5px;
}
.cal-time   { font-family: 'DM Mono', monospace; font-size: 12px; color: var(--gray-3); white-space: nowrap; }
.cal-title  { font-weight: 500; color: var(--text); }
.cal-loc    { font-size: 11px; color: var(--text-lt); white-space: nowrap; }
.cal-link   { text-decoration: none; color: inherit; }
.cal-link:hover .cal-title { text-decoration: underline; color: var(--blue); }
[data-theme="dark"] .cal-event {
    border-color: #2D3A4D;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
}
[data-theme="dark"] .cal-today  { background: rgba(234, 162, 52, 0.14); border-left-color: #F0B868; }
[data-theme="dark"] .cal-future { background: rgba(45, 191, 175, 0.12); border-left-color: #5EDBCE; }
[data-theme="dark"] .cal-past   { background: rgba(18, 28, 44, 0.86); border-left-color: #3A4658; }
[data-theme="dark"] .cal-title,
[data-theme="dark"] .cal-date { color: #E6EAF0; }
[data-theme="dark"] .cal-time,
[data-theme="dark"] .cal-loc { color: #8A97A8; }

/* ── DOCUMENTS ── */
.documents-wrap { display: flex; flex-wrap: wrap; gap: 12px; }
.doc-group {
    background: var(--gray-bg);
    border: 1px solid var(--gray-1);
    border-radius: 8px;
    padding: 10px 14px;
    min-width: 200px;
}
.doc-group-title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--gray-3);
    margin-bottom: 6px;
}
.doc-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.doc-link {
    color: var(--blue);
    text-decoration: none;
    font-size: 12px;
    font-family: 'DM Sans', sans-serif;
    word-break: break-all;
}
.doc-link:hover { text-decoration: underline; }

/* When Home or Settings is the active view, hide the jobs wrap + footer so
   the landing page isn't competing with a half-rendered dashboard below. */
body.home-active .main-wrap,
body.home-active .site-footer {
    display: none !important;
}

/* ── ESTIMATE DRAFTS CARD ────────────────────────────────────────────── */
.drafts-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}
.draft-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: var(--gray-bg);
    border: 1px solid var(--gray-2);
    border-radius: 8px;
}
.draft-row-main { flex: 1; min-width: 0; }
.draft-row-title { font-weight: 600; font-size: 14px; color: var(--text); }
.draft-row-meta  { font-size: 12px; color: var(--gray-3); margin-top: 2px; }
.draft-row-scope { font-size: 12px; color: var(--text); margin-top: 4px; white-space: pre-wrap; }
.draft-row-age { font-style: italic; }
.draft-row-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

/* ── OFFLINE CHIP ─────────────────────────────────────────────────────── */
#offline-chip {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0) + 4px);
    left: 50%;
    transform: translateX(-50%);
    background: #fef3c7;
    color: #92400e;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 9500;
}
#offline-chip[hidden] { display: none; }

/* ── PULL-TO-REFRESH PILL ─────────────────────────────────────────────── */
#ptr-pill {
    position: fixed;
    top: 0;
    left: 50%;
    width: 36px;
    height: 36px;
    background: var(--white);
    border: 1px solid var(--gray-2);
    border-radius: 999px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -60px);
    z-index: 9500;
}
#ptr-pill.ptr-visible { pointer-events: auto; }
.ptr-spinner {
    display: block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--gray-3);
    border-top-color: var(--blue);
    transition: transform 0.1s linear;
}
#ptr-pill.ptr-ready .ptr-spinner { border-color: var(--blue); }
@keyframes ptr-spin { to { transform: rotate(360deg); } }
#ptr-pill.ptr-spinning .ptr-spinner {
    animation: ptr-spin 0.9s linear infinite;
}

/* ── TOAST ─────────────────────────────────────────────────────────────
   iOS-style glass banner. A fixed stack container at the top center holds
   multiple toasts so concurrent notifications layer cleanly instead of
   replacing each other. Each toast is a frosted-glass card with a soft
   accent on the icon (no full-panel color flood). */
.mpro-toast-stack {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 78px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    z-index: 10000;
    width: min(calc(100vw - 24px), 520px);
}

/* Mobile — header is 52px instead of 64px, and we want extra room
   away from the iPhone Dynamic Island / notch. */
@media (max-width: 768px) {
    .mpro-toast-stack { top: calc(env(safe-area-inset-top, 0px) + 64px); }
}
html.mobile-touch-ui .mpro-toast-stack {
    top: calc(env(safe-area-inset-top, 0px) + 64px);
}

.mpro-toast {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: auto;
    max-width: 100%;
    padding: 11px 38px 11px 14px;
    border-radius: 20px;
    background: rgba(30, 30, 40, 0.55);
    -webkit-backdrop-filter: blur(28px) saturate(170%);
    backdrop-filter: blur(28px) saturate(170%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.22),
        0 12px 36px rgba(0, 0, 0, 0.22);
    color: #fff;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1px;
    line-height: 1.35;
    pointer-events: auto;
    cursor: pointer;
    transform: translateY(-12px);
    opacity: 0;
    transition:
        transform 200ms cubic-bezier(0.2, 0.9, 0.25, 1.1),
        opacity 200ms ease;
}
.mpro-toast-visible {
    transform: translateY(0);
    opacity: 1;
}

/* Light-theme adaptive material — lighter glass, less blur. */
html:not([data-theme="dark"]) .mpro-toast {
    background: rgba(255, 255, 255, 0.78);
    -webkit-backdrop-filter: blur(22px) saturate(150%);
    backdrop-filter: blur(22px) saturate(150%);
    border-color: rgba(255, 255, 255, 0.55);
    color: #1B3350;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.65),
        0 12px 36px rgba(15, 26, 45, 0.18);
}

.mpro-toast-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.18);
    color: inherit;
}
.mpro-toast-msg {
    flex: 1;
    min-width: 0;
}
.mpro-toast-close {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    padding: 0;
    color: inherit;
    opacity: 0.55;
    cursor: pointer;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1;
    font-family: inherit;
    transition: opacity 150ms ease, background-color 150ms ease;
}
.mpro-toast-close:hover,
.mpro-toast-close:focus-visible {
    opacity: 0.95;
    background: rgba(127, 127, 127, 0.14);
    outline: none;
}

/* Subtle state accent — only the icon chip is colored, panel stays glass. */
.mpro-toast-success .mpro-toast-icon { background: rgba(48, 209, 88, 0.32);  color: #30D158; }
.mpro-toast-error   .mpro-toast-icon { background: rgba(255, 69, 58, 0.32);  color: #FF453A; }
.mpro-toast-warning .mpro-toast-icon { background: rgba(255, 159, 10, 0.32); color: #FF9F0A; }
.mpro-toast-info    .mpro-toast-icon { background: rgba(10, 132, 255, 0.32); color: #0A84FF; }

html:not([data-theme="dark"]) .mpro-toast-success .mpro-toast-icon { background: rgba(48, 209, 88, 0.18);  color: #248A3D; }
html:not([data-theme="dark"]) .mpro-toast-error   .mpro-toast-icon { background: rgba(255, 69, 58, 0.18);  color: #C92127; }
html:not([data-theme="dark"]) .mpro-toast-warning .mpro-toast-icon { background: rgba(255, 159, 10, 0.18); color: #B25E00; }
html:not([data-theme="dark"]) .mpro-toast-info    .mpro-toast-icon { background: rgba(10, 132, 255, 0.18); color: #0040DD; }

/* iOS18 desktop — the surrounding chrome is darker glass; nudge the
   stack a hair lower to clear the wider header pills. */
body.ios18-desktop .mpro-toast-stack {
    top: calc(env(safe-area-inset-top, 0px) + 86px);
}

/* Map as its own full-page view — hide the footer and stretch the map
   container to the viewport height. */
body.map-active .site-footer { display: none !important; }
body.map-active #map-container {
    width: 100%;
    height: calc(100vh - 200px);
    min-height: 480px;
}
@media (max-width: 768px) {
    body.map-active #map-container {
        height: calc(100vh - 140px);
    }
}

/* ── FOOTER ── */
.site-footer {
    text-align: center;
    color: var(--gray-3);
    font-size: 11px;
    padding: 20px;
    letter-spacing: 0.5px;
}

/* ── DOC IMPORT BUTTONS ── */
.doc-import-btns {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}
.doc-import-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    background: transparent;
    color: var(--navy);
    border: 1px solid var(--navy);
    border-radius: 5px;
    padding: 0 12px;
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    letter-spacing: 0.3px;
    transition: all 0.15s;
    text-decoration: none;
    text-transform: none;
    white-space: nowrap;
    box-sizing: border-box;
}
.doc-import-btn:hover  { background: var(--navy); color: var(--white); }
.doc-import-btn:disabled { opacity: 0.5; cursor: wait; }

/* ── DOC IMPORT MODAL ── */
.dim-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 9000;
}

/* ── Card preview modal — large, glasses-free legibility ── */
#card-preview-modal {
    cursor: pointer;
}
#card-preview-modal .dim-overlay {
    background: rgba(0,0,0,0.65);
    z-index: 9100;
    opacity: 0;
    transition: opacity 0.32s ease-out;
}
#card-preview-modal.is-open .dim-overlay { opacity: 1; }
#card-preview-modal.is-closing .dim-overlay {
    opacity: 0;
    transition: opacity 0.28s ease-in;
}
.card-preview-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.7);
    background: var(--white);
    border-radius: 14px;
    padding: 32px 28px 24px;
    width: min(520px, 92vw);
    z-index: 9101;
    box-shadow: 0 12px 48px rgba(0,0,0,0.35);
    text-align: center;
    opacity: 0;
    transition: opacity 0.42s ease-out, transform 0.42s cubic-bezier(0.2, 0.9, 0.3, 1.25);
}
#card-preview-modal.is-open .card-preview-box {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}
#card-preview-modal.is-closing .card-preview-box {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.78);
    transition: opacity 0.28s ease-in, transform 0.28s ease-in;
}
[data-theme="dark"] .card-preview-box { background: var(--gray-1); }

/* ── Estimate preview modal — fullscreen PDF iframe ── */
#estimate-preview-modal .dim-overlay {
    background: rgba(0,0,0,0.7);
    z-index: 9200;
    opacity: 0;
    transition: opacity 0.2s ease-out;
}
#estimate-preview-modal.is-open .dim-overlay { opacity: 1; }
#estimate-preview-modal.is-closing .dim-overlay { opacity: 0; }
.estimate-preview-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(960px, 96vw);
    height: 92vh;
    background: var(--white);
    border-radius: 10px;
    z-index: 9201;
    box-shadow: 0 16px 56px rgba(0,0,0,0.45);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.2s ease-out;
}
#estimate-preview-modal.is-open .estimate-preview-box { opacity: 1; }
#estimate-preview-modal.is-closing .estimate-preview-box { opacity: 0; }
[data-theme="dark"] .estimate-preview-box { background: var(--gray-1); }
.estimate-preview-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--navy);
    color: var(--white);
    font-size: 14px;
    font-weight: 600;
    flex: 0 0 auto;
}
.estimate-preview-title {
    font-family: 'DM Mono', ui-monospace, monospace;
    letter-spacing: 0.5px;
}
.estimate-preview-close {
    background: transparent;
    border: 0;
    color: var(--white);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 0 8px;
}
.estimate-preview-close:hover { opacity: 0.7; }
.estimate-preview-body {
    flex: 1 1 auto;
    position: relative;
    background: #2b2b2b;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.estimate-preview-pages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
}
.estimate-preview-page {
    display: block;
    width: 100%;
    height: auto;
    background: var(--white);
    box-shadow: 0 2px 12px rgba(0,0,0,0.5);
    border-radius: 2px;
}
.estimate-preview-loading,
.estimate-preview-error {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ddd;
    font-size: 15px;
    text-align: center;
    padding: 20px;
}
.estimate-preview-error { color: #ff8888; }
@media (max-width: 640px) {
    .estimate-preview-box {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        top: 0;
        left: 0;
        transform: none;
    }
}
.card-preview-jobnum {
    font-family: 'DM Mono', ui-monospace, monospace;
    font-size: 14px;
    color: var(--text-lt);
    letter-spacing: 1px;
    margin-bottom: 14px;
}
.card-preview-addr {
    font-size: 32px;
    font-weight: 800;
    color: var(--navy);
    line-height: 1.15;
    word-break: break-word;
}
[data-theme="dark"] .card-preview-addr { color: var(--text); }
.card-preview-city {
    font-size: 24px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.25;
    margin-top: 4px;
    word-break: break-word;
}
.card-preview-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-lt);
    line-height: 1.3;
    margin-top: 14px;
    word-break: break-word;
}
.card-preview-next {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 16px;
    padding: 8px 14px;
    background: var(--gray-1);
    border-radius: 999px;
    max-width: 100%;
}
[data-theme="dark"] .card-preview-next { background: var(--gray-2); }
.card-preview-next-lbl {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--gray-3);
}
.card-preview-next-val {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    word-break: break-word;
}
.card-preview-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
    margin-top: 22px;
    flex-wrap: wrap;
}
.card-preview-maps {
    display: inline-block;
    font-size: 14px;
    color: var(--blue);
    text-decoration: underline;
    text-underline-offset: 3px;
}
.card-preview-share {
    background: var(--blue);
    color: var(--white);
    border: none;
    border-radius: 999px;
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}
.card-preview-share:hover { background: var(--navy); }
.card-preview-hint {
    margin-top: 22px;
    font-size: 11px;
    color: var(--gray-3);
    letter-spacing: 1.2px;
    text-transform: uppercase;
}
.doc-modal-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--white);
    border-radius: 10px;
    padding: 28px 28px 22px;
    width: min(480px, 90vw);
    z-index: 9001;
    box-shadow: 0 8px 40px rgba(0,0,0,0.25);
}
.doc-modal-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 20px;
    letter-spacing: 1.5px;
    color: var(--navy);
    margin-bottom: 18px;
}
.doc-modal-row {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
    font-size: 13px;
    align-items: flex-start;
}
.doc-modal-label {
    font-weight: 700;
    color: var(--navy);
    min-width: 90px;
    flex-shrink: 0;
}
.doc-modal-val {
    color: var(--gray-2);
    word-break: break-all;
}
.doc-modal-dest {
    font-size: 11px;
    color: var(--gray-3);
}
.doc-modal-warn {
    font-size: 12px;
    color: var(--warning);
}
.doc-modal-hint {
    font-size: 12px;
    color: var(--text-lt);
}
.doc-modal-input-warn {
    border-color: var(--warning);
}
.doc-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}
.doc-modal-cancel {
    background: transparent;
    color: var(--gray-2);
    border: 1px solid var(--gray-3);
    border-radius: 6px;
    padding: 7px 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.doc-modal-cancel:hover { background: var(--gray-1); }
.doc-modal-confirm {
    background: var(--navy);
    color: var(--white);
    border: none;
    border-radius: 6px;
    padding: 7px 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.doc-modal-confirm:hover { background: var(--blue); }
.doc-modal-confirm:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.doc-modal-confirm:disabled:hover { background: var(--navy); }

/* ── HOME DEPOT MATERIAL PICKER ── */
.hd-price-btn {
    height: 26px;
    padding: 0 9px;
}
.material-price-main {
    font-weight: 800;
    color: var(--navy);
    white-space: nowrap;
}
.material-price-sub {
    margin-top: 2px;
    font-size: 11px;
    color: var(--gray-3);
    white-space: nowrap;
}
.material-hd-link {
    display: inline-flex;
    margin-left: 6px;
    font-size: 11px;
    font-weight: 800;
    color: var(--blue);
    text-decoration: none;
}
.material-hd-cell {
    text-align: right;
}
.material-card-list {
    display: grid;
    gap: 10px;
}
.material-card-row {
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.96));
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 6px 18px rgba(15, 27, 45, 0.06);
}
.material-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.material-card-title {
    min-width: 0;
    flex: 1 1 auto;
    align-items: flex-start;
}
.material-card-title .material-desc {
    font-size: 15px;
    font-weight: 750;
    color: var(--navy);
    line-height: 1.25;
    overflow-wrap: anywhere;
}
.material-card-detail {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    color: var(--gray-3);
    font-size: 12.5px;
    line-height: 1.35;
}
.material-card-dot {
    opacity: 0.65;
}
.material-card-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
}
.material-card-metric {
    min-width: 0;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 10px;
    background: rgba(248, 250, 252, 0.82);
    padding: 8px 10px;
}
.material-card-metric span {
    display: block;
    color: var(--gray-3);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}
.material-card-metric strong {
    display: block;
    margin-top: 2px;
    color: var(--navy);
    font-family: 'DM Mono', ui-monospace, monospace;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.material-card-notes {
    margin-top: 10px;
    border-left: 3px solid rgba(213, 106, 21, 0.36);
    padding: 7px 10px;
    border-radius: 8px;
    background: rgba(213, 106, 21, 0.06);
    color: var(--text-lt);
    font-size: 13px;
    line-height: 1.45;
}
.material-card-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
.material-card-action {
    min-width: 90px;
    justify-content: center;
}
[data-theme="dark"] .material-card-row {
    background: linear-gradient(180deg, rgba(26, 35, 50, 0.98), rgba(18, 28, 44, 0.96));
    border-color: #2D3A4D;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}
[data-theme="dark"] .material-card-row:hover {
    border-color: #3B4B62;
}
[data-theme="dark"] .material-card-title .material-desc {
    color: #E6EAF0;
}
[data-theme="dark"] .material-card-detail,
[data-theme="dark"] .material-card-metric span {
    color: #8A97A8;
}
[data-theme="dark"] .material-card-metric {
    background: rgba(10, 18, 32, 0.42);
    border-color: #2A3545;
}
[data-theme="dark"] .material-card-metric strong {
    color: #E6EAF0;
}
[data-theme="dark"] .material-card-notes {
    background: rgba(240, 141, 60, 0.10);
    border-left-color: rgba(240, 141, 60, 0.50);
    color: #B6BEC9;
}
.hd-picker-box {
    width: min(720px, 94vw);
    max-height: 86vh;
    overflow: auto;
}
.hd-result-list {
    display: grid;
    gap: 10px;
}
.hd-result-card {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    width: 100%;
    padding: 10px;
    background: #fff;
    border: 1px solid var(--gray-1);
    border-radius: 10px;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}
.hd-result-card:hover {
    border-color: var(--blue);
    box-shadow: 0 4px 14px rgba(15, 27, 45, 0.10);
}
.hd-result-thumb {
    width: 54px;
    height: 54px;
    object-fit: contain;
    background: #F7F9FC;
    border-radius: 8px;
}
.hd-result-thumb-empty {
    border: 1px dashed var(--gray-2);
}
.hd-result-main {
    display: grid;
    gap: 4px;
    min-width: 0;
}
.hd-result-main strong {
    font-size: 13px;
    line-height: 1.25;
}
.hd-result-main span {
    font-size: 12px;
    color: var(--gray-3);
}
.hd-result-price {
    font-size: 14px;
    font-weight: 900;
    color: var(--navy);
    white-space: nowrap;
}
[data-theme="dark"] .material-price-main,
[data-theme="dark"] .hd-result-price {
    color: #E6EAF0;
}
[data-theme="dark"] .hd-result-card {
    background: #151C28;
    border-color: #2A3545;
    color: #E6EAF0;
}
[data-theme="dark"] .hd-result-thumb {
    background: #0E1420;
}

/* ── INVOICE NUMBER IN PAYMENTS ── */
.inv-num {
    font-size: 11px;
    font-weight: 600;
    color: var(--navy);
    letter-spacing: 0.3px;
}
.inv-num-empty {
    color: var(--gray-3);
}

/* ── DOC MODAL INPUTS ── */
.doc-modal-input {
    flex: 1;
    border: 1px solid var(--gray-3);
    border-radius: 5px;
    padding: 6px 10px;
    font-size: 13px;
    color: var(--navy);
    background: var(--white);
    outline: none;
    transition: border-color 0.15s;
}
.doc-modal-input:focus { border-color: var(--navy); }

.import-job-actions {
    justify-content: flex-end;
}

.import-json-picker {
    align-items: flex-start;
}

.import-json-controls {
    flex: 1;
}

/* ── CONFIRM MODAL ── */
.confirm-modal-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--white);
    border-radius: 10px;
    padding: 24px 24px 20px;
    width: 90vw;
    max-width: 420px;
    z-index: 9001;
    box-shadow: 0 8px 40px rgba(0,0,0,0.25);
}
.confirm-modal-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 22px;
    letter-spacing: 1px;
    color: var(--navy);
    margin-bottom: 8px;
}
.confirm-modal-body {
    color: var(--text-lt);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 18px;
}
.confirm-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.confirm-modal-cancel,
.confirm-modal-confirm {
    border-radius: 7px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.confirm-modal-cancel {
    background: var(--white);
    color: var(--navy);
    border: 1px solid var(--gray-2);
}
.confirm-modal-cancel:hover { background: var(--gray-1); }
.confirm-modal-confirm {
    background: var(--navy);
    color: var(--white);
    border: 1px solid var(--navy);
}
.confirm-modal-confirm:hover { background: var(--blue); }

/* ── MOBILE FLOATING COLLAPSE ── */
.mobile-collapse-btn {
    position: fixed;
    right: 16px;
    bottom: 18px;
    z-index: 7000;
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 108px;
    padding: 10px 14px;
    border: none;
    border-radius: 999px;
    background: rgba(27,51,80,0.94);
    color: var(--white);
    box-shadow: 0 8px 20px rgba(27,51,80,0.28);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.4px;
}
.mobile-collapse-btn:hover {
    background: rgba(41,104,166,0.96);
}

/* ── DRAFT STUB PANEL ── */
.draft-stub-panel {
    margin: 12px 0;
    padding: 22px 18px;
    background: linear-gradient(135deg, #F4F7FB 0%, #E9EFF8 100%);
    border: 1px dashed #2E75B6;
    border-radius: 12px;
    text-align: center;
}
.draft-stub-title {
    font-size: 16px;
    font-weight: 700;
    color: #1F3A5F;
    margin-bottom: 6px;
}
.draft-stub-sub {
    font-size: 13px;
    color: #4A5568;
    margin-bottom: 14px;
    line-height: 1.45;
}
.draft-stub-warning {
    background: #FFF4D6;
    color: #8A6D00;
    border: 1px solid #E5C870;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12.5px;
    margin: 0 auto 14px;
    max-width: 460px;
}
.draft-stub-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 10px;
}
.draft-stub-cta {
    background: #1F3A5F;
    color: #fff;
    border: 1px solid #1F3A5F;
    padding: 10px 22px;
    font-weight: 600;
    border-radius: 8px;
}
.draft-stub-cta:hover {
    background: #2E75B6;
    border-color: #2E75B6;
}
.draft-stub-hint {
    font-size: 11.5px;
    color: #767676;
    line-height: 1.4;
    max-width: 480px;
    margin: 0 auto;
}
[data-theme="dark"] .draft-stub-panel {
    background: linear-gradient(135deg, rgba(46,117,182,0.12) 0%, rgba(31,58,95,0.18) 100%);
    border-color: #4A8FCB;
}
[data-theme="dark"] .draft-stub-title { color: #C4D6EA; }
[data-theme="dark"] .draft-stub-sub,
[data-theme="dark"] .draft-stub-hint { color: #8FA4BF; }

/* Card-header timestamp line: created + updated, derived from audit_log */
.jc-timestamps {
    font-size: 11px;
    color: #767676;
    margin-top: 2px;
    letter-spacing: 0.1px;
}
[data-theme="dark"] .jc-timestamps { color: #8FA4BF; }

/* ── CONTACTS / JURISDICTIONS DIRECTORY ──────────────────────────────────
   Compact mobile-first card list. Replaces the old data-table layout.
   Public class prefix: .cdir-* (contacts directory). */

.cdir-shell {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 12px calc(env(safe-area-inset-bottom, 0px) + 100px);
    color: var(--text);
}

.cdir-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 0 8px;
}
.cdir-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 22px;
    color: var(--navy);
    letter-spacing: 1px;
}
.cdir-titlebar-actions { display: flex; gap: 8px; }
.cdir-action-btn {
    appearance: none;
    border: 0;
    border-radius: 999px;
    height: 32px;
    min-width: 32px;
    padding: 0 12px;
    background: var(--navy);
    color: #fff;
    font: 600 13px/1 'DM Sans', sans-serif;
    cursor: pointer;
    transition: filter 0.15s ease;
}
.cdir-action-btn:active { filter: brightness(0.92); }
.cdir-action-btn-secondary {
    background: transparent;
    color: var(--navy);
    border: 1px solid rgba(15, 26, 45, 0.15);
}
[data-theme="dark"] .cdir-action-btn-secondary {
    color: #E4E8ED;
    border-color: rgba(255, 255, 255, 0.20);
}

.cdir-tabs {
    display: flex;
    align-items: center;
    gap: 0;
    border-bottom: 1px solid rgba(15, 26, 45, 0.10);
    margin: 12px 0 6px;
}
[data-theme="dark"] .cdir-tabs { border-bottom-color: rgba(255, 255, 255, 0.10); }
.cdir-tab {
    appearance: none;
    background: transparent;
    border: 0;
    padding: 10px 14px;
    font: 600 14px/1 'DM Sans', sans-serif;
    color: var(--gray-3);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.cdir-tab.is-active { color: var(--navy); border-bottom-color: var(--navy); }
[data-theme="dark"] .cdir-tab.is-active { color: #E4E8ED; border-bottom-color: #E4E8ED; }
.cdir-tab-add {
    appearance: none;
    background: var(--navy);
    color: #fff;
    border: 0;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    margin-left: auto;
    margin-bottom: 4px;
    font: 700 18px/1 'DM Sans', sans-serif;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.15s ease;
}
.cdir-tab-add:active { filter: brightness(0.92); }
[data-theme="dark"] .cdir-tab-add { background: #E4E8ED; color: #0F1726; }

/* Stickybar block intentionally left empty — the legacy
   .cdir-stickybar wrapper was removed when the page-actions row
   started using the same DOM as the Jobs view (no sticky band, no
   background, no border). Selector kept as a no-op stub in case any
   in-flight HTML still references it. */
.cdir-stickybar { background: transparent; border: 0; padding: 0; }
/* iOS 18 page-actions row — same DOM as `.jobs-page-actions` on the
   Jobs view. The .cdir-page-actions modifier just gates the
   contacts-specific search-active state without colliding with the
   Jobs body class. */
body.contacts-search-active .cdir-page-actions .jobs-page-actions-default { display: none; }
body.contacts-search-active .cdir-page-actions .jobs-page-actions-search { display: flex; }
/* When search is active, let the input row stretch to fill width — the
   base .jobs-page-actions rule keeps justify-content: flex-end which
   would otherwise leave a visible "inner container" gap. */
body.contacts-search-active .cdir-page-actions { justify-content: stretch; }

/* Strip the default iOS <input type="search"> chrome (border, rounded
   corners, native cancel button). The Jobs view does this by ID for
   its own input; this selector covers any input inside the shared
   .jobs-action-search-field class so the contacts copy looks the same. */
.jobs-action-search-field input[type="search"] {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: 0;
    outline: 0;
    color: inherit;
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    padding: 0;
    -webkit-appearance: none;
    appearance: none;
}
.jobs-action-search-field input[type="search"]::placeholder { color: var(--gray-3, #7A8694); }
.jobs-action-search-field input[type="search"]::-webkit-search-cancel-button { display: none; }
.jobs-action-search-field input[type="search"]::-webkit-search-decoration,
.jobs-action-search-field input[type="search"]::-webkit-search-results-button,
.jobs-action-search-field input[type="search"]::-webkit-search-results-decoration { display: none; }

/* Sticky page-actions row — stays at the top of the viewport (just
   under the fixed site-header) while the card list scrolls. Glass
   tint + backdrop blur so content scrolling underneath stays visible
   without bleeding through. */
.cdir-page-actions {
    position: sticky;
    top: 52px;
    z-index: 5;
    background: rgba(245, 247, 250, 0.78);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    backdrop-filter: blur(20px) saturate(160%);
    border-radius: 14px;
    margin: 6px 0 8px;
}
[data-theme="dark"] .cdir-page-actions {
    background: rgba(15, 23, 38, 0.65);
}
@media (min-width: 769px) {
    .cdir-page-actions { top: 64px; }
}

.cdir-chiprow {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    margin-top: 8px;
    padding-bottom: 2px;
    scrollbar-width: none;
}
.cdir-chiprow::-webkit-scrollbar { display: none; }
.cdir-chip {
    appearance: none;
    flex: 0 0 auto;
    border: 1px solid rgba(15, 26, 45, 0.14);
    background: transparent;
    color: var(--text-lt, #4B5563);
    border-radius: 999px;
    padding: 5px 12px;
    font: 600 12px/1 'DM Sans', sans-serif;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.cdir-chip.is-active {
    background: var(--navy);
    color: #fff;
    border-color: var(--navy);
}
[data-theme="dark"] .cdir-chip {
    border-color: rgba(255, 255, 255, 0.14);
    color: #C7D0DD;
}
[data-theme="dark"] .cdir-chip.is-active {
    background: #E4E8ED;
    color: #0F1726;
    border-color: #E4E8ED;
}

.cdir-sortrow {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 12px;
}
.cdir-sortlabel { color: var(--gray-3); font-weight: 600; }
.cdir-sort {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid rgba(15, 26, 45, 0.14);
    background: transparent;
    color: inherit;
    border-radius: 8px;
    padding: 4px 22px 4px 8px;
    font: 600 12px/1 'DM Sans', sans-serif;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%237A8694' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    cursor: pointer;
}
[data-theme="dark"] .cdir-sort { border-color: rgba(255,255,255,0.14); }

.cdir-list { padding-top: 8px; }
.cdir-count {
    font-size: 12px;
    color: var(--gray-3);
    margin: 4px 2px 8px;
}
.cdir-empty {
    padding: 24px 12px;
    text-align: center;
    color: var(--gray-3);
    font-size: 14px;
}

.cdir-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--white, #fff);
    border: 0;
    border-bottom: 1px solid rgba(15, 26, 45, 0.06);
    border-radius: 0;
    padding: 0;
    margin: 0;
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
.cdir-card:first-of-type { border-top-left-radius: 14px; border-top-right-radius: 14px; }
.cdir-card:last-of-type {
    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 14px;
    border-bottom: 0;
}
.cdir-list > .cdir-card {
    background: var(--white, #fff);
}
[data-theme="dark"] .cdir-card {
    background: rgba(28, 32, 42, 0.72);
    border-bottom-color: rgba(255, 255, 255, 0.06);
}
.cdir-card.is-open {
    background: var(--white, #fff);
    box-shadow: 0 8px 22px rgba(15, 26, 45, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.6);
    margin: 6px 0;
    border-radius: 14px;
    border-bottom: 0;
}
[data-theme="dark"] .cdir-card.is-open {
    background: rgba(40, 44, 56, 0.92);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.40);
}

.cdir-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    min-height: 64px;
}
.cdir-card-text {
    flex: 1;
    min-width: 0;
}
.cdir-card-title {
    font: 600 16px/1.2 'DM Sans', sans-serif;
    color: var(--text);
    letter-spacing: 0.1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cdir-card-sub {
    display: block;
    font: 500 12px/1.3 'DM Sans', sans-serif;
    color: var(--gray-3);
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
[data-theme="dark"] .cdir-card-sub { color: #8FA4BF; }

.cdir-pill {
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 4px 10px;
    font: 700 11px/1 'DM Sans', sans-serif;
    letter-spacing: 0.2px;
}
.cdir-pill-jobs {
    background: rgba(46, 117, 182, 0.12);
    color: #1E5A8C;
}
[data-theme="dark"] .cdir-pill-jobs { background: rgba(124, 173, 217, 0.18); color: #A6CCEE; }
.cdir-pill-muted {
    background: rgba(15, 26, 45, 0.06);
    color: var(--gray-3);
}
[data-theme="dark"] .cdir-pill-muted { background: rgba(255,255,255,0.06); color: #8FA4BF; }

/* Portal button — right-aligned, primary action on Jurisdiction rows. */
.cdir-portal-btn {
    appearance: none;
    border: 0;
    border-radius: 999px;
    padding: 7px 12px 7px 10px;
    background: var(--navy);
    color: #fff;
    font: 600 12px/1 'DM Sans', sans-serif;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: filter 0.15s ease;
}
.cdir-portal-btn:active { filter: brightness(0.92); }
.cdir-portal-btn svg { width: 14px; height: 14px; }
.cdir-portal-none {
    flex: 0 0 auto;
    font: 600 11px/1 'DM Sans', sans-serif;
    color: var(--gray-3);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.cdir-card-body {
    border-top: 1px solid rgba(15, 26, 45, 0.06);
    padding: 10px 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
[data-theme="dark"] .cdir-card-body { border-top-color: rgba(255,255,255,0.06); }
.cdir-line {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    border-bottom: 1px dashed rgba(15, 26, 45, 0.04);
}
.cdir-line:last-of-type { border-bottom: 0; }
[data-theme="dark"] .cdir-line { color: #E4E8ED; border-bottom-color: rgba(255,255,255,0.04); }
.cdir-line-icon {
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-3);
}
.cdir-line-icon svg { width: 18px; height: 18px; }
.cdir-line-tel { color: var(--navy); font-weight: 600; }
[data-theme="dark"] .cdir-line-tel { color: #B6D5F1; }
.cdir-line-mail { color: var(--blue, #2E75B6); font-weight: 500; }
[data-theme="dark"] .cdir-line-mail { color: #9CC8EE; }
.cdir-line-link { color: var(--blue, #2E75B6); font-weight: 500; }
[data-theme="dark"] .cdir-line-link { color: #9CC8EE; }
.cdir-line-static { color: var(--text-lt, #4B5563); }
.cdir-line-muted { color: var(--gray-3); font-style: italic; }
.cdir-line-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.cdir-notes {
    font-size: 12px;
    color: var(--gray-3);
    padding: 6px 0;
    line-height: 1.45;
}
[data-theme="dark"] .cdir-notes { color: #8FA4BF; }

.cdir-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.cdir-btn {
    appearance: none;
    flex: 1 1 auto;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 999px;
    border: 0;
    font: 600 13px/1 'DM Sans', sans-serif;
    cursor: pointer;
    transition: filter 0.15s ease, background-color 0.15s ease;
}
.cdir-btn-primary { background: var(--navy); color: #fff; }
.cdir-btn-primary:active { filter: brightness(0.92); }
.cdir-btn-secondary {
    background: rgba(15, 26, 45, 0.06);
    color: var(--text);
}
.cdir-btn-secondary:active { background: rgba(15, 26, 45, 0.10); }
[data-theme="dark"] .cdir-btn-secondary {
    background: rgba(255,255,255,0.10);
    color: #E4E8ED;
}
.cdir-btn-ghost {
    background: transparent;
    color: var(--blue, #2E75B6);
    flex: 0 1 auto;
}
.cdir-btn-ghost:active { background: rgba(46, 117, 182, 0.10); }

/* Highlighted match text inside titles / values. */
.cdir-card mark.hl,
.cdir-line mark.hl,
.cdir-contact-card mark.hl {
    background: rgba(255, 235, 100, 0.55);
    color: inherit;
    border-radius: 3px;
    padding: 0 2px;
}
[data-theme="dark"] .cdir-card mark.hl,
[data-theme="dark"] .cdir-line mark.hl,
[data-theme="dark"] .cdir-contact-card mark.hl {
    background: rgba(255, 220, 90, 0.30);
}

/* Group sections — a thin top hairline + a small label so the listing
   reads like an iOS grouped table. The first group has no top hairline
   so it doesn't double-up on the row above. */
.cdir-group {
    margin-top: 18px;
}
.cdir-group:first-of-type { margin-top: 6px; }
.cdir-group-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 4px 8px;
    border-top: 0.5px solid rgba(15, 26, 45, 0.18);
}
.cdir-group:first-of-type .cdir-group-head { border-top: 0; }
.cdir-group-name {
    font: 700 11px/1 'DM Sans', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-lt, #4B5563);
}
.cdir-group-count {
    font: 600 11px/1 'DM Sans', sans-serif;
    color: var(--gray-3);
}
[data-theme="dark"] .cdir-group-head { border-top-color: rgba(255, 255, 255, 0.14); }
[data-theme="dark"] .cdir-group-name { color: #C7D0DD; }
[data-theme="dark"] .cdir-group-count { color: #8FA4BF; }
.cdir-group-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Tweaks for .contact-card-row when used inside the directory: a
   secondary line for city/company, and small "+ Job" / "Edit" pills
   that sit alongside the phone action pill. */
.cdir-contact-card .contact-card-sub {
    font: 500 12px/1.3 'DM Sans', sans-serif;
    color: var(--gray-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
[data-theme="dark"] .cdir-contact-card .contact-card-sub { color: #8FA4BF; }

.cdir-contact-card .contact-card-notes-static {
    font: 500 12px/1.45 'DM Sans', sans-serif;
    color: var(--gray-3);
    padding-top: 2px;
}
[data-theme="dark"] .cdir-contact-card .contact-card-notes-static { color: #8FA4BF; }

.cdir-mini-btn {
    appearance: none;
    border: 0;
    border-radius: 999px;
    height: 30px;
    padding: 0 12px;
    background: var(--navy);
    color: #fff;
    font: 600 12px/1 'DM Sans', sans-serif;
    cursor: pointer;
    transition: filter 0.15s ease;
}
.cdir-mini-btn:active { filter: brightness(0.92); }
.cdir-mini-btn-ghost {
    background: transparent;
    color: var(--text-lt, #4B5563);
    border: 1px solid rgba(15, 26, 45, 0.14);
}
[data-theme="dark"] .cdir-mini-btn-ghost {
    color: #C7D0DD;
    border-color: rgba(255, 255, 255, 0.14);
}

/* Field label inside add/edit modals — kept consistent with the new cards. */
.cdir-fld-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--gray-3);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* Flash animation when a card is opened via deep-link from elsewhere. */
@keyframes cdir-flash {
    0%   { box-shadow: 0 0 0 0 rgba(46, 117, 182, 0.45); }
    50%  { box-shadow: 0 0 0 8px rgba(46, 117, 182, 0.10); }
    100% { box-shadow: 0 0 0 0 rgba(46, 117, 182, 0.0); }
}
.cdir-card.jur-detail-flash,
.jur-detail-flash {
    animation: cdir-flash 1.4s ease-out;
}

@media (max-width: 480px) {
    .cdir-shell { padding: 0 8px calc(env(safe-area-inset-bottom, 0px) + 100px); }
    .cdir-card-head { padding: 10px 12px; min-height: 60px; }
    .cdir-card.is-open { margin: 4px 0; }
    .cdir-stickybar { top: 52px; }
}
