/* Локален CSS. Без CDN, без външни шрифтове. Тъмна гама по подразбиране,
   светла при `html[data-theme="light"]` (изборът е в localStorage „sklad.theme“). */

/* Цикламеният акцент е един за двете теми и се пише само тук: светлата тема
   не го предефинира. Текстът върху него (`--accent-fg`) е тъмен и в двете. */
:root {
  --accent: #F65DA5;
  --accent-hover: #FB79B6;
  --accent-fg: #14161A;
}

/* Тъмна тема — стойностите са същите, които бяха твърдо в правилата. */
:root {
  color-scheme: dark;
  --bg: #111315;
  --panel: #1B1E22;
  --panel-soft: #23272C;
  --fg: #E8EAED;
  --muted: #9AA0A6;
  --line: #2A2F36;
  --error: #FF7B85;
  --ok: #5FD38D;
  --warn: #E5B25D;
  --field-bg: var(--panel-soft);
  --field-line: var(--line);
  --hover: #2E343B;
  --banner-bg: #3A2E12;
  --row-dim: #191C20;
  --row-dispatched: #242017;
  --row-picked: #172018;
  --shadow: rgba(0, 0, 0, .45);
  /* Графиките: мрежа, нулева линия, числа по осите и гамата на дяловете. */
  --chart-grid: #2A2F36;
  --chart-zero: #3A414A;
  --chart-text: #9AA0A6;
  --series-0: var(--accent);
  --series-1: #5DA9F6;
  --series-2: #5FD38D;
  --series-3: #E5B25D;
  --series-4: #B38DF6;
  --series-5: #F68A5D;
  --series-6: #5DD3D0;
  --series-7: #9AA0A6;
}

/* Светла тема: почти бял фон, бели панели, тъмен текст. Цветовете за грешка,
   „готово“ и предупреждение са по-тъмни, за да се четат на бяло и на слънце. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F5F6F8;
  --panel: #FFFFFF;
  --panel-soft: #ECEEF1;
  --fg: #14171B;
  --muted: #555B63;
  --line: #D3D7DD;
  --error: #C4202F;
  --ok: #17753F;
  --warn: #8A5700;
  --field-bg: #FFFFFF;
  --field-line: #B7BDC5;
  --hover: #DFE3E8;
  --banner-bg: #FFF0D1;
  --row-dim: #EFF0F2;
  --row-dispatched: #FBF2DE;
  --row-picked: #E4F4E9;
  --shadow: rgba(0, 0, 0, .16);
  --chart-grid: #E2E5E9;
  --chart-zero: #A9B0B8;
  --chart-text: #555B63;
  --series-1: #2F78C9;
  --series-2: #1E8A4C;
  --series-3: #B07A12;
  --series-4: #7C4FD6;
  --series-5: #D4561E;
  --series-6: #14908C;
  --series-7: #7A8088;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 15px;
}

.banner {
  background: var(--banner-bg);
  color: var(--warn);
  padding: 8px 16px;
  font-weight: 700;
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar .brand { font-weight: 700; font-size: 18px; text-decoration: none; color: var(--accent); }
.topbar nav a { margin-right: 16px; color: var(--fg); text-decoration: none; }
.topbar nav a:hover { text-decoration: underline; color: var(--accent); }
.topbar .user { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); }

/* Превключвател Тъмна / Светла. Кой бутон свети решава data-theme на html,
   не скрипт — така и при първото рисуване е вярно. */
.theme-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.theme-switch button { border: 0; border-radius: 0; padding: 3px 10px; font-size: 13px; background: var(--panel-soft); color: var(--muted); }
.theme-switch button + button { border-left: 1px solid var(--line); }
.theme-switch button:hover { background: var(--hover); color: var(--fg); }
:root:not([data-theme="light"]) .theme-switch [data-theme-set="dark"],
:root[data-theme="light"] .theme-switch [data-theme-set="light"] {
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}

main { padding: 16px; }

a { color: var(--accent); }

footer {
  padding: 12px 16px;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  gap: 24px;
  border-top: 1px solid var(--line);
}

h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 17px; margin: 0 0 12px; font-weight: 600; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
  max-width: 900px;
}
.card.narrow { max-width: 420px; margin: 40px auto; }

label { display: block; margin: 12px 0 4px; font-weight: 600; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; margin: 0 12px 0 0; }
label.small { font-size: 12px; }

input[type=text], input[type=search], input[type=password], input[type=number], select, textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--field-line);
  border-radius: 4px;
  background: var(--field-bg);
  color: var(--fg);
  font: inherit;
}
input[type=text]:focus, input[type=search]:focus, input[type=password]:focus,
input[type=number]:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}
input[type=checkbox] { accent-color: var(--accent); }
::placeholder { color: var(--muted); }

.filters input[type=search], .filters select { width: auto; min-width: 200px; }
.filters input[type=date], .filters input[type=number], .filters input[type=text] { width: auto; min-width: 140px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.inline-form { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.inline-form input { max-width: 320px; }

button, .button {
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel-soft);
  color: var(--fg);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .button:hover { background: var(--hover); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
button.primary:hover, .button.primary:hover { background: var(--accent-hover); }
button.link { border: none; background: none; color: var(--accent); padding: 2px 4px; }
button.link:hover { text-decoration: underline; background: none; }

.row { display: flex; gap: 8px; margin-top: 16px; }

.flashes { list-style: none; padding: 0; margin: 0 0 12px; }
.flash { padding: 8px 12px; border-radius: 4px; margin-bottom: 6px; border: 1px solid var(--line); background: var(--panel); }
.flash.error { border-color: var(--error); color: var(--error); }
.flash.ok { border-color: var(--ok); color: var(--ok); }

.field-error { color: var(--error); margin: 4px 0 0; font-size: 13px; }
.note { color: var(--muted); font-size: 13px; }

table.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); }
table.grid th, table.grid td { border: 1px solid var(--line); padding: 6px 8px; vertical-align: top; text-align: left; }
table.grid th { background: var(--accent); color: var(--accent-fg); font-size: 13px; }
/* Кликваеми заглавия: стрелката идва от CSS, без скрипт и без нов текст в клетката. */
table.grid th a.sort { color: inherit; text-decoration: none; }
table.grid th a.sort:hover, table.grid th a.sort:focus { text-decoration: underline; }
table.grid th[aria-sort] a.sort::after { content: " \25B2"; font-size: 10px; }
table.grid th[aria-sort="descending"] a.sort::after { content: " \25BC"; }
table.grid td.num, table.grid th.num { text-align: right; white-space: nowrap; }
table.grid td.code { font-family: Consolas, "Courier New", monospace; }
table.grid td.comment { max-width: 260px; color: var(--muted); font-size: 13px; }
table.grid td.strong { font-weight: 700; }
/* Ред „Общо“: обикновен ред на таблицата, същите колони като thead/tbody. */
table.grid tfoot tr { display: table-row; }
table.grid tfoot td { background: var(--panel-soft); font-weight: 700; }
table.grid tfoot tr.totals td:first-child { color: var(--accent); }
table.grid tr.archived td { background: var(--row-dim); color: var(--muted); }
/* Лист продажби: приключените редове не крещят. */
table.grid tr.status-cancelled td,
table.grid tr.status-returned td { background: var(--row-dim); color: var(--muted); }
table.grid tr.status-dispatched td { background: var(--row-dispatched); }
table.grid tr.status-picked_up td { background: var(--row-picked); }
table.grid td.actions input[type=text] { width: auto; min-width: 120px; margin-right: 4px; }
table.small-table { max-width: 360px; margin-bottom: 12px; }

td.actions { white-space: nowrap; }
td.actions form { display: inline; }
td.actions a { margin-right: 8px; }

.tag { background: var(--panel-soft); border-radius: 3px; padding: 1px 5px; font-size: 11px; color: var(--muted); }
.neg { color: var(--error); }

.pager { margin-top: 12px; display: flex; gap: 6px; }
.pager .current { font-weight: 700; color: var(--accent); }

/* Няколко отметки в един филтър: категории и доставчици. */
.multi {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 10px 6px;
  margin: 0;
  max-height: 104px;
  overflow-y: auto;
}
.multi legend { color: var(--muted); font-size: 12px; padding: 0 4px; }
.multi .inline { display: flex; align-items: center; gap: 4px; font-size: 13px; white-space: nowrap; }

/* Търсачка за артикул в дневния лист. */
.search-pick { position: relative; }
.search-pick input[type=search] { min-width: 260px; }
.search-results {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.search-results li { display: flex; gap: 8px; padding: 5px 8px; font-size: 13px; }
.search-results li.option { cursor: pointer; }
.search-results li.option.active { background: var(--panel-soft); }
.search-results li .name { flex: 1; }
.search-results li .code { color: var(--muted); font-family: ui-monospace, monospace; }
.search-results li .qty { color: var(--accent); font-variant-numeric: tabular-nums; }
.search-results li.empty { color: var(--muted); cursor: default; }

/* Филтри и колони в една решетка. Колона 4 започва след кутията „Доставчици“;
   в нея са и групата „нулева наличност … Нов артикул“, и лентата „Колони“.
   Така лявото поле на лентата пада точно под лявото поле на групата, без да
   влиза под търсачката и кутиите. Двете форми остават две — `display: contents`
   маха само кутиите им, не и подаването. */
.filter-bar {
  display: grid;
  grid-template-columns: auto auto auto minmax(0, 1fr);
  /* Трети ред без съдържание: в него отива излишъкът, когато кутиите отляво са
     по-високи от двата реда отдясно. Иначе той се разлива между тях и между
     бутоните и колоните зейва празен ред. */
  grid-template-rows: auto auto 1fr;
  column-gap: 8px;
  row-gap: 6px;
  align-items: start;
  margin-bottom: 12px;
}
.filter-bar > form { display: contents; }

.filter-bar .filters-search { grid-column: 1; grid-row: 1 / 4; }
.filter-bar .multi-category { grid-column: 2; grid-row: 1 / 4; }
.filter-bar .multi-supplier { grid-column: 3; grid-row: 1 / 4; }
.filter-bar .filters-actions { grid-column: 4; grid-row: 1; }
.filter-bar .columns-row { grid-column: 4; grid-row: 2; }

/* Отляво надясно, пренос само когато не се събират — без разтягане до края. */
.filter-bar .filters-actions,
.filter-bar .columns-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  min-width: 0;
}
.columns-row .columns-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.columns-row .inline { display: flex; align-items: center; gap: 5px; font-size: 13px; white-space: nowrap; margin: 0; }
.filter-bar .filters-actions .inline { margin: 0; }

/* Много колони: скролира таблицата, не прозорецът. */
.table-scroll { overflow-x: auto; max-width: 100%; }

/* Бутонът „Филтри“ е за тесен екран. На широк го няма — там лентата стои
   отворена както винаги. Скриптът маха `hidden`; без JS бутонът не се появява
   и лентата остава видима. */
.filters-toggle { display: none; }

/* Тесен екран: всичко се реди едно под друго, в реда от страницата. */
@media (max-width: 800px) {
  .filter-bar {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    row-gap: 8px;
  }
  .filter-bar .filters-search,
  .filter-bar .multi-category,
  .filter-bar .multi-supplier,
  .filter-bar .filters-actions,
  .filter-bar .columns-row {
    grid-column: 1;
    grid-row: auto;
  }
  .filter-bar .filters-search { width: 100%; min-width: 0; }
  .filter-bar .multi { max-width: 100%; }
  /* Пръст, не мишка: отметките за колони не са по-дребни от филтърните. */
  .filter-bar label.inline { min-height: 32px; }

  /* Свита лента: таблицата започва веднага под бутона. Двата класа бият
     `.filter-bar.sales-filters { display: block }` по-надолу във файла. */
  .filters-toggle:not([hidden]) {
    display: inline-block;
    margin-bottom: 8px;
    min-height: 36px;
  }
  .filter-bar.is-collapsed,
  .filter-bar.sales-filters.is-collapsed,
  .filter-bar.reports-filters.is-collapsed,
  .filter-bar.logs-filters.is-collapsed { display: none; }
}

/* Лист продажби 0.9: филтрите са прост ред, не решетката от артикулите. */
.filter-bar.sales-filters { display: block; }
.filter-bar.sales-filters > form { display: block; }
.filter-bar.sales-filters .filters-actions { display: inline-flex; gap: 6px; align-items: center; }
.filter-bar.sales-filters .columns-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }

/* Справки 1.2: лентата е прост ред като на продажбите, не решетката. */
.filter-bar.reports-filters { display: block; }
.filter-bar.reports-filters > form { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 12px; }
.filter-bar.reports-filters .filters-actions { display: inline-flex; gap: 6px; align-items: center; }

/* Журналът е със същата лента: период, падащи, два бутона. */
.filter-bar.logs-filters { display: block; }
.filter-bar.logs-filters > form { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 12px; }
.filter-bar.logs-filters .filters-actions { display: inline-flex; gap: 6px; align-items: center; }

/* Отметките за линиите стоят под филтрите, над графиката. */
.series { margin: 0 0 8px; }
.series-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.series-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.series-row .inline { display: flex; align-items: center; gap: 5px; font-size: 13px; white-space: nowrap; margin: 0; }

/* Графиката: SVG-то пълни ширината, височината е фиксирана от viewBox-а.
   `position: relative`, защото надписът при посочване се мери спрямо рамката. */
.chart {
  position: relative;
  margin: 0 0 10px;
  padding: 8px 4px 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  min-height: 120px;
}
.chart svg { display: block; width: 100%; height: auto; }

/* Надписът при посочване на точка. Стои над графиката и не лови мишката,
   иначе би отнел посочването на собствената си точка. */
.chart-tip {
  position: absolute;
  z-index: 5;
  transform: translate(-50%, -120%);
  padding: 4px 8px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--fg);
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 12px var(--shadow);
}
.chart-tip[hidden] { display: none; }

/* Редът под графиката, който обяснява двете оси. */
.chart-note { margin-top: -4px; }

/* Двете кръгови графики под линейната: една до друга, на телефон една под друга. */
.pies {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 10px;
}
@media (max-width: 700px) {
  .pies { grid-template-columns: 1fr; }
}
.pie-card {
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  min-width: 0;
}
.pie-title { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.pie { position: relative; margin: 0 auto 8px; max-width: 220px; }
.pie svg { display: block; width: 100%; height: auto; }
.pie svg path, .pie svg circle { cursor: pointer; }
.pie .chart-tip { transform: translate(-50%, -50%); }
.pie-legend { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.pie-legend li {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  border-top: 1px solid var(--line);
}
.pie-legend li:first-child { border-top: 0; }
.pie-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pie-value, .pie-share { font-variant-numeric: tabular-nums; text-align: right; }
.pie-share { color: var(--muted); min-width: 56px; }
.pie-empty { margin: 0; }
/* Гамата на дяловете идва от `--series-N` горе. Кръгът рисува със същите
   променливи — легендата и кръгът се сменят заедно при смяна на темата. */
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 2px; background: var(--series-7); }
.swatch-0 { background: var(--series-0); }
.swatch-1 { background: var(--series-1); }
.swatch-2 { background: var(--series-2); }
.swatch-3 { background: var(--series-3); }
.swatch-4 { background: var(--series-4); }
.swatch-5 { background: var(--series-5); }
.swatch-6 { background: var(--series-6); }
.swatch-7 { background: var(--series-7); }

/* Тоталите под графиката. Само блокът `div.totals`: редът „Общо“ в склада е
   `tr.totals` и flex върху него го вади от таблицата — клетките се събират
   в блок долу вляво, вместо да стоят под колоните си. */
div.totals {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 20px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.totals-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
div.totals strong { font-variant-numeric: tabular-nums; }

/* Графиката с натрупване стои най-долу, под тоталите. Рамката и надписът при
   посочване са същите `.chart` и `.chart-tip` като на горната. */
.cumulative { margin-top: 14px; }
.chart-title { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* 15 колони с полета в тях: таблицата има право да порасне и да се скролира,
   иначе `width: 100%` смачква клетките под ширината на самите полета. */
table.sales-grid { width: auto; min-width: 100%; }

/* Клетките са писани: полето пълни клетката и не изблъсква съседите. */
table.sales-grid td input[type=text],
table.sales-grid td input[type=date],
table.sales-grid td input[type=number],
table.sales-grid td input[type=search],
table.sales-grid td select {
  width: 100%;
  min-width: 0;
  padding: 4px 6px;
  font-size: 13px;
}
table.sales-grid td input.qty-input { min-width: 64px; }
table.sales-grid td input.price-input { min-width: 92px; }
/* Клетките не бива да се свиват до 40 пиксела: таблицата скролира, полето — не. */
table.sales-grid td.col-phone input { min-width: 120px; }
table.sales-grid td.col-customer input { min-width: 140px; }
table.sales-grid td.col-address input { min-width: 200px; }
table.sales-grid td.col-comment input { min-width: 160px; }
table.sales-grid td.col-tracking input { min-width: 130px; }
table.sales-grid td.col-date input { min-width: 130px; }
table.sales-grid td.col-channel select { min-width: 130px; }
table.sales-grid td.col-courier select { min-width: 100px; }
table.sales-grid td.col-article input.pick-query { min-width: 200px; }
table.sales-grid td.col-no { white-space: nowrap; }
table.sales-grid tr.order-row td.col-no { font-weight: 700; }
/* Редовете с артикули се четат като подредове на поръчката. */
table.sales-grid tr.line-row td.col-no { padding-left: 18px; color: var(--muted); }
table.sales-grid td.muted { color: var(--muted); }
table.sales-grid tr.new-order td { background: var(--panel-soft); }
table.sales-grid td.actions .add-line { font-weight: 700; }
/* Статусът е падащо, не текст. Бутонът стои до него, датите — под тях. */
table.sales-grid td.col-status .status-form { display: flex; align-items: center; gap: 4px; }
table.sales-grid td.col-status select { min-width: 120px; }
table.sales-grid td.col-status small { display: block; color: var(--muted); }
/* Свитата поръчка е един ред: номерът ѝ се чете като заглавка. */
table.sales-grid tr.single-row td.col-no { font-weight: 700; }
table.sales-grid td.actions input[type=text] { min-width: 90px; }

/* 0.9.2: „Сума“ = ед. цена × брой. Само се чете, затова не е поле. */
table.sales-grid td.col-total { white-space: nowrap; font-weight: 600; }
/* Отказаните, върнатите и наследените резервации не влизат в „Общо“ —
   сумата им се вижда, но не се чете като продажба. */
table.sales-grid tr.status-cancelled td.col-total,
table.sales-grid tr.status-returned td.col-total,
table.sales-grid tr.status-reserved td.col-total { font-weight: 400; color: var(--muted); }
/* „Общо“ под листа: брой продажби, бройки и сума за избрания период. */
.sheet-totals { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; margin: 10px 0 0; padding: 8px 12px; background: var(--panel-soft); border-radius: 6px; font-size: 14px; }
.sheet-totals .sheet-totals-label { font-weight: 600; }
.sheet-totals strong { font-size: 15px; }
.sheet-totals small { color: var(--muted); }

/* Падащото на търсачката в реда: само име и разполагаемо.
   `position: fixed`, защото `.table-scroll` е `overflow-x: auto` и режеше
   абсолютно позиционираното падащо. Фиксираното се мери спрямо прозореца,
   затова нищо не го реже; мястото му го смята скриптът на листа.
   Скролът е вътре в списъка и тръгва чак след ~12 реда — страницата не мърда. */
.search-pick .pick-results {
  position: fixed;
  z-index: 1000;
  min-width: 260px;
  margin: 0;
  padding: 0;
  list-style: none;
  /* 12 реда по 28px. Скриптът го смалява само ако до ръба няма толкова място. */
  max-height: 336px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 6px 18px var(--shadow);
}
.pick-results li { display: flex; gap: 8px; padding: 5px 8px; font-size: 13px; }
.pick-results li.option { cursor: pointer; }
.pick-results li.option.active { background: var(--panel-soft); }
.pick-results li .name { flex: 1; }
.pick-results li .qty { color: var(--accent); font-variant-numeric: tabular-nums; }
.pick-results li.empty { color: var(--muted); cursor: default; }

/* --- Журнал: броячи над таблицата ------------------------------------- */
.counters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 12px;
}
.counter-block {
  flex: 1 1 220px;
  min-width: 200px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.counter-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.counter-block ul { margin: 6px 0 0; padding: 0; list-style: none; max-height: 190px; overflow-y: auto; }
.counter-block li { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; font-size: 14px; }
.counter-block li .value { font-variant-numeric: tabular-nums; color: var(--accent); }
.counter-block .muted { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.counter-total { margin: 6px 0 0; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Таблицата на журнала: резюмето има право на цялата останала ширина. */
table.logs-grid { width: auto; min-width: 100%; }
table.logs-grid td.col-when { white-space: nowrap; font-variant-numeric: tabular-nums; }
table.logs-grid td.col-actor,
table.logs-grid td.col-screen,
table.logs-grid td.col-action,
table.logs-grid td.col-entity { white-space: nowrap; }
table.logs-grid td.col-summary { min-width: 320px; }
table.logs-grid td.muted { color: var(--muted); }

/* Настройки 1.3: трите номенклатури са секции на един екран. Бутоните горе са
   обикновени връзки — секцията живее в адреса, затова „назад“ работи сам. */
.settings-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.settings-tabs .button[aria-current="page"] { font-weight: 700; }

/* Експортът стои до филтрите. На справката „Очаквано“ филтър няма, затова
   редът с бутона е самостоятелен. */
.screen-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }

/* Телефон: менюто, потребителят и превключвателят се пренасят, не излизат вдясно. */
@media (max-width: 800px) {
  .topbar { flex-wrap: wrap; gap: 8px 16px; }
  .topbar .user { flex-wrap: wrap; }
}

/* 0.9.1: „Върни“ на ред от продажба — брой и бутон на един ред. */
table.sales-grid form.return-form { display: inline-flex; gap: 4px; align-items: center; }
table.sales-grid form.return-form input.qty-input { min-width: 56px; width: 64px; }

/* Планиране: колоната „За поръчка“ е числото, заради което табът съществува. */
table.grid td.col-to_order { font-weight: 600; }
table.grid form.plan-add { display: inline; }
