/* site/patterns.css — Kit patterns: statuses and badges, alerts and empty states, bulk actions, metric tiles, home, document page, modal, sign-in, legacy components, column chooser, responsive, print. Order: wwwroot/README.md. */
/* ======================================================================
   Status indicator, badges, dots, tags
   ====================================================================== */
/* Badge (VB ERP): a small filled label, 4 px radius. .badge = blue, .badge-neutral = grey */
.badge {
  display: inline-flex; align-items: center; padding: 0 8px; border-radius: var(--radius-badge);
  font-size: 12px; font-weight: 400; line-height: 20px; letter-spacing: .005em; white-space: nowrap;
  background: var(--info-fill); color: var(--on-fill); border: 0;
}
.badge-neutral { background: var(--neutral-fill); color: #fff; }
.badge-red { background: var(--danger-fill); color: #fff; }
.badge-green { background: var(--ok-fill); color: #fff; }
/* StatusIndicator (VB ERP): a coloured glyph + coloured text. .badge-ok / -warn / -danger / -off are statuses. */
.status, .badge-ok, .badge-success, .badge-warn, .badge-danger, .badge-off {
  display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; border-radius: 0; background: none;
  font-size: 14px; font-weight: 400; line-height: 20px; white-space: nowrap; letter-spacing: 0;
}
.status::before, .badge-ok::before, .badge-success::before, .badge-warn::before, .badge-danger::before, .badge-off::before {
  content: ""; flex-shrink: 0; width: 16px; height: 16px; border-radius: 0; background: currentColor;
  -webkit-mask: var(--status-icon, var(--i-info)) center / contain no-repeat; mask: var(--status-icon, var(--i-info)) center / contain no-repeat;
}
.status-success, .badge-ok, .badge-success { color: var(--ok); --status-icon: var(--i-positive); }
.status-error, .badge-danger { color: var(--danger); --status-icon: var(--i-negative); }
.status-warning, .badge-warn { color: var(--warn); --status-icon: var(--i-warning); }
.status-info { color: var(--info); --status-icon: var(--i-info); }
.status-stopped, .badge-off { color: var(--muted); --status-icon: var(--i-stopped); }
.status-pending { color: var(--muted); --status-icon: var(--i-pending); }
.status-loading { color: var(--muted); }
.status-loading::before { -webkit-mask: none; mask: none; background: none; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; width: 12px; height: 12px; margin: 2px; animation: spin .8s linear infinite; }
h1 .status, h1 .badge-ok, h1 .badge-warn, h1 .badge-danger, h1 .badge-off { font-size: 14px; letter-spacing: 0; vertical-align: 4px; }
/* Dots before a status text become StatusIndicator glyphs; colour dots of categories (rdot-*) stay round */
.dot {
  display: inline-block; width: 16px; height: 16px; margin-right: 4px; vertical-align: -3px; background: var(--muted);
  -webkit-mask: var(--i-stopped) center / contain no-repeat; mask: var(--i-stopped) center / contain no-repeat;
}
.dot-ok { background: var(--ok); -webkit-mask-image: var(--i-positive); mask-image: var(--i-positive); }
.dot-warn { background: var(--warn); -webkit-mask-image: var(--i-warning); mask-image: var(--i-warning); }
.dot-danger { background: var(--danger); -webkit-mask-image: var(--i-negative); mask-image: var(--i-negative); }
.dot-info { background: var(--info); -webkit-mask-image: var(--i-info); mask-image: var(--i-info); }
.dot[class*="rdot-"] { width: 10px; height: 10px; margin-right: 8px; vertical-align: 0; border-radius: 50%; -webkit-mask: none; mask: none; }
/* .dot.kind marks a kind (income / expense / transfer), not a status: a small round colour dot */
.dot.kind { width: 8px; height: 8px; margin-right: 8px; vertical-align: 1px; border-radius: 50%; -webkit-mask: none; mask: none; }
.dot.kind.dot-ok { background: var(--ok-fill); } .dot.kind.dot-danger { background: var(--danger-fill); } .dot.kind.dot-info { background: var(--info-fill); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chips .chip, span.chip {
  display: inline-flex; align-items: center; min-height: 0; padding: 0 8px; border-radius: var(--radius-badge); border: 1px solid var(--border);
  font-size: 12px; line-height: 20px; font-weight: 400; background: var(--surface-2); color: var(--text-2); cursor: default;
}

/* ======================================================================
   Alerts, empty and loading states, spinner, progress bar
   ====================================================================== */
/* Alert (VB ERP): 2 px status border, 12 px radius, tinted background, body-coloured text, status glyph */
.alert {
  display: block; position: relative; margin: 0 0 20px; padding: 8px 16px 8px 44px; border-radius: var(--radius-alert);
  background: var(--info-soft); color: var(--text); border: 2px solid var(--info-border); font-size: 14px; line-height: 20px;
  --alert-icon: var(--i-info);
}
.alert::before {
  content: ""; position: absolute; left: 16px; top: 10px; width: 16px; height: 16px; background: var(--info);
  -webkit-mask: var(--alert-icon) center / contain no-repeat; mask: var(--alert-icon) center / contain no-repeat;
}
.alert ul { margin: 6px 0 0; }
.alert a { color: var(--link); text-decoration: underline; text-underline-offset: .2em; }
.alert-error { background: var(--danger-soft); border-color: var(--danger-border); --alert-icon: var(--i-negative); }
.alert-error::before { background: var(--danger); }
.alert-ok { background: var(--ok-soft); border-color: var(--ok-border); --alert-icon: var(--i-positive); }
.alert-ok::before { background: var(--ok); }
.alert-warn { background: var(--warn-soft); border-color: var(--warn-border); --alert-icon: var(--i-warning); }
.alert-warn::before { background: var(--warn); }
/* An alert placed straight in a list container keeps the container's inset */
.card.flush > .alert, .card.flush > [data-live-region] > .alert { margin: 0 20px 12px; }

/* Empty state (VB ERP table empty): centred bold line, grey text, an action. .panel.muted (legacy) looks the same. */
.empty, .panel.muted {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center;
  padding: 32px 24px 36px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.card > .empty, .card.flush .empty, [data-live-region] > .empty { border: 0; border-radius: 0; background: none; }
.empty p { margin: 0; max-width: 520px; }
.empty > p:first-child, .empty .empty-title { color: var(--muted); font-weight: 700; font-size: 14px; }
.empty .btn { margin-top: 8px; }

.skeleton { display: inline-block; height: 12px; border-radius: var(--radius-sm); background: var(--skeleton); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }
/* Loading state of a live list: dimmed rows and «Завантаження…» with a spinner over them */
[data-live-region].is-loading { position: relative; }
[data-live-region].is-loading > * { opacity: .45; transition: opacity .1s linear .15s; }
[data-live-region].is-loading::after {
  content: "Завантаження…"; position: absolute; left: 50%; top: 56px; transform: translateX(-50%); z-index: 6;
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 36px; border-radius: var(--radius-btn);
  background: var(--surface); color: var(--muted); font-weight: 700; box-shadow: var(--shadow-pop);
}
[data-live-region].is-loading::before {
  content: ""; position: absolute; left: calc(50% - 58px); top: 64px; z-index: 7; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--muted); border-right-color: transparent; animation: spin .8s linear infinite;
}
/* Spinner (VB ERP Spinner): <span class="spinner" role="status" aria-label="Завантаження"></span> */
.spinner { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; vertical-align: -3px; animation: spin .8s linear infinite; color: var(--muted); }
.spinner.big { width: 32px; height: 32px; border-width: 3px; }
/* Progress bar (VB ERP ProgressBar): <div class="progress"><span class="progress-track"><i style="width:40%"></i></span><span>40 %</span></div> */
.progress { display: flex; align-items: center; gap: 12px; }
.progress-track { flex: 1; height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.progress-track > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.progress > span:last-child { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ======================================================================
   Bulk actions: shown only while rows are checked (site.js toggles [hidden]); «Дії» on the selection
   ====================================================================== */
.bulkbar, .bulk-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 20px; margin: 0 0 16px;
  border-radius: var(--radius); background: var(--selected); color: var(--heading); border: 2px solid var(--selected-border);
}
.card > .bulkbar, .card > .bulk-bar { margin: 0; border-radius: var(--radius) var(--radius) 0 0; border-width: 0 0 1px; border-color: var(--border); }
.bulkbar select, .bulk-bar select { width: auto; min-width: 180px; }
.bulk-bar label { min-width: 150px; }
.bulk-bar .selected, .bulkbar .selected { font-weight: 700; color: var(--heading); margin-right: 4px; }
.selection-count { color: var(--muted); }

/* ======================================================================
   Metric tiles (stats pages, dashboards): a Container with a bold label and a large value
   ====================================================================== */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; margin: 0 0 20px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px; display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.kpi > .muted:first-child, .kpi .kpi-head > .muted { color: var(--heading); font-size: 14px; font-weight: 700; }
.kpi strong { font-size: 24px; line-height: 30px; font-weight: 400; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.kpi strong + .muted, .kpi .trend, .kpi .kpi-sub { font-size: 12px; line-height: 16px; }
.kpi .kpi-sub { color: var(--muted); }
.kpi .trend.up { color: var(--ok); }
.kpi .trend.down { color: var(--danger); }
.kpi-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.kpi-icon .icon { width: 16px; height: 16px; }
.kpi-icon.warn { background: var(--warn-soft); color: var(--warn); }
.kpi-icon.ok { background: var(--ok-soft); color: var(--ok); }
.kpi.kpi-ok strong { color: var(--ok); }
.kpi.kpi-danger strong { color: var(--danger); }
a.kpi { color: inherit; transition: border-color var(--dur-fast) linear, box-shadow var(--dur-fast) linear; }
a.kpi:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.bar { display: inline-block; height: 8px; background: var(--accent); border-radius: 4px; vertical-align: middle; }

/* ======================================================================
   Home dashboard
   ====================================================================== */
.hello { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.hello h1 { margin: 0 0 2px; }
.hello p { margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px 20px;
  display: flex; flex-direction: column; gap: 8px; transition: border-color var(--dur-fast) linear;
}
.tile:hover { border-color: var(--border-strong); }
.tile-head { display: flex; align-items: center; gap: 10px; color: var(--heading); }
.tile-head:hover { text-decoration: none; color: var(--link); }
.tile-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; background: var(--selected); color: var(--accent); }
.tile-icon .icon { width: 18px; height: 18px; }
.tile h3 { margin: 0; font-size: 18px; line-height: 22px; color: inherit; }
.tile p { margin: 0; color: var(--text-2); }
.tile ul { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.tile li a { font-weight: 400; }

/* ======================================================================
   Document page: header container, spreadsheet-like lines, sticky form actions
   ====================================================================== */
.doc-meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px 24px; margin: 0; }
.doc-meta dt { color: var(--heading); font-weight: 700; }
.doc-meta dd { margin: 2px 0 0; min-height: 20px; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.profile-identity { display: flex; align-items: center; gap: 16px; }
.profile-avatar { display: grid; place-items: center; width: 52px; height: 52px; flex: 0 0 52px; border-radius: 16px; background: var(--selected); color: var(--accent); }
.profile-avatar .icon { width: 26px; height: 26px; }
.profile-identity-copy { min-width: 0; flex: 1; }
.profile-identity-copy h2 { margin: 0; color: var(--heading); font-size: 20px; line-height: 26px; }
.profile-identity-copy .muted { margin: 2px 0 0; }
.profile-security-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.profile-security-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.profile-security-item > span:first-child { color: var(--text-2); }
.profile-security-item > span:last-child { text-align: right; }
.profile-api-token > .status { margin: 0 20px 16px; }
.profile-token-meta { padding: 0 20px; }
.profile-api-token > .hint { margin: 16px 20px 0; }
.profile-api-token-head .actions { flex-wrap: wrap; }
.profile-new-token { margin: 20px; padding: 16px; border: 1px solid var(--selected-border); border-radius: var(--radius); background: var(--selected); }
.profile-new-token h3 { margin: 0 0 12px; }
.profile-new-token > .hint { margin: 12px 0 0; }
.profile-token-reveal { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.profile-token-reveal code { min-width: 0; overflow-wrap: anywhere; color: var(--heading); font-family: var(--mono); }
.profile-totp-qr { display: grid; place-items: center; width: fit-content; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.profile-totp-qr canvas { display: block; max-width: min(220px, 100%); height: auto; image-rendering: pixelated; }
.profile-totp-secret { display: inline-block; max-width: 100%; overflow-wrap: anywhere; font-size: 15px; letter-spacing: .08em; }
.profile-login-history table { min-width: 880px; }
.profile-login-history td:nth-child(5) { min-width: 240px; }
@media (max-width: 900px) {
  .profile-identity { align-items: flex-start; flex-wrap: wrap; }
  .profile-identity-copy { flex-basis: calc(100% - 72px); }
  .profile-identity > .status { margin-left: 68px; }
  .profile-security-grid { grid-template-columns: minmax(0, 1fr); }
  .profile-api-token-head { align-items: flex-start; flex-direction: column; }
  .profile-api-token-head .actions { width: 100%; }
  .profile-token-reveal { align-items: flex-start; flex-direction: column; }
}
table.lines td { height: 48px; padding-top: 6px; padding-bottom: 6px; }
table.lines td.op, table.lines th.op { width: 18px; padding-left: 0; padding-right: 0; text-align: center; color: var(--decor); font-size: 16px; }
table.lines .cell, table.lines input:not([type=checkbox]):not([type=hidden]) { min-height: var(--control-h); }
table.lines td.qty { width: 120px; }
table.lines td.money { width: 150px; }
table.lines td.qty input, table.lines td.money input { text-align: right; font-variant-numeric: tabular-nums; }
table.lines tr.add-row > td { background: var(--surface-2); }
table.lines tr.add-row:hover > td { background: var(--surface-2); }
table.lines tr.line-error > td { background: var(--danger-soft); }
table.lines tr.is-saving > td { opacity: .7; }
table.lines .line-name { display: flex; flex-direction: column; min-width: 0; line-height: 18px; }
table.lines .line-name > span:first-child, table.lines .line-name > a:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
table.lines .line-name small { color: var(--muted); }
.muted-link { color: var(--text-2); }
.muted-link:hover { color: var(--link-hover); }
.link-add { display: inline-flex; align-items: center; gap: 6px; color: var(--link); font-weight: 700; background: none; border: 0; padding: 4px 0; cursor: pointer; font: inherit; }
.link-add:hover { color: var(--link-hover); text-decoration: underline; }
.link-add .icon { width: 16px; height: 16px; }

/* Sticky form actions at the bottom of a document or big form (VB ERP Form: actions on the right, primary last) */
.savebar {
  position: sticky; bottom: 0; z-index: 20; display: flex; flex-direction: row-reverse; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap;
  margin: 24px -16px -40px calc(-1 * var(--gutter)); padding: 12px 16px 12px var(--gutter);
  background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 8px -4px rgba(0, 7, 22, .10);
}
.savebar-actions { display: flex; flex-direction: row-reverse; align-items: center; gap: 8px; flex-wrap: wrap; }
.savebar-totals { display: flex; align-items: baseline; gap: 8px 24px; flex-wrap: wrap; font-size: 14px; color: var(--text-2); }
.savebar-totals b { font-size: 18px; color: var(--heading); font-variant-numeric: tabular-nums; }
.savebar-totals b.negative { color: var(--danger); }
.save-state { font-size: 14px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.save-state.ok { color: var(--ok); }
.save-state.error { color: var(--danger); }

/* Product picker under an input: <span class="picker"><input data-product-picker="…"></span> */
.picker { position: relative; display: block; }
.picker-list { left: 0; right: auto; top: calc(100% + 4px); min-width: 100%; width: max-content; max-width: min(560px, 90vw); }
.menu-list > .picker-item { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 1px; text-align: left; white-space: normal; line-height: 18px; }
.menu-list > .picker-item.active { background: var(--selected); box-shadow: inset 0 0 0 1px var(--selected-border); border-radius: var(--radius-sm); }
.picker-item .pi-meta { color: var(--muted); font-size: 12px; }

/* ======================================================================
   Modal (VB ERP Modal): <dialog class="modal"> (site.js: data-modal-open / data-modal-close)
   ====================================================================== */
dialog.modal {
  width: min(600px, calc(100vw - 32px)); max-height: calc(100vh - 80px); padding: 0; margin: 64px auto auto;
  border: 0; border-radius: var(--radius); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-pop); overflow: auto;
}
dialog.modal.wide { width: min(820px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: var(--backdrop); }
dialog.modal[open] { animation: modal-in var(--dur-slow) var(--ease); }
@keyframes modal-in { from { opacity: 0; transform: translateY(-8px) scale(.99); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 12px 8px 20px; }
.modal-head h2 { margin: 2px 0 0; font-size: 20px; line-height: 24px; }
.modal-body { padding: 8px 20px 20px; display: grid; gap: 16px; }
.modal-body p { margin: 0; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; background: none; border-top: 1px solid var(--border); }
.modal-foot.start { justify-content: flex-start; }
.modal-foot .spacer { flex: 1; }
.table-settings-grid { display: grid; grid-template-columns: minmax(180px, .8fr) minmax(260px, 1.2fr); gap: 24px; }
.table-settings-grid h3 { margin: 0 0 10px; font-size: 14px; line-height: 20px; }
.table-setting-check { align-items: flex-start; min-height: 32px; padding: 6px 8px; border-radius: var(--radius-sm); }
.table-setting-check:hover { background: var(--surface-2); }
.table-setting-check input { flex: 0 0 auto; margin-top: 3px; }
.table-setting-check small { color: var(--muted); font-weight: 400; }
.table-column-choices { display: grid; gap: 2px; max-height: 360px; overflow: auto; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.table-settings-grid .hint { margin: 10px 0 0; }
.table-tool .icon { width: 16px; height: 16px; }

/* Expandable section (VB ERP ExpandableSection): <details class="expandable"><summary>Title</summary>…</details>;
   details.drawer (legacy «Додати» forms) is its «container» variant */
details.expandable > summary, details.drawer > summary {
  display: flex; align-items: center; gap: 8px; list-style: none; cursor: pointer; color: var(--heading); font-weight: 700;
}
details.expandable > summary::-webkit-details-marker, details.drawer > summary::-webkit-details-marker { display: none; }
details.expandable > summary::before, details.drawer > summary::before {
  content: ""; flex-shrink: 0; width: 16px; height: 16px; background: currentColor; transform: rotate(-90deg); transition: transform var(--dur) var(--ease);
  -webkit-mask: var(--i-caret) center / contain no-repeat; mask: var(--i-caret) center / contain no-repeat;
}
details.expandable[open] > summary::before, details.drawer[open] > summary::before { transform: none; }
details.expandable > summary:hover, details.drawer > summary:hover { color: var(--accent); }
details.expandable > summary { padding: 4px 0; }
details.expandable[open] > summary { margin-bottom: 8px; }
details.drawer { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; }
details.drawer > summary { padding: 16px 20px; font-size: 18px; line-height: 22px; }
details.drawer[open] > summary { padding-bottom: 8px; }
details.drawer > .drawer-body { padding: 8px 20px 20px; }
details.inline-edit > summary { list-style: none; cursor: pointer; color: var(--link); font-weight: 700; }
details.inline-edit > summary::-webkit-details-marker { display: none; }
details.inline-edit[open] > summary { margin-bottom: 8px; }

/* ======================================================================
   Sign-in
   ====================================================================== */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 24px; background: var(--surface-2); }
.auth-wrap { display: grid; gap: 20px; justify-items: center; width: min(400px, 100%); }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; letter-spacing: -.015em; color: var(--heading); }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 6px; background: var(--logo-bg); color: #fff; font-weight: 700; font-size: 15px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; width: 100%; display: grid; gap: 16px; }
.auth-card h1 { text-align: center; margin: 0 0 4px; font-size: 20px; line-height: 24px; }
.auth-card .btn { width: 100%; min-height: 36px; margin-top: 4px; }
.auth-foot { font-size: 12px; color: var(--muted); margin: 0; text-align: center; }

/* ======================================================================
   Legacy components (kept so every page looks right without markup changes)
   ====================================================================== */
/* Products in tables: no letter avatars (Poster shows a photo or nothing); SKU on the same line, grey. */
table .thumb { display: none; }
.prod { display: flex; align-items: center; gap: 10px; min-width: 0; }
.prod-text { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.prod-text a, .prod-text strong { font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.prod-text a { color: var(--link); }
.prod-text a:hover { color: var(--link-hover); }
.prod-text small { color: var(--muted); font-size: 12px; white-space: nowrap; }
/* In tables a product stays on one line: the name ends with … (max 360 px), the SKU stays visible. */
table .prod-text { white-space: nowrap; max-width: 360px; }
table .prod-text a, table .prod-text strong { min-width: 0; white-space: nowrap; }
table .prod-text small { flex-shrink: 0; }
.thumb {
  --h: 210;
  display: inline-grid; place-items: center; flex-shrink: 0; width: 36px; height: 36px; border-radius: 9px;
  font-size: 12.5px; font-weight: 700; letter-spacing: .02em; color: hsl(var(--h) 45% 38%);
  background: hsl(var(--h) 60% 94%); border: 1px solid hsl(var(--h) 45% 86%);
}
.thumb-lg { width: 64px; height: 64px; border-radius: 14px; font-size: 20px; }
:root[data-theme="dark"] .thumb { color: hsl(var(--h) 70% 80%); background: hsl(var(--h) 30% 22%); border-color: hsl(var(--h) 25% 30%); }

.fin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 16px; }
.fin-head h1 { margin: 0; }
.fin-title p { margin: 2px 0 0; font-size: 13px; }
.fin-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fin-filters {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px;
}
.fin-filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.fin-filter-row > label { display: flex; align-items: center; gap: 8px; }
.fin-filter-row select { min-width: 180px; width: auto; }
.fin-filter-row input[type=search] { min-width: 200px; }
.fin-dates input[type=date] { width: 150px; }
.fin-presets { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.fin-presets > a, .fin-presets > span {
  padding: 5px 12px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; color: var(--text-2); white-space: nowrap;
  border: 1px solid var(--border-strong); background: var(--surface);
}
.fin-presets > span { color: var(--muted); }
.fin-presets > a:hover { border-color: var(--muted); color: var(--text); text-decoration: none; }
.fin-presets > .active { background: var(--chip-on); border-color: var(--chip-on); color: var(--chip-on-text); }

.fin-chart-box { margin: 0 0 16px; padding: 16px 16px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.fin-chart { display: block; width: 100%; height: auto; overflow: visible; }
.fin-chart .fin-grid { stroke: var(--line); stroke-width: 1; }
.fin-chart .fin-zero { stroke: var(--border-strong); }
.fin-chart .fin-axis { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.fin-chart .fin-line { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.fin-chart .fin-area { opacity: .12; }
.fin-chart .fin-dot { fill: var(--surface); stroke-width: 2; }
.fin-chart .fin-bar { opacity: .9; }
.fin-chart .fin-hit { fill: transparent; }
.fin-chart .fin-hit:hover { fill: var(--accent); fill-opacity: .06; }
.fin-legend { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 8px; padding-left: 64px; font-size: 13px; color: var(--text-2); }
.fin-legend span { display: inline-flex; align-items: center; gap: 8px; }
.fin-legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }

/* P&L and cash flow tree tables */
table.pl td, table.pl th { height: 35px; padding-top: 6px; padding-bottom: 6px; }
table.pl td:first-child, table.pl th:first-child { min-width: 260px; }
table.pl tbody tr td { background: var(--surface); }
table.pl tbody tr.pl-block td { background: var(--surface-3); font-weight: 600; color: var(--text); }
table.pl tbody tr.pl-line td:first-child { padding-left: 36px; color: var(--text-2); }
table.pl tbody tr.pl-result td { background: var(--accent-soft); font-weight: 700; color: var(--text); }
table.pl tbody tr.pl-result td:first-child { color: var(--accent-text); }
table.pl tbody tr.pl-note td { color: var(--muted); }
table.pl .pct { display: block; font-size: 11.5px; font-weight: 400; color: var(--muted); }
table.pl .hint { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }

.who-cell { display: flex; align-items: center; gap: 10px; }
.who-avatar { display: none; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin-bottom: 16px; }
.settings-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: grid; gap: 12px; align-content: start; }
.settings-card h3 { margin: 0; display: flex; align-items: center; gap: 8px; }
.settings-card dl { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; margin: 0; }
.settings-card dt { color: var(--text-2); }
.settings-card dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.ladder { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ladder li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.int-card-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }

.card-head { display: flex; gap: 16px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.card-head .meta { display: flex; gap: 8px 16px; flex-wrap: wrap; color: var(--muted); font-size: 13.5px; align-items: center; }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.card-head h1 { margin: 0 0 4px; }
.dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 20px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.codes { display: flex; gap: 6px; flex-wrap: wrap; }
.codes code { font-size: 12.5px; }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 110px; padding-top: 8px; }
.bars div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; min-width: 0; }
.bars span { width: 100%; max-width: 36px; border-radius: 4px 4px 1px 1px; background: var(--accent); min-height: 2px; }
.bars small { font-size: 11px; color: var(--muted); white-space: nowrap; }

.tree-name { display: inline-flex; align-items: center; gap: 8px; }
.tree-name .icon { width: 16px; height: 16px; color: var(--muted); }
.tree-guide { display: inline-block; width: 14px; height: 14px; border-left: 1px solid var(--border-strong); border-bottom: 1px solid var(--border-strong); border-bottom-left-radius: 4px; margin: -8px 2px 0 0; }
.row-actions { display: inline-flex; gap: 4px; align-items: center; flex-wrap: nowrap; }

.paybar { display: inline-block; width: 56px; height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; vertical-align: middle; margin-right: 6px; }
.paybar i { display: block; height: 100%; background: var(--ok-fill); border-radius: 3px; }

/* Photo reports */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 16px 0; }
.photo-grid-large { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.photo-card {
  display: block; margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; color: inherit; text-decoration: none; transition: box-shadow .12s ease;
}
a.photo-card:hover { box-shadow: var(--shadow-sm); text-decoration: none; }
.photo-card img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--surface-3); }
.photo-card-body { display: block; padding: 10px 12px; font-size: 13.5px; }

/* Price tags: 58 × 40 mm (always black on white) */
.price-tags { display: flex; flex-wrap: wrap; gap: 2mm; }
.price-tag { width: 58mm; height: 40mm; box-sizing: border-box; border: 1px dashed #9ca3af; padding: 2mm; display: flex; flex-direction: column; justify-content: space-between; background: #fff; color: #000; overflow: hidden; }
.price-tag-name { font-size: 11pt; font-weight: 600; line-height: 1.15; max-height: 3.5em; overflow: hidden; }
.price-tag-price { font-size: 20pt; font-weight: 700; }
.price-tag-sku { font-size: 7pt; color: #6b7280; }
.ean13 { height: 12mm; width: 34mm; }
.price-tags.tpl-small .price-tag { width: 40mm; height: 25mm; padding: 1.5mm; }
.price-tags.tpl-small .price-tag-name { font-size: 8pt; max-height: 2.4em; }
.price-tags.tpl-small .price-tag-price { font-size: 14pt; }
.price-tags.tpl-small .ean13 { height: 7mm; width: 24mm; }
.price-tags.tpl-large .price-tag { width: 90mm; height: 60mm; padding: 4mm; }
.price-tags.tpl-large .price-tag-name { font-size: 15pt; max-height: 3.6em; }
.price-tags.tpl-large .price-tag-price { font-size: 34pt; }
.price-tags.tpl-large .ean13 { height: 16mm; width: 48mm; }
.tpl-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.tpl-picker label { display: flex; flex-direction: row; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer; background: var(--surface); font-weight: 500; color: var(--text); }
.tpl-picker label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.tpl-picker small { color: var(--muted); font-weight: 400; }

/* Printable count sheet (stock take) */
.sheet { background: #fff; color: #000; padding: 24px; border-radius: var(--radius); border: 1px solid var(--border); }
.sheet h1 { font-size: 18pt; margin: 0 0 4px; color: #000; }
.sheet .sheet-meta { display: flex; gap: 24px; flex-wrap: wrap; font-size: 10.5pt; margin-bottom: 12px; color: #333; }
.sheet table { border: 1px solid #000; border-radius: 0; background: #fff; font-size: 10pt; }
.sheet th, .sheet td { border: 1px solid #000; padding: 4px 8px; color: #000; background: #fff !important; height: auto; }
.sheet thead th { position: static; background: #f0f0f0 !important; color: #000; font-size: 9.5pt; }
.sheet td.blank { width: 28mm; }
.sheet .sign { display: flex; gap: 48px; margin-top: 24px; font-size: 10.5pt; }
.sheet .sign span { flex: 1; border-top: 1px solid #000; padding-top: 4px; }

/* ======================================================================
   Kit additions (feat/ui-poster): column chooser, expandable rows
   ====================================================================== */
.col-hidden { display: none !important; }
.columns-list { gap: 10px; }
.expander .icon { transition: transform .15s ease; }
.expander[aria-expanded="true"] .icon { transform: rotate(90deg); }
tr.detail-row > td { background: var(--surface-2); padding: 10px 20px 14px 52px; height: auto; white-space: normal; }
tr.detail-row:hover > td { background: var(--surface-2); }
.detail > table { width: auto; min-width: min(640px, 100%); margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.card .detail > table { width: auto; margin: 0; border: 1px solid var(--line); border-radius: 8px; }
.detail th, .detail td { height: 34px; padding-top: 6px; padding-bottom: 6px; }
.detail thead th { position: static; font-size: 12.5px; }
.detail p { margin: 0; }
.detail .more { margin-top: 8px; }
.doc-meta .wide { grid-column: 1 / -1; }
.quick-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.quick-action {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 500;
}
.quick-action:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); color: var(--accent-text); text-decoration: none; }

/* ======================================================================
   Responsive
   ====================================================================== */
@media (max-width: 1100px) {
  .fields.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  h1 { font-size: 20px; line-height: 24px; }
  .page-head .actions .btn-text { display: none; }
  /* An applied condition with a long text («Зміна: ЛЬВІВ-… · 01.10 09:33–21:02») wraps inside the screen. */
  .filterbar a.chip { max-width: 100%; white-space: normal; text-align: left; }

  /* Wide tables scroll sideways inside their card instead of stretching the page */
  /* position: the scroll box holds absolutely placed bits too (.sr-only labels in static header cells) */
  table { position: relative; display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  thead th { position: static; }
  th, td { white-space: nowrap; }
  td.trunc { max-width: 60vw; }
  .panel, .card { padding: 16px; }
  .panel > table, .card > table { width: calc(100% + 32px); margin-left: -16px; margin-right: -16px; }
  .card > .table-scroll, .panel > .table-scroll { margin: 0 -16px; }
  .panel table th:first-child, .panel table td:first-child, .card table th:first-child, .card table td:first-child { padding-left: 16px; }
  .card.flush, .card.table-card { padding: 0; }
  .card.flush > table, .card.table-card > table { width: 100%; margin: 0; }
  .filterbar { padding: 12px; }
  .search { flex: 1 1 100%; }
  form.toolbar > label:not(.check), form.filters label { min-width: 0; flex: 1 1 100% !important; max-width: none; }
  .toolbar > div { width: 100%; }
  .fields, .fields.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .form-rows > label, .form-rows > .row { grid-template-columns: minmax(0, 1fr); }
  .form-rows > label > .hint, .form-rows > .row > .hint { grid-column: 1; }
  .form-rows > label.check { padding-left: 0; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .savebar { margin-bottom: -32px; }
  .savebar-totals b { font-size: 16px; }
  dialog.modal { margin-top: 24px; max-height: calc(100vh - 48px); }
  .table-settings-grid { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .menu-list { max-width: calc(100vw - 24px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Employee directory: filters and the people-list table share the VB ERP directory pattern. */
.employee-tabs { margin-bottom: 16px; }
.employee-list-filters { align-items: end; }
.employee-list-filters .search { flex: 1 1 240px; max-width: 360px; }
.employee-filter { display: grid; gap: 4px; min-width: 140px; color: var(--text-2); font-size: 12px; font-weight: 700; }
.employee-filter select { min-width: 0; width: 100%; color: var(--text); font-size: 14px; font-weight: 400; }
.employee-directory { min-width: 940px; }
.employee-directory th:nth-child(1) { min-width: 220px; }
.employee-directory th:nth-child(2) { min-width: 110px; }
.employee-directory th:nth-child(3) { min-width: 140px; }
.employee-directory th:nth-child(4) { min-width: 130px; }
.employee-directory th:nth-child(5) { min-width: 180px; }
.employee-directory th:nth-child(6) { min-width: 160px; }
.employee-name-link { font-weight: 700; }
.employee-kind { display: inline-flex; align-items: center; min-height: 22px; padding: 1px 8px; border: 1px solid var(--border); border-radius: var(--radius-badge); background: var(--surface-2); color: var(--text-2); font-size: 12px; line-height: 18px; white-space: nowrap; }
/* Literal matches in table search results stay legible in both themes and inside links or badges. */
mark.search-match { padding: 0 1px; border-radius: 2px; background: var(--accent-active); color: var(--heading); box-shadow: inset 0 -1px var(--accent); font-weight: 700; }
.vbfine-create-tabs { margin-bottom: 16px; }
.vbfine-create-form .form-grid { max-width: 980px; }
.vbfine-create-form .required-mark { color: var(--danger); }
.vbfine-create-form .validation-summary:not(:empty) { margin: 0 0 16px; color: var(--danger); font-size: 13px; font-weight: 700; }
.vbfine-employee-select[multiple] { min-height: 240px; }
.vbfine-bulk-confirm { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.vbfine-bulk-confirm .hint { margin: 8px 0 0 24px; }
.vbfine-list-filters { margin-bottom: 16px; }
.vbfine-list-filters .search-field { flex: 1 1 280px; }
.vbfine-list-filters .search-field input { width: 100%; }
.vbfine-list-filters .filter-checks { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.vbfine-list-filters .filter-checks legend { padding: 0 4px; color: var(--muted); font-size: 12px; }
.vbfine-include-paid { white-space: nowrap; }
.vbfine-detail { margin-top: 16px; }
.vbfine-edit { margin-top: 16px; }
.vbfine-edit-form { max-width: 980px; margin-top: 12px; }
.vbfine-auth-meta { margin-bottom: 20px; }
.vbfine-auth-link { padding-top: 16px; border-top: 1px solid var(--border); }
.vbfine-auth-link h3 { margin: 0 0 6px; }
.vbfine-auth-link > p { margin: 0 0 12px; color: var(--text-2); }
.vbfine-auth-link-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.vbfine-auth-link-row input { min-width: 0; }
.vbfine-auth-revoke { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding-top: 16px; border-top: 1px solid var(--border); }
@media (max-width: 900px) {
  .employee-list-filters .search { flex-basis: 100%; max-width: none; }
  .employee-filter { flex: 1 1 130px; }
}
@media (max-width: 600px) {
  .vbfine-auth-link-row { grid-template-columns: 1fr; }
}

/* ======================================================================
   Print
   ====================================================================== */
@media print {
  .sidebar, .topnav, .breadcrumbs, .rail, .tools, .split-panel, .flashbar, .skip-link, .no-print, .nav-toggle, .scrim, .savebar, .filterbar, .pager, .page-head .actions { display: none !important; }
  .main, .content { margin: 0 !important; padding: 0 !important; max-width: none; }
  body { background: #fff; color: #000; }
  .panel, .card, table, .kpi, .tile { box-shadow: none !important; border-color: #ccc !important; }
  .table-scroll { overflow: visible !important; margin: 0 !important; }
  .table-card { border: 0 !important; }
  .table-card table.list { display: table !important; width: 100% !important; }
  .table-card table.list th, .table-card table.list td { white-space: normal; }
  thead th { position: static; }
  .price-tag { border: 1px solid #000; break-inside: avoid; }
  .sheet { border: 0; padding: 0; }
  .sheet tr { break-inside: avoid; }
  tr.row-hot td { background: none !important; }
}

