/* Source Serif 4 and Public Sans (SIL Open Font License 1.1), the latin and latin-ext subsets of the
   variable fonts Google Fonts serves, kept here so no page asks Google for them (a public visitor's
   address never reaches Google). server.js serves each file under a content-hashed name. */
/* latin-ext */
@font-face {
  font-family: 'Public Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/public-sans-latin-ext.1c8a26c0ed43.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Public Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/public-sans-latin.c1b6da516e00.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* latin-ext */
@font-face {
  font-family: 'Public Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/assets/public-sans-latin-ext.1c8a26c0ed43.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Public Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/assets/public-sans-latin.c1b6da516e00.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* latin-ext */
@font-face {
  font-family: 'Public Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/assets/public-sans-latin-ext.1c8a26c0ed43.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Public Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/assets/public-sans-latin.c1b6da516e00.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* latin-ext */
@font-face {
  font-family: 'Public Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/assets/public-sans-latin-ext.1c8a26c0ed43.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Public Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/assets/public-sans-latin.c1b6da516e00.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* latin-ext */
@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/assets/source-serif-4-latin-ext.c9299a71605a.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/assets/source-serif-4-latin.2a24bad466f0.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* latin-ext */
@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/assets/source-serif-4-latin-ext.c9299a71605a.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/assets/source-serif-4-latin.2a24bad466f0.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* latin-ext */
@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/assets/source-serif-4-latin-ext.c9299a71605a.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/assets/source-serif-4-latin.2a24bad466f0.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

    @media print {
      @page { size: letter; margin: 0.5in; }
      html, body { margin:0; padding:0; background:white; font-size:9.5pt; }
      .screen-only { display:none !important; }
      .print-page  { page-break-after:always; }
      .print-page:last-child { page-break-after:avoid; }
      /* Definite page height so the QDA table can stretch to the bottom. */
      .po-page { height:9.55in; min-height:0; }
      .no-break    { page-break-inside:avoid; }
      .est-page    { min-height:9.7in; }
    }
    @media screen { .print-only { display:none !important; } }
    /* Paginated estimate page: header, flexible body, footer pinned to the bottom */
    .est-page { display:flex; flex-direction:column; }
    .est-body { flex:1 1 auto; }
    .est-foot { display:flex; align-items:flex-end; margin-top:10px; padding-top:5px; border-top:1px solid #e5e7eb; font-size:8pt; color:#555; }
    .est-cont { flex:1; font-style:italic; }
    .est-pageno { font-weight:700; white-space:nowrap; }

    /* ═══════════════════════════════════════════════════════════════
       KSI UI REFRESH — "Showroom" theme (screen styles)
       Warm neutrals · ink navy · brass accent · Source Serif 4 display
       All selectors below match the class names already emitted by
       Index.html and JavaScript.html. Print styles are unchanged.
       ═══════════════════════════════════════════════════════════════ */

    /* ── Design tokens ── */
    :root {
      --navy:#1f2340; --navy-2:#2a2f52;
      --accent:#c9a15f; --accent-2:#a67c3d; --accent-tint:#fbf7f0; --accent-ring:rgba(201,161,95,.18);
      --bg:#f4f1ec; --surface:#ffffff; --surface-2:#fbfaf8; --surface-3:#ebe6dd;
      --border:#e3ddd3; --border-2:#cfc7ba; --border-soft:#efeae2;
      --text:#1c1a17; --text-2:#4b463f; --muted:#857d72; --muted-2:#a69c8e;
      --success:#2f7a4a; --success-2:#25693e;
      --danger:#b0352b; --danger-2:#c44a40; --danger-tint:#fdf3f2;
      --font-ui:'Public Sans',system-ui,-apple-system,"Segoe UI",sans-serif;
      --font-display:'Source Serif 4',Georgia,"Times New Roman",serif;
      --fs-1:11px; --fs-2:12px; --fs-3:13px; --fs-4:15px; --fs-5:18px; --fs-6:22px;
      --sp-1:4px; --sp-2:8px; --sp-3:12px; --sp-4:16px; --sp-5:24px; --sp-6:32px;
      --r-1:6px; --r-2:9px; --r-3:14px; --r-pill:999px;
      --control-h:44px;
      --shadow-1:0 1px 3px rgba(28,26,23,.06);
      --shadow-2:0 10px 24px rgba(28,26,23,.10);
      --shadow-3:0 12px 30px rgba(28,26,23,.16);
      --shadow-bar:0 12px 30px rgba(31,35,64,.30);
      --ease:cubic-bezier(.2,.8,.2,1);
    }

    /* ── Base reset (replaces Tailwind preflight) ── */
    *, *::before, *::after { box-sizing:border-box; border:0 solid var(--border); }
    html { line-height:1.5; -webkit-text-size-adjust:100%; font-family:var(--font-ui); }
    body { margin:0; line-height:inherit; color:var(--text); background:var(--bg); min-height:100vh; -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale; text-rendering:optimizeLegibility; }
    h1,h2,h3,h4,h5,h6,p,blockquote,figure { margin:0; }
    button,input,optgroup,select,textarea { font-family:inherit; font-size:100%; line-height:inherit; color:inherit; margin:0; padding:0; }
    button,select { text-transform:none; }
    button { background-color:transparent; background-image:none; -webkit-appearance:button; }
    ul,ol { list-style:none; margin:0; padding:0; }
    img,svg,video,canvas { display:block; vertical-align:middle; }
    a { color:var(--navy); text-decoration:inherit; } a:hover { color:var(--accent-2); }
    hr { height:0; color:inherit; border-top-width:1px; }
    table { border-collapse:collapse; border-color:inherit; text-indent:0; }
    .view { display:none; } .view.active { display:block; }

    /* ── Utility classes (kept — same names/values the markup relies on) ── */
    .flex { display:flex; } .grid { display:grid; }
    .hidden { display:none !important; }
    .items-center { align-items:center; } .items-start { align-items:flex-start; }
    .justify-between { justify-content:space-between; }
    .flex-1 { flex:1 1 0%; }
    .mx-auto { margin-left:auto; margin-right:auto; }
    .text-center { text-align:center; }
    .grid-cols-2 { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .grid-cols-3 { grid-template-columns:repeat(3,minmax(0,1fr)); }
    .grid-cols-5 { grid-template-columns:repeat(5,minmax(0,1fr)); }
    /* Estimate form blocks drawn from the layout Shop Settings arranges (formFieldsHTML) */
    .fgrid { display:grid; column-gap:12px; row-gap:0; }
    .fcols-1 { grid-template-columns:minmax(0,1fr); }
    .fcols-2 { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .fcols-3 { grid-template-columns:repeat(3,minmax(0,1fr)); }
    .fcell { min-width:0; }
    .fcell.fwide { grid-column:1 / -1; margin-bottom:12px; }
    .fcell.fwide > .field { margin-bottom:0; }
    .f-hidden { display:none !important; }
    .f-hidden-filled { outline:1px dashed var(--border-2); outline-offset:4px; border-radius:var(--r-1); }
    .fhead { font-size:11px; font-weight:700; color:#6b7280; text-transform:uppercase; letter-spacing:.05em; margin:10px 0 4px; }
    .col-span-2 { grid-column:span 2 / span 2; } .col-span-3 { grid-column:span 3 / span 3; }
    .gap-1 { gap:4px; } .gap-2 { gap:8px; } .gap-3 { gap:12px; }
    .gap-4 { gap:16px; } .gap-5 { gap:20px; } .gap-6 { gap:24px; }
    .mt-1 { margin-top:4px; } .mt-2 { margin-top:8px; } .mt-3 { margin-top:12px; } .mt-4 { margin-top:16px; }
    .mb-1 { margin-bottom:4px; } .mb-2 { margin-bottom:8px; } .mb-3 { margin-bottom:12px; }
    .mb-4 { margin-bottom:16px; } .mb-8 { margin-bottom:32px; }
    .ml-1 { margin-left:4px; }
    .pt-2 { padding-top:8px; } .pl-3 { padding-left:12px; }
    .px-4 { padding-left:16px; padding-right:16px; } .px-5 { padding-left:20px; padding-right:20px; }
    .px-14 { padding-left:56px; padding-right:56px; }
    .py-2 { padding-top:8px; padding-bottom:8px; } .py-3 { padding-top:12px; padding-bottom:12px; }
    .py-4 { padding-top:16px; padding-bottom:16px; } .py-6 { padding-top:24px; padding-bottom:24px; }
    .max-w-3xl { max-width:48rem; } .max-w-4xl { max-width:62rem; } .max-w-6xl { max-width:74rem; }
    .text-xs { font-size:12px; line-height:16px; } .text-sm { font-size:14px; line-height:20px; }
    .text-base { font-size:16px; line-height:24px; } .text-lg { font-size:18px; line-height:28px; }
    .text-gray-400 { color:var(--muted); } .text-gray-500 { color:var(--muted); }
    .text-gray-700 { color:var(--text-2); } .text-gray-900 { color:var(--text); }
    .font-medium { font-weight:500; } .font-semibold { font-weight:600; } .font-bold { font-weight:700; }
    .italic { font-style:italic; }
    .border-l { border-left-width:1px; border-left-style:solid; } .border-gray-200 { border-color:var(--border); }

    /* ── Focus visibility (keyboard) ── */
    :focus-visible { outline:2px solid var(--accent-2); outline-offset:2px; border-radius:4px; }

    /* ── Skeleton loaders ── */
    @keyframes ksi-shimmer { 0%{background-position:-600px 0;} 100%{background-position:600px 0;} }
    .skeleton-bar { border-radius:6px; background:linear-gradient(90deg,#efeae2 25%,#e3ddd3 50%,#efeae2 75%); background-size:600px 100%; animation:ksi-shimmer 1.4s linear infinite; }
    .skeleton-card { pointer-events:none; }
    .skeleton-card .skeleton-bar { height:12px; margin-bottom:10px; }
    .skeleton-card .skeleton-bar.w40 { width:40%; } .skeleton-card .skeleton-bar.w70 { width:70%; }
    .skeleton-card .skeleton-bar.w55 { width:55%; } .skeleton-card .skeleton-bar.tall { height:30px; margin-top:8px; margin-bottom:0; }

    /* ── App shell ── */
    .app-header { background:var(--navy); color:#fff; padding:12px 24px; min-height:64px; display:flex; align-items:center; justify-content:space-between; gap:14px; flex-wrap:wrap; position:sticky; top:0; z-index:50; box-shadow:0 2px 10px rgba(31,35,64,.2); }
    .app-header svg polygon { stroke:var(--accent); stroke-width:7; }
    .header-search { flex:1 1 220px; max-width:420px; margin-left:auto; display:flex; align-items:center; gap:10px; height:44px; padding:0 14px; background:rgba(255,255,255,.1); border:1px solid rgba(255,255,255,.14); border-radius:10px; color:rgba(255,255,255,.75); transition:background .15s,border-color .15s; }
    .header-search:hover { background:rgba(255,255,255,.15); }
    .header-search:focus-within { border-color:var(--accent); }
    /* The field sits inside its dark pill. The type/state selectors outrank the generic
       input[type=text] rules further down, which otherwise drew a white box over the pill. */
    .header-search input, .header-search input[type=text], .header-search input[type=text]:hover, .header-search input[type=text]:focus { flex:1; min-width:0; min-height:0; height:auto; background:none; border:none; border-radius:0; box-shadow:none; outline:none; color:#fff; font-size:15px; padding:0; }
    .header-search input::placeholder { color:rgba(255,255,255,.6); }
    /* Clear (×) inside the pill, only while there is text; the invisible ::after makes a 44px tap area without enlarging the pill */
    .search-clear { position:relative; flex:none; display:inline-flex; align-items:center; justify-content:center; width:22px; height:22px; margin-right:-4px; padding:0; border:none; border-radius:50%; background:rgba(255,255,255,.18); color:rgba(255,255,255,.8); cursor:pointer; transition:background .15s,color .15s; }
    .search-clear::after { content:""; position:absolute; inset:-11px; }
    .search-clear:hover, .search-clear:focus-visible { background:rgba(255,255,255,.3); color:#fff; }
    .search-clear:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
    .search-clear[hidden] { display:none; }
    .search-row { grid-template-columns:minmax(0,1fr) minmax(0,1fr); }
    @media screen and (max-width:767px) { .header-search { order:3; flex-basis:100%; max-width:none; margin-left:0; } }
    .app-header > button > div > div { font-family:var(--font-display) !important; font-weight:600 !important; font-size:15px !important; letter-spacing:.06em !important; }
    .sub-header { background:var(--surface); border-bottom:1px solid var(--border); padding:10px 24px; min-height:60px; display:flex; align-items:center; justify-content:space-between; gap:14px; flex-wrap:nowrap; position:sticky; top:0; z-index:40; }
    .sub-header > div:first-child { flex:1 1 auto; min-width:0; }
    .sub-header > div:first-child > div:last-child { min-width:0; overflow:hidden; }
    .sub-header > div:last-child { flex:none; }
    #editorTitle { font-family:var(--font-display); font-weight:600; font-size:17px; line-height:1.2; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
    #currentFileName { font-size:12px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
    .form-card.glass { background:var(--surface); border:1px solid var(--border); }

    /* ── Dashboard: filters ── */
    .search-row   { display:grid; grid-template-columns:minmax(0,2fr) minmax(0,1fr) minmax(0,1fr); gap:12px; align-items:end; }
    .filter-field { display:flex; flex-direction:column; gap:5px; min-width:0; }
    .filter-field label { font-size:12px; font-weight:600; color:var(--text-2); text-transform:none; letter-spacing:0; }
    .search-row input, .search-row select, .dash-toolbar select { width:100%; min-width:0; height:var(--control-h); font-weight:500; }
    .search-row select, .dash-toolbar select { -webkit-appearance:none; -moz-appearance:none; appearance:none; padding-left:12px; padding-right:36px; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23857d72' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 14px center; }
    .status-bar   { background:var(--surface); border:1px solid var(--border); border-radius:var(--r-3); padding:14px 18px; margin-bottom:18px; }
    .empty-state  { text-align:center; padding:60px 20px; color:var(--muted); background:var(--surface); border:1px dashed var(--border-2); border-radius:var(--r-3); }
    .empty-state .text-lg { font-family:var(--font-display); font-weight:600; font-size:20px; color:var(--text-2); }
    .empty-icon   { font-size:48px; margin-bottom:12px; }
    .loading-cards { text-align:center; padding:40px; color:var(--muted); }
    /* Dashboard toolbar — filters (Status/Sort) share one bar with the
       view toggle, Import and Refresh. */
    .dash-toolbar { display:flex; align-items:end; flex-wrap:wrap; gap:12px; }
    .dash-toolbar .filter-field { flex:0 1 190px; min-width:150px; }
    .dash-toolbar-actions { display:flex; align-items:center; gap:8px; margin-left:auto; }
    @media screen and (max-width:767px) { .dash-toolbar-actions { margin-left:0; width:100%; } .dash-toolbar .filter-field { flex:1 1 46%; } }
    /* Paddle-style segmented toggle for Tile / List view */
    .view-toggle { display:inline-flex; align-items:center; gap:3px; height:44px; padding:3px; background:var(--surface-3); border:1px solid var(--border-2); border-radius:var(--r-pill); box-sizing:border-box; }
    .layout-btn { background:none; color:var(--muted); border:none; width:44px; height:100%; padding:0; border-radius:var(--r-pill); line-height:0; cursor:pointer; transition:background .15s var(--ease),color .15s,box-shadow .15s; display:inline-flex; align-items:center; justify-content:center; }
    .layout-btn.active { background:var(--navy); color:#fff; box-shadow:var(--shadow-1); }
    .layout-btn:hover:not(.active) { color:var(--text); background:rgba(31,35,64,.06); }

    /* ── Dashboard: tile cards ── */
    .est-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(270px,1fr)); gap:14px; margin-top:18px; }
    .est-card { position:relative; background:var(--surface); border:1px solid var(--border); border-radius:var(--r-3); padding:18px 18px 16px; box-shadow:none; transition:box-shadow .15s var(--ease),border-color .15s,transform .15s var(--ease); display:flex; flex-direction:column; gap:8px; }
    .est-card:hover { box-shadow:var(--shadow-2); border-color:var(--accent); }
    .est-card:hover, .est-card:focus-within { z-index:40; }
    .est-card:has(.card-menu:not(.hidden)) { z-index:80; }
    .est-card-top { display:flex; justify-content:space-between; align-items:center; gap:10px; }
    .est-card-id { min-width:0; margin-top:4px; }
    .est-card-room { font-size:13px; font-weight:400; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
    .est-card-bottom { display:flex; flex-wrap:wrap; justify-content:space-between; align-items:flex-end; gap:10px; margin-top:auto; padding-top:10px; border-top:1px solid var(--border-soft); }
    .est-card-total { font-family:var(--font-display); font-size:22px; line-height:1; font-weight:600; color:var(--text); font-variant-numeric:tabular-nums; }
    .est-card-actions { display:flex; gap:6px; align-items:center; flex-shrink:0; margin-left:auto; } /* a 7-figure total pushes Open/⋯ to their own row, inside the card */
    .est-badge { font-size:11px; font-weight:700; padding:5px 10px; border-radius:var(--r-1); text-transform:uppercase; letter-spacing:.06em; white-space:nowrap; }
    .est-badge--estimate { background:#e8ebf4; color:#2b3a6b; }
    .est-badge--salesorder { background:#e6f1ea; color:var(--success); }
    /* Project-status pill — fixed width keeps customer names aligned across cards */
    .est-status { flex:none; width:112px; box-sizing:border-box; align-self:flex-start; font-size:11px; font-weight:700; padding:5px 8px; border-radius:var(--r-1); text-transform:uppercase; letter-spacing:.06em; white-space:normal; text-align:center; line-height:1.2; box-shadow:none; }
    .est-status--estimate   { background:#e8ebf4; color:#2b3a6b; }
    .est-status--production { background:#f7ecd8; color:#8a5a12; }
    .est-status--complete   { background:#e6f1ea; color:#2f7a4a; }
    .est-status--warranty   { background:#f4e4f1; color:#7a2c6b; }
    .est-status--install    { background:#dff1f2; color:#0f5f66; }
    .est-date-small { font-size:12px; color:var(--muted); text-align:right; line-height:1.4; flex-shrink:0; white-space:nowrap; }
    .est-customer { font-family:var(--font-display); font-size:19px; font-weight:600; color:var(--text); line-height:1.25; margin-bottom:2px; }
    .est-po       { font-size:13px; font-weight:500; color:var(--text-2); margin-bottom:2px; }
    .est-company  { font-size:13px; font-weight:600; color:var(--text-2); margin-bottom:2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; } /* Bill To company under the person's name */
    .est-nameline { display:flex; align-items:baseline; gap:8px; flex-wrap:wrap; margin-bottom:2px; }
    .est-nameline .est-customer { flex:0 1 auto; min-width:0; margin-bottom:0; overflow:hidden; text-overflow:ellipsis; }
    .est-ponum    { font-size:13px; font-weight:600; color:var(--text-2); letter-spacing:0; white-space:normal; line-height:1.3; }
    .est-amount   { font-family:var(--font-display); font-size:22px; font-weight:600; color:var(--text); margin:6px 0 12px; font-variant-numeric:tabular-nums; }
    .est-footer   { display:flex; gap:7px; margin-top:auto; border-top:1px solid var(--border-soft); padding-top:12px; }

    /* ── Dashboard: list view ── */
    .est-list { display:flex; flex-direction:column; gap:0; margin-top:16px; background:var(--surface); border:1px solid var(--border); border-radius:var(--r-3); overflow:visible; }
    .est-list-row { position:relative; background:transparent; border:none; border-bottom:1px solid var(--border-soft); border-radius:0; padding:12px 18px; min-height:60px; display:flex; align-items:center; gap:14px; box-shadow:none; transition:background .12s; }
    .est-list-row:first-child { border-radius:var(--r-3) var(--r-3) 0 0; } .est-list-row:last-child { border-bottom:none; border-radius:0 0 var(--r-3) var(--r-3); }
    /* Zebra striping: row 1 stays light; even rows take a very slightly darker tint */
    .est-list-row:nth-child(even) { background:var(--surface-2); }
    .est-list-row:hover { background:var(--accent-tint); box-shadow:none; transform:none; }
    .est-list-row:hover, .est-list-row:focus-within { z-index:40; }
    .est-list-row:has(.card-menu:not(.hidden)) { z-index:80; }
    .est-list-id { flex:1; min-width:0; }
    .est-list-id .est-customer { font-size:16px; }
    .est-list-id .est-customer, .est-list-id .est-po, .est-list-id .est-card-room { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
    .est-list-id .est-nameline { flex-wrap:nowrap; }
    .est-list-id .est-nameline .est-customer { flex:0 0 250px; }
    .est-list-id .est-nameline .est-ponum { flex:1 1 auto; text-align:left; }
    .est-list-amount { font-family:var(--font-display); font-size:17px; font-weight:600; color:var(--text); width:120px; text-align:right; flex-shrink:0; font-variant-numeric:tabular-nums; }
    .est-list-date { font-size:12px; color:var(--muted); width:150px; text-align:right; flex-shrink:0; line-height:1.35; }
    .est-list-actions { display:flex; gap:5px; flex-shrink:0; }
    .storage-warning { background:#f7ecd8; border:1px solid #e3c98f; border-radius:var(--r-3); padding:13px 18px; margin-bottom:14px; display:flex; align-items:center; justify-content:space-between; gap:12px; }
    .storage-warning-text { font-size:13px; color:#8a5a12; font-weight:600; }

    /* ── Card action menu (⋯) ── */
    .card-menu-wrap { position:relative; display:inline-flex; }
    .card-menu-btn { background:var(--surface); border:1px solid var(--border); color:var(--text-2); border-radius:var(--r-2); width:40px; height:40px; padding:0; font-size:18px; line-height:1; cursor:pointer; display:inline-flex; align-items:center; justify-content:center; transition:background .12s,border-color .12s; }
    .card-menu-btn:hover { background:var(--bg); border-color:var(--border-2); }
    .card-menu { position:absolute; right:0; top:calc(100% + 6px); background:var(--surface); border:1px solid var(--border); border-radius:12px; box-shadow:var(--shadow-3); width:max-content; min-width:180px; z-index:60; overflow:hidden; animation:ksi-menu-in .18s var(--ease) both; }
    @keyframes ksi-menu-in { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }
    .card-menu.card-menu-up { top:auto; bottom:calc(100% + 6px); } /* flipped by toggleCardMenu on touch screens */
    .card-menu-item { display:flex; align-items:center; gap:8px; width:100%; min-height:44px; padding:10px 16px; font-size:14px; font-weight:600; color:var(--text); background:none; border:none; border-top:1px solid var(--border-soft); cursor:pointer; text-align:left; white-space:nowrap; transition:background .12s; }
    .card-menu-item:first-child { border-top:none; }
    .card-menu-item:hover { background:var(--bg); }
    .card-menu-item.danger, .card-menu-item[data-action="delete"], #editorMenu .card-menu-item:last-child { color:var(--danger); }
    .card-menu-item.danger:hover, .card-menu-item[data-action="delete"]:hover, #editorMenu .card-menu-item:last-child:hover { background:var(--danger-tint); }

    /* ── User bubble + dropdown ── */
    .user-bubble { width:40px; height:40px; border-radius:50%; background:var(--accent); color:var(--text); font-size:13px; font-weight:700; border:2px solid rgba(255,255,255,.35); display:flex; align-items:center; justify-content:center; cursor:pointer; user-select:none; flex-shrink:0; transition:filter .15s,border-color .15s; letter-spacing:0; box-shadow:none; }
    .user-bubble:hover { filter:brightness(1.06); border-color:rgba(255,255,255,.6); opacity:1; }
    .user-dropdown { position:fixed; right:16px; top:66px; background:var(--surface); border:1px solid var(--border); border-radius:12px; box-shadow:var(--shadow-3); width:max-content; min-width:240px; max-width:90vw; z-index:200; overflow:hidden; animation:ksi-menu-in .18s var(--ease) both; }
    .user-dropdown-header { padding:12px 16px 10px; }
    .user-dropdown-label { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); margin-bottom:3px; }
    .user-dropdown-email { font-size:14px; font-weight:600; color:var(--text); word-break:break-all; }
    .user-dropdown hr { border-top:1px solid var(--border-soft) !important; }
    .user-dropdown-item { display:flex; align-items:center; gap:9px; width:100%; min-height:44px; padding:10px 16px; font-size:14px; color:var(--text); background:none; border:none; cursor:pointer; text-align:left; font-weight:600; transition:background .12s; }
    .user-dropdown-item:hover { background:var(--bg); color:var(--text); }

    /* ── Modal (confirm / select dialogs) ── */
    .modal-overlay { position:fixed; inset:0; background:rgba(28,26,23,.5); z-index:300; display:flex; align-items:center; justify-content:center; padding:20px; }
    .modal-panel { background:var(--surface); border-radius:16px; box-shadow:0 24px 60px rgba(0,0,0,.3); width:100%; max-width:420px; padding:24px; animation:ksi-pop .28s var(--ease) both; }
    @keyframes ksi-pop { 0%{transform:scale(.92);opacity:0} 100%{transform:scale(1);opacity:1} }
    .modal-title { font-family:var(--font-display); font-size:19px; font-weight:600; color:var(--text); margin-bottom:8px; }
    .modal-message { font-size:14px; color:var(--text-2); line-height:1.55; white-space:pre-line; }
    .modal-select-wrap { margin-top:14px; }
    .modal-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:20px; }
    .modal-panel .btn-primary.danger { background:var(--danger); }
    .modal-panel .btn-primary.danger:hover { background:#9a2d24; }

    /* ── Shared buttons (all ≥40px tall for touch) ── */
    .btn-primary { background:var(--navy); color:#fff; border:none; min-height:42px; padding:0 18px; border-radius:var(--r-2); font-size:14px; font-weight:700; cursor:pointer; white-space:nowrap; box-shadow:none; transition:background .15s,box-shadow .15s var(--ease); }
    .btn-primary:hover { background:var(--navy-2); box-shadow:var(--shadow-2); }
    .btn-primary:disabled { background:var(--muted-2); cursor:not-allowed; transform:none; }
    /* The heads-up before a weekly update: the New Estimate button's gold, low key, above every page */
    .update-banner { background:var(--accent); color:var(--text); display:flex; align-items:center; justify-content:center; gap:12px; flex-wrap:nowrap; padding:8px 16px; font-size:13px; line-height:1.4; }
    /* The text wraps in its own block; OK stays inline to its right at every width (owner, 2026-10-04) */
    .update-banner > span { flex:0 1 auto; min-width:0; text-align:left; }
    .update-banner[hidden] { display:none; }
    .update-banner button { flex:none; background:var(--text); color:var(--accent); border:1px solid var(--text); border-radius:var(--r-2); min-height:32px; min-width:56px; padding:0 14px; font-size:13px; font-weight:700; cursor:pointer; font-family:inherit; } /* the banner's colors reversed (owner, 2026-10-04) */
    .update-banner button:hover { background:var(--text-2); border-color:var(--text-2); }
    .update-banner button:focus-visible { outline:2px solid var(--navy); outline-offset:2px; }
    .btn-green { background:var(--accent); color:var(--text); border:none; min-height:44px; padding:0 18px; border-radius:var(--r-2); font-size:14px; font-weight:700; cursor:pointer; white-space:nowrap; box-shadow:none; transition:filter .12s,box-shadow .15s var(--ease); }
    .btn-green:hover { filter:brightness(1.06); box-shadow:var(--shadow-2); background:var(--accent); }
    .btn-add { background:var(--surface); color:var(--text); border:1px solid var(--border); min-height:40px; padding:0 14px; border-radius:var(--r-2); font-size:13px; font-weight:600; cursor:pointer; white-space:nowrap; display:inline-flex; align-items:center; justify-content:center; gap:6px; transition:background .12s,border-color .12s; }
    .btn-add:hover { background:var(--accent-tint); border-color:var(--accent); }
    .btn-ghost { background:none; color:var(--muted); border:none; min-height:40px; padding:0 10px; white-space:nowrap; display:inline-flex; align-items:center; border-radius:var(--r-2); font-size:14px; cursor:pointer; font-weight:600; transition:background .12s,color .12s; }
    .btn-ghost:hover { background:var(--bg); color:var(--text); }
    .btn-del { background:none; border:none; color:var(--danger); font-size:18px; cursor:pointer; padding:0 8px; min-width:36px; min-height:36px; line-height:1; border-radius:var(--r-1); }
    .btn-del:hover { background:var(--danger-tint); }
    .btn-sort { background:var(--surface); color:var(--text-2); border:1px solid var(--border); min-height:36px; padding:0 12px; border-radius:var(--r-1); font-size:12px; font-weight:600; cursor:pointer; white-space:nowrap; }
    .btn-sort:hover { background:var(--accent-tint); border-color:var(--accent); }
    .btn-header-ghost { background:rgba(255,255,255,.12); color:#fff; border:1px solid rgba(255,255,255,.22); min-height:40px; padding:0 14px; white-space:nowrap; border-radius:var(--r-2); font-size:13px; font-weight:600; cursor:pointer; transition:background .12s; }
    .btn-header-ghost:hover { background:rgba(255,255,255,.2); }
    .save-indicator { font-size:13px; color:var(--success); font-weight:600; opacity:0; transition:opacity .3s; display:inline-flex; align-items:center; gap:6px; }
    .save-indicator.show { opacity:1; }

    /* ── Form surfaces ── */
    .form-card { background:var(--surface); border:1px solid var(--border); border-radius:var(--r-3); padding:20px 22px 22px; margin-bottom:18px; box-shadow:none; }
    .section-title { font-family:var(--font-display); font-size:18px; font-weight:600; text-transform:none; letter-spacing:0; color:var(--text); margin-bottom:16px; padding-bottom:12px; border-bottom:1px solid var(--border-soft); }
    .form-card > .section-title { padding-left:0; position:static; }
    .form-card > .section-title::before { content:none; }
    .field { margin-bottom:12px; }
    .field label { display:block; font-size:12px; font-weight:600; color:var(--text-2); margin-bottom:5px; }
    .field label .hint { font-weight:400; color:var(--muted); font-size:12px; }
    input[type=text],input[type=number],input[type=date],input[type=email],select,textarea { width:100%; border:1px solid var(--border-2); border-radius:var(--r-2); padding:0 12px; min-height:var(--control-h); font-size:15px; font-weight:500; color:var(--text); outline:none; background:var(--surface); transition:border-color .12s,box-shadow .12s; box-sizing:border-box; }
    textarea { padding:10px 12px; line-height:1.5; min-height:0; resize:vertical; }
    input::placeholder,textarea::placeholder { color:var(--muted-2); font-weight:400; }
    input[type=text]:hover,input[type=number]:hover,input[type=date]:hover,input[type=email]:hover,select:hover,textarea:hover { border-color:var(--accent-2); }
    input:focus,select:focus,textarea:focus { border-color:var(--accent-2); box-shadow:0 0 0 3px var(--accent-ring); }
    select { -webkit-appearance:none; -moz-appearance:none; appearance:none; padding-right:36px; cursor:pointer; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23857d72' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 14px center; }
    input[type=number] { -moz-appearance:textfield; font-variant-numeric:tabular-nums; }
    input[type=number]::-webkit-outer-spin-button,
    input[type=number]::-webkit-inner-spin-button { -webkit-appearance:none; margin:0; }
    input[readonly], textarea[readonly] { background:var(--bg); color:var(--text-2); }
    .toggle-row { display:flex; align-items:center; gap:12px; cursor:pointer; min-height:44px; padding:0 6px; border-radius:var(--r-2); font-size:14px; font-weight:500; color:var(--text); transition:background .12s; }
    .toggle-row:hover { background:var(--bg); }
    .toggle-row input[type=checkbox],.toggle-row input[type=radio] { width:22px; height:22px; min-height:0; margin:0; accent-color:var(--navy); flex:none; }
    .included-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); gap:4px 8px; margin-top:6px; }
    .inc-item { display:flex; align-items:center; gap:8px; min-height:40px; font-size:14px; color:var(--text-2); }
    .inc-item input { width:20px; height:20px; min-height:0; accent-color:var(--navy); }
    .hw-cols { display:grid; grid-template-columns:64px 1.1fr 1fr 1fr 56px 1fr auto; gap:10px; align-items:end; margin-bottom:8px; }

    /* ── Rooms & line items ── */
    .room-card { background:var(--surface); border:1px solid var(--border); border-radius:var(--r-3); padding:0; margin-bottom:14px; overflow:hidden; }
    .room-card > .flex:first-child, .room-card > div:first-child { padding:12px 16px; background:var(--bg); border-bottom:1px solid var(--border); }
    .room-card > :not(:first-child) { margin-left:14px; margin-right:14px; }
    .room-card > :last-child { margin-bottom:14px; }
    .spec-block { background:var(--surface); border:1px solid var(--border); border-radius:10px; padding:12px 14px; margin-top:10px; }
    .hw-item { border:1px solid var(--border); border-radius:10px; padding:10px 14px 14px; margin-bottom:10px; background:var(--surface); transition:border-color .2s,box-shadow .2s; }
    .hw-item:not(.collapsed) { border-color:var(--accent); box-shadow:0 0 0 3px rgba(201,161,95,.15); }
    .hw-item.collapsed { background:var(--surface-2); cursor:pointer; }
    .hw-item.collapsed:hover { border-color:var(--accent); }
    .hw-item-head { display:flex; align-items:center; justify-content:space-between; gap:10px; min-height:32px; margin-bottom:10px; }
    .hw-item.collapsed .hw-item-head { margin-bottom:0; }
    .hw-item.collapsed > :not(.hw-item-head) { display:none !important; } /* !important: the countertop sink rows carry an inline display:flex */
    .hw-item:not(.collapsed) .cab-summary { display:none; }
    .hw-item-tag { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.08em; color:var(--accent-2); }
    .hw-item-arrow { display:inline-block; width:1em; font-size:16px; line-height:1; color:var(--muted); font-weight:700; vertical-align:-2px; margin-right:4px; transition:transform .2s var(--ease); }
    .hw-head-actions { display:flex; gap:4px; align-items:center; margin-left:auto; }
    .btn-copy { background:none; border:none; color:var(--muted); font-size:16px; cursor:pointer; min-width:36px; min-height:36px; padding:0 6px; line-height:1; border-radius:var(--r-1); }
    .btn-copy:hover { color:var(--text); background:var(--bg); }
    .cab-cat-lbl { font-size:14px; font-weight:700; color:var(--text); margin-left:4px; }
    .cab-summary { font-size:13px; font-weight:400; color:var(--muted); margin-left:8px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0; }
    #editorBody [id^="instBody-"]:not(.inst-collapsed) .cab-summary { display:none; }
    [id^="instBody-"].inst-collapsed > :not(.hw-item-head) { display:none; }
    .cab-2020 { margin-top:8px; display:flex; align-items:center; flex-wrap:wrap; gap:6px; }
    .cab-xml-chip { display:inline-flex; align-items:center; gap:4px; background:var(--accent-tint); border:1px solid var(--accent); color:var(--accent-2); border-radius:var(--r-pill); padding:4px 10px; font-size:12px; font-weight:600; margin-left:6px; }
    .cab-pricing { margin-top:8px; border:1px solid var(--border); border-radius:10px; padding:10px 12px; background:var(--surface-2); }
    .cab-pricing summary { font-size:13px; font-weight:600; color:var(--text-2); cursor:pointer; min-height:28px; display:flex; align-items:center; }
    .cab-calc-out { margin-top:8px; font-size:13px; color:var(--text-2); line-height:1.5; }
    .cab-inc-lbl { font-size:13px; font-weight:600; color:var(--text); display:inline-flex; align-items:center; gap:6px; margin-left:10px; cursor:pointer; min-height:36px; }
    .cab-inc-lbl input { margin:0; width:20px; height:20px; min-height:0; accent-color:var(--navy); }
    .cab-verify-btn { background:var(--navy); color:#fff; border:none; border-radius:var(--r-2); min-height:44px; padding:0 18px; font-size:14px; font-weight:700; cursor:pointer; white-space:nowrap; transition:background .15s,box-shadow .15s var(--ease); }
    .cab-verify-btn:hover { background:var(--navy-2); filter:none; box-shadow:var(--shadow-2); }
    .cab-verify-btn.verified { background:var(--success); }

    /* ── Document-type folder tabs ── */
    #docTypeCard { background:transparent; border:none; box-shadow:none; padding:0; margin:0 0 -1px; position:relative; z-index:3; }
    .doctype-tabs { display:flex; flex-wrap:nowrap; overflow-x:auto; scrollbar-width:none; row-gap:4px; gap:6px; align-items:flex-end; padding:0 0 0 4px; }
    .doctype-tabs::-webkit-scrollbar { display:none; }
    .doctab { flex:none; min-height:46px; padding:12px 20px; border:1px solid var(--border); border-bottom:none; border-radius:10px 10px 0 0; background:var(--surface-3); color:var(--text-2); font-weight:600; font-size:14px; cursor:pointer; position:relative; transition:background .15s,color .15s; user-select:none; white-space:nowrap; }
    .doctab:hover { background:#f0ece4; color:var(--text); }
    .doctab.active { background:var(--surface); color:var(--navy); font-weight:700; padding-top:12px; padding-bottom:13px; box-shadow:none; z-index:2; }
    .doctab.available { background:var(--surface-3); color:var(--text-2); }
    .doctab.available:hover { background:#f0ece4; color:var(--text); }
    .doctab.ghost { background:transparent; border-style:dashed; border-color:#b8ad9c; color:var(--muted); }
    .doctab.ghost::before { content:"+ "; font-weight:700; }
    .doctab.doctab-create::before { content:none; }
    .doctab.ghost:not(.locked):hover { background:var(--surface); color:var(--text); }
    .doctab.locked { opacity:.45; cursor:not-allowed; }
    .doctab.locked:hover { background:transparent; color:var(--muted); }
    #docTypeCard + .form-card { border-top-left-radius:0; }

    /* ── Purchase Order cards (editor) ── */
    .po-card { border:1px solid var(--border); border-radius:var(--r-3); padding:16px 18px; margin-bottom:12px; background:var(--surface); box-shadow:none; }
    .po-card-head { display:flex; align-items:center; gap:10px; margin-bottom:12px; flex-wrap:wrap; }
    .po-tag { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; padding:6px 10px; border-radius:var(--r-1); }
    .po-tag-vendor { background:#e8ebf4; color:#2b3a6b; }
    .po-tag-warranty { background:#f7ecd8; color:#8a5a12; }
    .po-tag-misc { background:var(--bg); color:var(--text-2); }
    .po-warr-toggle { font-size:13px; font-weight:600; color:var(--text-2); display:inline-flex; align-items:center; gap:6px; cursor:pointer; min-height:36px; }
    .po-card-head .btn-del { margin-left:auto; }
    .po-card input[readonly], .po-card textarea[readonly] { background:var(--bg); color:var(--text-2); cursor:default; }
    .po-card input.po-shade { background:var(--bg); }
    .po-keyfield { border:1px solid var(--border-2); border-radius:var(--r-2); background:var(--surface); color:var(--text); }
    .po-keyfield:focus { border-color:var(--accent-2); box-shadow:0 0 0 3px var(--accent-ring); }
    .po-atts { margin-top:12px; border-top:1px solid var(--border-soft); padding-top:12px; }
    .po-atts-list { display:flex; flex-direction:column; gap:6px; margin-bottom:8px; }
    .po-att-row { display:flex; align-items:center; justify-content:space-between; gap:8px; background:var(--surface-2); border:1px solid var(--border); border-radius:var(--r-2); padding:8px 12px; min-height:44px; font-size:14px; }
    .po-att-name { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

    /* ── Job reconciliation (screen) ── */
    .recon-tbl { width:100%; border-collapse:collapse; font-size:14px; }
    .recon-tbl th, .recon-tbl td { padding:12px 10px; border-bottom:1px solid var(--border-soft); text-align:left; }
    .recon-tbl thead th { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); background:transparent; }
    .recon-tbl .recon-amt { text-align:right; white-space:nowrap; font-family:var(--font-display); font-weight:600; font-size:15px; font-variant-numeric:tabular-nums; }
    .recon-tbl tfoot td { border-top:1px solid var(--border-2); border-bottom:none; font-weight:700; }
    .recon-tbl tfoot .recon-sum td { color:var(--text-2); }
    .recon-tbl tfoot .recon-over td { font-size:18px; font-weight:700; color:var(--navy); }
    .recon-tbl tfoot .recon-over td.recon-amt { font-size:22px; }
    .recon-in { border:1px solid var(--border-2); border-radius:var(--r-2); padding:0 10px; min-height:var(--control-h); font-size:14px; width:100%; box-sizing:border-box; text-align:right; }
    .recon-tbl td .recon-in { max-width:140px; margin-left:auto; }
    .recon-h { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.08em; color:var(--accent-2); margin:18px 0 8px; }
    .recon-foot { display:flex; flex-wrap:wrap; gap:14px; align-items:flex-end; margin-top:16px; }
    .recon-foot .field { margin:0; flex:1; min-width:180px; }
    .recon-foot .recon-in { text-align:left; }

    /* ── Payment totals ── */
    .totals-display { background:var(--bg); border:none; border-radius:12px; padding:14px 18px; box-shadow:none; }
    .tot-row { display:flex; justify-content:space-between; align-items:baseline; font-size:14px; margin-bottom:8px; color:var(--text-2); }
    .tot-row > span:last-child { font-family:var(--font-display); font-weight:600; font-size:15px; color:var(--text); font-variant-numeric:tabular-nums; }
    .tot-row.final { border-top:1px solid #d9d1c4; padding-top:10px; margin-top:2px; font-weight:700; font-size:14px; color:var(--text); }
    .tot-row.final > span:last-child { font-size:22px; font-weight:700; color:var(--navy); }

    /* ── Sticky totals bar (Phase 2 markup; harmless if absent) ── */
    .totals-bar-wrap { position:sticky; bottom:0; z-index:30; padding:0 16px 16px; pointer-events:none; }
    .totals-bar { max-width:62rem; margin:0 auto; min-height:56px; background:var(--navy); color:#fff; border-radius:var(--r-3); box-shadow:var(--shadow-bar); display:flex; align-items:center; padding:8px 10px 8px 20px; gap:18px; flex-wrap:wrap; pointer-events:auto; }
    .totals-bar .tb-cell { font-size:13px; color:rgba(255,255,255,.65); white-space:nowrap; }
    .totals-bar .tb-cell b { color:#fff; font-family:var(--font-display); font-weight:600; font-size:15px; margin-left:6px; font-variant-numeric:tabular-nums; }
    .totals-bar .tb-due { margin-left:auto; color:var(--accent); font-weight:600; }
    .totals-bar .tb-due b { font-size:20px; font-weight:700; margin-left:8px; }
    .totals-bar .btn-green { min-height:40px; }
    /* PO / Reconcile tabs: collapse the bar to just the Save & Close button */
    #totalsBar.tb-min .tb-cell { display:none; }
    #totalsBar.tb-min .totals-bar { justify-content:flex-end; }

    /* ── Settings ── */
    /* App Admin → Overview → System: small charts on one time line (two or three across, one on a phone) */
    .sys-charts { display:grid; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); gap:16px 20px; }
    .group-card { border:1px solid var(--border); border-radius:var(--r-3); background:var(--surface); padding:20px 22px; margin-bottom:16px; box-shadow:none; }
    .group-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:4px; gap:10px; }
    .group-label { font-family:var(--font-display); font-size:18px; font-weight:600; text-transform:none; letter-spacing:0; color:var(--text); }
    .group-divider { border:none; border-top:1px solid var(--border-soft); margin:12px 0 16px; }
    .setting-field { margin-bottom:20px; padding-bottom:20px; border-bottom:1px solid var(--border-soft); }
    .setting-field:last-child { margin-bottom:0; padding-bottom:0; border-bottom:none; }
    .setting-field-header { display:flex; align-items:center; gap:8px; margin-bottom:8px; flex-wrap:wrap; }
    .setting-label { font-size:14px; font-weight:700; color:var(--text); flex:1; min-width:0; }
    .tag-extra { font-size:10px; font-weight:700; background:#f7ecd8; color:#8a5a12; border-radius:4px; padding:2px 7px; letter-spacing:.04em; vertical-align:middle; }
    .tag-builtin { font-size:10px; font-weight:700; background:var(--bg); color:var(--muted); padding:3px 8px; border-radius:10px; white-space:nowrap; }
    .option-row { display:flex; align-items:center; background:var(--surface-2); border:1px solid var(--border); border-radius:var(--r-2); padding:8px 12px; min-height:44px; margin-bottom:6px; font-size:14px; transition:border-color .1s,background .1s; }
    .option-row.drag-over { border-top:2px solid var(--accent-2); background:var(--accent-tint); }
    .option-row-text { flex:1; color:var(--text); }
    .drag-handle { cursor:grab; color:var(--border-2); font-size:16px; margin-right:10px; user-select:none; letter-spacing:1px; flex-shrink:0; }
    .drag-handle:hover { color:var(--muted); }
    .option-add-row { display:flex; gap:8px; margin-top:8px; }
    .option-add-row input { flex:1; }
    .add-section-form { background:var(--accent-tint); border:1px solid var(--accent); border-radius:var(--r-2); padding:14px; margin-bottom:16px; }
    .reorder-btn { background:var(--surface); border:1px solid var(--border); border-radius:var(--r-1); min-width:36px; min-height:36px; padding:0 8px; font-size:11px; color:var(--muted); cursor:pointer; line-height:1.2; }
    .reorder-btn:hover:not([disabled]) { background:var(--bg); border-color:var(--border-2); color:var(--text); }
    .reorder-btn[disabled] { opacity:.25; cursor:not-allowed; }
    .reorder-cluster { display:flex; gap:3px; flex-shrink:0; }
    .group-card.drag-over { outline:2px solid var(--accent-2); outline-offset:-2px; background:var(--accent-tint); }
    .setting-field.drag-over { border-top:2px solid var(--accent-2); background:var(--accent-tint); border-radius:4px; }
    .bo-chip { display:inline-flex; align-items:center; margin:3px; min-height:36px; padding:0 14px; border-radius:var(--r-pill); font-size:13px; font-weight:600; cursor:pointer; user-select:none; transition:background .12s,color .12s,border-color .12s; }
    .bo-chip-on { background:var(--navy); color:#fff; border:1px solid var(--navy); }
    .bo-chip-on:hover { background:var(--navy-2); border-color:var(--navy-2); }
    .bo-chip-off { background:var(--surface); color:var(--text-2); border:1px solid var(--border-2); }
    .bo-chip-off:hover { background:var(--accent-tint); color:var(--text); border-color:var(--accent); }
    .bo-group-label { font-size:11px; font-weight:700; color:var(--accent-2); text-transform:uppercase; letter-spacing:.08em; display:block; margin:8px 0 4px; }

    /* ── Card entrance (one-time, on deliberate full re-renders) ── */
    @keyframes ksiCardIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
    .cards-enter > * { animation:ksiCardIn .32s var(--ease) both; }
    .cards-enter > :nth-child(1){animation-delay:.02s}  .cards-enter > :nth-child(2){animation-delay:.05s}
    .cards-enter > :nth-child(3){animation-delay:.08s}  .cards-enter > :nth-child(4){animation-delay:.11s}
    .cards-enter > :nth-child(5){animation-delay:.14s}  .cards-enter > :nth-child(6){animation-delay:.17s}
    .cards-enter > :nth-child(7){animation-delay:.20s}  .cards-enter > :nth-child(8){animation-delay:.23s}
    .cards-enter > :nth-child(9){animation-delay:.26s}  .cards-enter > :nth-child(n+10){animation-delay:.29s}

    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after { animation-duration:.001ms !important; animation-iteration-count:1 !important; transition-duration:.001ms !important; }
    }

    /* ══ RESPONSIVE ═══════════════════════════════════════════════ */
    html, body { max-width:100%; overflow-x:clip; }
    .view.active { max-width:100vw; overflow-x:clip; }

    /* Tablet: 768–1024px */
    @media screen and (min-width:768px) and (max-width:1024px) {
      /* Same 270px minimum as on desktop: a narrower tile (3 × 250px at 820–877px, iPad portrait)
         pushed its date and ⋯ button past the card, and the right-hand ⋯ off the screen. */
      .est-grid { grid-template-columns:repeat(auto-fill,minmax(270px,1fr)); }
      .app-header { padding:12px 20px; }
      .form-card { padding:18px 20px; }
    }

    /* Mobile: ≤767px */
    @media screen and (max-width:767px) {
      /* 16px prevents iOS auto-zoom on focus */
      input[type=text],input[type=number],input[type=date],input[type=email],select,textarea { font-size:16px !important; min-height:48px !important; }
      textarea { padding:12px !important; }
      .field label { font-size:13px; margin-bottom:6px; }
      .toggle-row { font-size:15px; min-height:48px; }
      .field { margin-bottom:14px; }

      .app-header { padding:10px 16px; gap:8px; }
      .app-header > button > div > div { font-size:14px !important; }
      .btn-header-ghost { min-height:44px; }
      .btn-green { min-height:46px; padding:0 16px; }

      .sub-header { padding:10px 16px; gap:10px; }
      #editorTitle { font-size:16px; }
      #currentFileName { display:none; }

      .btn-primary, .btn-add, .cab-verify-btn { min-height:46px; font-size:14px; }
      .btn-del { font-size:22px; min-width:44px; min-height:44px; }

      .est-grid { grid-template-columns:1fr; gap:10px; margin-top:14px; }
      .est-customer { font-size:18px; }
      .est-card-total, .est-amount { font-size:22px; }
      .search-row { grid-template-columns:1fr; }
      .status-bar { padding:12px 14px; }
      .est-list-row { flex-wrap:wrap; }
      .est-list-id .est-nameline .est-customer { flex:0 1 auto; }
      .est-list-amount, .est-list-date { width:auto; text-align:left; }

      .form-card { padding:16px; margin-bottom:12px; }
      .section-title { font-size:17px; }
      .grid-cols-2,.grid-cols-3 { grid-template-columns:1fr !important; }
      .fgrid { grid-template-columns:minmax(0,1fr) minmax(0,1fr) !important; grid-auto-flow:row dense; column-gap:10px; }
      .fgrid > .fcell { grid-column:1 / -1; }
      /* Short fields side by side */
      .fgrid > .fcell:is([data-field="ct:thickness"],[data-field="ct:edge"]) { grid-column:auto; }
      .grid-cols-5 { grid-template-columns:1fr 1fr !important; }
      .grid-cols-5 .col-span-3 { grid-column:1 / -1; }
      .included-grid { grid-template-columns:repeat(2,1fr) !important; gap:6px 10px; }
      .hw-cols { grid-template-columns:48px 1fr 1fr 1fr 44px auto !important; gap:8px; }
      .hw-cols > *:nth-child(6) { display:none; }
      .doctab { padding:10px 14px; font-size:13px; }

      .totals-display { padding:14px 16px; }
      .tot-row { font-size:15px; }
      .tot-row.final > span:last-child { font-size:22px; }
      .totals-bar-wrap { padding:0 10px 10px; }
      .totals-bar { gap:10px 14px; padding:10px 10px 10px 16px; }
      .totals-bar .tb-cell:not(.tb-due) { font-size:12px; }

      .group-card { padding:16px; }
      .setting-label { width:100%; font-size:16px; margin-bottom:6px; }
      .option-row { padding:10px 12px; min-height:48px; }
      .add-section-form > div { grid-template-columns:1fr !important; gap:14px; }
    }

    /* ══ PRINT — unchanged from previous Styles.html ══════════════ */
    /* Printed attachment page: one image per page, full printable width */
    .po-att-page { text-align:center; }
    .po-att-page img { max-width:100%; max-height:9.6in; height:auto; }
    /* Internal pricing sheet (prints between the PO and its attachments) */
    .po-pricing-page { color:#000; font-family:Arial,Helvetica,sans-serif; }
    .po-pricing-title { font-size:14pt; font-weight:800; border-bottom:2px solid #1a1a2e; padding-bottom:6px; margin-bottom:12px; }
    .po-pricing-tbl { width:100%; border-collapse:collapse; }
    .po-pricing-tbl th, .po-pricing-tbl td { border:1px solid #000; padding:6px 8px; font-size:9.5pt; text-align:left; }
    .po-pricing-tbl th { background:#f1f1f1; font-size:8pt; }
    .po-pricing-note { margin-top:12px; font-size:8pt; font-style:italic; color:#555; }
    /* ── Purchase Order printout (replica of the Kitchen Sales PO form) ── */
    .po-page { color:#000; font-family:Arial,Helvetica,sans-serif; display:flex; flex-direction:column; min-height:9.6in; }
    /* The quantity/description/amount table stretches down to just above the
       signature line so every PO fills exactly one page. */
    .po-body-fill { flex:1 1 auto; }
    .po-body-fill .po-table { width:100%; height:100%; }
    .po-head { display:flex; justify-content:space-between; align-items:flex-start; }
    .po-title { font-size:10pt; letter-spacing:.06em; }
    .po-co { font-size:21pt; font-weight:800; letter-spacing:.02em; }
    .po-co-addr { font-size:8pt; color:#333; margin-top:3px; line-height:1.4; }
    .po-head-right { text-align:right; font-size:9.5pt; line-height:2.1; white-space:nowrap; }
    .po-num { color:#c00; font-weight:800; font-size:13pt; letter-spacing:.06em; }
    .po-date { font-size:11pt; font-weight:700; }
    .po-addr { display:flex; gap:16px; margin:18px 0 12px; }
    .po-box { flex:1; border:1.5px solid #000; min-height:1.05in; padding:6px 9px; }
    .po-box-lbl { font-size:8pt; font-weight:700; color:#444; letter-spacing:.05em; }
    .po-box-body { font-size:10.5pt; white-space:pre-line; margin-top:3px; line-height:1.45; }
    .po-table { width:100%; border-collapse:collapse; }
    .po-table th, .po-table td { border:1.5px solid #000; padding:7px 9px; font-size:10pt; vertical-align:top; text-align:left; }
    .po-table th { font-size:8pt; letter-spacing:.05em; background:#f1f1f1; }
    .po-c-qty { width:0.95in; white-space:nowrap; }
    .po-c-amt { width:1.7in; font-size:10pt; line-height:1.6; }
    .po-amt-row { padding:3px 0; }
    .po-desc { white-space:pre-wrap; line-height:1.55; }
    .po-total-line { font-weight:800; margin-top:12px; border-top:1.5px solid #000; padding-top:7px; }
    /* Printed reconciliation sheet */
    .recon-print { color:#000; font-family:Arial,Helvetica,sans-serif; }
    .recon-print-head { text-align:center; margin-bottom:16px; }
    .recon-print-co { font-size:15pt; font-weight:800; letter-spacing:.02em; }
    .recon-print-title { font-size:12pt; font-weight:700; margin-top:2px; }
    .recon-print-cust { font-size:11pt; margin-top:5px; }
    .recon-print-h { font-size:9.5pt; font-weight:800; text-transform:uppercase; letter-spacing:.05em; margin:18px 0 5px; }
    .recon-print-tbl { width:100%; border-collapse:collapse; font-size:10pt; margin-bottom:4px; }
    .recon-print-tbl th, .recon-print-tbl td { border:1px solid #000; padding:5px 8px; text-align:left; }
    .recon-print-tbl th { background:#f1f1f1; font-size:8.5pt; letter-spacing:.03em; }
    .recon-print-tbl .r { text-align:right; white-space:nowrap; font-variant-numeric:tabular-nums; }
    .recon-print-tbl .c { text-align:center; color:#666; }
    .recon-print-tbl tfoot .tot td { font-weight:700; background:#fafafa; }
    .recon-print-tbl tfoot .big td, .recon-print-tbl .big td { font-size:11pt; font-weight:800; }
    .recon-print-tbl.summary { margin-top:10px; }
    .po-foot { margin-top:14px; flex:none; }
    .po-foot-note { font-size:7.5pt; color:#444; line-height:1.4; }
    .po-signed { margin-top:22px; font-size:10.5pt; }
    .po-sig-line { display:inline-block; border-bottom:1px solid #000; width:3.2in; }
    /* ── Print document ── */
    .doc-wrap { padding:0; font-family:Arial,Helvetica,sans-serif; font-size:9pt; line-height:1.45; color:#000; box-sizing:border-box; }
    .doc-header { display:flex; justify-content:space-between; align-items:flex-start; border-bottom:2.5px solid #1a1a2e; padding-bottom:16px; margin-bottom:9px; }
    .doc-co-name { font-weight:bold; font-size:11.5pt; } .doc-co-sub { font-size:8pt; color:#333; line-height:1.25; }
    .doc-title { font-size:12pt; font-weight:700; letter-spacing:.5px; color:#1a1a2e; text-align:right; }
    .doc-meta { font-size:8.5pt; text-align:right; line-height:1.7; }
    .doc-addr-grid { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin:7px 0 9px; }
    .doc-addr-box { border:1px solid #bbb; padding:6px 9px; font-size:8.5pt; line-height:1.6; }
    .doc-addr-label { font-weight:700; font-size:7.5pt; text-transform:uppercase; letter-spacing:.04em; border-bottom:1px solid #ccc; margin-bottom:4px; padding-bottom:2px; }
    .doc-table { width:100%; border-collapse:collapse; }
    .doc-table thead th { background:#1a1a2e; color:#fff; padding:5px 7px; text-align:left; font-size:8pt; font-weight:700; }
    .doc-table tbody td { padding:5px 7px; vertical-align:top; font-size:8.5pt; }
    /* Separator line only between rooms, not between item types within a room */
    .doc-table tbody tr.room-sep td { border-top:1px solid #cbd5e1; padding-top:8px; }
    .doc-table tbody tr.room-sep td.col-room { padding-top:8px; }
    .col-room { width:17%; font-weight:600; } .col-type { width:12%; } .col-spec { width:55%; white-space:pre-wrap; } .col-total { width:16%; text-align:right; font-weight:700; }
    .doc-table thead th.col-total { text-align:right; }
    .doc-footer-row td { border:none !important; padding:3px 7px; font-size:8pt; }
    .doc-total-label { text-align:right; font-weight:600; } .doc-total-val { text-align:right; font-weight:700; width:1.3in; } .doc-total-due { font-size:11pt; }
    .doc-disclaimer { font-size:7.5pt; color:#555; margin-top:4px; line-height:1.5; }
    .doc-tax-note { text-align:right; font-size:7.5pt; color:#555; margin-top:5px; line-height:1.4; }
    .doc-sig { margin-top:13px; font-size:8pt; line-height:1.7; }
    .sig-blank { display:inline-block; border-bottom:1px solid #000; vertical-align:bottom; }
    .tc-page { font-size:8pt; line-height:1.7; } .tc-page p { margin:0 0 8px; }
    .tc-header { font-size:8.5pt; font-weight:700; text-align:right; border-bottom:1px solid #ccc; padding-bottom:5px; margin-bottom:10px; }
    .doc-history { margin-top:16px; border-top:1px solid #cbd5e1; padding-top:8px; }
    .doc-history-title { font-size:8.5pt; font-weight:700; margin-bottom:6px; }
    .doc-history-entry { margin-bottom:6px; font-size:7.5pt; }
    .doc-history-when { font-weight:700; color:#333; }
    .doc-history-entry ul { margin:2px 0 0; padding-left:14px; }
  
    /* ── Preserved from legacy: non-blocking save/refresh status bubble ──
       (classes emitted by JavaScript.html on this branch; not part of the
       original handoff, which was authored against main) ── */
    .status-bubble { position:fixed; left:50%; transform:translateX(-50%); bottom:calc(22px + env(safe-area-inset-bottom,0px)); z-index:9999; display:flex; align-items:center; gap:11px; max-width:min(90vw,420px); background:var(--navy); color:#fff; font-size:15px; font-weight:600; line-height:1.35; padding:13px 22px; border-radius:999px; box-shadow:var(--shadow-2); transition:opacity .2s; }
    .status-bubble[hidden] { display:none; }
    .status-bubble .sb-icon { display:inline-flex; align-items:center; justify-content:center; width:17px; height:17px; flex:none; font-weight:800; }
    .status-bubble.sb-done { background:var(--success-2); }
    .status-bubble.sb-error { background:var(--danger); }
    .sb-spin { width:16px; height:16px; border-radius:50%; border:2px solid rgba(255,255,255,.35); border-top-color:#fff; animation:sb-rot .7s linear infinite; }
    @keyframes sb-rot { to { transform:rotate(360deg); } }
    @media (prefers-reduced-motion:reduce) { .sb-spin { animation:none; } }


    /* ── Password fields match the other text inputs ── */
    input[type=password] { width:100%; border:1px solid var(--border-2); border-radius:var(--r-2); padding:0 12px; min-height:var(--control-h); font-size:15px; font-weight:500; color:var(--text); outline:none; background:var(--surface); transition:border-color .15s,box-shadow .15s; }
    input[type=password]:hover { border-color:var(--accent-2); }
    @media screen and (max-width:767px) { input[type=password] { font-size:16px !important; min-height:48px !important; } }
    #formModal .modal-panel { max-height:calc(100vh - 40px); overflow:auto; }

    /* ── Doc tab row: overflow control (a tab-shaped ‹ | › at the row's end) ── */
    #docTypeCard.tabs-overflow { display:flex; align-items:flex-end; gap:6px; }
    #docTypeCard.tabs-overflow #docTabs { flex:1 1 auto; min-width:0; }
    #docTypeCard.tabs-can-right #docTabs { -webkit-mask-image:linear-gradient(to right,#000 calc(100% - 40px),transparent); mask-image:linear-gradient(to right,#000 calc(100% - 40px),transparent); }
    #docTypeCard.tabs-can-left #docTabs { -webkit-mask-image:linear-gradient(to left,#000 calc(100% - 40px),transparent); mask-image:linear-gradient(to left,#000 calc(100% - 40px),transparent); }
    #docTypeCard.tabs-can-left.tabs-can-right #docTabs { -webkit-mask-image:linear-gradient(to right,transparent,#000 40px,#000 calc(100% - 40px),transparent); mask-image:linear-gradient(to right,transparent,#000 40px,#000 calc(100% - 40px),transparent); }
    .doctab-nav { display:none; flex:none; min-height:46px; border:1px solid var(--border); border-bottom:none; border-radius:10px 10px 0 0; background:var(--surface-3); overflow:hidden; }
    #docTypeCard.tabs-overflow .doctab-nav { display:flex; }
    .doctab-nav button { width:38px; min-height:46px; border:none; background:transparent; color:var(--text-2); font-size:22px; font-weight:600; line-height:1; cursor:pointer; padding:0 0 3px; transition:background .15s,color .15s; }
    .doctab-nav button + button { border-left:1px solid var(--border); }
    .doctab-nav button:hover:not(:disabled) { background:#f0ece4; color:var(--text); }
    .doctab-nav button:focus-visible { outline:2px solid var(--accent-2); outline-offset:-2px; }
    .doctab-nav button:disabled { color:var(--muted-2); opacity:.45; cursor:default; }
    @media screen and (max-width:767px) { .doctab-nav button { width:34px; } }

    /* ── Print canvas (must follow the RESPONSIVE html/body and body rules) ──
       The app paginates for a 7.5in-wide printable area. WebKit (Safari, and
       every browser on iPad/iPhone) otherwise lays printed pages out wider than
       the paper, and Apple devices print into a smaller area than @page asks
       for, so pages overflowed onto extra sheets. Printing on a fixed canvas —
       7.5in, or 8in on Apple devices (html.print-compact, set in JavaScript) —
       makes the device scale it to the paper so every page fits. The screen-
       only horizontal clip must not apply, and the page background is white
       (the print block at the top of this file intends that, but the later
       body rule overrode it). body's screen min-height (100vh) must not apply
       either: on iPad, 100vh while printing is the screen height, taller than
       a sheet, so a one-page printout (a PO) gained a blank second page.
       Chrome/Edge output is unchanged. */
    @media print {
      html, body  { max-width:none; overflow:visible; background:white; min-height:0; }
      #print-view { width:7.5in; }
      html.print-compact #print-view { width:8in; }
    }

    /* Long modal messages (e.g. many recalculated price lines) scroll inside the
       dialog so its title and buttons stay on screen. */
    #appModal .modal-message { max-height:min(55vh,420px); overflow:auto; }

    /* Dialog buttons wrap onto a second row on narrow phones instead of being
       pushed off-screen (e.g. Keep Editing / Discard Changes / Save & Close). */
    #appModal .modal-actions { flex-wrap:wrap; }

    /* Status bubble: gentle fade/slide in and out (statusBubble adds .sb-visible). */
    .status-bubble { opacity:0; transform:translateX(-50%) translateY(10px); transition:opacity .4s ease, transform .4s var(--ease), background-color .3s ease; }
    .status-bubble.sb-visible { opacity:1; transform:translateX(-50%) translateY(0); }
    .status-bubble > * { transition:opacity .2s ease; }
    .status-bubble.sb-swap > * { opacity:0; }
    @media (prefers-reduced-motion:reduce) { .status-bubble, .status-bubble.sb-visible { transform:translateX(-50%); transition:opacity .2s linear; } }

    /* Pop-up stack: every short message appears bottom-center, stacked above the
       status bubble (Index.html #popupStack; showToast/statusBubble in JS). */
    .popup-stack { position:fixed; left:50%; transform:translateX(-50%); bottom:calc(22px + env(safe-area-inset-bottom,0px)); z-index:9999; display:flex; flex-direction:column; align-items:center; width:max-content; max-width:min(90vw,420px); pointer-events:none; }
    .popup-stack > * { pointer-events:auto; }
    .popup-stack .status-bubble { position:static; left:auto; bottom:auto; max-width:100%; transform:translateY(10px); }
    .popup-stack .status-bubble.sb-visible { transform:translateY(0); }
    .popup-toast { max-width:100%; box-sizing:border-box; padding:12px 22px; margin-bottom:8px; border-radius:22px; background:var(--navy); color:#fff; font-size:15px; font-weight:600; line-height:1.35; text-align:center; box-shadow:var(--shadow-2); overflow:hidden; max-height:240px;
      opacity:0; transform:translateY(10px); transition:opacity .4s ease, transform .4s var(--ease), max-height .3s ease .15s, margin .3s ease .15s, padding .3s ease .15s; }
    .popup-toast.pt-visible { opacity:1; transform:translateY(0); }
    .popup-toast.pt-leaving { opacity:0; transform:translateY(6px); max-height:0; margin-bottom:0; padding-top:0; padding-bottom:0; }
    .popup-toast.pt-success { background:var(--success-2); }
    .popup-toast.pt-error { background:var(--danger); }
    /* Admins: active alerts, at the top of the stack until they clear or are dismissed (JavaScript.html, _alertsRender) */
    .popup-alerts { display:flex; flex-direction:column; align-items:stretch; width:100%; }
    .popup-alert { display:flex; align-items:center; gap:10px; max-width:100%; box-sizing:border-box; padding:10px 10px 10px 18px; margin-bottom:8px; border-radius:22px; color:#fff; font-size:14px; font-weight:600; line-height:1.35; box-shadow:var(--shadow-2); }
    .popup-alert.pa-error { background:var(--danger); }
    .popup-alert.pa-warn { background:#b45309; }
    .popup-alert button.pa-open { flex:1 1 auto; min-width:0; border:0; padding:4px 0; min-height:0; text-align:left; font-size:14px; border-radius:0; }
    .popup-alert button.pa-open:hover { background:transparent; text-decoration:underline; }
    .popup-alert button { flex:none; border:1px solid rgba(255,255,255,.55); background:transparent; color:#fff; border-radius:999px; min-height:32px; padding:0 12px; font:inherit; font-size:13px; font-weight:700; cursor:pointer; }
    .popup-alert button:hover { background:rgba(255,255,255,.14); }
    .popup-alert button.pa-x { min-width:32px; padding:0; font-size:16px; line-height:1; }
    .popup-alert button:focus-visible { outline:2px solid #fff; outline-offset:2px; }
    @media (prefers-reduced-motion:reduce) { .popup-stack .status-bubble, .popup-stack .status-bubble.sb-visible, .popup-toast, .popup-toast.pt-visible { transform:none; } .popup-toast { transition:opacity .2s linear; } }

    /* Inline field errors in the estimate editor (_fieldError in JavaScript). */
    input.field-invalid, select.field-invalid, textarea.field-invalid { border-color:var(--danger) !important; box-shadow:0 0 0 3px rgba(176,53,43,.16) !important; background-color:var(--danger-tint); }
    .field-error { margin:6px 0 0; font-size:13px; font-weight:600; line-height:1.45; color:var(--danger); }

    /* ── App Admin page: shared-settings section, overview tiles, move highlight ── */
    .admin-tiles { display:grid; grid-template-columns:repeat(auto-fit,minmax(140px,1fr)); gap:10px; }
    .admin-section-title { font-family:var(--font-display); font-size:20px; font-weight:600; color:var(--text); margin:4px 0 4px; }
    .admin-section-note { font-size:12px; color:var(--muted); line-height:1.5; margin-bottom:14px; }

    /* ══ SHOP SETTINGS → ESTIMATE FORM (fe* in JavaScript.html) ═══════════════════ */
    .sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
    .fe-root { --ux-top:64px; }
    .fe-root .ux-muted, .ux-drawer .ux-muted { color:var(--muted); }
    .fe-root :focus-visible { outline:3px solid var(--accent); outline-offset:2px; }
    .ux-bar { position:sticky; top:var(--ux-top); z-index:30; display:flex; align-items:center; gap:12px; flex-wrap:wrap; background:var(--bg); padding:10px 0; margin-bottom:8px; border-bottom:1px solid var(--border-soft); }
    .ux-bar .btn-add[disabled], .ux-drawer-top .btn-add[disabled] { opacity:.45; cursor:not-allowed; }
    .ux-undo-what { font-weight:500; color:var(--text-2); max-width:42ch; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; display:inline-block; vertical-align:bottom; }
    .ux-bar-status { font-size:12px; color:var(--muted); }
    .ux-bar-status.is-dirty { color:#8a5a12; }
    /* the form, block by block */
    .fe-block { background:var(--surface); border:1px solid var(--border); border-radius:var(--r-3); padding:16px 18px; margin-bottom:14px; }
    .fe-block-h { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:10px; }
    .fe-block-h h3 { font-family:var(--font-display); font-size:18px; font-weight:600; }
    .fe-block-h h3 span { font-family:var(--font-ui); font-size:12px; font-weight:400; color:var(--muted); margin-left:6px; }
    .fe-sub { font-size:11px; font-weight:800; letter-spacing:.06em; text-transform:uppercase; color:var(--muted); margin:16px 0 8px; }
    .fe-grid { display:grid; gap:8px; margin-bottom:8px; }
    .fe-tile { display:flex; align-items:stretch; gap:2px; background:var(--surface); border:1px solid var(--border); border-radius:var(--r-2); min-width:0; position:relative; transition:border-color .12s, box-shadow .12s; }
    .fe-tile.fwide { grid-column:1 / -1; }
    .fe-tile:hover, .fe-tile.is-sel { border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-ring); }
    .fe-tile.is-hidden { background:var(--surface-2); border-style:dashed; }
    .fe-tile.is-hidden .fe-tile-main > :not(.ux-tile-lab) { opacity:.45; }
    .fe-tile-head { background:none; border-style:dashed; }
    .fe-tile .ux-handle { align-self:center; }
    .fe-tile-main { flex:1; min-width:0; display:flex; flex-direction:column; align-items:stretch; gap:6px; text-align:left; background:none; border:none; padding:10px 12px 10px 4px; cursor:pointer; font-size:13px; color:var(--text); border-radius:var(--r-2); }
    .fe-tile-head .fe-tile-main { flex-direction:row; align-items:center; gap:8px; padding:6px 12px 6px 4px; }
    .fe-tile.fe-dragging { opacity:.35; }
    .fe-ghost { position:fixed; left:0; top:0; z-index:80; pointer-events:none; box-shadow:var(--shadow-3); border-color:var(--accent); background:var(--accent-tint); opacity:.95; }
    .fe-tile.drop-before::before, .fe-tile.drop-after::after { content:''; position:absolute; background:var(--accent); border-radius:3px; pointer-events:none; }
    .fe-tile:not(.fwide):not(.fe-tile-head).drop-before::before { left:-6px; top:4px; bottom:4px; width:4px; }
    .fe-tile:not(.fwide):not(.fe-tile-head).drop-after::after { right:-6px; top:4px; bottom:4px; width:4px; }
    .fe-tile:is(.fwide,.fe-tile-head).drop-before::before { top:-6px; left:4px; right:4px; height:4px; }
    .fe-tile:is(.fwide,.fe-tile-head).drop-after::after { bottom:-6px; left:4px; right:4px; height:4px; }
    .fe-badge { display:inline-block; font-size:10px; font-weight:800; text-transform:uppercase; letter-spacing:.05em; padding:1px 7px; border-radius:999px; background:var(--surface-3); color:var(--text-2); margin-left:4px; vertical-align:1px; }
    .fe-fixed { font-size:12px; color:var(--muted); border-top:1px dashed var(--border); padding-top:8px; margin-top:4px; }
    .fe-field-props { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; background:var(--surface-2); border-radius:var(--r-2); padding:10px 12px; margin-bottom:14px; }
    .fe-pos { display:inline-flex; align-items:center; gap:6px; font-size:13px; color:var(--text-2); }
    .ux-tile-lab { font-size:12px; font-weight:600; color:var(--text-2); }
    .ux-tile-select, .ux-tile-ctl { display:block; border:1px solid var(--border); border-radius:var(--r-1); padding:8px 30px 8px 10px; background:var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23857d72' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; font-size:13px; }
    .ux-tile-ctl { background-image:none; font-style:italic; color:var(--muted); }
    .ux-tile-checks, .ux-tile-chips { display:flex; flex-wrap:wrap; gap:4px 12px; font-size:12px; color:var(--text-2); }
    .ux-tile-chips span { border:1px solid var(--border); border-radius:var(--r-pill); padding:2px 10px; }
    .ux-tile-meta { font-size:11px; color:var(--muted); }
    /* lists: choices, room sections */
    .ux-opts { list-style:none; margin:0 0 6px; padding:0; }
    .ux-item { display:flex; align-items:center; gap:6px; background:var(--surface-2); border:1px solid var(--border); border-radius:var(--r-2); padding:4px 6px; min-height:48px; margin-bottom:6px; position:relative; }
    .ux-sorting .ux-item { transition:transform .15s var(--ease); }
    .ux-item.ux-dragging { transition:none; z-index:5; box-shadow:var(--shadow-2); background:var(--accent-tint); border-color:var(--accent); }
    .ux-handle { flex:none; width:40px; height:40px; border:none; background:none; color:var(--muted-2); font-size:18px; cursor:grab; touch-action:none; border-radius:var(--r-1); user-select:none; -webkit-user-select:none; }
    .ux-handle:hover { color:var(--text); background:var(--bg); }
    .ux-dragging .ux-handle, .fe-dragging .ux-handle { cursor:grabbing; }
    .ux-num { flex:none; width:22px; text-align:right; font-size:12px; font-weight:700; color:var(--muted); font-variant-numeric:tabular-nums; }
    .ux-opt-text { flex:1; min-width:0; text-align:left; font-size:14px; color:var(--text); background:none; border:none; padding:8px 6px; border-radius:var(--r-1); cursor:text; }
    button.ux-opt-text:hover { background:var(--surface); box-shadow:inset 0 0 0 1px var(--border); }
    .fe-secs button.ux-opt-text { cursor:pointer; }
    .ux-rename { flex:1; min-width:0; height:38px; }
    .ux-row-btns { display:flex; gap:3px; flex:none; align-items:center; }
    .ux-row-btns .reorder-btn { min-width:36px; min-height:36px; }
    .ux-danger { color:var(--danger); }
    .ux-tag-cat { font-size:10px; font-weight:700; background:#eef2ff; color:#4338ca; padding:2px 7px; border-radius:10px; white-space:nowrap; }
    .ux-addsec, .ux-sec-props { display:grid; grid-template-columns:1fr 1fr auto; gap:10px; align-items:end; margin-bottom:14px; }
    /* the drawer: one field's choices */
    .ux-scrim { position:fixed; inset:0; background:rgba(28,26,23,.35); z-index:60; }
    .ux-drawer { position:fixed; top:0; right:0; bottom:0; width:min(560px,100vw); background:var(--surface); z-index:61; box-shadow:var(--shadow-3); overflow:auto; padding:18px 22px 40px; overscroll-behavior:contain; }
    .ux-drawer-top { position:sticky; top:-18px; z-index:2; display:flex; justify-content:flex-end; gap:8px; background:var(--surface); padding:8px 0; margin:-8px 0 6px; }
    body.ux-drawer-open { overflow:hidden; }
    .ux-ed-head { margin-bottom:14px; }
    .ux-ed-title { font-family:var(--font-display); font-size:22px; font-weight:600; color:var(--text); }
    .ux-ed-where { font-size:13px; color:var(--text-2); margin-top:2px; }
    .ux-preview { background:var(--surface-2); border:1px dashed var(--border-2); border-radius:var(--r-2); padding:12px 14px; margin-bottom:16px; }
    .ux-preview-h { font-size:11px; font-weight:800; letter-spacing:.06em; text-transform:uppercase; color:var(--muted); margin-bottom:8px; }
    .ux-note { font-size:13px; color:var(--text-2); background:#eef2ff; border-radius:var(--r-2); padding:10px 12px; margin-bottom:14px; line-height:1.5; }
    .ux-hint { font-size:12px; color:var(--muted); margin-top:8px; }
    .ux-list-tools { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:8px; }
    .ux-list-h { font-size:11px; font-weight:800; letter-spacing:.06em; text-transform:uppercase; color:var(--muted); }
    .ux-brand { border-top:1px solid var(--border-soft); margin-top:18px; padding-top:14px; }
    .ux-brand-h { font-size:15px; font-weight:700; color:var(--text); margin-bottom:10px; }
    .ux-brand-row { display:flex; gap:12px; align-items:end; flex-wrap:wrap; margin-bottom:10px; }
    .ux-brand-count { font-size:13px; color:var(--text-2); padding-bottom:12px; }
    .ux-brand-btns { display:flex; gap:6px; padding-bottom:4px; margin-left:auto; }
    .ux-bfilter { width:100%; margin-bottom:8px; }
    .ux-drawer input[type=search] { width:100%; border:1px solid var(--border-2); border-radius:var(--r-2); padding:0 12px; min-height:var(--control-h); font-size:15px; font-weight:500; color:var(--text); background:var(--surface); box-sizing:border-box; -webkit-appearance:none; appearance:none; }
    .ux-checks { display:grid; grid-template-columns:repeat(auto-fill,minmax(200px,1fr)); gap:4px 8px; max-height:360px; overflow:auto; padding:2px; }
    .ux-check { display:flex; align-items:center; gap:8px; min-height:40px; padding:4px 10px; border:1px solid var(--border); border-radius:var(--r-2); font-size:13px; cursor:pointer; background:var(--surface); color:var(--muted); }
    .ux-check.is-on { color:var(--text); background:var(--surface-2); }
    .ux-check input { width:18px; height:18px; flex:none; }
    @media screen and (max-width:899px) { .ux-sec-props, .ux-addsec { grid-template-columns:1fr; } }
    @media screen and (max-width:767px) {
      .fe-root { --ux-top:56px; }
      .fe-block { padding:12px; }
      .fe-grid { grid-template-columns:1fr !important; }
      .ux-drawer { padding:14px 14px 40px; }
      .ux-row-btns .reorder-btn { min-width:32px; }
    }

    /* ══ SETTINGS, SHOP SETTINGS & ADMIN WIDTH ════════════════════════════════════
       From 1200px both pages line up with the dashboard (max-w-6xl) and use two
       columns where that helps; prose stays at a readable 64ch. Below 1200px
       they keep the 48rem column: a single wider column only spreads labels
       away from their values. Phones are unaffected (the column is narrower). */
    @media screen and (max-width:1199px) { #settingsView > .max-w-6xl, #adminView > .max-w-6xl, #shopView > .max-w-6xl { max-width:48rem; } }
    @media screen and (min-width:1200px) {
      /* App Admin's text uses its cards' full width (owner's choice); the other pages keep a readable measure */
      #settingsView .max-w-6xl p, #shopView .max-w-6xl p { max-width:64ch; }
      #settingsBody { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); column-gap:16px; align-items:start; }
      /* User Settings → Account (owner, 2026-10-04): User with Passkeys right under it on the left, Devices on the right.
         The second row takes any extra height, so Passkeys sits under User however long the Devices list grows. */
      #settingsBody[data-tab="account"] { grid-template-rows:auto 1fr; }
      #settingsBody[data-tab="account"] > #acctCard { grid-column:1; grid-row:1; }
      #settingsBody[data-tab="account"] > #passkeysCard { grid-column:1; grid-row:2; }
      #settingsBody[data-tab="account"] > #devicesCard { grid-column:2; grid-row:1 / span 2; }
      /* Admin: one column of cards, the selected tab's (JavaScript.html, _ADMIN_TABS). Shop Settings: one full-width column of cards. */
      .admin-tiles { grid-template-columns:repeat(4,minmax(0,1fr)); } /* two even rows of four */
      .log-file-row { max-width:32rem; }
    }

    /* ══ PHONE LAYOUT (≤767px) ════════════════════════════════════
       One system for every screen on a phone. Desktop, tablet and print
       never match this block (screen + max-width:767px), so they are
       unchanged. It comes last, so it wins over the RESPONSIVE rules above
       (it supersedes their 48px control height).
         Rhythm   12px page gutter · 14px card padding · 8px between cards
                  · 10px between fields
         Controls 44px tall with 16px text (no iOS zoom on focus); every
                  tap target ≥ 44px (chips and toggles grow their hit area
                  with an invisible ::after instead of looking bigger)
         Chrome   one compact header row (the dashboard adds its search row);
                  back buttons become a 44px ← icon; one 56px bottom bar
         Type     brand fonts as on desktop: serif names, titles and money;
                  11px caps labels; 12–13px muted meta, one line, ellipsis
         Sheets   confirm dialogs rise from the bottom (thumb reach);
                  forms stay centred; everything sized to the visible
                  viewport (dvh/svh) and the safe areas
       ════════════════════════════════════════════════════════════ */
    @media screen and (max-width:767px) {
      :root { --ph-gutter:12px; --ph-pad:14px; --ph-gap:8px; }

      /* ── 1. Controls & buttons ── */
      input[type=text],input[type=number],input[type=date],input[type=email],input[type=password],select,textarea { min-height:44px !important; }
      input[type=date] { -webkit-appearance:none; appearance:none; display:block; }
      input[type=date]::-webkit-date-and-time-value { text-align:left; }
      .field { margin-bottom:10px; }
      .field label { font-size:12px; margin-bottom:4px; line-height:1.35; }
      .toggle-row { min-height:44px; }
      .btn-primary, .btn-add, .btn-green, .cab-verify-btn, .btn-header-ghost { min-height:44px; }
      .btn-copy { min-width:44px; min-height:44px; }
      .card-menu-btn, .user-bubble { width:44px; height:44px; }
      .section-title { font-size:17px; margin-bottom:12px; padding-bottom:10px; }

      /* ── 2. Headers (dashboard, settings, admin, sign-in) ── */
      .app-header { min-height:60px; gap:8px 10px; padding:8px max(var(--ph-gutter), env(safe-area-inset-right)) 8px max(var(--ph-gutter), env(safe-area-inset-left)); }
      .app-header .user-bubble { margin-left:0 !important; }
      .user-dropdown { top:calc(56px + env(safe-area-inset-top, 0px)); right:max(var(--ph-gutter), env(safe-area-inset-right)); }
      /* Dashboard: [logo · wordmark … New Estimate · avatar] over a full-width search.
         The brand takes whatever is left (flex-basis 0), so the first row never wraps. */
      #dashView .app-header > button:first-child { flex:1 1 0; min-width:0; min-height:44px; gap:8px !important; }
      #dashView .app-header > button:first-child svg { flex:none; width:30px; height:28px; }
      #dashView .app-header > button:first-child > div { min-width:0; }
      #dashView .app-header > button > div > div { font-size:clamp(12px, 3.4vw, 15px) !important; letter-spacing:.05em !important; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
      #dashView .app-header > div.flex { flex:none; gap:6px; }
      #dashView .app-header .btn-green { padding:0 12px; }
      /* The search pill is the 44px tap target; its field fills it at 16px (no iOS zoom). */
      .header-search { height:44px; padding:0 12px; gap:8px; }
      .header-search input[type=text] { height:100%; min-height:0 !important; font-size:16px !important; }
      /* Settings / Shop Settings / Admin: one row — [←] USER SETTINGS … [Save] [avatar] */
      #settingsView .app-header, #adminView .app-header, #shopView .app-header { flex-wrap:nowrap; }
      #settingsView .app-header > div:first-child, #adminView .app-header > div:first-child, #shopView .app-header > div:first-child { flex:1 1 auto; min-width:0; gap:10px; }
      #settingsView .app-header > div:first-child > div, #adminView .app-header > div:first-child > div, #shopView .app-header > div:first-child > div { min-width:0; padding-left:10px !important; }
      #settingsView .app-header > div:first-child > div > div, #adminView .app-header > div:first-child > div > div, #shopView .app-header > div:first-child > div > div { font-size:14px !important; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
      #settingsView .app-header > div:last-child, #adminView .app-header > div:last-child, #shopView .app-header > div:last-child { flex:none; }
      #adminView .app-header .btn-green, #shopView .app-header .btn-green { padding:0 14px; }
      #adminSaveIndicator, #shopSaveIndicator { display:none; } /* the "Changes saved." toast confirms instead */
      /* Every "← Dashboard" becomes a 44px arrow; the words stay for screen readers */
      #settingsView .app-header .btn-header-ghost, #adminView .app-header .btn-header-ghost, #shopView .app-header .btn-header-ghost,
      #editorView .sub-header > div:first-child > button { flex:none; width:44px; min-width:44px; padding:0; font-size:0; display:inline-flex; align-items:center; justify-content:center; }
      #settingsView .app-header .btn-header-ghost::before, #adminView .app-header .btn-header-ghost::before, #shopView .app-header .btn-header-ghost::before,
      #editorView .sub-header > div:first-child > button::before { content:"\2190"; font-size:20px; line-height:1; }
      /* Editor: [←] | title (2 lines) … [Import XML] [Print] [⋯] in one 56px row */
      .sub-header { min-height:56px; gap:8px; padding:6px max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left)); }
      #editorView .sub-header > div:first-child { gap:8px; }
      #editorView .sub-header > div:first-child > div { padding-left:8px; }
      #editorTitle { white-space:normal; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; font-size:15px; line-height:1.25; overflow-wrap:anywhere; }
      #printBtn { padding:0 12px; }
      /* "Import XML" (owner, 2026-10-04: no other product's name) is short enough to show whole */
      #import2020Btn { padding:0 12px; }

      /* ── 3. Dashboard: filters and tools ── */
      #dashView > .max-w-6xl { padding:12px var(--ph-gutter) 24px; }
      .dash-toolbar { gap:8px; margin-bottom:0; }
      /* Status / Sort side by side; the label sits inside the field, like the other caps labels */
      .dash-toolbar .filter-field { position:relative; flex:1 1 0; min-width:0; }
      .dash-toolbar .filter-field label { position:absolute; z-index:1; left:13px; top:6px; font-size:10px; line-height:12px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--muted); pointer-events:none; }
      .dash-toolbar select { height:44px; padding:14px 30px 0 12px; font-weight:600; background-position:right 12px center; }
      .dash-toolbar-actions { gap:8px; }
      .dash-toolbar-actions .btn-add { flex:1 1 0; }
      .layout-btn { position:relative; }
      .layout-btn::after { content:""; position:absolute; top:-4px; bottom:-4px; left:0; right:0; } /* 44px hit area inside the 44px pill */

      /* ── 4. Dashboard: tile cards ──
         [STATUS ········ $total] / name (≤2 lines) / PO line / ref · rooms / dates · [Open][⋯] */
      .est-grid { grid-template-columns:minmax(0,1fr); gap:var(--ph-gap); margin-top:12px; }
      .est-card { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:0; min-width:0; padding:12px var(--ph-pad); }
      .est-card.skeleton-card { display:block; }
      .est-card-top, .est-card-bottom { display:contents; }
      .est-card .est-status { grid-area:1 / 1; justify-self:start; align-self:center; width:auto; white-space:nowrap; padding:4px 8px; }
      .est-card .est-card-total { grid-area:1 / 2; justify-self:end; padding-left:10px; font-size:20px; }
      .est-card .est-card-id { grid-area:2 / 1 / 3 / 3; min-width:0; margin-top:8px; display:flex; flex-wrap:wrap; align-items:baseline; }
      .est-card .est-nameline { flex:1 0 100%; min-width:0; gap:0; margin-bottom:1px; }
      .est-card .est-customer { flex:1 0 100%; font-size:17px; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden; overflow-wrap:anywhere; }
      .est-card .est-ponum { flex:1 0 100%; min-width:0; font-size:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
      .est-card .est-company { flex:1 0 100%; min-width:0; margin:0 0 1px; }
      .est-card .est-po { flex:0 1 auto; max-width:60%; margin:0; font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
      .est-card .est-card-room { flex:1 1 0; min-width:0; }
      .est-card .est-po + .est-card-room::before { content:"\00b7"; margin:0 6px; color:var(--muted-2); }
      .est-card .est-date-small { grid-area:3 / 1; align-self:stretch; display:flex; flex-direction:column; justify-content:center; text-align:left; margin-top:10px; padding-top:8px; border-top:1px solid var(--border-soft); }
      .est-card .est-card-actions { grid-area:3 / 2; margin-top:10px; padding:8px 0 0 10px; border-top:1px solid var(--border-soft); }

      /* ── 5. Dashboard: list rows ── [name ········ $total] / [STATUS] ref … [Open][⋯] */
      .est-list { margin-top:12px; }
      .est-list-row { display:grid; grid-template-columns:auto minmax(0,1fr) auto; align-items:center; gap:6px 10px; min-height:0; padding:10px 12px 10px var(--ph-pad); }
      .est-list-row > .est-list-id, .est-list-row .est-list-id > div { display:contents !important; }
      .est-list-row .est-nameline { grid-area:1 / 1 / 2 / 3; min-width:0; margin:0; }
      .est-list-row .est-list-amount { grid-area:1 / 3; align-self:start; width:auto; text-align:right; font-size:16px; line-height:1.25; }
      .est-list-row .est-customer { white-space:normal; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; text-overflow:clip; overflow-wrap:anywhere; }
      .est-list-row .est-status { grid-area:2 / 1; justify-self:start; align-self:center; width:auto; white-space:nowrap; padding:4px 8px; }
      .est-list-row .est-po { grid-area:2 / 2; min-width:0; margin:0; font-size:12px; color:var(--muted); }
      .est-list-row .est-list-actions { grid-area:2 / 3; }
      .est-list-row .est-ponum, .est-list-row .est-card-room, .est-list-row .est-list-date { display:none; }
      /* A Bill To company: its own line under the name; status, ref and actions move down one row */
      .est-list-row .est-company { grid-area:2 / 1 / 3 / 3; min-width:0; margin:-4px 0 0; font-size:12px; }
      .est-list-row:has(.est-company) .est-status { grid-row:3; }
      .est-list-row:has(.est-company) .est-po { grid-row:3; }
      .est-list-row:has(.est-company) .est-list-actions { grid-row:3; }

      .storage-warning { flex-wrap:wrap; padding:12px var(--ph-pad); }

      /* ── 6. Menus, pop-ups ── */
      #cardsGrid > :last-child:not(:first-child) .card-menu { top:auto; bottom:calc(100% + 6px); } /* the bottom card's ⋯ menu opens upward, on screen */
      .popup-toast, .popup-stack .status-bubble { font-size:14px; padding:10px 16px; }
      body:has(#editorView.active) .popup-stack { bottom:calc(76px + env(safe-area-inset-bottom, 0px)); } /* above the totals bar */
      body > div[role=alert] a { display:inline-block; padding:10px 0; margin:-10px 0; }
      body > div[role=alert] > button { width:44px !important; height:44px !important; }

      /* ── 7. Dialogs: confirm dialogs are bottom sheets, forms stay centred ── */
      .modal-panel { padding:20px 18px; overscroll-behavior:contain; }
      #appModal.modal-overlay { align-items:flex-end; padding:12px 10px calc(10px + env(safe-area-inset-bottom, 0px)); }
      #appModal .modal-actions { gap:8px; margin-top:16px; }
      #appModal .modal-actions > button { flex:1 1 0; min-height:48px; padding:0 12px; }
      #appModal .modal-actions:has(#modalThird:not(.hidden)) { flex-direction:column-reverse; } /* 3 choices: stacked, primary on top */
      #appModal .modal-message { max-height:min(55vh, 420px); max-height:min(55svh, 420px); }
      #formModal .modal-panel { max-height:calc(100vh - 40px); max-height:calc(100dvh - 40px); }

      /* ── 8. Sign-in ── */
      body > .login-wrap { min-height:0; padding:20px var(--ph-gutter) 32px; }
      .login-card { padding:20px 16px; }
      .login-foot a { display:inline-block; padding:13px 16px; margin:-13px 0; }

      /* ── 9. Editor: page, tabs, cards ── */
      #editorBody { padding:12px 10px 16px; }
      #editorBody > .form-card:not(#docTypeCard) { padding:14px 12px; margin-bottom:10px; }
      .doctab { min-height:44px; padding:10px 12px; }
      .doctab-nav, .doctab-nav button { min-height:44px; }
      .doctab-nav button { width:44px; }
      /* One vertical rhythm: the field margin spaces stacked fields, not the grid gap as well */
      #editorBody .grid { row-gap:0; }
      #editorBody .grid.gap-5, #editorBody .grid.gap-6 { row-gap:12px; }
      /* Short fields side by side */
      #editorBody .grid-cols-3:has(> .field > #poNumber) { grid-template-columns:minmax(0,1fr) minmax(0,1fr) !important; column-gap:10px; }
      #editorBody .grid-cols-3:has(> .field > #poNumber) > .field:nth-child(3) { grid-column:1 / -1; }
      .grid-cols-5 { grid-template-columns:minmax(0,1fr) 56px 112px !important; }
      .grid-cols-5 .col-span-3 { grid-column:auto; }
      #editorBody .grid-cols-2:has(#depositPct) > div:first-child { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); column-gap:10px; }
      .cab-pricing .grid-cols-3, [id^="ctitem-"] .grid-cols-3 { grid-template-columns:minmax(0,1fr) minmax(0,1fr) !important; column-gap:10px; }
      .cab-pricing .grid-cols-3 > .field:has(select[id^="cabDelivSel-"]) { grid-column:1 / -1; }
      .cab-pricing select[id^="cabMultOp-"] { width:50px !important; padding:0 18px 0 10px !important; background-position:right 7px center !important; }
      [id^="ctitem-"] .grid-cols-3 > .field:not(:has(select[id^="ctThick-"], select[id^="ctEdge-"])) { grid-column:1 / -1; }
      [id^="hwitem-"] .grid-cols-3.mt-2 { grid-template-columns:repeat(3, minmax(0,1fr)) !important; column-gap:8px; }
      .po-card > .po-card-head + .grid-cols-3 { grid-template-columns:minmax(0,1fr) minmax(0,1fr) !important; column-gap:10px; }
      .po-card > .po-card-head + .grid-cols-3 > .field:first-child { grid-column:1 / -1; }
      .po-card > .grid-cols-3:has(input[id^="poSub-"]) { grid-template-columns:repeat(3, minmax(0,1fr)) !important; column-gap:8px; }
      .po-card > .grid-cols-3:has(input[id^="poSub-"]) input { padding:0 8px; }

      /* ── 10. Editor: rooms and line items (one level of boxes, not five) ── */
      .room-card { margin-bottom:10px; }
      .room-card > :not(:first-child) { margin-left:10px; margin-right:10px; }
      .room-card > .flex:first-child, .room-card > div:first-child { padding:10px; }
      /* Room header: label + Duplicate/✕ on one line, the chips get the full width */
      .room-card > .flex:first-child { flex-wrap:wrap; align-items:center; }
      .room-card > .flex:first-child > div:first-child { display:contents; }
      .room-card > .flex:first-child > div:first-child > div:first-child { flex:1 1 0; min-width:0; margin:0 !important; }
      .room-card > .flex:first-child > div:last-child { order:1; margin-left:8px !important; }
      .room-card > .flex:first-child > div:first-child > div:nth-child(2) { order:2; flex:1 1 100%; margin:8px 0 6px !important; }
      .room-card > .flex:first-child > div:first-child > input { order:3; flex:1 1 100%; width:100% !important; }
      .bo-chip { position:relative; min-height:40px; margin:2px; padding:0 13px; }
      .bo-chip::after { content:""; position:absolute; top:-2px; bottom:-2px; left:0; right:0; }
      .spec-block { border-width:1px 0 0; border-radius:0; padding:8px 0 4px; margin-top:4px; }
      .spec-block > .flex.justify-between { flex-wrap:wrap; column-gap:8px; }
      .spec-block > .flex.justify-between > .btn-add { white-space:normal; text-align:left; padding:0 12px; }
      .hw-item { padding:6px 10px 10px; }
      .cab-pricing { padding:6px 10px; }
      .cab-pricing summary { flex-wrap:wrap; min-height:44px; column-gap:6px; }
      .cab-pricing summary .hint { flex-basis:100%; font-size:12px; font-weight:400; }
      .inc-item { min-height:44px; line-height:1.25; }
      .included-grid { gap:0 10px; }
      /* Collapsed items: spec + price on their own line under the header */
      .hw-item-head { flex-wrap:wrap; row-gap:0; }
      .hw-item-tag { min-height:44px; display:inline-flex; align-items:center; }
      .hw-item-head .cab-cat-lbl { flex:1 1 0; min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
      .hw-item-head .cab-summary { order:5; flex:1 1 100%; margin:0 0 2px; white-space:normal; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; }
      /* Countertop sink rows: the label wraps, Qty stays on screen */
      [id^="ctitem-"] > div[style*="display:flex"] > .toggle-row { flex:1 1 auto !important; min-width:0; }
      [id^="ctitem-"] > div[style*="display:flex"] > input[type=number] { flex:0 0 72px; }
      /* Hardware rows: a small stacked card instead of six squeezed columns (each field has an aria-label) */
      .hw-cols:not([id]) { display:none !important; }
      [id^="hwrow-"].hw-cols { grid-template-columns:minmax(0,1fr) minmax(0,1fr) auto !important; gap:6px 8px; padding:8px; border:1px solid var(--border-soft); border-radius:var(--r-2); background:var(--surface-2); }
      [id^="hwrow-"].hw-cols > :nth-child(1) { grid-area:1 / 1; padding:0 26px 0 12px; background-position:right 9px center; } /* "Knob" fits beside the chevron */
      [id^="hwrow-"].hw-cols > :nth-child(5) { grid-area:1 / 2; }
      [id^="hwrow-"].hw-cols > :nth-child(7) { grid-area:1 / 3; }
      [id^="hwrow-"].hw-cols > :nth-child(2) { grid-area:2 / 1 / 3 / 3; }
      [id^="hwrow-"].hw-cols > :nth-child(3) { grid-area:2 / 3; width:96px; }
      [id^="hwrow-"].hw-cols > :nth-child(4) { grid-area:3 / 1 / 4 / 4; }
      [id^="hwrow-"].hw-cols > :nth-child(6) { display:block !important; grid-area:4 / 1 / 5 / 4; }

      /* ── 11. Editor: purchase orders and reconciliation ── */
      .po-card { padding:12px 10px; }
      .field .po-warr-toggle { display:inline-flex; align-items:center; gap:8px; min-height:44px; margin:0; }
      .po-warr-toggle input { width:22px; height:22px; accent-color:var(--navy); }
      .po-att-name { white-space:normal; overflow-wrap:anywhere; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; }
      #poCard > p.text-xs, #reconCard > p.text-xs { font-size:12px; line-height:1.45 !important; }
      /* Reconcile: each PO is a stacked row with labelled amounts instead of a 492px table */
      #reconBody .recon-tbl thead { display:none; }
      #reconBody .recon-tbl, #reconBody .recon-tbl tbody, #reconBody .recon-tbl tfoot { display:block; }
      #reconBody .recon-tbl tr { display:grid; grid-template-columns:repeat(3, minmax(0,1fr)); gap:4px 8px; padding:10px 0; border-bottom:1px solid var(--border-soft); }
      #reconBody .recon-tbl td { display:block; padding:0; border:0; min-width:0; }
      #reconBody .recon-tbl tbody td:nth-child(1) { font-weight:700; }
      #reconBody .recon-tbl tbody td:nth-child(2) { grid-column:2 / -1; }
      #reconBody .recon-tbl td[colspan] { grid-column:1 / -1; }
      #reconBody .recon-tbl td.recon-amt { text-align:left; }
      #reconBody .recon-tbl td .recon-in { max-width:none; margin:0; text-align:left; padding:0 8px; }
      #reconBody .recon-tbl tbody td.recon-amt::before, #reconBody .recon-tbl tfoot .recon-sum td.recon-amt::before { display:block; font:700 11px/1.4 var(--font-ui); letter-spacing:.06em; text-transform:uppercase; color:var(--muted); margin-bottom:3px; }
      #reconBody table:first-of-type tbody td:nth-child(3)::before, #reconBody table:first-of-type tfoot td:nth-child(2)::before { content:"Retail"; }
      #reconBody table:first-of-type tbody td:nth-child(4)::before, #reconBody table:first-of-type tfoot td:nth-child(3)::before { content:"Actual"; }
      #reconBody table:first-of-type tbody td:nth-child(5)::before, #reconBody table:first-of-type tfoot td:nth-child(4)::before { content:"Difference"; }
      #reconBody table:last-of-type tbody td:nth-child(3) { grid-column:1 / -1; }
      #reconBody table:last-of-type tbody td:nth-child(3)::before { content:"Amount"; }
      #reconBody table:last-of-type tfoot tr { grid-template-columns:minmax(0,1fr) auto; align-items:baseline; }
      .recon-foot .field { min-width:0; flex:1 1 40%; max-width:none !important; }
      .recon-foot .field:first-child { flex-basis:100%; }

      /* ── 12. Editor: totals bar — one 56px row: Subtotal · Balance Due · Save
         (Deposit and Paid stay in the Payment Terms card) ── */
      .totals-bar-wrap { padding:0 8px calc(8px + env(safe-area-inset-bottom, 0px)); }
      .totals-bar { flex-wrap:nowrap; gap:12px; min-height:0; padding:6px 6px 6px 14px; }
      .totals-bar .tb-cell, .totals-bar .tb-cell:not(.tb-due) { display:flex; flex-direction:column; font-size:11px; line-height:1.15; }
      .totals-bar .tb-cell b { margin-left:0; font-size:15px; }
      .totals-bar .tb-cell:nth-child(2), .totals-bar .tb-cell:nth-child(3) { display:none; }
      .totals-bar .tb-due { margin-left:auto; text-align:right; }
      .totals-bar .tb-due b { margin-left:0; font-size:18px; }
      .totals-bar .btn-green { flex:none; min-height:44px; padding:0 14px; }

      /* ── 13. Settings (personal), Shop Settings (the shared option groups, brand options, pricing, notes & terms) and Admin ── */
      #settingsView .max-w-6xl, #adminView .max-w-6xl, #shopView .max-w-6xl { padding:14px var(--ph-gutter) 0; }
      #adminView .max-w-6xl > p:first-of-type, #shopView .max-w-6xl > p:first-of-type { margin-bottom:12px !important; }
      #settingsView .group-card, #adminView .group-card, #shopView .group-card { padding:var(--ph-pad); margin-bottom:12px !important; }
      #settingsView .group-divider, #adminView .group-divider, #shopView .group-divider { margin:10px 0 12px; }
      #settingsView .grid.gap-4, #adminView .grid.gap-4, #shopView .grid.gap-4 { row-gap:0; }
      #shopView .setting-field { margin-bottom:14px; padding-bottom:14px; }
      /* Section header: ▲▼ + label on row 1, tags and controls on row 2 (no overlap) */
      #shopView .setting-field-header { row-gap:8px; }
      #shopView .setting-field-header > .drag-handle, #shopView .group-header .drag-handle { display:none; } /* group/section drag needs a mouse */
      #shopView .setting-field-header .setting-label { flex:1 1 auto; width:auto; max-width:calc(100% - 100px); margin-bottom:0; overflow-wrap:anywhere; }
      #shopView .setting-field-header select { padding:0 36px 0 12px !important; border-radius:var(--r-2) !important; }
      #shopView .setting-field-header > .btn-sort, #shopView .setting-field-header > select, #shopView .setting-field-header > .btn-del { order:2; }
      #shopView .setting-field-header:has(> select, > .btn-sort) > .tag-builtin { order:2; }
      #shopView .setting-field-header:has(> select, > .btn-sort)::after { content:""; order:1; flex-basis:100%; height:0; }
      #shopView .reorder-btn { min-width:44px; min-height:44px; font-size:12px; }
      #shopView .btn-sort { min-height:44px; padding:0 14px; font-size:13px; }
      #brandConfigBody .btn-sort { min-height:44px !important; min-width:56px; padding:0 14px !important; font-size:13px !important; }
      #acctCard button[onclick="signOut()"] { min-height:44px; }
      /* Option rows: 48px, the ✕ fills the row height */
      #shopView .option-row { min-height:48px; margin-bottom:4px; padding:0 0 0 12px; }
      #shopView .option-row .option-row-text { padding:12px 0; }
      #shopView .option-row .btn-del { min-width:48px; min-height:46px; }
      /* Price book: the item name gets its own full-width line */
      #priceBookCard > div > div { flex-wrap:wrap; }
      #priceBookCard > div > div > input[type=text] { flex:1 1 100% !important; }
      #priceBookCard > div > div > input[type=number] { flex:1 1 0 !important; width:auto !important; min-width:0; }
      /* Readable hints (inline #94a3b8 is 2.6:1 on white) and word-safe wrapping */
      #settingsView [style*="color:#94a3b8"], #adminView [style*="color:#94a3b8"], #adminView [style*="color:#cbd5e1"], #shopView [style*="color:#94a3b8"] { color:var(--muted) !important; }
      #acctCard [style*="break-all"], #adminsCard [style*="break-all"] { word-break:normal !important; overflow-wrap:anywhere; }
      /* Admin */
      #serverCard .grid-cols-2 { grid-template-columns:1fr 1fr !important; column-gap:12px; align-items:end; }
      #replSettings .grid-cols-2:has(input[type=number]) { grid-template-columns:1fr 1fr !important; column-gap:12px; align-items:end; }
      #logsCard .dash-toolbar-actions { width:auto; margin-left:0; }
      #logsCard .dash-toolbar .filter-field:nth-child(3) { flex:1 1 0 !important; }
      #adminView .log-tbl > tbody > tr > td:first-child { display:flex !important; flex-wrap:wrap; align-items:center; gap:4px 10px; }
      #adminView .log-tbl > tbody > tr > td:first-child > div:last-child { margin-top:0 !important; }
      #adminView a[href^="/api/backups/"], #adminView a[href^="/api/admin/logs/"] { display:inline-flex; align-items:center; min-height:44px; padding:0 4px; }

      /* ── 14. Touch (WebKit): no stuck hover, no grey flash on whole regions, and
         taps on empty space reach the document listener that closes menus ── */
      @media (hover:none) {
        .view { cursor:pointer; -webkit-tap-highlight-color:transparent; }
        .view button, .view a, .view summary, .view label, .view select, .view [onclick] { -webkit-tap-highlight-color:rgba(31,35,64,.12); }
        .doctab, .bo-chip, .hw-item-tag, .toggle-row, .inc-item, #cardsGrid { -webkit-tap-highlight-color:transparent; }
        .est-card:hover { box-shadow:none; border-color:var(--border); }
        .est-list-row:hover { background:transparent; }
        .est-list-row:nth-child(even):hover { background:var(--surface-2); }
        .btn-add:hover { background:var(--surface); border-color:var(--border); }
        .btn-sort:hover { background:var(--surface); border-color:var(--border); }
        .reorder-btn:hover:not([disabled]) { background:var(--surface); border-color:var(--border); color:var(--muted); }
        .bo-chip-off:hover { background:var(--surface); color:var(--text-2); border-color:var(--border-2); }
        .bo-chip-on:hover { background:var(--navy); border-color:var(--navy); }
        .toggle-row:hover, .btn-copy:hover { background:transparent; }
        .card-menu-btn:hover { background:var(--surface); border-color:var(--border); }
        .layout-btn:hover:not(.active) { color:var(--muted); background:none; }
        .hw-item.collapsed:hover { border-color:var(--border); }
      }
    }
    /* Very narrow phones (320px, or Display Zoom): the logo mark alone; no "SET…" titles;
       the totals bar keeps Balance Due + Save */
    @media screen and (max-width:359px) {
      .totals-bar .tb-cell:first-child { display:none; }
      #dashView .app-header > button:first-child > div { display:none; }
      #settingsView .app-header > div:first-child > div, #adminView .app-header > div:first-child > div, #shopView .app-header > div:first-child > div { display:none; }
    }
    /* ══ PHONE ON ITS SIDE (short touch screens) ═══════════════════
       A phone in landscape is 844–932px wide, so it keeps the tablet layout;
       this adds the phone's touch rules to it: 44px tap targets, 16px fields
       (no zoom on focus) and pop-ups clear of the totals bar. iPads and
       computers are taller than 500px (or use a mouse), so they never match. */
    @media screen and (max-height:500px) and (pointer:coarse) {
      input[type=text],input[type=number],input[type=date],input[type=email],input[type=password],select,textarea,.recon-in,.header-search input[type=text] { font-size:16px; }
      .setting-field-header select { font-size:16px !important; } /* their inline 11px */
      .btn-primary, .btn-add, .btn-green, .totals-bar .btn-green, .btn-header-ghost, .cab-verify-btn, .toggle-row, .inc-item, .card-menu-item, .user-dropdown-item { min-height:44px; }
      .card-menu-btn, .user-bubble { width:44px; height:44px; }
      .btn-del, .btn-copy, .reorder-btn { min-width:44px; min-height:44px; }
      .btn-sort, #brandConfigBody .btn-sort { min-height:44px !important; }
      #dashView .app-header > button:first-child, .hw-item-tag, .po-warr-toggle, .cab-inc-lbl, .cab-pricing summary { min-height:44px; display:inline-flex; align-items:center; }
      .doctab, .doctab-nav, .doctab-nav button, .bo-chip { min-height:44px; }
      #acctCard button[onclick="signOut()"] { min-height:44px; }
      #adminView a[href^="/api/backups/"], #adminView a[href^="/api/admin/logs/"], .login-foot a { display:inline-flex; align-items:center; min-height:44px; }
      .popup-toast, .popup-stack .status-bubble { font-size:14px; padding:10px 16px; }
      body:has(#editorView.active) .popup-stack { bottom:calc(84px + env(safe-area-inset-bottom, 0px)); } /* above the totals bar */
    }
