/* SyntaxFlow — documents, budgets and projects: the shared pieces.
   ===========================================================================
   Loaded on top of base.css by the pages of the Documents area and My
   projects only. Built from base.css tokens, so light and dark come free.

   DESIGN PLAN — "live paper"
     Layout   the desk on one side (what you type, photograph and measure), the
              paper on the other: the real A4 or Letter page, updating as you
              type, at the size it will print. On a phone the two are tabs.
     Colour   the sixth world, Documents: drafting-ink indigo with the red of a
              marking pencil. On the paper itself, black ink on white, always:
              it is a document, not a screen, and it prints the same.
     Type     Archivo, the site's face, set wider for the documents' headings;
              measurements and references in the monospace, with tabular figures.
     Motion   only as an answer: a photo lands on the paper, a line moves where
              it was dragged, a saved state ticks. Nothing loops.
   =========================================================================== */
:root{
  --docs:#1f2547; --docs-ink:#eef0fa; --docs-ink2:#c5c9e6; --pencil:#ff8a6b;
  --pencil-ink:#b5381f;                    /* the pencil as text on white: 5.5 : 1 */
  --desk:#e6e9ee; --sheet:#ffffff; --sheet-ink:#1b1f24; --sheet-ink2:#4a525c; --sheet-rule:#d9dde3;
}
@media (prefers-color-scheme: dark){
  :root{ --desk:#0c1013; --pencil-ink:#ff9b80; }
}

/* buttons the tools add to base.css's .btn */
.btn.primary{ background:var(--glass); border-color:var(--glass); color:#fff; font-weight:640; }
.btn.primary:hover{ background:var(--glass-deep); border-color:var(--glass-deep); color:#fff; }
@media (prefers-color-scheme: dark){ .btn.primary{ color:#06231e; } .btn.primary:hover{ color:#06231e; } }
.btn.danger{ border-color:color-mix(in srgb,var(--fail) 55%,var(--rule)); color:var(--fail); }
.btn.danger:hover{ background:color-mix(in srgb,var(--fail) 10%,var(--surface)); border-color:var(--fail); color:var(--fail); }
.btn.small{ min-height:36px; padding:6px 12px; font-size:.9rem; }
.btn[disabled]{ opacity:.55; cursor:not-allowed; }

/* ---------- toasts ---------- */
.sf-toasts{ position:fixed; left:50%; bottom:calc(16px + env(safe-area-inset-bottom,0px)); transform:translateX(-50%); z-index:200;
  display:grid; gap:8px; width:min(560px, calc(100vw - 32px)); pointer-events:none; }
.sf-toast{ pointer-events:auto; padding:12px 16px; border-radius:10px; background:var(--ink); color:var(--surface); font-size:.95rem;
  box-shadow:0 14px 34px -16px rgba(0,0,0,.55); transition:opacity .3s, transform .3s; }
.sf-toast.error{ background:var(--fail); color:#fff; }
.sf-toast.ok{ background:var(--pass); color:#fff; }
@media (prefers-color-scheme: dark){ .sf-toast.error,.sf-toast.ok{ color:#0b1115; } }
.sf-toast.out{ opacity:0; transform:translateY(8px); }

/* ---------- dialog ---------- */
.sf-dialog{ border:1px solid var(--rule-2); border-radius:14px; padding:22px 24px 20px; width:min(520px, calc(100vw - 32px));
  background:var(--surface); color:var(--ink); box-shadow:0 30px 80px -30px rgba(0,0,0,.6); }
.sf-dialog::backdrop{ background:rgba(10,16,20,.55); }
.sf-dialog h2{ font-size:1.25rem; margin:0 0 12px; font-stretch:112%; }
.sf-dialog p{ color:var(--ink-2); margin:0 0 12px; }
.sf-dialog .sf-pro-line{ color:var(--ink); font-weight:560; }
.sf-dialog-acts{ display:flex; flex-wrap:wrap; gap:10px; justify-content:flex-end; margin-top:16px; }

/* ---------- save state ---------- */
.sf-save{ display:inline-flex; align-items:center; gap:8px; font-size:.86rem; color:var(--ink-3); }
.sf-save::before{ content:""; width:8px; height:8px; border-radius:50%; background:var(--rule-2); flex:0 0 8px; }
.sf-save.saving::before{ background:var(--warn); }
.sf-save.saved::before{ background:var(--pass); }
.sf-save.failed{ color:var(--fail); font-weight:600; }
.sf-save.failed::before{ background:var(--fail); }

/* ---------- free-limit meter ---------- */
.sf-meter{ display:grid; gap:5px; min-width:150px; font-size:.86rem; color:var(--ink-2); }
.sf-meter-bar{ display:block; height:5px; border-radius:3px; background:var(--paper-2); overflow:hidden; }
.sf-meter-bar i{ display:block; height:100%; width:0; background:var(--glass); transition:width .25s; }
.sf-meter.near .sf-meter-bar i{ background:var(--warn); }
.sf-meter.full .sf-meter-bar i{ background:var(--fail); }
.sf-meter.full .sf-meter-txt{ color:var(--ink); font-weight:600; }
.sf-meter.pro .sf-meter-bar{ display:none; }

/* ---------- storage box ---------- */
.sf-storage{ display:grid; gap:8px; padding:14px 16px; border:1px solid var(--rule); border-radius:10px; background:var(--surface); font-size:.9rem; }
.sf-storage p{ margin:0; }
.sf-storage-why{ color:var(--ink-2); max-width:78ch; }
.sf-storage-line{ color:var(--ink-3); font-variant-numeric:tabular-nums; }
.sf-storage .btn{ justify-self:start; }
.sf-storage.bad{ border-color:var(--fail); background:color-mix(in srgb,var(--fail) 6%,var(--surface)); }
.sf-storage.bad .sf-storage-line{ color:var(--fail); font-weight:600; }

/* ---------- project picker ---------- */
.sf-picker{ display:grid; gap:4px; min-width:0; }
.sf-picker label{ font-size:.86rem; font-weight:560; color:var(--ink-2); }
.sf-picker select{ min-height:42px; max-width:100%; }

/* ---------- example ribbon ---------- */
.sf-example{ display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:10px 16px; padding:10px 14px; border-radius:10px;
  border:1.5px dashed color-mix(in srgb,var(--pencil-ink) 60%,var(--rule)); background:color-mix(in srgb,var(--pencil) 7%,var(--surface)); color:var(--ink); font-size:.92rem; }

/* ---------- the tool bar at the top of every document tool ---------- */
.sf-bar{ display:flex; flex-wrap:wrap; align-items:end; gap:12px 18px; padding:14px 0 16px; border-bottom:1px solid var(--rule); margin-bottom:18px; }
.sf-bar .grow{ flex:1 1 auto; }
.sf-bar-acts{ display:flex; flex-wrap:wrap; gap:8px; }
.sf-limits{ font-size:.9rem; color:var(--ink-2); margin:0; max-width:90ch; }
.sf-limits b{ color:var(--ink); font-weight:620; }

/* ---------- desk and paper ---------- */
.sf-work{ display:grid; gap:24px; align-items:start; }
@media (min-width:1100px){ .sf-work{ grid-template-columns:minmax(0,1fr) minmax(0,1.04fr); } }
.sf-desk{ display:grid; gap:18px; min-width:0; }
.sf-paperwrap{ position:relative; min-width:0; background:var(--desk); border-radius:14px; padding:clamp(12px,2vw,24px); }
@media (min-width:1100px){ .sf-paperwrap{ position:sticky; top:calc(var(--hd,61px) + 12px); max-height:calc(100svh - var(--hd,61px) - 24px); overflow:auto; } }
.sf-tabs{ display:none; }
@media (max-width:1099px){
  .sf-tabs{ display:flex; gap:4px; padding:4px; border-radius:999px; background:var(--paper-2); position:sticky; top:calc(var(--hd,61px) + 6px); z-index:5; }
  .sf-tabs button{ flex:1; min-height:42px; border:0; border-radius:999px; background:transparent; color:var(--ink-2); font:inherit; font-weight:600; }
  .sf-tabs button[aria-selected="true"]{ background:var(--surface); color:var(--ink); box-shadow:var(--e1); }
  .sf-work[data-tab="desk"] .sf-paperwrap{ display:none; }
  .sf-work[data-tab="paper"] .sf-desk{ display:none; }
}

/* ---------- sections of the desk ---------- */
.sf-panel{ background:var(--surface); border:1px solid var(--rule); border-radius:12px; padding:16px 18px; display:grid; gap:12px; min-width:0; }
.sf-panel > h2,.sf-panel > h3{ margin:0; font-size:1.06rem; font-stretch:110%; display:flex; align-items:center; gap:10px; }
.sf-panel > h2::before,.sf-panel > h3::before{ content:""; width:4px; height:1.05em; border-radius:2px; background:var(--pencil); flex:0 0 4px; }
.sf-row{ display:grid; gap:12px; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); }
.sf-drop{ display:grid; place-items:center; gap:6px; text-align:center; padding:22px 16px; border:2px dashed var(--rule-2); border-radius:12px; color:var(--ink-2); background:var(--surface-2); cursor:pointer; }
.sf-drop:hover,.sf-drop.over{ border-color:var(--pencil-ink); color:var(--ink); background:color-mix(in srgb,var(--pencil) 6%,var(--surface)); }
.sf-drop:focus-within{ outline:3px solid var(--glass); outline-offset:2px; }
.sf-drop input[type=file]{ position:absolute; width:1px; height:1px; opacity:0; }
.sf-empty{ padding:22px 18px; border:1px dashed var(--rule-2); border-radius:12px; color:var(--ink-2); background:var(--surface); }
.sf-empty b{ color:var(--ink); }

/* ---------- the paper (screen) ---------- */
.sf-sheet{ background:var(--sheet); color:var(--sheet-ink); box-shadow:0 1px 0 rgba(0,0,0,.05),0 18px 40px -22px rgba(0,0,0,.45); margin:0 auto 18px; transform-origin:top left; }
.sf-sheet:last-child{ margin-bottom:0; }

/* ---------- My projects ---------- */
.sf-projects{ display:grid; gap:10px; }
.sf-proj{ display:grid; grid-template-columns:minmax(0,1fr) auto; gap:6px 18px; align-items:center; padding:14px 16px; background:var(--surface); border:1px solid var(--rule); border-radius:12px; }
.sf-proj:hover{ border-color:var(--rule-2); }
.sf-proj h3{ margin:0; font-size:1.08rem; font-stretch:108%; }
.sf-proj h3 a{ color:var(--ink); text-decoration:none; }
.sf-proj h3 a:hover{ text-decoration:underline; }
.sf-proj .meta{ font-size:.86rem; color:var(--ink-3); font-variant-numeric:tabular-nums; }
.sf-proj .counts{ display:flex; flex-wrap:wrap; gap:6px 14px; font-size:.86rem; color:var(--ink-2); }
.sf-proj .acts{ display:flex; flex-wrap:wrap; gap:6px; justify-content:flex-end; grid-row:1 / span 3; grid-column:2; }
.sf-proj.archived{ opacity:.72; }
@media (max-width:640px){ .sf-proj{ grid-template-columns:1fr; } .sf-proj .acts{ grid-row:auto; grid-column:1; justify-content:flex-start; } }

@media print{
  .sf-bar,.sf-tabs,.sf-desk,.sf-toasts,.sf-storage,.sf-example,.site-head,.site-foot,.langbar{ display:none !important; }
  .sf-paperwrap{ background:none; padding:0; position:static; max-height:none; overflow:visible; }
  .sf-sheet{ box-shadow:none; margin:0; transform:none !important; }
}

/* My projects */
.linklike{ background:none; border:0; padding:0; font:inherit; color:inherit; cursor:pointer; text-align:left; }
.linklike:hover{ text-decoration:underline; }
.linklike:focus-visible{ outline:2px solid var(--glass); outline-offset:3px; border-radius:3px; }
.sf-open{ margin:-4px 0 6px; border-top-left-radius:0; border-top-right-radius:0; }
.sf-detail{ display:grid; gap:4px; }
.sf-detail-bar{ display:flex; justify-content:flex-end; }
.sf-contents h4{ margin:10px 0 4px; font-size:.95rem; }
.sf-contents ul{ margin:0; padding-left:18px; color:var(--ink-2); font-size:.92rem; }
#sf-projects.over{ outline:2px dashed var(--pencil-ink); outline-offset:8px; border-radius:12px; }
.sf-app{ display:grid; gap:14px; }

/* on a page that IS a tool, the coloured band is a title, not a poster:
   the work has to be on the first screen */
body.app main > .hero:first-of-type{ padding-top:22px !important; padding-bottom:20px !important; }
body.app main > .hero:first-of-type > h1{ font-size:clamp(1.7rem,1.2rem + 1.8vw,2.5rem); margin-bottom:.35em; }
body.app main > .hero:first-of-type > .answer{ padding:12px 16px; margin-bottom:0; }
body.app main > .hero:first-of-type > .answer p{ font-size:.98rem; }
body.app .sf-bar{ padding-top:4px; }
body.app .sf-storage{ padding:10px 14px; }
body.app .sf-storage-why{ font-size:.86rem; }
body.app main > section.sf-app{ padding-top:18px; }

/* your company on the documents */
.sf-company > summary{ cursor:pointer; font-weight:640; font-stretch:108%; list-style-position:inside; }
.sf-company > summary:focus-visible{ outline:2px solid var(--glass); outline-offset:3px; border-radius:4px; }
.sf-company[open] > summary{ margin-bottom:6px; }
.sf-logo{ display:flex; flex-wrap:wrap; align-items:center; gap:14px; }
.sf-logo img{ max-height:64px; max-width:200px; object-fit:contain; background:#fff; border:1px solid var(--rule); border-radius:8px; padding:6px; }

/* ---------- the live paper: holder, sheet, page guides ---------- */
/* the sheet keeps its real size in mm and is scaled down; the holder takes the
   scaled size, so nothing overflows the column */
.sf-sheet-holder{ position:relative; margin:0 auto; }
.sf-sheet-holder > .sf-sheet{ position:absolute; top:0; left:0; margin:0; box-sizing:border-box; }
.sf-guides{ position:absolute; inset:0; pointer-events:none; }
.sf-guides i{ position:absolute; left:0; right:0; border-top:1px dashed #8a94a0; }
.sf-guides span{ position:absolute; right:6px; top:3px; font:600 10px/1.2 var(--mono,monospace); color:#5b6470; background:#fff; padding:1px 5px; border-radius:3px; }

/* ---------- a document on paper: black ink on white, always ---------- */
.sf-doc{ font:9.5pt/1.42 Archivo,Arial,sans-serif; color:#1b1f24; overflow:hidden; }
.sf-doc h1,.sf-doc h2,.sf-doc h3{ color:#1f2547; font-stretch:110%; }
.sf-doc p{ margin:0; }
.d-head{ display:flex; justify-content:space-between; align-items:flex-start; gap:8mm; padding-bottom:4.5mm; margin-bottom:6mm; border-bottom:.6mm solid #1f2547; }
.d-co{ display:flex; gap:4mm; align-items:flex-start; min-width:0; }
.d-co strong{ font-size:11.5pt; font-stretch:108%; }
.d-co p{ margin-top:1mm; color:#4a525c; font-size:8.5pt; }
.d-logo{ max-height:18mm; max-width:42mm; object-fit:contain; }
.d-meta{ text-align:right; flex:0 0 auto; }
.d-meta h1,.d-meta .d-h1{ font-size:20pt; line-height:1; margin:0 0 3mm; letter-spacing:-.01em; }
.d-meta dl{ display:grid; grid-template-columns:auto auto; gap:.6mm 4mm; margin:0; justify-content:end; font-size:9pt; }
.d-meta dt{ color:#4a525c; }
.d-meta dd{ margin:0; font-weight:620; font-variant-numeric:tabular-nums; }
.d-draft{ color:#b5381f; text-transform:uppercase; letter-spacing:.1em; font-size:8pt; }
.d-client{ margin:0 0 5mm; }
.d-client h2{ font-size:7.5pt; text-transform:uppercase; letter-spacing:.12em; color:#4a525c; margin:0 0 1mm; }
.d-title{ font-size:12.5pt; margin:0 0 4mm; }
.sf-sheet.sf-doc table{ display:table; width:auto; margin:0; overflow:visible; font-size:inherit; }
.sf-sheet.sf-doc th,.sf-sheet.sf-doc td{ background:none; white-space:normal; color:inherit; }
.sf-sheet.sf-doc tbody tr:hover td{ background:none; }
.sf-sheet.sf-doc .d-lines{ width:100%; font-size:9pt; }
.sf-sheet.sf-doc .d-lines td.i,.sf-sheet.sf-doc .d-lines th.i{ background:#fbf1ee; }
.d-ph{ flex:1; padding:3mm 4mm; border:.3mm dashed #9aa3ad; border-radius:2mm; color:#5b6470; font-size:8.5pt; max-width:95mm; }
.d-lines thead{ display:table-header-group; }
.d-lines th{ text-align:left; font-size:7.3pt; font-weight:650; text-transform:uppercase; letter-spacing:.07em; color:#4a525c; padding:1.6mm 2mm; border-bottom:.35mm solid #1b1f24; }
.d-lines td{ padding:2mm; border-bottom:.2mm solid #d9dde3; vertical-align:top; }
.d-lines tr{ break-inside:avoid; }
.d-lines .n{ text-align:right; white-space:nowrap; font-variant-numeric:tabular-nums; }
.d-lines th:first-child,.d-lines td:first-child{ padding-left:0; }
.d-lines th:last-child,.d-lines td:last-child{ padding-right:0; }
.d-ch td{ padding-top:4.5mm; font-weight:700; font-stretch:108%; color:#1f2547; border-bottom:.35mm solid #1f2547; }
.d-out td{ color:#69727d; }
.d-tag{ display:block; margin-top:.8mm; font-size:7.6pt; font-style:italic; color:#4a525c; }
.d-tag.warn{ font-style:normal; font-weight:650; color:#b5381f; }
.d-empty{ padding:8mm 2mm !important; text-align:center; font-style:italic; color:#69727d; }
.d-totals{ margin:4mm 0 0 auto; border-collapse:collapse; min-width:78mm; font-size:9.5pt; break-inside:avoid; }
.d-totals th{ text-align:left; font-weight:500; color:#4a525c; padding:1.1mm 6mm 1.1mm 0; }
.d-totals td{ padding:1.1mm 0; text-align:right; white-space:nowrap; font-variant-numeric:tabular-nums; }
.d-total th,.d-total td{ padding-top:2.5mm; border-top:.5mm solid #1b1f24; font-size:12.5pt; font-weight:760; color:#1b1f24; }
.d-note th{ font-style:italic; font-size:8.3pt; }
.d-texts{ display:grid; grid-template-columns:1fr 1fr; gap:4mm 8mm; margin-top:7mm; font-size:8.8pt; }
.d-texts h3{ font-size:7.3pt; text-transform:uppercase; letter-spacing:.1em; margin:0 0 1mm; }
.d-internal{ margin-top:6mm; padding:3mm 4mm; border:.4mm dashed #b5381f; font-size:8.8pt; break-inside:avoid; }
.d-internal h3{ color:#b5381f; font-size:8pt; text-transform:uppercase; letter-spacing:.08em; margin:0 0 1.5mm; }
.d-internal p + p{ margin-top:1.5mm; }
.d-foot{ display:flex; justify-content:space-between; align-items:flex-end; gap:6mm; margin-top:10mm; padding-top:3mm; border-top:.2mm solid #d9dde3; font-size:7.8pt; color:#4a525c; }
.d-brand{ color:#69727d; white-space:nowrap; }
.d-watermark{ position:absolute; top:38%; left:50%; transform:translate(-50%,-50%) rotate(-24deg); font:800 30pt/1 Archivo,Arial,sans-serif; letter-spacing:.06em; white-space:nowrap; color:rgba(181,56,31,.14); pointer-events:none; z-index:1; }

/* ---------- the budget's desk ---------- */
.q-acts{ display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.q-chapter{ display:grid; gap:4px; padding:12px 14px; border:1px solid var(--rule); border-radius:10px; background:var(--surface-2); min-width:0; }
.q-ch-head{ display:flex; flex-wrap:wrap; align-items:end; gap:4px 12px; }
.q-ch-head .grow{ flex:1 1 220px; }
.q-ch-acts{ display:flex; flex-wrap:wrap; gap:6px; margin-bottom:14px; }
.q-line{ position:relative; display:grid; grid-template-columns:repeat(auto-fill,minmax(68px,1fr)); gap:0 8px; align-items:end; padding-top:10px; border-top:1px dashed var(--rule-2); min-width:0; }
.q-line .q-text{ grid-column:1 / -1; }
.q-line .field{ margin-bottom:10px; }
.q-line .field label{ font-size:.84rem; margin-bottom:4px; }
.q-line .field .hint{ margin-top:3px; font-size:.78rem; }
.q-line input,.q-line select{ width:100%; min-width:0; }
.q-line-acts{ position:absolute; top:6px; right:0; display:flex; gap:4px; }
.q-line-acts .btn{ min-height:28px; padding:2px 9px; font-size:.82rem; }
.q-lines-acts,.q-chips{ display:flex; flex-wrap:wrap; align-items:center; gap:8px; }
.q-tax{ align-items:end; }
.q-tax .btn{ margin-bottom:14px; justify-self:start; }
.q-check{ display:flex; gap:10px; align-items:center; font-size:.92rem; cursor:pointer; }
.q-check input{ width:20px; height:20px; accent-color:var(--glass); }
.field.i input,.field.i textarea{ border-style:dashed; border-color:var(--pencil-ink); }
input[aria-invalid="true"],textarea[aria-invalid="true"]{ border-color:var(--fail) !important; box-shadow:0 0 0 3px color-mix(in srgb,var(--fail) 18%,transparent); }
.q-summary{ position:sticky; bottom:0; z-index:4; display:flex; flex-wrap:wrap; align-items:baseline; gap:4px 18px; padding:12px 16px; border:1px solid var(--rule); border-radius:12px; background:color-mix(in srgb,var(--surface) 94%,transparent); backdrop-filter:blur(6px); box-shadow:0 -8px 24px -18px rgba(0,0,0,.35); font-variant-numeric:tabular-nums; }
.q-summary .q-total{ margin:0; font-size:1.05rem; }
.q-summary .q-total strong{ font-size:1.3rem; font-weight:760; }
.q-summary span{ font-size:.88rem; color:var(--ink-2); }
.q-summary .warn{ color:var(--pencil-ink); font-weight:600; }
.q-diff ul{ margin:0 0 10px; padding-left:18px; display:grid; gap:4px; }
.q-diff .d-added{ color:var(--pass,#1d7a4f); }
.q-diff .d-removed{ color:var(--fail); }

/* printing a document: only the sheet, at its real size, on the paper @page sets */
@media print{
  body.app main > :not(.sf-app),.sf-app > :not(.sf-work),.sf-work > :not(.sf-paperwrap),.sf-guides,.sf-dialog{ display:none !important; }
  /* Print lays the page out at the paper's width (≈794 px for A4), under the
     1100 px where the desk/paper tabs hide one of the two. The page opens on
     the desk tab, so without this the sheet stayed hidden and the PDF came out
     blank (13-10-2026). Whatever the tab, the sheet is what prints. */
  .sf-work[data-tab] > .sf-paperwrap{ display:block !important; }
  body.app main,body.app main > .sf-app{ padding:0 !important; margin:0 !important; max-width:none !important; }
  .sf-sheet-holder{ width:auto !important; height:auto !important; }
  .sf-sheet-holder > .sf-sheet{ position:static; }
  .sf-doc{ overflow:visible; }
  .d-watermark{ position:fixed; top:45%; }
  .d-ph{ visibility:hidden; }
}
.sf-sheet.sf-doc .d-totals{ margin:4mm 0 0 auto; min-width:78mm; }
.q-line textarea{ min-height:0; height:auto; padding-top:8px; padding-bottom:8px; }
.q-line input,.q-line select{ min-height:42px; }
.q-line .field label{ white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.q-line .q-sel{ grid-column:span 2; }
.q-preview{ max-height:260px; overflow:auto; }
.q-ptable{ display:table; width:100%; margin:6px 0 4px; font-size:.86rem; }
.q-ptable th,.q-ptable td{ padding:5px 8px; white-space:normal; }
.q-ptable .n{ text-align:right; font-variant-numeric:tabular-nums; }
.q-ptable .q-miss{ color:var(--pencil-ink); font-size:.8rem; }
.q-ptable tr.q-over td{ opacity:.55; }

/* results waiting from the calculators */
.q-inbox{ display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:10px 16px; padding:12px 16px; border-radius:12px; border:1px solid color-mix(in srgb,var(--pencil) 45%,var(--rule)); background:color-mix(in srgb,var(--pencil) 8%,var(--surface)); }
.q-inbox p{ margin:0; }
.q-inbox-list{ display:grid; gap:12px; max-height:min(62vh,560px); overflow:auto; }
.q-inbox-item{ border:1px solid var(--rule); border-radius:10px; padding:8px 12px 2px; margin:0; min-width:0; }
.q-inbox-item legend{ padding:0 6px; font-weight:640; }
.q-inbox-item .grow2{ grid-column:span 2; }

/* library and revision history (Pro) */
.q-lib-list{ display:grid; gap:2px; max-height:min(50vh,420px); overflow:auto; margin:4px 0 8px; }
.q-lib-row{ display:grid; grid-template-columns:minmax(0,1fr) auto auto; gap:10px; align-items:center; padding:6px 4px; border-bottom:1px solid var(--rule); }
.q-lib-row .q-check span{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.q-lib-price{ font-size:.86rem; color:var(--ink-2); font-variant-numeric:tabular-nums; white-space:nowrap; }
.q-ptable tr.q-h-cur td{ font-weight:640; }
.q-chips select{ min-height:38px; }

/* new budget: blank, trade templates, mine */
.q-new{ display:grid; gap:8px; max-height:min(64vh,600px); overflow:auto; }
.q-new h3{ margin:10px 0 0; font-size:.92rem; color:var(--ink-2); }
.q-new-opt{ display:grid; gap:2px; width:100%; text-align:left; padding:10px 14px; border:1px solid var(--rule); border-radius:10px; background:var(--surface); color:var(--ink); font:inherit; cursor:pointer; }
.q-new-opt:hover{ border-color:var(--pencil-ink); }
.q-new-opt:focus-visible{ outline:3px solid var(--glass); outline-offset:2px; }
.q-new-opt span{ font-size:.86rem; color:var(--ink-2); }
.q-new-row{ display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px; align-items:center; }
.q-fx{ display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:6px 14px; margin-top:-4px; }
.q-fx .hint{ margin:0; flex:1 1 260px; }

/* phones: the tool, not the title, fills the first screen */
@media (max-width:640px){
  body.app main > .hero:first-of-type{ padding-top:14px !important; padding-bottom:14px !important; }
  body.app main > .hero:first-of-type > h1{ font-size:1.55rem; }
  body.app main > .hero:first-of-type > .answer{ padding:9px 12px; }
  body.app main > .hero:first-of-type > .answer p{ font-size:.86rem; line-height:1.45; }
}

/* the bar's "More" */
/* base.css frames every <details> as a panel; this one is a button in the bar */
.q-more{ position:relative; border:0; border-radius:0; padding:0; margin:0; background:none; }
.q-more[open] > summary{ margin-bottom:0; }
.q-more > summary{ list-style:none; cursor:pointer; }
.q-more > summary::-webkit-details-marker{ display:none; }
.q-more > summary::after{ content:" ▾"; }
.q-more-menu{ position:absolute; z-index:20; top:calc(100% + 6px); right:0; display:grid; gap:4px; min-width:240px; padding:8px; border:1px solid var(--rule); border-radius:12px; background:var(--surface); box-shadow:var(--e2,0 12px 30px -12px rgba(0,0,0,.35)); }
.q-more-menu .btn{ justify-content:flex-start; text-align:left; width:100%; }
@media (max-width:640px){ .q-more-menu{ right:auto; left:0; } }
@media (max-width:640px){
  /* the same promise is in the save line and in the text below the tool */
  body.app main > .hero:first-of-type > .answer{ display:none; }
  body.app .sf-example{ padding:8px 12px; font-size:.86rem; }
  .q-acts .btn{ padding-left:10px; padding-right:10px; }
}

/* ---------- the red pencil (pencil.js) ---------- */
.sf-dialog.wide{ width:min(1100px, calc(100vw - 16px)); max-height:calc(100svh - 16px); padding:14px 16px 16px; }
.pn{ display:grid; gap:10px; }
.pn-tools{ display:flex; flex-wrap:wrap; gap:6px; }
.pn-tools [aria-pressed="true"]{ background:var(--docs); border-color:var(--docs); color:#fff; }
.pn-status{ margin:0; font-size:.9rem; color:var(--ink-2); min-height:1.4em; }
.pn-stage{ background:#15181c; border-radius:10px; overflow:hidden; display:grid; place-items:center; }
.pn-stage svg{ display:block; width:100%; height:auto; max-height:58svh; touch-action:none; cursor:crosshair; user-select:none; }
.pn-dim{ display:flex; flex-wrap:wrap; align-items:end; gap:8px 12px; padding:10px 12px; border:1px solid var(--rule); border-radius:10px; background:var(--surface-2); }
.pn-dim label{ flex:1 1 100%; font-size:.9rem; font-weight:600; }
.pn-dim input{ max-width:180px; }
.pn-h{ margin:4px 0 0; font-size:.95rem; }
.pn-list{ margin:0; padding-left:20px; display:grid; gap:4px; }
.pn-list li{ display:flex; flex-wrap:wrap; align-items:center; gap:6px 10px; }
.pn-list li > span{ flex:1 1 auto; }
.pn-list li.sel > span{ font-weight:700; }
.sf-photo{ display:block; width:100%; height:auto; }

/* ---------- the survey sheet's desk ---------- */
.s-refs{ gap:14px; }
.s-el{ display:grid; gap:6px; padding:12px 14px; border:1px solid var(--rule); border-radius:12px; background:var(--surface-2); min-width:0; }
.s-el-h{ display:flex; flex-wrap:wrap; align-items:end; gap:4px 10px; }
.s-el-h .s-code{ flex:0 0 84px; }
.s-el-h .grow{ flex:1 1 180px; }
.s-el-acts{ display:flex; gap:4px; margin-bottom:14px; }
.s-el-acts .btn{ min-height:32px; padding:2px 10px; }
.s-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(140px,1fr)); gap:0 10px; }
.s-grid .wide{ grid-column:auto; }
.s-el textarea{ min-height:0; height:auto; }
.s-grid select{ text-overflow:ellipsis; }
.s-six{ display:grid; grid-template-columns:auto repeat(3,minmax(0,1fr)); gap:0 10px; align-items:end; }
.s-six .s-lab{ font-size:.86rem; font-weight:650; color:var(--ink-2); padding-bottom:26px; }
.s-six .field{ margin-bottom:8px; }
.s-six .field label{ font-size:.8rem; margin-bottom:3px; }
.s-calc{ display:flex; flex-wrap:wrap; gap:4px 12px; margin:0 0 4px; font-size:.9rem; font-variant-numeric:tabular-nums; }
.s-flag{ font-size:.84rem; padding:1px 8px; border-radius:999px; background:var(--paper-2); color:var(--ink-2); }
.s-flag.warn{ background:color-mix(in srgb,var(--pencil) 16%,var(--surface)); color:var(--pencil-ink); font-weight:600; }
.s-links{ display:flex; gap:12px; font-size:.86rem; }
.s-photos{ display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:8px 10px; align-items:start; }
.s-ph{ position:relative; border-radius:8px; overflow:hidden; background:#15181c; }
.s-ph-acts{ position:absolute; left:6px; right:6px; bottom:6px; display:flex; justify-content:space-between; gap:6px; }
.s-ph-acts .btn{ min-height:30px; padding:2px 9px; font-size:.8rem; background:rgba(255,255,255,.92); }
.s-photos > .btn{ align-self:center; justify-self:start; }
.s-cap{ margin-bottom:6px; }
.s-ph-meta{ grid-column:1 / -1; }
.s-sys{ align-items:end; }
.s-sys .btn{ margin-bottom:14px; justify-self:start; }
.s-pend{ display:flex; align-items:center; gap:10px; }
.s-pend .grow{ flex:1 1 auto; }
.s-pend input[type=checkbox]{ width:20px; height:20px; accent-color:var(--glass); }
.s-views{ display:inline-flex; gap:4px; padding:4px; border-radius:999px; background:var(--paper-2); }
.s-views button{ min-height:36px; border:0; border-radius:999px; padding:0 14px; background:transparent; color:var(--ink-2); font:inherit; font-weight:600; cursor:pointer; }
.s-views button[aria-pressed="true"]{ background:var(--surface); color:var(--ink); box-shadow:var(--e1); }
.s-copy{ width:100%; font-family:var(--mono,monospace); font-size:.86rem; }
@media (max-width:640px){ .s-six{ grid-template-columns:repeat(3,minmax(0,1fr)); } .s-six .s-lab{ grid-column:1 / -1; padding:4px 0 0; } }

/* ---------- the survey sheet on paper ---------- */
.sf-sheet.sf-doc .d-survey{ width:100%; font-size:8.8pt; border-collapse:collapse; }
.d-survey .d-el{ break-inside:avoid; }
.d-survey .d-el-h th{ text-align:left; font-size:10pt; color:#1f2547; padding:2.6mm 2mm 1mm 0; border-top:.35mm solid #1f2547; }
.d-survey .d-el-h td{ padding:2.6mm 2mm 1mm; border-top:.35mm solid #1f2547; font-weight:600; }
.d-survey .d-el-h td.n{ text-align:right; font-weight:500; white-space:nowrap; }
.d-survey .d-meas{ padding:0 0 2.4mm; }
.d-meas > span{ display:inline-block; margin:0 5mm 1mm 0; font-variant-numeric:tabular-nums; }
.d-meas b{ color:#4a525c; font-weight:600; margin-right:1mm; }
.d-meas .d-glass{ color:#1b1f24; }
.d-meas .d-flags{ display:block; }
.d-meas .d-flags i{ display:inline-block; font-style:normal; font-size:7.8pt; margin:0 2mm .6mm 0; padding:.2mm 1.6mm; border-radius:1mm; background:#eef0f3; color:#4a525c; }
.d-meas .d-flags i.warn{ background:#fbe9e5; color:#b5381f; font-weight:650; }
.d-note-i{ display:block; color:#4a525c; font-style:italic; }
.d-thumbs{ display:flex !important; gap:2mm; margin-top:1mm; }
.d-thumb{ width:30mm; }
.d-state{ font-size:7.8pt; color:#4a525c; }
.d-state.estimated,.d-state.pending{ color:#b5381f; font-weight:650; }
.d-tag-i{ display:inline-block; font-size:7.6pt; font-weight:500; color:#4a525c; margin-left:1.5mm; }
.d-sum{ margin:0 0 3mm; font-size:9pt; color:#4a525c; }
.d-method{ margin-top:5mm; font-size:7.6pt; color:#69727d; }
.d-figs{ display:grid; grid-template-columns:1fr 1fr; gap:4mm 5mm; margin-bottom:4mm; }
.d-fig{ margin:0; break-inside:avoid; }
.d-fig figcaption{ font-size:8pt; color:#4a525c; margin-top:1mm; }
.d-fig .d-dims{ display:block; color:#b5381f; font-weight:600; }
.d-group{ font-size:9.5pt; margin:4mm 0 2mm; color:#1f2547; }
.d-nophoto{ display:grid; place-items:center; aspect-ratio:4/3; background:#eef0f3; color:#69727d; font-size:7.5pt; }
.q-ready{ margin:0 0 6px; padding-left:18px; font-size:.88rem; color:var(--ink-2); display:grid; gap:2px; }
