:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --ink: #111827;
  --ink2: #374151;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #0f172a;
  --accent: #1d4ed8;
  --accent-soft: #e0e7ff;
  --ok: #15803d;   --ok-bg: #dcfce7;
  --warn: #b45309; --warn-bg: #fef3c7;
  --bad: #b91c1c;  --bad-bg: #fee2e2;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 2px 0 0; }
h2 { font-size: 16px; margin: 26px 0 10px; color: var(--ink2); }
h3 { font-size: 14px; margin: 18px 0 8px; color: var(--ink2); }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  border: 1px solid #d1d5db; border-radius: 8px; padding: 7px 9px; background: #fff; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { width: 100%; resize: vertical; }
input[type=number] { width: 80px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; }
pre { white-space: pre-wrap; margin: 6px 0 0; font: 13px/1.4 Consolas, monospace; }

.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--brand); color: #fff; padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; }
.brand { font-weight: 800; letter-spacing: .08em; font-size: 18px; padding: 4px 10px 18px; }
.brand span { display: block; font-weight: 400; letter-spacing: 0; font-size: 12px; opacity: .55; }
.side a { color: #cbd5e1; text-decoration: none; padding: 9px 10px; border-radius: 8px; }
.side a:hover { background: #1e293b; color: #fff; }
.side a.on { background: #fff; color: var(--brand); font-weight: 600; }
main { padding: 22px 28px 80px; width: 100%; max-width: 1240px; min-width: 0; }
h1 { overflow-wrap: anywhere; }

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.head .actions { margin: 0; }
.back { text-decoration: none; font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); }
.sub { color: var(--muted); font-size: 12.5px; }
.r { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.loading, .empty { padding: 26px; text-align: center; color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card.flush { padding: 0; overflow: hidden; }
.card.scroll { overflow-x: auto; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid #d1d5db; background: #fff; border-radius: 8px; padding: 7px 13px; cursor: pointer; text-decoration: none; color: var(--ink); font-weight: 500; white-space: nowrap; }
.btn:hover { background: #f9fafb; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1e40af; }
.btn.danger { color: var(--bad); border-color: #fecaca; }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn small { opacity: .7; font-weight: 400; }
.btn.dirty { box-shadow: 0 0 0 3px #fde68a; }
.btn:disabled { opacity: .55; cursor: default; }
.icon { border: 0; background: transparent; cursor: pointer; font-size: 15px; padding: 4px 7px; border-radius: 6px; color: var(--muted); }
.icon:hover { background: #f3f4f6; color: var(--ink); }
.icon.danger:hover { color: var(--bad); background: var(--bad-bg); }

.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; background: #f1f5f9; color: var(--ink2); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }

/* табели */
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); background: #fafafa; white-space: nowrap; }
table.list td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr[data-href] { cursor: pointer; }
table.list tr[data-href]:hover td { background: #f8fafc; }
table.list .num { font-weight: 600; white-space: nowrap; }
table.list .num a { text-decoration: none; }
table.edit td { padding: 6px 6px; vertical-align: middle; }
table.edit input:not([type=checkbox]) { width: 100%; }
table.edit input[type=number] { width: 78px; }
table.edit .w-name { min-width: 190px; }
table.edit .w-mid { min-width: 130px; }
table.edit tr.new td { background: #f8fafc; }

/* статуси */
select.st { font-size: 12.5px; padding: 4px 6px; border-radius: 99px; font-weight: 600; }
.st-nova { background: #f1f5f9; }
.st-ceka_velicini, .st-ceka_logo { background: var(--warn-bg); color: var(--warn); }
.st-za_naracka { background: var(--accent-soft); color: var(--accent); }
.st-naracano, .st-pristignato { background: #ede9fe; color: #6d28d9; }
.st-pecatenje { background: #cffafe; color: #0e7490; }
.st-gotovo, .st-isporaceno { background: var(--ok-bg); color: var(--ok); }
.st-otkazana { background: #e5e7eb; color: var(--muted); }
.st-vratena { background: var(--bad-bg); color: var(--bad); }
.dl.ok { color: var(--ink2); }
.dl.warn { color: var(--warn); font-weight: 600; }
.dl.bad { color: var(--bad); font-weight: 700; }

/* табла */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { text-align: left; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; }
.tile b { display: block; font-size: 24px; line-height: 1.1; }
.tile span { color: var(--muted); font-size: 12.5px; }
.tile.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.tile.alert b { color: var(--bad); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 4px 11px; cursor: pointer; font-size: 13px; }
.chip i { font-style: normal; color: var(--muted); margin-left: 3px; }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.chip.on i { color: #cbd5e1; }
.search { flex: 1; min-width: 200px; padding: 9px 12px; }

/* нова нарачка */
.picklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; margin-top: 10px; }
.pick { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 9px 11px; cursor: pointer; }
.pick:hover { border-color: var(--accent); background: #f8faff; }
.pick span { display: block; color: var(--muted); font-size: 12.5px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 14px; }
.form-grid label, .lbl { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.form-grid label input, .form-grid label select, .form-grid label textarea { color: var(--ink); font-size: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
label.chk { flex-direction: row !important; align-items: center; gap: 8px; color: var(--ink) !important; font-size: 14px !important; cursor: pointer; }
label.chk.small { font-size: 13px !important; color: var(--muted) !important; margin-top: 8px; display: inline-flex; }

/* нарачка */
.warnbox { background: var(--warn-bg); border: 1px solid #fcd34d; color: #78350f; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; }
.warnbox ul { margin: 4px 0 0; padding-left: 18px; }
.okbox { background: var(--ok-bg); border: 1px solid #86efac; color: #14532d; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; }
.item { padding: 12px 14px; }
.item-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.item-top .idx { width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.item-top .prod { min-width: 240px; flex: 1 1 260px; font-weight: 600; }
.item-top .color { width: 150px; }
.spacer { flex: 1; }
.sizes { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.sz { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; color: var(--muted); font-weight: 600; }
.sz input { width: 58px; text-align: center; font-size: 15px; font-weight: 600; padding: 6px 4px; }
.sz input:not(:placeholder-shown) { border-color: var(--accent); background: #f8faff; }
.sz.tbd { margin-left: 12px; padding-left: 12px; border-left: 1px dashed #d1d5db; }
.sz.tbd input { width: 90px; border-color: #fcd34d; }
.prints { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; align-items: flex-start; }
.print { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; }
.print select[data-pf=pos] { width: 105px; }
.print select[data-pf=logo_id] { max-width: 230px; }
.print .cm input { width: 66px; }
.thumb { width: 44px; height: 36px; display: grid; place-items: center; border-radius: 6px; overflow: hidden; }
.thumb img { max-width: 100%; max-height: 100%; }
.nologo { font-size: 10.5px; color: var(--bad); text-align: center; line-height: 1.1; }
.q-ok { color: var(--ok); } .q-warn { color: var(--warn); } .q-bad { color: var(--bad); }
.print b[class^=q-] { font-size: 12px; }
.item-price { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: flex-end; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 13.5px; }
.item-price .override input { width: 90px; }
.item-price .line b.lt { font-size: 15px; }

.pay-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 150px); gap: 8px 14px; align-items: center; }
.pay-grid input:not([type=checkbox]) { width: 100%; }
.pay-grid .big { font-size: 18px; font-weight: 700; }
.order-bottom { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 0 14px; align-items: start; }

/* логоа */
.chk-bg { background: conic-gradient(#e5e7eb 25%, #fff 0 50%, #e5e7eb 0 75%, #fff 0) 0 0 / 16px 16px; border-radius: 8px; display: grid; place-items: center; }
.logo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.logo-card { padding: 10px; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.logo-card .chk-bg { height: 150px; }
.logo-card img { max-width: 92%; max-height: 136px; }
.logo-card .lname { font-weight: 600; border-color: transparent; padding: 4px 6px; }
.logo-card .lname:hover { border-color: #d1d5db; }
.quality { display: flex; flex-direction: column; font-size: 12.5px; color: var(--muted); }
.logos-strip { display: flex; gap: 10px; flex-wrap: wrap; }
.lg { margin: 0; width: 120px; font-size: 12px; }
.lg .chk-bg { height: 90px; }
.lg img { max-width: 90%; max-height: 80px; }
.lg figcaption { margin-top: 4px; word-break: break-word; }
.drop { border: 2px dashed #cbd5e1; border-radius: var(--radius); display: grid; place-items: center; text-align: center; padding: 14px; cursor: pointer; color: var(--muted); min-height: 120px; background: #fafafa; }
.drop:hover, .drop.over { border-color: var(--accent); color: var(--accent); background: #f8faff; }
.logos-strip .drop { width: 160px; min-height: 110px; }

/* добавувачи */
.sup-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.sup-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.sup-head h3 { margin: 0; font-size: 16px; color: var(--ink); }
.sup textarea { font: 13.5px/1.45 Consolas, "Segoe UI", monospace; }
.sup.done { opacity: .6; }
details summary { cursor: pointer; color: var(--accent); font-size: 12.5px; }

/* печатење */
.stats { display: flex; gap: 26px; flex-wrap: wrap; margin-bottom: 12px; }
.stats b { display: block; font-size: 22px; }
.stats span { color: var(--muted); font-size: 12.5px; }
.sheets { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.sheet { margin: 0; width: 260px; }
.sheet .chk-bg { padding: 6px; border: 1px solid var(--line); }
.sheet img { width: 100%; display: block; }
.sheet figcaption { font-size: 13px; margin-top: 6px; }
.press { border-top: 1px solid var(--line); padding: 8px 0; }
.press ul { margin: 4px 0 0; padding-left: 18px; }
.radio-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(30px); background: var(--brand); color: #fff; padding: 10px 18px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--bad); }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .item-top .prod { min-width: 0; flex-basis: 100%; }
  .item-top .color { flex: 1; width: auto; }
  .print select[data-pf=logo_id] { max-width: 150px; }
  .sz.tbd { margin-left: 0; padding-left: 0; border-left: 0; }
  .search { min-width: 0; }
  .side { height: auto; flex-direction: row; overflow-x: auto; padding: 8px; z-index: 10; gap: 4px; }
  .brand { display: none; }
  .side a { white-space: nowrap; padding: 7px 10px; }
  main { padding: 14px 12px 80px; }
  .card.flush { overflow-x: auto; }
  .order-bottom { grid-template-columns: 1fr; }
  .pay-grid { grid-template-columns: 1fr 1fr; }
}

/* нови делови */
input.need { border-color: #fcd34d !important; background: #fffbeb; }
.pay-grid.profit { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
div.tile { cursor: default; }
table.acc input.ad { width: 92px; text-align: right; padding: 4px 6px; }
table.acc .fb { display: inline-block; margin-left: 4px; background: #1877f2; color: #fff; border-radius: 4px; font-size: 10px; padding: 0 4px; font-weight: 700; vertical-align: middle; }
table.acc tr.today td { background: #eff6ff; }
table.acc tr.weekend td:first-child { color: var(--muted); }
table.acc tr.total td { font-weight: 600; background: #fafafa; border-top: 2px solid var(--line); }
#camp { max-width: 280px; }

/* графикони */
.viz { position: relative; }
.viz svg { display: block; max-width: 100%; overflow: visible; }
.viz svg:focus { outline: 2px solid var(--accent-soft); outline-offset: 2px; border-radius: 6px; }
.viz .grid { stroke: #eef0f3; stroke-width: 1; }
.viz .axis { stroke: #d1d5db; stroke-width: 1; }
.viz .tick { fill: var(--muted); font-size: 11px; }
.viz .dlabel { fill: var(--ink2); font-size: 12px; font-weight: 600; }
.viz .cross { stroke: #9ca3af; stroke-width: 1; }
.viz .bar { cursor: default; }
.viz .bar:hover path, .viz .bar:focus path { filter: brightness(1.15); }
.viz .bar:focus { outline: none; }
.viz-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink2); margin-bottom: 6px; }
.viz-legend .key i { display: inline-block; width: 16px; height: 2px; vertical-align: middle; margin-right: 6px; border-radius: 1px; }
.viz-tip { position: absolute; pointer-events: none; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.08); padding: 8px 10px; font-size: 12.5px; min-width: 130px; z-index: 5; white-space: nowrap; }
.viz-tip .tip-h { color: var(--muted); margin-bottom: 4px; }
.viz-tip .tip-r { display: flex; align-items: center; gap: 8px; line-height: 1.6; }
.viz-tip .tip-r i { width: 12px; height: 2px; display: inline-block; flex: none; }
.viz-tip .tip-r span { color: var(--muted); }

/* архива */
.ykey { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 7px; }
#ytbl tr.sel td { background: #eff6ff; }
.arch-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 0 12px; align-items: start; }
.hbar { display: grid; grid-template-columns: 90px 1fr 40px; gap: 8px; align-items: center; font-size: 13px; margin: 5px 0; }
.hbar div { background: #f1f5f9; border-radius: 4px; height: 10px; overflow: hidden; }
.hbar i { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.hbar b { text-align: right; }
.seg-list { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.scroll { overflow-x: auto; }

/* список за работа */
.print-only { display: none !important; }
.wl-card { padding: 12px 14px; }
.wl-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.wl-num { font-weight: 800; font-size: 16px; text-decoration: none; color: var(--ink); background: #f1f5f9; border-radius: 6px; padding: 2px 8px; }
.wl-name { font-size: 15px; }
.wl-item { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.wl-item:last-of-type { border-bottom: 0; }
.wl-line { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.wl-prod { min-width: 220px; font-size: 14px; }
.wl-sizes { display: flex; gap: 5px; flex-wrap: wrap; flex: 1; }
.wl-qty { white-space: nowrap; }
.szc { display: inline-block; border: 1px solid #cbd5e1; border-radius: 6px; padding: 1px 7px; font-size: 13px; background: #fff; }
.szc b { font-size: 14px; }
.szc.tbd { border-color: #fcd34d; background: var(--warn-bg); }
.wl-prints { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; }
.wl-print { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; line-height: 1.25; }
.wl-print .thumb { width: 52px; height: 40px; }
.wl-note { margin-top: 6px; font-size: 13px; background: #fffbeb; border-radius: 6px; padding: 4px 8px; }
.wl-totals summary { cursor: pointer; }
.wl-totals table { margin-top: 8px; }
.wl-short td:nth-child(3) { font-size: 13px; }

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 12px; }
  .layout { display: block; }
  .side, .no-print, #toast, details:not([open]) { display: none !important; }
  .print-only { display: initial !important; }
  .wl-checks.print-only { display: block !important; margin-top: 8px; font-size: 13px; }
  main { padding: 0; max-width: none; }
  .card { border: 1px solid #999; box-shadow: none; break-inside: avoid; margin-bottom: 8px; }
  .card.flush { overflow: visible; }
  a { color: inherit; text-decoration: none; }
  .chk-bg { background: #fff; }
  table.list tr { break-inside: avoid; }
}

/* email форма */
.mailbox:empty { display: none; }
.mailbox { margin-top: 12px; }
.mailform { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: #fafafa; }

/* ---------- најава и корисник ---------- */
body.booting #app { visibility: hidden; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--brand); }
.auth-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 14px; padding: 26px 24px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); }
.auth-card h1 { font-size: 20px; margin: 0; }
.auth-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink2); }
.auth-card input { padding: 10px 11px; font-size: 15px; }
.auth-card .btn { justify-content: center; padding: 10px; font-size: 15px; margin-top: 4px; }
.auth-brand { font-weight: 800; letter-spacing: .08em; font-size: 18px; color: var(--brand); }
.auth-brand span { display: block; font-weight: 400; letter-spacing: 0; font-size: 12px; color: var(--muted); }
.auth-err { color: var(--bad); font-size: 13px; min-height: 1em; }
.me { margin-top: auto; border-top: 1px solid #1e293b; padding: 12px 10px 0; }
.me-name { color: #fff; font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }
.me-name span { display: block; font-weight: 400; color: #94a3b8; font-size: 12px; }
.me-act { display: flex; gap: 6px; margin-top: 8px; }
.me-act button { flex: 1; background: #1e293b; color: #cbd5e1; border: 0; border-radius: 6px; padding: 5px 6px; font-size: 12px; cursor: pointer; }
.me-act button:hover { background: #334155; color: #fff; }
body.staff .owner-only { display: none !important; }
@media (max-width: 860px) {
  .me { margin: 0 0 0 auto; border: 0; padding: 0 2px 0 8px; display: flex; align-items: center; gap: 8px; flex: none; }
  .me-name { white-space: nowrap; }
  .me-name span { display: none; }
  .me-act { margin: 0; }
  .me-act button { flex: none; padding: 6px 8px; }
}
table.list tr.done td { color: var(--muted); }
