/* Quotecycle components v1.0. Uses ONLY values from tokens.css. */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: calc(16px * var(--ui-scale)); -webkit-text-size-adjust: 100%; }
body { margin: 0; font: var(--weight-regular) var(--text-md)/var(--lh-body) var(--font); color: var(--slate-900); background: var(--page); }
h1, h2, h3, h4 { margin: 0; line-height: var(--lh-tight); font-weight: var(--weight-strong); letter-spacing: -0.005em; }
h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-md); }
p { margin: 0 0 var(--s-3); }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-strong); }
.num, .money { font-variant-numeric: tabular-nums lining-nums; font-feature-settings: "tnum" 1, "lnum" 1; }
.money { text-align: right; white-space: nowrap; }
.muted { color: var(--slate-600); }
.small { font-size: var(--text-sm); }
.xs { font-size: var(--text-xs); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
.skip { position: absolute; left: var(--s-3); top: -60px; background: var(--white); padding: var(--s-2) var(--s-3); border: 1px solid var(--slate-300); border-radius: var(--r-md); z-index: 100; }
.skip:focus { top: var(--s-3); }

/* ---------- Shell (top navigation) ---------- */
:root { --nav-h: 56px; }
.shell { display: block; min-height: 100vh; }
.rail { position: sticky; top: 0; z-index: 40; min-height: var(--nav-h); background: var(--nav-bg); color: var(--nav-fg); border-bottom: 1px solid var(--slate-200); display: flex; align-items: center; gap: var(--s-5); padding: 0 var(--s-6); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: var(--s-2); text-decoration: none; color: var(--nav-fg); }
.brand:hover { color: var(--nav-fg); }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-word { font-weight: var(--weight-strong); font-size: 1.25rem; letter-spacing: -0.02em; }
.brand-word .c2 { color: var(--logo-2); }
.nav { display: flex; gap: var(--s-1); height: var(--nav-h); align-items: stretch; }
.nav a { display: flex; align-items: center; gap: var(--s-2); padding: 0 var(--s-3); color: var(--nav-fg-dim); text-decoration: none; font-size: var(--text-md); border-bottom: 3px solid transparent; border-top: 3px solid transparent; }
.nav a:hover { background: var(--nav-hover); color: var(--nav-fg); }
.nav a[aria-current="page"] { color: var(--accent-strong); border-bottom-color: var(--nav-active); font-weight: var(--weight-medium); }
.nav .count { font-size: var(--text-xs); color: var(--slate-700); background: var(--slate-100); border-radius: var(--r-pill); padding: 0 var(--s-2); }
.rail-right { margin-left: auto; flex: none; display: flex; align-items: center; gap: var(--s-4); font-size: var(--text-sm); }
.rail-right .select { background: var(--white); color: var(--slate-700); border-color: var(--slate-300); height: 32px; width: auto; font-size: var(--text-sm); }
.rail-right .select option { color: var(--slate-900); }
.nav-user { display: flex; align-items: center; gap: var(--s-2); color: var(--nav-fg); }
.nav-user .avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: inline-flex; align-items: center; justify-content: center; font-weight: var(--weight-strong); font-size: var(--text-xs); }
.nav-user .role { display: block; color: var(--nav-fg-dim); font-size: var(--text-xs); line-height: 1.1; }
.main { min-width: 0; display: block; }
.topbar { min-height: var(--topbar-h); display: flex; align-items: center; gap: var(--s-4); padding: var(--s-2) var(--s-6); background: var(--white); border-bottom: 1px solid var(--slate-200); position: sticky; top: var(--nav-h); z-index: 30; flex-wrap: wrap; }
.topbar:empty { display: none; }
.topbar .title { display: flex; align-items: baseline; gap: var(--s-3); min-width: 0; }
.topbar .title h1 { font-size: var(--text-lg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .qno { color: var(--slate-600); font-size: var(--text-sm); }
.topbar .spacer { flex: 1; }
.topbar > .btn, .topbar > a.btn, .topbar > button { flex: none; }
.saved { font-size: var(--text-sm); color: var(--slate-600); }
.content { padding: var(--s-6); width: 100%; max-width: 1360px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-5); flex-wrap: wrap; }
.page-head p { margin: var(--s-1) 0 0; color: var(--slate-600); font-size: var(--text-sm); }
.btn.menu-btn { display: none; }

/* ---------- Buttons ---------- */
.btn { font: inherit; font-size: var(--text-md); font-weight: var(--weight-medium); display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); height: var(--control-h); padding: 0 var(--s-4); border-radius: var(--r-md); border: 1px solid var(--slate-300); background: var(--white); color: var(--slate-900); cursor: pointer; text-decoration: none; transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease); white-space: nowrap; }
.btn:hover { background: var(--slate-100); border-color: var(--slate-400); color: var(--slate-900); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--slate-700); }
.btn-quiet:hover { background: var(--slate-100); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-lg { height: var(--control-h-lg); padding: 0 var(--s-5); font-size: var(--text-lg); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.icon-btn { width: var(--control-h); padding: 0; }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.field > label, .label { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--slate-700); }
.hint { font-size: var(--text-xs); color: var(--slate-600); }
.input, .select, .textarea { font: inherit; font-size: var(--text-md); height: var(--control-h); width: 100%; padding: 0 var(--s-3); border: 1px solid var(--slate-300); border-radius: var(--r-md); background: var(--white); color: var(--slate-900); }
.textarea { height: auto; padding: var(--s-2) var(--s-3); min-height: 72px; resize: vertical; line-height: var(--lh-body); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--slate-400); }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.error-text { font-size: var(--text-xs); color: var(--danger); }
.input.money { text-align: right; }
.row { display: grid; gap: var(--s-4); }
.row.two { grid-template-columns: 1fr 1fr; }
.row.three { grid-template-columns: 1fr 1fr 1fr; }
.switch { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--text-sm); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 32px; height: 18px; border-radius: var(--r-pill); background: var(--slate-300); position: relative; transition: background var(--dur) var(--ease); flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--white); box-shadow: var(--shadow-1); transition: transform var(--dur) var(--ease); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }
.check { display: flex; align-items: flex-start; gap: var(--s-2); font-size: var(--text-md); }
.check input { margin-top: 4px; width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- Status chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 var(--s-2); border-radius: var(--r-pill); font-size: var(--text-xs); font-weight: var(--weight-medium); background: var(--st-draft-bg); color: var(--st-draft-fg); white-space: nowrap; }
.chip.draft { background: var(--st-draft-bg); color: var(--st-draft-fg); }
.chip.sent { background: var(--st-sent-bg); color: var(--st-sent-fg); }
.chip.accepted { background: var(--st-accepted-bg); color: var(--st-accepted-fg); }
.chip.complete { background: var(--st-complete-bg); color: var(--st-complete-fg); }
.chip.expired, .chip.withdrawn { background: var(--st-warn-bg); color: var(--st-warn-fg); }
.chip.declined { background: var(--st-bad-bg); color: var(--st-bad-fg); }
.chip.editing { background: var(--st-warn-bg); color: var(--st-warn-fg); }
.seen { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-sm); color: var(--slate-600); white-space: nowrap; }
.seen .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--slate-300); flex: none; }
.seen.viewed .dot { background: var(--seq-2); }
.seen.live { color: var(--accent-strong); font-weight: var(--weight-medium); }
.seen.live .dot { background: var(--seq-4); box-shadow: 0 0 0 0 rgba(26, 91, 168, 0.5); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 6px rgba(26, 91, 168, 0); } 100% { box-shadow: 0 0 0 0 rgba(26, 91, 168, 0); } }
@media (prefers-reduced-motion: reduce) { .seen.live .dot { animation: none; } }

/* ---------- Tables ---------- */
.table-wrap { background: var(--white); border: 1px solid var(--slate-200); border-radius: var(--r-lg); box-shadow: var(--shadow-1); overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: var(--text-md); }
.t th { text-align: left; font-size: var(--text-xs); font-weight: var(--weight-medium); text-transform: uppercase; letter-spacing: 0.05em; color: var(--slate-600); background: var(--slate-25); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--slate-200); white-space: nowrap; }
.t td { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--slate-100); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr:hover { background: var(--slate-25); }
.t td.money, .t th.money { text-align: right; }
.t .primary a { color: var(--slate-900); font-weight: var(--weight-medium); text-decoration: none; }
.t .primary a:hover { color: var(--accent); text-decoration: underline; }
.t .primary .sub { display: block; font-size: var(--text-sm); color: var(--slate-600); font-weight: var(--weight-regular); }
.tabs { overflow-x: auto; white-space: nowrap; display: flex; gap: var(--s-1); border-bottom: 1px solid var(--slate-200); margin-bottom: var(--s-4); }
.tabs button { font: inherit; font-size: var(--text-md); background: none; border: 0; border-bottom: 2px solid transparent; padding: var(--s-2) var(--s-3); color: var(--slate-600); cursor: pointer; margin-bottom: -1px; }
.tabs button:hover { color: var(--slate-900); }
.tabs button[aria-selected="true"] { color: var(--slate-900); border-bottom-color: var(--accent); font-weight: var(--weight-medium); }
.toolbar { display: flex; gap: var(--s-3); align-items: center; margin-bottom: var(--s-4); flex-wrap: wrap; }
.toolbar .input, .toolbar .select { width: auto; min-width: 180px; }
.toolbar .input[type="search"] { min-width: 300px; }

/* ---------- Panels ---------- */
.panel { background: var(--white); border: 1px solid var(--slate-200); border-radius: var(--r-lg); padding: var(--s-5); box-shadow: var(--shadow-1); }
.section { margin-bottom: var(--s-6); }
.section > .sec-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: var(--s-3); }
.sec-head .switch { font-size: var(--text-sm); }
.sec-label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--slate-600); font-weight: var(--weight-medium); margin: 0 0 var(--s-3); }

/* ---------- Send-to box (layout A) ---------- */
.sendto { position: relative; display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; min-height: 44px; padding: var(--s-2) var(--s-3); border: 1px solid var(--slate-300); border-radius: var(--r-md); background: var(--white); }
.sendto:focus-within { outline: 2px solid var(--focus); border-color: var(--focus); }
.sendto input { border: 0; outline: 0; font: inherit; font-size: var(--text-md); flex: 1; min-width: 160px; height: 28px; background: transparent; }
.rchip { display: inline-flex; align-items: center; gap: var(--s-2); height: 28px; padding: 0 var(--s-1) 0 var(--s-2); background: var(--slate-100); border-radius: var(--r-pill); font-size: var(--text-sm); }
.rchip .tag { font: inherit; font-size: var(--text-xs); font-weight: var(--weight-medium); border: 1px solid var(--slate-300); background: var(--white); color: var(--slate-700); border-radius: var(--r-pill); padding: 0 var(--s-2); height: 20px; cursor: pointer; }
.rchip .tag.to { background: var(--accent-tint); border-color: var(--accent-edge); color: var(--accent-strong); }
.rchip .x { border: 0; background: none; cursor: pointer; width: 22px; height: 22px; border-radius: 50%; color: var(--slate-600); font-size: var(--text-md); line-height: 1; }
.rchip .x:hover { background: var(--slate-200); color: var(--slate-900); }
.rchip .opened { color: var(--slate-600); font-size: var(--text-xs); }
.suggest { position: absolute; left: -1px; right: -1px; top: calc(100% + 4px); background: var(--white); border: 1px solid var(--slate-200); border-radius: var(--r-md); box-shadow: var(--shadow-2); z-index: 30; padding: var(--s-1); max-height: 260px; overflow: auto; }
.suggest button { display: flex; justify-content: space-between; gap: var(--s-3); width: 100%; text-align: left; font: inherit; font-size: var(--text-sm); padding: var(--s-2) var(--s-3); border: 0; background: none; border-radius: var(--r-sm); cursor: pointer; }
.suggest button:hover, .suggest button[aria-selected="true"] { background: var(--accent-tint); }
.suggest .kind { color: var(--slate-600); font-size: var(--text-xs); }

/* ---------- Rich text bar ---------- */
.rte { border: 1px solid var(--slate-300); border-radius: var(--r-md); background: var(--white); }
.rte:focus-within { outline: 2px solid var(--focus); border-color: var(--focus); }
.rte-bar { display: flex; gap: 2px; padding: var(--s-1); border-bottom: 1px solid var(--slate-200); background: var(--slate-25); border-radius: var(--r-md) var(--r-md) 0 0; }
.rte-bar button { font: inherit; font-size: var(--text-sm); min-width: 30px; height: 28px; border: 0; background: none; border-radius: var(--r-sm); cursor: pointer; color: var(--slate-700); }
.rte-bar button:hover { background: var(--slate-200); }
.rte-body { padding: var(--s-3); min-height: 84px; outline: 0; }

/* ---------- Quote builder ---------- */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--s-6); align-items: start; }
.lines { background: var(--white); border: 1px solid var(--slate-200); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.lines-head, .line-main { display: grid; grid-template-columns: minmax(0, 1fr) 64px 100px 68px 100px 32px; gap: var(--s-3); align-items: start; }
.lines-head { padding: var(--s-2) var(--s-4); background: var(--slate-25); border-bottom: 1px solid var(--slate-200); border-radius: var(--r-lg) var(--r-lg) 0 0; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.05em; color: var(--slate-600); font-weight: var(--weight-medium); }
.lines-head .money { text-align: right; }
.line { border-bottom: 1px solid var(--slate-200); padding: var(--s-4); }
.line:last-of-type { border-bottom: 0; }
.line-main .pic { width: 56px; height: 56px; border-radius: var(--r-md); border: 1px solid var(--slate-200); background: var(--slate-100); overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--slate-500); font-size: var(--text-xs); cursor: pointer; padding: 0; }
.line-main .pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.line .code { font-size: var(--text-xs); color: var(--slate-600); letter-spacing: 0.02em; margin-bottom: 2px; }
.line .ltitle { display: block; resize: none; overflow: hidden; border: 1px solid transparent; font: inherit; font-weight: var(--weight-medium); width: 100%; background: transparent; padding: 2px var(--s-2); margin-left: calc(-1 * var(--s-2)); border-radius: var(--r-sm); }
.line .ldesc { border: 1px solid transparent; font: inherit; font-size: var(--text-sm); color: var(--slate-600); width: 100%; background: transparent; padding: 2px var(--s-2); margin-left: calc(-1 * var(--s-2)); border-radius: var(--r-sm); resize: none; display: block; }
.line .ltitle:hover, .line .ldesc:hover { border-color: var(--slate-200); }
.line .ltitle:focus, .line .ldesc:focus { border-color: var(--focus); outline: 1px solid var(--focus); background: var(--white); color: var(--slate-900); }
.line .qty, .line .unit { text-align: right; }
.line .ltotal { text-align: right; font-weight: var(--weight-medium); padding-top: 7px; }
.line .rm, .line .mv { border: 0; background: none; width: 28px; height: 26px; border-radius: var(--r-sm); cursor: pointer; color: var(--slate-600); font-size: var(--text-lg); line-height: 1; padding: 0; }
.line .rm:hover { background: var(--st-bad-bg); color: var(--st-bad-fg); }
.line .mv { font-size: 11px; }
.line .mv:hover:not(:disabled) { background: var(--accent-tint); color: var(--accent-strong); }
.line .mv:disabled { opacity: 0.3; cursor: default; }
.line .acts { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.line .disc { text-align: right; }
.line { position: relative; }
.item-c { position: relative; min-width: 0; }
.suggest.items { left: -4px; right: -4px; top: 32px; z-index: 35; }
.suggest.items button { align-items: center; }
.suggest .num { color: var(--slate-700); white-space: nowrap; }
.suggest .kind { display: block; }
.suggest .sug-foot { margin: 0; padding: var(--s-2) var(--s-3); font-size: var(--text-xs); color: var(--slate-600); border-top: 1px solid var(--slate-100); }
.flag-price { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--st-warn-fg); background: var(--st-warn-bg); border-radius: var(--r-pill); padding: 2px var(--s-2); margin-top: var(--s-1); }
.staff { margin: var(--s-3) 0 0; background: var(--staff-bg); border: 1px solid var(--staff-edge); border-radius: var(--r-md); color: var(--staff-fg); }
.staff > summary { list-style: none; cursor: pointer; padding: var(--s-2) var(--s-3); font-size: var(--text-sm); display: flex; align-items: center; gap: var(--s-2); }
.staff > summary::-webkit-details-marker { display: none; }
.staff > summary .lock { font-weight: var(--weight-medium); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; }
.staff > summary .sum { margin-left: auto; font-variant-numeric: tabular-nums; }
.staff[open] > summary { border-bottom: 1px solid var(--staff-edge); }
.staff-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-3); padding: var(--s-3); }
.staff .field > label { color: var(--staff-fg); }
.staff .input, .staff .select { background: var(--white); }
.staff .note { padding: 0 var(--s-3) var(--s-3); font-size: var(--text-xs); }
.lines-foot { display: flex; gap: var(--s-2); padding: var(--s-3) var(--s-4); border-top: 1px solid var(--slate-200); background: var(--slate-25); border-radius: 0 0 var(--r-lg) var(--r-lg); align-items: center; }
.lines-foot .hint { margin-left: auto; }
kbd { font: inherit; font-size: var(--text-xs); border: 1px solid var(--slate-300); border-bottom-width: 2px; border-radius: var(--r-sm); padding: 0 5px; background: var(--white); color: var(--slate-700); }

/* ---------- Totals ---------- */
.totals { position: sticky; top: calc(var(--nav-h) + var(--topbar-h) + var(--s-5)); background: var(--white); border: 1px solid var(--slate-200); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: var(--s-5); }
.totals dl { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: var(--s-2) var(--s-4); font-size: var(--text-md); }
.totals dt { color: var(--slate-600); }
.totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.totals .grand { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr auto; padding-top: var(--s-3); margin-top: var(--s-2); border-top: 1px solid var(--slate-200); align-items: baseline; }
.totals .grand dt { color: var(--slate-900); font-weight: var(--weight-medium); }
.totals .grand dd { font-size: var(--text-xl); font-weight: var(--weight-strong); }
.totals .switchrow { margin-top: var(--s-4); }
.totals .staff { margin: var(--s-4) 0 0; padding: var(--s-3); font-size: var(--text-sm); }
.totals .staff .lock { font-weight: var(--weight-medium); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; display: block; margin-bottom: var(--s-1); }
.totals .staff div { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }

/* ---------- Activity ---------- */
.activity { list-style: none; margin: 0; padding: 0; font-size: var(--text-sm); }
.activity li { display: grid; grid-template-columns: 96px 1fr; gap: var(--s-3); padding: var(--s-2) 0; border-bottom: 1px solid var(--slate-100); }
.activity li:last-child { border: 0; }
.activity time { color: var(--slate-600); }

/* ---------- Empty, toast, dialog ---------- */
.empty { text-align: center; padding: var(--s-7) var(--s-5); color: var(--slate-600); }
.empty .empty-t { color: var(--slate-900); margin-bottom: var(--s-2); }
.empty p { max-width: 42ch; margin: 0 auto var(--s-4); }
.toasts { position: fixed; left: 50%; bottom: var(--s-5); transform: translateX(-50%); display: flex; flex-direction: column; gap: var(--s-2); z-index: 80; align-items: center; }
.toast { background: var(--slate-900); color: var(--white); padding: var(--s-3) var(--s-4); border-radius: var(--r-md); box-shadow: var(--shadow-2); font-size: var(--text-sm); display: flex; gap: var(--s-4); align-items: center; }
.toast button { font: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium); background: none; border: 0; color: #9CC4EE; cursor: pointer; padding: 0; text-decoration: underline; }
dialog { border: 1px solid var(--slate-200); border-radius: var(--r-lg); box-shadow: var(--shadow-3); padding: 0; width: min(560px, calc(100vw - 32px)); color: var(--slate-900); }
dialog::backdrop { background: rgba(20, 26, 35, 0.4); }
.dlg-head { padding: var(--s-5) var(--s-5) var(--s-3); }
.dlg-body { padding: 0 var(--s-5) var(--s-4); display: grid; gap: var(--s-4); }
.dlg-foot { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-4) var(--s-5); border-top: 1px solid var(--slate-200); background: var(--slate-25); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.callout { border-left: 3px solid var(--accent); background: var(--accent-tint); padding: var(--s-3) var(--s-4); border-radius: 0 var(--r-md) var(--r-md) 0; font-size: var(--text-sm); }

/* ---------- Recipient page ---------- */
.rx { background: var(--slate-50); min-height: 100vh; }
.rx-wrap { max-width: 720px; margin: 0 auto; padding: var(--s-5) var(--s-4) var(--s-8); }
.rx-top { display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); padding-bottom: var(--s-4); border-bottom: 3px solid var(--brand-primary); margin-bottom: var(--s-5); }
.rx-logo { max-height: 44px; max-width: 200px; display: block; }
.rx-logo-text { font-weight: var(--weight-strong); font-size: var(--text-lg); color: var(--brand-primary); }
.rx-meta { text-align: right; font-size: var(--text-sm); color: var(--slate-600); }
.rx-meta strong { display: block; color: var(--slate-900); font-size: var(--text-md); }
.rx h1 { font-size: var(--text-xl); margin-bottom: var(--s-2); }
.rx-intro { color: var(--slate-700); margin-bottom: var(--s-5); }
.rx-lines { list-style: none; margin: 0; padding: 0; background: var(--white); border: 1px solid var(--slate-200); border-radius: var(--r-lg); }
.rx-line { display: grid; grid-template-columns: 64px 1fr auto; gap: var(--s-3) var(--s-4); padding: var(--s-4); border-bottom: 1px solid var(--slate-200); align-items: start; }
.rx-line:last-child { border-bottom: 0; }
.rx-line .pic { width: 64px; height: 64px; border-radius: var(--r-md); border: 1px solid var(--slate-200); overflow: hidden; background: var(--slate-100); }
.rx-line .pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rx-line .t1 { font-weight: var(--weight-medium); }
.rx-line .t2 { font-size: var(--text-sm); color: var(--slate-600); margin-top: 2px; }
.rx-line .qline { font-size: var(--text-sm); color: var(--slate-600); margin-top: var(--s-1); }
.rx-line .amt { text-align: right; font-weight: var(--weight-medium); font-variant-numeric: tabular-nums; }
.rx-total { margin: var(--s-4) 0 var(--s-5); display: grid; grid-template-columns: 1fr auto; gap: var(--s-2) var(--s-4); }
.rx-total dt { color: var(--slate-600); }
.rx-total dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.rx-total .grand { font-size: var(--text-xl); font-weight: var(--weight-strong); color: var(--slate-900); }
.rx-total .grand-l { font-weight: var(--weight-medium); color: var(--slate-900); align-self: end; }
.rx-actions { display: grid; gap: var(--s-3); }
.rx .btn-primary { background: var(--brand-primary); border-color: var(--brand-primary); }
.rx .btn-primary:hover { filter: brightness(0.9); }
.rx-foot { margin-top: var(--s-6); padding-top: var(--s-4); border-top: 1px solid var(--slate-200); font-size: var(--text-xs); color: var(--slate-600); }
.preview-bar { background: var(--staff-bg); border-bottom: 1px solid var(--staff-edge); color: var(--staff-fg); font-size: var(--text-sm); padding: var(--s-2) var(--s-4); text-align: center; }
.rx .btn, .rx .input, .rx .textarea { min-height: var(--control-h-lg); }

/* ---------- Component page helpers ---------- */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--s-3); }
.sw { font-size: var(--text-xs); }
.sw i { display: block; height: 44px; border-radius: var(--r-md); border: 1px solid var(--slate-200); margin-bottom: var(--s-1); }
.sw b { display: block; font-weight: var(--weight-medium); font-size: var(--text-sm); }
.sw span { color: var(--slate-600); }
.demo { background: var(--white); border: 1px solid var(--slate-200); border-radius: var(--r-lg); padding: var(--s-5); display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }
.demo.block { display: block; }
.cp h2 { margin: var(--s-7) 0 var(--s-1); padding-top: var(--s-4); border-top: 1px solid var(--slate-200); }
.cp h2 + p { color: var(--slate-600); font-size: var(--text-sm); margin-bottom: var(--s-4); }
.cp h2:first-of-type { border-top: 0; margin-top: var(--s-5); }
.type-row { display: grid; grid-template-columns: 140px 1fr; gap: var(--s-4); align-items: baseline; padding: var(--s-2) 0; border-bottom: 1px solid var(--slate-100); }
.type-row code { font-size: var(--text-xs); color: var(--slate-600); }
.tweak { position: fixed; right: var(--s-4); bottom: var(--s-4); z-index: 60; width: 280px; background: var(--white); border: 1px solid var(--slate-300); border-radius: var(--r-lg); box-shadow: var(--shadow-3); padding: var(--s-4); display: grid; gap: var(--s-3); }
.tweak h3 { font-size: var(--text-md); }
.tweak .contrast { font-size: var(--text-xs); }
.tweak .ok { color: var(--st-accepted-fg); font-weight: var(--weight-medium); }
.tweak .bad { color: var(--st-bad-fg); font-weight: var(--weight-medium); }
.tweak input[type="color"] { width: 44px; height: 32px; padding: 0; border: 1px solid var(--slate-300); border-radius: var(--r-md); background: none; }

/* ---------- Small screens ---------- */
@media (max-width: 1100px) {
  .rail { height: auto; min-height: var(--nav-h); padding: var(--s-2) var(--s-4); gap: var(--s-3); }
  .nav { display: none; order: 5; width: 100%; flex-direction: column; height: auto; padding-bottom: var(--s-2); }
  .rail.open .nav { display: flex; }
  .nav a { min-height: 44px; border-left: 3px solid transparent; border-bottom: 0; border-top: 0; }
  .nav a[aria-current="page"] { border-left-color: var(--nav-active); border-bottom: 0; background: var(--accent-tint); }
  .btn.menu-btn { display: inline-flex; }
  .nav-user .who { display: none; }
  .topbar { top: auto; position: static; }
  .content { padding: var(--s-5) var(--s-4); }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi:nth-child(3) { border-left: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--slate-200); }
}

@media (max-width: 980px) {
  .builder { grid-template-columns: 1fr; }
  .totals { position: static; }
}
@media (max-width: 760px) {
  .rail-right .select { display: none; }
  .hide-sm { display: none !important; }
  .topbar { padding: var(--s-2) var(--s-4); gap: var(--s-2); }
  .topbar .qno, .topbar .saved { display: none; }
  .content { padding: var(--s-4); }
  .row.two, .row.three { grid-template-columns: 1fr; }
  .lines-head { display: none; }
  .line-main { grid-template-columns: 1fr 32px; }
  .line-main .acts { grid-column: 2; grid-row: 1 / span 5; }
  .staff { margin-left: 0; }
  .line-main .tot-c { text-align: right; }
  .staff-grid { grid-template-columns: 1fr 1fr; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .t .hide-sm, .t th.hide-sm { display: none; }
  .tweak { width: auto; left: var(--s-3); right: var(--s-3); }
}
@media print { .rail, .topbar, .tweak, .toasts { display: none; } .shell { display: block; } }

/* ---------- Dashboard: filters, KPIs, charts, pipeline, timeline ---------- */
.seg { display: inline-flex; border: 1px solid var(--slate-300); border-radius: var(--r-md); background: var(--white); padding: 2px; gap: 2px; }
.seg button { font: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium); border: 0; background: none; padding: 0 var(--s-3); height: 30px; border-radius: var(--r-sm); color: var(--slate-700); cursor: pointer; }
.seg button:hover { background: var(--slate-100); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--white); border: 1px solid var(--slate-200); border-radius: var(--r-lg); box-shadow: var(--shadow-1); margin-bottom: var(--s-5); }
.kpi { padding: var(--s-4) var(--s-5); border-left: 1px solid var(--slate-200); min-width: 0; }
.kpi:first-child { border-left: 0; }
.kpi .l { font-size: var(--text-sm); color: var(--slate-600); }
.kpi .v { font-size: var(--text-2xl); font-weight: var(--weight-medium); line-height: 1.15; font-variant-numeric: tabular-nums; margin: var(--s-1) 0; }
.kpi .d { font-size: var(--text-xs); color: var(--slate-600); display: flex; align-items: center; gap: var(--s-1); flex-wrap: wrap; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: var(--weight-medium); padding: 0 var(--s-2); height: 20px; border-radius: var(--r-pill); }
.delta.up { background: var(--st-accepted-bg); color: var(--st-accepted-fg); }
.delta.down { background: var(--st-bad-bg); color: var(--st-bad-fg); }
.delta.flat { background: var(--st-draft-bg); color: var(--st-draft-fg); }
.spark { display: block; width: 100%; height: 36px; margin-top: var(--s-2); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--s-5); margin-bottom: var(--s-6); align-items: start; }
.card { background: var(--white); border: 1px solid var(--slate-200); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: var(--s-5); }
.card + .card { margin-top: var(--s-5); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-3); margin-bottom: var(--s-3); flex-wrap: wrap; }
.card-head h2 { font-size: var(--text-lg); }
.card-head .sub { font-size: var(--text-sm); color: var(--slate-600); }
.legend { display: flex; gap: var(--s-4); font-size: var(--text-sm); color: var(--slate-700); flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.legend i.box { height: 10px; width: 10px; border-radius: 2px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart svg:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
.chart text { font-family: var(--font); fill: var(--slate-600); font-size: 11.5px; }
.chart .grid line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .cross { stroke: var(--slate-400); stroke-width: 1; }
.tip { position: absolute; pointer-events: none; background: var(--white); border: 1px solid var(--slate-300); border-radius: var(--r-md); box-shadow: var(--shadow-2); padding: var(--s-2) var(--s-3); font-size: var(--text-sm); z-index: 5; min-width: 170px; }
.tip .when { color: var(--slate-600); font-size: var(--text-xs); margin-bottom: 2px; }
.tip .row2 { display: flex; justify-content: space-between; gap: var(--s-4); align-items: center; }
.tip .row2 b { font-weight: var(--weight-strong); font-variant-numeric: tabular-nums; }
.tip i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.tview { margin-top: var(--s-3); font-size: var(--text-sm); }
.tview summary { cursor: pointer; color: var(--accent); }
.tview table { width: 100%; border-collapse: collapse; margin-top: var(--s-2); font-variant-numeric: tabular-nums; }
.tview th, .tview td { text-align: right; padding: 4px var(--s-2); border-bottom: 1px solid var(--slate-100); }
.tview th:first-child, .tview td:first-child { text-align: left; }
.pipe { display: flex; gap: 2px; height: 22px; margin: var(--s-3) 0 var(--s-4); }
.pipe > div { border-radius: var(--r-sm); min-width: 4px; transition: opacity var(--dur) var(--ease); }
.pipe > div:hover, .pipe > div:focus-visible { opacity: 0.8; }
.pipe-key { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-3); }
.pipe-key div { font-size: var(--text-sm); color: var(--slate-600); }
.pipe-key b { display: block; color: var(--slate-900); font-size: var(--text-md); font-weight: var(--weight-medium); font-variant-numeric: tabular-nums; }
.pipe-key i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 8px; bottom: 8px; width: 2px; background: var(--slate-200); }
.timeline li { position: relative; padding: 0 0 var(--s-4) var(--s-5); font-size: var(--text-sm); }
.timeline li:last-child { padding-bottom: 0; }
.timeline .pt { position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--slate-300); border: 2px solid var(--white); box-sizing: border-box; }
.timeline .pt.live { background: var(--seq-4); animation: pulse 2s infinite; }
.timeline .pt.opened { background: var(--chart-1); }
.timeline .pt.accepted { background: var(--chart-2); }
.timeline .pt.followup { background: var(--st-warn-fg); }
.timeline .when { display: block; color: var(--slate-600); font-size: var(--text-xs); }
.timeline a { color: var(--slate-900); font-weight: var(--weight-medium); text-decoration: none; }
.timeline a:hover { color: var(--accent); text-decoration: underline; }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .kpis { grid-template-columns: 1fr 1fr; } .kpi:nth-child(3) { border-left: 0; } .kpi:nth-child(n+3) { border-top: 1px solid var(--slate-200); } .pipe-key { grid-template-columns: 1fr 1fr; } }

/* ---------- Dashboard filters row and collapsible sections ---------- */
.filters { display: flex; gap: var(--s-4); align-items: flex-end; flex-wrap: wrap; margin-bottom: var(--s-4); padding: var(--s-3) var(--s-4); background: var(--white); border: 1px solid var(--slate-200); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.filters .field { min-width: 0; }
.filters .select { width: auto; min-width: 170px; }
.filters .grow { flex: 1; }
.card-toggle { height: 28px; padding: 0 var(--s-2); font-size: var(--text-sm); color: var(--accent); }
.card.collapsed .card-body { display: none; }
.card.collapsed .card-head { margin-bottom: 0; }
.kpi-mini { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); align-items: baseline; background: var(--white); border: 1px solid var(--slate-200); border-radius: var(--r-lg); padding: var(--s-3) var(--s-5); margin-bottom: var(--s-5); font-size: var(--text-sm); color: var(--slate-600); box-shadow: var(--shadow-1); }
.kpi-mini b { color: var(--slate-900); font-size: var(--text-lg); font-weight: var(--weight-medium); font-variant-numeric: tabular-nums; margin-right: 4px; }
.kpi-mini .delta { margin-left: 4px; }

/* ---------- Private notes ---------- */
.notelist { list-style: none; margin: var(--s-2) 0 var(--s-3); padding: 0; display: grid; gap: var(--s-2); }
.notelist li { background: var(--white); border: 1px solid var(--staff-edge); border-radius: var(--r-md); padding: var(--s-2) var(--s-3); }
.nmeta { font-size: var(--text-xs); color: var(--staff-fg); }
.ntext { white-space: pre-wrap; color: var(--slate-900); margin: 2px 0; }
.nact { display: flex; gap: var(--s-1); }
.nact .btn { height: 28px; padding: 0 var(--s-2); font-size: var(--text-sm); }
.nhist { margin-top: var(--s-3); font-size: var(--text-sm); }
.nhist summary { cursor: pointer; color: var(--staff-fg); text-decoration: underline; }
.nhist .activity { margin-top: var(--s-2); }
.nhist .activity li { grid-template-columns: 110px 1fr; }

/* ---------- Home: glance card and colour bars ---------- */
.glance { display: flex; align-items: center; gap: var(--s-6); row-gap: var(--s-3); background: var(--white); border: 1px solid var(--slate-200); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: var(--s-3) var(--s-5); margin-bottom: var(--s-5); flex-wrap: wrap; }
.glance .donut { width: 96px; height: 96px; flex: none; }
.glance .fig { border-left: 4px solid var(--accent); padding-left: var(--s-3); }
.glance .fig.wait { border-left-color: var(--slate-500); }
.glance .fig.draft { border-left-color: var(--slate-300); }
.glance .fig b { display: block; font-size: var(--text-xl); font-weight: var(--weight-medium); font-variant-numeric: tabular-nums; line-height: 1.15; }
.glance .fig span { font-size: var(--text-sm); color: var(--slate-600); }
.glance .more { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: var(--s-1); }
.glance .scope { font-size: var(--text-xs); color: var(--slate-600); }
.t td.bar-cell, .t th.bar-cell { padding: 0; width: 6px; min-width: 6px; }
.t td.bar-cell { background: var(--bar, transparent); }
.t tr[data-bar="none"] { --bar: var(--slate-200); }
.t tr[data-bar="sent"] { --bar: var(--slate-500); }
.t tr[data-bar="viewed"] { --bar: var(--seq-2); }
.t tr[data-bar="live"] { --bar: var(--seq-4); }
.t tr[data-bar="accepted"] { --bar: #1E8E4E; }
.t tr[data-bar="declined"] { --bar: #C0362C; }
.t tr[data-bar="done"] { --bar: #8CC9A5; }
.t tr[data-bar="warn"] { --bar: #C98A12; }
.barkey { display: flex; gap: var(--s-4); flex-wrap: wrap; font-size: var(--text-xs); color: var(--slate-600); margin: 0 0 var(--s-2); }
.barkey i { display: inline-block; width: 4px; height: 12px; border-radius: 1px; margin-right: 6px; vertical-align: middle; }

/* ---------- Pictures on lines: large, under the description, like the finished quote ---------- */
.picbox { margin-top: var(--s-3); }
.picbox img { display: block; max-width: min(100%, 320px); max-height: 180px; width: auto; height: auto; object-fit: contain; border: 1px solid var(--slate-200); border-radius: var(--r-md); background: var(--white); padding: var(--s-2); }
.picbtns { display: flex; gap: var(--s-1); margin-top: var(--s-1); }
.picbtns .btn { height: 28px; padding: 0 var(--s-2); font-size: var(--text-sm); }
.addpic { font: inherit; font-size: var(--text-sm); color: var(--slate-700); background: var(--white); border: 1px dashed var(--slate-400); border-radius: var(--r-md); width: min(100%, 320px); min-height: 64px; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: var(--s-2); padding: var(--s-2) var(--s-3); cursor: pointer; text-align: center; }
.addpic:hover { border-color: var(--accent); color: var(--accent-strong); background: var(--accent-tint); }
.addpic > span:first-child { font-size: var(--text-lg); line-height: 1; }
.addpic .hint { flex-basis: 100%; }
.rx-line { grid-template-columns: 1fr auto; }
.rx-line .rpic { display: block; max-width: min(100%, 360px); max-height: 200px; width: auto; height: auto; margin-top: var(--s-3); }

/* ---------- Quote list: two-line quote cell, status with seen line, date, total ---------- */
.tabs button .tcount { font-size: var(--text-xs); color: var(--slate-600); background: var(--slate-100); border-radius: var(--r-pill); padding: 0 6px; margin-left: 4px; }
.tabs button[aria-selected="true"] .tcount { background: var(--accent-tint); color: var(--accent-strong); }
.toolbar .grow { flex: 1; }
.t.quotes td { padding: var(--s-4) var(--s-4); vertical-align: top; }
.t.quotes th { text-transform: none; letter-spacing: 0; font-size: var(--text-sm); }
.t.quotes .primary a { font-size: var(--text-md); }
.t.quotes .primary .sub { margin-top: 2px; color: var(--slate-700); max-width: 54ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t.quotes .primary .sub2 { display: block; font-size: var(--text-xs); color: var(--slate-600); margin-top: 2px; }
.t.quotes .st .stsub { display: block; margin-top: var(--s-1); }
.t.quotes .dt .d1 { display: block; white-space: nowrap; }
.t.quotes .dt .d2 { display: block; font-size: var(--text-xs); color: var(--slate-600); margin-top: 2px; }
.t.quotes td.money { font-weight: var(--weight-medium); }
.t.quotes tbody tr { cursor: pointer; }
/* ---------- New contact form inside the Send-to box ---------- */
.newc { margin-top: var(--s-3); padding: var(--s-4); background: var(--accent-tint); border: 1px solid var(--accent-edge); border-radius: var(--r-md); display: grid; gap: var(--s-3); }
.newc p { margin: 0; font-size: var(--text-sm); }
/* ---------- Quote title block with who it was sent to ---------- */
.topbar .title { flex-direction: column; align-items: flex-start; gap: 0; }
.topbar .title { max-width: 100%; }
.topbar .title .trow { display: flex; align-items: baseline; gap: var(--s-3); min-width: 0; }
.to-line { font-size: var(--text-sm); color: var(--slate-600); max-width: min(70ch, 100%); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.t.quotes td.bar-cell, .t.quotes th.bar-cell { padding: 0; width: 6px; min-width: 6px; }
.toolbar .input[type="search"] { min-width: 380px; }
@media (max-width: 760px) { .toolbar .input[type="search"] { min-width: 0; flex: 1; } }

.line .lcode { display: block; width: 11rem; max-width: 100%; border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; font: inherit; font-size: var(--text-xs); color: var(--slate-600); letter-spacing: 0.02em; padding: 1px 4px; margin: 0 0 2px -4px; }
.line .lcode:hover { border-color: var(--slate-200); }
.line .lcode:focus { border-color: var(--focus); background: #fff; outline: none; }
.rx-line .t0 { font-size: var(--text-xs); color: var(--slate-500); letter-spacing: 0.02em; }
.reason-note { font-size: var(--text-sm); color: var(--slate-600); }

.line .opts { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); margin-top: var(--s-2); }
.line .opts .select { width: auto; min-width: 0; font-size: var(--text-sm); padding-top: 3px; padding-bottom: 3px; }
.line .opts .check { font-size: var(--text-sm); color: var(--slate-700); }
.line.is-off .ltotal, .line.is-off .qty, .line.is-off .unit { color: var(--slate-500); text-decoration: line-through; }
.rx-line { align-items: start; }
.rx-line.is-off { color: var(--slate-500); }
.rx-line.is-off .amt { text-decoration: line-through; color: var(--slate-500); }
.rx-ctl { padding-top: 3px; }
.rx-ctl input { width: 20px; height: 20px; accent-color: var(--accent); }
.rx-tag { display: inline-block; font-size: var(--text-xs); color: var(--slate-600); border: 1px solid var(--slate-300); border-radius: var(--r-sm); padding: 0 6px; margin-right: var(--s-2); vertical-align: 1px; }
.rx-line.is-off .t1 { color: var(--slate-600); }

.line .opts { padding: var(--s-2) var(--s-3); background: var(--slate-50, #F6F8FA); border: 1px solid var(--slate-200); border-radius: var(--r-sm); }
.line .opts[hidden] { display: none; }
.line .more { font-weight: var(--weight-bold); letter-spacing: 1px; }
.line-tag { float: right; font-size: var(--text-xs); color: var(--slate-600); border: 1px solid var(--slate-300); border-radius: var(--r-sm); padding: 0 6px; }

.line .picbox:has(.addpic) { display: none; }

/* ---------- rev 7: options row, text lines, menus, tabs, expiry ---------- */
.selrow { display: flex; align-items: center; gap: var(--s-3); min-height: 0; }
.selrow:empty { display: none; }
.selrow .selctl:empty { display: none; }
.selbox { font-size: var(--text-sm); color: var(--slate-700); align-items: center; }
.selbox input { margin-top: 0; }
.line-tag { float: none; }
.line .opts .check { align-items: center; }
.line .opts .check input { margin-top: 0; }
.line .opts .hint { margin-left: 2px; }
.line .per { display: block; font-size: var(--text-xs); font-weight: var(--weight-regular); color: var(--slate-600); }
.staff-grid { grid-template-columns: repeat(5, 1fr); }
.textline .text-c, .textline .sub-c { grid-column: 1 / 6; }
.textline .sub-c { grid-column: 1 / 5; }
.textline .line-main { align-items: start; }
.textline .acts { grid-column: 6; grid-row: 1; }
.textline .sub-amt { grid-column: 5; grid-row: 1; font-weight: var(--weight-medium); padding-top: 7px; }
.textline .lsubl { display: block; width: 100%; font: inherit; font-weight: var(--weight-medium); border: 1px solid transparent; background: transparent; border-radius: var(--r-sm); padding: 2px var(--s-2); margin-left: calc(-1 * var(--s-2)); }
.textline .lsubl:hover { border-color: var(--slate-200); }
.textline .lsubl:focus { border-color: var(--focus); outline: 1px solid var(--focus); background: #fff; }
.textline { background: var(--slate-25); }
.rec-block { margin-top: var(--s-4); padding-top: var(--s-3); border-top: 1px solid var(--slate-200); font-size: var(--text-sm); display: grid; gap: var(--s-1); }
.rec-block div { display: flex; justify-content: space-between; gap: var(--s-3); font-variant-numeric: tabular-nums; }
.rec-l { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--slate-600); font-weight: var(--weight-medium); }
.menu-wrap { position: relative; display: inline-block; }
.menu { position: absolute; right: 0; top: calc(100% + 4px); min-width: 250px; background: var(--white); border: 1px solid var(--slate-200); border-radius: var(--r-md); box-shadow: var(--shadow-2); padding: var(--s-1); z-index: 60; }
.menu button { display: block; width: 100%; text-align: left; font: inherit; font-size: var(--text-sm); padding: var(--s-2) var(--s-3); border: 0; background: none; border-radius: var(--r-sm); cursor: pointer; color: var(--slate-900); }
.menu button:hover, .menu button:focus-visible { background: var(--accent-tint); }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--slate-100); margin: var(--s-1) 0; }
.exprow { display: flex; gap: var(--s-2); }
.exprow .input { min-width: 0; }
.qtabs { margin-bottom: var(--s-5); }
.qtabs .badge { font-size: var(--text-xs); background: var(--slate-100); border-radius: var(--r-pill); padding: 0 var(--s-2); margin-left: var(--s-1); color: var(--slate-700); }
.act-sum { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-6); margin-bottom: var(--s-4); font-size: var(--text-sm); color: var(--slate-600); }
.act-sum b { color: var(--slate-900); font-size: var(--text-lg); font-weight: var(--weight-medium); margin-right: 4px; }
.vlist li { grid-template-columns: 120px 1fr auto; align-items: center; }
.rx-line:has(.rx-ctl) { grid-template-columns: auto 1fr auto; }
.rx-text { grid-template-columns: 1fr; background: var(--slate-25); }
.rx-text .t1 { font-size: var(--text-md); }
.rx-text .t2 { white-space: pre-wrap; }
.rx-sub { font-weight: var(--weight-medium); background: var(--slate-25); }
.rx-qty { width: 68px; height: 30px; font: inherit; text-align: right; border: 1px solid var(--slate-300); border-radius: var(--r-sm); padding: 0 var(--s-2); }
.rx-per { font-size: var(--text-xs); color: var(--slate-600); display: block; font-weight: var(--weight-regular); }
.chip.dismissed { background: var(--st-draft-bg); color: var(--st-draft-fg); }
@media (max-width: 760px) { .textline .text-c, .textline .sub-c { grid-column: 1; } .textline .sub-amt { grid-column: 1; grid-row: auto; } .staff-grid { grid-template-columns: 1fr 1fr; } }

.line .opts { display: grid; grid-template-columns: repeat(3, minmax(0, auto)); gap: var(--s-2) var(--s-6); justify-content: start; align-items: start; }
.line .opts .optcol { display: grid; gap: var(--s-2); align-content: start; }
.line .opts .btn-sm { height: 30px; padding: 0 var(--s-3); font-size: var(--text-sm); }
.line .disc-c.off .disc { visibility: hidden; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4) var(--s-6); }
.settings-grid .exprow .select { width: 130px; flex: none; }
@media (max-width: 760px) { .line .opts { grid-template-columns: 1fr; } .settings-grid { grid-template-columns: 1fr; } }

/* ---------- rev 7b: Quotient-style lines (toolbar on top, captions under fields, no table head) ---------- */
.lines-head { display: none; }
.line-main { grid-template-columns: minmax(0, 1fr) 72px 110px 84px 110px; grid-template-rows: auto auto; gap: var(--s-2) var(--s-3); }
.line .acts { grid-column: 1 / -1; grid-row: 1; flex-direction: row; justify-self: end; justify-content: flex-end; gap: 2px; position: relative; }
.line .item-c, .line .qty-c, .line .unit-c, .line .disc-c, .line .tot-c { grid-row: 2; }
.line .item-c { grid-column: 1; }
.line .cap { display: block; text-align: right; font-size: var(--text-xs); color: var(--slate-600); margin-top: 2px; }
.line .tot-c .ltotal { padding-top: 7px; }
.line .mv.plus, .line .more { font-size: var(--text-lg); width: 30px; height: 28px; border: 1px solid transparent; }
.line .mv.plus:hover, .line .more:hover { background: var(--accent-tint); color: var(--accent-strong); }
.line .lmenu { top: 32px; right: 0; }
.textline .text-c { grid-column: 1 / -1; grid-row: 2; }
.textline .sub-c { grid-column: 1 / 5; grid-row: 2; }
.textline .sub-amt { grid-column: 5; grid-row: 2; }
.textline .acts { grid-row: 1; grid-column: 1 / -1; }
.addmenu { left: 0; right: auto; top: auto; bottom: calc(100% + 4px); }
.rsug { display: grid !important; grid-template-columns: 1fr; gap: 0; padding: var(--s-2) var(--s-3) !important; }
.rsug .rn { font-weight: var(--weight-medium); color: var(--slate-900); }
.rsug .rc { color: var(--slate-700); font-size: var(--text-sm); }
.rsug .re { color: var(--slate-600); font-size: var(--text-xs); }
.rorg { color: var(--slate-600); font-size: var(--text-xs); margin-left: 2px; }
@media (max-width: 760px) {
  .line-main { grid-template-columns: 1fr 1fr; }
  .line .item-c { grid-column: 1 / -1; grid-row: 2; }
  .line .qty-c, .line .unit-c, .line .disc-c, .line .tot-c { grid-row: auto; }
  .line-main .acts { grid-column: 1 / -1; grid-row: 1; }
  .textline .text-c, .textline .sub-c { grid-column: 1 / -1; grid-row: 2; }
  .textline .sub-amt { grid-column: 1 / -1; grid-row: 3; }
}
.line .opts { grid-template-columns: repeat(3, max-content); }
.line .opts .check span { white-space: nowrap; }
#seen-row:empty { display: none; }

/* ---------- rev 8: Quotient-style cost and markup row, popup line menu, card layout ---------- */
.line-main { grid-template-columns: minmax(0, 1fr) minmax(300px, 400px); grid-template-rows: auto auto; gap: var(--s-2) var(--s-4); }
.lm-head { grid-column: 1 / -1; grid-row: 1; display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-height: 28px; }
.lm-head .acts { position: relative; grid-column: auto; grid-row: auto; justify-self: auto; }
.line .item-c { grid-column: 1; grid-row: 2; }
.line .price-c { grid-column: 2; grid-row: 2; display: grid; gap: var(--s-2); align-content: start; min-width: 0; }
.itemcard { border: 1px solid var(--slate-300); border-radius: var(--r-md); background: var(--white); }
.itemcard:focus-within { outline: 2px solid var(--focus); border-color: var(--focus); }
.itemcard .lcode, .itemcard .ltitle, .itemcard .ldesc { display: block; width: 100%; margin: 0; border: 0; border-radius: 0; background: transparent; padding: var(--s-2) var(--s-3); color: var(--slate-900); outline: none; box-shadow: none; }
.itemcard .lcode { font-size: var(--text-md); border-bottom: 1px solid var(--slate-200); }
.itemcard .ltitle { font-size: var(--text-lg); font-weight: var(--weight-strong); border-bottom: 1px solid var(--slate-200); }
.itemcard .ldesc { font-size: var(--text-md); min-height: 84px; }
.itemcard .lcode:hover, .itemcard .ltitle:hover, .itemcard .ldesc:hover, .itemcard .lcode:focus, .itemcard .ltitle:focus, .itemcard .ldesc:focus { border-color: var(--slate-200); outline: none; background: transparent; }
.line .item-c .suggest.items { left: 0; right: 0; top: 84px; }
.line .picbox { margin-top: var(--s-2); }
.pr-sel { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }
.pr-sel .select { height: 36px; }
.staffrow { background: var(--staff-bg); border: 1px solid var(--staff-edge); border-radius: var(--r-md); padding: var(--s-2) var(--s-3) var(--s-2); color: var(--staff-fg); }
.staffrow .lock { display: block; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .06em; font-weight: var(--weight-medium); margin-bottom: var(--s-2); }
.sr-in { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: var(--s-2); }
.sr-in .input { border-color: var(--staff-edge); background: var(--white); }
.sr-in .cap, .pr-nums .cap { text-align: right; }
.sr-note { margin: var(--s-1) 0 0; font-size: var(--text-xs); color: var(--staff-fg); }
.pr-nums { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: var(--s-2); }
.pr-nums .tot-c .ltotal { padding-top: 7px; font-weight: var(--weight-strong); }
.line .disc-c.off { display: none; }
.line .opts.menu { right: 0; top: 32px; min-width: 300px; display: grid; grid-template-columns: 1fr; gap: 0; padding: var(--s-2) var(--s-3); background: var(--white); border: 1px solid var(--slate-200); box-shadow: var(--shadow-2); }
.line .opts.menu .optcol { display: grid; gap: var(--s-2); padding: var(--s-2) 0; }
.line .opts.menu .optcol + .optcol { border-top: 1px solid var(--slate-100); }
.line .opts.menu .optsel { display: grid; gap: 2px; }
.line .opts.menu .optlab { font-size: var(--text-xs); color: var(--slate-600); }
.line .opts.menu .select, .line .opts.menu .btn-sm { width: 100%; }
.textline .line-main { grid-template-columns: minmax(0, 1fr) 140px; }
.textline .sub-c { grid-column: 1; grid-row: 2; }
.textline .sub-amt { grid-column: 2; grid-row: 2; }
@media (max-width: 900px) {
  .line-main { grid-template-columns: 1fr; }
  .line .item-c { grid-column: 1; grid-row: 2; }
  .line .price-c { grid-column: 1; grid-row: 3; }
  .textline .sub-c, .textline .sub-amt { grid-column: 1; grid-row: auto; }
}
.top2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s-5); align-items: start; }
.top2 .section { margin-bottom: var(--s-5); }
.top2 .notelist { max-height: 140px; overflow: auto; }
@media (max-width: 900px) { .top2 { grid-template-columns: 1fr; } }
.builder { display: block; }
.totals-sec { display: grid; grid-template-columns: 1fr minmax(300px, 380px); gap: var(--s-5); align-items: start; justify-content: end; }
.totals-sec .tot-left { display: grid; gap: var(--s-3); align-content: start; }
.totals-sec .totals { position: static; }
@media (max-width: 760px) { .totals-sec { grid-template-columns: 1fr; } }
.attlist { list-style: none; margin: 0 0 var(--s-3); padding: 0; display: grid; gap: var(--s-2); }
.attlist li { display: grid; grid-template-columns: minmax(0, 1fr) auto 190px auto; gap: var(--s-3); align-items: center; padding: var(--s-2) var(--s-3); border: 1px solid var(--slate-200); border-radius: var(--r-md); }
.attlist li:only-child.muted, .attlist li.muted { border: 0; padding: 0; display: block; }
.attlist .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: var(--weight-medium); }
.attlist .select { height: 32px; font-size: var(--text-sm); }
.attdrop { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; padding: var(--s-3); border: 1px dashed var(--slate-400); border-radius: var(--r-md); }
.attdrop.over { border-color: var(--accent); background: var(--accent-tint); }
@media (max-width: 760px) { .attlist li { grid-template-columns: 1fr auto; } .attlist .select { grid-column: 1 / -1; } }

/* rev 9 */
.rx-top { display: block; border-bottom: 0; padding-bottom: 0; }
.rx-brand { padding-bottom: var(--s-4); border-bottom: 3px solid var(--brand-primary); margin-bottom: var(--s-4); }
.rx-info { display: grid; grid-template-columns: 1.3fr 1fr 1fr; margin: 0 0 var(--s-5); border-bottom: 1px solid var(--slate-200); padding-bottom: var(--s-4); }
.rx-col { padding: 0 var(--s-4); border-left: 1px solid var(--slate-200); font-size: var(--text-sm); color: var(--slate-700); min-width: 0; }
.rx-col:first-child { padding-left: 0; border-left: 0; }
.rx-col dt { font-size: var(--text-xs); letter-spacing: 0.06em; text-transform: uppercase; color: var(--slate-600); margin-top: var(--s-2); }
.rx-col dt:first-child { margin-top: 0; }
.rx-col dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.rx-col dd strong { display: block; color: var(--slate-900); font-weight: var(--weight-medium); }
.rx-col dd span { display: block; }
.rx-pdf { display: inline-block; margin-top: var(--s-3); color: var(--accent-strong, var(--accent)); font-weight: var(--weight-medium); }
.rx-line .amt { background: var(--accent-tint); margin: calc(var(--s-4) * -1) calc(var(--s-4) * -1) calc(var(--s-4) * -1) 0; padding: var(--s-4); min-width: 120px; align-self: stretch; }
.rx-line:last-child .amt { border-radius: 0 0 var(--r-lg) 0; }
.rx-text .amt, .rx-sub .amt { background: none; margin: 0; padding: 0; min-width: 0; }
.rx-lines { overflow: hidden; }
@media (max-width: 640px) { .rx-info { grid-template-columns: 1fr; gap: var(--s-4); } .rx-col, .rx-col:first-child { padding: 0; border-left: 0; } .rx-line .amt { min-width: 90px; } }
.fu-hint { font-size: var(--text-sm); color: var(--slate-600); margin: 0 0 var(--s-3); }
.fu-why { color: var(--st-warn-fg); }
.sr-ren { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; margin-top: var(--s-2); }
.sr-rl { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--text-sm); }
.sr-rl .select { min-width: 130px; }
.rx-line.is-off .amt { color: var(--slate-700); }
/* rev 9b: quote list toolbar on phones - search gets its own full-width row */
@media (max-width: 760px) {
  .toolbar { display: grid; grid-template-columns: 1fr; gap: var(--s-2); }
  .toolbar .select, .toolbar .input, .toolbar .input[type="search"] { width: 100%; min-width: 0; }
  .toolbar .grow { display: none; }
  .toolbar .btn { width: 100%; }
  .toolbar .input[type="search"] { order: -1; }
}

/* rev 9c: bigger company logo on the recipient page */
.rx-logo { max-height: 84px; max-width: 320px; }
.rx-logo-text { font-size: var(--text-xl); }
@media (max-width: 640px) { .rx-logo { max-height: 64px; max-width: 240px; } }

/* rev 9d: quote list - recipients in green, sender in company blue */
.t.quotes .primary .sub .to-names { color: var(--name-to); font-weight: var(--weight-medium); }
.t.quotes .primary .sentby { display: block; font-size: var(--text-sm); color: var(--brand-primary); margin-top: 2px; }

/* rev 9e */
.line.dropping { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-tint); }
.lockbar { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; margin: 0 0 var(--s-4); padding: var(--s-3) var(--s-4); background: var(--staff-bg); border: 1px solid var(--staff-edge); border-radius: var(--r-md); color: var(--staff-fg); font-size: var(--text-sm); }
.lockbar b { font-weight: var(--weight-strong); }
.fu-due { color: var(--st-warn-fg); font-weight: var(--weight-medium); }

/* rev 9f: tidy recipient chips (one line each, long company names shorten) */
.rchip { max-width: 100%; flex-wrap: nowrap; }
.rchip > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rchip .opened, .rchip .tag, .rchip .x { flex: none; white-space: nowrap; }
.rchip .opened { color: var(--slate-600); }

/* rev 9g: quantity x price sits with the line total, right-aligned */
.rx-line .amt { min-width: 150px; }
.rx-line .amt .qline { font-size: var(--text-sm); font-weight: var(--weight-regular); color: var(--slate-700); margin-top: var(--s-1); }
.rx-line .amt .qline .rx-qty { width: 56px; }
.rx-line.is-off .amt .qline { color: var(--slate-700); }
@media (max-width: 640px) { .rx-line .amt { min-width: 110px; } }
/* rev 9g: pictures a little smaller (recipient page and editor) */
.rx-line .rpic { max-width: min(100%, 180px); max-height: 100px; }
.picbox img { max-width: min(100%, 180px); max-height: 100px; }
/* rev 9h: price, then x quantity, then the line total, stacked on the right */
.rx-line .amt .qline { margin-top: 0; line-height: 1.5; }
.rx-line .amt .rx-tot { margin-top: var(--s-1); padding-top: var(--s-1); border-top: 1px solid var(--accent-edge); font-weight: var(--weight-strong); }
.rx-line .amt .rx-per { margin-top: var(--s-1); }

/* rev 9i: no stray vertical scroll bar on the status tabs (sideways scroll stays for phones) */
.tabs { overflow-y: hidden; padding-bottom: 1px; }
