/* НАС АУТО ERP – стилове на прототипа. Цветовете следват одобрения макет („Ясен ден“, модели A–I и дъските Dashboard, Orders, Pricelist, Item, M_*); падащи менюта и превключватели в края. */
:root {
  --bg: #F3F4F6; --surface: #fff; --line: #E2E5EA; --line-soft: #EEF0F3;
  --text: #1B1F24; --text-2: #3B4250; --muted: #525966; --muted-2: #6B7280; --faint: #9AA3AF;
  --accent: #1D4ED8; --accent-dark: #1E3A8A; --accent-soft: #E8F0FE; --accent-softer: #F5F8FF;
  --sidebar: #1B2430; --sidebar-text: #C9D1DC; --sidebar-muted: #8B96A5;
  --ok-bg: #DCFCE7; --ok: #166534; --ok-dot: #16A34A;
  --warn-bg: #FEF3C7; --warn: #92400E; --warn-dot: #D97706;
  --off-bg: #F1F3F5; --off: #4B5563; --off-dot: #9AA3AF;
  --bad-bg: #FEE2E2; --bad: #991B1B; --bad-dot: #DC2626;
  --radius: 10px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* скритото е скрито, дори когато класът му задава display */
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 13px/1.45 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }
h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.25; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; } .nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.neg { color: var(--bad); } .pos { color: var(--ok); }
.right { margin-left: auto; }
kbd { font-family: inherit; font-size: 11px; border: 1px solid #D7DBE0; border-radius: 4px; padding: 0 5px; background: #fff; color: var(--text); }

/* Рамка */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 224px; flex: 0 0 224px; background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.08); color: inherit; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 30px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { color: #fff; font-size: 14px; } .brand-text small { font-size: 11px; color: var(--sidebar-muted); }
.brand-light .brand-text strong { color: var(--text); }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 12px 12px 0; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.25) transparent; }
.nav::-webkit-scrollbar { width: 6px; } .nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.25); border-radius: 3px; }
.sidebar-foot { flex: 0 0 auto; }
@media (max-height: 640px) { .sidebar { overflow-y: auto; scrollbar-width: thin; } .nav { flex: 0 0 auto; overflow: visible; } .sidebar-foot { margin-top: 8px; } }
.nav a, .sidebar-foot a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 7px; color: var(--sidebar-text); font-weight: 500; }
.nav a:hover, .sidebar-foot a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(255,255,255,.10); color: #fff; font-weight: 600; }
.nav a.disabled { opacity: .45; cursor: default; } .nav a.disabled:hover { background: none; }
.nav svg, .sidebar-foot svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 18px; }
.nav-badge { margin-left: auto; font-size: 11px; font-weight: 600; background: #F59E0B; color: var(--text); border-radius: 10px; padding: 1px 7px; }
.nav-section { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--sidebar-muted); padding: 12px 10px 3px; }
.nav-section:first-of-type { padding-top: 8px; }
.nav-settings summary { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 7px; color: var(--sidebar-text); font-weight: 500; cursor: pointer; list-style: none; }
.nav-settings summary::-webkit-details-marker { display: none; }
.nav-settings summary:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-settings summary.active { color: #fff; }
.nav-settings summary .chev { margin-left: auto; width: 14px; height: 14px; flex: 0 0 14px; transition: transform .15s; }
.nav-settings[open] summary .chev { transform: rotate(180deg); }
.nav-settings a { padding-left: 38px; font-size: 13px; }
.sidebar-foot { margin-top: auto; padding: 12px 12px 16px; display: flex; flex-direction: column; gap: 2px; }
.user { display: flex; align-items: center; gap: 10px; padding: 12px 10px 0; border-top: 1px solid rgba(255,255,255,.08); margin-top: 8px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #3B4654; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; flex: 0 0 30px; }
.user-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; } .user-text strong { color: #fff; font-weight: 500; } .user-text small { font-size: 11px; color: var(--sidebar-muted); }
.user form { margin-left: auto; } .user .link { background: none; border: 0; color: var(--sidebar-muted); cursor: pointer; font: inherit; font-size: 12px; padding: 4px; } .user .link:hover { color: #fff; }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.gsearch { position: relative; flex: 1 1 320px; max-width: 560px; }
.gsearch svg { position: absolute; left: 12px; top: 11px; width: 16px; height: 16px; fill: none; stroke: var(--muted-2); stroke-width: 2; stroke-linecap: round; }
.gsearch input { width: 100%; height: 38px; padding: 0 12px 0 36px; border: 1px solid #D7DBE0; border-radius: 8px; background: #F8F9FA; font: inherit; color: var(--text); }
.gsearch input:focus, .filters input:focus, .filters select:focus, .form input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.topbar-right { margin-left: auto; display: flex; gap: 8px; }
.gs-kbd { position: absolute; right: 10px; top: 10px; }
.step-h .n { display: inline-flex; width: 20px; height: 20px; border-radius: 10px; background: var(--text); color: #fff; font-size: 11px; align-items: center; justify-content: center; margin-right: 6px; }
.sum-total { display: flex; justify-content: space-between; align-items: baseline; } .sum-total strong { font-size: 20px; }
.ctx-sum .ctx-body { display: flex; flex-direction: column; gap: 8px; }
.ic-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
/* табовете под търсачката: последно отворените страници */
.htabs { display: flex; gap: 4px; align-items: flex-end; padding: 6px 24px 0; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; }
.htabs[hidden] { display: none; }
.htab { display: flex; align-items: center; gap: 6px; flex: none; max-width: 200px; height: 30px; padding: 0 6px 0 10px; border: 1px solid var(--line); border-bottom: 0; border-radius: 8px 8px 0 0; background: #F8F9FA; color: var(--muted); font-size: 12.5px; text-decoration: none; white-space: nowrap; cursor: pointer; user-select: none; }
.htab:hover { background: var(--accent-softer); color: var(--text); }
.htab.on { background: var(--bg); color: var(--text); font-weight: 600; border-color: #D7DBE0; margin-bottom: -1px; height: 31px; }
.htab svg { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.htab.pin svg { stroke: var(--accent); }
.htab span:not(.x) { overflow: hidden; text-overflow: ellipsis; }
.htab .x { flex: none; width: 18px; height: 18px; line-height: 17px; text-align: center; border-radius: 4px; color: var(--faint); font-size: 15px; font-weight: 400; }
.htab .x:hover { background: var(--bad-bg); color: var(--bad); }
@media (max-width: 900px) { .htabs { padding: 6px 16px 0; } }
.content { padding: 20px 24px 28px; display: flex; flex-direction: column; gap: 14px; }
.flash { padding: 10px 14px; background: var(--ok-bg); color: var(--ok); border-radius: 8px; }

/* Бутони и форми */
.btn { height: 36px; padding: 0 14px; border: 1px solid #D7DBE0; border-radius: 8px; background: #fff; color: var(--text); font: inherit; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.btn:hover { background: #F8F9FA; } .btn[disabled] { opacity: .55; cursor: not-allowed; } .btn small { font-size: 11px; color: var(--muted-2); font-weight: 400; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; } .btn-primary:hover { background: var(--accent-dark); }
/* Бутон, който е връзка: общото a:hover не бива да му сменя цвета на текста (на тъмния бутон той „изчезва“) */
a.btn:hover { color: var(--text); } a.btn-primary:hover, .btn-primary:hover { color: #fff; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; } .btn-block { width: 100%; justify-content: center; }
.form { display: flex; flex-direction: column; gap: 6px; }
.form label { font-size: 12px; font-weight: 500; color: var(--muted); margin-top: 8px; }
.form input[type=text], .form input[type=email], .form input[type=password] { height: 38px; padding: 0 12px; border: 1px solid #D7DBE0; border-radius: 8px; font: inherit; }
.form .check { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--text); margin: 10px 0 14px; }
.error { color: var(--bad); font-size: 12px; margin: 4px 0 0; }
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.auth-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 24px 28px 28px; display: flex; flex-direction: column; gap: 10px; }
.auth-card .brand { padding: 0 0 16px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }

/* Заглавие и филтри */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.page-head .sub { color: var(--muted); font-size: 12px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; }
.page-head .item-actions { flex-wrap: wrap; justify-content: flex-end; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.filters input[type=search], .filters input[type=text], .filters input[type=date] { height: 34px; padding: 0 12px; border: 1px solid #D7DBE0; border-radius: 7px; font: inherit; }
.filters input[type=search] { flex: 1 1 260px; } .filters input[type=date] { width: 150px; }
.filters select { height: 34px; padding: 0 10px; border: 1px solid #D7DBE0; border-radius: 7px; background: #fff; font: inherit; min-width: 140px; }
.filters .check { display: flex; align-items: center; gap: 7px; padding: 0 10px; height: 34px; border: 1px solid #D7DBE0; border-radius: 7px; background: #fff; cursor: pointer; }
.filters .check input { margin: 0; width: 15px; height: 15px; accent-color: var(--accent); }
.filters .meta { margin-left: auto; color: var(--muted); font-size: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-dark); font-size: 12px; font-weight: 500; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 10px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500; margin-bottom: -1px; }
.tabs a.active { color: var(--text); font-weight: 600; border-color: var(--accent); }

/* Карти и таблици */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; }
.split { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.split > .card.list { flex: 999 1 560px; }
.panel:empty { display: none; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th { font-weight: 600; font-size: 12px; color: var(--muted); text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); background: #FAFBFC; white-space: nowrap; }
td { padding: 8px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tr.row { cursor: pointer; } tr.row:hover td { background: var(--accent-softer); }
tr.row.selected td { background: var(--accent-soft); } tr.row.selected td:first-child { color: var(--accent); font-weight: 600; }
td.wrap, th.wrap { white-space: normal; }
td.idx { color: var(--faint); width: 36px; }
td .id { font-weight: 600; color: var(--text); }
.table-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.table-foot .keys { margin-left: auto; display: flex; gap: 14px; }
.pager { display: flex; gap: 6px; } .pager a, .pager span { padding: 3px 9px; border: 1px solid #D7DBE0; border-radius: 6px; background: #fff; color: var(--text); } .pager span { opacity: .5; }
table.compact th { padding: 6px 8px; } table.compact td { padding: 7px 8px; }
.empty { padding: 28px 16px; color: var(--muted); text-align: center; }

/* Състояния */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 11px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .9; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.ok::before { background: var(--ok-dot); }
.pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.warn::before { background: var(--warn-dot); }
.pill.off { background: var(--off-bg); color: var(--off); } .pill.off::before { background: var(--off-dot); }
.pill.bad { background: var(--bad-bg); color: var(--bad); } .pill.bad::before { background: var(--bad-dot); }
.pill.info { background: var(--accent-soft); color: var(--accent-dark); } .pill.info::before { background: var(--accent); }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--off-bg); color: var(--text-2); font-size: 12px; }

/* Панел с детайли */
.panel-head { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.panel-head .title-row { display: flex; align-items: flex-start; gap: 10px; }
.panel-head .close { margin-left: auto; width: 30px; height: 30px; border: 0; border-radius: 6px; background: var(--off-bg); color: var(--off); font-size: 16px; cursor: pointer; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.stat small { font-size: 11px; color: var(--muted); } .stat strong { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; } .stat .note { font-size: 11px; color: var(--muted); }
.moves { display: flex; flex-direction: column; }
.moves .mv { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); } .moves .mv:last-child { border-bottom: 0; }
.moves .d { width: 72px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; flex: 0 0 72px; }
.moves .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.moves .q { font-weight: 600; font-variant-numeric: tabular-nums; }
.section { display: flex; flex-direction: column; gap: 8px; }
.dash { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.dash .stat strong { font-size: 24px; }
.cols { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
@media (min-width: 1500px) { .cols { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; flex: none; height: auto; position: static; }
  .nav { flex-direction: row; flex-wrap: wrap; padding-bottom: 12px; }
  .sidebar-foot { padding-top: 0; }
  .content { padding: 14px 16px 20px; }
}

/* Падащи менюта с писане */
.combo { position: relative; display: inline-block; min-width: 160px; }
.combo input { width: 100%; height: 34px; padding: 0 28px 0 10px; border: 1px solid #D7DBE0; border-radius: 7px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center; font: inherit; color: var(--text); }
.combo input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.combo .combo-native { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; left: 0; top: 0; }
.combo-list { position: absolute; z-index: 20; left: 0; top: calc(100% + 4px); min-width: 100%; max-width: 360px; max-height: 300px; overflow-y: auto; margin: 0; padding: 4px; list-style: none; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(27,31,36,.12); }
.combo-list li { padding: 6px 10px; border-radius: 5px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-list li:hover, .combo-list li.active { background: var(--accent-softer); }
.combo-list li.current { font-weight: 600; }
.combo-list li:first-child { color: var(--muted); }

/* Списъци: скрол вътре в екрана, заглавие и хоризонтална лента винаги видими, редове на един ред */
.list-scroll { max-height: calc(100vh - 250px); min-height: 240px; overflow: auto; }
.list-scroll thead th { position: sticky; top: 0; z-index: 2; box-shadow: inset 0 -1px 0 var(--line); }
.ell { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ell-sm { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Плъзгащ се панел с детайли (drawer) върху таблицата */
.panel { position: fixed; top: 0; right: 0; height: 100vh; width: min(500px, 100vw); z-index: 40; background: var(--surface); box-shadow: -12px 0 32px rgba(27,31,36,.18); display: flex; flex-direction: column; }
.panel > .card { border: 0; border-radius: 0; height: 100%; }
.panel > .card > .card-body { flex: 1 1 auto; overflow-y: auto; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 39; background: rgba(27,31,36,.12); }
.split > .card.list { flex: 1 1 100%; }
@media (max-width: 900px) { .panel { width: 100vw; } }
.panel-back { padding: 0 9px; font-size: 16px; line-height: 1; }
.panel .kv { font-size: 12.5px; }

/* Пълна страница на артикул: на широк екран в две колони */
.detail-page .card-body { gap: 18px; }
@media (min-width: 1100px) {
  .detail-page .card-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px 32px; align-items: start; }
  .detail-page .card-body > :last-child { grid-column: 1 / -1; }
}

/* Тестова среда */
.test-banner { background: #FEF3C7; color: #92400E; font-size: 12px; font-weight: 500; padding: 6px 24px; border-bottom: 1px solid #FDE68A; }
.pill.test { background: #FEF3C7; color: #92400E; } .pill.test::before { background: #D97706; }

/* Икони в бутони (товарителници: проследи, етикет, статус, анулирай) */
.btn .ico { width: 16px; height: 16px; flex: 0 0 auto; }
.btn-ico { width: 28px; height: 28px; padding: 0; justify-content: center; border-radius: 7px; color: var(--muted); }
.btn-ico:hover { color: var(--text); } .btn-ico.bad { color: var(--bad); }
.btn-xs { height: 28px; padding: 0 9px; font-size: 12px; gap: 6px; }
.ico-row { display: inline-flex; align-items: center; gap: 4px; vertical-align: middle; margin-left: 4px; }
/* телефон на клиент: връзка „tel:“ с иконка, номерът не се пренася */
.phone-link { white-space: nowrap; }
.phone-link a { display: inline-flex; align-items: center; gap: 4px; }
.phone-link .ico { width: 14px; height: 14px; flex: 0 0 auto; }

/* Ходът на Монета: оцветяване на редове по състояние на обработка (поръчки от сайта) и по наличност */
tr.st-new td { background: #F0FDF4; } tr.st-new.row:hover td { background: #DCFCE7; }
tr.st-checked td { background: #EFF6FF; } tr.st-checked.row:hover td { background: #DBEAFE; }
tr.st-prepared td { background: #FFFBEB; } tr.st-prepared.row:hover td { background: #FEF3C7; }
tr.st-mismatch td { background: #FFF1F2; } tr.st-mismatch.row:hover td { background: #FFE4E6; }
tr.st-shipped td, tr.st-cancelled td { color: var(--muted); }
tr.nostock td { background: #FEE2E2; } tr.nostock td .id, tr.nostock td a.id { color: var(--bad); }
tr.short td { background: #FFF7ED; }
tr.instock td { background: #ECFDF3; } tr.instock.row:hover td { background: #DCFCE7; }
tr.row.selected.instock td { background: var(--accent-soft); }
tr.row.selected.nostock td, tr.row.selected.short td { background: var(--accent-soft); }

/* Падащо меню „Функции ›“ */
details.menu { position: relative; }
details.menu > summary { list-style: none; cursor: pointer; } details.menu > summary::-webkit-details-marker { display: none; }
details.menu .menu-body { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 300px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(27,31,36,.14); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
details.menu .menu-body form { display: flex; flex-direction: column; gap: 6px; }
details.menu .menu-body form > .btn { justify-content: flex-start; width: 100%; } details.menu .menu-body .btn small { color: var(--muted); font-weight: 400; margin-left: 6px; }
details.menu .menu-form { padding: 8px; border: 1px dashed var(--line); border-radius: 8px; }
details.menu .menu-form label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
details.menu .menu-form label.check { flex-direction: row; align-items: center; gap: 6px; }
details.menu .menu-form select, details.menu .menu-form input[type=text] { height: 34px; padding: 0 8px; border: 1px solid #D7DBE0; border-radius: 6px; font: inherit; font-size: 13px; background: #fff; }

/* Форма на документ с десен контекстен панел (клиент и артикул), както в Монета */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
@media (min-width: 1240px) { .doc-layout { grid-template-columns: minmax(0, 1fr) 340px; } .doc-layout .ctx { position: sticky; top: 16px; } }
.ctx { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.ctx-card .ctx-head { padding: 10px 14px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 13px; display: flex; gap: 8px; align-items: baseline; }
.ctx-card .ctx-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; font-size: 12.5px; min-height: 60px; }
.ctx-card .ctx-body[aria-busy=true] { opacity: .5; }
.ctx-empty { color: var(--muted); font-size: 12px; padding: 4px 0; }
.ctx-title .id { font-weight: 600; } .ctx-title .ell { display: block; max-width: 100%; }
.ctx-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; } .ctx-stats .stat { padding: 8px 10px; } .ctx-stats .stat strong { font-size: 16px; }
.ctx-table td { padding: 5px 6px; } .ctx-kv { font-size: 12px; } .ctx-kv dd.wrap { white-space: normal; display: flex; flex-wrap: wrap; gap: 4px; }
.ctx-sub { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; margin-top: 4px; }
.ctx-moves .mv { padding: 5px 0; font-size: 12px; } .ctx-moves .d { width: 64px; flex-basis: 64px; }

/* Прозорец с клавишите */
.keys-help { position: fixed; inset: 0; z-index: 60; background: rgba(27,31,36,.35); display: flex; align-items: center; justify-content: center; }
.keys-help .card { width: min(560px, 92vw); } .keys-help table td { padding: 6px 10px; } .keys-help kbd { font-size: 12px; padding: 1px 6px; }
.table-foot .keys .link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: 12px; padding: 0; }
.btn small { font-weight: 500; opacity: 1; margin-left: 2px; padding: 1px 6px; border-radius: 4px; background: rgba(0,0,0,.06); color: var(--muted); line-height: 1.4; }
.btn-primary small { background: rgba(255,255,255,.22); color: #fff; }
.btn-primary[disabled] small { color: #fff; }
.tpl-pick { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); } .tpl-pick select.mini { max-width: 240px; }
/* малки полета във формите в картите и редовете (същият вид като филтрите, височина като .btn-sm) */
input.mini, select.mini { height: 30px; padding: 0 8px; border: 1px solid #D7DBE0; border-radius: 6px; background: #fff; color: var(--text); font: inherit; font-size: 12px; box-sizing: border-box; }
input.mini:focus, select.mini:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input.mini::placeholder { color: var(--muted); }
/* чат „Помощ“ долу вдясно */
.ai-fab { position: fixed; right: 18px; bottom: 18px; z-index: 45; height: 40px; padding: 0 16px 0 12px; border: 0; border-radius: 20px; background: var(--accent); color: #fff; font: inherit; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; box-shadow: 0 6px 18px rgba(29,78,216,.35); }
.ai-fab:hover { background: var(--accent-dark); }
.ai-fab svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ai.open .ai-fab { display: none; }
.ai-box { position: fixed; right: 18px; bottom: 18px; z-index: 46; width: min(400px, calc(100vw - 24px)); height: min(600px, calc(100vh - 36px)); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 44px rgba(27,31,36,.22); display: flex; flex-direction: column; overflow: hidden; }
.ai-box[hidden] { display: none; }
.ai-head { display: flex; align-items: center; gap: 4px; padding: 10px 10px 10px 14px; border-bottom: 1px solid var(--line); }
.ai-head > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ai-head strong { font-size: 14px; } .ai-head small { color: var(--muted); font-size: 11px; }
.ai-icon { width: 30px; height: 30px; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.ai-icon:hover { background: var(--off-bg); color: var(--text); }
.ai-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ai-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.ai-hello { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; color: var(--text-2); }
.ai-chip { border: 1px solid #D7DBE0; background: #fff; border-radius: 14px; padding: 5px 11px; font: inherit; font-size: 12px; color: var(--accent); cursor: pointer; text-align: left; }
.ai-chip:hover { border-color: var(--accent); }
.ai-note { color: var(--muted); font-size: 11px; margin-top: 4px; }
.ai-msg { max-width: 92%; padding: 8px 11px; border-radius: 10px; line-height: 1.5; overflow-wrap: anywhere; }
.ai-msg p { margin: 0 0 6px; } .ai-msg p:last-child, .ai-msg ol:last-child, .ai-msg ul:last-child { margin-bottom: 0; }
.ai-msg ol, .ai-msg ul { margin: 0 0 6px; padding-left: 20px; } .ai-msg li { margin: 2px 0; }
.ai-msg code { font-size: 12px; background: var(--off-bg); padding: 0 4px; border-radius: 4px; }
.ai-me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 3px; }
.ai-bot, .ai-wait { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.ai-err { align-self: flex-start; background: var(--bad-bg); color: var(--bad); }
.ai-dots { display: inline-flex; gap: 4px; } .ai-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); animation: ai-dot 1s infinite ease-in-out; } .ai-dots i:nth-child(2) { animation-delay: .15s; } .ai-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes ai-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.ai-form { display: flex; gap: 8px; align-items: flex-end; padding: 10px; border-top: 1px solid var(--line); }
.ai-form textarea { flex: 1; resize: none; min-height: 40px; max-height: 120px; padding: 8px 10px; border: 1px solid #D7DBE0; border-radius: 8px; font: inherit; }
.ai-form textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
@media print { .ai { display: none !important; } }
/* бутоните под картата на артикул: основният на цял ред, останалите в равни колони */
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; container-type: inline-size; }
.panel-head .panel-actions { margin-top: 10px; }
/* бутон „Excel“ над списъците и справките (public/js/export.js) */
.xl-bar { display: flex; justify-content: flex-end; padding: 6px 10px 0; }
.xl-btn { display: inline-flex; align-items: center; gap: 5px; }
.xl-btn svg { width: 14px; height: 14px; fill: none; stroke: #15803D; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media print { .xl-bar { display: none !important; } }
@container (max-width: 380px) { .panel-actions > .btn:not(.btn-primary) { flex: 1 1 calc(50% - 4px); } }
.panel-actions > .btn { flex: 1 1 0; min-width: 84px; justify-content: center; padding: 0 10px; }
.panel-actions > .btn-primary, .panel-actions > form { flex: 1 0 100%; display: flex; }
.panel-actions > form > .btn { flex: 1 1 auto; justify-content: center; }
.page-head .actions .mini { height: 34px; padding: 0 8px; border: 1px solid #D7DBE0; border-radius: 6px; background: #fff; font: inherit; font-size: 12px; }

/* Каталог на справките: модулите в колони, търсене по име */
.rep-modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.rep-list { list-style: none; margin: 0; padding: 4px 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.rep-list .rep-title { font-weight: 600; }
.filters label.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.rep-result tfoot td { border-top: 2px solid var(--line); background: var(--bg); }

/* Печат на справка: само таблицата */
@media print {
  .sidebar, .topbar, .htabs, .test-banner, .filters, .page-head .sub a, .panel { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0 !important; }
  .list-scroll { max-height: none !important; overflow: visible !important; }
  .rep-result { box-shadow: none; border: 0; }
}

/* Бутони вляво под заглавието на страницата (Склад WMS) */
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 16px; }

/* Опашка за проверка (Склад WMS): чакащите са с жълта лента отляво, новият документ свети */
.queue-table { width: 100%; }
.queue-table td.empty { white-space: normal; }
.queue-table tr.q-wait td:first-child { box-shadow: inset 3px 0 0 var(--warn-dot); }
@keyframes q-flash { 0%, 60% { background: var(--warn-bg); } 100% { background: transparent; } }
.queue-table tr.q-new td { animation: q-flash 6s ease-out 1; }
/* Inter Cars: компактен ред в десния панел на формата */
.ic-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

/* Начало (макет „Ясен ден“): поздрав, броячи, поръчки на колони, „Внимание“, пратки */
.hello { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 14px; }
.hello h1 { margin: 0; font-size: 26px; font-weight: 700; }
.hello .sub { color: #5B6678; font-size: 14px; margin-top: 4px; }
.hello-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.kpi { display: flex; flex-direction: column; gap: 6px; padding: 18px; background: #FFFFFF; border: 1px solid #E3E7EE; border-radius: 14px; color: #142033; text-decoration: none; }
.kpi:hover { border-color: #B9C6E4; color: #142033; }
.kpi small { font-size: 13px; color: #5B6678; font-weight: 600; }
.kpi strong { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi span { font-size: 12px; color: #5B6678; }
.dash-row { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.dash-lanes { flex: 999 1 620px; min-width: 0; container-type: inline-size; container-name: lanes; }
.dash-lanes .card-head { gap: 10px; flex-wrap: wrap; }
.dash-side { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.lanes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 0 16px 16px; }
.lane { background: #F4F6F9; border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 320px; min-width: 0; transition: box-shadow .12s; }
.lane.over { box-shadow: inset 0 0 0 2px #2453D6; background: #EEF3FD; }
.lane-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px; }
.lane-head .n { margin-left: auto; font-size: 13px; font-weight: 700; color: #3E4A5C; font-variant-numeric: tabular-nums; }
.pill.ln-new { background: #E8EEFC; color: #1F48BC; } .pill.ln-ok { background: #E3F4EA; color: #14653E; }
.pill.ln-warn { background: #FFF1D6; color: #8A4F00; } .pill.ln-bad { background: #FDE8E6; color: #A31F14; }
.ocard { display: flex; flex-direction: column; gap: 4px; min-width: 0; background: #FFFFFF; border: 1px solid #E3E7EE; border-radius: 10px; padding: 10px 12px; color: #142033; text-decoration: none; }
.ocard:hover { border-color: #B9C6E4; color: #142033; }
.ocard.selected { border-color: #2453D6; box-shadow: 0 0 0 1px #2453D6; }
.ocard[draggable] { cursor: grab; } .ocard.dragging { opacity: .45; }
.oc-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; min-width: 0; }
.oc-top > b:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oc-top .num { flex: none; font-variant-numeric: tabular-nums; white-space: nowrap; }
.oc-who { font-size: 13px; color: #3E4A5C; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oc-meta { font-size: 12px; color: #5B6678; }
.lane-more { font-size: 13px; font-weight: 600; padding: 2px 4px; }
.lane-empty { font-size: 13px; color: #8A94A6; padding: 2px 4px; }
.alerts { display: flex; flex-direction: column; gap: 10px; }
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border-radius: 10px; color: #142033; text-decoration: none; }
a.alert[href]:hover { filter: brightness(.98); color: #142033; }
.alert .dot { width: 8px; height: 8px; border-radius: 4px; margin-top: 6px; flex: none; }
.alert b { display: block; font-size: 14px; font-weight: 600; } .alert small { display: block; font-size: 13px; color: #3E4A5C; }
.a-bad { background: #FDE8E6; } .a-bad .dot { background: #C8372D; }
.a-warn { background: #FFF1D6; } .a-warn .dot { background: #D98A00; }
.a-info { background: #E8EEFC; } .a-info .dot { background: #2453D6; }
.a-off { background: #EEF1F5; } .a-off .dot { background: #7F8CA0; }
.ship3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; text-align: center; }
.ship3 > div { background: #F4F6F9; border-radius: 10px; padding: 12px 6px; }
.ship3 strong { display: block; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ship3 small { font-size: 12px; color: #5B6678; }
/* колоните следват ширината на самата карта (меню, дясната колона и панелът я стесняват), не на екрана:
   4 колони при ≥ 860 px, 2 при по-тясно, 1 под 440 px; празните колони не държат 320 px височина */
@container lanes (max-width: 860px) { .lanes { grid-template-columns: repeat(2, minmax(0, 1fr)); } .lane { min-height: 160px; } }
@container lanes (max-width: 440px) { .lanes { grid-template-columns: 1fr; padding: 0 12px 12px; } .lane { min-height: 0; } }
.lane:not(:has(.ocard)) { min-height: 0; }
@media (max-width: 560px) { .hello h1 { font-size: 22px; } }

/* Карта на запис (макет „Ясен ден“, модел B): числата горе, разделите като табове вляво, свързаното вдясно */
.rec-stats { margin-bottom: 0; }
.rec { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.rec-main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.rec-side { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.rec-main > .tabbar { margin-bottom: -4px; }
.rec-main > .card[data-tab] { margin-top: 0 !important; }

/* Ценова листа › карта на ред от TecDoc (макет „Ясен ден“): снимка до името, бутони 1 + 3, сиви плочки */
.td-head { display: flex; gap: 14px; align-items: flex-start; }
.td-thumb-main { width: 84px; height: 84px; flex: none; border-radius: 12px; background: #F4F6F9; border: 1px solid #E3E7EE; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.td-thumb-main img { max-width: 100%; max-height: 100%; object-fit: contain; }
.td-thumb-main.empty { font-size: 11px; color: #5B6678; text-align: center; padding: 4px; }
.td-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.td-title h2 { margin: 0; font-size: 20px; }
.td-title .tags { margin-top: 6px; }
.td-actions, .td-sell { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.td-actions > .td-sell { grid-column: 1 / -1; margin-top: 0; }
.td-actions .btn-primary, .td-sell .btn-primary { grid-column: 1 / -1; height: 44px; justify-content: center; font-size: 15px; }
.td-actions .btn, .td-sell .btn { justify-content: center; }
.td-actions > a.btn:not(.btn-primary):last-child:nth-child(5) { grid-column: 1 / -1; }
.td-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.td-tile, .td-card .stat, body.ui-v2 .td-card .stat { display: flex; flex-direction: column; gap: 2px; background: #F4F6F9; border: 0; border-radius: 10px; padding: 10px; }
.td-tile small { font-size: 12px; color: #5B6678; font-weight: 600; }
.td-tile strong { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.td-tile .note { font-size: 12px; color: #3E4A5C; } .td-tile .note.ok { color: #14653E; }
.td-thumb img { width: 52px; height: 52px; object-fit: contain; border: 1px solid #E3E7EE; border-radius: 8px; background: #fff; padding: 2px; }

/* Панели на документ и контрагент (макет „Ясен ден“, дъска Orders) */
.doc-kicker { font-size: 12px; color: #5B6678; font-weight: 600; letter-spacing: .02em; }
.doc-card .title-row h2 { margin: 2px 0 0; font-size: 22px; }
.doc-steps { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.doc-steps li { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: #5B6678; }
.doc-steps li span { height: 6px; border-radius: 3px; background: #E3E7EE; }
.doc-steps li.on span { background: #2453D6; }
.doc-steps li.cur { font-weight: 700; color: #1F48BC; }
.doc-state-note { margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: #EEF1F5; color: #3E4A5C; font-size: 13px; font-weight: 600; }
.doc-state-note.bad { background: #FDE8E6; color: #A31F14; }
.doc-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.doc-actions > .btn-primary { grid-column: 1 / -1; height: 44px; font-size: 15px; }
.doc-actions .btn, .doc-actions form .btn { justify-content: center; width: 100%; }
.doc-actions form { margin: 0; }
.doc-actions > :last-child:nth-child(even):not(.btn-primary) { grid-column: auto; }
.doc-kv { background: #F4F6F9; border-radius: 12px; padding: 14px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; font-size: 14px; }
.doc-kv > span:nth-child(odd) { color: #5B6678; }
.doc-kv > span:nth-child(even) { min-width: 0; overflow-wrap: anywhere; }
.doc-kv .pos { color: #14653E; } .doc-kv .neg { color: #A31F14; }
.doc-lines { display: flex; flex-direction: column; gap: 8px; }
.doc-line { display: flex; gap: 12px; align-items: center; padding: 10px; border: 1px solid #E3E7EE; border-radius: 10px; }
.dl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dl-main .id { font-weight: 700; font-size: 14px; }
.dl-sub { font-size: 12px; color: #5B6678; }
.doc-line .num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-warn { margin-top: 8px; font-size: 13px; color: #8A4F00; background: #FFF1D6; border-radius: 10px; padding: 10px; }
.doc-card .card-body { display: flex; flex-direction: column; gap: 14px; }
[data-tabs-ready] > .section > .tab-h { display: none; }

/* Падащо меню с връзки (напр. „Печат ▾“ в офертата): всяка възможност на два реда */
details.menu .menu-body > a.btn { width: 100%; height: auto; min-height: 40px; padding: 8px 12px; flex-direction: column; align-items: flex-start; justify-content: center; gap: 1px; text-align: left; }
details.menu .menu-body > a.btn small { margin-left: 0; font-size: 12px; }
details.print-menu .menu-body { min-width: 260px; }
/* Избор от две възможности като превключвател (сегменти) */
.seg-toggle { display: inline-flex; padding: 3px; gap: 3px; border-radius: 10px; background: #EEF1F5; }
.seg-toggle label { margin: 0; }
.seg-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.seg-toggle span { display: inline-flex; align-items: center; height: 32px; padding: 0 14px; border-radius: 8px; font-size: 13px; font-weight: 600; color: #3E4A5C; cursor: pointer; white-space: nowrap; }
.seg-toggle input:checked + span { background: #FFFFFF; color: #142033; box-shadow: 0 1px 3px rgba(14,26,43,.12); }
.seg-toggle input:focus-visible + span { outline: 2px solid #2453D6; outline-offset: 1px; }
