:root {
  --blue: #1f6feb;
  --blue-d: #1557c0;
  --blue-l: #e8f0fe;
  --ink: #1b2330;
  --ink-2: #4a5566;
  --muted: #7a8699;
  --line: #e3e7ee;
  --bg: #f5f7fa;
  --card: #ffffff;
  --red: #d93025;
  --red-l: #fdecea;
  --green: #188038;
  --green-l: #e6f4ea;
  --amber: #b06000;
  --amber-l: #fef3e0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); background: var(--bg);
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; font-weight: 650; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 650; }
h3 { font-size: 14px; margin: 0 0 8px; }
code { background: #eef1f5; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex: 0 0 220px; background: #0f1724; color: #cfd6e2;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: block; padding: 18px 18px 14px; font-weight: 700; font-size: 18px; color: #fff; letter-spacing: .2px; }
.brand:hover { text-decoration: none; }
.brand small { font-weight: 500; font-size: 11px; color: #8fa1bb; margin-left: 4px; letter-spacing: 1px; }
.brand-b { color: #4d8dff; }
.brand-lg { color: var(--ink); text-align: center; font-size: 24px; padding: 0 0 12px; }
.sidebar nav { flex: 1; padding: 6px 10px; overflow-y: auto; }
.sidebar nav a { display: block; padding: 8px 12px; color: #cfd6e2; border-radius: 8px; margin-bottom: 2px; }
.sidebar nav a:hover { background: #1b2638; text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--blue); color: #fff; }
.nav-sep { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #6f7f97; padding: 16px 12px 6px; }
.sidebar-foot { padding: 12px; border-top: 1px solid #1f2a3d; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.user-chip { color: #fff; font-size: 13px; line-height: 1.2; }
.user-chip small { display: block; color: #8fa1bb; font-size: 11px; }
.sidebar .btn-ghost { color: #cfd6e2; border-color: #2a3850; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); padding: 10px 24px; display: flex; gap: 12px; align-items: center; position: sticky; top: 0; z-index: 5; }
.global-search { flex: 1; max-width: 520px; }
.global-search input { width: 100%; }
.btn.menu-toggle { display: none; }
.content { padding: 24px; max-width: 1400px; width: 100%; }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: -240px; z-index: 20; transition: left .2s; }
  .sidebar.open { left: 0; }
  .btn.menu-toggle { display: inline-flex; }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
}

/* ---------- components ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .form-grid .span-2 { grid-column: auto; } }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 550; cursor: pointer; line-height: 1.2; white-space: nowrap;
}
.btn:hover { background: #f0f3f7; text-decoration: none; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-d); }
.btn-danger { color: var(--red); border-color: #f3c2bd; }
.btn-danger:hover { background: var(--red-l); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; margin-top: 6px; }
.link-btn { background: none; border: 0; color: var(--blue); cursor: pointer; font: inherit; padding: 0; }
.link-btn.danger { color: var(--red); }
form.inline { display: inline; }

label { display: block; font-size: 13px; color: var(--ink-2); font-weight: 550; margin-bottom: 10px; }
label .req { color: var(--red); }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=date], input[type=tel], select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid #cfd6e0; border-radius: 8px;
  font: inherit; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd3fb; border-color: var(--blue); }
textarea { min-height: 70px; resize: vertical; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.check input { width: auto; margin: 0; }
.code-input { font-size: 24px; letter-spacing: 6px; text-align: center; font-family: ui-monospace, Menlo, Consolas, monospace; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid transparent; }
.alert-error { background: var(--red-l); color: #8c1d18; border-color: #f6c7c2; }
.alert-success { background: var(--green-l); color: #0d5224; border-color: #bfe3ca; }
.alert-info { background: var(--blue-l); color: #174ea6; border-color: #c6dafc; }
.alert-warn { background: var(--amber-l); color: #7a4300; border-color: #f7d8a8; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef1f5; color: var(--ink-2); white-space: nowrap; }
.badge-red { background: var(--red-l); color: var(--red); }
.badge-green { background: var(--green-l); color: var(--green); }
.badge-blue { background: var(--blue-l); color: var(--blue-d); }
.badge-amber { background: var(--amber-l); color: var(--amber); }
.bf { background: var(--red); color: #fff; padding: 2px 7px; border-radius: 5px; font-weight: 700; font-size: 12px; }

/* tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.t th { font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; background: #fafbfc; }
table.t tbody tr:hover { background: #f8fafd; }
table.t tr.row-link { cursor: pointer; }
table.t tr.row-bf td { background: #fff4f3; }
table.t tr.row-bf td:first-child { box-shadow: inset 3px 0 0 var(--red); }
table.t tr.row-cancelled td { color: var(--muted); text-decoration: line-through; }
table.t td.num, table.t th.num { text-align: right; white-space: nowrap; }
table.t.compact th, table.t.compact td { padding: 6px 8px; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

.serial-form { display: flex; gap: 4px; min-width: 200px; }
.serial-form input { margin: 0; padding: 5px 8px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 550; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.active { color: var(--blue); border-bottom-color: var(--blue); }
.tabs .count { background: #eef1f5; border-radius: 999px; padding: 0 7px; font-size: 12px; margin-left: 4px; }

/* order cards */
.order-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; box-shadow: var(--shadow); overflow: hidden; }
.order-card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; background: #fafbfd; border-bottom: 1px solid var(--line); }
.order-card-head h3 { margin: 0; font-size: 15px; }
.order-dates { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.order-dates b { color: var(--ink); }
.order-card .table-wrap { padding: 0 6px; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .n { font-size: 22px; font-weight: 700; }
.stat .l { font-size: 12px; color: var(--muted); }

.dl { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

.pager { display: flex; gap: 4px; margin-top: 14px; flex-wrap: wrap; }
.pager a, .pager span { padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.pager a.active { background: var(--blue); color: #fff; border-color: var(--blue); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters label { margin: 0; }
.filters input, .filters select { min-width: 160px; }

.photos { display: flex; gap: 10px; flex-wrap: wrap; }
.photo { position: relative; width: 150px; }
.photo img { width: 150px; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.photo form { margin-top: 4px; }

.lines-table input, .lines-table select { margin: 0; }
.lines-table td { vertical-align: top; }
.totals { margin-left: auto; width: 320px; max-width: 100%; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.totals .grand { font-weight: 700; font-size: 16px; border-top: 1px solid var(--line); padding-top: 8px; }

.lookup { position: relative; }
.lookup-results { position: fixed; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 2000; max-height: 280px; overflow-y: auto; }
.lookup-results div { padding: 8px 10px; cursor: pointer; border-bottom: 1px solid #f0f2f5; }
.lookup-results div:hover, .lookup-results div.hl { background: var(--blue-l); }
.lookup-results small { color: var(--muted); display: block; }

/* auth */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; background: linear-gradient(160deg, #0f1724, #1c2b45); }
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: 14px; padding: 28px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.auth-card h1 { font-size: 18px; text-align: center; }
.steps { padding-left: 20px; color: var(--ink-2); }
.qr { display: flex; justify-content: center; margin: 12px 0; }
.qr svg, .qr img { width: 200px; height: 200px; }
.secret { font-size: 14px; letter-spacing: 1px; user-select: all; }

/* ---------- document (invoice) ---------- */
.doc-toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.doc-paper { background: #fff; max-width: 820px; margin: 0 auto; padding: 36px 40px; border: 1px solid var(--line); box-shadow: var(--shadow); color: #111; font-size: 13px; }
.doc-top { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--blue); padding-bottom: 12px; margin-bottom: 16px; }
.doc-logo { font-size: 22px; font-weight: 800; }
.doc-title { text-align: right; }
.doc-title .type { font-size: 22px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; }
.doc-title .no { font-size: 15px; margin-top: 2px; }
.doc-title .orig { display: inline-block; margin-top: 6px; border: 1px solid #111; padding: 1px 10px; font-weight: 700; font-size: 12px; letter-spacing: 2px; }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.doc-party { border: 1px solid #d5d9e0; border-radius: 6px; padding: 10px 12px; }
.doc-party h4 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #555; }
.doc-party .nm { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.doc-party table td { padding: 1px 8px 1px 0; vertical-align: top; }
.doc-party table td:first-child { color: #555; white-space: nowrap; }
.doc-meta { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 12px; }
.doc-lines { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.doc-lines th { background: #f0f3f8; font-size: 11px; text-transform: uppercase; text-align: left; padding: 6px 8px; border: 1px solid #d5d9e0; }
.doc-lines td { padding: 6px 8px; border: 1px solid #d5d9e0; vertical-align: top; }
.doc-lines .num { text-align: right; white-space: nowrap; }
.doc-sum { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.doc-sum table { border-collapse: collapse; min-width: 280px; }
.doc-sum td { padding: 4px 8px; border: 1px solid #d5d9e0; }
.doc-sum tr.grand td { font-weight: 800; font-size: 14px; background: #f0f3f8; }
.doc-words { font-style: italic; margin: 6px 0 14px; }
.doc-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
.doc-sign { border-top: 1px solid #999; padding-top: 4px; margin-top: 44px; font-size: 12px; color: #444; }
.doc-cancelled { color: var(--red); font-weight: 800; font-size: 26px; text-align: center; border: 3px solid var(--red); padding: 6px; margin-bottom: 12px; letter-spacing: 4px; }
.doc-note { margin-top: 12px; font-size: 12px; color: #333; }

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .sidebar, .topbar, .doc-toolbar, .alert, .no-print { display: none !important; }
  .content { padding: 0; max-width: none; }
  .doc-paper { border: 0; box-shadow: none; padding: 0; max-width: none; }
  a { color: inherit; }
}

/* ---------- фактура в стила на БМ Орион ---------- */
.inv { font-family: Calibri, Carlito, "Segoe UI", Arial, sans-serif; font-size: 13px; color: #000; padding: 32px 48px; }
.inv-head { display: flex; justify-content: space-between; align-items: flex-start; }
.inv-logo { width: 78px; height: auto; }
.inv-co { text-align: right; color: #888; font-size: 11px; line-height: 1.7; }
.inv-title { text-align: center; font-size: 17px; font-weight: 700; margin: 26px 0 30px; letter-spacing: .3px; }
.inv-boxes { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; }
.inv-box { border: 1.5px solid #000; padding: 4px 6px; min-height: 204px; line-height: 1.45; }
.inv-box .nm { font-weight: 700; }
.inv-box table { border-collapse: collapse; }
.inv-box td { padding: 0; }
.inv-box td:first-child { width: 146px; }
.inv-gap { margin-top: 18px; }
.inv-meta { margin-top: 40px; border-collapse: collapse; }
.inv-meta td { padding: 1px 0; }
.inv-meta td:first-child { width: 146px; }
.inv-details { margin: 22px 0 28px; }
.inv-lines { width: 100%; border-collapse: collapse; }
.inv-lines th, .inv-lines td { border: 1px solid #bbb; padding: 3px 4px; }
.inv-lines th { text-align: left; font-weight: 700; font-size: 12px; padding: 7px 4px; border-bottom: 2px solid #999; }
.inv-lines .c-qty { text-align: right; width: 80px; }
.inv-lines .c-num { text-align: right; width: 82px; white-space: nowrap; }
.inv-lines tr.sum td { border-left: 0; border-right: 0; }
.inv-lines tr.sum td:last-child { border-left: 1px solid #bbb; border-right: 1px solid #bbb; }
.inv-lines tr.sum td[colspan="4"] { border: 1px solid #bbb; }
.inv-lines tr.sum td.c-num[colspan] { width: auto; }
.inv-sn { color: #333; font-size: 12px; }
.inv-pay { margin-top: 26px; border-collapse: collapse; }
.inv-pay td { padding: 1px 0; }
.inv-pay td:first-child { width: 146px; }
.inv-sign { margin-top: 36px; }
.inv-sign .inv-box { min-height: 110px; }
.inv-foot { margin-top: 26px; color: #888; font-size: 10.5px; }
@media print { .inv { padding: 0; } }

.service-table td { vertical-align: top; }
.service-table td.pre { white-space: pre-wrap; }
.service-table tr.add-row td { background: #f4f8ff; }
.service-table tr.add-row input, .service-table tr.add-row textarea { margin: 0; }
.service-table tr.add-row textarea { min-height: 38px; }
@media print {
  .app, .main { display: block; }
  .inv { padding: 0 3px; font-size: 12px; }
  .inv-title { margin: 14px 0 18px; }
  .inv-box { min-height: 170px; }
  .inv-meta { margin-top: 22px; }
  .inv-details { margin: 12px 0 14px; }
  .inv-pay { margin-top: 16px; }
  .inv-sign { margin-top: 20px; }
  .inv-sign .inv-box { min-height: 95px; }
  .inv-lines tr { page-break-inside: avoid; }
}

.assign-form { display: flex; gap: 4px; min-width: 200px; }
.assign-form .lookup { flex: 1; }
.assign-form input[type=search] { margin: 0; padding: 5px 8px; font-size: 13px; }
.lines-table .lookup input[type=search] { margin: 0; }
.lines-table .lookup-picked { margin-top: 2px; }
.deposit-box { background: #fafbfd; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.deposit-box label { margin-bottom: 4px; }
.lines-table select[name="item_type[]"] { min-width: 130px; }
.lines-table select[name="item_deposit_state[]"] { min-width: 165px; }
.lines-table input[name="item_qty[]"] { min-width: 64px; }

/* ---------- статистика ---------- */
.kpis .stat .n { font-size: 20px; }
.delta { display: block; font-size: 11.5px; font-weight: 600; margin-top: 4px; }
.delta.up { color: #1a7f37; }
.delta.down { color: var(--red); }
.stats.mini { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); margin-bottom: 0; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart .bar { fill: var(--blue); }
svg.chart .bar-row:hover .bar { fill: var(--blue-d); }
svg.chart .hit { fill: transparent; }
svg.chart .bar-row:hover .hit { fill: #f3f6fb; }
svg.chart .lbl { font-size: 12.5px; fill: var(--ink); }
svg.chart .val { font-size: 12px; fill: var(--ink-2); font-variant-numeric: tabular-nums; }
svg.chart .axis { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
svg.chart .grid { stroke: #edf0f4; stroke-width: 1; }
svg.chart .base { stroke: #c9d1dc; stroke-width: 1; }
.table-toggle { margin-top: 10px; }
.table-toggle summary { cursor: pointer; color: var(--blue); font-size: 13px; }
h3.sub { font-size: 14px; margin: 18px 0 8px; }

/* ---------- резервирана / продадена ---------- */
.sale-cell { min-width: 230px; }
.sale-cell .badge { margin: 2px 0; }
.sell-form { display: flex; gap: 4px; align-items: center; margin-top: 4px; }
.sell-form input[type=date] { margin: 0; padding: 4px 6px; font-size: 12.5px; width: auto; }
.btn-sold { background: var(--green-l); border-color: #b7dfc3; color: var(--green); }
.btn-sold:hover { background: #d3eedb; }
.sale-actions { margin-top: 14px; }
.sale-actions:empty { display: none; }

/* ---------- тестова версия ---------- */
.test-banner { position: sticky; top: 0; z-index: 1000; background: #c2410c; color: #fff; text-align: center; font-weight: 700; font-size: 13px; padding: 6px 12px; letter-spacing: .3px; }

/* ---------- протокол + печат (полета като в PDF фактурите, без празна 2-ра страница) ---------- */
.protocol { margin-top: 18px; }
.prot-intro { line-height: 1.7; margin: 10px 0 18px; }
.prot-lines td, .prot-lines th { padding: 6px 6px; }
.prot-sign { margin-top: 60px; }
.prot-line { margin-top: 18px; }
.inv-lines tr.sum td:first-child { border-left: 1px solid #bbb; }
@media print {
  @page { size: A4; margin: 0; }
  html, body, .app, .main, .content { height: auto !important; min-height: 0 !important; overflow: visible !important; }
  .test-banner { display: none !important; }
  .doc-paper.inv { padding: 15mm 17mm 12mm !important; margin: 0 !important; box-sizing: border-box; width: 210mm; }
  .protocol { break-before: page; page-break-before: always; margin-top: 0 !important; }
  .inv-lines th, .inv-lines td { border-color: #888 !important; }
  .inv-lines { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

.row-special td { background: #fffbeb; }
.line-buttons { display: flex; gap: 6px; flex-wrap: wrap; }

.pay-status { max-width: 820px; margin: 0 auto 12px; padding: 10px 14px; border-radius: 8px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.pay-status.unpaid { background: var(--red-l); color: var(--red); }
.pay-status.paid { background: var(--green-l); color: var(--green); }

/* ---------- плащане по машина / документи ---------- */
.btn-paid { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn-paid:hover { background: #15803d; color: #fff; }
.btn-partial { background: var(--amber-l); border-color: #f3d38a; color: var(--amber); }
.pay-box .btn { margin-left: 8px; }
.upload-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-top: 12px; }
.upload-form label { margin: 0; }
.dropzone { flex: 1; min-width: 260px; border: 2px dashed #c9d3e2; border-radius: 10px; padding: 18px; text-align: center; cursor: pointer; color: var(--ink-2); font-weight: 500; position: relative; }
.dropzone.over { border-color: var(--blue); background: var(--blue-l); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dz-files { display: block; margin-top: 6px; }
.sale-cell .assign-form { flex-wrap: wrap; min-width: 230px; }
.sale-cell .assign-form .lookup { flex: 1 1 100%; }

/* ---------- Поръчки ADMIN ---------- */
.nav-admin { color: #fca5a5 !important; }
.admin-card { border-color: #fecaca; background: #fffafa; }
input.missing, input.soft-missing:placeholder-shown { background: #fff7d6; border-color: #f3d38a; }
.cost-table input { min-width: 80px; margin: 0; padding: 5px 7px; }
.cost-table input.fx { min-width: 70px; color: var(--muted); }
.pos { color: #15803d; }
.neg { color: var(--red); }
.fin-summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-top: 16px; }
.fin-summary > div { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fff; display: flex; flex-direction: column; gap: 2px; }
.fin-summary span { font-size: 12px; color: var(--muted); }
.fin-summary b { font-size: 17px; }
.fin-summary small { color: var(--muted); font-size: 11.5px; }
.fin-summary .tot { background: #f6f8fb; }
.fin-summary .profit b { font-size: 20px; }
.pin-wrap { display: flex; justify-content: center; padding-top: 40px; }
.pin-card { max-width: 380px; width: 100%; text-align: center; }
.pin-card form { display: flex; flex-direction: column; gap: 10px; align-items: stretch; text-align: left; }
.pin-input { font-size: 28px; letter-spacing: 14px; text-align: center; }

/* ---------- части / логистика ---------- */
.row-muted td { color: var(--muted); }
.ship-new { background: #ffedd5; color: #c2410c; }
.ship-sent { background: var(--green-l); color: var(--green); }
.ship-returned { background: var(--red-l); color: var(--red); }
tr.ship-row-new td:first-child { border-left: 4px solid #f97316; }
tr.ship-row-sent td:first-child { border-left: 4px solid #16a34a; }
tr.ship-row-returned td:first-child { border-left: 4px solid var(--red); }
.ship-status-form { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; min-width: 300px; }
.ship-status-form select, .ship-status-form input { margin: 0; padding: 4px 6px; font-size: 12.5px; width: auto; }
.ship-status-form input[name=tracking] { width: 120px; }

/* ---- 27.10 ---- */
/* нови редове: по-широки полета, клиент като малък бутон с изскачащ прозорец */
.new-items input[name="item_cost_usd[]"], .new-items input[name="item_deposit[]"] { min-width: 130px; }
.new-items input[name="item_price[]"] { min-width: 115px; }
.new-items input[name="item_transport[]"], .new-items input[name="item_vatdiff[]"] { min-width: 95px; }
.client-pick { display: flex; align-items: center; gap: 6px; min-width: 0; }
.client-pick .cp-btn { padding: 3px 8px; flex: 0 0 auto; }
.client-pick .cp-btn.picked { background: var(--blue-l); border-color: #b9d1fb; }
.client-pick .cp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 110px; }
.client-dialog { border: 1px solid var(--line); border-radius: 12px; padding: 16px; width: min(460px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.client-dialog::backdrop { background: rgba(15,23,42,.35); }
.client-dialog .cd-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.client-dialog .cd-foot { margin-top: 10px; text-align: right; }
/* непрочетени промени */
.nav-badge { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 6px; border-radius: 999px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.unread-dot { color: var(--red); font-size: 11px; vertical-align: super; }
tr.row-unread td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.badge-unread { background: var(--red); color: #fff; }
/* Поръчки ADMIN: транспорт DHL и ДДС разлика */
.admin-card .transport-form { margin-top: 10px; padding-top: 10px; border-top: 1px dashed #fecaca; }
.vat-cell { position: relative; }
.vat-cell input.vat-red, .vat-red-sample { background: #fde8e8; border-color: #f5a9a9; color: var(--red); }
.vat-red-sample { padding: 0 4px; border-radius: 4px; border: 1px solid #f5a9a9; }
.vat-tag { display: block; font-size: 10px; color: var(--muted); margin-top: 1px; }
/* Детайли на машина: начин на плащане, фактури, остатък */
.pay-modes { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.pay-rows { margin-top: 6px; }
.pay-rows td { padding: 5px 8px; }
.pay-rows tr.doc-row td { color: var(--green); background: var(--green-l); }
.pay-rows tr.doc-row a { color: var(--green); font-weight: 600; }
.pay-rows tr.tot td { border-top: 2px solid var(--line); font-weight: 600; }
.adv-attach { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-top: 10px; padding: 10px; border: 1px dashed var(--line); border-radius: 8px; }
.adv-attach[hidden] { display: none; }
.adv-attach label { margin: 0; }
.adv-attach select { min-width: 260px; }
.pay-foot { margin-top: 10px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.default-submit { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* 03.11 – сортиране по колони */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--blue); }
a.sort-link { color: inherit; white-space: nowrap; }
a.sort-link:hover, a.sort-link.active, th[data-dir] { color: var(--blue); }
.sort-hint { color: var(--muted); opacity: .55; font-weight: 400; }
/* 03.11 – прозорец за потвърждение (вместо браузърния confirm) */
.cmodal-back { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.cmodal { background: var(--card); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(16, 24, 40, .25); padding: 20px 22px; max-width: 420px; width: 100%; }
.cmodal p { margin: 0 0 18px; font-size: 15px; color: var(--ink); }
.cmodal-actions { display: flex; justify-content: flex-end; gap: 8px; }
/* 03.11 – надплатена машина */
.btn-over { background: var(--red-l); border-color: #f5b5ae; color: var(--red); }
.over-note { color: var(--red); font-weight: 600; }
input.locked { background: var(--bg, #f3f4f6); color: var(--muted, #6b7280); cursor: not-allowed; }

/* 26.11: номенклатура – снимки и ID на машината */
.model-cell { display: flex; align-items: center; gap: 8px; }
.cat-thumb { width: 30px; height: 30px; object-fit: contain; border-radius: 6px; background: #fff; border: 1px solid var(--line); flex: none; display: inline-block; vertical-align: middle; }
.cat-thumb-lg { width: 48px; height: 48px; }
.cat-thumb-xl { width: 140px; height: 140px; }
.cat-noimg { background: var(--bg); }
.item-uid { font-size: 11px; letter-spacing: .02em; }
.catalog-table td { vertical-align: middle; }
table.t tr.row-off td { opacity: .55; }
.cat-select { width: 100%; min-width: 220px; }
.adv-note { margin-top: 3px; }
.adv-note.warn { color: var(--amber); font-weight: 600; }
.cat-edit-img { margin: 4px 0; }
