/* CarSolutions Lager - internal warehouse program. Calm, dense, made for daily work. */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #18202e;
  --ink-2: #4a5466;
  --muted: #7a8394;
  --line: #e3e6eb;
  --line-strong: #cfd4dc;
  --accent: #1f5fbf;
  --accent-ink: #ffffff;
  --accent-soft: #e8f0fc;
  --ok: #1d7a46;
  --ok-soft: #e4f4ea;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --side: #121a29;
  --side-ink: #c9d1de;
  --side-active: #ffffff;
  --radius: 8px;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 650; }
h3 { font-size: 13px; margin: 18px 0 8px; font-weight: 650; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.04em; }
.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side {
  background: var(--side); color: var(--side-ink);
  display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; color: #fff; font-weight: 650; }
.brand small { display: block; font-weight: 400; color: var(--side-ink); font-size: 11px; opacity: 0.8; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  color: var(--side-ink); padding: 8px 10px; border-radius: 6px; display: flex; gap: 10px; align-items: center;
}
.nav a:hover { background: rgba(255,255,255,0.06); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(255,255,255,0.12); color: var(--side-active); font-weight: 600; }
.nav svg { width: 17px; height: 17px; flex: none; opacity: 0.9; }
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,0.08); font-size: 12px; }
.side-foot .who { color: #fff; font-weight: 600; margin-bottom: 6px; }
.side-foot a { color: var(--side-ink); display: block; padding: 3px 0; white-space: nowrap; }

.main { padding: 22px 28px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .spacer { flex: 1; }
.crumb { font-size: 13px; margin-bottom: 4px; }

.grid-2 { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
.grid-loc { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 16px; }
.card.flush { padding: 0; }
.card-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-head h2 { margin: 0; }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px; }

/* ---------------------------------------------------------------- controls */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; background: #fff; border: 1px solid var(--line-strong); border-radius: 6px; padding: 7px 9px; min-height: 34px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[readonly] { background: var(--bg); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 14px; }
.fields .wide { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.hint.ok { color: var(--ok); }
.hint.bad { color: var(--danger); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: #fff;
  border-radius: 6px; padding: 7px 13px; min-height: 34px; cursor: pointer; font-weight: 600; white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 28px; padding: 3px 9px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn svg { width: 15px; height: 15px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .search { flex: 1 1 260px; max-width: 420px; position: relative; }
.toolbar .search input { padding-left: 32px; }
.toolbar .search svg { position: absolute; left: 9px; top: 9px; width: 16px; height: 16px; color: var(--muted); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line-strong); background: #fff; border-radius: 999px; padding: 4px 11px; font-size: 13px; cursor: pointer;
}
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }

.tag { white-space: nowrap; display: inline-block; font-size: 11px; font-weight: 650; padding: 1px 7px; border-radius: 999px; background: var(--bg); color: var(--ink-2); border: 1px solid var(--line); vertical-align: 1px; }
.tag.blue { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

.notice { border-radius: var(--radius); padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.notice.warn { background: var(--warn-soft); color: #5c3700; }
.notice.info { background: var(--accent-soft); color: #173f7a; }
.notice.bad { background: var(--danger-soft); color: #7a1610; }

/* ---------------------------------------------------------------- tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; font-weight: 650; color: var(--muted); background: #fafbfc; position: sticky; top: 0; z-index: 1; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover { background: #f7f9fc; }
tbody tr.sel { background: var(--accent-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.empty { padding: 34px 16px; text-align: center; color: var(--muted); }
.thumb { width: 40px; height: 40px; border-radius: 5px; object-fit: cover; background: var(--bg); border: 1px solid var(--line); display: block; }
.thumb.none { display: grid; place-items: center; color: var(--line-strong); }
.cell-main { font-weight: 600; }
.cell-sub { font-size: 12px; color: var(--muted); }
.qty-low { color: var(--danger); font-weight: 700; }

.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding: 10px 14px; font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------------- product images */
.images { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.img-tile { position: relative; aspect-ratio: 1; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); background: var(--bg); cursor: grab; }
.img-tile img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.img-tile.main { grid-column: span 3; aspect-ratio: 4 / 3; }
.img-tile.main img { object-fit: contain; background: #fff; }
.img-tile .badge { position: absolute; left: 6px; top: 6px; }
.img-tile .del {
  position: absolute; right: 5px; top: 5px; width: 26px; height: 26px; border-radius: 50%; border: none;
  background: rgba(17, 24, 39, 0.72); color: #fff; cursor: pointer; display: grid; place-items: center; opacity: 0;
}
.img-tile:hover .del, .img-tile:focus-within .del { opacity: 1; }
.img-tile.dragging { opacity: 0.4; }
.img-tile.over { outline: 2px solid var(--accent); outline-offset: -2px; }
.drop {
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 18px 12px; text-align: center;
  color: var(--muted); margin-top: 10px; cursor: pointer; font-size: 13px;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.drop strong { color: var(--ink); }

.preview-pn { font-size: 12px; margin-top: 4px; }
.preview-pn b { font-family: var(--mono); font-weight: 600; }

.sticky-save {
  position: sticky; bottom: 0; background: linear-gradient(to top, var(--panel) 75%, rgba(255,255,255,0));
  padding: 14px 0 2px; margin-top: 8px; display: flex; gap: 8px; align-items: center;
}

/* ---------------------------------------------------------------- location list */
.loc-list { display: flex; flex-direction: column; }
.loc-item { padding: 11px 16px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; gap: 10px; align-items: center; }
.loc-item:last-child { border-bottom: none; }
.loc-item:hover { background: #f7f9fc; }
.loc-item.on { background: var(--accent-soft); }
.loc-code { font-family: var(--mono); font-weight: 700; font-size: 12px; background: var(--ink); color: #fff; border-radius: 5px; padding: 2px 6px; }

/* ---------------------------------------------------------------- login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 360px; }
.login .brand { color: var(--ink); padding: 0 0 18px; font-size: 17px; }
.login .brand small { color: var(--muted); }

/* ---------------------------------------------------------------- modal + toast */
.modal-bg { position: fixed; inset: 0; background: rgba(17, 24, 39, 0.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--panel); border-radius: 10px; width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,0.25); }
.modal .card-head { position: sticky; top: 0; background: var(--panel); }
.modal .foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--line); }
.x { border: none; background: none; cursor: pointer; padding: 4px; color: var(--muted); font-size: 20px; line-height: 1; }

#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast-item { background: var(--ink); color: #fff; padding: 9px 14px; border-radius: 7px; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,0.2); }
.toast-item.bad { background: var(--danger); }

pre.log { background: #0f1724; color: #d6deeb; padding: 12px; border-radius: 6px; font: 12px/1.5 var(--mono); max-height: 320px; overflow: auto; white-space: pre-wrap; margin: 0; }
.stats { display: flex; gap: 22px; flex-wrap: wrap; margin: 4px 0 12px; }
.stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------- labels (print) */
#print-root { display: none; }
@media print {
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing #print-root { display: block; }
  body.printing { background: #fff; }
}
.label {
  overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; color: #000;
  font-family: Arial, sans-serif; page-break-inside: avoid; break-inside: avoid;
}
.label .l-title { font-weight: 700; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label .l-sub { line-height: 1.15; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.label .l-code { font-family: Consolas, monospace; text-align: center; letter-spacing: 0.04em; }
.label svg { width: 100%; display: block; }

/* 62 x 29 mm - one label per page (Brother DK-11209 and similar) */
.labels-62x29 .label { width: 62mm; height: 29mm; padding: 1.5mm 3mm; page-break-after: always; break-after: page; }
.labels-62x29 .l-title { font-size: 11pt; }
.labels-62x29 .l-sub { font-size: 7pt; }
.labels-62x29 svg { height: 10mm; }
.labels-62x29 .l-code { font-size: 7pt; }

/* A4 sheet, 3 x 8 labels of 70 x 37 mm */
.labels-a4 { display: grid; grid-template-columns: repeat(3, 70mm); grid-auto-rows: 37mm; }
.labels-a4 .label { width: 70mm; height: 37mm; padding: 3mm 4mm; }
.labels-a4 .l-title { font-size: 13pt; }
.labels-a4 .l-sub { font-size: 8pt; }
.labels-a4 svg { height: 13mm; }
.labels-a4 .l-code { font-size: 8pt; }

/* On-screen label preview inside the print dialog */
.label-preview { background: var(--bg); border-radius: 6px; padding: 12px; display: flex; justify-content: center; overflow: hidden; }
.label-preview .label { background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.15); }
.label-preview .labels-a4 { display: block; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .grid-2, .grid-loc { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; padding: 8px 10px; gap: 6px; overflow-x: auto; }
  .brand { padding: 0 6px 0 0; }
  .brand small { display: none; }
  .nav { flex-direction: row; }
  .nav a span { display: none; }
  .side-foot { margin: 0 0 0 auto; border: none; padding: 0; display: flex; gap: 10px; align-items: center; }
  .side-foot .who, .side-foot .ver { display: none; }
  .main { padding: 16px 16px 50px; }
  .hide-sm { display: none; }
}

/* ---------------------------------------------------------------- 0.2.0: kinds, parts lists */
.seg { display: inline-flex; background: #e9ecf1; border-radius: 8px; padding: 3px; gap: 2px; margin-bottom: 12px; }
.seg button { border: none; background: none; padding: 6px 16px; border-radius: 6px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.12); }
.picker { position: relative; flex: 1 1 320px; max-width: 460px; }
.picker-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; background: #fff; border: 1px solid var(--line-strong);
  border-radius: 8px; box-shadow: 0 10px 30px rgba(17,24,39,0.15); max-height: 320px; overflow: auto; padding: 4px;
}
.picker-item { display: block; width: 100%; text-align: left; background: none; border: none; padding: 7px 9px; border-radius: 6px; cursor: pointer; font: inherit; color: inherit; }
.picker-item:hover, .picker-item.on { background: var(--accent-soft); }
.picker-item.create { color: var(--accent); font-weight: 600; border-top: 1px solid var(--line); border-radius: 0 0 6px 6px; display: flex; align-items: center; gap: 4px; }
.picker-item.create svg { width: 15px; height: 15px; }
.picker-static { margin-top: 8px; max-height: 300px; overflow: auto; }
.qty-input { width: 64px !important; min-height: 28px !important; padding: 3px 6px !important; text-align: right; }
.neg { color: var(--danger); }
tr.inherited td { color: var(--ink-2); background: #fafbfc; }

/* ---------------------------------------------------------------- 0.3.0: supplier invoices */
.inv-grid { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 16px; align-items: start; }
.inv-pdf { position: sticky; top: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.inv-pdf iframe { width: 100%; height: calc(100vh - 90px); min-height: 480px; border: none; border-radius: 4px; background: #525659; }
.inv-pdf a { display: inline-flex; align-items: center; gap: 4px; }
.inv-pdf a svg { width: 14px; height: 14px; }
.inv-side { min-width: 0; }
.inv-side .card + .card { margin-top: 16px; }
.inv-actions { margin-top: 16px; }
details.pay { border-top: 1px solid var(--line); padding-top: 10px; margin-bottom: 12px; }
details.pay summary { cursor: pointer; font-size: 13px; font-weight: 600; }
ul.tight { margin: 4px 0 0; padding-left: 18px; }
ul.tight li { margin: 2px 0; }
.num-input { text-align: right; font-variant-numeric: tabular-nums; }
input[type=date] { width: 100%; background: #fff; border: 1px solid var(--line-strong); border-radius: 6px; padding: 6px 9px; min-height: 34px; }
input:disabled, select:disabled, textarea:disabled { background: var(--bg); color: var(--ink-2); }
select.compact { min-height: 28px; padding: 3px 6px; width: auto; font-size: 13px; }
table.inv-lines td { vertical-align: top; }
table.inv-lines .part-cell { min-width: 220px; width: 40%; }
.part-cell .picker { max-width: none; }
.linked { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; }
.linked .cell-sub { flex-basis: 100%; }
.linked .x { font-size: 16px; padding: 0 2px; }
.link-btn { margin-top: 6px; }
.btn-link { border: none; background: none; padding: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: 12px; }
.btn-link:hover { text-decoration: underline; }
@media (max-width: 1100px) {
  .inv-grid { grid-template-columns: 1fr; }
  .inv-pdf { position: static; }
  .inv-pdf iframe { height: 70vh; }
}

/* ---------------------------------------------------------------- 0.3.1: supplier templates */
.flow-choice { display: grid; gap: 8px; }
.flow-opt { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line-strong); border-radius: 8px; padding: 10px 12px; cursor: pointer; }
.flow-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.flow-opt input { margin-top: 3px; accent-color: var(--accent); }
.flow-opt .cell-sub { font-weight: 400; }
.notice.new-supplier { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
div.field.group { margin-bottom: 12px; }
div.field.group > span { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }

/* ---------------------------------------------------------------- 0.4.0: payments, settings, bookkeeper page */
.grid-settings { max-width: 640px; }
.bk { max-width: 1000px; margin: 0 auto; padding: 28px 20px 60px; }
.bk-steps { margin: 6px 0 0; padding-left: 20px; color: var(--ink-2); }
.bk-steps li { margin: 3px 0; }
.bk .brand { display: flex; align-items: center; gap: 10px; } .bk .brand svg { width: 30px; height: 30px; flex: none; }
.grid-settings .card + .card { margin-top: 16px; }
.label-preview .lbl-page { box-shadow: 0 1px 4px rgba(0,0,0,0.15); flex: none; }
.label-preview .lbl-page .label { box-shadow: none; background: transparent; }
