/* ============================================
   FHP Office - staff back-end (admin.html)
   Same navy / warm white / yellow palette as the public site (css/styles.css), denser app layout.
   ============================================ */

:root {
  --navy: #14213D;
  --navy-deep: #0B1426;
  --navy-mid: #22335A;
  --navy-tint: #E9ECF3;
  --gold: #A86400;
  --gold-light: #FCA311;
  --gold-soft: #FFF2D9;
  --ink: #1B1B1F;
  --ink-soft: #3A3B40;
  --muted: #6B6F76;
  --line: #E7E2D8;
  --line-soft: #EFEBE3;
  --bg: #F6F3EE;
  --surface: #FFFFFF;
  --hover: #FAF7F2;
  --green: #2E7754;  --green-bg: #E6F2EC;
  --red: #B73E41;    --red-bg: #F8E7E7;
  --amber: #9A6416;  --amber-bg: #FBF0DC;
  --blue: #22335A;   --blue-bg: #E9ECF3;
  --slate-bg: #ECE7DE;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(20, 33, 61, .05), 0 2px 6px rgba(20, 33, 61, .04);
  --shadow-lg: 0 20px 50px rgba(20, 33, 61, .18);
  --side-w: 236px;
  --font: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  --serif: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--navy-mid); }
img { max-width: 100%; }
[hidden] { display: none !important; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
input, select, textarea, button { font: inherit; color: inherit; }

.muted { color: var(--muted); }
.strong { font-weight: 600; }
.warn { color: var(--amber); }
.mono { font-family: var(--mono); font-size: .9em; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.pad { padding: 1rem 1.25rem; }
.fine { font-size: .8rem; color: var(--muted); margin: .75rem 0 0; }

/* ---------- buttons ---------- */
.btn-o {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem 1rem; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: .9rem; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-o.primary { background: var(--navy); color: #fff; }
.btn-o.primary:hover { background: var(--navy-mid); }
.btn-o.ghost { background: var(--surface); border-color: var(--line); color: var(--ink-soft); }
.btn-o.ghost:hover { border-color: #FCA311; background: var(--hover); }
.btn-o.danger { background: var(--red); color: #fff; }
.btn-o.danger:hover { filter: brightness(.95); }
.btn-o.sm { padding: .35rem .7rem; font-size: .82rem; }
.btn-o.block { width: 100%; }
.btn-o:disabled { opacity: .55; cursor: not-allowed; }
.btn-o:focus-visible, .icon-btn:focus-visible, .link-btn:focus-visible, .side-nav a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.icon-btn { background: none; border: 0; cursor: pointer; padding: .3rem .45rem; border-radius: var(--radius-sm); color: var(--muted); line-height: 1; }
.icon-btn:hover { background: var(--slate-bg); color: var(--ink); }
.link-btn { background: none; border: 0; padding: .25rem 0; color: var(--navy-mid); cursor: pointer; font-weight: 500; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--red); font-size: .8rem; margin-left: .5rem; }

/* ---------- forms ---------- */
.field { display: block; margin-bottom: .9rem; }
.field > span { display: block; font-size: .75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .3rem; }
.field input, .field select, .field textarea, .toolbar input, .toolbar select, .typeahead input, textarea, .lines input {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy-mid); box-shadow: 0 0 0 3px rgba(20, 33, 61, .12); }
input:disabled { background: var(--slate-bg); color: var(--muted); }
.form-msg { margin: .25rem 0 .9rem; padding: .55rem .75rem; border-radius: var(--radius-sm); background: var(--red-bg); color: var(--red); font-size: .88rem; }
.form-msg.ok { background: var(--green-bg); color: var(--green); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-grid .span-2 { grid-column: span 2; }
.form-bar { display: flex; justify-content: flex-end; gap: .6rem; padding: 1rem 0 2rem; }
.check { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem; background: linear-gradient(160deg, var(--navy-deep), var(--navy-mid)); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 14px; padding: 2rem 1.75rem; box-shadow: var(--shadow-lg); }
.auth-logo { display: block; width: 100%; max-width: 280px; margin: 0 auto 1.25rem; }
.auth-card h1 { font-family: var(--serif); text-align: center; font-size: 1.6rem; color: var(--navy); }
.auth-card > .muted { text-align: center; margin: .2rem 0 1.5rem; }
.auth-card .link-btn { display: block; margin: .9rem auto 0; }
.auth-foot { text-align: center; margin: 1.25rem 0 0; font-size: .85rem; }
.auth-foot a { color: var(--muted); }
.auth-wrap > .loading { color: #fff; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--side-w); flex-shrink: 0; background: var(--navy-deep); color: #C9D1E0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: .6rem; padding: 1.2rem 1.1rem 1rem; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.07); }
.side-brand img { width: 34px; height: 34px; }
.side-word { color: #fff; font-family: var(--serif); font-size: 1.15rem; font-weight: 600; letter-spacing: .01em; }
.side-word strong { color: var(--gold-light); font-weight: 700; }
.side-nav { flex: 1; padding: .75rem .6rem; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.side-nav a { display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border-radius: var(--radius-sm); color: #C9D1E0; text-decoration: none; font-weight: 500; }
.side-nav a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; }
.side-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-nav a.active { background: rgba(252, 163, 17, .14); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.side-nav a.active svg { color: var(--gold-light); opacity: 1; }
.side-foot { padding: .9rem 1.1rem calc(.9rem + env(safe-area-inset-bottom, 0px)); border-top: 1px solid rgba(255,255,255,.07); font-size: .82rem; }
.side-foot a { color: #9AA6BF; text-decoration: none; }
.side-foot a:hover { color: #fff; }
.scrim { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar-o {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem;
  padding: .7rem 1.5rem; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.topbar-o h1 { font-size: 1.05rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-btn { display: none; font-size: 1.2rem; }
.global-search { position: relative; flex: 1 1 auto; max-width: 520px; }
.global-search input { width: 100%; padding: .5rem .8rem; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); }
.g-results, .ta-list {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 420px; overflow-y: auto; padding: .35rem;
}
.g-results a, .ta-list button {
  display: flex; flex-direction: column; gap: 1px; width: 100%; text-align: left; padding: .5rem .65rem; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--ink); background: none; border: 0; cursor: pointer;
}
.g-results a span, .ta-list button span { font-size: .8rem; color: var(--muted); }
.g-results a:hover, .ta-list button:hover, .ta-list button.on { background: var(--navy-tint); }
.g-group { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .5rem .65rem .2rem; }
.g-none { padding: .7rem; color: var(--muted); font-size: .88rem; }

.new-btn { margin-left: auto; }
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: .5rem; background: none; border: 0; cursor: pointer; padding: .25rem .4rem; border-radius: 999px; }
.user-btn:hover { background: var(--slate-bg); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--navy); color: var(--gold-light); display: grid; place-items: center; font-size: .78rem; font-weight: 700; }
.user-name { font-weight: 500; max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-pop { position: absolute; right: 0; top: calc(100% + 8px); width: 240px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: .4rem; z-index: 40; }
.user-pop-head { padding: .55rem .65rem .7rem; border-bottom: 1px solid var(--line-soft); margin-bottom: .3rem; display: flex; flex-direction: column; }
.user-pop-head .muted { font-size: .8rem; overflow-wrap: anywhere; }
.user-pop a, .user-pop button { display: block; width: 100%; text-align: left; padding: .5rem .65rem; border-radius: var(--radius-sm); background: none; border: 0; cursor: pointer; color: var(--ink); text-decoration: none; }
.user-pop a:hover, .user-pop button:hover { background: var(--hover); }

.view { padding: 1.75rem 2rem 3rem; max-width: 1480px; width: 100%; margin: 0 auto; }

/* ---------- page parts ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h2 { font-family: var(--serif); font-size: 1.65rem; color: var(--navy); display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.page-head p { margin: .25rem 0 0; max-width: 70ch; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.back { display: inline-block; margin-bottom: .6rem; color: var(--muted); text-decoration: none; font-size: .88rem; }
.back:hover { color: var(--navy); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1.25rem; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .9rem 1.25rem; border-bottom: 1px solid var(--line-soft); }
.card-head h3 { font-size: .95rem; font-weight: 600; }
.card-head a { font-size: .85rem; text-decoration: none; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25rem; }
.grid-2.wide-left { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.grid-2 > * { min-width: 0; }
.grid-2 { align-items: start; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpis.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi { display: flex; flex-direction: column; gap: .15rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); text-decoration: none; color: inherit; }
a.kpi:hover { border-color: var(--gold-light); }
.kpi-label { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.kpi-val { font-size: 1.6rem; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.kpi-val.sm { font-size: 1.2rem; padding: .2rem 0; }
.kpi-val.warn { color: var(--amber); }
.kpi-sub { font-size: .8rem; color: var(--muted); }

/* ---------- tables ---------- */
.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; padding: .85rem 1.25rem; border-bottom: 1px solid var(--line-soft); }
.toolbar input { flex: 1 1 260px; width: auto; }
.toolbar select { width: auto; flex: 0 0 auto; }
.toolbar .count { margin-left: auto; color: var(--muted); font-size: .85rem; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: .65rem 1.25rem; background: #FAF7F2; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: .7rem 1.25rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl td.mono { font-size: .82rem; color: var(--ink-soft); }
.row-go { color: #FCA311; font-size: 1.3rem; line-height: 1; }
.row-link:hover .row-go { color: var(--gold); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .sub { font-size: .8rem; color: var(--muted); margin-top: 1px; }
.tbl .actions { text-align: right; white-space: nowrap; }
.row-link { cursor: pointer; }
.row-link:hover td { background: var(--hover); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sorted { color: var(--navy); }
th.sorted[data-dir=asc]::after { content: ' ▲'; font-size: .6rem; }
th.sorted[data-dir=desc]::after { content: ' ▼'; font-size: .6rem; }
.pager { display: flex; justify-content: center; align-items: center; gap: 1rem; padding: .8rem; color: var(--muted); font-size: .88rem; }
.pager:empty { display: none; }
.bar { display: inline-block; width: 90px; height: 6px; background: var(--slate-bg); border-radius: 3px; overflow: hidden; vertical-align: middle; }
.bar span { display: block; height: 100%; background: var(--gold); }

.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .74rem; font-weight: 600; white-space: nowrap; vertical-align: middle; }
.tone-slate { background: var(--slate-bg); color: var(--ink-soft); }
.tone-blue { background: var(--blue-bg); color: var(--blue); }
.tone-gold { background: var(--amber-bg); color: var(--amber); }
.tone-green { background: var(--green-bg); color: var(--green); }
.tone-red { background: var(--red-bg); color: var(--red); }
.page-head h2 .badge { font-family: var(--font); font-size: .78rem; }

.tabs { display: flex; gap: .25rem; margin-bottom: 1rem; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; padding: .6rem .85rem; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--navy); border-bottom-color: var(--gold); }
.tab-n { display: inline-block; min-width: 1.4em; padding: 0 .35rem; border-radius: 999px; background: var(--slate-bg); font-size: .72rem; text-align: center; margin-left: .2rem; }

/* ---------- detail bits ---------- */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: .55rem 1.25rem; margin: 0; padding: 1rem 1.25rem 0; }
.dl dt { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding-top: .15rem; }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.card > .fine { padding: 0 1.25rem 1rem; }
.dl.creds { padding: .75rem 0; }

.note-form { padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: .5rem; align-items: flex-end; border-bottom: 1px solid var(--line-soft); }
.notes { list-style: none; margin: 0; padding: 0; }
.notes li { padding: .85rem 1.25rem; border-bottom: 1px solid var(--line-soft); }
.notes li:last-child { border-bottom: 0; }
.note-meta { font-size: .8rem; color: var(--muted); margin-bottom: .2rem; }
.note-meta strong { color: var(--ink-soft); }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; }

.feed { list-style: none; margin: 0; padding: .4rem 0; }
.feed li { padding: .55rem 1.25rem; display: flex; flex-wrap: wrap; gap: .35rem; align-items: baseline; }
.feed li a { font-size: .82rem; }
.feed-who { font-weight: 600; }
.feed-when { margin-left: auto; font-size: .78rem; color: var(--muted); white-space: nowrap; }
.feed-day { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: #FAF7F2; border-block: 1px solid var(--line-soft); }

.empty { text-align: center; padding: 2.5rem 1rem; }
.empty h3 { font-size: 1rem; margin-bottom: .3rem; }
.empty p { color: var(--muted); margin: 0 0 1rem; }
.loading { display: flex; align-items: center; justify-content: center; gap: .6rem; padding: 3rem; color: var(--muted); }
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; }
.alert-error { background: var(--red-bg); color: var(--red); }
.alert-info { background: var(--gold-soft); color: #5A3A00; }
.code { background: var(--navy-deep); color: #ECE7DE; padding: .75rem 1rem; border-radius: var(--radius-sm); font: .8rem/1.6 var(--mono); overflow-x: auto; white-space: pre; }

/* ---------- order editor ---------- */
.typeahead { position: relative; }
.cust-card { margin-top: .9rem; }
.cust-sum { display: flex; flex-direction: column; gap: .1rem; padding: .8rem 1rem; background: var(--hover); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }
.lines td { padding: .45rem .6rem; vertical-align: middle; }
.lines th { padding: .55rem .6rem; }
.lines input { padding: .4rem .5rem; }
.in-sku { width: 7.5rem; } .in-name { min-width: 16rem; } .in-unit { width: 7.5rem; } .in-num { width: 6rem; text-align: right; }
.totals { display: flex; justify-content: flex-end; align-items: flex-start; gap: 1.5rem; flex-wrap: wrap; padding: 1rem 1.25rem; border-top: 1px solid var(--line-soft); }
.totals .rate { display: inline-flex; align-items: center; gap: .4rem; }
.totals .rate input { width: 5.5rem; padding: .35rem .5rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.totals dl { display: grid; grid-template-columns: auto 8rem; gap: .3rem 1.25rem; margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; }
.totals .grand { font-weight: 700; font-size: 1.1rem; color: var(--navy); }

.more { position: relative; }
.more-pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: .35rem; z-index: 30; }
.more-pop a, .more-pop button { display: block; width: 100%; text-align: left; padding: .5rem .65rem; border-radius: var(--radius-sm); background: none; border: 0; cursor: pointer; color: var(--ink); text-decoration: none; }
.more-pop a:hover, .more-pop button:hover { background: var(--hover); }
.more-pop .danger { color: var(--red); }

/* ---------- printable quote / sales order ----------
   Same layout as the customer PO printout (css/styles.css .po-doc).
   On screen it shows as a paper preview. */
.po-doc { font: 9.5pt/1.45 'Plus Jakarta Sans', 'Segoe UI', Arial, sans-serif; color: #000; background: #fff; max-width: 7.3in; margin: 0 auto; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.po-doc * { color: #000; }
.po-doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24pt; padding-bottom: 12pt; border-bottom: 2.5pt solid #000; }
.po-doc-logo { width: 2.7in; height: auto; display: block; }
.po-doc-title { text-align: right; }
.po-doc-title h1 { font-size: 20pt; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; margin: 0 0 6pt; line-height: 1; }
.po-doc-meta { border-collapse: collapse; margin-left: auto; font-size: 8.5pt; }
.po-doc-meta th { text-align: right; font-weight: 500; color: #444; padding: 1.5pt 10pt 1.5pt 0; text-transform: uppercase; letter-spacing: .06em; font-size: 7.5pt; }
.po-doc-meta td { text-align: right; font-weight: 700; padding: 1.5pt 0; }
.po-doc-parties { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10pt; margin: 14pt 0; }
.po-doc-box { border: 1pt solid #000; break-inside: avoid; }
.po-doc-box-h { background: #e9e9e9; border-bottom: 1pt solid #000; padding: 3pt 7pt; font-size: 7.5pt; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.po-doc-box-b { padding: 6pt 7pt 7pt; min-height: 52pt; }
.po-doc-lines { width: 100%; border-collapse: collapse; font-size: 9pt; }
.po-doc-lines thead { display: table-header-group; }
.po-doc-lines th { background: #000; color: #fff !important; text-align: left; font-size: 7.5pt; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 5pt 6pt; }
.po-doc-lines td { padding: 6pt; border-bottom: .75pt solid #bbb; vertical-align: top; }
.po-doc-lines tbody tr { break-inside: avoid; }
.po-doc-lines tbody tr:nth-child(even) td { background: #f3f3f3; }
.po-doc-lines .c-n { width: 18pt; text-align: center; color: #555; }
.po-doc-lines .c-item { width: 72pt; font-family: 'JetBrains Mono', Consolas, monospace; font-size: 8.5pt; }
.po-doc-lines .c-qty { width: 34pt; text-align: right; font-weight: 700; }
.po-doc-lines .c-unit { width: 70pt; }
.po-doc-lines .c-money { width: 64pt; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.po-doc-note { font-size: 8pt; font-style: italic; color: #333; margin-top: 2pt; }
.po-doc-tag { display: inline-block; border: .75pt solid #000; font-size: 6.5pt; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 0 3pt; margin-left: 3pt; vertical-align: 1pt; }
.po-doc-bottom { display: grid; grid-template-columns: 1fr 2.6in; gap: 18pt; margin-top: 12pt; break-inside: avoid; }
.po-doc-terms { font-size: 7.5pt; color: #333; margin: 8pt 0 0; line-height: 1.5; }
.po-doc-notes .po-doc-box-b { min-height: 0; }
.po-doc-totals { width: 100%; border-collapse: collapse; font-size: 9pt; }
.po-doc-totals th { text-align: left; font-weight: 500; padding: 3pt 0; }
.po-doc-totals td { text-align: right; padding: 3pt 0; font-variant-numeric: tabular-nums; }
.po-doc-totals .grand th, .po-doc-totals .grand td { font-size: 11.5pt; font-weight: 800; border-top: 2pt solid #000; border-bottom: 4pt double #000; padding: 6pt 0; }
.po-doc-sign { display: grid; grid-template-columns: 2fr 1.3fr 1fr; gap: 18pt; margin-top: 34pt; font-size: 7.5pt; text-transform: uppercase; letter-spacing: .08em; color: #444; break-inside: avoid; }
.po-doc-sign span { display: block; border-bottom: 1pt solid #000; height: 22pt; margin-bottom: 3pt; }
.po-doc-foot { margin-top: 22pt; padding-top: 6pt; border-top: .75pt solid #000; font-size: 7.5pt; color: #444; text-align: center; }
.po-doc .po-doc-head { padding-top: 0; }
.po-doc .po-doc-parties, .po-doc .po-doc-bottom { padding-top: 0; padding-bottom: 0; }
.po-doc .po-doc-sign { padding: 0; }
.po-doc .po-doc-foot { padding-bottom: 0; }
.po-doc .po-doc-lines td { padding-top: 5pt; padding-bottom: 5pt; }
.po-doc .po-doc-parties { margin: 12pt 0; }
.po-doc .po-doc-sign { margin-top: 22pt; }
.po-doc .po-doc-sign span { height: 18pt; }
.po-doc .po-doc-foot { margin-top: 14pt; }
.po-doc { padding: .55in .6in; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1.25rem; max-width: 8.5in; }
@media screen and (max-width: 860px) { .po-doc { padding: 1.25rem; font-size: 9pt; } .po-doc-parties, .po-doc-bottom { grid-template-columns: 1fr !important; } .po-doc-head { flex-direction: column; } .po-doc-title { text-align: left; } .po-doc-meta { margin-left: 0; } }

/* Invoice extras */
.doc-switch { display: inline-flex; gap: 2px; padding: 3px; background: var(--slate-bg); border-radius: 999px; margin-bottom: .75rem; }
.doc-switch button { border: 0; background: none; padding: .4rem .9rem; border-radius: 999px; font-weight: 600; color: var(--muted); cursor: pointer; }
.doc-switch button.active { background: var(--surface); color: var(--navy); box-shadow: var(--shadow); }
.po-doc-co { font-size: 8.5pt; line-height: 1.5; margin-top: 6pt; color: #000; }
.po-doc-co .sep { background: #000; }
.inv-parties { grid-template-columns: 1fr 1fr !important; }
.inv-facts { width: 100%; border-collapse: collapse; margin: 0 0 10pt; font-size: 8.5pt; table-layout: fixed; }
.inv-facts th { background: #e9e9e9; border: 1pt solid #000; padding: 3pt 5pt; font-size: 7pt; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; text-align: center; }
.inv-facts td { border: 1pt solid #000; padding: 4pt 5pt; text-align: center; font-weight: 600; }
.po-doc-invoice .po-doc-lines .c-qty { text-align: center; width: 36pt; }
.po-doc-invoice .po-doc-lines .c-tax { width: 26pt; text-align: center; font-weight: 700; }
.po-doc-invoice .po-doc-lines td { padding-top: 4pt; padding-bottom: 4pt; }
.po-doc-invoice .po-doc-parties { margin: 10pt 0; }
.po-doc-invoice .po-doc-box-b { min-height: 0; }
.po-doc-invoice .po-doc-bottom { margin-top: 10pt; }
.po-doc-invoice .po-doc-foot { margin-top: 12pt; }

/* ---------- modal & toast ---------- */
.o-modal-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(20, 33, 61, .5); display: grid; place-items: center; padding: 1rem; animation: fade .15s; }
.o-modal { width: 100%; max-width: 460px; max-height: calc(100vh - 2rem); overflow-y: auto; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); }
.o-modal.wide { max-width: 720px; }
.o-modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line-soft); }
.o-modal-head h3 { font-size: 1.05rem; }
.o-modal-body { padding: 1.25rem; }
.o-modal-body > p:first-child { margin-top: 0; }
.o-modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; flex-wrap: wrap; }
.o-modal-actions.split { justify-content: space-between; }
.o-modal-actions.split > div { display: flex; gap: .5rem; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }

#toasts { position: fixed; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); z-index: 200; display: flex; flex-direction: column; gap: .5rem; }
.toast { background: var(--navy-deep); color: #fff; padding: .7rem 1rem; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: .9rem; transition: opacity .4s, transform .4s; max-width: 340px; }
.toast-error { background: var(--red); }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-2.wide-left { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%); transition: transform .2s; padding-top: env(safe-area-inset-top, 0px); }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .scrim.show { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(20, 33, 61, .45); }
  .menu-btn { display: inline-block; }
  .topbar-o { padding: .6rem 1rem; padding-top: calc(.6rem + env(safe-area-inset-top, 0px)); gap: .6rem; flex-wrap: wrap; }
  .global-search { order: 5; flex-basis: 100%; max-width: none; }
  .new-btn { margin-left: auto; }
  .user-menu { margin-left: auto; }
  .user-name { display: none; }
  .view { padding: 1.1rem 1rem 3rem; }
}
@media (max-width: 560px) {
  .kpis, .kpis.kpis-3 { grid-template-columns: 1fr 1fr; }
  .kpi-val { font-size: 1.3rem; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .tbl th, .tbl td { padding-left: .8rem; padding-right: .8rem; }
  .toolbar { padding: .75rem .8rem; }
  .page-head h2 { font-size: 1.35rem; }
}

/* ---------- print: only the quote / order document ---------- */
@media print {
  @page { size: letter; margin: 0.55in 0.6in; }
  body { background: #fff; }
  .sidebar, .topbar-o, .no-print, #toasts, .scrim { display: none !important; }
  .shell, .main { display: block; }
  .view { padding: 0; max-width: none; }
  .po-doc { border: 0; box-shadow: none; padding: 0; margin: 0 auto; border-radius: 0; }
}

/* PO requests */
.nav-badge { margin-left: auto; min-width: 20px; padding: 0 .4rem; border-radius: 999px; background: var(--gold-light); color: var(--navy-deep); font-size: .72rem; font-weight: 800; text-align: center; line-height: 20px; }
.po-alert { display: block; text-decoration: none; }
.po-alert:hover { filter: brightness(.98); }

/* Thin vertical separator (replaces "·" dots) */
.sep { display: inline-block; width: 1px; height: .85em; background: currentColor; opacity: .3; margin: 0 .5em; vertical-align: -0.08em; }

/* ---------- Scrollbars ----------
   Inner scroll areas scroll without a visible bar; the page itself keeps a
   slim, low-contrast bar so mouse users can still see where they are. */
html { scrollbar-width: thin; scrollbar-color: rgba(20, 33, 61, .25) transparent; }
html::-webkit-scrollbar { width: 8px; height: 8px; }
html::-webkit-scrollbar-track { background: transparent; }
html::-webkit-scrollbar-thumb { background: rgba(20, 33, 61, .22); border-radius: 8px; }
html::-webkit-scrollbar-thumb:hover { background: rgba(20, 33, 61, .4); }
body *:not(html) { scrollbar-width: none; }
body *::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* Messages */
.msg-list { list-style: none; margin: 0; padding: 0; }
.msg { padding: 1rem 1.25rem; border-bottom: 1px solid var(--line-soft); }
.msg:last-child { border-bottom: 0; }
.msg.done { opacity: .65; }
.msg-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.msg-when { margin-left: auto; font-size: .8rem; color: var(--muted); }
.msg-body { margin: .5rem 0; white-space: normal; overflow-wrap: anywhere; }
.msg-foot { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; font-size: .88rem; }
.msg-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }

/* Dropdowns: one look everywhere */
select {
  -webkit-appearance: none; appearance: none;
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2314213D' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center; background-size: 12px 8px;
  padding-right: 2.1rem !important; cursor: pointer;
}
select:hover { border-color: #9AA6BF; }
body select:not([multiple]) { -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2314213D' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .7rem center; background-size: 12px 8px; padding-right: 2.1rem; }

/* Requested-item approvals */
.approval-row td { padding-top: 0 !important; border-top: 0; }
.approval-row .btn-o { margin-right: .35rem; }
.approval-row .link-btn { margin-left: .5rem; }
.row-declined td { opacity: .55; text-decoration: line-through; }
.row-declined td .badge { text-decoration: none; }
.approval-alert { margin: 0 1.25rem 1rem; }

/* Blanket POs */
.blanket-strip { border: 1px solid var(--line); border-left: 4px solid var(--green); border-radius: var(--radius-sm); padding: .65rem .85rem; margin-bottom: 1rem; background: var(--surface); }
.blanket-strip.tone-warn { border-left-color: var(--gold-light); background: #FFFBF2; }
.blanket-strip.tone-over { border-left-color: var(--red); background: #FFF6F6; }
.bs-top { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: baseline; font-size: .88rem; }
.bs-left { font-weight: 700; }
.tone-over .bs-left, .tone-over .bs-after b { color: var(--red); }
.bs-after { color: var(--muted); }
.bs-bar { height: 6px; background: var(--slate-bg); border-radius: 999px; overflow: hidden; margin-top: .45rem; }
.bs-bar span { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.tone-warn .bs-bar span, .bs-bar.warn span { background: var(--gold-light); }
.tone-over .bs-bar span, .bs-bar.over span { background: var(--red); }
.bs-note { font-size: .8rem; color: var(--muted); margin-top: .35rem; }
.tbl .neg { color: var(--red); }
tr.dim td { opacity: .55; }
