/* Compact everywhere, for every role and screen (owner's rule, ANSWERS_5 §2): dense tables, small fonts,
   many rows and fields per screen. There is no "large" variant, not even for the admin's sale form. */
:root {  /* aliases: the colours themselves are in theme.css */
  --bg: var(--c-page);
  --card: var(--c-surface);
  --text: var(--c-text);
  --muted: var(--c-text-muted);
  --line: var(--c-border);
  --accent: var(--c-accent);
  --accent-text: var(--c-accent-text);
  --ok: var(--c-ok-bg);
  --err: var(--c-err-bg);
  --err-text: var(--c-err);
  --head: var(--c-tabs-bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 13px/1.35 system-ui, "Segoe UI", Arial, sans-serif; }
main { max-width: 1500px; margin: 0 auto; padding: 10px 14px; }
h1 { font-size: 18px; margin: 0 0 8px; }
h2 { font-size: 15px; margin: 14px 0 6px; }
p { margin: 0 0 8px; }
a { color: var(--c-accent-dark); }
.muted { color: var(--muted); }

.topbar { display: flex; justify-content: space-between; align-items: center; background: var(--c-header); color: var(--c-header-text); padding: 0 14px; }
.brand { display: inline-flex; align-items: center; margin-right: 14px; color: var(--c-gold); font-weight: 700; font-size: 15px; text-decoration: none; vertical-align: middle; }
.brand img { height: 28px; display: block; }
.topbar nav a { display: inline-block; padding: 8px 10px; text-decoration: none; color: var(--c-header-text); font-weight: 500; border-bottom: 2px solid transparent; }
.topbar nav a:hover { color: var(--c-surface); }
.topbar nav a.active { color: var(--c-surface); border-bottom: 2px solid var(--c-gold); }
.who { color: var(--c-header-text); font-size: 12px; }
.topbar { flex-wrap: wrap; }
.db-banner { flex: 0 0 auto; width: calc(100% + 28px); margin: 0 -14px; padding: 3px 14px; font-size: 13px; font-weight: 700; letter-spacing: .04em; color: var(--c-db-text); }
.db-banner.db-mirror { background: var(--c-db-mirror); }
.db-banner.db-sandbox { background: var(--c-db-sandbox); }
.db-banner.db-demo { background: var(--c-db-demo); }
.sync-warning { flex: 0 0 auto; width: calc(100% + 28px); margin: 0 -14px; padding: 3px 14px; font-size: 13px; font-weight: 700; background: var(--c-err-bg); color: var(--c-err); border-bottom: 1px solid var(--c-err); }
.sync-warning a { color: inherit; text-decoration: underline; }
.db-switch { margin-right: 10px; }
.db-switch details { display: inline-block; position: relative; }
.db-switch summary { cursor: pointer; display: inline; color: var(--c-gold); font-weight: 600; }
.db-switch .menu-list { position: absolute; right: 0; top: 100%; z-index: 40; min-width: 140px; background: var(--c-surface); border: 1px solid var(--c-border-strong); padding: 2px 0; }
.db-switch .menu-item { display: block; padding: 4px 10px; color: var(--c-text); text-decoration: none; white-space: nowrap; }
.db-switch a.menu-item:hover { background: var(--c-row-hover); }
.db-switch .menu-item.current { font-weight: 700; color: var(--c-text-muted); }
.mirror-note { color: var(--c-text-muted); font-size: 12px; border: 1px dashed var(--c-border-strong); padding: 1px 8px; border-radius: var(--radius); }
.who button.link { color: var(--c-gold); }
.subbar { display: flex; justify-content: space-between; align-items: center; background: var(--c-tabs-bg); border-bottom: 1px solid var(--c-border); padding: 0 14px; }
.subbar nav a { display: inline-block; padding: 4px 10px 2px; text-decoration: none; color: var(--c-tabs-text); border-bottom: 2px solid transparent; }
.subbar nav a.active { color: var(--c-header); border-bottom: 2px solid var(--c-accent); font-weight: 600; }
.subbar .button { padding: 2px 10px; }
form.inline { display: inline; }
button.link { background: none; border: 0; color: var(--c-accent-dark); font: inherit; cursor: pointer; padding: 0 0 0 6px; }

.card { background: var(--card); border: 1px solid var(--c-border-strong); border-radius: 6px; padding: 12px; }
.card.narrow { max-width: 340px; margin: 40px auto; }

label { display: block; font-weight: 500; margin-bottom: 2px; }
input, select, textarea { width: 100%; font: inherit; color: var(--c-text); padding: 4px 7px; border: 1px solid var(--c-border-strong); border-radius: var(--radius); background: var(--c-surface); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--c-header); outline-offset: -1px; border-color: var(--c-header); }
button:focus-visible, .button:focus-visible, button:active, .button:active, summary:focus-visible { outline: 2px solid var(--c-header); outline-offset: 1px; }
input[type=checkbox] { width: 14px; height: 14px; vertical-align: middle; margin: 0 5px 0 0; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 6px 14px; }
.field { margin-bottom: 4px; }
.field.checkbox label { font-weight: 400; }
.field.has-error input, .field.has-error select { border-color: var(--err-text); }
.field small { display: block; line-height: 1.25; }
.errorlist { color: var(--err-text); list-style: none; padding: 0; margin: 2px 0 0; }

button, .button { display: inline-block; font: inherit; font-weight: 500; padding: 4px 12px; border-radius: var(--radius); border: 1px solid var(--c-border-strong); background: var(--c-surface); color: var(--c-accent-dark); cursor: pointer; text-decoration: none; }
.primary { background: var(--c-accent); border-color: var(--c-accent-dark); color: var(--c-accent-text); font-weight: 600; }
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--c-border-strong); }
th, td { text-align: left; padding: 3px 8px; border-bottom: 1px solid var(--line); }
th { background: var(--c-table-head); color: var(--c-text); font-weight: 700; position: sticky; top: 0; border-bottom: 2px solid var(--c-header); }
tbody tr:nth-child(even) { background: var(--c-row-alt); }
tbody tr:hover { background: var(--c-row-hover); }

.badge.kind-studio { background: var(--c-kind-studio-bg); color: var(--c-kind-studio); }   /* write-off kinds: coloured marks */
.badge.kind-gift { background: var(--c-ok-bg); color: var(--c-ok); }
.badge.kind-reimburse { background: var(--c-warn-bg); color: var(--c-warn); }
.badge.kind-shortage { background: var(--c-err-bg); color: var(--c-err); }
.kpis { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }
.kpi { background: var(--card); border: 1px solid var(--c-border-strong); border-radius: 6px; padding: 6px 12px; min-width: 150px; }
.kpi span { display: block; color: var(--muted); font-size: 12px; }
.kpi b { font-size: 15px; }
.chart-switch { font-size: 12px; font-weight: 400; margin-left: 12px; }
.chart-switch label { margin-right: 8px; }
.bars { margin-bottom: 10px; }
.bar-row { display: grid; grid-template-columns: 220px 1fr 130px; gap: 8px; align-items: center; padding: 1px 0; }
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--head); height: 12px; border-radius: 3px; }
.bar-fill { display: block; height: 12px; background: var(--c-accent); border-radius: 3px; width: 0; }
.bar-value { text-align: right; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; align-items: start; }
.motivation { font-size: 15px; margin: 4px 0 8px; }
.bad-text { color: var(--c-err); }
tr.today-row td { background: var(--c-warn-bg); font-weight: 600; }
.plain-row { padding: 2px 0; }
details.filter-box { margin-bottom: 6px; }
details.filter-box > summary { cursor: pointer; font-weight: 600; padding: 2px 0; user-select: none; }
tfoot tr.totals th { position: sticky; bottom: 0; top: auto; background: var(--c-header); color: var(--c-header-text); border-top: 0; z-index: 2; }
tfoot tr.totals th b, tfoot tr.totals th.num { color: var(--c-gold); }  /* the totals row stays in view */
.filters { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.filters input, .filters select { width: auto; }
.filters input[type=search] { width: 240px; }
.filters select { max-width: 220px; }
.filters label { margin: 0; font-weight: 400; }
.inline-check { display: inline-flex; align-items: center; font-weight: 400; margin: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.archived td { color: var(--muted); }
table.compact { width: auto; min-width: 320px; }
table.compact td input, table.compact td select { padding: 2px 5px; }
dl.details { display: grid; grid-template-columns: 150px 1fr; gap: 2px 12px; margin: 0; }
dl.details dt { color: var(--muted); }
dl.details dd { margin: 0; }
.pagination { display: flex; gap: 12px; align-items: center; }
.tiles { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.tiles a { display: block; padding: 8px 12px; background: var(--card); border: 1px solid var(--c-border-strong); border-radius: 6px; text-decoration: none; font-weight: 500; }

.message { padding: 6px 10px; border-radius: var(--radius); margin-bottom: 8px; background: var(--ok); }
.message.error, .errors { background: var(--err); color: var(--err-text); padding: 6px 10px; border-radius: var(--radius); margin-bottom: 8px; }

/* Document screens (receipts, transfers, stock): header fields in a row, then a dense lines table. */
.doc-head { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 12px; margin-bottom: 8px; }
.lines td { padding: 1px 4px; }
.lines input, .lines select { padding: 2px 5px; }
.lines td.num input { text-align: right; }
.totals { text-align: right; font-weight: 600; margin: 6px 0; }
.badge { display: inline-block; padding: 0 6px; border-radius: 8px; background: var(--head); font-size: 12px; }
.badge.ok { background: var(--ok); }
.badge.warn { background: var(--c-warn-bg); }
.badge.bad { background: var(--c-err-bg); color: var(--err-text); font-weight: 600; }
tr.overdue td { background: var(--c-warn-bg); }
.payments { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; margin: 6px 0 10px; padding: 6px 8px; background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: 6px; }
.payments .pay { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border: 1px solid var(--c-border-strong); border-radius: 6px; background: var(--c-surface); }
.payments .pay.on { border-color: var(--c-header); background: var(--c-row-hover); }
.payments .pay input[type=number] { width: 110px; }
.actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pay-box { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 6px 10px; margin: 6px 0; background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: 6px; }
.pay-box select, .pay-box input { width: auto; }
tr.short td, tr.short td input, tr.short td .line-stock { color: var(--c-err); font-weight: 600; }  /* quantity above the stock */
tr.cancelled-row td { color: var(--muted); text-decoration: line-through; }
tr.cancelled-row td .badge { text-decoration: none; }

/* «Создать документ» drop-down (no script needed) */
details.pop-menu { position: relative; display: inline-block; }
details.pop-menu > summary { list-style: none; cursor: pointer; }
details.pop-menu > summary::-webkit-details-marker { display: none; }
details.pop-menu .pop { position: absolute; z-index: 15; background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: 6px; box-shadow: none; min-width: 220px; padding: 3px 0; }
details.pop-menu .pop a { display: block; padding: 4px 12px; color: var(--text); text-decoration: none; white-space: nowrap; }
details.pop-menu .pop a:hover { background: var(--c-row-hover); }

/* The chain of related documents: order → invoice → shipment → УПД → payments */
.chain { display: flex; align-items: flex-start; gap: 6px; flex-wrap: wrap; }
.chain-col { display: flex; flex-direction: column; gap: 4px; min-width: 190px; }
.chain-title { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.chain-arrow { align-self: center; color: var(--muted); font-size: 18px; }
.chain-card { display: block; padding: 5px 8px; border: 1px solid var(--c-border-strong); border-radius: 6px; background: var(--c-surface); color: var(--text); text-decoration: none; }
.chain-card:hover { border-color: var(--accent); }
.chain-card.current { border: 2px solid var(--c-header); background: var(--c-row-hover); }
.chain-card.cancelled { color: var(--muted); text-decoration: line-through; }
.chain-card .tick { color: var(--c-ok); font-weight: 700; }
.chain-card.cancelled .tick { color: var(--err-text); }
.neg { color: var(--err-text); font-weight: 600; }

.lines .remove { padding: 0 7px; line-height: 1.2; }
.lines.no-cost .cost-col { display: none; }
.lines tr[hidden] { display: none; }
.suggest { position: absolute; z-index: 20; background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: var(--radius); box-shadow: none; max-height: 280px; overflow: auto; }
.suggest div { padding: 3px 8px; cursor: pointer; white-space: nowrap; }
.suggest div.active, .suggest div:hover { background: var(--c-row-hover); }

/* Group tree on the left of «Товары» and «Остатки» (ANSWERS_5 §1) */
.with-tree { display: grid; grid-template-columns: 210px 1fr; gap: 12px; align-items: start; }
.tree { position: sticky; top: 4px; background: var(--card); border: 1px solid var(--c-border-strong); border-radius: 6px; padding: 4px; max-height: calc(100vh - 20px); overflow: auto; }
.tree-row[hidden] { display: none; }
/* the sidebar tree and the picker tree are <div class="tree-row">; a <tr class="tree-row"> of the home tables must stay a table row */
div.tree-row { display: flex; align-items: center; min-width: 0; }
div.tree-row.depth-2 { padding-left: 14px; } div.tree-row.depth-3 { padding-left: 28px; } div.tree-row.depth-4 { padding-left: 42px; }
.tree-toggle { display: inline-block; width: 14px; flex: none; text-align: center; color: var(--muted); text-decoration: none; }
div.tree-row .tree-item { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }  /* long names are cut, the tooltip has the full one */
.tree-move { margin-top: 6px; font-size: 12px; }
.tree-item { display: block; padding: 2px 8px; border-radius: var(--radius); color: var(--text); text-decoration: none; }
.tree-item:hover { background: var(--c-row-hover); }
.tree-item.active { background: var(--c-row-hover); color: var(--c-header); border-left: 3px solid var(--c-accent); font-weight: 600; }
.tree-item .count { opacity: .7; }

details.raw summary { cursor: pointer; font-size: 11px; }
details.raw pre { margin: 2px 0 0; padding: 4px 6px; background: var(--head); border-radius: var(--radius); font-size: 11px; white-space: pre-wrap; max-height: 260px; overflow: auto; }
td.diff.neg { color: var(--err-text); font-weight: 600; }
td.diff.pos { color: var(--c-ok); font-weight: 600; }
table.count input.actual { padding: 1px 5px; text-align: right; }
.group-checks ul { list-style: none; display: flex; flex-wrap: wrap; gap: 2px 16px; padding: 0; margin: 0; }
.group-checks label { font-weight: 400; margin: 0; }

/* «Из справочника» picker window (ANSWERS_5 §2) */
.pick-button { padding: 1px 8px; margin-left: 6px; font-weight: 400; }
.modal-overlay { position: fixed; inset: 0; background: var(--c-overlay); z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal-overlay[hidden] { display: none; }
.modal { background: var(--c-surface); border-radius: 8px; width: min(980px, 96vw); height: min(620px, 92vh); display: flex; flex-direction: column; box-shadow: none; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; border-bottom: 1px solid var(--line); }
.modal-head .link { font-size: 20px; line-height: 1; }
.modal-body { flex: 1; display: grid; grid-template-columns: 210px 1fr; min-height: 0; }
.modal-tree { overflow: auto; border-right: 1px solid var(--line); padding: 4px; }
.modal-right { display: flex; flex-direction: column; min-height: 0; }
.modal-bar { display: flex; gap: 6px; padding: 6px; border-bottom: 1px solid var(--line); }
.modal-table { overflow: auto; flex: 1; }
.modal-table table { border: 0; }
.modal-foot { display: flex; gap: 8px; align-items: center; padding: 6px 12px; border-top: 1px solid var(--line); }
.qty-btn { padding: 0 8px; line-height: 1.3; }
.qty-input { width: 54px; text-align: center; margin: 0 2px; }

/* Stock levels (ANSWERS_4 §5): out of stock red, low amber. */
tr.stock-out td { background: var(--c-stock-out-bg); color: var(--c-text); }
tr.stock-low td { background: var(--c-stock-low-bg); color: var(--c-text); }
tr.group-row th { background: var(--c-table-head); font-size: 13px; }
tr.subtotal td { font-weight: 600; background: var(--c-row-alt); }
.swatch { display: inline-block; width: 12px; height: 12px; vertical-align: middle; border: 1px solid var(--line); margin: 0 3px 0 10px; }
.swatch.out { background: var(--c-stock-out-bg); }
.swatch.low { background: var(--c-stock-low-bg); }
.quick { display: inline-flex; gap: 2px; }

/* Print: only the content (stock by groups, lists). Every list has a «Печать» button. */
@media print {
  body { background: var(--c-surface); font-size: 11px; }
  .topbar, .subbar, .no-print, .pagination, .message, button, .button { display: none !important; }
  main { max-width: none; padding: 0; }
  th { position: static; }
  table { border: 0; }
  tr.group-row { break-after: avoid; }
  tr { break-inside: avoid; }
  tbody tr:hover { background: none; }
}

/* Sticky navigation (ANSWERS_7 п. 23): the section row and the page row stay at the top. */
.topbar { position: sticky; top: 0; z-index: 30; }
.subbar { position: sticky; top: var(--sticky-top, 37px); z-index: 29; }

/* List title row (п. 1): title, accent create button, «Фильтр», «Печать»; the panel opens under the row. */
.list-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 6px; }
.list-head h1 { margin: 0 6px 0 0; }
.button.accent { background: var(--c-accent); border-color: var(--c-accent-dark); color: var(--c-accent-text); font-weight: 600; }
.list-head label.button { margin: 0; display: inline-block; }
.filter-check:checked ~ label.filter-toggle { background: var(--c-row-hover); border-color: var(--c-accent-dark); }
.filter-panel { display: none; flex-basis: 100%; background: var(--card); border: 1px solid var(--c-border-strong); border-radius: 6px; padding: 8px; }
.filter-check:checked ~ .filter-panel { display: block; }
.filter-panel .filters { margin: 0; align-items: flex-end; }
.filter-panel .filters > * { max-width: 220px; }
.filter-panel .filters > .period { max-width: none; }
.filter-buttons { white-space: nowrap; }
.period { min-width: 260px; }
.period-quick { font-size: 12px; margin-bottom: 2px; }
.period-quick details { display: inline-block; position: relative; }
.period-quick summary { display: inline; cursor: pointer; list-style: none; color: var(--c-accent-dark); }
.period-quick .pop { position: absolute; z-index: 30; background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: var(--radius); padding: 3px 0; min-width: 110px; }
.period-quick .pop a { display: block; padding: 3px 12px; white-space: nowrap; }
.period-name { display: flex; align-items: center; flex-wrap: nowrap; gap: 4px; }
.period-name > * { flex: 0 0 auto; }
.period-name .button { padding: 2px 8px; }
.period-name .button.off { opacity: .35; cursor: default; }
.period-label { cursor: pointer; border: 1px solid var(--c-border-strong); border-radius: var(--radius); padding: 3px 10px; background: var(--c-surface); min-width: 190px; text-align: center; font-weight: 600; font: inherit; font-weight: 600; color: var(--c-text); }
.period-label[hidden], .period-fields[hidden] { display: none; }
.period-fields { display: inline-flex; align-items: center; gap: 4px; }
.period-field { position: relative; display: inline-block; }
.period-input { width: 12.5em; padding-right: 22px; box-sizing: border-box; }
.period-field .cal-icon { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.period-input.invalid { border-color: var(--c-err); background: var(--c-err-bg); }
.cal-icon { cursor: pointer; padding: 0 4px; color: var(--c-accent-dark); user-select: none; }
details.menu { position: relative; }
details.menu > summary { cursor: pointer; list-style: none; }
.menu-items { position: absolute; z-index: 20; background: var(--card); border: 1px solid var(--c-border-strong); border-radius: 6px; padding: 4px 0; min-width: 260px; box-shadow: none; }
.menu-items a { display: block; padding: 4px 12px; color: var(--text); text-decoration: none; white-space: nowrap; }
.menu-items a:hover { background: var(--c-row-hover); }
.menu-items .disabled { display: block; padding: 4px 12px; color: var(--muted); white-space: nowrap; cursor: not-allowed; }

/* Document form button row and related-documents strip (п. 23, 44). */
.doc-bar { position: sticky; top: var(--sticky-sub, 66px); z-index: 25; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: var(--bg); padding: 4px 0; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.doc-bar form { display: inline; }
.chain-strip { position: sticky; bottom: 0; z-index: 25; background: var(--c-surface); border-top: 2px solid var(--c-border-strong); padding: 3px 10px; margin-top: 10px; font-size: 12px; }

/* The price type switch in the «Цена» column header looks like a drop-down list (ANSWERS_7 п. 4). */
.lines th select {
  appearance: none; -webkit-appearance: none; width: auto; min-width: 150px; max-width: 100%; display: block; margin-top: 2px;
  background-color: var(--c-surface); background-repeat: no-repeat;
  background-image: linear-gradient(45deg, transparent 50%, var(--c-text) 50%), linear-gradient(135deg, var(--c-text) 50%, transparent 50%);
  background-position: calc(100% - 13px) 55%, calc(100% - 8px) 55%; background-size: 5px 5px, 5px 5px;
  border: 1px solid var(--c-border-strong); padding: 2px 24px 2px 7px; font-weight: 600; cursor: pointer; text-overflow: clip;
}
.lines th.price-col { min-width: 190px; }
.chain-link { margin-right: 10px; text-decoration: none; white-space: nowrap; }
.chain-link.current { font-weight: 700; text-decoration: underline; }
.chain-link.cancelled { color: var(--muted); text-decoration: line-through; }
.doc-bar .pop-menu .pop .disabled { display: block; padding: 4px 12px; color: var(--muted); white-space: nowrap; cursor: not-allowed; }
.inline-search { margin: 0; }
.inline-search input { margin: 0; }
.lines-tools { display: flex; gap: 8px; align-items: center; margin: 4px 0 2px; min-height: 22px; }
.lines-tools .button { padding: 1px 10px; }
.lines tfoot tr.add-row td { padding: 3px 4px; background: var(--card); border-bottom: 0; }
.add-line-row { display: flex; gap: 8px; align-items: center; }
.add-line-row input { flex: 1 1 auto; max-width: 560px; }
.add-line-row .pick-button { margin-left: 0; padding: 3px 10px; white-space: nowrap; }
.doc-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; margin: 8px 0; }
.doc-foot .comment-box textarea { min-height: 5.5em; resize: vertical; }
.doc-foot .totals { margin: 0; text-align: right; align-self: end; }
.doc-total-row { display: flex; justify-content: flex-end; margin: 6px 0 2px; }
.doc-total-row .doc-total { font-size: 15px; font-weight: 700; margin: 0; }
details.pop-menu .pop.pad { padding: 8px 10px; display: grid; gap: 6px; min-width: 260px; }
td.cut { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pct-cell { position: relative; }
.pct-cell input { padding-right: 16px; }
.pct-cell .pct { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); color: var(--c-text-muted); pointer-events: none; }
.payments > b, .pay-box > b, .chain-title { background: var(--c-panel-head); color: var(--c-text); padding: 1px 6px; border-radius: 3px; }
#day-kpis .kpi b { font-size: 20px; }
.kpi small { display: block; font-size: 11px; }

/* Dates: flatpickr (static/vendor/flatpickr); colours of the calendar are in theme.css */
.datepick-input { width: 10.5em; }
.flatpickr-calendar { font-size: 12px; width: 268px; border-radius: var(--radius); box-shadow: none; }
.flatpickr-calendar .flatpickr-innerContainer, .flatpickr-calendar .dayContainer { width: 266px; min-width: 266px; max-width: 266px; }
.flatpickr-day { max-width: 36px; height: 30px; line-height: 30px; border-radius: var(--radius); }
.flatpickr-months .flatpickr-month { height: 32px; }
.flatpickr-current-month { font-size: 13px; padding-top: 6px; }
.flatpickr-time { height: 34px; max-height: 34px; }
.flatpickr-time input { font-size: 13px; }

/* A row that opens a document on click (ANSWERS_10 п. 7) */
tr[data-row-href] { cursor: pointer; }
tr[data-row-href]:hover td { background: var(--c-row-hover); }

/* toast with «Отменить» (ANSWERS_13 п. 10) */
.message.toast { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 50; max-width: 90%; }
.chain-text { margin-right: 10px; }
.cancelled-row td { color: var(--muted); text-decoration: line-through; }

/* Settings page: sections on the left, content on the right (ANSWERS_13 п. 19) */
.settings-layout { display: grid; grid-template-columns: 200px 1fr; gap: 16px; align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 8px; }
.settings-nav a { display: block; padding: 6px 10px; border: 1px solid var(--c-border-strong); background: var(--card); text-decoration: none; border-radius: 4px; }
.settings-nav a.active { background: var(--c-header); color: var(--c-header-text); font-weight: 600; }
.settings-links { list-style: none; padding: 0; margin: 0; }
.settings-links li { padding: 5px 0; border-bottom: 1px solid var(--c-border); }
.settings-section[hidden] { display: none; }
@media (max-width: 720px) { .settings-layout { grid-template-columns: 1fr; } .settings-nav { flex-direction: row; flex-wrap: wrap; position: static; } }

/* Resizable columns (ANSWERS_13 п. 22): one line, ellipsis, a drag handle on the right border of each head */
table.resizable th, table.resizable td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: none; }
table.resizable td.cut { max-width: none; }
/* before the user drags a column (auto layout) long text is cut instead of stretching the page: real data has long names and comments */
table.resizable:not([style*="table-layout"]) td, table.resizable:not([style*="table-layout"]) td.cut { max-width: 250px; }
.col-resizer { position: absolute; top: 0; right: 0; bottom: 0; width: 7px; cursor: col-resize; user-select: none; touch-action: none; }
.col-resizer:hover { background: var(--c-border-strong); }
.table-menu { position: relative; height: 0; margin: 0; z-index: 3; }  /* takes no height: the list looks as before */
.table-menu details { position: absolute; right: 0; bottom: 1px; }
.table-menu summary { padding: 0 6px; font-size: 11px; line-height: 1.3; }
.table-menu .menu-items button { display: block; width: 100%; text-align: left; }
.home-panel .table-menu details { right: 34px; }


/* «Главная» of the owner and the head: tiles with expanding panels (ANSWERS_13 п. 9) */
.home-period { display: flex; margin: 4px 0 8px; }
.home-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin: 4px 0 10px; }
.tile { display: flex; flex-direction: column; gap: 3px; text-align: left; padding: 7px 10px; background: var(--c-surface); color: var(--c-text); border: 1px solid var(--c-border-strong); border-radius: var(--radius); cursor: pointer; font: inherit; }
.tile.active { border: 2px solid var(--c-header); padding: 6px 9px; background: var(--c-row-alt); }
.tile-wide { grid-column: span 2; }
@media (min-width: 1280px) { .home-tiles { grid-template-columns: 1.7fr 1fr 1fr 1.7fr 1fr; } .home-tiles .tile-wide { grid-column: auto; } }
.tile-title { font-size: 12px; color: var(--c-text-muted); }
.tile-value { font-size: 15px; }
.tile-triple { display: grid; grid-template-columns: 1fr 1fr 1fr; }
.tile-triple .cell { display: flex; flex-direction: column; padding: 0 10px; border-left: 1px solid var(--c-border-strong); }
.tile-triple .cell:first-child { padding-left: 0; border-left: 0; }
.tile-triple small { font-size: 11px; color: var(--c-text-muted); }
.tile-triple b { font-size: 15px; }
.tile-triple .revenue b { color: var(--c-ok); }
.tile-triple .profit b { color: var(--c-accent-dark); }
.tile-triple .margin b { color: var(--c-text); }
.tile-note { font-size: 11px; color: var(--c-text-muted); }
.tile-note.up { color: var(--c-ok); }
.tile-note .warn { color: var(--c-warn); font-weight: 600; }
.home-panel { position: relative; background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: var(--radius); padding: 8px 12px 10px; margin-bottom: 10px; }
.home-panel[hidden] { display: none; }
.home-panel h2 { margin: 0 24px 6px 0; }
.panel-close { position: absolute; top: 4px; right: 6px; padding: 0 7px; line-height: 1.3; }
.home-tree .tree-row { cursor: pointer; }
.home-tree .tree-toggle { display: inline-block; width: 1.1em; color: var(--c-text-muted); }
.home-tree .depth-1 .tree-name { padding-left: 1.4em; }
.home-tree .depth-2 .tree-name { padding-left: 2.8em; }
.home-tree .depth-3 .tree-name { padding-left: 4.2em; }
.home-tree .depth-4 .tree-name { padding-left: 5.6em; }
.home-tree .product-row td { color: var(--c-text-muted); }
.scale-col { width: 110px; }
.scale { display: block; height: 7px; background: var(--c-row-alt); border: 1px solid var(--c-border); }
.scale i { display: block; height: 100%; background: var(--c-accent); }
.stock-blocks { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stock-block { padding: 6px 10px; border-radius: var(--radius); max-height: 360px; overflow: auto; }
.stock-block.out { background: var(--c-stock-out-bg); }
.stock-block.low { background: var(--c-stock-low-bg); }
.stock-block h3 { margin: 0 0 4px; }
.stock-block ul { margin: 0; padding-left: 16px; }
.pay-pop { display: flex; flex-direction: column; gap: 4px; padding: 6px; }
.recent-paid { margin-top: 8px; }
@media (max-width: 720px) { .tile-wide { grid-column: span 1; } .stock-blocks { grid-template-columns: 1fr; } }

/* «Остатки»: the filter as in the other lists, the table fits the page (ANSWERS_16 п. 9) */
.filter-panel .filters .filter-field { display: flex; flex-direction: column; gap: 2px; font-weight: 600; font-size: 12px; max-width: 220px; }
.filter-field .filter-gap { display: block; height: 1.2em; }
.filter-field input, .filter-field select { font-weight: 400; font-size: 13px; }
table.stock .name { width: 100%; max-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.stock th.num, table.stock td.num { width: 1%; white-space: nowrap; }
table.stock thead th.num { white-space: normal; max-width: 110px; }

/* the main tile: four or five values, each in its own cell (ANSWERS_16 п. 10, 15) */
.tile-cells { display: grid; }
.tile-cells.cells-4 { grid-template-columns: repeat(4, auto); }
.tile-cells.cells-5 { grid-template-columns: repeat(5, auto); }
.tile-cells.cells-3 { grid-template-columns: repeat(3, auto); }
.tile-cells .cell { display: flex; flex-direction: column; padding: 0 10px; border-left: 1px solid var(--c-border-strong); }
.tile-cells .cell:first-child { padding-left: 0; border-left: 0; }
.tile-cells small { font-size: 11px; color: var(--c-text-muted); }
.tile-cells b { font-size: 15px; }
.tile-cells .revenue b { color: var(--c-ok); }
.tile-cells .profit b { color: var(--c-accent-dark); }
.tile-cells .pieces b { color: var(--c-text); }
.tile-cells .studio b { color: var(--c-kind-studio); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable.asc::after { content: " ▲"; }
th.sortable.desc::after { content: " ▼"; }

/* «Итоги дня» as tiles; the till (ANSWERS_16 п. 22) */
.day-tiles { grid-template-columns: repeat(4, 1fr); }
.till-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 5px 10px; border: 1px solid var(--c-border-strong); border-radius: var(--radius); background: var(--c-surface); list-style: none; font-size: 14px; }
.till-toggle::-webkit-details-marker { display: none; }
.till-caret { font-size: 14px; line-height: 1; width: 16px; color: var(--c-accent-dark); }
details[open] > .till-toggle .till-caret { transform: rotate(90deg); }
.till-action { margin-left: auto; color: var(--c-accent-dark); font-weight: 600; font-size: 12px; }
.till-table td.till-line { padding: 3px 0; }
.till-panel { padding: 6px 0 4px; }
.till-panel table { width: 100%; }
.till-add { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.till-add select { width: 240px; flex: none; }
.till-add input[name=amount] { width: 120px !important; flex: none; }
.till-add input[name=comment] { flex: 1; min-width: 0; }
.till-add select, .till-add input, .till-add button { font-size: 14px; padding: 5px 8px; }

/* The search-and-choose field (lookup.js, ANSWERS_18 п. 3–4) */
.lookup { position: relative; display: inline-block; min-width: 190px; max-width: 260px; vertical-align: bottom; }
.lookup-field { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; box-sizing: border-box; padding: 3px 8px; background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: var(--radius); color: var(--c-text); font: inherit; text-align: left; cursor: pointer; }
.lookup-field.empty .lookup-text { color: var(--c-text-muted); }
.lookup-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lookup-clear { flex: 0 0 auto; color: var(--c-accent-dark); padding: 0 2px; }
.lookup-clear[hidden], .lookup-box[hidden] { display: none; }
.lookup-box { position: absolute; z-index: 50; left: 0; top: 100%; min-width: 100%; width: max-content; max-width: 420px; margin-top: 2px; background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: var(--radius); }
.lookup-input { display: block; width: 100%; box-sizing: border-box; border: 0; border-bottom: 1px solid var(--c-border); border-radius: 0; padding: 5px 8px; }
.lookup-list { overflow-y: auto; }
.lookup-row { display: flex; align-items: flex-start; gap: 6px; padding: 4px 8px; min-height: 28px; box-sizing: border-box; cursor: pointer; }
.lookup-row.active, .lookup-row:hover { background: var(--c-row-hover); }
.lookup-row.is-group .lookup-name { font-weight: 700; }
.lookup-tick { flex: 0 0 auto; margin: 3px 0 0; }
.lookup-body { display: flex; flex-direction: column; min-width: 0; }
.lookup-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lookup-sub { color: var(--c-text-muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lookup-empty { padding: 8px; color: var(--c-text-muted); }
.lookup-foot { display: flex; justify-content: flex-end; padding: 4px 6px; border-top: 1px solid var(--c-border); }
.lookup-done { padding: 2px 12px; }
.doc-head .lookup { max-width: none; width: 100%; }

/* «Стоимость остатков» (ANSWERS_20 п. 1) */
.basis { display: flex; flex-direction: column; gap: 1px; font-weight: 400; }
.percent-field { display: inline-flex; align-items: center; gap: 4px; font-weight: 400; }
.small { font-size: 11px; }
.filter-panel .filters .filter-field small { font-weight: 400; max-width: 200px; }

/* «Закончились и мало»: two trees in the style of the revenue table (ANSWERS_20 п. 2) */
.stock-tables { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.stock-table { width: 100%; table-layout: fixed; }
.stock-table th.stock-head { text-align: left; }
.stock-table.out th { background: var(--c-stock-out-bg); }
.stock-table.low th { background: var(--c-stock-low-bg); }
.stock-table td:first-child { overflow: hidden; text-overflow: ellipsis; }
.stock-table th:nth-child(3), .stock-table td:nth-child(3) { width: 24px; }
.stock-table th:nth-child(2) { width: 90px; }
.stock-tools { display: flex; gap: 6px; align-items: center; margin: 4px 0; }
@media (max-width: 900px) { .stock-tables { grid-template-columns: 1fr; } }

.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }

/* ANSWERS_24: three tables side by side on the day panel, the studio section */
.day-tables { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: flex-start; }
.day-tables > div { min-width: 220px; }
.day-tables h3 { margin: 0 0 4px; font-size: 13px; }
.outside-revenue { margin-top: 8px; }
.outside-revenue caption { text-align: left; padding: 2px 0; }
.studio-table td.num input { width: 88px; text-align: right; }
.studio-table tfoot th { position: sticky; bottom: 0; background: var(--c-surface); }
.studio-table .cert-cell { white-space: nowrap; }
.studio-table .saving { opacity: 0.6; }
.studio-table .failed { outline: 2px solid var(--c-err); }
.cert-pop { padding: 6px; min-width: 260px; }
.cert-pop select, .cert-pop input { width: 100%; margin-bottom: 4px; }
tr.row-under td { background: var(--c-warn-bg); }
tr.row-over td { background: var(--c-err-bg); }
.inline-form { display: inline; }
.studio-forms { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin: 6px 0; }

/* «Столбцы…» (ANSWERS_24 п. 8в): list of columns with check boxes, dragged to change the order */
.columns-panel { border: 1px solid var(--c-border-strong); background: var(--c-surface); padding: 6px 8px; margin: 2px 0 6px; max-width: 320px; }
.columns-panel ul { list-style: none; margin: 0 0 6px; padding: 0; }
.columns-panel li { display: flex; gap: 6px; align-items: center; padding: 2px 0; cursor: grab; border-bottom: 1px solid var(--c-border); }
.columns-panel button { margin-right: 4px; }
.tile-cells .cell b { white-space: nowrap; }
.day-big { font-size: 22px; margin: 4px 0 6px; font-weight: 600; }
.studio-table .blank-row select { width: 100%; }
.studio-table tfoot .day-grand th { font-size: 18px; }
.studio-table tfoot .day-grand .num { text-align: right; }
.studio-table td.master-name { white-space: nowrap; }
.studio-table tfoot tr.totals th { bottom: 34px; }
.studio-table tfoot tr.day-grand th { bottom: 0; line-height: 26px; }
.studio-table .blank-row select { min-width: 150px; }
.studio-table td.master-name { min-width: 150px; }
.cert-pop .cert-list { max-height: 180px; overflow: auto; margin-bottom: 4px; border: 1px solid var(--c-border); }
.cert-pop .cert-item { display: block; padding: 2px 4px; white-space: normal; }
.cert-pop .cert-item[hidden] { display: none; }
.cert-pop .cert-item input { width: auto; margin: 0 4px 0 0; }

/* ANSWERS_29: employee search field, certificate window, course payments, pay rule cards */
.emp-pick { position: relative; display: inline-flex; width: 100%; }
.emp-pick .emp-input { flex: 1; min-width: 0; }
.emp-pick .emp-toggle { padding: 0 6px; }
.studio-table .blank-row .emp-pick { min-width: 190px; }
.emp-list { position: fixed; z-index: 60; max-height: 260px; overflow: auto; background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: 4px; }
.emp-item, .emp-none { padding: 3px 8px; cursor: pointer; white-space: nowrap; }
.emp-none { color: var(--c-text-muted); cursor: default; }
.emp-item.active, .emp-item:hover { background: var(--c-row-hover); }
.cert-modal { width: min(560px, 96vw); height: auto; max-height: 92vh; }
.cert-modal-body { padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.cert-modal-body input[type=search] { width: 100%; }
.cert-modal .cert-list { max-height: 300px; overflow: auto; border: 1px solid var(--c-border-strong); }
.cert-modal .cert-item { display: flex; justify-content: space-between; gap: 12px; padding: 4px 8px; cursor: pointer; border-bottom: 1px solid var(--c-border); }
.cert-modal .cert-item:hover, .cert-modal .cert-item.active { background: var(--c-row-hover); }
.cert-modal .cert-item.active { outline: 2px solid var(--c-header); outline-offset: -2px; }
#cert-error { color: var(--c-err); }
.pay-state .badge { margin-left: 2px; }
#pay-diff.under { color: var(--c-warn); font-weight: 600; }
#pay-diff.over { color: var(--c-err); font-weight: 600; }
#pay-diff.ok { color: var(--c-ok); font-weight: 600; }
#course-payments input[type=text] { width: 110px; text-align: right; }
.pay-card { margin: 6px 0; padding: 6px 10px; }
.pay-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pay-card-head h2 { margin: 0; }
.pay-summary > div { padding: 2px 0; border-bottom: 1px solid var(--c-border); }
.pay-summary > div > .muted { display: inline-block; min-width: 150px; }
#rule-form .doc-head .field.check { align-self: end; }
#scale-table input { width: 140px; text-align: right; }
.computed { display: inline-block; padding: 3px 0; font-weight: 600; }
.day-courses { margin: 6px 0; } .day-courses .day-all { font-weight: 600; font-size: 15px; }
.history-note { display: block; margin: 4px 0; padding: 3px 8px; }

/* ---- «Финансы» (ANSWERS_31): entry window, chips, lists by day, reference tables ---- */
.fin-quick { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 6px; }
.fin-summary { margin: 4px 0; }
.fin-summary summary { cursor: pointer; font-weight: 600; }
.fin-table tr.fin-row { cursor: pointer; }
.fin-table tr.fin-auto td { color: var(--c-text-muted); }
.fin-table tr.fin-auto { background: var(--c-row-alt); }
.fin-table tr.fin-day-head th { background: var(--c-panel-head); text-align: left; position: static; }
.fin-table tr.fin-day-head th.num { text-align: right; }
.fin-overlay { position: fixed; inset: 0; background: var(--c-overlay); z-index: 70; display: flex; align-items: center; justify-content: center; }
.fin-overlay[hidden] { display: none; }
.fin-sheet { background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: 8px; width: min(520px, 96vw); max-height: 94vh; display: flex; flex-direction: column; }
.fin-sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--c-border); }
.fin-sheet-head .link { font-size: 22px; line-height: 1; }
.fin-sheet-body { padding: 8px 12px; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.fin-sheet-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--c-border); }
.fin-switch { display: flex; flex-wrap: wrap; gap: 4px; }
.fin-switch .button.on, .chip.on { background: var(--c-accent); color: var(--c-accent-text); border-color: var(--c-accent-dark); }
.fin-amount-label { display: flex; flex-direction: column; gap: 2px; font-weight: 600; }
.fin-amount { font-size: 26px; padding: 6px 10px; text-align: right; width: 100%; }
.fin-preview { min-height: 18px; font-weight: 400; color: var(--c-text-muted); text-align: right; }
.fin-preview.bad { color: var(--c-err); }
.fin-label { display: block; font-weight: 600; margin-bottom: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 12px; min-height: 36px; border: 1px solid var(--c-border-strong); border-radius: 18px; background: var(--c-surface); cursor: pointer; }
.chips.small .chip { padding: 2px 10px; min-height: 26px; }
.fin-row2 { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.fin-hint.warn { background: var(--c-warn-bg); color: var(--c-warn); padding: 2px 8px; border-radius: 8px; }
.fin-error { background: var(--c-err-bg); color: var(--c-err); padding: 6px 8px; border-radius: 4px; }
.fin-sheet label { display: flex; flex-direction: column; gap: 2px; }
body.fin-open { overflow: hidden; }
.fin-ref-table input[type=text], .fin-ref-table select { width: 100%; min-width: 80px; }
.fin-ref-table input.num { text-align: right; min-width: 90px; }
.fin-ref-table input.narrow { min-width: 50px; width: 60px; }
.fin-refs-scroll { overflow-x: auto; }
.fin-ref-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.settings-nav a.active { font-weight: 700; background: var(--c-row-hover); }
@media (max-width: 640px) {
  .fin-overlay { align-items: flex-end; }
  .fin-sheet { width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; border-width: 0; }
  .fin-sheet-body { flex: 1; }
  .fin-amount { font-size: 30px; }
}
.fin-diff-bad th { color: var(--c-err); }
.fin-diff-ok th { color: var(--c-ok); }
.fin-pick { position: relative; }
.fin-pick-input { width: 100%; }
.fin-pick-list { position: absolute; z-index: 5; left: 0; right: 0; top: 100%; max-height: 220px; overflow: auto; margin: 0; padding: 0; list-style: none; background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: 4px; }
.fin-pick-list[hidden] { display: none; }
.fin-pick-list li { padding: 6px 10px; cursor: pointer; border-bottom: 1px solid var(--c-border); }
.fin-pick-list li[hidden] { display: none; }
.fin-pick-list li:hover { background: var(--c-row-hover); }
.fin-pick-new { font-weight: 600; }
.chip[hidden] { display: none; }
.fin-field[hidden] { display: none; }

/* calendar of shifts (ANSWERS_34 п. 4): the colour of a cell is the employee's own, set as --emp in the markup */
.cal-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 6px; }
.cal-title { margin: 0; font-size: 15px; min-width: 130px; text-align: center; }
.cal-tools { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.cal-error { color: var(--c-err); margin: 4px 0; }
.cal-panel { display: flex; flex-wrap: wrap; align-items: end; gap: 6px 12px; padding: 8px; margin: 6px 0; background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: 6px; }
.cal-panel label { display: grid; gap: 2px; font-size: 12px; color: var(--c-text-muted); }
.num-s { width: 60px; }
.cal-block { margin: 12px 0 4px; font-size: 14px; }
.cal-scroll { overflow-x: auto; }
.cal-table { border-collapse: collapse; width: 100%; }
.cal-table th, .cal-table td { border: 1px solid var(--c-border); text-align: center; padding: 0; }
.cal-table th.cal-name { text-align: left; padding: 4px 8px; white-space: nowrap; position: sticky; left: 0; background: var(--c-surface); z-index: 1; }
.cal-day { min-width: 28px; font-weight: 400; background: var(--c-panel-head); }
.cal-day span { display: block; font-size: 12px; }
.cal-day small { display: block; font-size: 10px; color: var(--c-text-muted); }
.cal-day.weekend span { color: var(--c-err); }
.cal-day.today, .cal-cell.today { outline: 2px solid var(--c-header); outline-offset: -2px; }
.cal-cell { height: 30px; min-width: 28px; cursor: pointer; }
.cal-cell:hover { background: var(--c-row-hover); }
.cal-cell.on { background: var(--emp); }
.cal-cell.sub { text-align: center; font-size: 11px; font-weight: 700; }
.cal-cell.sub::after { content: "↺"; }
.cal-sum { width: 44px; font-size: 12px; color: var(--c-text-muted); }
.emp-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--emp); margin-right: 6px; border: 1px solid var(--c-border-strong); }
.cal-weeknav { display: none; gap: 6px; }
[hidden] { display: none !important; }
@media (max-width: 700px) {
  .cal-weeknav { display: inline-flex; }
  .cal-cell { height: 44px; min-width: 40px; }
  .cal-table { table-layout: fixed; }
}
.cal-remove { margin-left: 6px; padding: 0 4px; font-size: 11px; color: var(--c-text-muted); background: none; border: 0; text-decoration: underline; cursor: pointer; }
.cal-remove:hover { color: var(--c-err); }

/* ANSWERS_39 п. 1: a minus in a payment is a refund to the client */
.is-refund, input.is-refund { color: var(--c-err); }
.payments .pay.refund { border-color: var(--c-err); }

/* ANSWERS_40 п. 1.2: «4 руки» in the row of «Услуги за день» */
.hands-cell { white-space: nowrap; }
.hands-cell .hands-sum { width: 72px; }
.hands-cell .hands-master { max-width: 130px; }

/* «Расходы студии» by articles (ANSWERS_40 этап 3) */
.fin-group { margin: 0 0 6px; }
.fin-group-head { display: flex; justify-content: space-between; padding: 3px 6px; background: var(--c-table-head); border-bottom: 2px solid var(--c-border-strong); }
.fin-article > summary { display: flex; justify-content: space-between; gap: 8px; padding: 2px 6px; border-bottom: 1px solid var(--c-border); cursor: pointer; list-style: none; }
.fin-article > summary::before { content: "▸"; margin-right: 4px; }
.fin-article[open] > summary::before { content: "▾"; }
.fin-art-name { flex: 1 1 auto; }
.fin-plus { padding: 0 6px; }
.fin-article > table { margin: 0 0 4px 16px; width: calc(100% - 16px); }
.fin-month-total { font-size: 1.1em; }
@media (max-width: 640px) {
  .fin-cards thead { display: none; }
  .fin-cards tr.fin-row { display: flex; flex-wrap: wrap; gap: 0 10px; padding: 4px 6px; border-bottom: 1px solid var(--c-border); }
  .fin-cards tr.fin-row td { border: 0; padding: 0; }
  .fin-cards tr.fin-row td:nth-child(7) { margin-left: auto; font-weight: 600; }
  .fin-cards tr.fin-row td:nth-child(8), .fin-cards tr.fin-row td:nth-child(5) { flex-basis: 100%; color: var(--c-text-muted); }
  .fin-cards tr.fin-day-head th { display: inline-block; }
}
.table-scroll { overflow-x: auto; max-width: 100%; }
/* ANSWERS_44 п. 4: the tree table of the tiles and of «Расходы студии»; on a phone it scrolls inside its block */
.tree-scroll { max-width: 100%; overflow-x: auto; }
.tree-table td.num, .tree-table th.num { white-space: nowrap; }
.tree-table .tree-name { white-space: nowrap; }
.tree-table tr.tree-edit { cursor: pointer; }
/* ANSWERS_45 п. 7: «Услуги за день» — a click on a master opens his payments of the day */
.studio-table td.has-pays { cursor: pointer; }
.studio-table td.has-pays .mark { display: inline-block; width: 1em; color: var(--c-text-muted); }
.studio-table .pays-list { margin: 2px 0 4px 1.4em; width: auto; }
.studio-table .pays-list td, .studio-table .pays-list th { padding: 1px 8px; font-size: 12px; }
@media (max-width: 700px) { .studio-scroll { max-width: 100%; overflow-x: auto; } }  /* on a phone the spreadsheet scrolls inside its block; on a computer the head stays sticky */
/* ANSWERS_47 п. 1: tiles by their content in a row of equal height; a tile with columns is a grid of two rows — the row of labels
   (one line each, never wrapped) and the row of figures, so every figure of the tile stands on one line whatever the label */
.home-tiles { display: flex; flex-wrap: wrap; align-items: stretch; }
.home-tiles > .tile { flex: 0 1 auto; min-width: 150px; max-width: 100%; }
.tile-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-cells { grid-template-rows: auto auto; grid-auto-flow: column; column-gap: 0; }
.tile-cells .cell { display: grid; grid-row: span 2; grid-template-rows: subgrid; row-gap: 0; align-items: end; min-width: 0; }
.tile-cells .cell small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 12em; }
@media (max-width: 600px) {
  .home-tiles > .tile { flex: 1 1 40%; min-width: 0; }
  .home-tiles > .tile-wide, .home-tiles > .tile:has(.tile-cells) { flex-basis: 100%; }
  .tile-cells .cell { padding: 0 6px; }
  .tile-cells .cell small { font-size: 10px; max-width: 9.5em; }
  .tile-cells b { font-size: 14px; }
}
/* ANSWERS_47 п. 2: «Действия ▾» in a row — a small menu beside the button (~220 px, one line per item), the item opens a small window */
details.row-actions .pop.act-menu { min-width: 200px; max-width: 240px; padding: 4px 0; box-shadow: var(--bt-shadow); }
details.row-actions .act-menu button { display: block; width: 100%; padding: 6px 12px; border: 0; border-radius: 0; background: none; color: var(--c-text); font: inherit; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; min-height: 0; }
details.row-actions .act-menu button:hover, details.row-actions .act-menu button:focus { background: var(--c-row-hover); outline: 0; }
.act-dlg .act-text { margin: 0; font-size: 13px; }
/* ANSWERS_47 п. 4: «Услуги за день» — a redo under the total of the master, without a method of payment */
.studio-table .redo-note { font-size: 11px; color: var(--c-text-muted); white-space: nowrap; font-weight: 400; }
.studio-table tr.redo-row td { color: var(--c-text-muted); }
@media (max-width: 600px) { .home-panel { overflow-x: auto; } }  /* ANSWERS_47: a wide table of a panel scrolls inside it on a phone */
/* ANSWERS_48 п. 2: blocks of «Главная» — «Продажи товаров», «Услуги и курсы», «Собственники»; each its own quiet accent (theme.css
   `--c-blk-*`): a stripe left of the head, a thin line over its tiles, the heads of the tables of its panels; the text stays dark */
.home-block { --blk: var(--c-blk-goods); --blk-soft: var(--c-blk-goods-soft); --blk-text: var(--c-blk-goods-text); margin: 0 0 6px; }
.home-block--studio { --blk: var(--c-blk-studio); --blk-soft: var(--c-blk-studio-soft); --blk-text: var(--c-blk-studio-text); }
.home-block--owners { --blk: var(--c-blk-owners); --blk-soft: var(--c-blk-owners-soft); --blk-text: var(--c-blk-owners-text); }
.home-block { --c-rc-accent: var(--blk); --c-rc-soft: var(--blk-soft); --c-rc-soft-text: var(--blk-text); }
.home-block-h { font-size: 15px; margin: 12px 0 6px; padding: 1px 0 1px 8px; border-left: 4px solid var(--blk); line-height: 1.3; }
.home-block .home-tiles > .tile { border-top: 3px solid var(--blk); padding-top: 5px; }
.home-block .home-tiles > .tile.active { border-top: 3px solid var(--blk); padding-top: 5px; }
.home-block .home-panel thead th { background: var(--blk-soft); color: var(--blk-text); border-bottom-color: var(--blk); }
.home-block .home-panel .rc .rc-table th { background: none; }
/* ANSWERS_48 п. 3: the tiles of a block in even rows of a grid; the columns come from tile_rows.js (`--tile-cols`), a tile with columns
   spans two; without the script an auto-fill grid. A tile shrinks, its label is cut with «…» (the full text is the tooltip). */
.home-tiles.home-tiles--rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); grid-auto-rows: auto; align-items: stretch; gap: 8px; }
.home-tiles.home-tiles--rows[data-cols] { grid-template-columns: repeat(var(--tile-cols), minmax(0, 360px)); }
.home-tiles.home-tiles--rows > .tile { min-width: 0; max-width: none; flex: none; overflow: hidden; }
.home-tiles.home-tiles--rows .tile-value { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-tiles.home-tiles--rows .tile-note { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-tiles.home-tiles--rows .tile-cells { min-width: 0; }
@media (max-width: 600px) {
  .home-tiles.home-tiles--rows[data-cols] { grid-template-columns: repeat(var(--tile-cols), minmax(0, 1fr)); }
  .home-tiles.home-tiles--rows > .tile { flex-basis: auto; }
}

/* ANSWERS_49: login, two-factor, profile, the line of the backup copies */
.who-link { color: inherit; text-decoration: none; }
.who-link:hover .who-name { text-decoration: underline; }
.two-factor .qr-box { display: flex; justify-content: center; margin: 8px 0; }
.two-factor .steps { padding-left: 18px; margin: 4px 0; }
.backup-codes { columns: 2; padding-left: 22px; font-size: 15px; }
.otp-input { letter-spacing: 3px; }
.backup-line { font-size: 12px; margin: 2px 0 6px; color: var(--c-ok); }
.backup-line.bad { color: var(--c-err); font-weight: 600; }
