/* site/components.css — Kit components: containers, buttons, forms, table tools (filters, gear), tables, pagination. Order: wwwroot/README.md. */
/* ======================================================================
   Containers (VB ERP Container): white, 1 px border, 16 px radius; a header strip with a title and actions
   ====================================================================== */
:root {
  /* Status and UI glyphs used as CSS masks (the same shapes as Icon.cs) */
  --i-positive: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9.5'/%3E%3Cpath d='m7.8 12.3 2.9 2.9 5.6-6.1'/%3E%3C/svg%3E");
  --i-negative: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9.5'/%3E%3Cpath d='m15 9-6 6M9 9l6 6'/%3E%3C/svg%3E");
  --i-warning: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 3.9 2.4 17.6A2 2 0 0 0 4.1 20.6h15.8a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z'/%3E%3Cpath d='M12 9.5v4'/%3E%3Cpath d='M12 17.1h.01' stroke-width='2.8'/%3E%3C/svg%3E");
  --i-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9.5'/%3E%3Cpath d='M12 16.5v-5'/%3E%3Cpath d='M12 7.6h.01' stroke-width='2.8'/%3E%3C/svg%3E");
  --i-stopped: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9.5'/%3E%3Cpath d='M8 12h8'/%3E%3C/svg%3E");
  --i-pending: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9.5'/%3E%3Cpath d='M12 7v5l3.2 2'/%3E%3C/svg%3E");
  --i-caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 8.5h14L12 17z'/%3E%3C/svg%3E");
  --i-gear: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
}

.card, .panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 20px;
}
.card > :last-child, .panel > :last-child { margin-bottom: 0; }
.panel > h2:first-child, .panel > h3:first-child, .card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card > h2:first-child, .panel > h2:first-child { margin-bottom: 16px; }
/* A card that holds a list (VB ERP Table in a container): tools on top, the table flush with the edges. */
.card.flush, .card.table-card { padding: 0; display: flex; flex-direction: column; }
.card.flush > *, .card.table-card > * { flex-shrink: 0; }
.card.flush > :is(.bulkbar, .bulk-bar, .filterbar, .card-bar, .list-hint), .card.table-card > :is(.bulkbar, .bulk-bar, .filterbar, .card-bar) { order: -2; }
.card.flush > .pager, .card.table-card > .pager { order: -1; }
/* Container header: title (counter) on the left, actions on the right */
.card-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; padding: 16px 20px 12px; }
.card-bar h2, .panel-head h2, .panel-title h2, .card-title { margin: 0; font-size: 20px; line-height: 24px; letter-spacing: -.015em; }
.card-bar h2 .count, .panel-head h2 .count { color: var(--muted); font-weight: 400; }
.card-bar p, .panel-head p { margin: 4px 0 0; color: var(--text-2); }
.card-bar + table, .card-bar + .table-scroll { border-top: 0; }
.card-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 20px; border-top: 1px solid var(--line); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 16px; }
.panel-head .muted { font-size: 14px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 16px; }
.section-title { margin: 28px 0 12px; color: var(--heading); font-size: 20px; line-height: 24px; font-weight: 700; letter-spacing: -.015em; }
.section-title:first-child { margin-top: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 20px; align-items: start; margin-bottom: 20px; }
.grid-2 > .panel, .grid-2 > .card { margin-bottom: 0; }

/* Key-value pairs (VB ERP KeyValuePairs): a bold label over the value; ColumnLayout with dividers */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px 24px; margin: 0; }
.kv > div { min-width: 0; }
.kv dt, .kv .kv-label { color: var(--heading); font-weight: 700; }
.kv dd, .kv .kv-value { margin: 2px 0 0; overflow-wrap: anywhere; }
.kv dd.big, .kv .kv-value.big { font-size: 24px; line-height: 30px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kv.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kv.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kv.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kv.divided { column-gap: 0; }
.kv.divided > div { padding: 0 20px; border-left: 1px solid var(--border); }
.kv.divided.cols-2 > :nth-child(2n+1), .kv.divided.cols-3 > :nth-child(3n+1), .kv.divided.cols-4 > :nth-child(4n+1) { padding-left: 0; border-left: 0; }

/* Report switcher tabs (VB ERP Tabs): bold 16 px labels, the active one blue with a 4 px underline */
.tabs { display: flex; flex-wrap: wrap; gap: 0; margin: 0 0 20px; border-bottom: 1px solid var(--border); }
.tabs a { position: relative; padding: 10px 16px 12px; color: var(--text-2); font-size: 16px; line-height: 20px; font-weight: 700; letter-spacing: -.005em; }
.tabs a + a::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 14px; width: 1px; background: var(--border); }
.tabs a:hover { color: var(--heading); text-decoration: none; }
.tabs a.active, .tabs a[aria-current] { color: var(--accent); }
.tabs a.active::after, .tabs a[aria-current]::after {
  content: ""; position: absolute; left: 16px; right: 16px; bottom: -1px; height: 4px; border-radius: 4px 4px 0 0; background: var(--accent);
}

/* Segmented control (VB ERP SegmentedControl): radios «Витрата | Дохід», inline page tabs, metric switches */
div.seg, form.seg, .page-tabs, .switch, .segmented {
  display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; margin: 0;
  border: 1px solid var(--border-strong); border-radius: var(--radius-btn); background: var(--surface);
}
div.seg label, form.seg label, .page-tabs a, .switch a, .segmented .seg {
  display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 3px 14px; border: 0; border-radius: var(--radius-btn);
  background: none; color: var(--text-2); font: inherit; font-size: 14px; font-weight: 700; line-height: 20px; white-space: nowrap; cursor: pointer; list-style: none;
}
div.seg label:hover, form.seg label:hover, .page-tabs a:hover, .switch a:hover, .segmented .seg:hover { color: var(--accent-hover); background: var(--accent-soft); text-decoration: none; }
div.seg input, form.seg input { position: absolute; opacity: 0; pointer-events: none; }
div.seg label:has(input:checked), form.seg label:has(input:checked),
.page-tabs a.active, .page-tabs a[aria-current], .switch a.active, .segmented .seg.active { background: var(--accent); color: var(--on-accent); }
div.seg label:has(input:focus-visible), form.seg label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 1px; }
div.seg label.in:has(input:checked) { background: var(--ok-fill); color: #fff; }
div.seg label.out:has(input:checked) { background: var(--danger-fill); color: #fff; }
.page-tabs { margin-left: 12px; vertical-align: middle; font-size: 14px; letter-spacing: 0; }

/* ======================================================================
   Buttons (VB ERP Button): pills, 2 px border, bold. Normal (blue outline), primary, link, icon, inline
   ====================================================================== */
.btn {
  font: inherit; font-size: 14px; font-weight: 700; line-height: 20px; letter-spacing: .005em;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 4px 18px; border-radius: var(--radius-btn);
  border: 2px solid var(--accent); background: var(--surface); color: var(--accent);
  cursor: pointer; white-space: nowrap; text-decoration: none; user-select: none;
  transition: background-color var(--dur-fast) linear, border-color var(--dur-fast) linear, color var(--dur-fast) linear;
}
.btn:hover { background: var(--accent-soft); border-color: var(--accent-hover); color: var(--accent-hover); text-decoration: none; }
.btn:active { background: var(--accent-active); }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-btn); }
.btn:disabled, .btn[aria-disabled="true"], .btn.disabled {
  background: var(--surface); border-color: var(--surface-3); color: var(--muted); cursor: default; pointer-events: none;
}
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-primary:active { background: var(--accent-press); border-color: var(--accent-press); }
.btn-primary:disabled, .btn-primary[aria-disabled="true"] { background: var(--surface-3); border-color: var(--surface-3); color: var(--muted); }
.btn-secondary, .btn-outline { background: var(--surface); border-color: var(--accent); color: var(--accent); }
.btn-secondary:hover, .btn-outline:hover { background: var(--accent-soft); border-color: var(--accent-hover); color: var(--accent-hover); }
/* VB ERP «link» button: no border, a light hover */
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); border-color: transparent; color: var(--accent-hover); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger-strong); color: var(--danger-strong); }
.btn-danger-fill { background: var(--danger-fill); border-color: var(--danger-fill); color: #fff; }
.btn-danger-fill:hover { background: var(--danger-strong); border-color: var(--danger-strong); color: #fff; }
.btn-sm { min-height: 28px; padding: 2px 14px; }
.btn-lg { min-height: 40px; padding: 8px 24px; }
/* VB ERP «inline-link»: a bold link without a box */
.btn-link { display: inline; min-height: 0; padding: 0; border: 0; border-radius: 0; background: none; color: var(--link); font: inherit; font-weight: 700; cursor: pointer; }
.btn-link:hover { background: none; color: var(--link-hover); text-decoration: underline; text-underline-offset: .25em; }
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--on-accent); border-right-color: transparent; animation: spin .7s linear infinite;
}
.btn:not(.btn-primary):not(.btn-danger-fill).is-busy::after { border-color: var(--accent); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
form.inline { display: inline; }

/* Icon buttons (VB ERP «icon» variant): grey glyph in a round hit area */
.btn-icon, .icon-btn {
  display: inline-grid; place-items: center; flex-shrink: 0; width: 32px; height: 32px; padding: 0; border-radius: 50%;
  border: 0; background: none; color: var(--text-2); cursor: pointer; font: inherit; line-height: 1; list-style: none;
}
.btn-icon::-webkit-details-marker, .icon-btn::-webkit-details-marker { display: none; }
.btn-icon:hover, .icon-btn:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent-hover); text-decoration: none; }
.btn-icon:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-radius: 50%; }
.btn-icon .icon, .icon-btn .icon { width: 18px; height: 18px; }
.btn-icon.danger { color: var(--text-2); }
.btn-icon.danger:hover { color: var(--danger); background: var(--danger-soft); }
.btn-icon.plain { color: var(--text-2); }
.icon-btn { border: 2px solid var(--accent); color: var(--accent); font-size: 14px; font-weight: 700; }
.icon-btn:disabled { border-color: var(--surface-3); color: var(--muted); cursor: default; }

/* «Оновити»: a normal button with the refresh glyph (it spins while a live list reloads) */
.btn[data-refresh].is-spinning .icon { animation: spin .8s linear infinite; }

/* ButtonDropdown / menus: <details class="dropdown"> with a <summary> and a .menu-list (site.js closes it on outside click / Esc) */
.dropdown { position: relative; display: inline-block; }
.dropdown > summary { list-style: none; cursor: pointer; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown > summary.btn .caret { width: 14px; height: 14px; margin-right: -4px; transition: transform var(--dur) var(--ease); }
.dropdown[open] > summary.btn .caret { transform: rotate(180deg); }
.dropdown.is-disabled > summary { border-color: var(--surface-3); color: var(--muted); background: var(--surface); cursor: default; pointer-events: none; }
.menu-list {
  position: absolute; z-index: 50; top: calc(100% + 4px); right: 0; min-width: 220px; max-width: calc(100vw - 16px); max-height: min(70vh, 460px); overflow-y: auto;
  display: flex; flex-direction: column; padding: 4px 0; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-pop);
  animation: pop-in var(--dur) var(--ease);
}
.menu-list.left, .dropdown.left > .menu-list { left: 0; right: auto; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.menu-item, .menu-list > a:not(.btn), .menu-list > button:not(.btn), .menu-list form > button:not(.btn) {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; padding: 6px 16px; border-radius: 0; border: 0; background: none;
  font: inherit; font-size: 14px; color: var(--text); text-align: left; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.menu-item:hover, .menu-list > a:not(.btn):hover, .menu-list > button:not(.btn):hover, .menu-list form > button:not(.btn):hover { background: var(--row-hover); color: var(--heading); text-decoration: none; box-shadow: inset 0 0 0 1px var(--border-strong); border-radius: var(--radius-sm); }
.menu-item .icon, .menu-list > a:not(.btn) .icon, .menu-list > button:not(.btn) .icon, .menu-list form > button:not(.btn) .icon { width: 16px; height: 16px; color: var(--text-2); }
.menu-item.danger, .menu-list .danger { color: var(--danger); }
.menu-item.danger .icon { color: var(--danger); }
.menu-item.active, .menu-item[aria-current] { background: var(--selected); color: var(--heading); font-weight: 700; box-shadow: inset 0 0 0 1px var(--selected-border); border-radius: var(--radius-sm); }
.menu-item[aria-disabled="true"] { color: var(--muted); pointer-events: none; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 0; }
.menu-label { padding: 8px 16px 2px; font-size: 12px; line-height: 16px; font-weight: 700; color: var(--muted); }
.menu-list form { margin: 0; }
.menu-list input[type=search] { margin: 4px 8px 6px; width: calc(100% - 16px); }

/* ======================================================================
   Forms (VB ERP FormField, Input, Select, Textarea, Checkbox, RadioGroup)
   ====================================================================== */
label { display: grid; gap: 4px; font-weight: 700; font-size: 14px; line-height: 20px; color: var(--text); }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=number], input[type=search],
input[type=date], input[type=datetime-local], input[type=month], input[type=time], input[type=url], input:not([type]),
select, textarea {
  font: inherit; font-size: 14px; line-height: 20px; font-weight: 400; color: var(--text);
  min-height: var(--control-h); padding: 5px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background-color: var(--surface); width: 100%;
  transition: border-color var(--dur-fast) linear, box-shadow var(--dur-fast) linear;
}
textarea { min-height: 80px; resize: vertical; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 8.5h14L12 17z' fill='%23424650'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 14px;
}
:root[data-theme="dark"] select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 8.5h14L12 17z' fill='%23c6c6cd'/%3E%3C/svg%3E"); }
select[multiple] { background-image: none !important; padding-right: 12px; }
input::placeholder, textarea::placeholder { color: var(--muted); font-style: italic; opacity: 1; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
input:disabled, select:disabled, textarea:disabled { background-color: var(--surface-3); border-color: var(--surface-3); color: var(--muted); cursor: not-allowed; }
input[readonly] { background-color: var(--surface-2); color: var(--text-2); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"], .input-validation-error { border-color: var(--danger); box-shadow: inset 4px 0 0 var(--danger); }
input[type=file] { font: inherit; font-size: 14px; color: var(--text-2); }
input[type=file]::file-selector-button {
  font: inherit; font-weight: 700; margin-right: 12px; padding: 4px 16px; border-radius: var(--radius-btn);
  border: 2px solid var(--accent); background: var(--surface); color: var(--accent); cursor: pointer;
}
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; flex-shrink: 0; }
input[type=number] { font-variant-numeric: tabular-nums; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; font-size: 14px; color: var(--text); cursor: pointer; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px 20px; margin: 0; background: var(--surface); min-width: 0; }
legend { font-weight: 700; padding: 0 6px; color: var(--heading); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px 16px; }
/* FormField description / constraint text (grey, 12 px) and the error text (red, with the error glyph) */
.hint, .help { font-size: 12px; line-height: 16px; color: var(--muted); font-weight: 400; letter-spacing: .005em; }
.field-error, .field-validation-error { display: inline-flex; align-items: flex-start; gap: 6px; font-size: 12px; line-height: 16px; color: var(--danger); font-weight: 700; }
.field-error::before, .field-validation-error:not(:empty)::before {
  content: ""; flex-shrink: 0; width: 14px; height: 14px; margin-top: 1px; background: currentColor;
  -webkit-mask: var(--i-negative) center / contain no-repeat; mask: var(--i-negative) center / contain no-repeat;
}
.field-validation-valid { display: none; }

/* Stacked form (label above the control) */
form.stack { display: grid; gap: 20px; max-width: 640px; }
/* Fields in two columns (document header, modal forms). Add .span-2 to a field for the full row. */
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.fields > .span-2, .fields > .full { grid-column: 1 / -1; }
.fields.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
/* Poster form rows: label on the left (220 px), control on the right (max 520 px). */
.form-rows { display: grid; gap: 16px; max-width: 800px; }
.form-rows > label, .form-rows > .row { display: grid; grid-template-columns: 220px minmax(0, 520px); gap: 4px 20px; align-items: center; font-size: 14px; font-weight: 700; color: var(--text); }
.form-rows > label > .hint, .form-rows > .row > .hint { grid-column: 2; }
.form-rows > label:has(textarea) { align-items: start; }
.form-rows > label.check { display: flex; padding-left: 240px; font-weight: 400; }
.form-rows .section { margin: 12px 0 0; padding-top: 16px; border-top: 1px solid var(--border); font-size: 18px; line-height: 22px; font-weight: 700; color: var(--heading); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px 20px; align-items: end; }

/* An input with a unit glued to its right side: <span class="addon"><input/><i>₴</i></span> */
.addon { display: inline-flex; align-items: stretch; width: 100%; }
.addon > input { border-top-right-radius: 0; border-bottom-right-radius: 0; min-width: 0; }
.addon > i, .addon > span {
  display: grid; place-items: center; min-width: 32px; padding: 0 10px; font-style: normal; font-size: 14px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ======================================================================
   Table tools (VB ERP Table header): text filter, selects, toggles, «Очистити», preferences (gear)
   ====================================================================== */
.filterbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 16px 20px 12px; margin: 0; }
.search { position: relative; display: inline-flex; align-items: center; flex: 0 1 420px; min-width: 200px; gap: 0; margin: 0; font-weight: 400; }
.search .icon { position: absolute; left: 12px; width: 16px; height: 16px; color: var(--text-2); pointer-events: none; }
.search input { padding-left: 36px; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
/* A native select as a VB ERP Select; .on = a value is chosen (the filter is applied) */
.chip-select {
  width: auto; min-width: 0; max-width: 280px; field-sizing: content; color: var(--text);
}
.chip-select.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background-color: var(--selected); color: var(--heading); font-weight: 700; }
.chip-select.on option { background: var(--surface); color: var(--text); font-weight: 400; }
/* A dropdown trigger (multi-select, period, «+ Фільтр») looks like a Select too */
summary.chip, .chip > summary {
  display: inline-flex; align-items: center; gap: 8px; min-height: var(--control-h); padding: 5px 12px; list-style: none;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 400; white-space: nowrap; cursor: pointer;
}
summary.chip::-webkit-details-marker { display: none; }
summary.chip:hover { border-color: var(--border-strong); color: var(--heading); text-decoration: none; }
summary.chip.on, summary.chip[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--selected); color: var(--heading); font-weight: 700; }
summary.chip .icon { width: 16px; height: 16px; color: var(--text-2); }
/* A quick toggle link (Мінусові, Нижче ліміту): VB ERP ToggleButton, pressed = light blue */
a.chip, button.chip, label.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--control-h); padding: 4px 16px;
  border: 2px solid var(--accent); border-radius: var(--radius-btn); background: var(--surface); color: var(--accent);
  font: inherit; font-size: 14px; font-weight: 700; letter-spacing: .005em; white-space: nowrap; cursor: pointer; text-decoration: none;
}
a.chip:hover, button.chip:hover, label.chip:hover { background: var(--accent-soft); border-color: var(--accent-hover); color: var(--accent-hover); text-decoration: none; }
a.chip.on, button.chip.on, a.chip[aria-pressed="true"], button.chip[aria-pressed="true"] { background: var(--chip-on); border-color: var(--chip-on-border); color: var(--chip-on-text); }
.chip .chip-count, .chip .count {
  display: inline-grid; place-items: center; min-width: 20px; height: 18px; padding: 0 6px; border-radius: var(--radius-badge);
  font-size: 12px; font-weight: 700; background: var(--neutral-fill); color: #fff; font-variant-numeric: tabular-nums;
}
.chip.warn .chip-count { background: var(--warn-fill); color: #0f141a; }
.chip.danger .chip-count { background: var(--danger-fill); color: #fff; }
.chip.on .chip-count, .chip.on .count { background: var(--accent); color: var(--on-accent); }
.filterbar .chip-group { display: contents; }
.chip .icon { width: 16px; height: 16px; }
.pp-caret { width: 14px !important; height: 14px !important; opacity: 1; color: var(--text-2); }
.filterbar .reset { padding: 4px 8px; border-radius: var(--radius-btn); color: var(--link); font-weight: 700; }
.filterbar .reset:hover { background: var(--accent-soft); color: var(--link-hover); text-decoration: none; }
.filterbar .spacer { flex: 1; }
.filterbar .date-range { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-weight: 400; }
.filterbar .date-range input { width: 150px; }
/* The preferences gear (VB ERP CollectionPreferences), added by site.js to lists with column choices */
.prefs-btn { margin-left: auto; }
.prefs-btn .icon { width: 20px; height: 20px; }
.prefs-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px 32px; }
.prefs-left { display: grid; gap: 24px; align-content: start; }
.prefs-body fieldset { border: 0; padding: 0; background: none; display: grid; gap: 8px; align-content: start; }
.prefs-body legend { padding: 0 0 4px; font-size: 16px; }
.prefs-cols { max-height: 360px; overflow-y: auto; padding-right: 4px; }
.prefs-cols label.check { justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }

/* Legacy filter forms: <form class="toolbar">, <form class="filters"> (labels above controls) */
form.toolbar, form.filters {
  justify-content: flex-start; align-items: flex-end; gap: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px; margin-bottom: 20px;
}
form.toolbar > label:not(.check), form.filters > label:not(.check) { min-width: 150px; }
form.toolbar > label.check { min-height: var(--control-h); }
.panel form.toolbar, .card form.toolbar { background: none; border: 0; padding: 0; margin-bottom: 0; }
form.filters { display: flex; flex-wrap: wrap; }
form.filters label { flex: 1 1 140px; max-width: 240px; }
form.filters label.check { flex: 0 0 auto; }
form.filters .range { display: flex; gap: 6px; }

/* Quick filter row (legacy «Усі · Нижче ліміту · Мінусові»): toggle buttons */
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin: -4px 0 16px; }
.quick a {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 16px; border-radius: var(--radius-btn); font-weight: 700;
  background: var(--surface); border: 2px solid var(--accent); color: var(--accent);
}
.quick a:hover { background: var(--accent-soft); color: var(--accent-hover); text-decoration: none; }
.quick a.on { background: var(--chip-on); border-color: var(--chip-on-border); color: var(--chip-on-text); }
.quick .count { font-variant-numeric: tabular-nums; }

/* ======================================================================
   Tables (VB ERP Table): bold grey column headers with dividers, sticky header, 1 px row lines, hover,
   selected rows outlined in blue. Bare <table> = its own container; table.list = one line per row.
   ====================================================================== */
table {
  width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px;
}
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td { height: var(--row-h); }
thead th {
  position: sticky; top: var(--sticky-top); z-index: 5; height: var(--row-h);
  background-color: var(--surface); color: var(--text-2); font-size: 14px; font-weight: 700; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
/* The header sticks under the top bar while the PAGE scrolls; inside a box that scrolls on its own (a sideways-scrolling
   table, the P&L tree, a modal, the side panel) it sticks to that box's top instead. */
:is(.table-scroll, .count-scroll, .pl-scroll, .lines-scroll, .fin-shifts-wrap, .store-prices, .pf-stores-scroll, .pm-stores,
    .sp-content, dialog, .rtab, .detail, .tools, .movement-scroll) { --sticky-top: 0px; }
/* column dividers between header cells (VB ERP draws them for resizable columns) */
thead th + th:not(:empty) { background-image: linear-gradient(var(--border), var(--border)); background-size: 1px 20px; background-position: 0 50%; background-repeat: no-repeat; }
thead :is(th.chev, th.check) + th { background-image: none; }
thead tr:first-child th:first-child { border-top-left-radius: var(--radius); }
thead tr:first-child th:last-child { border-top-right-radius: var(--radius); }
tbody tr > td { transition: background-color var(--dur-fast) linear; }
tbody tr:hover > td { background-color: var(--row-hover); }
tbody tr:last-child > td { border-bottom: none; }
tbody tr:last-child > td:first-child { border-bottom-left-radius: var(--radius); }
tbody tr:last-child > td:last-child { border-bottom-right-radius: var(--radius); }
tbody th { font-weight: 700; color: var(--text-2); white-space: nowrap; }
th.num, td.num { text-align: right; }
tfoot td, tfoot th {
  background: var(--surface-2); font-weight: 700; color: var(--heading); height: var(--row-h);
  border-top: 1px solid var(--border); border-bottom: none; font-size: 14px;
}
tfoot tr:last-child > :first-child { border-bottom-left-radius: var(--radius); }
tfoot tr:last-child > :last-child { border-bottom-right-radius: var(--radius); }
tbody:has(+ tfoot) tr:last-child td { border-radius: 0 !important; }
td .btn, td form { vertical-align: middle; }
td > .btn-sm, td > form > .btn-sm { margin: -4px 0; }
.panel table, .card table { border: 0; border-radius: 0; margin-bottom: 0; background: transparent; }
.panel > table, .card > table { width: calc(100% + 40px); margin: 0 -20px; }
.panel > table:first-child, .card > table:first-child { margin-top: -8px; }
.panel > table:last-child, .card > table:last-child { margin-bottom: -12px; }
.card.flush > table, .card.table-card > table, .card.flush > .table-scroll > table, .card.table-card > .table-scroll > table { width: 100%; margin: 0; }
.panel table thead th, .card table thead th { background-color: var(--surface); }
.panel table th:first-child, .panel table td:first-child, .card table th:first-child, .card table td:first-child { padding-left: 20px; }
.panel table th:last-child, .panel table td:last-child, .card table th:last-child, .card table td:last-child { padding-right: 20px; }
.card table thead tr:first-child th, .panel table thead tr:first-child th { border-radius: 0; }
.card.flush table tbody tr:last-child > td, .card.table-card table tbody tr:last-child > td { border-radius: 0; }
.card.flush > table:last-child tbody tr:last-child > td:first-child, .card.table-card > table:last-child tbody tr:last-child > td:first-child { border-bottom-left-radius: var(--radius); }
.card.flush > table:last-child tbody tr:last-child > td:last-child, .card.table-card > table:last-child tbody tr:last-child > td:last-child { border-bottom-right-radius: var(--radius); }
.card.flush > table:first-child thead tr:first-child th:first-child { border-top-left-radius: var(--radius); }
.card.flush > table:first-child thead tr:first-child th:last-child { border-top-right-radius: var(--radius); }

/* Dense list: one line per row, long text ends with … (the full text is in title=""), numbers right. */
table.list td { white-space: nowrap; }
table.list td.wrap { white-space: normal; }
table.list.wrap-lines td { white-space: normal; }
table.list.wrap-lines td.trunc { overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
/* .trunc: a flexible text column that shrinks and truncates (give it a width, e.g. style="width:40%"). */
td.trunc { max-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
th.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.list th, table.list td { padding-left: 12px; padding-right: 12px; }
.table-compact table.list th, .table-compact table.list td { padding-top: 4px; padding-bottom: 4px; }
td.trunc > a, td.trunc > span, td.trunc > strong { overflow: hidden; text-overflow: ellipsis; }
/* A link in a truncated cell ends where the cell ends: its box no longer runs under the next cells' links (Lighthouse
   target-size on long names: a transfer's goods, an account). */
td.trunc > a { display: inline-block; max-width: 100%; vertical-align: top; }
/* The key column links to the record (VB ERP: blue, bold) */
td.name a, td a.row-link, a.row-link { color: var(--link); font-weight: 700; }
td strong.q { font-weight: 700; }
td strong.zero { font-weight: 400; }
td.name a:hover, a.row-link:hover { color: var(--link-hover); }
td.name small, td.trunc small { color: var(--muted); margin-left: 6px; font-size: 12px; }
td.check, th.check { width: 44px; padding-right: 0; text-align: center; }
td.check + td, th.check + th { padding-left: 8px; }
td.act, th.act { width: 1%; white-space: nowrap; text-align: right; padding-top: 0; padding-bottom: 0; }
/* A list too wide for its card (it scrolls sideways in .table-scroll) keeps its row actions (→ ⋮, «Деталі», «Ред.»)
   pinned at the right edge behind a divider, as Poster's lists show them: they never hide past the edge at 1366/1440.
   Zero specificity (:where), so row states (selected, deleted, hover) and the lists' own rules still win. */
@media (min-width: 901px) {
  :where(.table-scroll > table.list) :where(th.act:last-child, td.act:last-child) { position: sticky; right: 0; z-index: 1; background-color: var(--surface); box-shadow: inset 1px 0 0 var(--line); }
}
td.chev, th.chev { width: 36px; padding-top: 0; padding-bottom: 0; padding-right: 0; color: var(--text-2); }
td.act .btn-icon, td.chev .btn-icon, td.check .btn-icon { width: 28px; height: 28px; vertical-align: middle; }
tr[data-href] { cursor: pointer; }
/* Selected rows (checkbox or radio): light blue with a 2 px blue outline, as in VB ERP */
tr.is-selected > td { background-color: var(--selected) !important; box-shadow: inset 0 2px 0 var(--selected-border), inset 0 -2px 0 var(--selected-border); }
tr.is-selected > td:first-child { box-shadow: inset 2px 0 0 var(--selected-border), inset 0 2px 0 var(--selected-border), inset 0 -2px 0 var(--selected-border); border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
tr.is-selected > td:last-child { box-shadow: inset -2px 0 0 var(--selected-border), inset 0 2px 0 var(--selected-border), inset 0 -2px 0 var(--selected-border); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
/* Sort (VB ERP: a caret after the header text; unsorted columns show it on hover) */
th a.sort, th a[data-sort] { color: inherit; display: inline-flex; gap: 6px; align-items: center; }
th a.sort:hover { color: var(--heading); text-decoration: none; }
th a.sort::after {
  content: ""; width: 12px; height: 12px; flex-shrink: 0; background: currentColor; opacity: 0; transition: opacity var(--dur-fast) linear;
  -webkit-mask: var(--i-caret) center / contain no-repeat; mask: var(--i-caret) center / contain no-repeat;
}
th a.sort:hover::after, th a.sort:focus-visible::after { opacity: .55; }
th a.sort.asc, th a.sort.desc { color: var(--heading); }
th a.sort.asc::after, th a.sort.desc::after { opacity: 1; }
th a.sort.asc::after { transform: rotate(180deg); }
th.num a.sort { flex-direction: row-reverse; }
/* Wide tables scroll sideways inside their own box (site.js wraps them). */
.table-scroll { position: relative; overflow-x: auto; margin-bottom: 20px; border-radius: var(--radius); }
.table-scroll > table { margin-bottom: 0; }
.table-scroll thead th { position: static; }
.card > .table-scroll, .panel > .table-scroll { margin: 0 -20px; border-radius: 0; }
.card.flush > .table-scroll, .card.table-card > .table-scroll { margin: 0; }
.card > .table-scroll:last-child, .panel > .table-scroll:last-child { margin-bottom: -12px; }
.card.flush > .table-scroll:last-child, .card.table-card > .table-scroll:last-child { margin-bottom: 0; border-radius: 0 0 var(--radius) var(--radius); }
/* Its scrollbar stays on screen (VB ERP's sticky scrollbar): site.js (stickyBars) puts a bar right under the table
   that sticks to the bottom of the window while the table goes on below it; the two scroll together, and the table's
   own bar is hidden. The bar takes over the box's outer margins. */
.table-scroll.has-hscroll { scrollbar-width: none; margin-bottom: 0 !important; border-radius: 0 !important; }
.table-scroll.has-hscroll::-webkit-scrollbar { display: none; }
.hscroll { position: sticky; bottom: 0; z-index: 6; min-height: 14px; overflow-x: auto; overflow-y: hidden; background: var(--surface); border-top: 1px solid var(--line); }
.hscroll > div { height: 1px; }
/* Text columns stay readable (Poster shows «Головний склад», not «Го…»): a minimum width, larger for the key ones
   (th.trunc.wide). A table that no longer fits scrolls sideways inside its card (site.js fitTables). */
table.list th.trunc { min-width: 7.5rem; }
table.list th.trunc.wide { min-width: 11rem; }
/* The key (name) column never shrinks below a readable width: with the side panel open, the list scrolls sideways. */
table.list td.trunc.name { min-width: 11rem; }
/* A menu opened inside a sideways-scrolling table floats above it, so the scroll box does not clip it. */
.menu-list.floating { position: fixed; right: auto; bottom: auto; z-index: 60; }

/* Row states */
tr.row-off td { color: var(--muted); }
tr.row-off td a { color: var(--muted); }
tr.row-deleted > td { background: var(--danger-soft); color: var(--muted); }
tr.row-danger > td { background: var(--danger-soft) !important; }
tr.row-hot > td { background: var(--warn-soft) !important; }
tr.row-hot > td:first-child { box-shadow: inset 4px 0 0 var(--warn-border); }
tr.row-low > td:first-child { box-shadow: inset 4px 0 0 var(--warn-border); }
tr.is-return td { background: color-mix(in srgb, var(--danger-soft) 70%, transparent); }
.low { color: var(--warn); font-weight: 700; }
.tag-low { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: var(--radius-badge); font-size: 12px; line-height: 18px; font-weight: 700; background: var(--warn-fill); color: #0f141a; vertical-align: 1px; }
.amount-in { color: var(--ok); font-weight: 700; }
.amount-out { color: var(--danger); font-weight: 700; }

/* Pagination (VB ERP Pagination): at the top right of the list, «Показано 51–100 з 3 349» on its left */
.pager {
  display: flex; align-items: center; justify-content: flex-end; gap: 4px 16px; flex-wrap: wrap;
  padding: 0 20px 8px; margin: 0; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums;
}
:not(.card):not(.panel):not([data-live-region]) > .pager { padding: 0 0 12px; }
.pager-total { margin-right: auto; color: var(--muted); }
.pager-pages { display: inline-flex; align-items: center; gap: 0; }
.pager a, .pager-pages > span {
  min-width: 28px; height: 28px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 14px; font-weight: 400;
}
.pager a:hover { color: var(--heading); text-decoration: none; background: var(--row-hover); }
.pager .pager-current { color: var(--heading); font-weight: 700; }
.pager .pager-gap { color: var(--muted); min-width: 20px; padding: 0; }
.pager .pager-step { color: var(--text-2); font-size: 20px; font-weight: 400; }
.pager .pager-step.disabled { color: var(--muted); opacity: .45; }
/* A live list region is a column, so its pager sits on top, under the filters (VB ERP) */
[data-live-region] { display: flex; flex-direction: column; }
[data-live-region] > * { flex-shrink: 0; }
[data-live-region] > .pager { order: -1; }
[data-live-region] > .list-hint { order: -2; }

