:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1d2433;
  --muted: #6b7486;
  --border: #dde2ea;
  --accent: #1f5fbf;
  --accent-soft: #e6eefb;
  --side-bg: #17223a;
  --side-text: #c9d2e3;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #18794e;
  --ok-soft: #e7f6ee;
  --radius: 8px;
  --topbar-h: 60px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
}
/* Друга організація має інший акцент, щоб було видно, в якій ведемо облік */
.org-42057871 { --accent: #0f7a6c; --accent-soft: #e2f4f1; --side-bg: #12302c; }

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }

/* ---------- Кнопки й поля ---------- */
.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 6px; cursor: pointer; font: inherit; text-decoration: none;
  display: inline-block;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { border-color: transparent; background: none; color: var(--muted); }
.btn-block { width: 100%; padding: 11px; font-weight: 600; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field span { font-size: 13px; color: var(--muted); }
input, select {
  font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text); min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.flash { padding: 10px 12px; border-radius: 6px; margin-bottom: 14px; }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash-ok { background: var(--ok-soft); color: var(--ok); }

.logo {
  width: 40px; height: 40px; border-radius: 10px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 20px; flex: none;
}

.logo-img { height: 40px; width: auto; flex: none; display: block; }
.logo-lg { height: 110px; }

/* ---------- Сторінка входу ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 480px; background: var(--surface); border-radius: 12px;
  padding: 28px; box-shadow: 0 8px 30px rgba(20, 30, 60, .08);
}
.login-brand { display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; margin-bottom: 22px; }
.login-brand h1 { font-size: 20px; }
.login-brand p { margin: 0; }
.org-choice { border: 0; padding: 0; margin: 0 0 18px; }
.org-choice legend { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.org-option {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer;
}
.org-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.org-option input { margin-top: 3px; }
.org-body { display: flex; flex-direction: column; gap: 2px; }
.org-name { font-weight: 600; }
.org-meta { font-size: 13px; color: var(--muted); }

/* ---------- Каркас застосунку ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.app-body { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: 250px; flex: none; background: var(--side-bg); color: var(--side-text);
  padding: 12px 10px; position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}
.sidebar-org { padding: 4px 10px 12px; border-bottom: 1px solid rgba(255, 255, 255, .1); }
.org-short { color: #fff; font-weight: 600; }
.org-code { font-size: 12px; opacity: .7; }
.nav-group {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .55;
  padding: 14px 10px 6px;
}
.nav-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; border-radius: 6px; color: var(--side-text); text-decoration: none;
}
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
/* розділи, які ще не зроблено (ready не задано в core.MODULES) — червоним; готові — звичайним білим */
.nav-item.todo { color: #ff6b6b; }
.nav-item.todo:hover { color: #ff8f8f; }
.nav-item.todo.active { color: #fff; }

.topbar {
  position: sticky; top: 0; z-index: 10; min-height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap;
  padding: 8px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand-text { font-weight: 700; font-size: 16px; }
.org-switch { margin-left: auto; }
.org-switch label { display: flex; align-items: center; gap: 8px; }
.org-switch select { max-width: 420px; }
.user { display: flex; align-items: center; gap: 6px; }
.user .user-name { color: inherit; text-decoration: none; }
.user .user-name:hover { text-decoration: underline; }
.content { flex: 1; min-width: 0; padding: 24px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-top: 18px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 24px; font-weight: 600; margin-top: 6px; }

.badge {
  display: inline-block; background: var(--accent-soft); color: var(--accent);
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; margin-top: 0;
}

.grid { display: grid; grid-template-columns: 150px 1fr 90px 90px 130px; gap: 0 12px; }
.grid .wide { grid-column: 1 / -1; }
.period { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.period .btn { margin-bottom: 14px; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.table tfoot td { font-weight: 600; border-bottom: 0; }
.num { text-align: right !important; white-space: nowrap; font-variant-numeric: tabular-nums; }

.nav-toggle, .nav-close { display: none; }
@media (max-width: 800px) {
  /* телефон: меню ховається за кнопкою ☰ і виїжджає зліва поверх сторінки */
  .app-body { display: block; }
  .topbar { gap: 8px 10px; padding: 8px 16px; }
  .nav-toggle {
    display: inline-flex; align-items: center; justify-content: center; order: 0;
    width: 40px; height: 40px; flex: none; font-size: 22px; line-height: 1;
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); cursor: pointer;
  }
  .brand { order: 1; flex: 1; min-width: 0; }
  .brand-text { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .logo-img { height: 30px; }
  .user { order: 2; }
  .user .user-name { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .org-switch { order: 3; margin-left: 0; width: 100%; }
  .stats, .grid { grid-template-columns: 1fr 1fr; }
  .org-switch label > .muted { display: none; }
  .org-switch select { width: 100%; max-width: none; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 40; width: min(300px, 85vw); height: 100%;
    transform: translateX(-100%); transition: transform .2s ease, visibility .2s; visibility: hidden;
  }
  body.nav-open .sidebar { transform: none; visibility: visible; box-shadow: 0 0 24px rgba(0, 0, 0, .3); }
  body.nav-open { overflow: hidden; }
  .sidebar-org { display: flex; flex-direction: row-reverse; justify-content: space-between; align-items: flex-start; gap: 8px; }
  .nav-close { display: block; width: 36px; height: 36px; flex: none; font-size: 18px; border: 0; border-radius: 6px;
               background: rgba(255, 255, 255, .08); color: #fff; cursor: pointer; }
  .nav-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .4); }
  .nav-item { padding: 11px 10px; }
  .content { padding: 12px 16px; }
  .grid { grid-template-columns: 1fr 1fr; }
  .card { overflow-x: auto; }
  .page-head { flex-wrap: wrap; }
  /* вкладки розділу гортаються вбік, а не розтягують сторінку */
  .section-links { overflow-x: auto; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
  .section-links a { white-space: nowrap; flex: none; padding: 8px 10px; }
  body .wo-signs td { min-width: 0; }
  body .wo-signs td:last-child { padding-left: 24px; }
  .toolbar { flex-wrap: wrap; }
}
@media (min-width: 801px) { .nav-backdrop { display: none; } }
@media (max-width: 420px) { .brand-text { display: none; } }

/* ---------- Загальні дрібниці ---------- */
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.in { color: var(--ok); }
.bad-text { color: var(--danger); }
.ok-text { color: var(--ok); font-size: 13px; margin-top: 4px; }
.bad-text.small, .stat .bad-text { font-size: 13px; }
.inline { display: inline; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; }
.btn-small { padding: 4px 10px; font-size: 13px; }
.btn-danger { color: var(--danger); border-color: var(--danger-soft); }
.btn:disabled { opacity: .5; cursor: default; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; vertical-align: middle; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: #fff4e0; color: #9a5b00; }
.check { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.table-wrap { overflow-x: auto; }
.print-only { display: none; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.period-picker { display: flex; gap: 6px; align-items: center; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.toolbar form { margin: 0; }
.dropdown { position: relative; }
.dropdown summary { list-style: none; }
.dropdown summary::-webkit-details-marker { display: none; }
.dropdown-body { position: absolute; z-index: 20; width: 320px; margin-top: 6px; box-shadow: 0 10px 30px rgba(20, 30, 60, .15); }
.stats { margin-top: 18px; }
.stat-value.in { color: var(--ok); }

.salary summary { cursor: pointer; }
.salary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 12px; align-items: end; margin-top: 12px; }
.salary-grid .btn { margin-bottom: 14px; }
.salary i { font-style: normal; font-size: 11px; }

/* ---------- Таблиця операцій ---------- */
.ops-card .hint { margin: 0 0 10px; }
.table.ops td { vertical-align: top; padding: 8px 6px; font-size: 14px; }
.table.ops th { padding: 8px 6px; }
.ops .no { color: var(--muted); width: 28px; }
.ops .cp { min-width: 260px; max-width: 420px; }
.cp-name { font-weight: 600; }
.purpose { font-size: 12px; color: var(--muted); margin-top: 2px; cursor: text; user-select: text; }
.purpose::selection { background: #ffe58a; color: var(--text); }
.ops .doc { font-size: 12px; white-space: nowrap; }
.ops .dir { min-width: 170px; }
.dir-select { width: 100%; padding: 5px 6px; font-size: 13px; }
.accs { font-size: 11px; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.acc { width: 48px; padding: 2px 4px; font-size: 12px; text-align: center; }
.amount { font-weight: 600; }
.amount.in { color: var(--ok); }
tr.op.bad { background: var(--danger-soft); }
tr.op.bad .dir-select, tr.op.bad .acc[value=""] { border-color: var(--danger); background: #fff; }
.only-bad tr.op:not(.bad), .only-bad tr.commission-sum { display: none; }
tr.commission-row { display: none; }
.show-commission tr.commission-row, .only-bad tr.commission-row.bad { display: table-row; }
tr.commission-row td { background: #fafbfc; }
.commission-sum td { background: #f6f7f9; }

.ico { width: 34px; text-align: center; }
.flag { width: 30px; height: 30px; border: 1px solid transparent; border-radius: 6px; background: none; color: #c3c9d4; cursor: pointer; padding: 4px; }
.flag svg { width: 20px; height: 20px; display: block; }
.flag:hover { border-color: var(--border); color: var(--muted); }
.flag.on { color: var(--accent); background: var(--accent-soft); }
.flag.need { color: #d48a00; }

.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; padding: 4px 8px; border-radius: 6px; color: var(--muted); }
.menu summary::-webkit-details-marker { display: none; }
.menu[open] summary { background: var(--accent-soft); }
.menu-body { position: absolute; right: 0; z-index: 15; width: 260px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px; box-shadow: 0 10px 30px rgba(20, 30, 60, .15); display: flex; flex-direction: column; gap: 10px; text-align: left; }
.menu-body form { margin: 0; }

.rule-pop { position: absolute; z-index: 30; width: 320px; background: var(--surface); border: 1px solid var(--accent); border-radius: 8px; padding: 12px; box-shadow: 0 10px 30px rgba(20, 30, 60, .2); display: flex; flex-direction: column; gap: 8px; }
.rule-pop[hidden] { display: none; }
.rule-text { font-weight: 600; word-break: break-word; }
.rule-actions { display: flex; gap: 6px; }

/* ---------- Налаштування ---------- */
.tabs { display: flex; gap: 4px; margin-top: 16px; border-bottom: 1px solid var(--border); }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.settings-table td { padding: 5px 8px; }
.settings-table tr.bad td:first-child { color: var(--danger); font-weight: 600; }
.num-input { width: 140px; text-align: right; }
.settings-table .acc { width: 60px; }

/* ---------- Головна книга (перегляд) ---------- */
.book-wrap { overflow: auto; max-height: calc(100vh - 230px); margin-top: 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.book { border-collapse: separate; border-spacing: 0; font-size: 12px; }
.book th, .book td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 4px 6px; white-space: nowrap; }
.book thead th { position: sticky; top: 0; background: var(--accent-soft); z-index: 2; font-weight: 600; text-align: center; }
.book thead tr:nth-child(2) th { top: 25px; white-space: normal; min-width: 78px; max-width: 110px; font-size: 11px; }
.book th.an, .book .grp.g-48in, .book .grp.g-48out { background: #eef3e6; }
.book td.cp { min-width: 200px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.book tr.total td { background: #f2f4f7; font-weight: 700; }
.book tr.act td { color: var(--muted); }
.book tr.salary td { background: #fbfaf2; }
.book td:first-child, .book th:first-child { position: sticky; left: 0; background: inherit; }

/* ---------- Акт списання (аркуш) ---------- */
.paper { background: #fff; color: #000; max-width: 1050px; margin-top: 16px; padding: 32px 40px; border: 1px solid var(--border); font-family: "Times New Roman", serif; font-size: 15px; }
.paper-top { display: flex; justify-content: space-between; gap: 20px; }
.approve { text-align: right; }
.paper-title { text-align: center; font-size: 18px; margin: 24px 0 12px; }
.paper-table th, .paper-table td { border: 1px solid #999; font-size: 13px; color: #000; }
.paper-table th { text-transform: none; font-size: 13px; color: #000; }
.signs { margin-top: 28px; display: flex; flex-direction: column; gap: 18px; }
.line { display: inline-block; width: 120px; border-bottom: 1px solid #000; margin-left: 10px; }
.line.long { width: 220px; }

@media print {
  .sidebar, .topbar, .no-print, .flash { display: none !important; }
  .print-only { display: block; }
  .app-body, .content { display: block; padding: 0; }
  body { background: #fff; }
  .book-wrap { overflow: visible; max-height: none; border: 0; }
  .book { font-size: 8px; }
  .book thead th { position: static; }
  .book td:first-child, .book th:first-child { position: static; }
  .paper { border: 0; padding: 0; max-width: none; }
  @page { size: A4 landscape; margin: 10mm; }
}

/* ---------- Банк / Каса / ГК: перемикач розділів ---------- */
.section-links { display: flex; gap: 4px; margin-top: 14px; border-bottom: 1px solid var(--border); }
.section-links a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; }
.section-links a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 18px; align-items: start; }
.manual-grid { display: grid; grid-template-columns: 140px 1fr 1fr 120px auto; gap: 0 10px; align-items: end; margin-top: 10px; }
.manual-grid .btn { margin-bottom: 14px; }
.book .src { font-size: 10px; padding: 1px 5px; border-radius: 4px; background: #eef1f5; color: var(--muted); }
.book .src-cash .src { background: #fff4e0; color: #9a5b00; }
.book .src-salary .src, .book .src-manual .src { background: #eef3e6; color: #3d6b12; }

/* ---------- Каса ---------- */
.cash-book td { font-size: 14px; vertical-align: top; }
.cash-book tr.day-head td { background: #f6f7f9; font-weight: 600; font-size: 13px; }
.cash-book tr.day-total td { font-weight: 600; border-bottom: 2px solid var(--border); }
.cash-book tfoot td { font-weight: 700; }
.order-page { padding: 16px; background: var(--bg); }
.paper.order { max-width: 820px; }
@media print { .order-page { padding: 0; background: #fff; } }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } .manual-grid { grid-template-columns: 1fr 1fr; } }

/* ---------- Персонал: календар, табель, зарплата ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 12px; align-items: end; }
.form-grid .check { margin-bottom: 14px; }
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0 6px; }
.week-grid input { width: 100%; text-align: center; }
.year-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin-top: 4px; }
.mini-month { margin-top: 14px; padding: 12px; }
.mini-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal th { font-size: 10px; color: var(--muted); font-weight: 600; padding: 2px; }
.cal td { padding: 2px; }
.day { width: 100%; min-height: 34px; border: 1px solid transparent; border-radius: 5px; background: #f4f6f9; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2px; font: inherit; color: var(--text); }
.day .dn { font-size: 12px; font-weight: 600; }
.day .dh { font-size: 9px; color: var(--muted); }
.day.work { background: var(--accent-soft); }
.day.off { background: #f1f2f4; color: #a0a7b4; }
.day.changed { border-color: #d48a00; }
.day:hover:not([disabled]) { border-color: var(--accent); }
.day.sel { outline: 2px solid var(--accent); }
.day[disabled] { cursor: default; opacity: .4; }
.cal.big .day { min-height: 64px; }
.cal.big .day .dn { font-size: 15px; }
.cal.big .day .dh { font-size: 11px; }
.dk { font-size: 11px; font-weight: 700; }
.day s { color: #b0b6c0; }
.k-work { background: var(--accent-soft) !important; color: var(--accent); }
.k-trip { background: #efe6fb !important; color: #6b3fb5; }
.k-vac { background: #e2f4e8 !important; color: #18794e; }
.k-sick { background: #fdecea !important; color: #b42318; }
.k-unpaid { background: #fff4e0 !important; color: #9a5b00; }
.k-off { background: #f1f2f4 !important; color: #a0a7b4; }
.k-none { background: #fff !important; color: #ccc; }
.day.ts .dn { color: var(--text); }
.kind { display: inline-block; min-width: 26px; text-align: center; border-radius: 4px; font-size: 11px; font-weight: 700; padding: 1px 4px; }
.legend { font-size: 12px; color: var(--muted); margin-bottom: 10px; line-height: 2; }
.ts-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.kind-buttons { display: flex; flex-direction: column; gap: 6px; }
.ts-all td, .ts-all th { min-width: 34px; font-size: 10px; padding: 3px; }
.ts-all th.wk, .ts-all td.wk { background: #f1f2f4; }
.pay-card .card-head { flex-wrap: wrap; gap: 8px; }
.pay-table td, .pay-table th { padding: 5px 8px; font-size: 13px; }
.pay-table .half { font-weight: 700; color: var(--accent); width: 24px; }
.pay-table tr.subtotal td { background: #f6f7f9; font-weight: 600; }
.pay-table tr.grand td, .pay-sum tr.grand td { background: var(--accent-soft); font-weight: 700; }
.pay-tools { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.inline-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { padding: 4px 6px; font-size: 13px; }
.ok-cell { color: var(--ok); }
.bad-cell { color: var(--danger); font-weight: 600; }
.card-table tr.archive td { color: #5b6475; }
@media (max-width: 800px) { .ts-layout { grid-template-columns: 1fr; } .week-grid { grid-template-columns: repeat(4, 1fr); } }

/* ---------- Відрядження: бланки ---------- */
.trips-table td { font-size: 13px; vertical-align: top; }
.trips-table tr.draft td { color: var(--muted); }
.trip-paper, .report-paper { max-width: 900px; font-size: 14px; line-height: 1.5; }
.trip-paper p, .report-paper p { margin: 6px 0; }
.trip-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.trip-right { border-left: 1px dashed #999; padding-left: 20px; }
.blank { display: inline-block; border-bottom: 1px solid #000; height: 1em; vertical-align: bottom; }
.hint { font-size: 10px; color: #555; }
.sign-row { margin-top: 18px !important; }
.cut { border: 0; border-top: 1px dashed #999; margin: 18px 0; }
.lines div { border-bottom: 1px solid #000; height: 26px; }
.marks { width: 100%; border-collapse: collapse; margin-top: 8px; }
.marks td { border: 1px solid #999; padding: 8px; width: 50%; vertical-align: top; font-size: 13px; }
.approved { text-align: right; }
.boxes { display: inline-flex; gap: 0; }
.boxes span { display: inline-block; width: 20px; height: 24px; border: 1px solid #000; margin-right: -1px; text-align: center; line-height: 24px; font-weight: 600; }
.page-break { margin-top: 24px; }
@media print {
  .page-break { page-break-before: always; margin-top: 0; }
  .trip-paper, .report-paper { font-size: 12px; }
  @page { size: A4 portrait; margin: 12mm; }
}

/* ---------- Відпустки ---------- */
.vac-total { font-size: 15px; }
.num-small { width: 38px; text-align: center; padding: 2px 4px; }
.vac-add { margin-top: 10px; }
.vac-add .comp-only { display: none; }
.vac-add.comp .comp-only { display: inline; }
.vac-add.comp .dates { display: none; }

/* ---------- Штатний розпис ---------- */
.current-row td { background: var(--ok-soft); }
.staff-table input, .staff-table select { padding: 4px 6px; font-size: 13px; }
.staff-table td { padding: 4px; }
.staff-table .new-row td { background: #f6f7f9; }
.staff-paper { max-width: 1000px; font-size: 14px; }
.staff-head { margin-bottom: 10px; }
.staff-print th { font-size: 11px; text-transform: none; color: #000; text-align: center; }
.staff-print td { font-size: 13px; }

/* ---------- Реєстрація документів ---------- */
.reg-form { margin-top: 12px; }
.reg-form .wide2, .card .form-grid .wide2 { grid-column: span 2; }
.reg-table td { font-size: 13px; vertical-align: top; }
@media (max-width: 800px) { .reg-form .wide2 { grid-column: auto; } }

/* ---------- Акт на списання (формат документа) ---------- */
.wo-paper { max-width: 820px; font-size: 16px; line-height: 1.45; }
.approve-block { margin-left: 55%; margin-bottom: 18px; }
.wo-text { text-align: justify; text-indent: 1.25cm; margin: 4px 0; }
.wo-item { position: relative; margin-bottom: 12px; }
.wo-edit { position: absolute; right: -44px; top: 0; }
.wo-signs { margin-top: 28px; border-collapse: collapse; }
.wo-signs td { padding: 4px 0; min-width: 220px; vertical-align: top; }
.wo-signs td:last-child { padding-left: 120px; }
textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; }
.act-head { margin: 22px 0 6px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.wo-paper.page-break { margin-top: 0; }
@media print { .wo-paper.page-break { page-break-before: always; } .wo-paper { margin-top: 0; } }

/* ---------- Кошторис: позиції для перевірки, рахунок поруч із файлом ---------- */
:root { --warn-soft: #fff4e0; --warn: #9a5b00; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --warn-soft: #3a2a10; --warn: #f0b860; } }
:root[data-theme="dark"] { --warn-soft: #3a2a10; --warn: #f0b860; }
tr.row-check > td { background: var(--warn-soft); }
.flag-text { color: var(--warn); font-size: 12px; }
.inv-split { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.4fr); gap: 16px; align-items: start; }
.inv-split .inv-file { position: sticky; top: 12px; height: calc(100vh - 120px); min-height: 420px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: auto; }
.inv-split .inv-file iframe { width: 100%; height: 100%; border: 0; }
.inv-split .inv-file img { width: 100%; display: block; }
.inv-lines td input:not([type=checkbox]) { width: 100%; box-sizing: border-box; }
.inv-lines input.w-name { min-width: 200px; } .inv-lines input.w-unit { min-width: 52px; } .inv-lines input.w-qty { min-width: 58px; }
.inv-lines input.w-price { min-width: 84px; } .inv-lines input.w-sum { min-width: 96px; } .inv-lines input.w-dir { min-width: 140px; }
.inv-lines .sub { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 3px; }
.inv-lines td { vertical-align: top; }
@media (max-width: 1000px) { .inv-split { grid-template-columns: 1fr; } .inv-split .inv-file { position: static; height: 70vh; } }
.flash-warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- Шапки документів для друку (як у Word) ---------- */
.lh-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 18px; }
.lh-wide { width: 38%; max-width: 320px; height: auto; }
.lh-approve { text-align: right; line-height: 1.35; }
.lh-org { display: flex; align-items: center; gap: 18px; }
.lh-org img { height: 78px; width: auto; }
.lh-org-name { color: #0070c0; font-weight: 700; font-family: Calibri, Arial, sans-serif; font-size: 15px; line-height: 1.3; }
.lh-org-req { text-align: center; color: #0070c0; font-family: Calibri, Arial, sans-serif; font-size: 10.5px; margin: 6px 0 14px;
              padding-top: 4px; border-top: 1px solid #0070c0; }
.trip-logo { float: right; height: 64px; margin: 0 0 6px 10px; }

/* ---------- Нагадування на «Огляді» ---------- */
.remind { padding: 8px 12px; border-left: 4px solid var(--border); border-radius: 4px; margin: 6px 0; background: var(--bg); }
.remind a { color: inherit; }
.remind ul { margin: 4px 0 0; padding-left: 20px; font-size: 13px; }
.remind-bad { border-left-color: var(--danger); background: var(--danger-soft); }
.remind-warn { border-left-color: #d48a00; background: var(--warn-soft); }
.remind-info { border-left-color: var(--accent); background: var(--accent-soft); }

/* ---------- Пошук у верхній панелі ---------- */
.top-search input { width: 190px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text); }
@media (max-width: 800px) { .top-search { order: 4; width: 100%; } .top-search input { width: 100%; box-sizing: border-box; } }

/* ---------- Члени профспілки ---------- */
a.card.stat { color: inherit; text-decoration: none; }
a.card.stat:hover { border-color: var(--accent); }
tr.row-sel > td { background: var(--accent-soft); }
.mono { font-family: Consolas, "Courier New", monospace; letter-spacing: .02em; }
.aid-table input.mono { font-size: 13px; }

/* ---------- Комплімент на «Огляді» ---------- */
.compliment { display: flex; align-items: center; gap: 12px; margin: 14px 0 6px; padding: 14px 18px; border-radius: var(--radius);
  background: linear-gradient(120deg, var(--accent-soft), var(--surface)); border: 1px solid var(--border); }
.compliment-icon { font-size: 22px; }
.compliment-text { flex: 1; font-size: 17px; font-weight: 600; color: var(--text); font-style: italic; }
.compliment-more { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* ---------- Чат ---------- */
.badge { display: inline-block; min-width: 18px; padding: 1px 6px; border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; text-align: center; line-height: 16px; }
.chat { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 14px; height: calc(100vh - 210px); min-height: 420px; }
.chat-list { overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.chat-peer { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; color: var(--text);
  text-decoration: none; border-bottom: 1px solid var(--border); }
.chat-peer:hover { background: var(--bg); }
.chat-peer.active { background: var(--accent-soft); font-weight: 600; }
.chat-room { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); min-width: 0; }
.chat-title { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.chat-day { align-self: center; font-size: 11px; color: var(--muted); background: var(--surface); padding: 2px 10px; border-radius: 999px; }
.chat-msg { max-width: 75%; align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: 12px 12px 12px 4px; padding: 6px 10px; }
.chat-msg.mine { align-self: flex-end; background: var(--accent-soft); border-color: transparent; border-radius: 12px 12px 4px 12px; }
.chat-meta { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.chat-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.chat-form textarea { flex: 1; resize: vertical; min-height: 40px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; }
@media (max-width: 800px) {
  .chat { grid-template-columns: 1fr; height: auto; }
  .chat-list { display: flex; overflow-x: auto; }
  .chat-peer { border-bottom: 0; border-right: 1px solid var(--border); white-space: nowrap; }
  .chat-msgs { height: 55vh; }
  .chat-msg { max-width: 90%; }
}

/* hidden завжди ховає, навіть якщо в класу свій display */
[hidden] { display: none !important; }

/* ---------- Чат: значок і бокова панель справа ---------- */
.chat-toggle { position: relative; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius);
  width: 38px; height: 34px; font-size: 18px; cursor: pointer; line-height: 1; }
.chat-toggle:hover, body.chat-open .chat-toggle { border-color: var(--accent); background: var(--accent-soft); }
.chat-toggle .badge { position: absolute; top: -7px; right: -8px; }
.chat-panel { position: fixed; right: 0; top: var(--topbar-h); bottom: 0; width: 360px; z-index: 35; display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: -6px 0 18px rgba(0, 0, 0, .08); }
.cp-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.cp-head .cp-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-head button { border: 0; background: none; font-size: 18px; cursor: pointer; color: var(--muted); padding: 2px 6px; }
.cp-list { overflow-y: auto; flex: 1; }
.cp-peer { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; padding: 11px 14px; border: 0;
  border-bottom: 1px solid var(--border); background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.cp-peer:hover { background: var(--bg); }
.cp-room { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.cp-room .chat-msgs { flex: 1; }
.cp-room .chat-msg { max-width: 88%; }
body.chat-open .content { padding-right: 384px; }          /* панель не закриває роботу */
@media (max-width: 1000px) {
  body.chat-open .content { padding-right: 24px; }
  .chat-panel { width: 100%; top: 0; z-index: 45; }      /* телефон / планшет: на весь екран, ✕ — сховати */
}

/* ---------- Двоетапна перевірка ---------- */
.qr { display: inline-block; background: #fff; padding: 8px; border-radius: var(--radius); border: 1px solid var(--border); margin: 4px 0 10px; }
.qr svg { display: block; width: 220px; height: 220px; }
code.key { font-size: 15px; letter-spacing: .5px; user-select: all; }
.code-input { font-size: 22px; letter-spacing: 4px; text-align: center; font-variant-numeric: tabular-nums; }
.codes { columns: 2; max-width: 360px; font-size: 17px; line-height: 1.9; }
@media print { .twofa-codes .toolbar, .sidebar, .topbar, .chat-panel, .page-head .btn { display: none !important; } }

/* ---------- Чат: в мережі, стан повідомлень, видалення ---------- */
.cp-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.cp-titles .cp-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-sub.online { color: var(--ok, #1a7f37); }
.cp-peer-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--border); }
.dot.on { background: #22a559; box-shadow: 0 0 0 2px rgba(34, 165, 89, .18); }
.chat-meta { display: flex; align-items: center; gap: 6px; }
.ticks { font-size: 11px; letter-spacing: -2px; color: var(--muted); margin-left: auto; }
.ticks.read { color: #1d8cf0; }
.ticks.partial { color: #1d8cf0; opacity: .6; }
.msg-del { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 11px; padding: 0 2px; opacity: 0; }
.chat-msg:hover .msg-del, .msg-del:focus { opacity: 1; }
.chat-msg:not(.mine) .msg-del { margin-left: auto; }
.msg-del:hover { color: var(--danger); }
@media (hover: none) { .msg-del { opacity: .55; } }
.edit-link { margin-left: 6px; text-decoration: none; color: var(--muted); } .edit-link:hover { color: var(--accent); }

/* Банк: перегляд за всі періоди */
.all-views { margin-top: -4px; }
.btn.btn-active { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }
.btn.bad-btn { border-color: var(--danger); color: var(--danger); }

tr.done-row { opacity: .35; transition: opacity .6s; }
