/* Внутрішній стиль: оксамит ювелірного лотка + камені, що кодують результат.
   Золото — зараховано, гранат — не зараховано / помилка, аметист — відмова після консультації,
   сапфір — продаж у переписці, смарагд — оплата є, але не врахована, срібло — інше. */
:root {
  --velvet: #1e3a32;
  --velvet-2: #24453b;
  --velvet-deep: #142821;
  --on-velvet: #e7eee9;
  --on-velvet-muted: #9fb5a9;
  --paper: #f2f4f0;
  --surface: #ffffff;
  --surface-2: #f7f8f6;
  --ink: #18221e;
  --muted: #5f6a65;
  --line: #e1e5df;
  --line-strong: #c9d0c7;

  --gold: #8f6a12; --gold-f: #c9a23f; --gold-bg: #f7eed6;
  --garnet: #9e2b3c; --garnet-f: #c4566a; --garnet-bg: #fae8eb;
  --amethyst: #66449a; --amethyst-f: #8f70c2; --amethyst-bg: #f0e9fa;
  --sapphire: #22558a; --sapphire-f: #4a82bd; --sapphire-bg: #e4edf8;
  --emerald: #1b6e4c; --emerald-f: #38a374; --emerald-bg: #e1f3ea;
  --silver: #6a756f; --silver-f: #b5bfb9; --silver-bg: #edf0ec;

  --serif: "Piazzolla", Georgia, serif;
  --sans: "Onest", -apple-system, "Segoe UI", sans-serif;
  --r-s: 8px;
  --r-m: 12px;
  --r-l: 18px;
  --shadow-1: 0 1px 2px rgba(20, 40, 30, .06), 0 1px 1px rgba(20, 40, 30, .04);
  --shadow-2: 0 10px 30px -10px rgba(20, 40, 30, .28), 0 2px 6px rgba(20, 40, 30, .08);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.4, .5, 1);
  --sidebar: 248px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--sapphire); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold-f); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--gold-bg); }

/* Тонкі власні смуги прокрутки */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ── Знак: обручка з камінцем ── */
.brand-mark {
  position: relative; display: inline-block; flex: none;
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(145deg, var(--velvet-2), var(--velvet-deep));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
}
.brand-mark::before {
  content: ""; position: absolute; left: 8px; top: 11px; width: 18px; height: 16px;
  border: 3px solid var(--gold-f); border-radius: 50%;
}
.brand-mark::after {
  content: ""; position: absolute; left: 13px; top: 5px; width: 8px; height: 8px;
  background: #8fd3c0; transform: rotate(45deg); border-radius: 1px;
}

/* ── Каркас ── */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; gap: 28px;
  padding: 22px 14px 18px;
  background: radial-gradient(140% 90% at 0% 0%, var(--velvet-2) 0%, var(--velvet) 50%, var(--velvet-deep) 100%);
  color: var(--on-velvet);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px; }
.brand b { display: block; font: 600 17px/1.2 var(--serif); }
.brand small { color: var(--on-velvet-muted); font-size: 12.5px; }

.nav { position: relative; display: grid; gap: 4px; }
.nav-item {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-m);
  color: var(--on-velvet-muted); font-weight: 500;
  transition: color .2s;
}
.nav-item:hover { text-decoration: none; color: var(--on-velvet); }
.nav-item svg { width: 21px; height: 21px; flex: none; }
.nav-item.active { color: #fff; }
.nav-indicator {
  position: absolute; left: 0; right: 0; top: 0; height: 42px; border-radius: var(--r-m);
  background: rgba(255, 255, 255, .09); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
  transition: transform .35s var(--ease), height .35s var(--ease);
}
.nav-indicator::before {
  content: ""; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--gold-f);
}

.sidebar-foot { margin-top: auto; display: grid; gap: 8px; padding: 0 10px; font-size: 12.5px; color: var(--on-velvet-muted); }
.conn { display: flex; align-items: center; gap: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--gold-f); flex: none; }
.conn.live::before { background: #5fd39b; box-shadow: 0 0 0 0 rgba(95, 211, 155, .6); animation: pulse 2.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(95, 211, 155, .55); } 70% { box-shadow: 0 0 0 7px rgba(95, 211, 155, 0); } 100% { box-shadow: 0 0 0 0 rgba(95, 211, 155, 0); } }
.link-btn { background: none; border: 0; padding: 0; color: var(--on-velvet-muted); text-align: left; }
.link-btn:hover { color: #fff; }

.main { position: relative; min-width: 0; padding: 0 36px 64px; }
.progress { position: fixed; z-index: 50; top: 0; left: var(--sidebar); right: 0; height: 3px; overflow: hidden; opacity: 0; transition: opacity .3s; }
.progress.active { opacity: 1; }
.progress::before {
  content: ""; position: absolute; inset: 0; width: 40%;
  background: linear-gradient(90deg, transparent, var(--gold-f), transparent);
  animation: slide 1.1s var(--ease) infinite;
}
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin: 0 -36px 26px; padding: 20px 36px 16px;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.view-title { margin: 0; font: 600 27px/1.2 var(--serif); letter-spacing: -.01em; }
.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Перехід між розділами */
.view { max-width: 1120px; }
.view.enter { animation: viewIn .45s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.view-title.enter { animation: titleIn .4s var(--ease) both; }
@keyframes titleIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }

/* ── Кнопки ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  height: 42px; padding: 0 20px; border-radius: var(--r-m); border: 0;
  font-weight: 600; white-space: nowrap;
  transition: transform .15s var(--ease), background-color .2s, box-shadow .2s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .7; cursor: progress; }
.btn-primary { background: var(--velvet); color: #fff; box-shadow: 0 6px 16px -8px rgba(30, 58, 50, .7); }
.btn-primary:hover { background: var(--velvet-2); }
.btn-ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn-ghost:hover { background: var(--surface); }
.btn-soft { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line); }
.btn-soft:hover { box-shadow: var(--shadow-2), inset 0 0 0 1px var(--line); }
.btn-small { height: 34px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn svg { width: 18px; height: 18px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

/* ── Власні елементи керування ── */
.select, .month-picker { position: relative; }
.select-trigger, .month-picker {
  height: 42px; border-radius: var(--r-m); background: var(--surface);
  box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line);
  transition: box-shadow .2s;
}
.select-trigger:hover, .month-picker:hover { box-shadow: var(--shadow-2), inset 0 0 0 1px var(--line); }
.select-trigger { display: flex; align-items: center; gap: 10px; min-width: 230px; padding: 0 10px 0 6px; border: 0; text-align: left; }
.select-value { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.select-value .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.placeholder { color: var(--muted); padding-left: 6px; }
.chev { display: grid; color: var(--muted); transition: transform .25s var(--ease); }
.chev svg { width: 18px; height: 18px; }
[aria-expanded="true"] .chev { transform: rotate(180deg); }

.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 30px; height: 30px; border-radius: 50%;
  font: 600 11.5px var(--sans); letter-spacing: .02em; color: #fff;
  background: var(--velvet);
}
.avatar[data-tone="0"] { background: linear-gradient(140deg, #d1ae4e, #9c7616); }
.avatar[data-tone="1"] { background: linear-gradient(140deg, #5d93c9, #22558a); }
.avatar[data-tone="2"] { background: linear-gradient(140deg, #9c80cc, #5c3d8f); }
.avatar[data-tone="3"] { background: linear-gradient(140deg, #4fb787, #1b6e4c); }
.avatar[data-tone="4"] { background: linear-gradient(140deg, #d0697c, #8f2537); }

.popover {
  position: absolute; z-index: 40; top: calc(100% + 8px); right: 0;
  min-width: 100%; padding: 6px; border-radius: var(--r-m);
  background: var(--surface); box-shadow: var(--shadow-2), 0 0 0 1px var(--line);
  opacity: 0; transform: translateY(-6px) scale(.97); transform-origin: top right;
  pointer-events: none; visibility: hidden;
  transition: opacity .18s var(--ease), transform .25s var(--spring), visibility 0s .25s;
}
.popover.open { opacity: 1; transform: none; pointer-events: auto; visibility: visible; transition: opacity .18s var(--ease), transform .25s var(--spring), visibility 0s; }
.popover:focus { outline: none; }
.select-panel { max-height: 360px; overflow: auto; min-width: 270px; }
.option { display: flex; align-items: center; gap: 10px; padding: 7px 10px 7px 6px; border-radius: 9px; cursor: pointer; }
.option.active { background: var(--surface-2); }
.option .label { flex: 1; }
.option .meta { color: var(--muted); font-size: 12.5px; }
.option .tick { width: 18px; height: 18px; color: var(--velvet); opacity: 0; transform: scale(.6); transition: .2s var(--spring); }
.option.selected .tick { opacity: 1; transform: none; }

.month-picker { display: flex; align-items: center; padding: 0 4px; }
.mp-step { display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; color: var(--muted); }
.mp-step:hover { background: var(--surface-2); color: var(--ink); }
.mp-step svg, .mp-year svg { width: 18px; height: 18px; }
.mp-label { min-width: 138px; height: 34px; border: 0; border-radius: 8px; background: none; font-weight: 600; overflow: hidden; }
.mp-label:hover { background: var(--surface-2); }
.mp-text { display: inline-block; animation: mpIn .3s var(--ease); }
.mp-label[data-dir="prev"] .mp-text { animation-name: mpInPrev; }
@keyframes mpIn { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }
@keyframes mpInPrev { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
.mp-panel { width: 260px; padding: 12px; }
.mp-year { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.mp-year b { font: 600 16px var(--serif); }
.mp-year button { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 8px; background: none; color: var(--muted); }
.mp-year button:hover { background: var(--surface-2); color: var(--ink); }
.mp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.mp-grid button { height: 36px; border: 0; border-radius: 8px; background: none; font-weight: 500; }
.mp-grid button:hover { background: var(--surface-2); }
.mp-grid button.selected { background: var(--velvet); color: #fff; }

.segmented {
  position: relative; display: inline-flex; padding: 4px; border-radius: 11px;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
}
.segmented button { position: relative; z-index: 1; height: 34px; padding: 0 14px; border: 0; background: none; border-radius: 8px; color: var(--muted); font-weight: 500; font-size: 14px; transition: color .2s; }
.segmented button[aria-checked="true"] { color: var(--ink); }
.seg-thumb { position: absolute; top: 4px; left: 4px; height: 34px; border-radius: 8px; background: var(--surface); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); transition: transform .35s var(--spring), width .35s var(--spring); }

.stepper { display: inline-flex; align-items: center; height: 42px; border-radius: var(--r-m); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.stepper button { width: 38px; height: 100%; border: 0; background: none; font-size: 18px; color: var(--muted); border-radius: var(--r-m); }
.stepper button:hover { color: var(--ink); background: var(--surface-2); }
.stepper input { width: 64px; height: 100%; border: 0; text-align: center; font: 600 16px var(--sans); background: none; color: var(--ink); }
.stepper input:focus { outline: none; }
.stepper:focus-within { box-shadow: inset 0 0 0 2px var(--gold-f); }

/* ── Картки ── */
.card { background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); padding: 22px 24px; }
.stack > * + * { margin-top: 18px; }
#checkResults:not(:empty) { margin-top: 18px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; font: 600 19px/1.3 var(--serif); }
.card-head .count { font: 700 19px var(--serif); color: var(--c, var(--muted)); }
.card-head .spacer { flex: 1; }
.card-note { margin: -6px 0 14px; color: var(--muted); font-size: 13.5px; max-width: 78ch; }
.chip { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: 13px; font-weight: 500; }
.lead { color: var(--muted); max-width: 70ch; margin: 0; }

/* Поява результатів: картки по черзі, один раз на результат */
.reveal > * { animation: cardIn .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes cardIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ── Вставка звіту ── */
.paste { position: relative; }
.paste textarea {
  width: 100%; min-height: 168px; resize: vertical;
  padding: 14px 44px 14px 16px; border-radius: var(--r-m); border: 0;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
  font: 14px/1.6 var(--sans); color: var(--ink);
  transition: box-shadow .2s, background-color .2s;
}
.paste textarea:focus { outline: none; background: var(--surface); box-shadow: inset 0 0 0 2px var(--gold-f); }
.paste textarea::placeholder { color: #8b958f; }
.paste-clear { position: absolute; top: 10px; right: 10px; }
.intake-options { display: grid; gap: 12px; margin-top: 16px; }
.option-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.option-label { min-width: 230px; color: var(--muted); font-size: 14px; }
.intake-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ── Підсумок: великі числа ── */
.summary { display: grid; grid-template-columns: repeat(3, 1fr) auto; gap: 0; align-items: stretch; padding: 0; overflow: hidden; }
.stat { padding: 22px 24px; border-right: 1px solid var(--line); }
.stat .label { display: block; color: var(--muted); font-size: 13.5px; margin-bottom: 6px; }
.stat .value { font: 700 44px/1 var(--serif); letter-spacing: -.02em; color: var(--c, var(--ink)); }
.stat .hint { display: block; margin-top: 8px; color: var(--muted); font-size: 12.5px; }
.summary-actions { display: flex; flex-direction: column; justify-content: center; gap: 8px; padding: 18px 22px; }

/* ── Списки розбіжностей ── */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li {
  display: grid; grid-template-columns: minmax(170px, 1fr) minmax(220px, 2fr) 76px;
  gap: 4px 18px; align-items: center;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.rows li:first-child { border-top: 0; }
.rows .who b { display: block; font-weight: 600; letter-spacing: .01em; }
.rows .who span { color: var(--muted); font-size: 13px; }
.rows .why { color: var(--c, var(--ink)); }
.rows .why small { display: block; color: var(--muted); }
.rows .open { justify-self: end; color: var(--muted); font-size: 13px; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.rows .open:hover { color: var(--sapphire); text-decoration: none; }
.rows .open svg { width: 15px; height: 15px; }
.sub-title { margin: 18px 0 2px; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.empty { color: var(--muted); margin: 0; padding: 6px 0; }
.searching { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 8px 0; }

/* Камені: колір картки / рядка за змістом */
.t-gold { --c: var(--gold); --f: var(--gold-f); --b: var(--gold-bg); }
.t-garnet { --c: var(--garnet); --f: var(--garnet-f); --b: var(--garnet-bg); }
.t-amethyst { --c: var(--amethyst); --f: var(--amethyst-f); --b: var(--amethyst-bg); }
.t-sapphire { --c: var(--sapphire); --f: var(--sapphire-f); --b: var(--sapphire-bg); }
.t-emerald { --c: var(--emerald); --f: var(--emerald-f); --b: var(--emerald-bg); }
.t-silver { --c: var(--silver); --f: var(--silver-f); --b: var(--silver-bg); }
.card[class*="t-"] { box-shadow: var(--shadow-1), 0 0 0 1px var(--line), inset 3px 0 0 var(--f); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--f); flex: none; }
.badge { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 99px; background: var(--b); color: var(--c); font-size: 12.5px; font-weight: 600; white-space: nowrap; }

/* Розгортання */
.collapsible .collapse-head { display: flex; align-items: center; gap: 12px; width: 100%; padding: 0; border: 0; background: none; text-align: left; }
.collapsible .collapse-head h2 { margin: 0; font: 600 19px/1.3 var(--serif); }
.collapsible .collapse-head .chev { margin-left: auto; }
.collapse-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .4s var(--ease); }
.collapse-body > div { overflow: hidden; }
.collapsible.open .collapse-body { grid-template-rows: 1fr; }
.collapsible.open .collapse-body > div { padding-top: 14px; }

/* Повна таблиця */
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.filter { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 99px; border: 0; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); font-size: 13.5px; transition: background-color .2s, box-shadow .2s; }
.filter b { font-weight: 600; }
.filter[aria-pressed="true"] { background: var(--velvet); color: #fff; box-shadow: none; }
.table-wrap { overflow-x: auto; margin: 0 -24px -22px; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 10px 12px; background: var(--surface-2); white-space: nowrap; }
td { padding: 11px 12px; border-top: 1px solid var(--line); vertical-align: top; }
td:first-child, th:first-child { padding-left: 24px; }
td:first-child { color: var(--muted); }
.small { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.mark { font-weight: 700; margin-right: 4px; }
.mark.ok { color: var(--gold); }
.mark.bad { color: var(--garnet); }
.nowrap { white-space: nowrap; }
.dim { color: var(--muted); }

/* ── Перевірка відділу ── */
.dept-head { display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 22px; }
.team { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.member {
  position: relative; display: grid; gap: 10px; padding: 18px; border: 0; text-align: left;
  border-radius: var(--r-l); background: var(--surface); box-shadow: var(--shadow-1), 0 0 0 1px var(--line);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.member:hover { transform: translateY(-2px); box-shadow: var(--shadow-2), 0 0 0 1px var(--line); }
.member[aria-pressed="true"] { box-shadow: var(--shadow-2), 0 0 0 2px var(--velvet); }
.member-top { display: flex; align-items: center; gap: 10px; }
.member-top b { font-weight: 600; line-height: 1.25; }
.member .big { font: 700 40px/1 var(--serif); letter-spacing: -.02em; color: var(--gold); }
.member .big small { font: 500 13px var(--sans); color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.member-stats { display: grid; gap: 3px; font-size: 13px; color: var(--muted); }
.member-stats span { display: flex; justify-content: space-between; gap: 8px; }
.member-stats b { color: var(--ink); font-weight: 600; }
.member .flag { justify-self: start; }
.issue-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.skeleton { border-radius: var(--r-l); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 40%, var(--surface) 80%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; box-shadow: 0 0 0 1px var(--line); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sk-member { height: 186px; }
.sk-card { height: 260px; margin-top: 18px; }
.steps-loading { display: grid; gap: 6px; margin-top: 14px; color: var(--muted); font-size: 14px; }

/* ── Як рахуємо ── */
.rules-steps { list-style: none; counter-reset: s; padding: 0; margin: 0; display: grid; gap: 12px; }
.rules-steps > li { counter-increment: s; display: grid; grid-template-columns: 44px 1fr; gap: 14px; padding: 18px 20px; border-radius: var(--r-l); background: var(--surface); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }
.rules-steps > li::before { content: counter(s); display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--velvet); color: #fff; font: 700 18px var(--serif); }
.rules-steps h3 { margin: 6px 0 4px; font-size: 16px; }
.rules-steps p { margin: 0 0 6px; color: var(--muted); max-width: 72ch; }
.pipes { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin-top: 8px; }
.pipe { padding: 12px 14px; border-radius: var(--r-m); background: var(--surface-2); box-shadow: inset 3px 0 0 var(--f); font-size: 13.5px; }
.pipe b { display: block; }
.field-name { color: var(--ink); font-weight: 500; }
.rules-h { font: 600 21px var(--serif); margin: 30px 0 12px; }
.legend-list { display: grid; gap: 10px; }
.legend-list div { display: grid; grid-template-columns: 220px 1fr; gap: 12px; align-items: start; }
.legend-list p { margin: 0; color: var(--muted); }

/* ── Вхід ── */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(120% 90% at 20% 0%, var(--velvet-2), var(--velvet) 50%, var(--velvet-deep)); }
.login-card { width: min(380px, 100%); padding: 32px 30px 28px; border-radius: 22px; background: var(--surface); box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .45); animation: cardIn .6s var(--ease) both; }
.login-card h1 { margin: 14px 0 2px; font: 600 26px var(--serif); }
.login-card > p { margin: 0 0 22px; color: var(--muted); }
.login-card.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
.field { display: grid; gap: 6px; margin-bottom: 14px; font-size: 14px; font-weight: 500; }
.text-input { width: 100%; height: 46px; padding: 0 14px; border: 0; border-radius: var(--r-m); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); font: 16px var(--sans); color: var(--ink); }
.text-input:focus { outline: none; background: var(--surface); box-shadow: inset 0 0 0 2px var(--gold-f); }
.who-am-i { display: flex; align-items: center; gap: 8px; color: var(--on-velvet); font-weight: 500; }
.who-am-i::before { content: ""; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--on-velvet-muted); }
.password { position: relative; display: block; }
.password input { width: 100%; height: 46px; padding: 0 46px 0 14px; border: 0; border-radius: var(--r-m); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); font: 16px var(--sans); color: var(--ink); }
.password input:focus { outline: none; background: var(--surface); box-shadow: inset 0 0 0 2px var(--gold-f); }
.password .icon-btn { position: absolute; right: 7px; top: 7px; }
.login-error { margin: -4px 0 12px; color: var(--garnet); font-size: 14px; }

/* ── Сповіщення ── */
.toasts { position: fixed; z-index: 60; right: 20px; bottom: 20px; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 40px)); }
.toast { padding: 12px 16px; border-radius: var(--r-m); background: var(--ink); color: #fff; box-shadow: var(--shadow-2); font-size: 14px; animation: toastIn .35s var(--spring) both; }
.toast-error { background: var(--garnet); }
.toast-success { background: var(--emerald); }
.toast.leaving { animation: toastOut .3s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }

/* ── Мобільні: бічна панель стає нижньою ── */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 30; top: auto; bottom: 0; left: 0; right: 0; height: auto;
    flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .brand, .sidebar-foot { display: none; }
  .nav { grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; }
  .nav-item { flex-direction: column; gap: 3px; padding: 7px 4px; font-size: 11.5px; text-align: center; }
  .nav-indicator { display: none; }
  .nav-item.active { background: rgba(255, 255, 255, .1); }
  .main { padding: 0 16px 96px; }
  .topbar { margin: 0 -16px 18px; padding: 14px 16px 12px; }
  .view-title { font-size: 22px; }
  .progress { left: 0; }
  .controls, .control-manager, .select-trigger { width: 100%; }
  .month-picker { width: 100%; justify-content: space-between; }
  .card { padding: 18px 16px; }
  .summary { grid-template-columns: 1fr 1fr; }
  .stat { border-bottom: 1px solid var(--line); }
  .stat .value { font-size: 34px; }
  .summary-actions { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
  .rows li { grid-template-columns: 1fr; }
  .rows .open { justify-self: start; }
  .option-label { min-width: 0; width: 100%; }
  .table-wrap { margin: 0 -16px -18px; }
  td:first-child, th:first-child { padding-left: 16px; }
  .legend-list div { grid-template-columns: 1fr; }
}

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