:root {
  --bg: #f2f4f6; --panel: #ffffff; --ink: #18212b; --muted: #66727f; --line: #e4e8ec; --line-strong: #cbd3db;
  --accent: #0f7b6c; --accent-deep: #0a5a4e; --accent-ink: #ffffff; --accent-soft: #e2f1ee; --accent-line: #bfe0d9;
  --top: #10282c; --top-2: #16363b; --top-ink: #e9f1ef; --top-muted: #9db6b1;
  --danger: #b3261e; --danger-soft: #fdecea; --warn: #8a5a00; --warn-soft: #fff3d6; --ok: #1f7a3d; --ok-soft: #e2f4e8; --info: #2457c5; --info-soft: #e6edfb;
  --st-draft: #8b96a3; --st-ready: #2f6fde; --st-shipped: #c27a0e; --st-paid: #1f7a3d;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 32, .05), 0 6px 18px rgba(16, 24, 32, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 13px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; background: var(--bg); padding: 1px 5px; border-radius: 4px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 13px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--panel); cursor: pointer; white-space: nowrap; font-weight: 500; transition: border-color .12s, background .12s, box-shadow .12s; }
.btn:hover { border-color: var(--accent); background: #fbfdfc; }
.btn:active { transform: translateY(.5px); }
.btn:focus-visible, .icon:focus-visible, .seg-btn:focus-visible, .ship:focus-visible, .chip-btn:focus-visible, .tb-btn:focus-visible, .co-chip:focus-visible, .lib-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 2px rgba(10, 90, 78, .25); }
.btn.primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--bg); border-color: var(--line-strong); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn.danger { color: var(--danger); }
.btn.armed { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.icon { width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--line-strong); background: #fff; cursor: pointer; }
.icon:hover { border-color: var(--accent); }
.icon:disabled { opacity: .35; cursor: default; }
.icon.danger { color: var(--danger); }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font-weight: 500; padding: 0; }
.link:hover { text-decoration: underline; }

/* segmented control */
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 9px; background: var(--bg); border: 1px solid var(--line); flex-wrap: wrap; }
.seg-btn { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 500; white-space: nowrap; }
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(16, 24, 32, .12); font-weight: 600; }
.seg.dark { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .1); }
.seg.dark .seg-btn { color: var(--top-muted); }
.seg.dark .seg-btn:hover { color: var(--top-ink); }
.seg.dark .seg-btn.active { background: rgba(255, 255, 255, .14); color: #fff; box-shadow: none; }

/* ---------- top bar ---------- */
.topbar { height: 54px; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: linear-gradient(90deg, var(--top), var(--top-2)); color: var(--top-ink); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; letter-spacing: -.01em; color: inherit; text-decoration: none; }
.brand .mark, .auth-brand .mark { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, #3fbfa8, #0f7b6c); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25); position: relative; }
.brand .mark::after, .auth-brand .mark::after { content: ''; position: absolute; left: 6px; top: 6px; width: 10px; height: 10px; border: 2px solid #fff; border-radius: 2px; opacity: .9; }
.co-chip { border: 1px solid rgba(255, 255, 255, .18); background: rgba(255, 255, 255, .06); color: var(--top-ink); border-radius: 999px; padding: 4px 12px; cursor: pointer; font-weight: 500; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.co-chip:hover { background: rgba(255, 255, 255, .12); }
.tb-btn { height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, .14); background: transparent; color: var(--top-ink); cursor: pointer; font-weight: 500; list-style: none; display: inline-flex; align-items: center; }
.tb-btn:hover { background: rgba(255, 255, 255, .1); }
summary.tb-btn::-webkit-details-marker { display: none; }
.saved { color: var(--top-muted); font-size: 12px; }
.saved.bad { color: #ffb4a8; font-weight: 600; }

.menu-wrap { position: relative; }
.menu-wrap > summary { list-style: none; cursor: pointer; }
.menu-wrap > summary::-webkit-details-marker { display: none; }
.menu { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; min-width: 220px; background: #fff; color: var(--ink); border: 1px solid var(--line-strong); border-radius: 10px; padding: 6px; box-shadow: 0 10px 30px rgba(16, 24, 32, .16); }
.menu.right { left: auto; right: 0; }
.menu.wide { min-width: 300px; padding: 10px; }
.menu-item { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 7px; cursor: pointer; font-weight: 500; }
.menu-item:hover { background: var(--bg); }

/* ---------- layout ---------- */
main { height: calc(100vh - 54px); }
.view { display: none; height: 100%; }
.view.active { display: block; }
#view-shipments.active { display: grid; }
.layout { grid-template-columns: 256px minmax(420px, 1fr) minmax(430px, 1.05fr); }

/* ---------- sidebar ---------- */
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 8px; }
.side-head h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); }
.side-tools { padding: 0 10px 8px; border-bottom: 1px solid var(--line); }
.side-tools input { width: 100%; height: 32px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 10px; background: var(--bg); margin-bottom: 8px; }
.side-tools input:focus { outline: none; border-color: var(--accent); background: #fff; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip-btn { border: 1px solid transparent; background: transparent; padding: 3px 8px; border-radius: 999px; font-size: 11.5px; color: var(--muted); cursor: pointer; }
.chip-btn b { font-weight: 600; color: var(--ink); opacity: .7; }
.chip-btn:hover { background: var(--bg); }
.chip-btn.active { background: var(--accent-soft); color: var(--accent-deep); border-color: var(--accent-line); }
.chip-btn.active b { color: var(--accent-deep); opacity: 1; }
.ship-list { overflow: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.ship { display: grid; gap: 2px; width: 100%; text-align: left; padding: 9px 11px; border: 1px solid transparent; border-radius: 9px; background: transparent; cursor: pointer; position: relative; }
.ship:hover { background: var(--bg); }
.ship.active { background: var(--accent-soft); border-color: var(--accent-line); }
.ship .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ship .t { font-weight: 600; }
.ship .w { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ship .meta { color: var(--muted); font-size: 11.5px; }
.ship .v { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.st { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.st-draft { --c: var(--st-draft); } .st-ready { --c: var(--st-ready); } .st-shipped { --c: var(--st-shipped); } .st-paid { --c: var(--st-paid); }
.st { background: var(--c); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 22%, transparent); }
.empty-note { color: var(--muted); padding: 14px 12px; text-align: center; }
.empty-note.ok { color: var(--ok); }

/* ---------- editor ---------- */
.editor-col { overflow: auto; min-height: 0; }
.editor { padding: 0 18px 80px; max-width: 800px; }
.ship-head { position: sticky; top: 0; z-index: 5; background: var(--bg); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 14px 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.ship-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex: 1 1 180px; }
.ship-title h2 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ship-title .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.status-select { appearance: none; -webkit-appearance: none; border: 1px solid var(--c, var(--line-strong)); color: var(--c, var(--ink)); background: #fff; border-radius: 999px; padding: 3px 24px 3px 11px; font-size: 12px; font-weight: 600; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%2366727f' stroke-width='1.5'/></svg>"); background-repeat: no-repeat; background-position: right 9px center; }
.status-select.st-draft, .status-select.st-ready, .status-select.st-shipped, .status-select.st-paid { background-color: color-mix(in srgb, var(--c) 9%, #fff); box-shadow: none; width: auto; height: auto; }

.sec { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; box-shadow: 0 1px 2px rgba(16, 24, 32, .03); }
.sec > summary { list-style: none; cursor: pointer; padding: 11px 14px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary::before { content: ''; width: 6px; height: 6px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; margin-right: 4px; }
.sec[open] > summary::before { transform: rotate(45deg); }
.sec-dot { display: none; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); font-size: 11px; font-weight: 700; align-items: center; justify-content: center; margin-left: auto; }
.sec-dot.on { display: inline-flex; }
.sec-meta + .sec-dot { margin-left: 0; }
.sec-meta:empty + .sec-dot { margin-left: auto; }
.sec > :not(summary) { margin: 0 14px; }
.sec[open] { padding-bottom: 12px; }
h4.sub { margin: 14px 0 6px; font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px; }
.grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid.g6 .field { grid-column: span 1; }
.grid.g6 .field.span3 { grid-column: span 3; }
.field.span2 { grid-column: 1 / -1; }
.field label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 3px; font-weight: 500; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 7px; padding: 6px 9px; background: #fff; min-height: 34px; transition: border-color .12s, box-shadow .12s; }
.field textarea { resize: vertical; line-height: 1.4; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input.flash, .field textarea.flash, .field select.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 4px #ffd27a; border-color: var(--warn); } 100% { box-shadow: 0 0 0 0 transparent; } }
.hint { font-size: 11px; color: var(--muted); margin-top: 3px; }
.with-addon { display: flex; gap: 6px; align-items: stretch; }
.with-addon > :first-child { flex: 1; min-width: 0; }
.with-addon .addon { height: 34px; }
.img-field { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.img-field img { max-height: 40px; max-width: 120px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.picker-row { display: flex; gap: 8px; align-items: center; margin: 2px 0 10px; }
.picker-row select { flex: 1; min-width: 0; height: 34px; border: 1px solid var(--line-strong); border-radius: 7px; padding: 0 9px; background: var(--accent-soft); color: var(--accent-deep); font-weight: 500; }
.picker-row select:focus { outline: none; border-color: var(--accent); }

.item { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px 10px; margin: 10px 0; background: #fbfcfc; }
.item-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.item-no { font-weight: 650; }
.item-amt { color: var(--accent-deep); font-weight: 600; font-variant-numeric: tabular-nums; }
.empty-items { color: var(--muted); padding: 16px; text-align: center; border: 1px dashed var(--line-strong); border-radius: 8px; margin: 10px 0; }
.row-actions { margin: 4px 0 2px; }
.summary { margin-top: 10px; display: grid; gap: 4px; }
.summary > div { display: flex; justify-content: space-between; padding: 5px 0; border-top: 1px dashed var(--line); }
.summary b { font-variant-numeric: tabular-nums; }
.summary .warn, .warn { display: block; background: var(--warn-soft); color: var(--warn); border: 0; padding: 6px 8px; border-radius: 6px; }

/* ---------- preview ---------- */
.preview-col { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); background: #dfe3e8; }
.preview-bar { background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 12px; display: grid; gap: 8px; position: relative; }
.tabs-row { display: flex; align-items: center; gap: 8px; }
.chip { margin-left: auto; border-radius: 999px; padding: 4px 11px; font-size: 12px; font-weight: 600; border: 1px solid; cursor: pointer; white-space: nowrap; background: #fff; }
.chip.ok { color: var(--ok); border-color: #b9e2c6; background: var(--ok-soft); }
.chip.warn { color: var(--warn); border-color: #f0d59a; background: var(--warn-soft); }
.chip.bad { color: var(--danger); border-color: #f1b7b2; background: var(--danger-soft); }
.chip::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; }
.pop { position: absolute; z-index: 20; right: 12px; top: 46px; width: 300px; max-height: 360px; overflow: auto; background: #fff; border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: 0 12px 32px rgba(16, 24, 32, .18); padding: 6px; }
.pop-h { font-weight: 650; padding: 6px 8px 4px; }
.pop-g { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 8px 8px 2px; }
.pop-item { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.pop-item:hover { background: var(--warn-soft); }
.pop-item::before { content: '→ '; color: var(--muted); }
.pop-ok { color: var(--ok); padding: 6px 8px; }
.pop-note { padding: 4px 8px; color: var(--warn); }
.print-row { display: flex; gap: 8px; align-items: center; }
.pick { display: grid; gap: 6px; margin-bottom: 8px; }
.pick-opt { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.pick-opt.sep { border-top: 1px solid var(--line); padding-top: 8px; margin-bottom: 10px; color: var(--muted); }
.kbd { font-size: 11.5px; }
.preview-scroll { flex: 1; overflow: auto; padding: 14px 16px; }
.preview-size { position: relative; margin: 0 auto; }
.preview-pages { transform-origin: top left; width: 210mm; position: absolute; top: 0; left: 0; }
.preview-pages .page { box-shadow: 0 1px 3px rgba(0, 0, 0, .15), 0 8px 24px rgba(0, 0, 0, .1); margin-bottom: 8mm; }
.error { background: #fff; color: var(--danger); padding: 16px; border-radius: 8px; }

/* ---------- overview ---------- */
#view-overview { overflow: auto; }
.ov { max-width: 1180px; margin: 0 auto; padding: 26px 28px 60px; }
.ov-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.ov-head h1 { font-size: 24px; }
.ov-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow); }
.tile-l { font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
.tile-v { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile-s { color: var(--muted); font-size: 12px; margin-top: 4px; }
.tile.attn { border-color: #f0d59a; background: linear-gradient(180deg, #fffaf0, #fff); }
.tile.attn .tile-v { color: var(--warn); }
.ov-cols { display: grid; grid-template-columns: 1.6fr 1fr; gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 14px 16px 16px; min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-h h3 { font-size: 14px; }
.card.setup { margin-bottom: 16px; border-color: var(--accent-line); background: linear-gradient(180deg, #f3faf8, #fff); }
.setup-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.setup-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.setup-list li.done { color: var(--muted); text-decoration: line-through; }
.setup-list .tick { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; flex: none; }
.setup-list li.done .tick { background: var(--ok); border-color: var(--ok); color: #fff; }
.setup-list .btn { margin-left: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl th.num { text-align: right; }
.tbl td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.attn-list { list-style: none; margin: 0; padding: 0; }
.attn-list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.attn-list li:last-child { border-bottom: 0; }
.attn-list li > div { flex: 1; min-width: 0; }

/* ---------- money: payment, incentives, reports ---------- */
.sec-meta { margin-left: auto; margin-right: 8px; font-size: 11.5px; color: var(--muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }
.sec-meta:empty { display: none; }
.fin-panel { border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px 8px; background: #fbfcfc; margin: 2px 0 8px; }
.fin-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-top: 1px dashed var(--line); font-size: 13px; }
.fin-row:first-child { border-top: 0; }
.fin-row b { font-variant-numeric: tabular-nums; text-align: right; }
.fin-note { font-size: 11.5px; color: var(--muted); padding: 5px 0 2px; }
.fin-panel .warn { margin-top: 6px; font-size: 12.5px; }
.bad { color: var(--danger); } .ok { color: var(--ok); } .warnc { color: var(--warn); }
.pay-chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; border: 1px solid; white-space: nowrap; }
.pay-paid { color: #1f7a3d; border-color: #b9e2c6; background: #e2f4e8; }
.pay-due { color: #1f4fb6; border-color: #b9ccf3; background: #e8effc; }
.pay-partly { color: #7a4a00; border-color: #f0d59a; background: #fff6e0; }
.pay-overdue, .pay-overdue-part { color: #a12a22; border-color: #f1b7b2; background: #fdecea; }
.pay-none { color: var(--muted); border-color: var(--line); background: var(--bg); }
.receipts { width: 100%; border-collapse: collapse; margin: 2px 0 6px; }
.receipts th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 500; padding: 2px 6px 4px 0; }
.receipts td { padding: 2px 6px 2px 0; vertical-align: middle; }
.receipts td:last-child { width: 30px; padding-right: 0; }
.receipts input { width: 100%; border: 1px solid var(--line-strong); border-radius: 7px; padding: 6px 9px; min-height: 32px; }
.receipts input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.receipts tr.none td { color: var(--muted); font-size: 12.5px; padding: 6px 0; }
.lut-banner { display: flex; align-items: center; justify-content: space-between; gap: 14px; border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px; border: 1px solid; }
.lut-banner.expiring, .lut-banner.unknown, .lut-banner.missing { background: var(--warn-soft); color: #5e3a00; border-color: #f0d59a; }
.lut-banner.expired { background: var(--danger-soft); color: #7a1f18; border-color: #f1b7b2; }
.ov-main { display: grid; gap: 12px; align-content: start; min-width: 0; }
.reports { display: grid; gap: 8px; }
.report-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.report-row:first-child { border-top: 0; padding-top: 2px; }
.report-row > div:first-child { flex: 1; min-width: 0; }
.report-row select { border: 1px solid var(--line-strong); border-radius: 7px; padding: 4px 6px; font-size: 12.5px; background: #fff; }
.inc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.inc-grid > div { background: var(--bg); border-radius: 8px; padding: 8px 10px; display: grid; }
.inc-grid span { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; }
.inc-grid b { font-size: 18px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.inc-grid small { color: var(--muted); font-size: 11.5px; }

/* ---------- dialogs ---------- */
.dialog { width: min(900px, 94vw); max-height: 90vh; border: 1px solid var(--line-strong); border-radius: 14px; padding: 0; box-shadow: 0 24px 60px rgba(16, 24, 32, .3); }
.dialog.wide { width: min(1040px, 96vw); }
.dialog::backdrop { background: rgba(16, 24, 32, .45); }
.dialog-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
.dialog-head h2 { font-size: 16px; }
.company-form { padding: 6px 16px 16px; }
.company-form fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 10px 0; padding: 8px 12px 12px; }
.company-form legend { font-weight: 650; padding: 0 4px; }
.num-table { width: 100%; border-collapse: collapse; }
.num-table th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 4px 6px; }
.num-table td { padding: 4px 6px; }
.num-table input[type="text"], .num-table input:not([type]) { width: 100%; border: 1px solid var(--line-strong); border-radius: 7px; padding: 6px 9px; }
.num-table input[type="number"] { width: 110px; border: 1px solid var(--line-strong); border-radius: 7px; padding: 6px 9px; }
.lib-body { display: grid; grid-template-columns: 300px 1fr; min-height: 420px; max-height: calc(90vh - 58px); }
.lib-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.lib-list-head { display: flex; gap: 6px; padding: 10px; border-bottom: 1px solid var(--line); }
.lib-list-head input { flex: 1; min-width: 0; height: 30px; border: 1px solid var(--line-strong); border-radius: 7px; padding: 0 9px; }
#lib-items { overflow: auto; padding: 6px; }
.lib-item { display: grid; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 7px; background: transparent; cursor: pointer; }
.lib-item:hover { background: var(--bg); }
.lib-item.active { background: var(--accent-soft); }
.lib-item .t { font-weight: 600; }
.lib-item .w { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-form { padding: 14px 16px; overflow: auto; }
.lib-actions { display: flex; gap: 8px; align-items: center; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.empty-state { padding: 40px 20px; text-align: center; color: var(--muted); max-width: 420px; margin: 0 auto; }
.empty-state h3 { color: var(--ink); margin-bottom: 6px; }
.empty-state p { margin: 0 0 14px; }
.import-body { padding: 14px 16px 16px; }
.import-top { display: flex; gap: 10px; align-items: flex-start; }
.import-top textarea { flex: 1; border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; resize: vertical; }
.import-top textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.import-meta { display: flex; gap: 14px; align-items: center; margin: 12px 0 8px; }
.import-table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; max-height: 300px; }
.import-table { border-collapse: collapse; min-width: 100%; }
.import-table th { background: var(--bg); padding: 6px; position: sticky; top: 0; }
.import-table th select { border: 1px solid var(--line-strong); border-radius: 6px; padding: 4px 6px; background: #fff; font-size: 12px; max-width: 160px; }
.import-table td { padding: 5px 8px; border-top: 1px solid var(--line); white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.import-table tr.is-head td { color: var(--muted); font-style: italic; }
.import-foot { display: flex; gap: 16px; align-items: center; margin-top: 12px; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 12px); background: #1b2630; color: #fff; padding: 9px 14px; border-radius: 9px; font-weight: 500; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 50; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.warn { background: #7a4a00; }

#print-root { position: absolute; left: -10000px; top: 0; width: 210mm; }

@media (max-width: 1180px) {
  .layout { grid-template-columns: 220px 1fr; }
  .preview-col { grid-column: 1 / -1; min-height: 80vh; border-left: 0; border-top: 1px solid var(--line); }
  main { height: auto; }
  #view-shipments.active { height: auto; }
  .ov-cols { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { max-height: 40vh; }
  .views { display: none; }
}

@page { size: A4; margin: 0; }
@media print {
  html, body { background: #fff; height: auto; }
  #app, .dialog, .toast { display: none !important; }
  #print-root { position: static; left: auto; width: auto; }
  #print-root .page { break-after: page; box-shadow: none; margin: 0; }
  #print-root .page:last-child { break-after: auto; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- approval workflow, roles, history ---------- */
.appr-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid; white-space: nowrap; }
.appr-chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.ap-draft { color: #5e6973; border-color: #cfd6dc; background: #f1f3f5; --c: #8b96a3; }
.ap-submitted { color: #1f4fb6; border-color: #b9ccf3; background: #e8effc; --c: #2f6fde; }
.ap-returned { color: #a12a22; border-color: #f1b7b2; background: #fdecea; --c: #b3261e; }
.ap-approved { color: #1f7a3d; border-color: #b9e2c6; background: #e2f4e8; --c: #1f7a3d; }
.st-open { --c: #8b96a3; }
.st.ap-draft, .st.ap-submitted, .st.ap-returned, .st.ap-approved { background: var(--c); border: 0; padding: 0; }
.status-select:disabled { opacity: .55; cursor: not-allowed; }
.return-note { background: var(--danger-soft); color: #7a1f18; border: 1px solid #f1b7b2; border-radius: 8px; padding: 8px 12px; margin: -4px 0 12px; font-size: 13px; }
.viewing-note { background: var(--info-soft); color: #1f3f8a; border: 1px solid #b9ccf3; border-radius: 8px; padding: 8px 12px; margin: -4px 0 12px; font-size: 13px; }
.print-gate { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 9px 12px; font-size: 13px; font-weight: 500; }
.version-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--info-soft); color: #1f3f8a; border: 1px solid #b9ccf3; border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 500; }
.demo-badge { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #ffd27a; border: 1px solid rgba(255, 210, 122, .5); border-radius: 999px; padding: 2px 8px; }
.menu-user { padding: 8px 10px 6px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-user:empty { display: none; }

.timeline { list-style: none; margin: 0; padding: 4px 0 0; }
.timeline li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.timeline li:last-child { border-bottom: 0; }
.tl-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); margin-top: 6px; flex: none; }
.tl-approved .tl-dot { background: var(--ok); } .tl-submitted .tl-dot { background: var(--info); } .tl-returned .tl-dot, .tl-deleted .tl-dot { background: var(--danger); }
.tl-reopened .tl-dot, .tl-withdrawn .tl-dot { background: var(--warn); } .tl-printed .tl-dot { background: var(--accent); } .tl-created .tl-dot { background: var(--st-draft); }
.tl-text { font-size: 13px; }
.tl-meta { font-size: 11.5px; color: var(--muted); }
.timeline.compact li { padding: 5px 0; }
.link.small { font-size: 12px; }
.ov-side { display: grid; gap: 12px; align-content: start; }

.people { width: 100%; border-collapse: collapse; margin: 10px 0 8px; }
.people th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.people td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.people select { border: 1px solid var(--line-strong); border-radius: 6px; padding: 4px 6px; }
.pill { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.add-person { display: grid; grid-template-columns: 1fr 1.4fr auto auto; gap: 8px; margin: 6px 0 8px; }
.add-person input, .add-person select { border: 1px solid var(--line-strong); border-radius: 7px; padding: 6px 9px; min-height: 32px; }
fieldset:disabled .field input, fieldset:disabled .field textarea, fieldset:disabled .field select { background: var(--bg); color: var(--muted); }

.dialog.narrow { width: min(460px, 94vw); }
.dialog-body { padding: 14px 16px 16px; display: grid; gap: 12px; }
.dialog-body textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px; resize: vertical; }

/* ---------- sign-in screens ---------- */
.auth { position: fixed; inset: 0; z-index: 40; background: radial-gradient(1200px 600px at 20% -10%, #1b4a50, var(--top) 60%); display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: min(440px, 100%); background: #fff; border-radius: 14px; padding: 26px 26px 20px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; margin-bottom: 18px; }
.auth-card h2 { font-size: 20px; margin-bottom: 6px; }
.auth-card p { margin: 0 0 14px; }
.auth-card label { display: block; font-size: 12px; color: var(--muted); font-weight: 500; margin: 10px 0 4px; }
.auth-card label input { display: block; width: 100%; border: 1px solid var(--line-strong); border-radius: 8px; padding: 9px 10px; font-size: 14px; margin-top: 4px; }
.auth-card label input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.auth-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.btn.big { height: 42px; padding: 0 18px; }
.auth-card .link { margin-top: 12px; display: inline-block; }
.auth-error { background: var(--danger-soft); color: var(--danger); border-radius: 8px; padding: 8px 10px; font-size: 13px; margin-bottom: 10px; }
.auth-busy { color: var(--accent-deep); font-weight: 600; margin-bottom: 10px; }
.auth-sent { background: var(--ok-soft); color: var(--ok); border-radius: 8px; padding: 8px 10px; font-size: 13px; margin-top: 12px; }
.auth-foot { margin-top: 16px; font-size: 13px; color: var(--muted); }
.auth-choose { display: grid; gap: 8px; }
[hidden] { display: none !important; }
.auth-foot a { color: var(--accent-deep); }
