/* =============================================================================
   Lease Rate Quote — estimator + host CRM integration styles
   Tokens: css/brand.css (load first). Auth shell / client-library / document-history
   provide chrome; this file styles the New Quote panel and host-only UI.
   ============================================================================= */

/* Estimator page styles (New Quote panel); chrome comes from auth-shell */
.lease-estimator-root {
      font: 14px/1.45 var(--font);
      color: var(--ink);
      position: relative;
      padding: 0 0 48px;
      min-height: 0;
    }

    /* Brand mesh decoration */
    .lease-estimator-root::before {
      content: "";
      position: fixed;
      top: 0; right: 0;
      width: min(52vw, 520px);
      height: min(42vh, 360px);
      background: var(--brand-mesh-top, url("../Brand/DiscoverDistrict_ExtraElements_Shapes_RED.png")) top right / contain no-repeat;
      opacity: .12;
      pointer-events: none;
      z-index: 0;
    }
    .lease-estimator-root::after {
      content: "";
      position: fixed;
      bottom: 0; left: 0;
      width: min(48vw, 480px);
      height: min(36vh, 300px);
      background: var(--brand-mesh-bottom, url("../Brand/DiscoverDistrict_ExtraElements_Shapes-50oppacity.png")) bottom left / contain no-repeat;
      opacity: .35;
      pointer-events: none;
      z-index: 0;
    }

    .wrap { max-width: 1080px; margin: 0 auto; padding: 16px 14px 0; position: relative; z-index: 1; }

    .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
    .btn {
      appearance: none; border: 1px solid var(--line); background: var(--card);
      color: var(--ink); font: inherit; font-weight: 600; font-size: 13px;
      border-radius: 8px; padding: 8px 12px; cursor: pointer;
      display: inline-flex; align-items: center; gap: 6px;
      transition: background .12s, border-color .12s, color .12s;
      white-space: nowrap;
    }
    .btn:hover { background: #fafafa; border-color: #ccc; }
    .btn:active { transform: translateY(1px); }
    .btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
    .btn-primary:hover { background: var(--brand-d); border-color: var(--brand-d); }
    .btn-sm { font-size: 12px; padding: 6px 10px; font-weight: 600; }
    .btn-danger { color: var(--brand); border-color: #f0c4c8; }
    .btn-danger:hover { background: var(--brand-tint); }
    .icon { width: 15px; height: 15px; flex-shrink: 0; }

    .card {
      background: var(--card);
      border: 1px solid #e0e0e0;
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      margin-bottom: 12px;
    }
    .card-pad { padding: 14px 16px; }
    .card-head {
      display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
      gap: 8px; margin-bottom: 12px;
    }
    .section-label {
      font-size: 11px; font-weight: 700; letter-spacing: .07em;
      text-transform: uppercase; color: var(--brand); margin: 0;
    }
    .hint { font-size: 12px; color: var(--muted); margin: 2px 0 0; }

    /* Required + empty validation */
    .req {
      color: var(--brand);
      font-weight: 700;
      margin-left: 1px;
    }
    .field input.is-empty,
    .input-row input.is-empty,
    .notes-area.is-empty {
      background: #fff1f2 !important;
      border-color: #f0a8b0 !important;
      box-shadow: inset 0 0 0 1px rgba(192, 32, 48, 0.12);
    }
    .field input.is-empty {
      border-bottom: 1.5px solid #e85a66 !important;
      border-radius: 4px 4px 0 0;
      padding-left: 4px;
      padding-right: 4px;
    }
    .input-box.has-empty {
      border-color: #f0a8b0;
      background: #fff8f8;
    }
    .field input.is-empty:focus,
    .input-row input.is-empty:focus,
    .notes-area.is-empty:focus {
      box-shadow: 0 0 0 3px rgba(192, 32, 48, 0.14);
      border-color: var(--brand) !important;
    }
    .field {
      display: flex; align-items: center; gap: 8px; min-width: 0;
    }
    .field label {
      color: var(--muted); font-size: 12px; flex-shrink: 0; min-width: 3.6rem;
    }
    .field input {
      flex: 1; min-width: 0; border: 0; border-bottom: 1px solid #ccc;
      background: transparent; font: inherit; font-weight: 600; color: var(--ink);
      padding: 3px 2px; outline: none;
    }
    .field input:focus { border-color: var(--brand); }
    .field.end { justify-content: flex-end; }
    @media (min-width: 641px) {
      .field.end label { text-align: right; }
    }

    .input-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 10px;
    }
    @media (max-width: 720px) { .input-grid { grid-template-columns: 1fr; } }

    .input-box {
      border: 1px solid var(--line);
      background: #fafafa;
      border-radius: 9px;
      padding: 10px 12px;
    }
    .input-box label {
      display: block; font-size: 10px; font-weight: 700;
      letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
      margin-bottom: 6px;
    }
    .input-row { display: flex; align-items: center; gap: 6px; }
    .input-row .prefix, .input-row .suffix {
      color: var(--muted); font-weight: 600; font-size: 13px;
    }
    .input-row input[type="number"] {
      width: 100%; border: 1px solid #ccc; border-radius: 7px;
      background: #fff; font: inherit; font-size: 1.55rem; font-weight: 650;
      letter-spacing: -.03em; color: var(--ink); padding: 7px 10px;
      outline: none; font-variant-numeric: tabular-nums;
    }
    .input-row input[type="number"]:focus {
      border-color: var(--brand);
      box-shadow: 0 0 0 3px rgba(192, 32, 48, .12);
    }
    .input-box .note { margin-top: 5px; font-size: 10px; color: #999; }

    .metrics {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 12px 16px;
    }
    @media (max-width: 800px) { .metrics { grid-template-columns: 1fr 1fr; } }
    @media (max-width: 480px) { .metrics { grid-template-columns: 1fr; } }

    .metric-label { font-size: 12px; color: var(--muted); font-weight: 500; }
    .metric-value {
      font-size: 1.05rem; font-weight: 650; color: var(--ink);
      font-variant-numeric: tabular-nums; margin-top: 2px;
    }
    .metric-value .unit { font-size: 12px; font-weight: 500; color: #999; margin-left: 4px; }
    .metric-sub { font-size: 10px; color: var(--ok); margin-top: 2px; }
    .metric-total {
      grid-column: 1 / -1;
      border-top: 1px solid var(--line);
      padding-top: 10px;
      display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
    }
    .metric-total .big {
      font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--brand);
    }
    .pill {
      font-size: 11px; background: var(--brand-tint); color: var(--brand-d);
      border-radius: 6px; padding: 3px 8px; font-weight: 600;
    }

    .stats {
      display: flex; flex-wrap: wrap; gap: 8px 14px;
      padding: 10px 16px;
      border-top: 1px solid var(--line);
      background: #fafafa;
      border-radius: 0 0 var(--radius) var(--radius);
      font-size: 12px; color: var(--muted);
    }
    .stats strong { color: var(--ink); font-variant-numeric: tabular-nums; }
    .stats .best { color: var(--ok); }

    .preset-row { display: flex; flex-wrap: wrap; gap: 6px; }
    .chip-label {
      font-size: 10px; font-weight: 700; letter-spacing: .05em;
      text-transform: uppercase; color: var(--muted); margin: 0 0 6px;
    }
    .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
    .chips:last-child { margin-bottom: 0; }
    .chip {
      appearance: none; border: 1px solid #ccc; background: #fff;
      color: #333; font: inherit; font-size: 12.5px; font-weight: 600;
      border-radius: 999px; padding: 5px 11px; cursor: pointer;
      transition: background .1s, color .1s, border-color .1s;
    }
    .chip:hover { background: #fafafa; }
    .chip.on-cap { background: var(--brand); border-color: var(--brand); color: #fff; }
    .chip.on-allow { background: #1a1a1a; border-color: #1a1a1a; color: #fff; }
    .chip.on-full { background: #5c1a22; border-color: #5c1a22; color: #fff; }
    .chip-note { font-size: 10px; color: #999; margin-top: 8px; line-height: 1.4; }

    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table.results {
      width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px;
    }
    table.results th {
      text-align: left; font-size: 10px; font-weight: 700;
      letter-spacing: .04em; text-transform: uppercase; color: #fff;
      padding: 9px 12px; border-bottom: 1px solid var(--brand-d);
      background: var(--brand); white-space: nowrap;
    }
    table.results th.num, table.results td.num { text-align: right; }
    table.results td {
      padding: 9px 12px; border-bottom: 1px solid #f0f0f0;
      vertical-align: middle; font-variant-numeric: tabular-nums;
    }
    table.results tbody tr:nth-child(even) { background: #fafafa; }
    table.results tbody tr.best-row { background: #f0faf5; }
    table.results tbody tr:hover { background: #f5f5f5; }
    table.results tbody tr.best-row:hover { background: #e6f6ee; }
    .cap-badge {
      display: inline-block; font-size: 11px; font-weight: 700;
      background: var(--ink); color: #fff; border-radius: 4px; padding: 2px 6px;
    }
    .rate-cell { font-weight: 700; color: var(--brand); }
    .rate-cell small { display: block; font-size: 10px; font-weight: 500; color: #999; }
    .best-tag {
      display: inline-block; margin-left: 6px; font-size: 9px; font-weight: 700;
      letter-spacing: .04em; text-transform: uppercase;
      background: #d1fae5; color: var(--ok); border-radius: 4px; padding: 1px 5px;
      vertical-align: middle;
    }
    .empty { text-align: center; color: #999; padding: 28px 12px !important; }
    .table-foot {
      padding: 8px 14px; font-size: 11px; color: var(--muted);
      border-top: 1px solid var(--line); background: #fafafa;
      display: flex; flex-wrap: wrap; gap: 6px 12px;
    }

    details.raw {
      background: var(--card); border: 1px solid #e0e0e0;
      border-radius: var(--radius); box-shadow: var(--shadow);
      margin-bottom: 12px;
    }
    details.raw > summary {
      list-style: none; cursor: pointer; padding: 12px 16px;
      font-weight: 650; font-size: 13px; color: #333;
      display: flex; align-items: center; justify-content: space-between; gap: 10px;
      user-select: none;
    }
    details.raw > summary::-webkit-details-marker { display: none; }
    details.raw > summary::before {
      content: "▸"; color: var(--brand); font-size: 12px; transition: transform .12s;
    }
    details.raw[open] > summary::before { transform: rotate(90deg); }
    .raw-body { padding: 0 16px 16px; border-top: 1px solid var(--line); }
    .raw-grid {
      display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding-top: 14px;
    }
    @media (max-width: 700px) { .raw-grid { grid-template-columns: 1fr; } }
    .raw-grid h3 { margin: 0 0 8px; font-size: 13px; color: var(--brand-d); }
    .kv { display: flex; justify-content: space-between; gap: 10px;
      padding: 5px 0; border-bottom: 1px solid #f0f0f0; font-size: 13px; }
    .kv span:first-child { color: var(--muted); }
    .kv span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
    .mono-box {
      font-family: var(--mono); font-size: 11px; line-height: 1.55;
      background: #fafafa; border: 1px solid var(--line); border-radius: 8px;
      padding: 10px 12px;
    }
    .alloc-grid {
      display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px;
    }
    @media (max-width: 600px) { .alloc-grid { grid-template-columns: 1fr; } }
    .alloc-card {
      background: #fafafa; border: 1px solid var(--line); border-radius: 8px; padding: 10px;
    }
    .alloc-card.hl { background: var(--brand-tint); border-color: var(--brand-soft); }
    .alloc-card .t { font-size: 11px; color: var(--muted); }
    .alloc-card .v { font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
    .alloc-card .f { font-size: 11px; font-family: var(--mono); color: var(--muted); margin-top: 6px; }
    #raw-scenarios { margin-top: 10px; }
    #raw-scenarios .sc {
      border-bottom: 1px solid var(--line); padding: 6px 0; font-size: 11px;
      font-family: var(--mono); line-height: 1.45;
    }
    #raw-scenarios .sc:last-child { border-bottom: 0; }

    .disclaimer {
      font-size: 11px; color: var(--muted); line-height: 1.5; margin: 4px 2px 0;
    }
    .toast {
      position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(12px);
      background: var(--ink); color: #fff; font-size: 13px; font-weight: 550;
      padding: 9px 14px; border-radius: 8px; opacity: 0; pointer-events: none;
      transition: opacity .18s, transform .18s; z-index: 50; box-shadow: 0 8px 24px rgba(0,0,0,.18);
    }
    .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

    /* Charts */
    .viz-grid {
      display: grid;
      grid-template-columns: minmax(200px, 280px) 1fr;
      gap: 16px 20px;
      align-items: start;
    }
    @media (max-width: 780px) { .viz-grid { grid-template-columns: 1fr; } }
    .viz-panel h3 {
      margin: 0 0 8px;
      font-size: 12px;
      font-weight: 700;
      letter-spacing: .04em;
      text-transform: uppercase;
      color: var(--brand);
    }
    .viz-panel .viz-sub {
      font-size: 11px; color: var(--muted); margin: -4px 0 10px;
    }
    .chart-box { width: 100%; overflow: hidden; }
    .chart-box svg { display: block; width: 100%; height: auto; max-height: 280px; }
    .legend {
      display: flex; flex-wrap: wrap; gap: 8px 14px;
      margin-top: 8px; font-size: 11px; color: var(--muted);
    }
    .legend span { display: inline-flex; align-items: center; gap: 5px; }
    .swatch {
      width: 10px; height: 10px; border-radius: 2px; display: inline-block;
    }
    .viz-empty {
      font-size: 12px; color: #999; padding: 24px 8px; text-align: center;
    }

    /* Notes */
    .notes-area {
      width: 100%;
      min-height: 96px;
      resize: vertical;
      border: 1px solid #ccc;
      border-radius: 8px;
      padding: 10px 12px;
      font: inherit;
      line-height: 1.45;
      color: var(--ink);
      background: #fff;
      outline: none;
    }
    .notes-area:focus {
      border-color: var(--brand);
      box-shadow: 0 0 0 3px rgba(192, 32, 48, .12);
    }
    .notes-area::placeholder { color: #aaa; }

    .notes-kind-label {
      display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
      font-size: 12px; font-weight: 700; color: var(--ink); margin: 0;
    }
    .notes-badge {
      font-size: 10px; font-weight: 700; letter-spacing: .04em;
      text-transform: uppercase; border-radius: 4px; padding: 2px 6px;
    }
    .notes-badge-public {
      color: var(--ok, #0f6b4c); background: #e8f5ef; border: 1px solid #b7e0c8;
    }
    .notes-badge-internal {
      color: #92400e; background: #fff7ed; border: 1px solid #fcd34d;
    }
    .notes-area-internal {
      background: #fffdf8;
      border-color: #f0d9a8;
    }
    .notes-meta {
      display: flex; justify-content: space-between; gap: 8px;
      margin-top: 6px; font-size: 11px; color: #999;
    }

    @media print {
      body { background: #fff; padding: 0; }
      .lease-estimator-root::before, .lease-estimator-root::after, .actions, .preset-row, details.raw, .toast { display: none !important; }
      .card { box-shadow: none; break-inside: avoid; }
        }
  

    
    /* Auth shell: #login-screen { display:flex } overrides [hidden] — force hide */
    #login-screen[hidden],
    #app-screen[hidden],
    .panel[hidden],
    [hidden] {
      display: none !important;
    }

    /* ===== Host integration (estimator panel + CRM panels) ===== */
    .lease-estimator .field {
      display: flex;
      align-items: center;
      gap: 8px;
      min-width: 0;
      flex: initial;
      margin-bottom: 0;
    }
    .lease-estimator .field label {
      color: var(--muted);
      font-size: 12px;
      flex-shrink: 0;
      min-width: 3.6rem;
      margin-bottom: 0;
      font-weight: 500;
      font-family: var(--font);
    }
    .lease-estimator .field input {
      flex: 1;
      min-width: 0;
      width: auto;
      border: 0;
      border-bottom: 1px solid #ccc;
      background: transparent;
      font: inherit;
      font-weight: 600;
      color: var(--ink);
      padding: 3px 2px;
      outline: none;
    }
    .lease-estimator .field input:focus {
      border-color: var(--brand);
      outline: none;
      box-shadow: none;
    }
    .lease-estimator .btn {
      appearance: none;
      border: 1px solid var(--line);
      background: var(--card);
      color: var(--ink);
      font: inherit;
      font-weight: 600;
      font-size: 13px;
      border-radius: 8px;
      padding: 8px 12px;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      transition: background .12s, border-color .12s, color .12s;
      white-space: nowrap;
      width: auto;
      margin-top: 0;
    }
    .lease-estimator .btn:hover { background: #fafafa; border-color: #ccc; }
    .lease-estimator .btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
    .lease-estimator .btn-primary:hover { background: var(--brand-d); border-color: var(--brand-d); }
    .lease-estimator .btn-sm { font-size: 12px; padding: 6px 10px; font-weight: 600; }
    .lease-estimator .btn-danger { color: var(--brand); border-color: #f0c4c8; }
    .lease-estimator .btn-danger:hover { background: var(--brand-tint); }

    /* Auth shell panel wraps estimator; remove double white box padding feel */
    #panel-estimator.panel {
      background: transparent;
      border: 0;
      padding: 0;
      box-shadow: none;
    }
    #panel-estimator.panel > h2.visually-hidden {
      position: absolute;
      width: 1px; height: 1px;
      padding: 0; margin: -1px;
      overflow: hidden; clip: rect(0,0,0,0);
      white-space: nowrap; border: 0;
    }
    .container.container-wide {
      max-width: 1120px;
    }

    /* Client library + history inside lease mockup */
    #estimator-client-block fieldset { min-width: 0; }
    #estimator-client-block .client-combobox-row input {
      font: 14px/1.45 var(--font);
    }

    /*
     * Shared surface radius — match New Quote .card (var(--radius) = 10px)
     * so History / Prospects / detail feel consistent.
     */
    #panel-history .dh-kpi,
    #panel-history .history-mine-summary .stat-card,
    #panel-history .table-wrap,
    #panel-history .detail-grid,
    #panel-detail .table-wrap,
    #panel-detail .detail-grid,
    #panel-detail #detail-quote-wrap,
    #panel-clients .table-wrap,
    #panel-clients .profile-card,
    #panel-clients .profile-empty,
    #panel-clients .client-profile-card,
    #panel-clients .client-none-state,
    #panel-profile .profile-card,
    #panel-profile fieldset,
    #panel-changelog .card,
    #estimator-client-block.card,
    #estimator-client-block .client-profile-card,
    #estimator-client-block .client-none-state,
    .modal-dialog {
      border-radius: var(--radius) !important;
      overflow: hidden;
    }

    #panel-history .dh-kpi,
    #panel-history .history-mine-summary .stat-card,
    #panel-history .table-wrap,
    #panel-detail .detail-grid,
    #panel-detail #detail-quote-wrap,
    #panel-clients .table-wrap,
    #panel-clients .profile-card,
    #panel-clients .profile-empty,
    #panel-clients .client-profile-card,
    #panel-profile .profile-card,
    #panel-changelog .card {
      border: 1px solid #e0e0e0;
      box-shadow: var(--shadow);
      background: #fff;
    }

    /* Search inputs — same soft radius as New Quote meta fields */
    #panel-history input[type="search"],
    #panel-clients input[type="search"],
    #panel-detail select,
    #panel-clients input[type="text"],
    #panel-clients input[type="email"],
    #panel-clients input[type="tel"],
    #panel-clients select,
    #panel-profile input[type="text"],
    #panel-profile input[type="email"],
    #panel-profile input[type="tel"],
    #client-modal input[type="text"],
    #client-modal input[type="email"],
    #client-modal input[type="tel"],
    #client-modal select,
    #estimator-client-block input[type="search"] {
      border-radius: 8px !important;
      border-color: var(--line, #e0e0e0) !important;
    }

    /* Buttons on CRM panels — match New Quote .btn radius */
    #panel-history .btn,
    #panel-clients .btn,
    #panel-detail .btn,
    #panel-profile .btn,
    #panel-changelog .btn,
    #client-modal .btn,
    #export-modal .btn,
    #preview-modal .btn {
      border-radius: 8px !important;
    }

    /* Scope switch already 8px; keep outer radius consistent */
    #panel-history .history-scope-switch {
      border-radius: 8px;
    }

    /* Combobox suggestions list */
    #panel-clients .client-suggestions,
    #estimator-client-block .client-suggestions {
      border-radius: 0 0 var(--radius) var(--radius);
    }
    #estimator-client-block .client-combobox-row input,
    #panel-clients .client-combobox-row input {
      border-radius: 8px;
    }

    /* Table header cells: soft top radius only on wrap container */
    #panel-history .table-wrap,
    #panel-clients .table-wrap {
      background: #fff;
    }

    /* Profile empty / detail boxes */
    #panel-clients .profile-empty,
    #panel-clients #client-detail-box.profile-empty {
      border: 1px dashed #d0d0d0;
      border-radius: var(--radius) !important;
      padding: 16px;
      background: #fafafa;
    }
    #panel-clients .profile-card {
      border: 1px solid #e0e0e0;
    }
    #panel-clients .profile-card-header {
      border-radius: var(--radius) var(--radius) 0 0;
    }

    /* Detail status bar select + quote frame container */
    #panel-detail .dh-detail-status select {
      border-radius: 8px;
    }
    #panel-detail #detail-quote-wrap {
      border: 1px solid #e0e0e0;
      box-shadow: var(--shadow);
    }
    #panel-history h2,
    #panel-clients h2,
    #panel-detail h2,
    #panel-changelog h2 {
      font-family: Arial, Helvetica, sans-serif;
      color: var(--brand);
    }
    #panel-history,
    #panel-clients,
    #panel-detail,
    #panel-changelog {
      max-width: 1100px;
      margin: 0 auto;
      padding: 8px 14px 32px;
    }
    /* History page head — match Rental mockup (title left, scope switch right) */
    .quote-page-head {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      align-items: center;
      gap: 10px;
      margin-bottom: 12px;
    }
    .quote-page-head h2 {
      margin: 0;
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }
    .history-scope-switch {
      display: inline-flex;
      border: 1px solid var(--brand, #c02030);
      border-radius: 8px;
      overflow: hidden;
      font-family: Arial, Helvetica, sans-serif;
      flex-shrink: 0;
    }
    .history-scope-tab {
      border: none;
      background: #fff;
      color: var(--brand, #c02030);
      padding: 8px 14px;
      font: inherit;
      font-size: 0.78rem;
      font-weight: 700;
      letter-spacing: 0.05em;
      text-transform: uppercase;
      cursor: pointer;
      margin: 0;
    }
    .history-scope-tab + .history-scope-tab {
      border-left: 1px solid var(--brand, #c02030);
    }
    .history-scope-tab:hover { background: #fdf2f3; }
    .history-scope-tab.is-active {
      background: var(--brand, #c02030);
      color: #fff;
    }
    .history-mine-summary {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
      gap: 10px;
      margin-bottom: 14px;
    }
    .history-mine-summary .stat-card {
      background: #fff;
      border: 1px solid #e8c5c9;
      padding: 12px 14px;
      font-family: Arial, Helvetica, sans-serif;
    }
    .history-mine-summary .stat-card .stat-label {
      font-size: 0.72rem;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      color: #64748b;
      font-weight: bold;
      margin: 0 0 4px;
    }
    .history-mine-summary .stat-card .stat-value {
      font-size: 1.15rem;
      font-weight: bold;
      color: var(--brand, #c02030);
      margin: 0;
    }
    .history-mine-summary .stat-card .stat-sub {
      font-size: 0.75rem;
      color: #888;
      margin: 4px 0 0;
    }
    /* Panel / section headings in all caps on key CRM screens */
    #panel-history h2,
    #panel-clients h2,
    #panel-detail h2,
    #panel-changelog h2,
    #panel-profile h2 {
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }
    /* Stock client-library still emits eligibility cells — hide on Prospects page */
    #clients-table th[data-sort="rate_category"],
    #clients-table tbody td:nth-child(4) {
      display: none !important;
    }
    #client-profile .cp-cell:has(#cp-eligibility),
    #cp-eligibility {
      /* fallback if :has unsupported — also hide by label cell below */
    }
    #estimator-client-block #cp-eligibility,
    #estimator-client-block .cp-cell:has(#cp-eligibility) {
      display: none !important;
    }
    /* Hide eligibility cell in picker grid (3rd cell) */
    #client-profile .client-profile-grid .cp-cell:nth-child(3) {
      display: none !important;
    }
    /* Hide required rate field in modal but keep in DOM for stock JS validation defaults */
    #client-modal .field:has(#modal_rate_category) {
      display: none !important;
    }
    .app-footer .app-footer-link {
      background: none;
      border: none;
      padding: 0;
      margin: 0;
      font: inherit;
      font-size: inherit;
      color: inherit;
      cursor: pointer;
      text-decoration: underline;
      text-underline-offset: 2px;
      vertical-align: baseline;
    }
    .app-footer .app-footer-link:hover {
      color: var(--brand, #c02030);
    }
    .modal-root { z-index: 2000; }
    .btn-save-quote { font-weight: 600; }
    .est-toolbar-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      align-items: center;
    }
    .est-toolbar-bottom {
      margin-top: 16px;
      margin-bottom: 8px;
    }
    .est-meta-fields {
      display: flex;
      flex-wrap: wrap;
      gap: 10px 16px;
      margin-top: 10px;
      align-items: flex-end;
    }
    .est-meta-fields .meta-field {
      display: flex;
      flex-direction: column;
      gap: 3px;
      min-width: 0;
    }
    .est-meta-fields .meta-field label {
      font-size: 10px;
      font-weight: 700;
      letter-spacing: .05em;
      text-transform: uppercase;
      color: var(--muted);
      min-width: 0;
    }
    .est-meta-fields .meta-field input {
      border: 1px solid var(--line);
      border-radius: 7px;
      background: #fff;
      font: inherit;
      font-weight: 600;
      font-size: 13px;
      color: var(--ink);
      padding: 6px 8px;
      min-width: 5.5rem;
      max-width: 9rem;
    }
    .est-meta-fields .meta-field input:focus {
      outline: none;
      border-color: var(--brand);
      box-shadow: 0 0 0 3px rgba(192, 32, 48, 0.12);
    }
    .est-meta-fields .meta-field input#quote-number {
      font-family: var(--mono);
      letter-spacing: .04em;
      color: var(--brand);
      max-width: 8rem;
    }
    .est-meta-fields .meta-field input#revision {
      max-width: 4.5rem;
    }
    .est-meta-fields .meta-field input#doc-date {
      max-width: 7.5rem;
    }
    @media (max-width: 640px) {
      .est-meta-fields .meta-field input {
        max-width: none;
        width: 100%;
      }
      .est-meta-fields .meta-field {
        flex: 1 1 40%;
      }
    }
    /* Export / preview modals (reuse client-library modal shell) */
    #export-modal .export-actions,
    #preview-modal .export-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      margin-top: 8px;
    }
    #export-modal .export-actions .btn {
      min-width: 7.5rem;
      justify-content: center;
    }
    #preview-modal .modal-dialog {
      max-width: min(920px, 96vw);
      width: 100%;
    }
    #preview-frame {
      width: 100%;
      min-height: min(70vh, 640px);
      border: 1px solid var(--line, #ddd);
      border-radius: 8px;
      background: #fff;
    }
    #export-modal-subtitle {
      margin: 0 0 12px;
      font-family: Arial, Helvetica, sans-serif;
      font-size: 13px;
      color: var(--muted, #5c5c5c);
    }

    /* Host: New Quote CTA (not in stock auth-shell tabs) */
    .tabs-right {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 8px;
      margin-left: auto;
      flex-shrink: 0;
    }
    .tab-cta {
      appearance: none;
      border: 1px solid rgba(255, 255, 255, 0.85);
      background: #fff;
      color: var(--brand, #c02030);
      font: inherit;
      font-size: 0.88rem;
      font-weight: 700;
      padding: 8px 16px;
      border-radius: 6px;
      cursor: pointer;
      white-space: nowrap;
    }
    .tab-cta:hover {
      background: var(--brand-tint, #fdf2f3);
      color: var(--brand-d, #9a1826);
    }
    .tab-cta.is-active {
      background: var(--brand, #c02030);
      border-color: var(--brand, #c02030);
      color: #fff;
      box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
    }
    /* Keep app footer clear of estimator decoration */
    .app-footer {
      position: relative;
      z-index: 2;
    }
    #panel-changelog {
      max-width: 720px;
      margin: 0 auto;
      padding: 8px 14px 32px;
      font-family: Arial, Helvetica, sans-serif;
    }
