/* =====================================================================
   CSW Web Tools - application stylesheet (no framework)
   ===================================================================== */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --header-tint: #eef3fa;   /* section (card) headers */
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-soft: #dbeafe;
  --green: #15803d;  --green-soft: #dcfce7;
  --purple: #6d28d9; --purple-soft: #ede9fe; --purple-line: #c4b5fd;
  --amber: #b45309;  --amber-soft: #fef3c7;
  --red: #b91c1c;    --red-soft: #fee2e2;
  --nav: #0f172a;
  --nav-text: #e2e8f0;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0 0 .6rem; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: .05em .3em; border-radius: 4px; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.page { padding: 24px 16px 64px; }
.container { max-width: 1480px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: .85rem; color: var(--text-2); margin-bottom: 4px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack.gap-sm, .gap-sm { gap: 8px; }
.flex { display: flex; align-items: center; }
.gap { gap: 12px; }
.wrap { flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
/* Fields side by side sharing the full width; one that is hidden (e.g. a CORR-only field on WEB) leaves the rest the whole row. */
.row-fill { display: flex; gap: 10px; }
.row-fill > * { flex: 1 1 0; }
.grid--dash { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); align-items: start; }
.grid--filters { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: end; }
.grid--quote-head { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.grid--order { grid-template-columns: 1fr 2fr 1fr; gap: 24px; }
.grid--main { grid-template-columns: minmax(300px, 1fr) minmax(0, 2.4fr); align-items: start; }
.grid--pricing { grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr); gap: 24px; }
@media (max-width: 1100px) {
  .grid--quote-head, .grid--order { grid-template-columns: 1fr 1fr; }
  .grid--main, .grid--pricing, .grid--dash { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .grid--quote-head, .grid--order, .grid--2, .grid--3 { grid-template-columns: 1fr; }
  .grid--2 .field--wide, .grid--3 .field--wide, .grid--4 .field--wide { grid-column: auto; }   /* one column: nothing to span */
  html { font-size: 14px; }
}
.mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; }
.right { text-align: right; } .center { text-align: center; }
.muted { color: var(--text-2); } .small { font-size: .85rem; } .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-red { color: var(--red); } .text-amber { color: var(--amber); } .text-green { color: var(--green); }
.req { color: var(--red); }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
.link:hover { text-decoration: underline; }
/* "?" help markers: the tip text lives in aria-label; it shows instantly on hover and toggles on click/tap (app.js) */
.help { position: relative; display: inline-block; width: 16px; height: 16px; border-radius: 50%; background: var(--border); color: var(--text-2); font-size: .7rem; text-align: center; line-height: 16px; cursor: help; margin-left: 4px; }
.help::after { content: attr(aria-label); position: absolute; left: 0; top: calc(100% + 6px); z-index: 30; width: max-content; max-width: 260px; padding: 7px 10px; border-radius: var(--radius-sm); background: var(--text); color: #fff; font-size: .78rem; font-weight: 400; line-height: 1.35; letter-spacing: 0; text-align: left; white-space: normal; box-shadow: var(--shadow-lg); pointer-events: none; opacity: 0; visibility: hidden; transition: opacity .1s; }
.help:hover::after, .help.is-open::after { opacity: 1; visibility: visible; }

/* ---------- top bar ---------- */
.topbar { --topbar-ctl: 34px; background: var(--nav); color: var(--nav-text); position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow); }
.topbar__inner { max-width: 1480px; margin: 0 auto; padding: 0 16px; height: 58px; display: flex; align-items: center; gap: 20px; }
.topbar__brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 650; font-size: 1rem; letter-spacing: .01em; white-space: nowrap; }
/* logo.png is the full "csw inc" lockup; on the dark bar we show only the color mark (left ~36px) and let the app name act as the wordmark */
.topbar__brand img { display: block; height: 34px; width: 36px; object-fit: cover; object-position: left center; }
.topbar__brand:hover { text-decoration: none; }
.topbar__nav { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.topbar__link { color: var(--nav-text); padding: 8px 12px; border-radius: var(--radius-sm); font-weight: 500; white-space: nowrap; }
.topbar__link:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.topbar__link.is-active { background: rgba(255,255,255,.14); color: #fff; }
.topbar__link--primary { color: #fde68a; }
/* search: input + Go rendered as one control, same height as the other bar controls */
.topbar__search { margin-left: auto; display: flex; align-items: center; flex: 0 1 320px; min-width: 180px; }
.topbar__search input { flex: 1 1 auto; width: auto; min-width: 0; height: var(--topbar-ctl); background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); border-right: 0; color: #fff; border-radius: var(--radius-sm) 0 0 var(--radius-sm); padding: 0 10px; font: inherit; font-size: .92rem; }
.topbar__search input::placeholder { color: rgba(255,255,255,.55); }
.topbar__search input:focus { outline: none; background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.4); }
.topbar__search .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
/* buttons on the dark bar: translucent instead of the white ghost style (which left white text on a white button) */
.topbar .btn--ghost { height: var(--topbar-ctl); padding: 0 12px; font-size: .85rem; background: rgba(255,255,255,.1); color: var(--nav-text); border-color: rgba(255,255,255,.18); }
.topbar .btn--ghost:hover:not(:disabled) { background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.35); color: #fff; }
.topbar .btn--ghost:focus-visible { outline: 2px solid rgba(255,255,255,.6); outline-offset: 1px; }
.topbar .btn--ghost.is-busy::after { border-color: rgba(255,255,255,.35); border-top-color: #fff; }
.topbar__user { display: flex; align-items: center; gap: 12px; white-space: nowrap; flex-shrink: 0; }
.topbar__user form { margin: 0; display: flex; }
.topbar__name { display: flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--nav-text); }
@media (max-width: 1180px) { .topbar__brand span { display: none; } }
@media (max-width: 1020px) { .topbar__name { display: none; } .topbar__inner { gap: 10px; } .topbar__link { padding: 8px 10px; } }
@media (max-width: 800px) { .topbar__inner { height: auto; min-height: 58px; flex-wrap: wrap; padding: 8px 16px; row-gap: 8px; } .topbar__nav { flex-wrap: wrap; } .topbar__search { order: 10; flex: 1 1 100%; margin-left: 0; } .topbar__user { margin-left: auto; } }

.subnav { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.subnav__link { padding: 8px 14px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.subnav__link:hover { color: var(--text); text-decoration: none; }
.subnav__link.is-active { color: var(--accent); border-color: var(--accent); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.card__header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; background: var(--header-tint); border-radius: var(--radius) var(--radius) 0 0; }
.card__header--summary { cursor: pointer; list-style: none; border-bottom: 0; border-radius: var(--radius); }
.card__header--summary::-webkit-details-marker { display: none; }
.card__header--summary::before { content: "▸"; color: var(--text-3); margin-right: 6px; }
details[open] > .card__header--summary::before { content: "▾"; }
details[open] > .card__header--summary { border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
.card__title { display: flex; align-items: center; gap: 8px; }
.card__body { padding: 18px; }
.card__footer { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field--wide { grid-column: span 2; }
.field--actions { flex-direction: row; gap: 8px; align-items: flex-end; }
.field__label { font-size: .8rem; font-weight: 600; color: var(--text-2); letter-spacing: .01em; display: flex; align-items: center; gap: 6px; }
.field__hint { font-size: .8rem; color: var(--text-2); }
.input, .select { width: 100%; font: inherit; color: var(--text); background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 8px 10px; transition: border-color .12s, box-shadow .12s; }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input:disabled, .select:disabled { background: var(--surface-2); color: var(--text-3); }
.input:read-only { background: var(--surface-2); }
.input--sm, .select--sm { padding: 5px 8px; font-size: .9rem; }
.input.is-invalid, .select.is-invalid { border-color: var(--red); }
/* Problems found by Finalize: the control is outlined (tables and ticks too) and its message sits underneath. */
.table.is-invalid { outline: 1px solid var(--red); outline-offset: -1px; }   /* inside its scrolling wrap, which would clip an outer outline */
.check.is-invalid { outline: 1px solid var(--red); outline-offset: 3px; border-radius: 3px; }
.field-error { font-size: .8rem; color: var(--red); }
.card > .field-error { padding: 6px 18px 10px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M2 4l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.check--strong { font-weight: 600; }
/* On/off switch: a checkbox (role="switch") drawn as a sliding knob; the invisible input lies over the track so it takes clicks and focus. */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; top: 50%; left: 0; width: 34px; height: 20px; margin: -10px 0 0; opacity: 0; cursor: pointer; }
.switch__track { position: relative; flex: none; width: 34px; height: 20px; border-radius: 10px; background: var(--border-strong); transition: background .15s; }
.switch__track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, .3); transition: transform .15s; }
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .switch__track { opacity: .5; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: 0; flex: 1; min-width: 0; }
.input-group > :first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group > :last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-group__addon { display: flex; align-items: center; padding: 0 10px; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text-2); font-size: .9rem; }
.input-group__addon + .input { border-left: 0; }
.input + .input-group__addon { border-left: 0; }
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Segmented control. Inside a .field (or with .seg--full) it behaves like an input: full width, equal
   segments, centerd labels, same height as .input. Elsewhere (toolbars, tabs) it hugs its content
   instead of being stretched by a flex column. */
.seg { display: inline-flex; width: max-content; max-width: 100%; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.field > .seg, .seg--full { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); width: 100%; }
.field--inline > .seg { display: inline-flex; width: max-content; }
.field--inline > .seg .seg__btn { padding: 5px 10px; font-size: .9rem; }
.seg__btn { display: inline-flex; align-items: center; justify-content: center; margin: 0; padding: 8px 12px; border: 0; border-radius: 0; background: transparent; font: inherit; color: var(--text-2); text-align: center; cursor: pointer; }
.seg__btn + .seg__btn { border-left: 1px solid var(--border); }
.seg__btn:hover { background: var(--surface-2); }
.seg__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.seg__btn.is-active { background: var(--accent); color: #fff; }
.seg__btn.is-active:hover { background: var(--accent-hover); }

.combobox { position: relative; }
.combobox__list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); max-height: 280px; overflow: auto; background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }
.combobox__item { padding: 8px 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.combobox__item:hover, .combobox__item.is-focused { background: var(--accent-soft); }
.combobox__item.is-selected { font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.combobox__item small { color: var(--text-3); font-family: var(--mono); max-width: 45%; text-align: right; }   /* a long sub never squeezes the name */
.combobox__note { display: block; font-size: .8rem; font-weight: 400; color: var(--text-2); }   /* second line under an item's name */
.combobox__empty { padding: 10px; color: var(--text-3); }
.combobox__item mark { background: none; color: inherit; font-weight: 700; }
.combobox__more { padding: 6px 10px; color: var(--text-3); font-size: .8rem; border-top: 1px solid var(--border); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; line-height: 1.2; }
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn--ghost { background: #fff; color: var(--text); border-color: var(--border-strong); }
.btn--ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn--danger { background: var(--red); color: #fff; }
.btn--sm { padding: 5px 10px; font-size: .85rem; }
.btn--xs { padding: 2px 7px; font-size: .78rem; font-weight: 500; }
.btn--lg { padding: 11px 20px; font-size: 1rem; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.btn--ghost.is-busy::after { border-color: var(--border-strong); border-top-color: var(--text); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); background: var(--surface-2); font-weight: 600; }
.table--hover tbody tr:hover { background: #f8fafc; }
.table--compact th, .table--compact td { padding: 5px 8px; }
.table tr.is-muted td { color: var(--text-3); }
.th--current, .td--current { background: #f0fdf4 !important; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.kv:last-child { border-bottom: 0; }
.kv--total { font-size: 1.05rem; border-top: 1px solid var(--border-strong); border-bottom: 0; padding-top: 10px; }

/* ---------- badges / banners / toasts ---------- */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .74rem; font-weight: 600; line-height: 1.6; vertical-align: middle; }
.badge--green { background: var(--green-soft); color: var(--green); }
.badge--amber { background: var(--amber-soft); color: var(--amber); }
.badge--red { background: var(--red-soft); color: var(--red); }
.badge--blue { background: var(--accent-soft); color: var(--accent); }
.badge--gray { background: #e2e8f0; color: var(--text-2); }
/* A banner is running text (inline <strong> flows with the sentence, several <div>s stack); only one that carries
   .banner__actions becomes a row with the buttons on the right. */
.banner { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: .92rem; }
.banner:has(> .banner__actions) { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.stack > .banner { margin-bottom: 0; }   /* the stack's gap already spaces it */
.banner--info { background: var(--accent-soft); color: #1e3a8a; }
.banner--warn { background: var(--amber-soft); color: #78350f; }
.banner--error { background: var(--red-soft); color: #7f1d1d; }
.banner--success { background: var(--green-soft); color: #14532d; }
.banner__actions { display: flex; gap: 6px; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast { background: var(--nav); color: #fff; padding: 10px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: .9rem; animation: rise .18s ease-out; }
.toast--error { background: var(--red); }
.toast--success { background: var(--green); }
@keyframes rise { from { transform: translateY(6px); opacity: 0; } }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; background: rgba(15, 23, 42, .5); display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; overflow: auto; }
.modal__dialog { background: #fff; border-radius: var(--radius); width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); animation: rise .15s ease-out; }
.modal__dialog--wide { max-width: 860px; }
.modal__header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal__close { background: none; border: 0; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--text-2); }
.modal__body { padding: 18px; }
.modal__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* ---------- pager ---------- */
.pager { display: flex; gap: 2px; align-items: center; font-size: .85rem; }
.pager__link { padding: 4px 9px; border-radius: var(--radius-sm); color: var(--text-2); }
.pager__link:hover { background: var(--surface-2); text-decoration: none; }
.pager__link.is-current { background: var(--accent); color: #fff; }
.pager__link.is-disabled { opacity: .4; }
.pager__gap { padding: 0 4px; color: var(--text-3); }

/* ---------- dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow); }
.stat__label { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); font-weight: 600; }
.stat__value { font-size: 1.9rem; font-weight: 700; line-height: 1.2; margin: 4px 0; font-variant-numeric: tabular-nums; }
.stat__sub { font-size: .85rem; color: var(--text-2); }
.spark { width: 100%; height: 56px; color: var(--accent); display: block; }
.dash-module { margin-bottom: 20px; }
.dash-module__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.dash-module__title { font-size: 1.05rem; font-weight: 700; margin: 0; }
.dash-module .stats { margin-bottom: 0; }
.spark-row + .spark-row { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border); }
.spark-row__head { display: flex; justify-content: space-between; gap: 12px; font-size: .85rem; margin-bottom: 4px; }

/* ---------- auth ---------- */
.auth { min-height: calc(100vh - 120px); display: flex; align-items: center; justify-content: center; }
.auth__card { width: 100%; max-width: 420px; padding: 36px 32px; text-align: center; }
.auth__logo { height: 56px; margin-bottom: 14px; }
.auth__title { font-size: 1.4rem; margin-bottom: 6px; }
.auth__ms { width: 100%; margin: 18px 0 10px; }
.auth .stack { text-align: left; margin-top: 16px; }

/* ---------- quoter ---------- */
.qhead { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 18px; flex-wrap: wrap; }
.qhead__number { display: flex; align-items: center; gap: 10px; }
.qhead__label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); font-weight: 600; }
.qhead__num { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.qhead__badges { display: inline-flex; gap: 6px; }
.qhead__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.fss { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.fss__x { color: var(--text-3); font-size: 1.2rem; }
.outputs { background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 12px; }
.table--lines td, .table--lines th { padding: 6px 8px; }
.table--lines .qty { width: 110px; }
.table--lines .input { padding: 5px 8px; text-align: right; }
.table--lines .input--label { text-align: left; }
.table--lines tr.rule td { font-weight: 600; }
.table--lines tfoot tr.total td { font-size: 1.05rem; font-weight: 700; border-top: 2px solid var(--border-strong); border-bottom: 0; padding-top: 10px; }
.table--lines .rate { color: var(--text-2); }
.table--lines .is-zero td { color: var(--text-3); }
.table--lines .is-zero .input { color: var(--text-3); }
.side__block { padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); display: flex; flex-direction: column; gap: 6px; background: var(--surface-2); }
.qfoot { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.qfoot__final { font-size: 1.15rem; }
.qfoot__final strong { font-size: 1.7rem; color: var(--accent); margin-left: 8px; }
.qfoot__actions { display: flex; gap: 12px; align-items: center; }
.done__num { font-size: 2rem; font-weight: 700; color: var(--accent); text-align: center; }
.filters .card__body { padding-bottom: 12px; }

/* ---------- admin: module switch, grouped rate tables ---------- */
.mb-2 { margin-bottom: 12px; }
a.seg__btn { text-decoration: none; }
a.seg__btn:hover { text-decoration: none; }
.table tr.table__group td { background: var(--surface-2); font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); font-weight: 600; padding-top: 8px; padding-bottom: 4px; }
.rate-editor { max-height: 52vh; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px 14px; margin: 0; }
.fieldset legend { padding: 0 6px; }

/* ---------- plate quoter ---------- */
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 680px) { .grid--4 { grid-template-columns: 1fr; } }
/* Job size: Stepping | thru column | across column | totals. Thru fields stack in one column and across fields in the next. */
.size-grid__thru { grid-column: 2; }
@media (max-width: 1100px) {   /* two columns: thru left, across right, Stepping above and the totals below */
  .size-grid__lead { grid-column: span 2; }
  .size-grid__thru { grid-column: 1; }
  .size-grid__tail { order: 1; }
}
@media (max-width: 680px) { .size-grid__lead, .size-grid__thru { grid-column: auto; } .size-grid__tail { order: 0; } }
.plate-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }
@media (max-width: 1240px) { .plate-layout { grid-template-columns: 1fr; } .plate-side { position: static !important; } }
.plate-side { position: sticky; top: 72px; }
.plate-side .card { margin-bottom: 0; max-height: calc(100vh - 88px); overflow: auto; }
.subhead { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); font-weight: 600; border-bottom: 1px solid var(--border); padding-bottom: 4px; margin-top: 4px; }
.readout { background: var(--surface-2); border-color: var(--border); color: var(--text-2); min-height: 38px; display: flex; align-items: center; }
.opts .check { font-size: .92rem; }
.field--inline { flex-direction: row; align-items: center; gap: 8px; font-size: .92rem; color: var(--text-2); }
.field--inline > span:first-child { white-space: nowrap; }
.field--inline .input, .field--inline .select { width: auto; min-width: 80px; }
.table--rows th, .table--rows td { padding: 5px 8px; }
.table--rows .input, .table--rows .select { padding: 5px 8px; font-size: .9rem; }
.table--rows td.n { width: 28px; color: var(--text-3); font-size: .8rem; }
.table--rows td.w-qty { width: 76px; } .table--rows td.w-dim { width: 110px; } .table--rows td.w-chk { width: 60px; text-align: center; }
.table--rows tr.is-measured td { background: #f0fdf4; }
.table--rows tr.is-calculated td { background: #eff6ff; }
.readouts .kv { border-bottom: 0; background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 12px; }
/* A department that is switched off keeps only its header: the name grays out, the switch stays at full strength. */
.dept-card.is-off .card__header { border-bottom: 0; border-radius: var(--radius); }
.dept-card.is-off .card__title { color: var(--text-3); }
.dept-card__follows { display: none; font-size: .85rem; font-weight: 400; color: var(--text-2); }   /* Proofing has no switch of its own */
.dept-card.is-off .dept-card__follows { display: inline; }
.dept-card.is-off .card__body, .dept-card.is-off .table-wrap, .dept-card.is-off .card__footer { display: none; }
.table--lines tr.dept td { font-weight: 600; cursor: pointer; }
.table--lines tr.dept td:first-child::before { content: "▸ "; color: var(--text-3); }
.table--lines tr.dept.is-open td:first-child::before { content: "▾ "; }
.table--lines tr.dept-line td { font-size: .82rem; color: var(--text-2); padding-top: 2px; padding-bottom: 2px; border-bottom: 0; }
.table--lines tr.dept-line td:first-child { padding-left: 22px; }
.table--lines tr.dept-line .basis { color: var(--text-3); }
.table--lines tfoot tr.subtotal td { border-bottom: 0; color: var(--text-2); }
.pricing-panel .table--lines td:last-child { white-space: nowrap; }
.freight-list { display: flex; flex-direction: column; gap: 4px; }
.freight-list label { display: flex; justify-content: space-between; gap: 10px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; font-size: .9rem; }
.freight-list label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.spec-summary { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.spec-summary span strong { color: var(--text); }
/* spec-driven controls: light purple while they still hold the press material setup's value (plate-quoter.js syncSpecHighlight) */
.input.from-spec, .select.from-spec, .readout.from-spec, .readouts .kv.from-spec { background-color: var(--purple-soft); border-color: var(--purple-line); }
.input.from-spec:focus, .select.from-spec:focus { border-color: var(--accent); }
.check.from-spec { background: var(--purple-soft); box-shadow: 0 0 0 4px var(--purple-soft); border-radius: 3px; }
.seg.from-spec { border-color: var(--purple-line); background: var(--purple-soft); }
.spec-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--purple-soft); border: 1px solid var(--purple-line); vertical-align: -1px; margin-right: 5px; }

/* ---------- measure artwork tool ---------- */
.modal--sticky:has(> .modal__dialog--full) { padding: 16px; }
.modal__dialog--full { max-width: none; width: 100%; height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden; }
.ms { display: grid; grid-template-rows: auto 1fr; height: 100%; min-height: 0; }
.ms__bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.ms__bar .seg__btn { padding: 6px 12px; }
.ms__body { display: grid; grid-template-columns: 96px minmax(0, 1fr) 300px; min-height: 0; }
.ms__pages { border-right: 1px solid var(--border); overflow: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); }
.ms__page { border: 2px solid transparent; border-radius: 4px; cursor: pointer; background: #fff; padding: 2px; position: relative; }
.ms__page img { width: 100%; display: block; }
.ms__page.is-active { border-color: var(--accent); }
.ms__page small { position: absolute; left: 4px; top: 4px; background: rgba(15,23,42,.7); color: #fff; font-size: .68rem; padding: 0 5px; border-radius: 3px; }
.ms__page .ms__count { position: absolute; right: 4px; bottom: 4px; background: var(--green); color: #fff; font-size: .68rem; padding: 0 5px; border-radius: 3px; }
.ms__stage { position: relative; background: #e2e8f0; min-height: 0; overflow: hidden; }
.ms__stage canvas { display: block; width: 100%; height: 100%; }
.ms__stage.tool-box canvas { cursor: crosshair; } .ms__stage.tool-calibrate canvas { cursor: crosshair; } .ms__stage.tool-select canvas { cursor: default; } .ms__stage.is-panning canvas { cursor: grabbing; }
.ms__status { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(15,23,42,.78); color: #e2e8f0; font-size: .78rem; padding: 4px 10px; display: flex; gap: 16px; font-family: var(--mono); }
.ms__status .warn { color: #fde68a; }
.ms__len { position: absolute; background: #fff; border: 1px solid var(--accent); border-radius: var(--radius-sm); padding: 6px 8px; box-shadow: var(--shadow-lg); display: flex; gap: 6px; align-items: center; z-index: 5; font-size: .85rem; }
.ms__len input { width: 90px; }
.ms__side { border-left: 1px solid var(--border); overflow: auto; display: flex; flex-direction: column; }
.ms__side-head { padding: 8px 12px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: .85rem; display: flex; justify-content: space-between; align-items: center; }
.ms__boxes { flex: 1; overflow: auto; }
.ms__box { padding: 8px 12px; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; cursor: pointer; font-size: .85rem; }
.ms__box.is-selected { background: var(--accent-soft); }
.ms__box .dims { font-family: var(--mono); color: var(--text-2); grid-column: 1 / -1; }
.ms__box .input { padding: 3px 6px; font-size: .82rem; }
.ms__box .row { display: flex; gap: 6px; align-items: center; grid-column: 1 / -1; }
.ms__box .row .input[data-k="label"] { flex: 1; } .ms__box .row .input[data-k="qty"] { width: 54px; }
.ms__box .check { font-size: .78rem; gap: 4px; }
.ms__foot { padding: 10px 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); }
.ms__hint { font-size: .78rem; color: var(--text-2); }

/* Picture buttons (stagger type, mount type): each option is a card with its drawing above its name. */
.field--row { grid-column: 1 / -1; }
.seg.seg--pics { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; width: 100%; border: 0; border-radius: 0; overflow: visible; background: transparent; }
.seg--pics .seg__btn { flex-direction: column; gap: 4px; padding: 8px 6px 6px; border: 2px solid var(--border); border-radius: var(--radius-sm); background: #fff; font-weight: 500; }
.seg--pics .seg__btn + .seg__btn { border-left: 2px solid var(--border); }
.seg--pics .seg__btn img { display: block; height: 52px; width: auto; max-width: 100%; object-fit: contain; mix-blend-mode: multiply; }
.seg--pics .seg__btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.seg--pics .seg__btn.is-active, .seg--pics .seg__btn.is-active:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.seg--pics .seg__btn:disabled { opacity: .45; cursor: not-allowed; }
@media (max-width: 680px) { .seg.seg--pics { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); } }
