:root {
  --ink: #1c1e21;
  --ink-2: #4a4d52;
  --ink-3: #85888d;
  --paper: #f6f4ef;
  --card: #ffffff;
  --line: #e4e1d9;
  --line-2: #d3cfc4;
  --glow: #f2c46d;
  --glow-soft: #fbecc9;
  --accent: #1c1e21;
  --ok: #2f7a4a;
  --ok-bg: #e6f2ea;
  --warn: #9a5b00;
  --warn-bg: #fdf1dc;
  --bad: #a3322a;
  --bad-bg: #fbe7e5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(28,30,33,.05), 0 6px 24px -12px rgba(28,30,33,.18);
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: inherit; text-underline-offset: 2px; }
h1 { font-size: 28px; line-height: 1.15; letter-spacing: -.01em; margin: 0 0 6px; font-weight: 650; }
h2 { font-size: 15px; margin: 0 0 14px; font-weight: 650; display: flex; align-items: center; gap: 10px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
body.public .wrap { max-width: 880px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.small { font-size: 12.5px; color: var(--ink-3); }
.block { display: block; }
.hint { color: var(--ink-2); margin: 0 0 16px; }
.opt { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.mono { font-family: var(--mono); font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.prewrap { white-space: pre-wrap; margin: 0; }
.inline { display: inline; }

/* Top bar */
.topbar { background: var(--ink); color: #fff; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-name { font-weight: 700; letter-spacing: .18em; font-size: 13px; }
.brand-sub { color: #b9bbbf; font-size: 13px; padding-left: 12px; border-left: 1px solid #3b3e43; }
.halo { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--glow);
  box-shadow: 0 0 10px 1px rgba(242,196,109,.55), inset 0 0 6px rgba(242,196,109,.5); flex: none; }
.halo.big { width: 64px; height: 64px; border-width: 3px; display: block; margin: 0 auto 18px;
  box-shadow: 0 0 34px 4px rgba(242,196,109,.55), inset 0 0 18px rgba(242,196,109,.45); }
.topnav { display: flex; gap: 18px; align-items: center; font-size: 14px; }
.topnav a { text-decoration: none; color: #e6e7e9; }
.topnav a:hover { color: #fff; }
.topnav .quiet { color: #9fa2a7; }
.linklike { background: none; border: 0; color: #9fa2a7; font: inherit; cursor: pointer; padding: 0; }
.linklike:hover { color: #fff; }

main { padding: 28px 20px 40px; }
.foot { display: flex; justify-content: space-between; gap: 12px 32px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--ink-3); padding-top: 18px; padding-bottom: 32px; border-top: 1px solid var(--line); }
.foot-hq, .foot-meta { display: flex; flex-direction: column; gap: 3px; }
.foot-hq strong { color: var(--ink-2); font-weight: 650; }
.foot-hq a { color: var(--ink-2); text-decoration: none; }
.foot-hq a:hover { text-decoration: underline; }
.foot-meta { text-align: right; justify-content: flex-end; }

/* Public notices */
.notice { background: var(--glow-soft); border: 1px solid #ecd39a; color: #6b4a00; border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 18px; font-size: 14.5px; }
.card.closed { text-align: center; padding: 34px 22px; }
.card.closed h2 { justify-content: center; font-size: 18px; }
.card.closed a { font-weight: 650; }

/* Admin */
.admin-nav { display: flex; gap: 4px; flex-wrap: wrap; margin: -8px 0 22px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.admin-nav a { text-decoration: none; padding: 7px 12px; border-radius: 7px; color: var(--ink-2); font-size: 14px; font-weight: 550; }
.admin-nav a.on { background: var(--ink); color: #fff; }
.admin-nav a:not(.on):hover { background: #ebe8e1; }
.actions.tight { margin-top: 0; }
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { display: flex; flex-direction: column; gap: 2px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); text-decoration: none; }
a.kpi:hover { border-color: var(--ink); }
.kpi-n { font-size: 28px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-l { font-size: 13px; font-weight: 650; color: var(--ink-2); }
.kpi-s { font-size: 12px; color: var(--ink-3); }
.kpi.alert { border-color: #e6b8b3; background: #fffaf9; }
.kpi.alert .kpi-n { color: var(--bad); }
.chart { width: 100%; height: auto; display: block; margin-bottom: 6px; }
.chart .axis { stroke: var(--line-2); stroke-width: 1; }
.chart .bar { fill: #c9c4b7; }
.chart .bar.today { fill: var(--glow); }
.chart g:hover .bar { fill: var(--ink); }
.chart .val { font-size: 11px; font-weight: 650; fill: var(--ink-2); text-anchor: middle; }
.chart .lbl { font-size: 10px; fill: var(--ink-3); text-anchor: middle; }
.card h2 .more { margin-left: auto; font-weight: 500; text-decoration: none; }
.card h2 .more:hover { color: var(--ink); }
.grid-table.compact td, .grid-table.compact th { padding: 8px 12px; font-size: 13.5px; }
.late { color: var(--bad); font-weight: 600; }
.filters { display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: flex-end; padding: 16px 18px; }
.filters label { flex: 0 1 160px; }
.filters label.grow { flex: 1 1 240px; }
.filters select, .filters input { padding: 7px 9px; margin-top: 4px; }
.filter-btns { display: flex; gap: 8px; }
.filter-btns .btn { padding: 8px 14px; }
.bulkbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 12px;
  background: var(--ink); color: #fff; border-radius: var(--radius); position: sticky; top: 8px; z-index: 5; }
.bulkbar select, .bulkbar input { width: auto; min-width: 220px; padding: 6px 9px; }
.bulkbar .btn.ghost { background: transparent; color: #fff; border-color: #55585e; }
.bulkbar .btn.ghost:hover:not(:disabled) { border-color: #fff; }
.bulkbar .btn.primary { background: var(--glow); color: var(--ink); }
.bulkbar .btn:disabled { opacity: .45; cursor: default; }
.bulk-count { font-size: 14px; color: #c9cbcf; margin-right: 4px; }
.bulk-count strong { color: #fff; }
.c-sel { width: 36px; padding-right: 0 !important; }
.c-sel input { width: 16px; height: 16px; cursor: pointer; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 8px; }
.row-menu { display: inline-block; position: relative; text-align: left; }
.row-menu summary { list-style: none; }
.row-menu summary::-webkit-details-marker { display: none; }
.row-menu[open] summary { border-color: var(--ink); }
.row-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; width: 280px; background: var(--card);
  border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: 0 12px 32px -12px rgba(0,0,0,.35); padding: 16px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 12px; margin-top: 4px; border-top: 1px solid var(--line); }
.settings .card h2 .opt { margin-left: 0; }
.settings textarea { min-height: 72px; }
.settings .grid { margin-top: 12px; }

/* Hero */
.hero { padding: 12px 0 22px; }
.hero h1 { font-size: 34px; }
.lede { font-size: 16.5px; color: var(--ink-2); max-width: 640px; margin: 8px 0 0; }
.hero.received { text-align: center; padding-top: 30px; }
.hero.received .lede { margin: 8px auto 0; }
.refbox { display: inline-flex; flex-direction: column; gap: 4px; margin-top: 22px; padding: 16px 28px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.ref { font-family: var(--mono); font-size: 26px; letter-spacing: .04em; }

/* Cards & forms */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow-x: auto; }
.card .pad { padding: 18px 20px 0; }
.step { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink); color: var(--glow); font-size: 12px; font-weight: 700; }
.grid { display: grid; gap: 14px 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-form { grid-column: 1 / -1; }
.g3 .span-form { grid-column: span 2; }
.g3 .span-form:last-child { grid-column: span 1; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); }
label > input:not([type=checkbox]):not([type=radio]):not([type=file]), label > textarea, label > select { display: block; margin-top: 5px; }
.mode-card, .drop { display: flex; flex-direction: column; }
label b { color: var(--bad); font-weight: 600; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
input, textarea, select { font: inherit; font-weight: 400; color: var(--ink); background: #fff;
  border: 1px solid var(--line-2); border-radius: 7px; padding: 9px 11px; width: 100%; min-width: 0; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--ink); }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--glow); outline-offset: 0; border-color: #c99a3e; }
textarea { resize: vertical; }
.stack { display: flex; flex-direction: column; gap: 12px; margin-bottom: 10px; }
.auth { max-width: 420px; margin: 30px auto; }
.auth form { display: flex; flex-direction: column; gap: 14px; }
.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* Mode switch */
.mode-switch { border: 0; padding: 0; margin: 0 0 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mode-card { position: relative; flex-direction: column; gap: 2px; cursor: pointer; padding: 16px 18px 16px 46px;
  background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.mode-card input { position: absolute; left: 18px; top: 19px; }
.mode-card:has(input:checked) { border-color: var(--ink); box-shadow: 0 0 0 3px var(--glow-soft), var(--shadow); }
.mode-title { font-size: 15px; color: var(--ink); font-weight: 650; }
.mode-desc { font-weight: 400; color: var(--ink-3); }

.order-form.mode-upload .form-only,
.order-form.mode-upload .form-only-inline { display: none; }

/* Upload */
.upload-zone { margin-top: 18px; }
.drop { position: relative; align-items: center; text-align: center; gap: 4px; padding: 26px 16px;
  border: 1.5px dashed var(--line-2); border-radius: var(--radius); background: #fbfaf7; cursor: pointer; transition: .15s; }
.drop:hover, .drop.over { border-color: #c99a3e; background: var(--glow-soft); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-icon { width: 30px; height: 36px; border: 2px solid var(--ink-2); border-radius: 3px 10px 3px 3px; margin-bottom: 6px; position: relative; }
.drop-icon::after { content: "PDF"; position: absolute; bottom: 4px; left: 0; right: 0; font-size: 8px; font-weight: 800; color: var(--ink-2); }
.drop-text { font-weight: 400; color: var(--ink-2); font-size: 14.5px; }
.drop-text strong { color: var(--ink); }
.drop-hint { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.file-list { list-style: none; margin: 10px 0 0; padding: 0; }
.file-list li { display: flex; justify-content: space-between; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: 7px; margin-top: 6px; font-size: 13.5px; background: #fff; }
.file-list li.bad { border-color: var(--bad); color: var(--bad); background: var(--bad-bg); }

/* Line items */
.lines-wrap { overflow-x: auto; margin: 0 -4px 12px; }
.lines { width: 100%; border-collapse: collapse; min-width: 640px; }
.lines th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3);
  text-align: left; font-weight: 600; padding: 0 4px 6px; }
.lines td { padding: 3px 4px; vertical-align: middle; }
.lines input { padding: 7px 8px; }
.c-n { width: 28px; color: var(--ink-3); font-size: 12.5px; text-align: center; }
.c-part { width: 150px; } .c-qty { width: 72px; } .c-price { width: 104px; } .c-ext { width: 104px; text-align: right; font-family: var(--mono); font-size: 13px; }
.c-x { width: 30px; }
.lines tfoot td { padding-top: 10px; font-weight: 650; }
.rm { border: 0; background: none; font-size: 20px; color: var(--ink-3); cursor: pointer; line-height: 1; }
.rm:hover { color: var(--bad); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600;
  font-size: 14px; border-radius: 8px; padding: 10px 16px; cursor: pointer; text-decoration: none; border: 1.5px solid transparent;
  white-space: nowrap; }
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover { background: #000; box-shadow: 0 0 0 3px var(--glow-soft); }
.btn.primary:disabled { opacity: .45; cursor: default; box-shadow: none; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.big { padding: 14px 28px; font-size: 16px; }
.btn.wide { width: 100%; }
.submit-bar { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 6px 2px 10px; }
.submit-bar .small { max-width: 520px; margin: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* Messages */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--bad-bg); color: var(--bad); }
.errors { background: var(--bad-bg); color: var(--bad); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 18px; }
.errors ul { margin: 6px 0 0; padding-left: 18px; }
.errors .small { color: var(--bad); margin: 8px 0 0; }
.warn { background: var(--warn-bg); color: var(--warn); padding: 10px 12px; border-radius: 7px; font-size: 13.5px; margin: 12px 0 0; }
.pw { font-family: var(--mono); background: #fff; padding: 2px 8px; border-radius: 5px; color: var(--ink); font-size: 15px; }

/* Portal */
.portal-head, .detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 18px; }
.portal-head form { text-align: right; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { text-decoration: none; padding: 7px 12px; border-radius: 7px; color: var(--ink-2); font-size: 14px; font-weight: 550; }
.tabs a.on { background: var(--ink); color: #fff; }
.tabs a:not(.on):hover { background: #ebe8e1; }
.count { font-size: 11.5px; opacity: .7; margin-left: 2px; }
.search { display: flex; gap: 8px; align-items: center; }
.search input[type=search] { width: 240px; }
.grid-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid-table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3);
  font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--line); background: #fbfaf7; }
.grid-table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid-table tbody tr:last-child td { border-bottom: 0; }
.grid-table tfoot td { font-weight: 650; border-top: 1px solid var(--line); border-bottom: 0; }
.rowlink { cursor: pointer; }
.rowlink:hover td { background: #fcfaf4; }
.rowlink.is-new td:first-child { box-shadow: inset 3px 0 0 var(--glow); }
.rowlink.is-new td:first-child a { font-weight: 650; }
.grid-table a { text-decoration: none; }
.sub, .ref-sm { display: block; font-size: 12px; color: var(--ink-3); }
.ref-sm { font-family: var(--mono); font-size: 11.5px; }
tr.inactive td { color: var(--ink-3); }
.empty { padding: 40px; text-align: center; color: var(--ink-3); }
.status { display: inline-block; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 3px 8px; border-radius: 99px; background: #eee; color: var(--ink-2); }
.s-new { background: var(--glow-soft); color: #8a5a00; }
.s-downloaded { background: #e7edf6; color: #2c4a73; }
.s-entered { background: var(--ok-bg); color: var(--ok); }
.s-void { background: #eee; color: var(--ink-3); text-decoration: line-through; }
.tag { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 5px;
  background: #f0eee8; color: var(--ink-2); margin-left: 4px; font-family: var(--sans); }
.tag.rush { background: var(--bad-bg); color: var(--bad); }
.tag.dup { background: var(--warn-bg); color: var(--warn); }
.tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tags .tag { margin: 0; }
.newbanner { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 12px 18px; border-radius: 99px; box-shadow: 0 0 0 3px var(--glow-soft), var(--shadow); font-size: 14px; }
.newbanner a { color: var(--glow); font-weight: 600; margin-left: 8px; }
.back { display: inline-block; text-decoration: none; color: var(--ink-3); font-size: 14px; margin-bottom: 14px; }
.back:hover { color: var(--ink); }
.po { font-size: 18px; color: var(--ink-2); font-weight: 500; margin-left: 6px; }
.dl-group { display: flex; flex-direction: column; gap: 8px; align-items: stretch; min-width: 260px; }
.dl-row { display: flex; gap: 6px; }
.dl-row .btn { flex: 1; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 8px 12px; margin: 0; font-size: 14px; }
.kv dt { color: var(--ink-3); font-size: 13px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.files { list-style: none; padding: 0; margin: 0; }
.files li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.files li:first-child { border-top: 0; padding-top: 0; }
.files .fname { flex: 1; overflow-wrap: anywhere; }
.files a { font-weight: 600; text-decoration: none; color: #2c4a73; }
.pdf-ico { width: 22px; height: 27px; border: 1.5px solid var(--bad); border-radius: 2px 7px 2px 2px; flex: none; }
.history { list-style: none; padding: 0; margin: 0; font-size: 13.5px; }
.history li { padding: 8px 0; border-top: 1px solid var(--line); }
.history li:first-child { border-top: 0; padding-top: 0; }
details.void { margin-top: 14px; font-size: 13.5px; color: var(--ink-3); }
details.void summary { cursor: pointer; margin-bottom: 10px; }

@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .cols { grid-template-columns: 1fr; }
  .portal-head, .detail-head { flex-direction: column; }
  .portal-head form { text-align: left; }
  .dl-group { min-width: 0; width: 100%; }
}
@media (max-width: 640px) {
  .g2, .g3 { grid-template-columns: 1fr; }
  .g3 .span-form, .g3 .span-form:last-child { grid-column: 1 / -1; }
  .mode-switch { grid-template-columns: 1fr; }
  .hero h1 { font-size: 27px; }
  .submit-bar { flex-direction: column; align-items: stretch; }
  .brand-sub { display: none; }
  .search { width: 100%; } .search input[type=search] { flex: 1; width: auto; }
  .foot { flex-direction: column; }
  .foot-meta { text-align: left; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters label, .filters label.grow { flex: 1 1 100%; }
  .bulkbar select, .bulkbar input { min-width: 0; flex: 1 1 100%; }
  .row-pop { width: min(280px, calc(100vw - 40px)); }
}
@media print {
  .topbar, .foot, .actions, .halo, .admin-nav, .bulkbar, .filters { display: none; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
