:root {
    /* Navy theme — soft, desaturated navy page background with off-white
       (never pure-white) text to keep long reading sessions easy on the
       eyes. --graphite stays dark (it was already the topbar's color, now
       just blends with the page instead of standing apart from it);
       --graphite-2 is repurposed as a light "heading" tone since its only
       consumers (h2, .match-model) are text, never a background. */
    --graphite: #121820;
    --graphite-2: #e8edf5;
    --paper: #1a2332;
    --ink: #dfe3e8;
    --muted: #93a0b8;
    --line: #34435f;
    /* RepWare brand colors -- tile oklch(0.58 0.15 42) converted to sRGB. */
    --copper: #c15627;
    --copper-dark: #9a451f;
    /* Brighter stand-in for --copper-dark specifically where it's used as
       TEXT (links, prices) rather than a button fill — #9a451f reads fine
       as a fill with white text on top, but as text-on-navy it's too dark
       to read comfortably. RepWare brand cream, W oklch(0.9 0.09 92). */
    --accent-text: #f3dd99;
    --ok: #2f7a4d;
    --quoting-green: #4c9a5b;
    --info: #2b5f9c;
    --danger: #a23b3b;
    /* Dedicated fill for the "Budget" status pill — it used to reuse
       --muted, which now has to be a light tone for on-navy body text and
       would no longer work as a solid badge background. */
    --status-neutral: #5b6b85;
    --card: #232f45;
    /* Sampled directly from static/img/riello_logo.png */
    --riello-blue: #000f9a;
    --riello-red: #fe0000;
    --riello-blue-light: #4da7e5;
    --font-ui: -apple-system, "Segoe UI", "Inter", Helvetica, Arial, sans-serif;
    --font-mono: "SF Mono", "Consolas", "Menlo", monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    background: var(--graphite);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 32px;
    border-bottom: 3px solid var(--copper);
}
.brand-lockup { display: flex; align-items: center; gap: 12px; background: #fff; padding: 6px 16px; border-radius: 5px; }
.brand-logo-primary { height: 30px; width: auto; display: block; }
.brand-divider { width: 1px; height: 26px; background: var(--line); }
.brand-logo-secondary { height: 18px; width: auto; display: block; opacity: 0.85; }
.topbar nav { display: flex; align-items: center; gap: 20px; font-size: 14px; }
.topbar nav a { color: #d7dbe1; }
.topbar nav a:hover { color: #fff; }
.who { color: #9aa3af; }
.logout { color: #d7dbe1 !important; }

.content { max-width: 1040px; margin: 0 auto; padding: 40px 32px 80px; }
.content:has(.wide-table) { max-width: 1400px; }

h1 { font-size: 26px; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 0 0 14px; color: var(--graphite-2); }
.muted { color: var(--muted); margin-top: 0; }

/* Preview of the quote number a brand-new quote will get, shown throughout
   the create-quote flow before the quote actually exists — the same number
   generate_quote_number() computes for real at save time. */
.quote-number-pill {
    display: inline-block;
    margin: 6px 0 10px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--riello-blue, #000f9a);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* ---- Login ---- */
.login-wrap { display: flex; justify-content: center; padding-top: 64px; }
.login-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 40px 36px;
    width: 360px;
    text-align: left;
    box-shadow: 0 1px 3px rgba(20,25,32,0.06);
}
/* repware_logo_slogan.png is dark ink baked onto a solid white PNG
   background — same issue as css_logo.png below, same fix: a white plate
   behind it so it doesn't disappear into the navy card. */
.login-logo-primary { height: 34px; width: auto; display: block; margin-bottom: 14px; background: #fff; padding: 8px 14px; border-radius: 6px; }
.login-secondary-row { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; }
.login-secondary-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
/* css_logo.png is a dark logo baked onto a solid white PNG background —
   fine on the old light page, unreadable directly on navy. A small white
   backdrop (same trick as .brand-lockup in the topbar) keeps it legible. */
.login-logo-secondary { height: 16px; width: auto; display: block; background: #fff; padding: 3px 6px; border-radius: 3px; }
.login-card h1 { font-size: 22px; }
.login-card form { margin-top: 20px; display: flex; flex-direction: column; gap: 8px; }
.login-card label { font-size: 13px; color: var(--muted); }

input[type="text"], input[type="number"], input[type="date"], select, textarea {
    font-family: var(--font-ui);
    font-size: 14px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--card);
    color: var(--ink);
}
input[type="text"]:focus, input[type="number"]:focus, input[type="date"]:focus, select:focus, textarea:focus {
    outline: 2px solid var(--copper); outline-offset: 1px;
}
input[type="file"] { color: var(--ink); }
/* Date/number input pickers (calendar icon, spin buttons) render dark-on-
   transparent by default — invisible against a dark field background. */
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.8); }

button, .btn {
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 18px;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    display: inline-block;
}
.btn-primary, button[type="submit"] {
    background: var(--copper);
    color: #fff;
}
.btn-primary:hover, button[type="submit"]:hover { background: var(--copper-dark); }
.btn-secondary { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.btn-secondary:hover { border-color: var(--copper); }
button.btn-danger, .btn-danger { background: transparent; border: 1px solid #b3392f; color: #d9564a; }
button.btn-danger:hover, .btn-danger:hover { background: #b3392f; color: #fff; }

/* ---- Dashboard ---- */
.dash-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 28px; gap: 20px; }
.action-buttons { display: flex; gap: 10px; flex-shrink: 0; }

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 24px;
}

.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.sort-select { font-size: 13px; padding: 6px 8px; flex-shrink: 0; }

.quote-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.quote-table th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
    padding: 0 10px 8px;
}
.quote-table td { padding: 12px 10px; border-bottom: 1px solid var(--line); }
.quote-table tr:last-child td { border-bottom: none; }

.status-form select.status-badge, span.status-badge {
    border: none;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 4px 10px;
    border-radius: 20px;
    color: #fff;
}
span.status-badge { display: inline-block; }
.status-budget { background: var(--status-neutral); }
.status-quoting { background: var(--quoting-green); }
.status-order { background: var(--info); }
.status-closed { background: var(--ok); }
.status-lost-sale { background: var(--danger); }

.empty-state { color: var(--muted); font-style: italic; padding: 20px 0; }

/* ---- Configurator ---- */
.back-link { font-size: 13px; }
.config-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-top: 24px; align-items: start; }
/* Grid items default to min-width:auto, which refuses to shrink below the
   content's natural (unwrapped) width — without this, long text/inputs
   overflow the column instead of wrapping when the track shrinks. */
.config-layout > * { min-width: 0; }
.config-form, .match-panel, .accessories-panel { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 24px; }

.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}
.modal-box {
    background: var(--card); border: 1px solid var(--line); border-radius: 6px;
    padding: 24px; width: 90%; max-width: 420px; max-height: 90vh; overflow-y: auto;
}
/* Accessory tables (battery cabinets, bypass panels) need real width to avoid
   side-scrolling — this section sits below the two-column layout, spanning
   the full content width, rather than being squeezed into one grid column.
   Its inputs still submit with the save-form via the HTML `form` attribute. */
.accessories-panel { margin-top: 24px; }
.field { margin-bottom: 16px; display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; color: var(--muted); }
.checkbox-field label { flex-direction: row; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); }
.checkbox-field input[type="checkbox"] { width: 16px; height: 16px; }

.match-card { border: 1px solid var(--line); border-radius: 6px; padding: 16px; margin-bottom: 20px; }
.match-model { font-family: var(--font-mono); font-weight: 700; font-size: 15px; color: var(--graphite-2); margin-bottom: 10px; }
.match-card dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: 14px; }
.match-card dt { color: var(--muted); }
.match-card dd { margin: 0; text-align: right; }
.price { font-family: var(--font-mono); font-weight: 700; color: var(--accent-text); font-size: 16px; }
.runtime-chart-image { display: block; width: 100%; max-width: 480px; margin-top: 14px; border-radius: 4px; background: #fff; }

.workup-totals { display: flex; flex-wrap: wrap; gap: 16px; align-items: stretch; max-width: 620px; }
.workup-totals .match-card { flex: 1; min-width: 220px; margin-bottom: 0; }
.pip-card { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; background: rgba(193, 86, 39, 0.1); border-color: var(--copper); }
.pip-label { font-size: 12px; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 6px; }
.pip-card .price { font-size: 22px; }

/* ---- Proposal / quote detail ---- */
.proposal { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 32px; }
.proposal-head { display: flex; justify-content: space-between; border-bottom: 2px solid var(--graphite); padding-bottom: 16px; margin-bottom: 24px; }
.proposal-logo { height: 30px; width: auto; display: block; margin-bottom: 10px; }
.prepared-by { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.prepared-by-logo { height: 14px; width: auto; display: block; background: #fff; padding: 3px 6px; border-radius: 3px; }
.proposal-meta { text-align: right; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.proposal-summary { font-size: 18px; font-weight: 600; color: var(--ink); margin: 0 0 24px; }
.proposal-section { margin-bottom: 28px; }

/* Collapsible company card on /companies -- native <details>, marker
   restyled since the default triangle is nearly invisible against the
   dark theme. */
.proposal-section summary { list-style: none; }
.proposal-section summary::-webkit-details-marker { display: none; }
.proposal-section summary::before {
    content: "▸"; display: inline-block; color: var(--copper, #c67437);
    transition: transform 0.15s ease; flex-shrink: 0;
}
.proposal-section details[open] summary::before { transform: rotate(90deg); }

/* Right-side reference panel (UPS Information / Dimensions / Design &
   Installation Information / Working Clearance) — engineering detail for
   whoever's designing around the equipment. Scoped to a grid with just
   Project Contacts/UPS System/Accessories (.proposal-top-main), NOT the
   whole page — a float here breaks badly: Project Contacts can contain
   long unbroken strings (emails, combined company/location/person text)
   that don't fit the width beside a float, so the browser pushes the
   *entire table* down past the float instead of wrapping it, stranding it
   far from its own heading. A grid track has a fixed width regardless of
   content, so it can't trigger that — content wraps in place instead. */
.proposal-top-grid { display: grid; grid-template-columns: 260px 1fr; gap: 24px; align-items: start; margin-bottom: 28px; }
.proposal-top-grid > * { min-width: 0; }
.proposal-sidebar { display: flex; flex-direction: column; gap: 12px; }
.sidebar-block { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin-bottom: 0; }
.sidebar-block h2 { font-size: 12px; margin-bottom: 6px; }
.sidebar-table { font-size: 11px; max-width: none; table-layout: fixed; width: 100%; }
.sidebar-table th { padding: 3px 6px 3px 0; width: auto; font-weight: 500; overflow-wrap: break-word; }
.sidebar-table td { padding: 3px 0; overflow-wrap: break-word; }
/* Dimensions: one equipment item per row, stacked on two lines (name, then
   size/weight) instead of a 4-column table — a table forces every column
   wide enough for its worst-case value ("Maintenance Bypass Panels", "108 x
   29.5 x 78.7") which doesn't fit the narrow sidebar without wrapping or
   overflowing; stacking removes the column-width problem entirely since
   each line only has to fit itself. */
.dimensions-list { display: flex; flex-direction: column; gap: 8px; font-size: 11px; }
.dim-row + .dim-row { padding-top: 8px; border-top: 1px solid var(--line); }
.dim-main { font-weight: 500; overflow-wrap: break-word; }
.dim-sub { font-size: 10px; margin-top: 2px; overflow-wrap: break-word; }
.sidebar-note { font-size: 10px; margin: 6px 0 0; }
.spec-table { border-collapse: collapse; width: 100%; max-width: 460px; font-size: 14px; }
.spec-table th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); width: 40%; }
.spec-table td { padding: 8px 0; border-bottom: 1px solid var(--line); overflow-wrap: break-word; }
/* Thor product tables (AC/DC Power, Data-Telecom, Cable-Phone line items) —
   .spec-table's 460px cap and zero-right-padding td were built for narrow
   2-column key/value layouts and left these multi-column tables squeezed
   with no breathing room between Qty/Price/Risk Score, forcing Part Number
   to wrap onto 3 lines even with plenty of room to spare. No max-width —
   uses the full section width instead. */
.spd-products-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.spd-products-table th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px 16px 8px 0; border-bottom: 1px solid var(--line); }
.spd-products-table td { padding: 10px 16px 10px 0; border-bottom: 1px solid var(--line); overflow-wrap: break-word; }
.spd-products-table td.match-model { min-width: 220px; }
/* Project Contacts rows can contain long unbroken strings (company +
   location + person combined, including email addresses) — fixed layout
   keeps the label column a predictable width instead of the auto-layout
   algorithm trying to size it around that long content. */
.contacts-table { max-width: none; table-layout: fixed; }
.contacts-table th { width: 140px; white-space: nowrap; }
.doc-links { display: flex; flex-wrap: wrap; gap: 10px; padding: 0; list-style: none; }
.doc-links li { background: var(--paper); border: 1px dashed var(--line); border-radius: 4px; padding: 6px 12px; font-size: 13px; color: var(--muted); }
.fine-print { font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 16px; margin-top: 8px; }

.attachment-list { list-style: none; padding: 0; margin: 0 0 12px; }
.attachment-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.attachment-list li:last-child { border-bottom: none; }
.attachment-list form { margin-left: auto; }
.attachment-upload-form { display: flex; align-items: center; gap: 8px; margin-top: 12px; }

.attachment-display { display: flex; align-items: center; gap: 8px; }
.attachment-list .attachment-rename-form { display: none; align-items: center; gap: 6px; margin-left: 0; }
.attachment-rename-form input[type="text"] { min-width: 200px; }
.btn-link {
    background: none; border: none; padding: 0; color: var(--accent-text);
    font-size: 12px; cursor: pointer; text-decoration: underline;
}
.btn-link:hover { color: var(--copper); }

.dropzone-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin: 12px 0 16px; }
.dropzone {
    border: 2px dashed var(--line);
    border-radius: 8px;
    padding: 16px 10px;
    text-align: center;
    cursor: pointer;
    background: var(--card);
    transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone:focus { border-color: var(--copper); outline: none; }
.dropzone.dropzone-active { border-color: var(--copper); background: rgba(193, 86, 39, 0.12); }
.dropzone-label { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.dropzone-hint { font-size: 11px; color: var(--muted); line-height: 1.4; }

/* ---- Company / contacts panel ---- */
.company-panel { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 24px; }
.spec-panel { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.spec-panel .config-form, .spec-panel .match-panel { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 24px; }
.small { font-size: 12px; }
.company-field { border-bottom: 1px solid var(--line); padding-bottom: 14px; }
.company-field:last-child { border-bottom: none; padding-bottom: 0; }
.quoting-extra-row { margin-top: 12px; padding: 12px; border: 1px dashed var(--line); border-radius: 4px; background: var(--paper); }
.quoting-extra-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.quoting-extra-header label { font-size: 13px; color: var(--muted); }
.combo-wrap { position: relative; }
.entry-input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 4px; font-size: 14px; font-family: inherit; }
.combo-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 20;
    max-height: 260px;
    overflow-y: auto;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 4px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    margin-top: 2px;
}
.combo-result { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 8px 10px; font-size: 13px; cursor: pointer; }
.combo-result:hover, .combo-highlight { background: var(--paper); }
.combo-label { flex-shrink: 0; }
.combo-action { color: var(--accent-text); font-style: italic; }
.combo-empty { padding: 8px 10px; font-size: 13px; color: var(--muted); font-style: italic; }
.combo-level-0 { padding-left: 10px; font-weight: 600; }
.combo-level-1 { padding-left: 26px; }
.combo-level-2 { padding-left: 42px; }
.combo-edit-btn { flex-shrink: 0; font-size: 11px; padding: 2px 8px; border-radius: 3px; border: 1px solid var(--line); background: var(--card); color: var(--muted); cursor: pointer; }
.combo-edit-btn:hover { border-color: var(--copper); color: var(--accent-text); }
.add-new-form { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; background: var(--paper); border: 1px dashed var(--line); border-radius: 4px; padding: 10px; }
.add-new-form input { padding: 6px 8px; border: 1px solid var(--line); border-radius: 4px; font-size: 13px; font-family: inherit; }
.quick-add-row { margin-top: 8px; align-items: center; gap: 8px; flex-wrap: wrap; }
.quick-add-label { font-size: 12px; color: var(--muted); }
.quick-add-company { color: var(--ink); }
.btn-small { padding: 5px 12px; font-size: 12px; }

/* ---- "View all quotes" staff toggle (Dashboard / Equipment Opportunities) ---- */
.view-all-toggle-form { margin: 6px 0 18px; }
.view-all-toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.view-all-toggle input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.view-all-toggle-track {
    position: relative; width: 38px; height: 22px; border-radius: 11px; background: var(--line);
    transition: background .15s; flex-shrink: 0;
}
.view-all-toggle-thumb {
    position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
    background: var(--paper); transition: left .15s;
}
.view-all-toggle input:checked + .view-all-toggle-track { background: var(--copper); }
.view-all-toggle input:checked + .view-all-toggle-track .view-all-toggle-thumb { left: 18px; }
.view-all-toggle-label { font-size: 13px; color: var(--muted); }

/* ---- Project Notes (type or sketch) ---- */
.notes-mode-toggle { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.notes-mode-btn.active { background: var(--copper); color: #fff; border-color: var(--copper); }
.notes-textarea {
    width: 100%; min-height: 160px; padding: 10px 12px; font-family: inherit; font-size: 14px;
    color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 4px;
    resize: vertical;
}
.notes-sketch-toolbar { margin-bottom: 8px; }
.notes-sketch-canvas {
    display: block; width: 100%; max-width: 900px; height: auto; aspect-ratio: 900 / 500;
    background: #fff; border: 1px solid var(--line); border-radius: 4px;
    touch-action: none; cursor: crosshair;
}

/* ---- Job Status share links ---- */
.share-link-field {
    width: 220px; font-size: 12px; color: var(--muted); background: var(--paper);
    border: 1px solid var(--line); border-radius: 4px; padding: 4px 6px; margin-right: 4px;
}

/* ---- Flash notices ---- */
.flash-notice {
    background: var(--paper);
    border: 1px solid var(--copper);
    border-left: 4px solid var(--copper);
    border-radius: 4px;
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--ink);
}

/* ---- Product family picker ---- */
.family-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 24px; }
.family-card {
    display: block;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 18px;
    color: var(--ink);
}
.family-card:hover { border-color: var(--copper); }
.family-name { font-weight: 700; margin-bottom: 6px; }
.family-subtext { font-size: 12px; color: var(--muted); }
.family-card.disabled { opacity: 0.5; cursor: default; }
.family-card.disabled:hover { border-color: var(--line); }

/* ---- Accessories / line items ---- */
.line-items-table { border-collapse: collapse; width: 100%; max-width: 620px; font-size: 14px; margin-bottom: 10px; }
.line-items-table th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); }
.line-items-table td { padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); }
.grand-total { font-size: 16px; margin-top: 10px; }
.accessory-group { border: 1px solid var(--line); border-radius: 6px; padding: 16px; margin-bottom: 16px; }
.accessory-group h3 { margin-top: 0; }
.accessory-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); gap: 12px; }
.accessory-row:last-child { border-bottom: none; }
.accessory-row .desc { font-size: 13px; color: var(--muted); flex: 1; }
.mode-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.mode-tabs a { padding: 8px 16px; border-radius: 4px; border: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.mode-tabs a.active { background: var(--copper); color: #fff; border-color: var(--copper); }

.chip-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.chip-filter-label { font-size: 13px; color: var(--muted); }
/* Stacks multiple filter dimensions (Breaker size / Mount / kAIC / SKRU)
   one per row instead of letting them run together in one wrapping line —
   each row is still a plain .chip-filter internally. */
.chip-filter-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.chip-filter-group .chip-filter { margin-bottom: 0; }
.filter-chip { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 13px; cursor: pointer; }
.filter-chip:hover { border-color: var(--copper); }
.filter-chip-active { background: var(--copper); border-color: var(--copper); color: #fff; }
/* Radio-backed chips (XPCC's Platform/Batteries/Runtime pickers) — same
   look as the JS filter chips, but a real <input type="radio"> drives the
   selection so picking one submits the surrounding form and lets the
   server re-narrow the candidate list, rather than filtering client-side. */
.pill-radio { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.3; gap: 1px; }
.pill-radio input[type="radio"] { position: absolute; opacity: 0; width: 0; height: 0; }
.pill-note { font-size: 11px; }
.filter-chip-active .pill-note { color: rgba(255, 255, 255, 0.85); }

/* An option that doesn't apply to the current selection: dimmed, with a faint
   X drawn corner to corner. Still clickable, since picking it switches the
   selection. */
.filter-chip-excluded {
    opacity: 0.55;
    --x-line: rgba(255, 255, 255, 0.28);
    background-image:
        linear-gradient(to top right, transparent calc(50% - 0.5px), var(--x-line) calc(50% - 0.5px), var(--x-line) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
        linear-gradient(to bottom right, transparent calc(50% - 0.5px), var(--x-line) calc(50% - 0.5px), var(--x-line) calc(50% + 0.5px), transparent calc(50% + 0.5px));
}
.filter-chip-excluded:hover { opacity: 0.85; }
.table-scroll { overflow-x: auto; margin-bottom: 10px; }
.table-scroll .line-items-table { margin-bottom: 0; }
.wide-table { max-width: none; width: max-content; min-width: 100%; white-space: nowrap; }
/* Left-aligned but with equal-width digits, so the first digit of every
   value in a numeric column lines up vertically regardless of how many
   digits follow (e.g. "7 min" vs "11.3 min"). */
.wide-table td.num, .wide-table th.num { font-variant-numeric: tabular-nums; }

/* Equipment Opportunities table — unlike .wide-table, this wraps text
   instead of forcing nowrap, so on a wide monitor it fills the (widened)
   .content column with no horizontal scrollbar; it only scrolls on a
   narrow viewport, via the same .table-scroll wrapper. */
.content:has(.equipment-table) { max-width: 1800px; }
.equipment-table { width: 100%; table-layout: auto; }
.equipment-table td.num, .equipment-table th.num { font-variant-numeric: tabular-nums; }
.equipment-table th.sortable { cursor: pointer; user-select: none; }
.equipment-table th.sortable:hover { color: var(--ink); }
.equipment-table .sort-indicator { display: inline-block; width: 10px; color: var(--copper); }

.xb-select-table .xb-selected-mark { color: var(--accent-text); font-weight: 600; font-size: 12px; white-space: nowrap; }
.xb-select-table tr.xb-row-selected { background: rgba(193, 86, 39, 0.14); }
.xb-select-table tr.xb-row-selected td:first-child { border-left: 3px solid var(--copper); }
.xb-select-table td.desc { white-space: normal; max-width: 260px; }
.xb-panel-box { border: 1px dashed var(--line); border-radius: 4px; padding: 10px 12px; margin-top: 6px; background: var(--paper); }
.xb-panel-box .checkbox-field { display: inline-block; margin-right: 16px; }

/* Miscellaneous accessory tables (Startup, Options, TCE Raceway, GTT) —
   wider than the 620px default so Model/Description need less wrapping.
   width:max-content (rather than the base rule's width:100%) lets the table
   actually grow to fit these column widths instead of being squeezed back
   down to its container, scrolling horizontally via .table-scroll if the
   container is narrower. */
.misc-table { width: max-content; min-width: 100%; max-width: 900px; }
.misc-table th:nth-child(2), .misc-table td:nth-child(2) { width: 220px; }
.misc-table th:nth-child(3), .misc-table td:nth-child(3) { width: 480px; white-space: normal; }
/* Pricing workup's Item column holds long accessory descriptions — wrap
   it instead of inheriting .wide-table's nowrap, so the numeric/multiplier
   columns stay in view without side-scrolling. */
.pricing-table td:first-child { white-space: normal; max-width: 360px; }
.custom-consult-note { background: var(--paper); border: 1px dashed var(--line); border-radius: 4px; padding: 14px 16px; }

/* "Add Another Product" divider — a deliberately heavy rule so a second
   (or third) UPS product on the same quote reads as a clear break, not
   just another section. */
.product-divider { margin: 36px 0 20px; }
.product-divider hr { border: none; border-top: 3px solid var(--riello-blue-light, #4da7e5); margin: 0 0 10px; }
.product-divider-label { margin: 0; color: var(--riello-blue-light, #4da7e5); }
.product-divider-row td { padding-top: 20px; border-top: 3px solid var(--riello-blue-light, #4da7e5); color: var(--riello-blue-light, #4da7e5); }

/* ---- Responsive (phones / small tablets) ---- */
@media (max-width: 760px) {
    .config-layout { grid-template-columns: 1fr; }
    .proposal-top-grid { grid-template-columns: 1fr; }
    .dash-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 640px) {
    .content { padding: 20px 16px 60px; }
    .topbar { padding: 12px 16px; flex-wrap: wrap; gap: 10px; }
    .brand-lockup { padding: 5px 12px; }
    .topbar nav { gap: 14px; font-size: 13px; }

    .login-wrap { padding: 32px 16px 0; }
    .login-card { width: 100%; max-width: 360px; padding: 28px 20px; }

    .proposal { padding: 20px; }
    .proposal-head { flex-direction: column; align-items: flex-start; gap: 16px; }
    .proposal-meta { align-items: flex-start; text-align: left; width: 100%; }
    .prepared-by { flex-wrap: wrap; }

    /* Long combined "Company — Location — Person" strings don't fit a fixed
       label-column table on a phone; stack each row into a little label/value
       card instead of squeezing the value into a sliver next to a wide label. */
    .contacts-table th, .contacts-table td { display: block; width: auto; padding: 2px 0; border-bottom: none; }
    .contacts-table tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); }
    .contacts-table tr:last-child { border-bottom: none; }

    .action-buttons { flex-wrap: wrap; }
}

/* ---- Dashboard: section badges, opportunities, news ticker ---- */
.section-badges { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.section-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}
.section-badge.customers { background: var(--riello-blue-light); }
.section-badge.equipment { background: var(--riello-blue); }
.section-badge.maintenance { background: var(--riello-red); }
.section-badge.is-link:hover { filter: brightness(1.1); text-decoration: none; }

.opportunities-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }

.opportunity-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 10px 4px;
    border-bottom: 1px solid var(--line);
    gap: 10px;
    color: var(--ink);
}
.opportunity-row:last-child { border-bottom: none; }
.opportunity-row:hover { background: var(--paper); text-decoration: none; }
.opportunities-scroll { max-height: 420px; overflow-y: auto; }
.opportunity-desc { flex: 1; overflow-wrap: break-word; white-space: normal; min-width: 0; }
.opportunity-value { font-family: var(--font-mono); color: var(--accent-text); font-weight: 600; white-space: nowrap; }


.news-ticker {
    position: sticky;
    bottom: 0;
    margin: 32px -32px 0;
    background: var(--riello-blue);
    color: #fff;
    border-top: 3px solid var(--riello-red);
    overflow: hidden;
    white-space: nowrap;
}
.news-ticker-label {
    position: relative;
    z-index: 2;
    display: inline-block;
    background: var(--riello-red);
    color: #fff;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 10px 16px;
    vertical-align: middle;
}
.news-ticker-track {
    position: relative;
    z-index: 1;
    display: inline-block;
    vertical-align: middle;
    padding-left: 100%;
    animation: news-ticker-scroll 55s linear infinite;
}
.news-ticker-track span { padding: 0 40px; font-size: 13px; }
.news-ticker-track a { color: #fff; text-decoration: underline; text-decoration-color: rgba(255,255,255,0.4); }
@keyframes news-ticker-scroll {
    from { transform: translateX(0); }
    to { transform: translateX(-100%); }
}
@media (prefers-reduced-motion: reduce) {
    .news-ticker-track { animation: none; padding-left: 16px; }
}

@media (max-width: 640px) {
    .news-ticker { margin: 24px -16px 0; }
    .opportunities-grid { grid-template-columns: 1fr; }
}

/* ---- AI-suggested BOM ---- */
.bom-pending-card { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 40px; text-align: center; max-width: 480px; margin: 40px auto; }
.bom-spinner { width: 34px; height: 34px; margin: 0 auto 18px; border: 3px solid var(--line); border-top-color: var(--riello-blue-light); border-radius: 50%; animation: bom-spin 0.9s linear infinite; }
@keyframes bom-spin { to { transform: rotate(360deg); } }
.bom-error-card { border-color: var(--danger); }
.bom-error-message { color: var(--danger); font-size: 14px; margin: 10px 0 20px; }
.bom-conflict-banner { background: rgba(254, 0, 0, 0.08); border: 1px solid var(--danger); border-radius: 6px; padding: 14px 18px; margin-bottom: 24px; font-size: 13px; }
.bom-conflict-banner h4 { margin: 0 0 8px; color: var(--danger); }
.bom-conflict-banner ul { margin: 0; padding-left: 18px; }
.bom-conflict-banner li { margin-bottom: 6px; }
.bom-req-table { border-collapse: collapse; width: 100%; font-size: 13px; margin-bottom: 24px; }
.bom-req-table th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); }
.bom-req-table td { padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.bom-not-specified { color: var(--muted); font-style: italic; }
.bom-source-note { color: var(--muted); font-size: 11px; display: block; margin-top: 3px; }
.bom-gap-list { color: var(--danger); font-size: 13px; margin-bottom: 24px; }
.bom-radio-row { display: flex; align-items: baseline; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.bom-radio-row label { font-size: 14px; }
.bom-list-notes { font-size: 13px; color: var(--muted); }

.doc-links-cell { font-size: 12px; white-space: nowrap; }
.doc-links-cell a { color: var(--riello-blue-light); }

/* ---------- Thor Systems SPD sizing tool (Series TSr) ---------- */
.spd-layout { display: grid; grid-template-columns: 1fr 340px; gap: 32px; margin-top: 24px; align-items: start; }
.spd-layout > * { min-width: 0; }
.spd-layout > aside { position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow-y: auto; }
@media (max-width: 900px) { .spd-layout { grid-template-columns: 1fr; } .spd-layout > aside { position: static; max-height: none; overflow-y: visible; } }

.spd-panel { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 24px; margin-bottom: 24px; }
.spd-panel h2 { margin-top: 0; }
.spd-panel h3 { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 4px; }

.spd-crit { margin-bottom: 22px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.spd-crit:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.spd-crit-title { font-weight: 600; margin-bottom: 10px; }

.spd-chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.spd-chip {
    display: flex; align-items: center; gap: 8px;
    background: var(--paper); border: 1px solid var(--line); border-radius: 6px;
    padding: 8px 12px; color: var(--ink); font-size: 13px; cursor: pointer;
    text-align: left; line-height: 1.3;
}
.spd-chip:hover { border-color: var(--copper); }
.spd-chip.selected { border-color: var(--copper); background: rgba(193, 86, 39, 0.15); }
.spd-chip:disabled, .spd-chip-disabled { opacity: 0.4; cursor: not-allowed; }
.spd-chip:disabled:hover, .spd-chip-disabled:hover { border-color: var(--line); }
.spd-chip-col { flex-direction: column; align-items: flex-start; }
.spd-warning-banner {
    border: 1px solid var(--danger); border-radius: 6px; padding: 10px 14px; margin-top: 10px;
    font-size: 12px; color: var(--danger); background: rgba(162, 59, 59, 0.1);
}
.spd-chip-pt {
    font-family: var(--font-mono); font-weight: 700; font-size: 12px; color: var(--accent-text);
    background: rgba(193, 86, 39, 0.15); border-radius: 4px; padding: 2px 6px; flex-shrink: 0;
}
.spd-chip-sub { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }

.spd-gauge-score { font-family: var(--font-mono); font-size: 42px; font-weight: 700; color: var(--graphite-2); line-height: 1; }
.spd-gauge-score small { font-size: 16px; color: var(--muted); font-weight: 400; }
.spd-gauge-track { position: relative; height: 8px; border-radius: 4px; background: var(--paper); border: 1px solid var(--line); margin: 14px 0 10px; overflow: hidden; }
.spd-gauge-fill { position: absolute; inset: 0; width: 0%; border-radius: 4px; background: linear-gradient(90deg, var(--ok), var(--copper) 60%, var(--danger)); transition: width 0.2s ease; }
.spd-band-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 12px; color: var(--muted); }
.spd-band-row.active { color: var(--ink); font-weight: 600; }
.spd-band-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); flex-shrink: 0; }
.spd-band-row.active .spd-band-dot { background: var(--copper); }

.spd-rating-card { text-align: center; padding: 18px 0; }
.spd-rating-readout { font-family: var(--font-mono); font-size: 30px; font-weight: 700; color: var(--accent-text); }
.spd-rating-readout small { font-size: 14px; color: var(--muted); font-weight: 400; }
.spd-rating-series { font-size: 15px; font-weight: 600; margin-top: 4px; }
.spd-rating-copy { font-size: 12px; color: var(--muted); margin-top: 8px; }
.spd-flag { display: inline-block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; border-radius: 4px; padding: 3px 8px; margin-top: 8px; }
.spd-flag.warn { background: rgba(162, 59, 59, 0.15); color: var(--danger); }

.spd-nameplate { text-align: center; }
.spd-part-number { font-family: var(--font-mono); font-size: 20px; font-weight: 700; color: var(--graphite-2); word-break: break-word; }
.spd-pn-breakdown { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 10px; margin-top: 16px; }
.spd-pn-seg-code { font-family: var(--font-mono); font-weight: 700; font-size: 13px; color: var(--accent-text); }
.spd-pn-seg-label { font-size: 10px; color: var(--muted); margin-top: 2px; }
.spd-pn-seg-edit { position: relative; display: block; cursor: pointer; border: 1px dashed var(--line); border-radius: 6px; padding: 7px 2px 6px; transition: border-color .12s, background .12s; }
.spd-pn-seg-edit:hover { border-color: var(--copper); background: rgba(193, 86, 39, 0.08); }
.spd-pn-seg-edit:focus-within { border-color: var(--copper); border-style: solid; }
.spd-pn-seg-edit .spd-pn-seg-code::after { content: " \25BE"; font-size: 9px; color: var(--muted); }
.spd-pn-seg-edit select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.spd-pn-seg-edit.invalid { border-color: var(--danger); }
.spd-pn-seg-edit.invalid .spd-pn-seg-code { color: var(--danger); }
.spd-pn-seg-edit.locked { opacity: 0.45; cursor: not-allowed; border-style: dotted; }
.spd-pn-seg-edit.locked .spd-pn-seg-code::after { content: ""; }
.spd-pn-seg-edit.locked select { cursor: not-allowed; }

.spd-spec-item { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.spd-spec-item:last-child { border-bottom: none; }
.spd-spec-item .k { color: var(--muted); }

.spd-ground-flag { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 4px; padding: 4px 10px; margin-top: 8px; }
.spd-ground-flag.neutral { background: var(--paper); color: var(--muted); }
.spd-ground-flag.safe { background: rgba(47, 122, 77, 0.15); color: var(--ok); }
.spd-ground-flag.danger { background: rgba(162, 59, 59, 0.15); color: var(--danger); }
.flag-safe { color: var(--ok); }
.flag-danger { color: var(--danger); }

.spd-photo-card img { width: 100%; border-radius: 6px; display: block; }

.spd-diagram { width: 100%; height: auto; margin: 12px 0; }
.spd-diagram text { fill: var(--ink); font-family: var(--font-ui); }
.spd-diagram .spd-diagram-muted { fill: var(--muted); }
.spd-diagram .spd-diagram-line { stroke: var(--line); stroke-width: 2; fill: none; }
.spd-diagram .spd-diagram-node { fill: var(--paper); stroke: var(--line); stroke-width: 1.5; }
.spd-diagram .spd-diagram-node.hi { stroke: var(--copper); }
.spd-diagram .spd-diagram-pt { fill: var(--accent-text); font-family: var(--font-mono); font-weight: 700; }

.spd-map-thumb {
    display: block; width: 100%; padding: 0; margin-top: 4px; border: 1px solid var(--line); border-radius: 6px;
    background: #d8d8d8; cursor: zoom-in; position: relative; overflow: hidden;
}
.spd-map-thumb:hover { border-color: var(--copper); }
.spd-map-thumb img { display: block; width: 100%; height: auto; }
.spd-map-thumb-label {
    position: absolute; right: 8px; bottom: 8px; background: rgba(18, 24, 32, 0.75); color: #fff;
    font-size: 11px; padding: 3px 8px; border-radius: 4px;
}
.spd-lightbox {
    position: fixed; inset: 0; background: rgba(10, 14, 20, 0.9); z-index: 100;
    display: flex; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out;
}
.spd-lightbox[hidden] { display: none; }
.spd-lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; background: #d8d8d8; }
.spd-lightbox-close {
    position: absolute; top: 18px; right: 24px; background: none; border: none; color: #fff;
    font-size: 32px; line-height: 1; cursor: pointer; padding: 4px 10px;
}
.spd-lightbox-close:hover { color: var(--copper); }

.company-modal-backdrop {
    position: fixed; inset: 0; background: rgba(10, 14, 20, 0.72); z-index: 100;
    display: flex; align-items: center; justify-content: center; padding: 24px;
}
.company-modal-backdrop[hidden] { display: none; }
.company-modal {
    background: var(--card); border: 1px solid var(--line); border-radius: 8px;
    width: 100%; max-width: 480px; max-height: calc(100vh - 48px); overflow-y: auto;
    padding: 20px 22px; display: flex; flex-direction: column; gap: 4px;
}
.company-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.company-modal-head h3 { margin: 0; font-size: 17px; }
.company-modal-close {
    background: none; border: none; color: var(--muted); font-size: 24px; line-height: 1;
    cursor: pointer; padding: 2px 8px;
}
.company-modal-close:hover { color: var(--copper); }
.company-modal-body { display: flex; flex-direction: column; gap: 14px; }
.company-modal .modal-section { margin-top: 0; }
.company-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---- Inline save feedback (workup page) ----
   A ghost of the button you just clicked peels off and floats away, and a
   pill confirms the save landed — the acknowledgement that replaces the
   full-page reload those buttons used to do. */
@keyframes btn-ghost-fly {
    from { opacity: 0.8; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(-42px) scale(1.08); }
}
.btn-ghost-fly {
    animation: btn-ghost-fly 0.65s cubic-bezier(0.2, 0.6, 0.3, 1) forwards;
}
@keyframes inline-save-flag-rise {
    0% { opacity: 0; transform: translate(-50%, -100%) translateY(8px); }
    18% { opacity: 1; transform: translate(-50%, -100%) translateY(-2px); }
    75% { opacity: 1; transform: translate(-50%, -100%) translateY(-10px); }
    100% { opacity: 0; transform: translate(-50%, -100%) translateY(-22px); }
}
.inline-save-flag {
    position: fixed;
    z-index: 2001;
    pointer-events: none;
    white-space: nowrap;
    padding: 5px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    background: var(--ok);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    animation: inline-save-flag-rise 1.8s ease-out forwards;
}
.inline-save-flag.is-error {
    background: var(--danger);
    animation-duration: 5s;
}

/* ---- Companies admin: deactivate / delete ---- */
.company-inactive { opacity: 0.7; }
.company-danger-zone { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; }
.company-danger-zone h3 { margin: 0; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.company-danger-zone form { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.company-danger-zone p { margin: 0; }
.company-delete-form input[type="text"] { width: 100%; max-width: 320px; }
