:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1d2129;
  --muted: #6b7280;
  --line: #e3e5ea;
  --hover: #f6f7fa;
  --accent: #3b5bdb;
  --accent-soft: #edf1fe;
  --on-accent: #fff;  /* text on --accent and --bad fills */
  --ok: #2b8a3e;
  --ok-soft: #e9f7ec;
  --bad: #c92a2a;
  --bad-soft: #fdecec;
  --warn: #b35c00;
  --warn-soft: #fff4e0;
  --top: 56px;
  --page: 1560px;  /* content width on wide screens; the rest is margin */
  color-scheme: light;
}
/* Dark: the system's choice, unless the person chose light (theme.js: <html data-theme>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171c;
    --card: #1d2027;
    --text: #e6e8ec;
    --muted: #9aa1ad;
    --line: #2d313a;
    --hover: #242833;
    --accent: #7c97ff;
    --accent-soft: #232b45;
    --on-accent: #10172e;
    --ok: #63c77a;
    --ok-soft: #1c2e22;
    --bad: #ff8080;
    --bad-soft: #3a2024;
    --warn: #f0a94b;
    --warn-soft: #362a17;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {  /* the same, chosen on the site */
  --bg: #15171c;
  --card: #1d2027;
  --text: #e6e8ec;
  --muted: #9aa1ad;
  --line: #2d313a;
  --hover: #242833;
  --accent: #7c97ff;
  --accent-soft: #232b45;
  --on-accent: #10172e;
  --ok: #63c77a;
  --ok-soft: #1c2e22;
  --bad: #ff8080;
  --bad-soft: #3a2024;
  --warn: #f0a94b;
  --warn-soft: #362a17;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, select, input { font: inherit; color: inherit; }
small { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 6px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* --- top bar --- */
.top {
  position: sticky; top: 0; z-index: 10;
  height: var(--top);
  display: flex; align-items: center; gap: 14px;
  padding: 0 max(20px, calc((100% - var(--page)) / 2 + 20px));  /* lined up with main */
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; }
.logo {
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--accent); color: var(--on-accent); font-size: 11px; letter-spacing: .5px;
}
.tabs { display: flex; align-self: stretch; gap: 4px; }
.tabs a {
  display: flex; align-items: center; padding: 0 10px; border-bottom: 2px solid transparent;
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 15px;
}
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.months { display: flex; align-items: center; gap: 4px; }
.months select { font-weight: 600; }
.spacer { flex: 1; }
.top .theme { display: grid; place-items: center; flex: none; color: var(--muted); }
.top .theme:hover { color: var(--text); }

.btn {
  border: 1px solid var(--line); background: var(--card);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 3px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon {
  border: 0; background: transparent; cursor: pointer;
  width: 28px; height: 28px; border-radius: 6px; font-size: 18px; line-height: 1;
}
.icon:hover { background: var(--hover); }
.icon:disabled { opacity: .3; cursor: default; }
select {
  border: 1px solid var(--line); background: var(--card);
  border-radius: 7px; padding: 5px 8px;
}

.pill {
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--hover); color: var(--muted);
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }

/* --- layout --- */
main { padding: 20px; max-width: var(--page); margin: 0 auto; }
.work { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; margin-top: 16px; }
.work.with-preview { grid-template-columns: minmax(0, 1fr) minmax(380px, 44%); }
.panels { min-width: 0; }
.panel { display: flex; flex-direction: column; gap: 16px; animation: reveal .22s ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(-8px); } }
.todo { margin-top: 16px; }
.todo ul { list-style: none; margin: 0; padding: 0; }
.todo-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer;
}
.todo-item:hover { background: var(--hover); }
.todo li + li .todo-item { border-top: 1px solid var(--line); border-radius: 0; }
.todo li + li .todo-item:hover { border-radius: 8px; border-top-color: transparent; }
.ti-icon {
  flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  font-size: 12px; font-weight: 700; background: var(--hover); color: var(--muted);
}
.todo-item.bad .ti-icon { background: var(--bad-soft); color: var(--bad); }
.todo-item.warn .ti-icon { background: var(--warn-soft); color: var(--warn); }
.todo-item.ok .ti-icon { background: var(--ok-soft); color: var(--ok); }
.ti-text { flex: 1; min-width: 0; }
.ti-go { flex: none; font-size: 12px; color: var(--muted); }
.todo-item:hover .ti-go { color: var(--accent); }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
}
.card h2 { margin: 0 0 12px; font-size: 15px; }

/* --- dashboard --- */
.dash { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 3px; min-width: 0;
  padding: 14px 16px 13px; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  border-top: 3px solid var(--line);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.tile:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0, 0, 0, .07); }
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile.ok { border-top-color: var(--ok); }
.tile.warn { border-top-color: var(--warn); }
.tile.bad { border-top-color: var(--bad); }
.tile.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tile.active::after {  /* points at the panel below */
  content: ""; position: absolute; left: 50%; bottom: -9px; width: 14px; height: 14px;
  background: var(--card); border: solid var(--accent); border-width: 0 1px 1px 0;
  transform: translateX(-50%) rotate(45deg);
}
.t-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; letter-spacing: .3px; color: var(--muted); text-transform: uppercase;
}
.chev { margin-left: auto; font-size: 11px; transition: transform .2s; }
.tile.active .chev { transform: rotate(180deg); color: var(--accent); }
.t-big { font-size: 26px; font-weight: 680; line-height: 1.25; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-big.long { font-size: 19px; line-height: 1.7; }
.tile.ok .t-big { color: var(--ok); }
.tile.warn .t-big { color: var(--warn); }
.tile.bad .t-big { color: var(--bad); }
.t-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 6px;
  border-radius: 10px; background: #e03131; color: #fff;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0; line-height: 1;
}
.btn .badge { margin-left: 7px; vertical-align: 1px; }

/* --- VAT --- */
.vat-due { font-size: 22px; margin-bottom: 2px; }
.vat-due strong { font-weight: 650; }
.vat-sum { margin: 0 0 8px; font-variant-numeric: tabular-nums; }
.vat-est { margin: 0 0 8px; padding-left: 18px; font-variant-numeric: tabular-nums; }
.vat-docs { margin-top: 8px; }
.vat-docs summary { cursor: pointer; padding: 4px 0; }
.vat-docs .fname { max-width: 420px; }

/* --- ОПР --- */
.bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bar h2 { margin: 0; }
.card.pnl > .bar:first-child { margin-bottom: 12px; }
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.crumb {
  border: 0; background: none; padding: 4px 6px; border-radius: 6px; cursor: pointer; color: var(--accent);
}
.crumb.on { color: var(--text); font-weight: 600; cursor: default; }
.crumb:not(.on):hover { background: var(--accent-soft); }
.chip-f {
  display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px 2px 10px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 13px;
}
.chip-f::before { content: "›"; margin-right: 6px; color: var(--muted); font-weight: 400; }
.chip-f .x {
  border: 0; background: none; cursor: pointer; color: inherit; width: 20px; height: 20px; border-radius: 50%; line-height: 1;
}
.chip-f .x:hover { background: var(--card); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--card); padding: 5px 11px; cursor: pointer; font-size: 13px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button:hover { background: var(--hover); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 14px 0 6px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 10px; background: var(--hover); min-width: 0; }
.k-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.k-value { font-size: 21px; font-weight: 680; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-extra { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.in .k-value, .kpi.pos .k-value { color: var(--ok); }
.kpi.out .k-value, .kpi.neg .k-value { color: var(--bad); }
.pnl-chart { height: 420px; margin-top: 4px; }
.hint { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.split.single { grid-template-columns: minmax(0, 1fr); }
.split h3 { margin: 0 0 8px; font-size: 14px; }
.break { height: 200px; }
.tt { min-width: 230px; font-size: 12.5px; }
.tt-head { font-weight: 700; margin-bottom: 4px; }
.tt-sum { display: flex; justify-content: space-between; gap: 16px; margin-top: 6px; font-weight: 600; }
.tt-sum.in { color: var(--ok); }
.tt-sum.out { color: var(--bad); }
.tt-sum.profit { border-top: 1px solid var(--line); padding-top: 5px; color: var(--accent); }
.tt-row { display: flex; align-items: center; gap: 2px; }
.tt-row .tt-name { flex: 1; max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.tt-row b { font-weight: 500; margin-left: 12px; font-variant-numeric: tabular-nums; }
.tt-hint { margin-top: 6px; font-size: 11px; color: var(--muted); }
#pnl-q { border: 1px solid var(--line); background: var(--card); border-radius: 7px; padding: 5px 9px; width: 200px; }
.check { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 13px; cursor: pointer; white-space: nowrap; }
.table-wrap { margin-top: 10px; max-height: 70vh; overflow: auto; }
.pnl-table th { position: sticky; top: 0; background: var(--card); padding-top: 4px; z-index: 1; }
.pnl-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.pnl-table th.sortable:hover, .pnl-table th.sorted { color: var(--text); }
.pnl-table td { padding: 5px 8px; white-space: nowrap; }
.pnl-table td.desc { max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
.pnl-table td.party { max-width: 230px; overflow: hidden; text-overflow: ellipsis; }
.pnl-table td.desc .tag { margin-left: 6px; }
.pnl-table td.income { color: var(--ok); font-weight: 600; }
.pnl-table td.expense { color: var(--text); }
.pnl-table tr.excluded td { color: var(--muted); }
.pnl-table tfoot td { font-weight: 600; border-top: 2px solid var(--line); position: sticky; bottom: 0; background: var(--card); }
.nowrap { white-space: nowrap; }
.small { font-size: 12px; }
.linkish {
  border: 0; background: none; padding: 0; cursor: pointer; text-align: left; color: inherit;
}
.linkish:hover { color: var(--accent); text-decoration: underline; }

/* --- suppliers --- */
.vendors, .files { list-style: none; margin: 0; padding: 0; }
.vendor { border-top: 1px solid var(--line); padding: 9px 0; }
.vendor:first-child { border-top: 0; padding-top: 0; }
.vhead { display: flex; align-items: center; gap: 10px; min-height: 26px; }
.mark { width: 18px; text-align: center; font-weight: 700; }
.vendor.ok .mark { color: var(--ok); }
.vendor.missing .mark { color: var(--bad); }
.vendor.optional .mark { color: var(--muted); }
.vname { font-weight: 600; }
.logo { width: 18px; height: 18px; flex: none; border-radius: 4px; object-fit: contain; }
img.logo { background: #fff; }  /* dark marks (Revolut, СОТ) stay visible in the dark theme */
.logo.mono { display: inline-grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700; line-height: 1; }
.vcell { display: inline-flex; align-items: center; gap: 6px; }
.vendor.optional:not(.has-files) .vname { font-weight: 500; color: var(--muted); }
.tag {
  font-size: 11px; padding: 1px 7px; border-radius: 5px;
  background: var(--hover); color: var(--muted);
}
.note { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.note.failed { color: var(--bad); }
.vendor.missing .note { color: var(--bad); }
.vhead .btn { margin-left: auto; }

.files { margin: 4px 0 0 28px; }
.file {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto auto;
  align-items: center; gap: 10px;
  padding: 3px 8px; margin: 0 -8px; border-radius: 7px;
}
#others .file { margin-left: -8px; }
.file:hover { background: var(--hover); }
.file.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.fname {
  border: 0; background: none; padding: 2px 0; cursor: pointer; text-align: left;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.fname:hover { color: var(--accent); }
.file.excluded .fname { text-decoration: line-through; color: var(--muted); }
.fmeta { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.fmeta .warn { color: var(--warn); font-weight: 600; }
.file select { font-size: 12px; padding: 2px 4px; max-width: 150px; }
/* Moving a recognised file to another supplier is rare: always there, but quiet until the row is in use. */
.file select.assign:not(.open) { border-color: transparent; background: transparent; color: var(--muted); cursor: pointer; }
.file:hover select.assign, .file.active select.assign, .file select.assign:focus {
  border-color: var(--line); background: var(--card); color: var(--text);
}
.incl { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.file .icon { width: 24px; height: 24px; font-size: 14px; color: var(--muted); }
.file .icon:hover { color: var(--bad); }
.file .spacer-icon { width: 24px; }

/* --- payments --- */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 0 8px 6px; }
td { padding: 6px 8px; border-top: 1px solid var(--line); }
td.num, th.num { text-align: right; white-space: nowrap; }
td:last-child { white-space: nowrap; }
tr.missing td { background: var(--bad-soft); }
tr.missing td:first-child { border-radius: 6px 0 0 6px; }
tr.missing td:last-child { border-radius: 0 6px 6px 0; color: var(--bad); font-weight: 600; }
td.yes { color: var(--ok); font-weight: 600; }
td.bank { color: var(--muted); font-size: 12px; }
#daily { color: var(--muted); font-size: 12px; white-space: nowrap; }
td .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.no-invoice { margin-top: 12px; }
td .btn.small { margin-left: 6px; font-weight: 400; color: var(--text); }
td .icon.undo { width: 22px; height: 22px; font-size: 14px; color: var(--muted); }
.no-invoice summary { cursor: pointer; padding: 4px 0; }
table.income tr.fold td { padding-top: 14px; }
table.income tr.fold .linkish { font-weight: 600; }
.no-invoice table { margin-top: 6px; }

/* --- supplier transfers --- */
.transfer { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.transfer + .transfer, .transfer + .order, .order + .order { margin-top: 10px; }
.transfer-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.transfer-sum { font-size: 18px; font-weight: 680; font-variant-numeric: tabular-nums; }
.transfer table td { padding: 4px 8px; }
.transfer-to { margin: 8px 0 0; font-size: 12.5px; }
.transfer .actions { margin-top: 10px; }
.order { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; background: var(--warn-soft); }
.order.paid { background: var(--hover); }
.order-mark { font-weight: 700; color: var(--warn); }
.order.paid .order-mark { color: var(--ok); }
.order-text { flex: 1; min-width: 0; }

/* --- upload --- */
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 22px; border: 2px dashed var(--line); border-radius: 10px;
  color: var(--muted); cursor: pointer; text-align: center;
}
.drop strong { color: var(--text); }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.row label { color: var(--muted); }

/* --- email --- */
.email dl { display: grid; grid-template-columns: 70px 1fr; gap: 4px 12px; margin: 0 0 10px; }
.email dt { color: var(--muted); }
.email dd { margin: 0; word-break: break-word; }
.email pre {
  margin: 0 0 10px; padding: 10px 12px; border-radius: 8px;
  background: var(--hover); font: inherit; white-space: pre-wrap; color: var(--muted);
  max-height: 240px; overflow: auto;
}
.attach { margin: 0; }
.attach.bad { color: var(--bad); font-weight: 600; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }

/* --- preview --- */
.preview {
  position: sticky; top: calc(var(--top) + 20px);
  height: calc(100vh - var(--top) - 40px);
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
}
.preview-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line); min-height: 44px;
}
#preview-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.keys { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }
.preview a { color: var(--accent); text-decoration: none; white-space: nowrap; }
.preview iframe { flex: 1; width: 100%; border: 0; background: var(--hover); }

/* --- job log --- */
.log {
  position: fixed; right: 20px; bottom: 20px; z-index: 20;
  width: min(640px, calc(100vw - 40px));
  background: #111318; color: #d7dae0; border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35); overflow: hidden;
}
.log-head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; font-weight: 600; }
.log-head span { flex: 1; }
.log-head .icon { color: #d7dae0; }
.log-head .icon:hover { background: #262a33; }
.log pre {
  margin: 0; padding: 0 14px 14px; max-height: 40vh; overflow: auto;
  font: 12px/1.5 ui-monospace, "SF Mono", Menlo, monospace; white-space: pre-wrap;
}
.spin {
  display: inline-block; width: 10px; height: 10px; margin-right: 8px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- dialog & toast --- */
dialog {
  border: 1px solid var(--line); border-radius: 14px; padding: 22px 24px;
  background: var(--card); color: var(--text); width: min(520px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(10, 12, 18, .45); }
dialog h3 { margin: 0 0 12px; }
dialog dl { display: grid; grid-template-columns: 90px 1fr; gap: 4px 12px; margin: 0; }
dialog dt { color: var(--muted); }
dialog dd { margin: 0; }
.callout { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); }
.callout.bad { background: var(--bad-soft); color: var(--bad); }
.callout.ok { background: var(--ok-soft); color: var(--ok); }

dialog.epay { width: min(620px, calc(100vw - 32px)); }
dialog .actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 16px; }
dialog .actions .muted { margin-right: auto; }
.epay-bills td { padding: 8px 6px; border-top: 1px solid var(--line); vertical-align: top; }
.epay-bills td.num { text-align: right; white-space: nowrap; }
.epay-bills td.ok { color: var(--ok); }
.epay-bills td.bad { color: var(--bad); }
.epay-code label { display: grid; grid-template-columns: 160px 1fr; align-items: center; gap: 12px; margin: 10px 0; }
.epay-code input {
  font: inherit; font-size: 18px; letter-spacing: 2px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.epay-msg { white-space: pre-line; }
dialog.remote { width: min(1060px, calc(100vw - 32px)); }
.remote-screen { position: relative; margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  line-height: 0; cursor: pointer; outline: none; }
.remote-screen:focus-visible, .remote-screen.typing { box-shadow: 0 0 0 2px var(--accent); }
.remote-screen img { width: 100%; height: auto; aspect-ratio: 1024 / 720; user-select: none; background: var(--line); }
.epay-screen { display: block; max-width: 100%; margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30;
  padding: 10px 16px; border-radius: 10px; background: var(--text); color: var(--card);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .25); max-width: calc(100vw - 32px);
}
.toast.bad { background: var(--bad); color: var(--on-accent); }
.toast a { color: inherit; font-weight: 600; }

/* --- ТРЗ (hr.html) --- */
.whoami { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.whoami select { color: var(--text); font-weight: 600; }
.account { color: var(--muted); font-size: 13px; text-decoration: none; white-space: nowrap; }
.account:hover { color: var(--text); text-decoration: underline; }
.req-form .kinds { margin-bottom: 12px; }
.seg label { position: relative; cursor: pointer; }
.seg label + label { border-left: 1px solid var(--line); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label span { display: block; padding: 6px 13px; font-size: 13px; }
.seg label:hover span { background: var(--hover); }
.seg input:checked + span { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px 14px; }
.fields > label:not(.check) { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.fields .wide { grid-column: 1 / -1; }
.fields input:not([type=checkbox]), .fields select, .fields textarea {
  font: inherit; font-weight: 400; color: var(--text); padding: 7px 9px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); min-width: 0;
}
.fields input[readonly] { color: var(--muted); }
.fields small { margin: 0; font-weight: 400; }
dialog .fields { margin-top: 4px; }
.req-form { position: relative; }
.req-texts { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.req-texts small { margin: 0; }
.req-texts > span { color: var(--muted); }
.date-field { cursor: pointer; }
.fields input.picking { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.fields input.bad { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
.picker {
  position: absolute; z-index: 20; width: min(300px, calc(100vw - 64px)); padding: 10px 12px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
}
.pd-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; font-weight: 650; }
.pd-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px 0; }
.pd-wd { padding: 4px 0; text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); }
.pd {
  position: relative; height: 36px; border: 0; border-radius: 8px; background: none; cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.pd:hover { background: var(--hover); }
.pd-wd.off, .pd.off { color: var(--bad); }  /* weekends and holidays, like Sundays */
.pd.holiday { font-weight: 700; }
.pd.today { box-shadow: inset 0 0 0 1px var(--accent); }
.pd.in, .pd.reach { background: var(--accent-soft); border-radius: 0; }
.pd.start, .pd.end { background: var(--accent); color: var(--on-accent); }
.pd.start { border-radius: 8px 0 0 8px; }
.pd.end { border-radius: 0 8px 8px 0; }
.pd.start.end { border-radius: 8px; }
.pd.busy::after {
  content: ""; position: absolute; left: 30%; right: 30%; bottom: 4px; height: 3px; border-radius: 2px;
  background: var(--warn);
}
.pd:disabled { opacity: .3; cursor: default; }
.pd-hint { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.pd-hol { list-style: none; margin: 8px 0 0; padding: 8px 0 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.pd-hol b { color: var(--bad); font-weight: 600; margin-right: 4px; }
.req-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.req {
  display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--line);
}
.req:first-child { border-top: 0; }
.req.rejected, .req.cancelled { opacity: .6; }
.req-main { flex: 1; min-width: 0; }
.req-meta { font-size: 12.5px; color: var(--muted); }
.small { font-size: 12px; }
.kind {
  flex: none; width: 116px; padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; text-align: center;
  background: var(--accent-soft); color: var(--accent);
}
.kind.unpaid { background: var(--hover); color: var(--muted); }
.kind.sick { background: var(--warn-soft); color: var(--warn); }
.legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; margin-left: 8px; }
.legend i.off { background: var(--hover); border: 1px solid var(--line); }
.cal { border-collapse: separate; border-spacing: 0; font-size: 12px; font-variant-numeric: tabular-nums; }
.cal th, .cal td { min-width: 26px; height: 30px; padding: 0; text-align: center; border-bottom: 1px solid var(--line); }
.cal thead th { position: sticky; top: 0; z-index: 1; background: var(--card); height: 38px; font-weight: 600; }
.cal thead th span { display: block; }
.cal thead th small { margin: 0; font-size: 10px; }
.cal .who {
  position: sticky; left: 0; z-index: 2; min-width: 150px; max-width: 190px; padding: 0 10px 0 0;
  text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--card); font-weight: 500;
}
.cal thead .who { z-index: 3; }
.cal tr.me .who { color: var(--accent); font-weight: 650; }
.cal .off { background: var(--hover); color: var(--muted); }
.cal thead th.today { color: var(--accent); }
.cal td.today { box-shadow: inset 2px 0 var(--accent), inset -2px 0 var(--accent); }
.cal thead th.today { box-shadow: inset 2px 2px var(--accent), inset -2px 0 var(--accent); }
.cal td.abs, .legend i.paid, .legend i.unpaid, .legend i.sick { background-clip: padding-box; }
.cal td.abs.paid, .legend i.paid { background: var(--accent); }
.cal td.abs.unpaid, .legend i.unpaid { background: #868e96; }
.cal td.abs.sick, .legend i.sick { background: #e8590c; }
.cal td.abs.off { opacity: .45; }
.cal td.abs.pending, .legend i.pending {
  background: repeating-linear-gradient(135deg, var(--accent) 0 3px, var(--accent-soft) 3px 7px);
}
.cal td.abs.sick.pending { background: repeating-linear-gradient(135deg, #e8590c 0 3px, var(--warn-soft) 3px 7px); }
.cal td.abs.unpaid.pending { background: repeating-linear-gradient(135deg, #868e96 0 3px, var(--hover) 3px 7px); }
.cal .total { min-width: 40px; padding-left: 8px; font-weight: 600; }
.cal-holidays { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 13px; color: var(--muted); }
.cal-holidays b { color: var(--text); font-weight: 600; }
.hr-table { width: 100%; border-collapse: collapse; }
.hr-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.hr-table td { padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.hr-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.hr-table .neg { color: var(--bad); font-weight: 600; }
.hr-table .pill { margin-left: 8px; }
.hr-table tr.inactive td { color: var(--muted); }
.mail-head { display: grid; grid-template-columns: 70px 1fr; gap: 4px 12px; margin: 12px 0; }
.mail-head dt { color: var(--muted); }
.mail-head dd { margin: 0; }
.mail-body {
  margin: 0; padding: 14px 16px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line);
  font: 13px/1.55 ui-monospace, "SF Mono", Menlo, monospace; white-space: pre-wrap; max-height: 60vh; overflow: auto;
}
dialog textarea { width: 100%; }

@media (max-width: 1000px) {
  .work.with-preview { grid-template-columns: 1fr; }
  .preview { position: static; height: 70vh; }
}
@media (max-width: 640px) {
  .top { flex-wrap: wrap; height: auto; padding: 8px 16px; }
  main { padding: 12px 16px; }
  .dash { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 11px 12px 10px; }
  .t-label { font-size: 11px; }
  .t-big { font-size: 21px; }
  .t-big.long { font-size: 14px; line-height: 1.9; }
  .tile.active::after { display: none; }
  .ti-go { display: none; }
  .file { grid-template-columns: minmax(0, 1fr) auto auto; }
  .file select, .file .fmeta { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
  .pnl-chart { height: 340px; }
  #pnl-q { width: 100%; }
  .tabs a { padding: 6px 8px; }
  .whoami { width: 100%; justify-content: flex-end; }
  .req { flex-wrap: wrap; }
  .req-main { flex-basis: calc(100% - 130px); }
  .cal .who { min-width: 96px; max-width: 110px; }
}
