:root {
  --ink: #14181f;
  --soft: #3d4654;
  --muted: #667085;
  --line: #e6e8ee;
  --paper: #eef1f5;
  --card: #fff;
  --teal: #17657c;
  --teal-2: #124f61;
  --brand: #3cb0c9;
  --bad: #c4322c;
  --ok: #0f7a45;
  --warn: #8a5a08;
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--sans); background: var(--paper); color: var(--ink); line-height: 1.45; }
a { color: var(--teal); }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
.hdr { background: #fff; min-height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; border-bottom: 1px solid var(--line); position: relative; gap: 16px; }
.hdr::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--brand); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand img { height: 48px; width: auto; }
.brand strong { display: block; font-size: 15px; }
.brand small, .muted, .crumb { color: var(--muted); font-size: 13px; }
.hdr-r, .row-actions, .inline, .page-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.who { font-size: 13px; color: var(--soft); }
.nav { background: #fff; display: flex; gap: 4px; padding: 0 14px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.nav a { padding: 12px 12px 10px; text-decoration: none; color: var(--muted); font-weight: 650; font-size: 14px; border-bottom: 2px solid transparent; }
.nav a.on, .nav a:hover { color: var(--ink); border-bottom-color: var(--brand); }
.banner { background: #fff5e4; color: var(--warn); padding: 8px 22px; font-size: 13px; font-weight: 650; }
main { width: 100%; max-width: none; margin: 0; padding: 16px 20px 40px; }
h1 { font-size: 26px; margin: 0; letter-spacing: -0.03em; }
h2 { font-size: 16px; margin: 0 0 10px; }
.page-head { justify-content: space-between; margin-bottom: 14px; }
.card, .login-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 12px 0; }
.login-card { max-width: 420px; margin: 48px auto; }
.login-card img { height: 42px; }
.btn { border: 1px solid #d5d9e2; background: #fff; border-radius: 9px; padding: 8px 12px; font-weight: 650; cursor: pointer; text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; }
.btn.primary { background: var(--teal); color: #fff; border-color: transparent; }
.btn.primary:hover { background: var(--teal-2); }
.btn.danger { color: var(--bad); border-color: #f0c4c2; background: #fff; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.55; cursor: default; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 650; color: var(--soft); }
label.check { flex-direction: row; align-items: center; gap: 8px; }
input, select, textarea { border: 1px solid #d5d9e2; border-radius: 9px; padding: 8px 10px; background: #fff; font-weight: 450; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(23, 101, 124, 0.14); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.person { display: grid; grid-template-columns: minmax(180px, 1.4fr) 160px auto auto; gap: 12px; align-items: end; padding: 12px 0; border-top: 1px solid var(--line); }
.person input { width: 100%; }
.grid { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; }
.grid th { background: var(--brand); color: #fff; text-align: left; font-size: 13px; padding: 8px; }
.grid td { border-bottom: 1px solid var(--line); padding: 6px 8px; vertical-align: middle; }
.grid input, .grid select { width: 100%; }
.num, .grid td.num, .grid th.num { text-align: right; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.pill { display: inline-block; border-radius: 999px; padding: 2px 8px; font-size: 12px; font-weight: 700; background: #eef1f5; text-transform: capitalize; }
.pill.pending { background: #fff5e4; color: var(--warn); }
.pill.approved, .pill.won, .pill.sent { background: #e5f6ed; color: var(--ok); }
.pill.stale { background: #fff5e4; color: var(--warn); margin-left: 6px; }
.flash { padding: 10px 12px; border-radius: 10px; margin-bottom: 10px; }
.flash.ok { background: #e5f6ed; color: var(--ok); }
.flash.bad, .warn { background: #fdeceb; color: var(--bad); padding: 10px 12px; border-radius: 10px; }
.split { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 12px; }
.totals { display: grid; gap: 4px; margin: 0; }
.totals div { display: flex; justify-content: space-between; gap: 12px; }
.totals dt { color: var(--soft); }
.totals dd { margin: 0; font-variant-numeric: tabular-nums; }
.totals div:nth-last-child(2) dd, .totals div:nth-last-child(2) dt { font-weight: 750; }
.empty { color: var(--muted); }
.plain { list-style: none; padding: 0; }
.plain li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.search { display: flex; gap: 8px; margin: 12px 0; }
.search input { flex: 1; }
.hit { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.hidden { display: none; }
.modal-back { position: fixed; inset: 0; background: rgba(20, 24, 31, 0.45); z-index: 40; display: flex; justify-content: center; align-items: flex-start; padding: 72px 16px 16px; }
.modal-back.hidden { display: none; }
.modal { background: #fff; width: min(460px, 100%); border-radius: 14px; padding: 16px 18px; box-shadow: 0 18px 50px rgba(20, 24, 31, 0.22); display: flex; flex-direction: column; gap: 10px; }
.add-line { display: grid; grid-template-columns: minmax(180px, 2fr) minmax(120px, 1fr) minmax(150px, 1fr) 110px 110px 72px auto; gap: 8px; align-items: end; }
.link-line { display: grid; grid-template-columns: minmax(240px, 1fr) auto; gap: 8px; margin-top: 8px; }
th.sort { cursor: pointer; user-select: none; }
.tabs { display: flex; gap: 4px; margin: -4px 0 12px; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: 8px 12px; font-weight: 650; color: var(--muted); cursor: pointer; }
.tabs button.on, .tabs button:hover { color: var(--ink); border-bottom-color: var(--brand); }
.delete-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 10px; position: sticky; top: 0; z-index: 2; background: var(--paper); padding: 8px 0; }
.delete-bar p { margin: 0; }
.grid th.check, .grid td.check { width: 42px; text-align: center; }
.grid th.check input, .grid td.check input { width: auto; accent-color: var(--bad); }
.grid tr.picked td { background: #fdeceb; }
.lines td:nth-child(5), .lines td:nth-child(6), .lines td:nth-child(7) { width: 90px; }
.lines td:nth-child(9) { width: 180px; }
.grid td.code { white-space: nowrap; font-variant-numeric: tabular-nums; }
#product-table { table-layout: fixed; }
#product-table col.col-gou { width: 7.5rem; }
#product-table col.col-part { width: 11rem; }
#product-table col.col-supplier { width: 12rem; }
#product-table col.col-money { width: 5rem; }
#product-table col.col-actions { width: 13.5rem; }
#product-table td.row-actions { white-space: nowrap; flex-wrap: nowrap; }
#product-table td.row-actions .btn { padding: 6px 8px; }
#product-table input[data-k="cost"],
#product-table input[data-k="sell"] { padding-left: 6px; padding-right: 2px; }
.tiny { width: 80px; }
#package-lines td:nth-child(3) { width: 16rem; }
#package-lines td:nth-child(4), #package-lines th:nth-child(4) { width: 90px; }
#package-lines td:last-child { width: 110px; white-space: nowrap; }
.danger-zone { margin-top: 24px; }
.lines td:last-child { white-space: nowrap; }
.lines td.row-actions .btn { padding: 6px 8px; }
.line-link, input.url { display: block; font-size: 12px; font-weight: 450; margin-top: 4px; }
input.url { width: 100%; }
.picker-list { max-height: 18rem; overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; margin-top: 8px; }
.picker-row { display: block; width: 100%; text-align: left; background: #fff; border: none; border-bottom: 1px solid var(--line); padding: 8px 12px; cursor: pointer; font-weight: 550; }
.picker-row:hover, .picker-row.on { background: #f0f7ff; }
.picker-row.up { background: #f6f7f9; font-weight: 700; }
.picker-row.doc { font-weight: 450; }
.picker-note { padding: 12px; color: var(--muted); }
#save-state { margin-left: 8px; }
@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
  .hdr { padding: 10px 12px; }
  .add-line { grid-template-columns: 1fr 1fr; }
  .person { grid-template-columns: 1fr; }
}
