/* Фінансова екосистема — оформлення */
:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --line: #e6e2d9;
  --line-2: #d6d0c3;
  --text: #22251f;
  --muted: #6f7268;
  --side: #17352f;
  --side-2: #1f4840;
  --side-text: #d9e6e1;
  --accent: #2f7d68;
  --accent-2: #3f9a80;
  --accent-soft: #e3f1ec;
  --gold: #d6a84e;
  --gold-soft: #fbf1dc;
  --input: #fffaf0;
  --input-line: #ecd9ad;
  --calc: #f3f6f5;
  --neg: #b54a3c;
  --pos: #2f7d68;
  --danger: #c0473a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(30, 40, 30, 0.05), 0 4px 16px rgba(30, 40, 30, 0.05);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.neg { color: var(--neg); }
.ic { width: 18px; height: 18px; flex: none; }

/* ---------- Каркас ---------- */
.app { display: flex; min-height: 100vh; }
.side {
  width: 244px; flex: none; background: linear-gradient(180deg, var(--side) 0%, #12292a 100%); color: var(--side-text);
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 16px; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; background: #fff; display: grid; place-items: center; color: #000; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25); }
.brand-mark .logo { width: 30px; height: 30px; }
.brand-name { font-weight: 700; font-size: 16px; color: #fff; line-height: 1.1; }
.brand-sub { font-size: 13px; color: var(--gold); letter-spacing: 0.02em; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: auto; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 10px; color: var(--side-text); font-size: 14px; transition: background 0.15s; }
.nav a:hover { background: rgba(255, 255, 255, 0.06); text-decoration: none; }
.nav a.active { background: var(--side-2); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav a.active .ic { color: var(--gold); }
.nav-g { display: flex; flex-direction: column; gap: 2px; flex: none; }
.nav-gh { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; margin-top: 10px; padding: 6px 12px 4px; border: 0; border-radius: 8px; background: transparent; color: #7f9a92; font: inherit; font-size: 10.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; cursor: pointer; text-align: left; }
.nav-gh:hover { color: #d7e6e1; }
.nav-gh .ic { width: 14px; height: 14px; transition: transform 0.15s; }
.nav-g:not(.open) .nav-gh .ic { transform: rotate(-90deg); }
.nav-sep { flex: none; height: 1px; margin: 10px 8px 6px; background: rgba(255, 255, 255, 0.08); }
.nav > a, .nav-g > a { flex: none; }
.side-foot { padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.backup-btn { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.14); background: transparent; color: var(--side-text); font: inherit; cursor: pointer; }
.backup-btn:hover { background: rgba(255, 255, 255, 0.06); }
.backup-btn.warn { border-color: var(--gold); color: #fff; background: rgba(214, 168, 78, 0.16); }
.side-note { font-size: 11.5px; color: #93aba3; padding: 6px 4px 0; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.monthbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 12px 28px; background: rgba(245, 243, 238, 0.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.yearsel { display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.year { font-weight: 700; min-width: 44px; text-align: center; }
.months { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.months::-webkit-scrollbar { display: none; }
.mtab { position: relative; flex: 1 0 auto; border: 1px solid transparent; background: transparent; padding: 8px 10px; border-radius: 10px; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.mtab .short { display: none; }
.mtab:hover { background: var(--surface); border-color: var(--line); }
.mtab.has { color: var(--text); font-weight: 550; }
.mtab.has::after { content: ''; position: absolute; left: 50%; bottom: 3px; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--accent-2); }
.mtab.active { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 3px 10px rgba(47, 125, 104, 0.3); }
.mtab.active::after { background: var(--gold); }
.main { padding: 24px 28px 60px; max-width: 1500px; width: 100%; }

/* ---------- Заголовки сторінок ---------- */
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.ph h1 { font-size: 26px; }
.ph p { color: var(--muted); margin: 4px 0 0; }
.ph-act { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sect { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 22px 0 10px; font-weight: 650; }
.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.subtabs::-webkit-scrollbar { display: none; }
.subtabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.subtabs a:hover { color: var(--text); text-decoration: none; }
.subtabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.subtabs a.right { margin-left: auto; }
.subtabs .ic { width: 15px; height: 15px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.lg-in { background: var(--input); border: 1px solid var(--input-line); }
.lg-calc { background: var(--calc); border: 1px solid var(--line); }
.lead { color: var(--muted); max-width: 760px; }

/* ---------- Картки ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card h3 { font-size: 15px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card h3.pad, .pad { padding: 16px 20px 0; }
.card .pad.kv { padding-bottom: 4px; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-h h3 { margin: 0; }
.card.narrow { max-width: 720px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; align-items: start; }
.stack > .card:last-child { margin-bottom: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; align-items: start; }
.cards .card { margin: 0; }
.row-act { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi-l { font-size: 12.5px; color: var(--muted); }
.kpi-v { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.kpi-n { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpis.small .kpi-v { font-size: 18px; }
.kpi.accent { background: linear-gradient(135deg, var(--side) 0%, var(--accent) 140%); color: #fff; border: none; }
.kpi.accent .kpi-l, .kpi.accent .kpi-n { color: #cfe3dc; }
.kpi.pos .kpi-v { color: var(--pos); }
.kpi.neg .kpi-v { color: var(--neg); }

.notice { display: flex; gap: 12px; align-items: flex-start; background: var(--accent-soft); border: 1px solid #c8e2d8; border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; font-size: 13px; }
.notice .ic { color: var(--accent); margin-top: 1px; }
.notice.warn { background: var(--gold-soft); border-color: #efd9a8; }
.notice.warn .ic { color: #a8792a; }
.notice .btn { margin-left: 8px; }

/* ---------- Кнопки ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 10px; font: inherit; font-weight: 550; cursor: pointer; transition: all 0.15s; white-space: nowrap; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn .ic { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #e7c1bb; background: #fff; }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.ibtn { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 1px solid transparent; background: transparent; border-radius: 8px; color: var(--muted); cursor: pointer; }
.ibtn:hover { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.ibtn.small { width: 26px; height: 26px; }
.ibtn.small .ic { width: 15px; height: 15px; }
.ibtn.danger:hover { color: var(--danger); }
.badge { font-size: 11.5px; background: var(--accent-soft); color: var(--accent); padding: 3px 8px; border-radius: 99px; font-weight: 600; }

/* ---------- Поля ---------- */
.in { font: inherit; color: var(--text); border: 1px solid var(--input-line); background: var(--input); border-radius: 8px; padding: 6px 8px; width: 100%; min-width: 0; transition: border-color 0.12s, box-shadow 0.12s; }
.in:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47, 125, 104, 0.15); background: #fff; }
.in.num { text-align: right; font-variant-numeric: tabular-nums; }
.in.txt { background: #fff; border-color: var(--line); }
/* Цифри з Altegio: заповнене автоматично — зелене; змінене вручну — з жовтою крапкою */
.crm .in { background: var(--accent-soft); border-color: #c8e2d8; }
.crm .in:focus { background: #fff; }
.crm-diff { position: relative; }
.crm-diff::after { content: ''; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 2px var(--surface); pointer-events: none; }
span.crm, span.crm-diff { display: inline-block; }
.crm-bar .btn { vertical-align: middle; }
.crm-note { margin-top: 6px; }
.in.txt:focus { border-color: var(--accent); }
select.in { background: #fff; border-color: var(--line); padding-right: 24px; }
.pctwrap { position: relative; display: inline-flex; align-items: center; width: 100%; }
.pctwrap .in { padding-right: 24px; }
.pctwrap i { position: absolute; right: 9px; font-style: normal; color: var(--muted); pointer-events: none; }
.colorin { width: 48px; height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: #fff; cursor: pointer; }
.chk { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; font-size: 13.5px; }
.chk input { position: absolute; opacity: 0; pointer-events: none; }
.chk span { width: 36px; height: 20px; border-radius: 99px; background: #d7d3c8; position: relative; transition: background 0.15s; flex: none; }
.chk span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); transition: transform 0.15s; }
.chk input:checked + span { background: var(--accent); }
.chk input:checked + span::after { transform: translateX(16px); }
.chk input:focus-visible + span { box-shadow: 0 0 0 3px rgba(47, 125, 104, 0.25); }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; margin-bottom: 12px; }
.f { display: flex; flex-direction: column; gap: 5px; }
.f.wide { grid-column: 1 / -1; }
.f label { font-size: 12.5px; color: var(--muted); }
.f .hint { font-size: 12px; color: var(--muted); min-height: 16px; }
.f .note { margin-top: 4px; }
.search { font: inherit; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; width: 280px; max-width: 100%; background: #fff; }
.search:focus { outline: none; border-color: var(--accent); }
.toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }

/* ---------- Таблиці ---------- */
.scroll-x { overflow-x: auto; }
.scroll-x.tall { max-height: calc(100vh - 250px); overflow: auto; }
/* Смужки прокрутки таблиць завжди видимі (на Mac вони інакше ховаються, і не видно, що таблицю можна гортати вбік) */
.scroll-x::-webkit-scrollbar { height: 11px; width: 11px; }
.scroll-x::-webkit-scrollbar-track { background: var(--surface-2); }
.scroll-x::-webkit-scrollbar-thumb { background: #cfc8b8; border-radius: 99px; border: 2px solid var(--surface-2); }
.scroll-x::-webkit-scrollbar-thumb:hover { background: #b9b19f; }
.scroll-x::-webkit-scrollbar-corner { background: var(--surface-2); }
.t { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.t th { font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); vertical-align: bottom; line-height: 1.25; }
.t td { padding: 7px 10px; border-bottom: 1px solid #f0ede6; vertical-align: middle; }
.t .r, .t th.r { text-align: right; }
.t .c, .t th.c { text-align: center; }
.t tbody tr:hover td { background: #fcfbf8; }
.t tr.grp td { background: var(--surface-2); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 650; padding-top: 10px; }
.t tr.sub td { font-weight: 600; background: #fbfaf7; }
.t tfoot td { font-weight: 700; background: var(--gold-soft); border-top: 1px solid #ecdcb5; border-bottom: none; padding: 10px; }
.t td.calc { background: var(--calc); text-align: right; }
.t td.calc small { display: block; font-size: 11px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.t td.strong, .t .strong { font-weight: 700; }
.t td.hl2 { color: var(--accent); }
.t td.name { white-space: nowrap; }
.t td.name a { color: var(--text); display: inline-flex; align-items: center; gap: 8px; }
.t td.act { width: 1%; white-space: nowrap; text-align: right; }
.t .z { color: #c3beb2; }
.t .na { color: #cbc6ba; display: block; text-align: center; }
.t.compact td, .t.compact th { padding: 6px 12px; }
.input-grid td { padding: 5px 6px; }
.input-grid .in { min-width: 92px; }
.input-grid td.name .in { min-width: 180px; }
/* Закріплена перша колонка: лише клітинки рядків і перша клітинка ПЕРШОГО рядка заголовка
   (у другому рядку заголовка перша клітинка — вже стовпець майстра, її не закріплюємо) */
.sticky-first td:first-child, .sticky-first thead tr:first-child th:first-child { position: sticky; left: 0; z-index: 2; background: var(--surface); box-shadow: 1px 0 0 var(--line); }
.sticky-first tr.grp td:first-child, .sticky-first thead tr:first-child th:first-child { background: var(--surface-2); }
.sticky-first tfoot td:first-child { background: var(--gold-soft); }
.sticky-head thead th { position: sticky; top: 0; z-index: 3; }
.sticky-head thead tr:nth-child(2) th { top: 35px; }
.sticky-head thead tr:first-child th:first-child { z-index: 4; }
.chip { width: 10px; height: 10px; border-radius: 3px; background: var(--c); display: inline-block; flex: none; }
.avatar { width: 38px; height: 38px; border-radius: 12px; background: var(--c); display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; color: #2b2b24; flex: none; }
.bar { height: 8px; border-radius: 99px; background: #efece5; overflow: hidden; min-width: 60px; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--accent-2); }
.bars-t td.bcell { width: 22%; }
/* Точка беззбитковості */
.t td.nw, a.nw { white-space: nowrap; }
.pos { color: var(--pos); }
.be-card { margin-bottom: 16px; }
.be-card .card-h { align-items: flex-start; }
.be-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 6px 0 14px; }
.be-nums span { display: block; font-size: 12.5px; color: var(--muted); }
.be-nums b { font-size: 20px; font-variant-numeric: tabular-nums; }
.be-bar { position: relative; height: 12px; border-radius: 99px; background: #efece5; margin: 28px 0 12px; }
.be-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%); }
.be-bar.bad i { background: var(--neg); }
.be-bar em { position: absolute; top: -8px; bottom: -8px; width: 3px; margin-left: -1.5px; border-radius: 2px; background: var(--gold); font-style: normal; }
.be-bar em span { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 4px; font-size: 11.5px; font-weight: 600; color: #9a7428; white-space: nowrap; }
.bars-t td.pctv { width: 90px; }

/* матеріали */
.mat-t th.mcol { background: color-mix(in srgb, var(--c) 45%, var(--surface-2)); color: var(--text); text-align: center; }
.mat-t td.mcol { background: color-mix(in srgb, var(--c) 18%, transparent); }
/* «Адміністрація» у витратних матеріалах — списання без майстра, сірий стовпець поруч із майстрами */
.mat-t th.admcol { background: var(--surface-2); color: var(--text); text-align: center; }
.mat-t td.admcol { background: color-mix(in srgb, var(--muted) 10%, transparent); }
.adm-tag { display: block; font-size: 10px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.mat-t td.calc { background: color-mix(in srgb, var(--c, #e9eeec) 14%, var(--calc)); }
.mat-t .in { min-width: 72px; }
.mat-t .h1 th { text-align: center; }
.mat-t td.mlcol .in { border-color: #e7b8b0; background: #fdf1ee; }
.mat-t tr.warnrow td.name .in { border-color: var(--gold); }
.warn-ic { color: #b47d1f; margin-left: 4px; vertical-align: -3px; }
.warn-ic .ic { width: 15px; height: 15px; }
.mat-t td.calc small.plus { display: block; font-size: 10.5px; color: var(--neg); font-weight: 500; white-space: nowrap; }
.mat-t td.short { text-align: center; min-width: 96px; }
.mat-t td.short b { display: block; }
.mat-t td.name .nm { display: inline-block; padding: 7px 4px; min-width: 180px; }
.mat-t .ro-v { display: block; text-align: right; padding: 7px 8px; }
.share-btn { display: block; margin: 3px auto 0; border: 1px solid var(--line-2); background: var(--surface); border-radius: 7px; padding: 2px 7px; font: inherit; font-size: 11px; color: var(--accent); cursor: pointer; white-space: nowrap; }
.share-btn.quiet { color: var(--muted); border-color: transparent; background: transparent; }
.share-btn:hover { border-color: var(--accent); }
.share-btn.quiet { display: none; margin: 0 auto; }
.mat-t tr:hover .share-btn.quiet { display: inline-block; }
.mat-t tr:hover td.short .nohov { display: none; }
.share-list { display: grid; gap: 10px; margin: 12px 0; }

/* таблиці адміністратора */
.stock-t td.no-stock { text-align: center; color: var(--muted); font-size: 12px; font-style: italic; }
.stock-t td.factcol .in { border-color: #b9d8cc; background: #f1f8f5; }
.stock-t td.calc.neg { color: var(--neg); background: #fbeeec; }
.stock-t td.calc.pos { color: var(--pos); }
.stock-t .in.date { min-width: 76px; width: 84px; }
.stock-t .in.note { min-width: 150px; }
.stock-t tr.sec td { position: static; background: var(--surface-2); padding: 10px 8px 4px; box-shadow: none; }
.stock-t tr.sec .sec-in { position: sticky; left: 8px; display: inline-flex; gap: 8px; }
.stock-t tr.sec .in { min-width: 0; width: 190px; font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: transparent; border-color: transparent; }
.stock-t tr.sec .in:hover, .stock-t tr.sec .in:focus { background: var(--surface); border-color: var(--line-2); }
.stock-t tr.sec .in:placeholder-shown:not(:focus) { width: 64px; }
.stock-t tr.sec .in::placeholder { text-transform: none; letter-spacing: 0; font-weight: 400; color: #cfcabf; }
body.ro .stock-t tr.sec .in:placeholder-shown { visibility: hidden; }
.stock-t tr.sec .sec-act { display: inline-flex; align-items: center; gap: 2px; }
.stock-t td.name .row-menu { flex: none; color: #b3ad9f; }
.stock-t tr:hover td.name .row-menu { color: var(--text); }
.stock-t td.calc.tot { font-weight: 650; }
.stock-t td.calc.start { white-space: nowrap; }
.stock-t td.addcol .in { min-width: 96px; }
/* Набори стовпців і картка матеріалу */
.view-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -4px 0 12px; }
.view-bar .chips { margin: 0; }
.stock-t .nm-txt { display: none; }
.modal.stock-card .fields { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
.modal.stock-card .f label small { color: var(--accent); font-weight: 600; }
.modal.stock-card .in.cabv { border-color: #b9d8cc; background: #f1f8f5; }
.modal.stock-card .in.cabv::placeholder { color: var(--accent); opacity: 1; font-weight: 650; }
.modal.stock-card .in.cabv.fixed { border-color: #e2b85e; background: #fff4d6; font-weight: 650; }
.modal.stock-card .ro-v { padding: 6px 2px; font-weight: 650; font-variant-numeric: tabular-nums; }
.modal.stock-card .ro-v small { display: block; font-weight: 400; font-size: 11.5px; color: var(--muted); }
.sc-calc { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px 12px; background: var(--calc); border-radius: 12px; padding: 10px 14px; margin: 4px 0 14px; }
.sc-calc span { display: block; font-size: 11.5px; color: var(--muted); }
.sc-calc b { font-size: 17px; font-variant-numeric: tabular-nums; }
.sc-calc .neg b { color: var(--neg); }
.sc-calc .pos b { color: var(--pos); }
@media (max-width: 700px) {
  /* Телефон: вузький стовпець назв (назва переноситься, а не ховається), натиск на назву — картка матеріалу */
  .stock-t td.name, .stock-t thead tr:first-child th:first-child { white-space: normal; width: 102px; min-width: 102px; max-width: 102px; }
  .stock-t.input-grid td { padding: 4px 4px; }
  .stock-t th { padding: 8px 4px; }
  .stock-t td.no-stock { white-space: normal; font-size: 11px; }
  .stock-t td.calc .calc-src { font-size: 9.5px; }
  .stock-t td.name .name-in { flex-wrap: wrap; gap: 3px; }
  .stock-t td.name .name-in > .in, .stock-t td.name .row-menu { display: none; }
  .stock-t .nm-txt { display: block; width: 100%; padding: 4px 2px; border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 600; line-height: 1.25; color: var(--text); text-align: left; overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; cursor: pointer; text-decoration: underline dotted #c9c3b6; text-underline-offset: 3px; }
  .stock-t .in.num { min-width: 60px; }
  .stock-t td.addcol .in { min-width: 74px; }
  /* Заголовки розділів не повинні розпирати таблицю ширше за екран */
  .stock-t tr.sec .in { width: 104px; }
  .stock-t tr.sec .in:placeholder-shown:not(:focus) { width: 52px; }
}
.stock-t td.calc .calc-src { display: block; font-size: 10.5px; font-weight: 500; color: var(--muted); }
.ic.inl { width: 15px; height: 15px; vertical-align: -3px; margin: 0 1px; color: var(--text) !important; }
.menu-list { display: flex; flex-direction: column; align-items: stretch; gap: 6px; margin-bottom: 6px; }
.menu-list .btn { justify-content: flex-start; }
.menu-list p { margin: -2px 2px 6px; }
.move-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.move-row select { flex: 1; min-width: 0; }
.buy-sum { margin-bottom: 16px; }
.inv-sum, .inv-year { margin: 0 0 16px; }
.inv-year { margin-top: 16px; }
.inv-t td.name a { font-weight: 600; }
.inv-t td.calc.owe { color: var(--neg); }
.inv-t .in.note { min-width: 200px; }
.inv-lines .in.date { min-width: 70px; width: 96px; }
.inv-lines .in.num { min-width: 120px; }
.inv-lines .in.note { min-width: 220px; }
p.pad { padding: 0 20px 16px; margin: 10px 0 0; }
.buy-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 8px; }
.buy-chips a, .buy-chips .all { display: inline-flex; gap: 8px; align-items: baseline; padding: 7px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); }
.buy-chips a:hover { border-color: var(--accent); text-decoration: none; }
.buy-chips span { color: var(--muted); font-size: 12.5px; }
.buy-chips b { font-variant-numeric: tabular-nums; }
.buy-chips .all { background: var(--gold-soft); border-color: #ecdcb5; }
.buy-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.buy-grid .card { margin: 0; }
.buy-tot { font-weight: 700; font-variant-numeric: tabular-nums; }
.buy-t .in.date { min-width: 70px; width: 96px; }
.buy-t td.name .in { min-width: 220px; }
.buy-t .in.num { min-width: 84px; }
.buy-t .in.note { min-width: 180px; }
.buy-t tr.warnrow td.name .in { border-color: var(--gold); }
.buy-t td.calc { min-width: 96px; }
.link-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -4px 0 10px; font-size: 12.5px; color: var(--muted); }
.link-line .ic { width: 14px; height: 14px; }
.link-line select.in { width: auto; min-width: 220px; font-size: 12.5px; padding: 4px 8px; }
.link-line em { font-style: normal; font-size: 11.5px; }
.t td.calc.linked a { display: block; font-size: 11px; font-weight: 400; margin-top: 2px; }

/* витрати */
.exp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); gap: 16px; align-items: start; }
.exp-grid .card { margin: 0; }
.exp-card .in.num { min-width: 110px; }
.exp-card td.name { display: flex; align-items: center; gap: 6px; }
.flags { display: inline-flex; gap: 3px; }
.flag { font-style: normal; font-size: 10px; font-weight: 700; padding: 2px 5px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); }
.flag.m { background: var(--gold-soft); color: #9a6c1c; }
.add-group { display: flex; gap: 14px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.turnover { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.turnover h3 { margin-bottom: 4px; }
.to-in { display: flex; align-items: center; gap: 10px; }
.to-in .in { width: 180px; font-size: 18px; font-weight: 700; }
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; border-bottom: 1px dashed #ece8df; }
.kv span { color: var(--muted); }
.kv b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.kv.sm { border: none; padding-top: 0; font-size: 12px; }
.kv.big b { font-size: 18px; color: var(--accent); }
.kv.big span { color: var(--text); font-weight: 600; }
details { margin: 4px 0 8px; font-size: 13px; }
details summary { cursor: pointer; color: var(--accent); }

/* ---------- Співробітники ---------- */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.person { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; color: var(--text); box-shadow: var(--shadow); transition: transform 0.12s, border-color 0.12s; }
.person:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.person .pi { flex: 1; min-width: 0; }
.person .pi b { display: block; }
.person .pi span, .person .pv span { font-size: 12px; color: var(--muted); }
.person .pv { text-align: right; }
.person .pv b { display: block; font-variant-numeric: tabular-nums; }
.person .arr, .qa .arr { color: #b9b4a8; }
.crumbs { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; font-size: 13px; }
.crumbs a { display: inline-flex; align-items: center; gap: 6px; }
.crumbs .ic { width: 15px; height: 15px; }
.crumbs .pn { color: var(--muted); }
.spacer { flex: 1; }
.emp-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.emp-head .avatar { width: 56px; height: 56px; font-size: 18px; border-radius: 16px; }
.emp-head h1 { font-size: 24px; }
.emp-head p { color: var(--muted); margin: 2px 0 0; }
.emp-head-sum { margin-left: auto; display: flex; gap: 10px; }
.emp-head-sum > div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; text-align: right; }
.emp-head-sum span { display: block; font-size: 12px; color: var(--muted); }
.emp-head-sum b { font-size: 19px; font-variant-numeric: tabular-nums; }
.emp-head-sum .hl { background: var(--side); border-color: var(--side); }
.emp-head-sum .hl span { color: #a9c6bc; }
.emp-head-sum .hl b { color: #fff; }
.blocks { display: grid; grid-template-columns: repeat(auto-fit, minmax(520px, 1fr)); gap: 16px; align-items: start; }
.blk { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.blk h3 { font-size: 14px; padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); margin: 0; }
.blk > .fields, .blk > .lines, .blk > .two { padding: 0 16px; }
.blk > .fields { padding-top: 14px; }
.blk-t td { text-align: right; }
.blk-t th { text-align: right; }
.blk-t td:first-child, .blk-t th:first-child { text-align: left; }
.blk-t td.inp { background: #fff; }
.blk-t td.hit { background: var(--gold-soft); font-weight: 700; }
.blk-f { padding: 10px 16px; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; border-top: 1px solid #f0ede6; }
.blk-f .in { width: 90px; }
.total-blk { grid-column: 1 / -1; }
.sumrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.sumrow > div { padding: 14px 16px; border-right: 1px solid #f0ede6; }
.sumrow span { display: block; font-size: 12px; color: var(--muted); }
.sumrow b { font-size: 18px; font-variant-numeric: tabular-nums; }
.sumrow .hl { background: var(--gold-soft); }
.sumrow .hl2 { background: var(--side); }
.sumrow .hl2 span { color: #a9c6bc; }
.sumrow .hl2 b { color: #fff; }
.lines { margin: 8px 0 14px; }
.lines-h { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-weight: 600; }
.line { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.line .grow { flex: 2; }
.line .note { flex: 1; }
.line .num { width: 120px; flex: none; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.emp-card .emp-h { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.emp-card .emp-h a { color: var(--text); }
.emp-card .emp-h span { display: block; font-size: 12px; color: var(--muted); }
.emp-sum { margin-left: auto; text-align: right; font-size: 12px; color: var(--muted); }
.emp-sum span { display: block; }
.emp-sum b { color: var(--text); font-variant-numeric: tabular-nums; }

/* розрахунковий лист */
.slip-wrap { max-width: 640px; }
.slip-act { display: flex; gap: 16px; align-items: center; margin-bottom: 12px; }
.slip { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 26px 28px; box-shadow: var(--shadow); }
.slip-h { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 18px; padding-bottom: 16px; border-bottom: 2px solid var(--side); }
.slip-brand { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--accent); font-weight: 600; margin-bottom: 4px; }
.slip-brand .logo { width: 15px; height: 15px; color: #000; }
.slip-h h2 { font-size: 22px; }
.slip-who { text-align: right; display: flex; flex-direction: column; font-size: 13px; color: var(--muted); }
.slip-who b { font-size: 16px; color: var(--text); }
.slip-t td { padding: 8px 4px; }
.slip-t td.ex { color: var(--muted); font-size: 12.5px; text-align: right; }
.slip-t tbody.tot td { background: #f3c998; font-weight: 700; border-bottom: none; }
.slip-t tbody.tot td:first-child { border-radius: 8px 0 0 8px; padding-left: 10px; }
.slip-t tbody.tot td:last-child { border-radius: 0 8px 8px 0; padding-right: 10px; }
.slip-t tbody.net td { font-weight: 700; font-size: 16px; border-top: 2px solid var(--side); border-bottom: none; padding-top: 12px; }
.slip-t tbody tr:hover td { background: transparent; }
.slip-sign { margin-top: 26px; font-size: 12px; color: var(--muted); }
.slips-all { display: grid; grid-template-columns: repeat(auto-fill, minmax(520px, 1fr)); gap: 16px; }

/* огляд */
.quick { display: flex; flex-direction: column; gap: 8px; }
.quick-card .quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.masters-t td.c, .masters-t th.c { text-align: center; }
.qa { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); }
.qa:hover { border-color: var(--accent); text-decoration: none; background: var(--accent-soft); }
.qa > .ic:first-child { width: 36px; height: 36px; padding: 8px; background: var(--accent-soft); color: var(--accent); border-radius: 10px; }
.qa div { flex: 1; }
.qa b { display: block; }
.qa span { font-size: 12.5px; color: var(--muted); }
.empty-state { text-align: center; max-width: 560px; margin: 60px auto; }
.es-ic { width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 20px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.es-ic .ic { width: 34px; height: 34px; }
.empty-state h2 { font-size: 24px; margin-bottom: 8px; }
.empty-state p { color: var(--muted); }
.es-act { display: flex; flex-direction: column; gap: 10px; align-items: center; margin: 22px 0 16px; }
.empty-mini { text-align: center; color: var(--muted); padding: 40px; }
.empty-mini .ic { width: 36px; height: 36px; color: #c9c4b8; }

/* налаштування */
.set-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
.set-list { position: sticky; top: 76px; padding: 14px; }
.set-emp { display: flex; align-items: center; gap: 4px; border-radius: 10px; padding: 4px; }
.set-emp a { flex: 1; display: flex; align-items: center; gap: 10px; color: var(--text); padding: 4px; min-width: 0; }
.set-emp a:hover { text-decoration: none; }
.set-emp a b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.set-emp a span { font-size: 11.5px; color: var(--muted); }
.set-emp .avatar { width: 32px; height: 32px; font-size: 11px; border-radius: 9px; }
.set-emp:hover { background: var(--surface-2); }
.set-emp.active { background: var(--accent-soft); }
.set-emp .ord { display: flex; opacity: 0.4; }
.set-emp:hover .ord { opacity: 1; }
.comps { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.comp { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface-2); }
.comp.on { background: #fff; border-color: #bfdcd1; box-shadow: inset 3px 0 0 var(--accent); }
.comp-h { margin-bottom: 4px; font-weight: 600; }
.comp .fields { margin: 8px 0 0; grid-template-columns: 1fr; }
.param-t { margin: 8px 0; }
.param-t .in { min-width: 60px; }
.apply-fwd { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 4px 0 16px; }
.h-in { font-weight: 650; font-size: 15px; max-width: 360px; }
.set-exp td .chk span { margin: 0 auto; }
.labels { display: flex; flex-direction: column; gap: 6px; }
.lbl { display: flex; gap: 6px; align-items: center; }

/* вікна */
.overlay { position: fixed; inset: 0; background: rgba(20, 30, 25, 0.38); backdrop-filter: blur(3px); z-index: 100; display: grid; place-items: center; padding: 20px; animation: fade 0.15s; }
.modal { background: #fff; border-radius: 18px; width: 100%; max-width: 480px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); display: flex; flex-direction: column; max-height: 90vh; }
.modal.wide { max-width: 760px; }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 8px; }
.modal-h h3 { font-size: 18px; }
.modal-b { padding: 8px 20px; overflow: auto; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; }
.modal textarea { width: 100%; font: 12.5px/1.4 ui-monospace, Menlo, monospace; border: 1px solid var(--line-2); border-radius: 10px; padding: 10px; margin-bottom: 10px; }
.modal .cols { display: flex; flex-wrap: wrap; gap: 4px; }
.modal .cols span { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; font-size: 12px; }
@keyframes fade { from { opacity: 0; } }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); background: var(--side); color: #fff; padding: 10px 18px; border-radius: 12px; opacity: 0; pointer-events: none; transition: all 0.2s; z-index: 200; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Підсумок року ---------- */
.ytab { flex: none; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); padding: 7px 12px; border-radius: 10px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.ytab .ic { width: 16px; height: 16px; color: var(--accent); }
.ytab .short { display: none; }
.ytab:hover { border-color: var(--accent); }
.ytab.active { background: var(--side); border-color: var(--side); color: #fff; box-shadow: 0 3px 10px rgba(23, 53, 47, 0.3); }
.ytab.active .ic { color: var(--gold); }
.card-h p { margin: 2px 0 0; }
.chart { position: relative; width: 100%; touch-action: pan-y; }
.chart svg { display: block; overflow: visible; }
.chart .tk { font-size: 11px; fill: #898781; font-variant-numeric: tabular-nums; }
.chart .tk.off { fill: #c9c5bb; }
.chart .cap { font-size: 11.5px; font-weight: 650; fill: var(--text); }
.chart .el-v { font-size: 12px; font-weight: 700; fill: var(--text); }
.chart .el-n { font-size: 11px; fill: #52514e; }
.chart .hb.on { fill: rgba(34, 37, 31, 0.05); }
.c-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: #52514e; }
.c-legend span { display: inline-flex; align-items: center; gap: 6px; }
.c-legend i { display: inline-block; flex: none; }
.c-legend i.sq { width: 10px; height: 10px; border-radius: 3px; }
.c-legend i.ln { width: 14px; height: 2px; border-radius: 2px; }
#ctip { position: fixed; z-index: 150; pointer-events: none; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 28px rgba(20, 30, 25, 0.16); padding: 8px 11px; font-size: 12.5px; min-width: 150px; max-width: 280px; opacity: 0; transition: opacity 0.1s; }
#ctip.show { opacity: 1; }
#ctip .tt-h { font-weight: 650; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
#ctip .tt-r { display: flex; align-items: center; gap: 8px; padding: 1px 0; }
#ctip .tt-r i { width: 12px; height: 2px; border-radius: 2px; flex: none; }
#ctip .tt-r i.none { background: transparent; }
#ctip .tt-r b { font-variant-numeric: tabular-nums; white-space: nowrap; }
#ctip .tt-r span { color: var(--muted); }
#ctip .tt-r.tot { border-bottom: 1px solid #f0ede6; padding-bottom: 4px; margin-bottom: 3px; }
.hbars { display: flex; flex-direction: column; gap: 4px; }
.hb-row { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 12px; align-items: center; padding: 5px 6px; border-radius: 8px; }
.hb-row[data-href] { cursor: pointer; }
.hb-row[data-href]:hover { background: var(--surface-2); }
.hb-row.muted .hb-name { color: var(--muted); }
.hb-l { display: flex; align-items: center; gap: 7px; min-width: 0; flex-wrap: wrap; row-gap: 0; }
.hb-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.hb-l small { width: 100%; font-size: 11px; color: var(--muted); padding-left: 17px; line-height: 1.2; }
.hb-l > .hb-name:first-child + small { padding-left: 0; }
.hb-track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hb-track i { display: block; height: 12px; width: calc((100% - 104px) * var(--p)); border-radius: 0 4px 4px 0; flex: none; }
.hb-track b { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hb-track b.neg { color: var(--neg); }
.sharebar { display: flex; gap: 2px; height: 16px; margin: 4px 0 14px; }
.sharebar i { display: block; min-width: 2px; }
.sharebar i:first-child { border-radius: 4px 0 0 4px; }
.sharebar i:last-child { border-radius: 0 4px 4px 0; }
.share-legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px 20px; }
.share-legend div { display: grid; grid-template-columns: 10px 1fr auto; gap: 2px 8px; align-items: center; }
.share-legend i { width: 10px; height: 10px; border-radius: 3px; }
.share-legend span { color: var(--muted); font-size: 12.5px; }
.share-legend b { font-size: 17px; font-weight: 650; grid-column: 2; }
.share-legend em { font-style: normal; font-size: 12.5px; color: var(--muted); grid-column: 3; grid-row: 1 / span 2; align-self: center; font-variant-numeric: tabular-nums; }
.share-legend b.neg { color: var(--neg); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chipbtn { border: 1px solid var(--line-2); background: var(--surface); color: var(--text); padding: 6px 12px; border-radius: 99px; font: inherit; font-size: 13px; cursor: pointer; }
.chipbtn:hover { border-color: var(--accent); }
.chipbtn.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.rating-t td.name small { display: block; font-size: 11px; color: var(--muted); padding-left: 18px; }
.rating-t .rk { width: 1%; text-align: center; }
.rating-t td.bcell { min-width: 120px; }
.rk-row { cursor: pointer; }
.rank { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); font-weight: 700; font-size: 12.5px; }
.rank.r1 { background: #f5d77a; border-color: #e3bd4a; }
.rank.r2 { background: #e3e3e0; border-color: #c9c9c4; }
.rank.r3 { background: #ecc39c; border-color: #d7a275; }
.months-t tr.off td { color: #b9b4a8; }
.t td.neg { color: var(--neg); }

/* ---------- Хмара: стан синхронізації ---------- */
.sync { display: inline-flex; align-items: center; gap: 8px; border: none; background: transparent; font: inherit; font-size: 12px; cursor: pointer; padding: 6px 8px; border-radius: 8px; color: inherit; text-align: left; }
.sync .ic { width: 17px; height: 17px; flex: none; }
.sync.ok .ic { color: #5fc79f; }
.sync.wait .ic { color: var(--gold); animation: pulse 1.2s ease-in-out infinite; }
.sync.off .ic { color: #b9c4bf; }
.sync.err .ic { color: #ef8b7d; }
@keyframes pulse { 50% { opacity: 0.4; } }
.side > .sync { order: 5; margin: 0 4px 8px; color: var(--side-text); }
.side > .sync:hover { background: rgba(255, 255, 255, 0.06); }
.side-foot { order: 6; }
.kv .sync { padding: 0; font-weight: 600; color: var(--text); }
.kv .sync.ok .ic { color: var(--pos); }

/* ---------- Екран входу ---------- */
body.gated { overflow: hidden; }
.gate { position: fixed; inset: 0; z-index: 90; background: linear-gradient(160deg, #17352f 0%, #12292a 55%, #0e2021 100%); overflow-y: auto; }
.gate-wrap { min-height: 100%; display: grid; place-items: center; padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); }
.gate-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 20px; padding: 28px 26px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35); display: flex; flex-direction: column; gap: 12px; }
.gate-card.center { text-align: center; align-items: center; }
.gate-card h2 { font-size: 22px; }
.gate-card p { margin: 0; }
.gate-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.gate-card.center .gate-brand { justify-content: center; }
.gate-brand .brand-name { color: var(--side); }
.gate-brand .brand-sub { color: #b98a33; }
.gl { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.gl .in { font-size: 16px; padding: 11px 12px; }
.gate-err { color: var(--neg); font-size: 13px; min-height: 18px; }
.gate-ok { color: var(--accent); background: var(--accent-soft); border-radius: 10px; padding: 9px 12px; font-size: 13px; font-weight: 600; }
.btn.big { justify-content: center; padding: 12px 16px; font-size: 16px; }
.btn:disabled { opacity: 0.6; cursor: default; }
.gate-link { text-align: center; font-size: 13px; }
.install-link { display: inline-flex; align-items: center; justify-content: center; gap: 6px; margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); }
.install-link .ic { width: 15px; height: 15px; }
.steps { padding-left: 20px; margin: 0 0 12px; display: flex; flex-direction: column; gap: 8px; }
.gate-opts { display: flex; flex-direction: column; gap: 8px; margin: 4px 0; }
.gate-opt { display: flex; align-items: center; gap: 14px; text-align: left; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #fff; font: inherit; color: var(--text); cursor: pointer; }
.gate-opt:hover { border-color: var(--accent); background: var(--accent-soft); }
.gate-opt > .ic { width: 38px; height: 38px; padding: 9px; background: var(--accent-soft); color: var(--accent); border-radius: 10px; }
.gate-opt b { display: block; }
.gate-opt span { font-size: 12.5px; color: var(--muted); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin 0.8s linear infinite; margin: 8px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Режими ---------- */
.mode-btn { width: 100%; display: flex; align-items: center; gap: 9px; padding: 9px 12px; margin-bottom: 8px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.14); background: rgba(255, 255, 255, 0.04); color: var(--side-text); font: inherit; font-size: 13px; cursor: pointer; text-align: left; }
.mode-btn:hover { background: rgba(255, 255, 255, 0.08); }
.mode-btn .ic { width: 17px; height: 17px; color: var(--gold); }
.mode-btn em { margin-left: auto; font-style: normal; font-size: 11.5px; color: #93aba3; }
.mode-btn.ro { border-color: rgba(214, 168, 78, 0.5); }
div.mode-btn { cursor: default; }
div.mode-btn:hover { background: rgba(255, 255, 255, 0.04); }
.m-ro { display: none; }
body.ro .in { background: transparent; border-color: transparent; box-shadow: none; pointer-events: none; }
body.ro .in.num { padding-right: 8px; }
/* Режим перегляду: цифри лише для читання — вужчі клітинки, щоб таблиці частіше вміщалися на екрані */
body.ro .input-grid .in.num { min-width: 64px; padding-left: 4px; padding-right: 4px; }
body.ro .input-grid td { padding-left: 4px; padding-right: 4px; }
body.ro .pctwrap i { right: 0; }
body.ro .chk, body.ro .colorin, body.ro select.in { pointer-events: none; }
body.ro .chk input:disabled + span { opacity: 0.55; }
body.ro .legend, body.ro .ph-act .legend { display: none; }
body.ro .mat-t td.mlcol .in { background: transparent; }

/* ---------- Закриття місяця ---------- */
body.locked .in { background: transparent; border-color: transparent; box-shadow: none; }
body.locked .input-grid .in.num { padding-left: 4px; padding-right: 4px; }
body.locked .chk, body.locked .colorin, body.locked select.in { pointer-events: none; }
body.locked .chk input:disabled + span { opacity: 0.55; }
body.locked .legend { display: none; }
body.locked .stock-t tr.sec .in:placeholder-shown { visibility: hidden; }
.notice.lock { background: #eef0f6; border-color: #d3d8e6; }
.notice.lock .ic { color: #4d5b86; }
.notice.lock .row-act { margin-top: 8px; }
.notice.lock .btn { margin-left: 0; }
.mtab .mlock { position: absolute; top: 2px; right: 2px; line-height: 0; color: #7d86a3; }
.mtab .mlock .ic { width: 10px; height: 10px; stroke-width: 2.4; }
.mtab.active .mlock { color: #fff; }
.subtabs-r { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; padding: 0 2px 6px; white-space: nowrap; }
.close-st { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: #4d5b86; }
.close-st .ic { width: 14px; height: 14px; }
.close-st.open { color: var(--muted); }
.close-card .cs-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.cs-step { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); flex-wrap: wrap; }
.cs-step > .ic { color: var(--muted); margin-top: 1px; }
.cs-step.ok { background: var(--accent-soft); border-color: #c8e2d8; }
.cs-step.ok > .ic { color: var(--accent); }
.cs-step > div { flex: 1; min-width: 120px; }
.cs-step > div b { display: block; font-size: 13.5px; }
.cs-step > div span { font-size: 12.5px; color: var(--muted); }
.cs-step .btn { margin-left: 28px; }
.send-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.send-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; flex-wrap: wrap; }
.send-row > a { display: inline-flex; align-items: center; gap: 10px; color: var(--text); flex: 1; min-width: 180px; }
.send-row .avatar { width: 32px; height: 32px; font-size: 11px; border-radius: 9px; }
.ss { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; }
.ss .ic { width: 15px; height: 15px; }
.ss.ok { color: var(--accent); }
.ss.warn { color: #a8792a; }
.ss.none { color: var(--muted); }
.slip-act.send { gap: 10px; flex-wrap: wrap; }
.slip-sent { display: flex; align-items: center; gap: 6px; margin-top: 18px; font-size: 12px; color: var(--muted); }
.slip-sent .ic { width: 14px; height: 14px; }
.slip-sent { flex-wrap: wrap; }
.slip-early { flex-basis: 100%; color: #a8792a; }
.send-all { margin-top: 10px; }

/* ---------- Рейтинг майстрів ---------- */
.rate { font: inherit; font-weight: 700; font-size: 13px; min-width: 42px; padding: 3px 8px; border-radius: 99px; border: 1px solid transparent; cursor: pointer; font-variant-numeric: tabular-nums; }
.rate.hi { background: var(--accent-soft); color: var(--accent); border-color: #c8e2d8; }
.rate.mid { background: var(--gold-soft); color: #9a7428; border-color: #efd9a8; }
.rate.lo { background: #fbeeec; color: var(--neg); border-color: #f0cfc9; }
.rate:hover { filter: brightness(0.97); }
.rate-t td small { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.rate-t td:first-child { min-width: 170px; }
.rate-t td.r { white-space: nowrap; }

/* ---------- Кабінет майстра ---------- */
.cab-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-bottom: 10px; }
.cal-w { text-align: center; font-size: 11.5px; color: var(--muted); font-weight: 600; padding-bottom: 2px; }
.cal-d { aspect-ratio: 1 / 1; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-variant-numeric: tabular-nums; }
a.cal-d:hover { border-color: var(--accent); text-decoration: none; }
.cal-d b { font-size: 15px; font-weight: 600; }
.cal-d span { font-size: 11px; color: var(--accent); font-weight: 700; display: inline-flex; align-items: center; gap: 2px; min-height: 13px; }
.cal-d span .ic { width: 11px; height: 11px; }
.cal-d.has { background: var(--accent-soft); border-color: #c8e2d8; }
.cal-d.today { box-shadow: 0 0 0 2px var(--gold); border-color: var(--gold); }
.cal-d.fut { color: #c3beb2; background: transparent; border-style: dashed; }
.cal-d.void { border: 0; background: transparent; }
.close-me { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.close-me > div:first-child { width: 40px; height: 40px; border-radius: 12px; background: #eef0f6; color: #4d5b86; display: grid; place-items: center; }
.close-me .cm-t { flex: 1; min-width: 200px; }
.close-me .cm-t b { display: block; }
.close-me .cm-t span { display: block; font-size: 12.5px; color: var(--muted); }
.cab-sum { display: flex; flex-direction: column; }
.cs-sec { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 650; margin: 10px 0 4px; }
.cs-sec:first-child { margin-top: 0; }
.cs-row { display: flex; align-items: baseline; gap: 10px; padding: 6px 0; border-bottom: 1px solid #f0ede6; }
.cs-row span { flex: 1; min-width: 0; }
.cs-row em { font-style: normal; font-size: 12px; color: var(--muted); }
.cs-row b { min-width: 56px; text-align: right; font-variant-numeric: tabular-nums; }
.flag { display: inline-block; font-size: 11px; font-weight: 650; padding: 2px 7px; border-radius: 99px; white-space: nowrap; line-height: 1.35; }
.flag.low { background: var(--gold-soft); color: #9a7428; border: 1px solid #efd9a8; }
.flag.out { background: #fbeeec; color: var(--neg); border: 1px solid #f0cfc9; }
.flag.ord { background: var(--accent-soft); color: var(--accent); border: 1px solid #c8e2d8; }
.flag-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.flag-row { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 10px; font: inherit; text-align: left; cursor: pointer; color: var(--text); }
.flag-row span:not(.flag) { flex: 1; min-width: 0; }
.flag-row em { font-style: normal; font-size: 12px; color: var(--muted); }
.flag-row:hover { border-color: var(--accent); }

.cab-nav { flex-wrap: wrap; }
.cab-dh { margin-bottom: 10px; }
.cab-tools { margin-bottom: 8px; }
.cab-tools .search { width: 100%; max-width: 520px; font-size: 16px; padding: 10px 14px; }
.cab-hint { max-width: 640px; }
.cab-secs { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.cab-sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.cab-sec.recent { margin-bottom: 8px; border-color: #efd9a8; }
.cab-sh { width: 100%; display: flex; align-items: center; gap: 10px; padding: 14px 16px; border: 0; background: transparent; font: inherit; color: var(--text); cursor: pointer; text-align: left; }
.cab-sh.static { cursor: default; background: var(--gold-soft); }
.cab-sh b { font-size: 15px; }
.cab-sh em { font-style: normal; font-size: 12px; color: var(--muted); flex: 1; }
.cab-sh .ic { color: var(--muted); }
.cab-sec.open > .cab-sh { border-bottom: 1px solid var(--line); }
.cab-list { padding: 2px 10px 8px; }
/* Залишки матеріалів у кабінеті майстра */
.left-b { display: inline-block; font-style: normal; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; white-space: nowrap; line-height: 1.4; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.left-b.ok { background: var(--accent-soft); color: var(--accent); border-color: #c8e2d8; }
.left-b.low { background: var(--gold-soft); color: #9a7428; border-color: #efd9a8; }
.left-b.out { background: #fbeeec; color: var(--neg); border-color: #f0cfc9; }
.left-v { font-variant-numeric: tabular-nums; }
.left-v.low { color: #9a7428; }
.left-v.out { color: var(--neg); }
.sheet-left { margin: -4px 0 10px; }
.rest-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.rest-top .chips { margin: 0; }
.rest-stats { display: flex; gap: 6px; flex-wrap: wrap; }
.rest-stats .left-b { font-size: 12.5px; padding: 3px 10px; }
.rest-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; align-items: start; margin-bottom: 12px; }
.rest-sec { margin: 0; }
.rest-sec h3 { margin-bottom: 4px; }
.rest-row { display: grid; grid-template-columns: minmax(0, 1fr) 52px 60px 58px; align-items: center; gap: 10px; width: 100%; padding: 8px 6px; border: 0; border-bottom: 1px solid #f3f0ea; background: transparent; font: inherit; color: var(--text); text-align: left; cursor: pointer; border-radius: 6px; }
.rest-row:hover { background: var(--surface-2); }
.rest-row:last-child { border-bottom: 0; }
.rest-row .nm { min-width: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; overflow-wrap: anywhere; }
.rest-row b { text-align: right; }
.rest-row em { font-style: normal; font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }
.rest-row em.rest-na { grid-column: 2 / -1; }
.rest-bar { height: 6px; border-radius: 99px; background: #eeebe4; overflow: hidden; }
.rest-bar i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.rest-row.low .rest-bar i { background: #e2b85e; }
.rest-row.out .rest-bar i { background: var(--neg); }
.rest-card { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.rest-card:hover { text-decoration: none; border-color: var(--accent); }
.rest-card > .ic { width: 22px; height: 22px; color: var(--accent); }
.rest-card > div { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.rest-card > div > span { display: flex; gap: 6px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.rest-card .arr { color: #b9b4a8; }
.cab-name .left-b { font-size: 10.5px; }
.cab-proc { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 650; padding: 12px 6px 4px; }
.cab-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px solid #f3f0ea; }
.cab-row:last-child { border-bottom: 0; }
.cab-name { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px 6px; border: 0; background: transparent; font: inherit; font-size: 15px; color: var(--text); text-align: left; cursor: pointer; border-radius: 8px; }
.cab-name:hover { background: var(--surface-2); }
.cab-name .nm { min-width: 0; }
.cab-row.has .cab-name .nm { font-weight: 650; }
.cab-name .more { margin-left: auto; color: #c3beb2; display: inline-flex; }
.note-ic { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); font-size: 11.5px; font-weight: 650; }
.note-ic .ic { width: 15px; height: 15px; }
.in.cab-q { width: 92px; flex: none; font-size: 16px; padding: 9px 10px; text-align: right; }
.cab-row.has .in.cab-q { border-color: var(--accent); background: #f1f8f5; font-weight: 650; }
.in.area, .modal textarea.in.area { resize: vertical; min-height: 64px; font: 15px/1.4 var(--font); padding: 9px 11px; margin: 0; border-color: var(--line); }
.cab-note .in.area { font-size: 16px; }
.cab-sheet .sheet-q { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 6px; }
.cab-sheet .sheet-q label { font-weight: 600; }
.sheet-h { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 650; margin: 14px 0 8px; }
.flag-opts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-bottom: 8px; }
.flag-opt { font: inherit; font-size: 13px; font-weight: 600; padding: 10px 6px; border-radius: 10px; border: 1px solid var(--line-2); background: #fff; cursor: pointer; color: var(--text); line-height: 1.2; }
.flag-opt.ok.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.flag-opt.low.on { background: #e9b949; border-color: #d6a84e; color: #3b2d0c; }
.flag-opt.out.on { background: var(--neg); border-color: var(--neg); color: #fff; }
.nav-new { margin-left: auto; font-style: normal; font-size: 11px; font-weight: 700; background: var(--gold); color: #17352f; border-radius: 99px; padding: 1px 7px; }
.slip-list { display: flex; flex-direction: column; gap: 6px; }
.slip-li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font: inherit; color: var(--text); cursor: pointer; text-align: left; }
.slip-li b { flex: 1; }
.slip-li em { font-style: normal; font-weight: 650; font-variant-numeric: tabular-nums; }
.slip-li.active { border-color: var(--accent); background: var(--accent-soft); }
.empty-state.small { margin: 30px auto; }
.cab-set .comp { margin: 0; }
.person.off { opacity: 0.6; box-shadow: none; }
.person .pv b.small { font-size: 12.5px; font-weight: 600; }

/* Стовпець майстра з кабінетом у «Витратних матеріалах» */
.stock-t td.name .name-in { display: flex; align-items: center; gap: 6px; }
.stock-t td.name .name-in .in { flex: 1; }
.sig { display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent; padding: 0; cursor: pointer; font: inherit; flex: none; }
.sig .flag { font-size: 10.5px; padding: 1px 6px; }
.in.cabv::placeholder { color: var(--accent); opacity: 1; font-weight: 650; }
.stock-t td.cabcol .in.cabv { border-color: #b9d8cc; background: #f1f8f5; }
.stock-t td.cabcol .in.cabv.fixed { border-color: #e2b85e; background: #fff4d6; font-weight: 650; }
body.locked .stock-t td.cabcol .in.cabv, body.ro .stock-t td.cabcol .in.cabv { background: transparent; border-color: transparent; }
.cab-tag { display: flex; align-items: center; justify-content: center; gap: 3px; font-size: 10px; font-weight: 600; color: var(--accent); margin-top: 2px; }
.cab-tag .ic { width: 11px; height: 11px; }
.cabv-demo { color: var(--accent); font-weight: 700; }
.sig-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 8px 24px; }
.sig-grid .sheet-h:first-child { margin-top: 0; }
.sig-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid #f0ede6; flex-wrap: wrap; }
.sig-row b { font-weight: 600; }
.sig-row .btn { margin-left: auto; }
.sig-row.done { opacity: 0.6; }
.sig-note { padding: 7px 0; border-bottom: 1px solid #f0ede6; }
.sig-note p { margin: 2px 0 0; white-space: pre-wrap; }

/* ---------- Адаптивність ---------- */
@media (max-width: 1480px) {
  .mtab .full { display: none; }
  .mtab .short { display: inline; }
}
@media (max-width: 700px) {
  .ytab .full { display: none; }
  .ytab .short { display: inline; }
  .hb-row { grid-template-columns: 1fr; gap: 3px; }
  .hb-track i { width: calc((100% - 110px) * var(--p)); }
}
.m-title, .m-menu { display: none; }
@media (max-width: 1000px) {
  html, body { overflow-x: clip; }
  .app { flex-direction: column; }
  .content { width: 100%; }
  /* Верхня панель замість бокового меню */
  .side { width: 100%; height: auto; position: sticky; top: 0; z-index: 30; padding: calc(8px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); flex-direction: row; align-items: center; gap: 10px; }
  .brand { padding: 0; }
  .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
  .brand-mark .logo { width: 26px; height: 26px; }
  .brand-sub, .brand-name { display: none; }
  .side > .sync { order: 0; margin: 0; padding: 8px; }
  .m-ro { display: inline-grid; place-items: center; vertical-align: -4px; margin-left: 8px; width: 26px; height: 26px; border-radius: 8px; border: 1px solid rgba(214, 168, 78, 0.6); background: transparent; color: var(--gold); cursor: pointer; }
  .m-ro .ic { width: 16px; height: 16px; }
  .side > .sync span { display: none; }
  .side > .sync .ic { width: 22px; height: 22px; }
  .m-title { display: block; flex: 1; min-width: 0; color: #fff; font-weight: 650; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side .m-menu { display: inline-grid; width: 40px; height: 40px; color: #fff; border-color: rgba(255, 255, 255, 0.16); }
  .m-menu .ic { width: 22px; height: 22px; }
  .m-menu:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
  .nav, .side-foot { display: none; }
  body.menu-open .nav, body.menu-open .side-foot { display: flex; }
  body.menu-open .nav { position: fixed; left: 0; right: 0; top: calc(56px + env(safe-area-inset-top)); bottom: 0; z-index: 40; background: #12292a; padding: 10px max(12px, env(safe-area-inset-left)) 90px; overflow-y: auto; flex-direction: column; }
  body.menu-open .nav a { padding: 13px 14px; font-size: 16px; }
  body.menu-open .side-foot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: #12292a; padding: 12px max(12px, env(safe-area-inset-left)) calc(12px + env(safe-area-inset-bottom)); flex-direction: column; }
  body.menu-open { overflow: hidden; }
  .monthbar { padding: 8px 12px; gap: 8px; top: calc(56px + env(safe-area-inset-top)); }
  .yearsel .ibtn { width: 28px; height: 28px; }
  .year { min-width: 38px; }
  .mtab { padding: 7px 8px; }
  .main { padding: 18px 16px 50px; }
  .set-layout { grid-template-columns: 1fr; }
  .set-list { position: static; }
  .blocks, .grid2, .cards, .exp-grid, .slips-all, .cab-grid, .rest-grid { grid-template-columns: 1fr; }
  .emp-head-sum { margin-left: 0; width: 100%; }
}
@media (max-width: 560px) {
  .be-nums { grid-template-columns: 1fr; gap: 6px; }
  .be-nums b { font-size: 17px; }
  .two { grid-template-columns: 1fr; }
  .people { grid-template-columns: 1fr; }
  .ph h1 { font-size: 22px; }
  .main { padding: 14px 12px 50px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
  .kpi { padding: 12px 13px; }
  .kpi-l { font-size: 11.5px; line-height: 1.3; }
  .kpi-v { font-size: 17px; }
  .kpis.small .kpi-v { font-size: 15.5px; }
  .kpi-n { font-size: 11px; }
  .card { padding: 14px; }
  .card.flush { padding: 0; }
  .grid2, .cards { grid-template-columns: minmax(0, 1fr); }
  .emp-head-sum > div { flex: 1; }
  .yearsel { padding: 2px; }
  .monthbar .ytab { padding: 7px 9px; }
  .subtabs a { padding: 10px 10px; }
  .fields { grid-template-columns: 1fr; }
  .search { width: 100%; }
  .modal-f { flex-wrap: wrap; }
  /* Кабінет майстра на телефоні */
  .cal { gap: 4px; }
  .cal-d { border-radius: 10px; min-height: 40px; }
  .cal-d b { font-size: 14px; }
  .cab-list { padding: 2px 6px 6px; }
  .cab-sh { padding: 13px 12px; }
  .in.cab-q { width: 84px; }
  .rest-row { grid-template-columns: minmax(0, 1fr) 34px 54px 52px; gap: 8px; }
  .close-card .cs-steps { grid-template-columns: 1fr; }
  .overlay:has(.cab-sheet) { place-items: end stretch; padding: 0; }
  .modal.cab-sheet { max-width: none; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
/* Сенсорні екрани: більші цілі для пальця */
@media (pointer: coarse) {
  .ibtn { width: 36px; height: 36px; }
  .ibtn.small { width: 32px; height: 32px; }
}

/* ---------- Телефон: таблиці без обрізання ---------- */
@media (max-width: 700px) {
  /* Витрати: кожна стаття — окремий блок, підписи над полями */
  .exp-card table, .exp-card tbody, .exp-card tfoot { display: block; width: 100%; }
  .exp-card thead { display: none; }
  .exp-card tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 6px 8px; align-items: end; padding: 10px 0; border-bottom: 1px solid #f0ede6; }
  .exp-card.sup tr { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; }
  .exp-card td { display: block; padding: 0; border: 0; min-width: 0; }
  .exp-card td.name { grid-column: 1 / -1; }
  .exp-card td.name .in { min-width: 0; flex: 1; }
  .exp-card .in.num { min-width: 0; }
  .exp-card td[data-l]::before { content: attr(data-l); display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; font-weight: 500; text-align: left; }
  .exp-card tbody tr:hover td { background: transparent; }
  .exp-card tfoot tr { background: var(--gold-soft); border-radius: 10px; padding: 10px 12px; border: 0; margin-top: 8px; }
  .exp-card tfoot td { background: transparent; border: 0; padding: 0; }
  .exp-card tfoot td:first-child { grid-column: 1 / -1; }
  .exp-card:not(.sup) tfoot tr { display: flex; justify-content: space-between; }
  .exp-card tfoot td.e { display: none; }
  /* Блоки розрахунку ЗП: по дві клітинки в рядок, підпис над значенням */
  .blk-t.kv-m, .blk-t.kv-m tbody { display: block; }
  .blk-t.kv-m thead { display: none; }
  .blk-t.kv-m tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .blk-t.kv-m td { display: block; text-align: left; min-width: 0; border-bottom: 1px solid #f0ede6; }
  .blk-t.kv-m td:nth-child(odd) { border-right: 1px solid #f0ede6; }
  .blk-t.kv-m td::before { content: attr(data-l); display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
  .blk-t.kv-m td.calc small { text-align: left; }
  .blk-t.kv-m .in { min-width: 0; }
  .blk-f { flex-wrap: wrap; }
  /* «Майстри місяця»: кожна майстриня — блок: імʼя й рейтинг, під ними чотири цифри з підписами */
  .masters-t, .masters-t tbody, .masters-t tfoot { display: block; width: 100%; }
  .masters-t thead { display: none; }
  .masters-t tr { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px 8px; align-items: end; padding: 12px 0; border-bottom: 1px solid #f0ede6; }
  .masters-t td { display: block; padding: 0; border: 0; min-width: 0; text-align: left; font-size: 13.5px; white-space: nowrap; }
  .masters-t td.r { text-align: left; }
  .masters-t td.nm { grid-column: 1 / 4; font-size: 15px; font-weight: 600; }
  .masters-t td.nm a { color: var(--text); }
  .masters-t td.rt { grid-column: 4; grid-row: 1; text-align: right; }
  .masters-t td[data-l]::before { content: attr(data-l); display: block; font-size: 11px; color: var(--muted); font-weight: 500; margin-bottom: 2px; white-space: normal; line-height: 1.2; }
  .masters-t td.barc { grid-column: 1 / -1; }
  .masters-t td.barc .bar { min-width: 0; height: 6px; }
  .masters-t tbody tr:hover td { background: transparent; }
  .masters-t tfoot tr { background: var(--gold-soft); border-radius: 10px; padding: 10px 12px; margin-top: 8px; border: 0; }
  .masters-t tfoot td { background: transparent; border: 0; padding: 0; }
  .masters-t tfoot td.e { display: none; }
  .masters-t tfoot tr { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .masters-t tfoot td.nm { grid-column: 1 / -1; }
  .masters-card .scroll-x { overflow: visible; }
  .to-in { flex-wrap: wrap; width: 100%; }
  .to-in .in { flex: 1 1 160px; width: auto; }
}

/* ---------- Друк ---------- */
@media print {
  body { background: #fff; }
  .side, .monthbar, .subtabs, .crumbs, .slip-act, .ph-act, .noprint, .notice, .legend, .btn, .ibtn { display: none !important; }
  .main { padding: 0; max-width: none; }
  .card, .kpi, .blk, .slip { box-shadow: none; }
  .slip { border: 1px solid #999; break-inside: avoid; margin-bottom: 20px; }
  .slips-all { display: block; }
  .scroll-x, .scroll-x.tall { overflow: visible; max-height: none; }
  .in { border: none; background: transparent; padding: 0; }
  .kpi.accent { background: #fff; color: var(--text); border: 1px solid #999; }
  .kpi.accent .kpi-l { color: var(--muted); }
}
