/* ============================================================
   МВ-Сервис — Кабинеты (админка УК + ЛК арендатора)
   ============================================================ */

body.app { background: var(--paper-2); }

/* ============================================================
   Тёмная тема кабинетов ([data-theme="dark"])
   ============================================================ */
[data-theme="dark"] {
  --ink: #e9efeb;
  --ink-2: #b6c2bb;
  --muted: #86938c;
  --faint: #64716a;
  --paper: #0e1613;
  --paper-2: #131d18;
  --card: #17221d;
  --line: #24312b;
  --line-2: #2f3d36;
  --emerald-50: #16261e;
  --emerald-100: #1e3529;
  --sh-sm: 0 1px 2px rgba(0,0,0,.3);
  --sh-md: 0 4px 14px rgba(0,0,0,.35), 0 12px 30px rgba(0,0,0,.28);
  --sh-lg: 0 10px 30px rgba(0,0,0,.4), 0 30px 70px rgba(0,0,0,.45);
}
[data-theme="dark"] body.app { background: var(--paper); }
[data-theme="dark"] .topbar { background: rgba(14,22,19,.8); }
[data-theme="dark"] .icon-btn { background: var(--card); }
[data-theme="dark"] .kpi.warn .ic { background: #2a2415; color: #e0b968; }
[data-theme="dark"] .kpi.danger .ic { background: #2c1c1a; color: #e88a7d; }
[data-theme="dark"] .kpi.info .ic { background: #16232e; color: #6fb0dd; }
[data-theme="dark"] .list-item .ic { background: var(--paper-2); }
[data-theme="dark"] .tick { background: var(--paper-2); }
[data-theme="dark"] .kan-col { background: #0f1814; }
[data-theme="dark"] .kan-col h4 .c { background: var(--card); }
[data-theme="dark"] .badge-ok    { background: #14301f; color: #63c795; }
[data-theme="dark"] .badge-warn  { background: #2c2413; color: #dcae5b; }
[data-theme="dark"] .badge-danger{ background: #2f1b18; color: #e58a7c; }
[data-theme="dark"] .badge-info  { background: #15242f; color: #6fb0dd; }
[data-theme="dark"] .badge-muted { background: var(--paper-2); color: var(--muted); }
[data-theme="dark"] .chip { background: var(--emerald-50); color: var(--emerald-300); }
[data-theme="dark"] .tick .cat { color: var(--emerald-300); }
[data-theme="dark"] .eyebrow { color: var(--emerald-300); }
[data-theme="dark"] .dl dd { color: var(--ink); }
[data-theme="dark"] .btn-light { background: var(--card); color: var(--ink); }
[data-theme="dark"] .btn-ghost { border-color: var(--line-2); color: var(--ink); }
[data-theme="dark"] .btn-dark { background: var(--emerald-600); }
/* квитанция всегда светлая (для печати) */
#printArea { --ink: #10201a; --ink-2: #35443d; --muted: #6a7a72; --faint: #93a29a;
  --paper: #f7f8f5; --paper-2: #eef1ea; --card: #fff; --line: #e4e8e1; --line-2: #d3dace;
  --emerald-700: #0d4a34; background: #fff; color: #10201a; }

/* ---------- Экран входа ---------- */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr;
}
.auth-visual {
  position: relative; overflow: hidden; background: var(--emerald-900);
  display: flex; flex-direction: column; justify-content: space-between; padding: 48px; color: #fff;
}
.auth-visual img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .28; }
.auth-visual::after { content:""; position:absolute; inset:0; background: linear-gradient(160deg, rgba(6,37,27,.7), rgba(10,53,39,.9)); }
.auth-visual > * { position: relative; z-index: 2; }
.auth-visual .brand-name { color: #fff; }
.auth-quote h2 { font-family: var(--font-display); font-weight: 700; font-size: clamp(26px, 3vw, 40px); line-height: 1.1; }
.auth-quote p { margin-top: 18px; color: rgba(255,255,255,.75); max-width: 420px; }
.auth-points { display: flex; gap: 26px; margin-top: 30px; flex-wrap: wrap; }
.auth-points .num { font-family: var(--font-display); font-size: 30px; font-weight: 700; }
.auth-points .lbl { font-size: 13px; color: rgba(255,255,255,.65); }

.auth-form-wrap { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card > .brand { margin-bottom: 30px; }
.auth-card h1 { font-family: var(--font-display); font-weight: 700; font-size: 32px; }
.auth-card .sub { color: var(--muted); margin-top: 8px; margin-bottom: 28px; }
.role-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; background: var(--paper-2); padding: 6px; border-radius: var(--r-md); margin-bottom: 22px; }
.role-switch button { padding: 12px; border-radius: 11px; font-weight: 700; font-size: 14px; color: var(--muted); transition: .25s var(--ease); }
.role-switch button.active { background: #fff; color: var(--emerald-700); box-shadow: var(--sh-sm); }
.auth-hint { margin-top: 16px; font-size: 13px; color: var(--muted); background: var(--emerald-50); border: 1px solid var(--emerald-100); border-radius: var(--r-sm); padding: 12px 14px; }
.auth-hint b { color: var(--emerald-700); }
.auth-error { background: #fbe7e4; color: #b23120; border: 1px solid #f4cec8; border-radius: var(--r-sm); padding: 11px 14px; font-size: 13.5px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; gap: 9px; }
.auth-error::before { content: "!"; width: 20px; height: 20px; border-radius: 50%; background: #b23120; color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 800; flex: none; }
.auth-foot { margin-top: 22px; font-size: 13.5px; color: var(--muted); text-align: center; }
.auth-foot a { color: var(--emerald-700); font-weight: 700; }

/* — Выбор роли — */
.role-cards { display: grid; gap: 12px; margin-top: 10px; }
.role-card { display: flex; align-items: center; gap: 15px; width: 100%; text-align: left; padding: 18px; border: 1.5px solid var(--line-2); border-radius: var(--r-md); background: var(--card); transition: transform .25s var(--ease), border-color .25s, box-shadow .25s; }
.role-card:hover { border-color: var(--emerald-500); box-shadow: var(--sh-md); transform: translateY(-2px); }
.role-card .rc-ic { width: 50px; height: 50px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.role-card .rc-ic.tenant { background: var(--emerald-50); color: var(--emerald-600); }
.role-card .rc-ic.admin { background: #eaeef0; color: #38504a; }
.role-card .rc-ic svg { width: 24px; height: 24px; }
.role-card .rc-txt { flex: 1; min-width: 0; }
.role-card .rc-txt b { display: block; font-size: 15.5px; font-weight: 700; color: var(--ink); }
.role-card .rc-txt small { display: block; font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.role-card .rc-arrow { color: var(--faint); flex: none; transition: transform .25s var(--ease), color .25s; }
.role-card:hover .rc-arrow { color: var(--emerald-600); transform: translateX(4px); }
.role-card .rc-arrow svg { width: 20px; height: 20px; }
.auth-back { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 13.5px; color: var(--muted); margin-bottom: 18px; }
.auth-back:hover { color: var(--emerald-700); }
.auth-back svg { width: 16px; height: 16px; }

/* — Сегмент-табы (Service Desk) — */
.seg-tabs { display: inline-flex; gap: 4px; background: var(--paper-2); padding: 4px; border-radius: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.seg { padding: 8px 14px; border-radius: 9px; font-weight: 700; font-size: 13px; color: var(--muted); transition: .2s var(--ease); }
.seg.active { background: var(--card); color: var(--emerald-700); box-shadow: var(--sh-sm); }
.seg:hover:not(.active) { color: var(--ink-2); }

/* ---------- Каркас приложения ---------- */
.app-shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--emerald-900); color: rgba(255,255,255,.72); padding: 22px 16px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 6px 8px 22px; }
.sidebar .brand-name { color: #fff; font-size: 19px; }
.sidebar .brand-sub { color: var(--emerald-300); }
.side-role { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--emerald-300); padding: 0 10px; margin: 6px 0 10px; font-weight: 700; }
.nav-item {
  display: flex; align-items: center; gap: 13px; padding: 11px 12px; border-radius: 12px;
  font-weight: 600; font-size: 14.5px; color: rgba(255,255,255,.74); cursor: pointer; transition: .2s; margin-bottom: 3px;
  width: 100%; text-align: left;
}
.nav-item svg { width: 19px; height: 19px; flex: none; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--emerald-500); color: #fff; box-shadow: var(--sh-emerald); }
.nav-item .count { margin-left: auto; background: rgba(255,255,255,.16); color: #fff; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 99px; }
.nav-item.active .count { background: rgba(255,255,255,.25); }
.side-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.1); }
.side-user { display: flex; align-items: center; gap: 11px; padding: 8px 8px; }
.side-user .av { width: 38px; height: 38px; border-radius: 50%; background: var(--emerald-500); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 15px; flex: none; }
.side-user .nm { color: #fff; font-size: 14px; font-weight: 700; line-height: 1.2; }
.side-user .rl { font-size: 12px; color: var(--emerald-300); }
.side-logout { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 11px; font-size: 14px; font-weight: 600; color: rgba(255,255,255,.6); width: 100%; margin-top: 6px; }
.side-logout:hover { background: rgba(255,255,255,.07); color: #fff; }
.side-logout svg { width: 18px; height: 18px; }

/* ---------- Основная область ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40; background: rgba(247,248,245,.85); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line); padding: 15px 28px; display: flex; align-items: center; gap: 16px;
}
.topbar h1 { font-family: var(--font-display); font-weight: 700; font-size: 24px; }
.topbar .crumb { font-size: 13px; color: var(--muted); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.icon-btn { width: 42px; height: 42px; border-radius: 12px; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; color: var(--ink-2); transition: .2s; position: relative; }
.icon-btn:hover { border-color: var(--emerald-400); color: var(--emerald-700); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn .dot { position: absolute; top: 3px; right: 3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--danger); border: 2px solid var(--paper); color: #fff; font-size: 10px; font-weight: 700; line-height: 13px; text-align: center; box-sizing: border-box; }
.notif-item .ic { flex: none; }
.notif-item .ic.lvl-danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.notif-item .ic.lvl-warn { background: color-mix(in srgb, #d98a1a 16%, transparent); color: #b9791b; }
.notif-item .ic.lvl-info { background: color-mix(in srgb, var(--emerald-500) 15%, transparent); color: var(--emerald-700); }
.notif-item { align-items: center; transition: background .14s; }
.notif-item:hover { background: color-mix(in srgb, var(--emerald-500) 8%, transparent); }
.notif-go { margin-left: auto; color: var(--muted); transform: rotate(90deg); opacity: .5; }
.notif-item:hover .notif-go { opacity: 1; color: var(--emerald-600); }
.menu-toggle { display: none; }

/* ---- Интеграции: переключатели, индикаторы, события ---- */
.switch { position: relative; display: inline-flex; align-items: center; flex: none; width: 42px; height: 24px; cursor: pointer; margin-left: auto; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch > span { position: absolute; inset: 0; background: var(--line, #d8ded9); border-radius: 999px; transition: background .18s; }
.switch > span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s; }
.switch input:checked + span { background: var(--emerald-500); }
.switch input:checked + span::after { transform: translateX(18px); }
.conn-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 8px; vertical-align: middle; }
.conn-dot.on { background: var(--emerald-500); box-shadow: 0 0 0 3px color-mix(in srgb, var(--emerald-500) 22%, transparent); }
.conn-dot.off { background: #c4ccc6; }
.card-head .switch { margin-left: auto; }
.ev-row { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line, #eef1ef); font-size: 14px; font-weight: 500; }
.ev-row:last-of-type { border-bottom: none; }
.banner-info { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-md, 12px); background: color-mix(in srgb, var(--emerald-500) 8%, var(--paper)); border: 1px solid color-mix(in srgb, var(--emerald-500) 22%, transparent); font-size: 14px; line-height: 1.5; }
.banner-info svg { flex: none; color: var(--emerald-600); margin-top: 1px; }

/* ---- Памятка «Как подключить» ---- */
.help-guide { font-size: 14px; line-height: 1.55; }
.help-sec { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--emerald-700); }
.help-sec svg { color: var(--emerald-600); }
.help-sec h4 { margin: 0; font-size: 15px; }
.help-step { display: flex; gap: 12px; padding: 8px 0; }
.help-num { flex: none; width: 26px; height: 26px; border-radius: 50%; background: color-mix(in srgb, var(--emerald-500) 14%, transparent); color: var(--emerald-700); font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.help-t { font-weight: 600; margin-bottom: 2px; }
.help-b { color: var(--muted); }
.help-b code, .help-note code { background: var(--paper-2, #f1f4f2); border: 1px solid var(--line, #e5e9e6); border-radius: 5px; padding: 1px 5px; font-size: 12.5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink); }
.help-note { display: flex; align-items: center; gap: 8px; margin-top: 16px; padding: 11px 13px; border-radius: var(--r-md, 12px); background: color-mix(in srgb, var(--emerald-500) 7%, var(--paper)); color: var(--muted); font-size: 13px; }
.help-note svg { flex: none; color: var(--emerald-600); }

.page { padding: 28px; max-width: 1280px; width: 100%; }
.page-view { animation: fadeUp .45s var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* stagger-появление элементов раздела */
@keyframes rowIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.page-view .kpi,
.page-view .tbl tbody tr,
.page-view .list-item,
.page-view .tick,
.page-view .quick > *,
.page-view .cert-card,
.page-view .cols > * { animation: rowIn .5s var(--ease) backwards; }
.page-view .kpi:nth-child(1),.page-view .tbl tbody tr:nth-child(1),.page-view .list-item:nth-child(1){animation-delay:.04s}
.page-view .kpi:nth-child(2),.page-view .tbl tbody tr:nth-child(2),.page-view .list-item:nth-child(2){animation-delay:.09s}
.page-view .kpi:nth-child(3),.page-view .tbl tbody tr:nth-child(3),.page-view .list-item:nth-child(3){animation-delay:.14s}
.page-view .kpi:nth-child(4),.page-view .tbl tbody tr:nth-child(4),.page-view .list-item:nth-child(4){animation-delay:.19s}
.page-view .tbl tbody tr:nth-child(5),.page-view .list-item:nth-child(5){animation-delay:.24s}
.page-view .tbl tbody tr:nth-child(6),.page-view .list-item:nth-child(6){animation-delay:.29s}
.page-view .tbl tbody tr:nth-child(7),.page-view .list-item:nth-child(7){animation-delay:.34s}
.page-view .tbl tbody tr:nth-child(8),.page-view .list-item:nth-child(8){animation-delay:.39s}
.page-view .tbl tbody tr:nth-child(n+9){animation-delay:.44s}
@media (prefers-reduced-motion: reduce) {
  .page-view, .page-view * { animation: none !important; }
}

/* ---------- KPI карточки ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 24px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); padding: 20px 22px;
  position: relative; overflow: hidden; transition: transform .3s var(--ease), box-shadow .3s;
}
.kpi:hover { transform: translateY(-3px); box-shadow: var(--sh-md); }
.kpi .ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 16px; }
.kpi .ic svg { width: 21px; height: 21px; }
.kpi.em .ic { background: var(--emerald-50); color: var(--emerald-600); }
.kpi.warn .ic { background: #fbf1dc; color: #a9741a; }
.kpi.danger .ic { background: #fbe7e4; color: #b23120; }
.kpi.info .ic { background: #e6f0f8; color: #22648f; }
.kpi .val { font-family: var(--font-display); font-size: 30px; font-weight: 700; line-height: 1; }
.kpi .lbl { color: var(--muted); font-size: 13.5px; margin-top: 8px; }
.kpi .trend { position: absolute; top: 20px; right: 22px; font-size: 12.5px; font-weight: 700; display: flex; align-items: center; gap: 3px; }
.kpi .trend.up { color: var(--ok); } .kpi .trend.down { color: var(--danger); }

/* ---------- Карточки / панели ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); }
.card-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: 17px; font-weight: 700; }
.card-head .act { margin-left: auto; display: flex; gap: 8px; }
.card-body { padding: 22px; }
.card-body.flush { padding: 0; }

.cols { display: grid; gap: 20px; }
.cols-2 { grid-template-columns: 1.6fr 1fr; }
.cols-2e { grid-template-columns: 1fr 1fr; }
/* грид-элементы должны уметь сжиматься уже своего контента (иначе широкая таблица ломает адаптив) */
.cols > * { min-width: 0; }
.card { min-width: 0; }

/* ---------- Таблицы ---------- */
.table-wrap { overflow-x: auto; min-width: 0; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
.tbl th { text-align: left; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 13px 18px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 15px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .15s; }
.tbl tbody tr:hover { background: var(--paper); }
.tbl .strong { font-weight: 700; color: var(--ink); }
.tbl .sub { font-size: 12.5px; color: var(--muted); }
.tbl .num { font-variant-numeric: tabular-nums; font-weight: 600; }
.t-right { text-align: right; }

/* ---------- Списки заявок / активности ---------- */
.list { display: grid; }
.list-item { display: flex; gap: 14px; padding: 16px 22px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.list-item:last-child { border-bottom: none; }
.list-item .ic { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--paper-2); color: var(--ink-2); }
.list-item .ic svg { width: 19px; height: 19px; }
.list-item .ttl { font-weight: 700; font-size: 14.5px; }
.list-item .meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.list-item .rt { margin-left: auto; text-align: right; white-space: nowrap; }

/* ---------- Канбан заявок ---------- */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; }
.kan-col { background: var(--paper-2); border-radius: var(--r-md); padding: 14px; }
.kan-col h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); display: flex; align-items: center; gap: 8px; margin-bottom: 12px; padding: 0 4px; }
.kan-col h4 .c { background: #fff; border-radius: 99px; padding: 1px 9px; font-size: 12px; }
.tick { background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 14px; margin-bottom: 10px; cursor: pointer; transition: .2s var(--ease); border-left: 3px solid var(--line-2); }
.tick:hover { box-shadow: var(--sh-md); transform: translateY(-2px); }
.tick.pri-high { border-left-color: var(--danger); }
.tick.pri-medium { border-left-color: var(--warn); }
.tick.pri-low { border-left-color: var(--emerald-400); }
.tick .cat { font-size: 12px; color: var(--emerald-700); font-weight: 700; }
.tick .subj { font-weight: 700; font-size: 14px; margin: 5px 0 8px; }
.tick .foot { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--muted); }

/* ---------- Формы в кабинете ---------- */
.form-row { display: grid; gap: 15px; }
.form-row.two { grid-template-columns: 1fr 1fr; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; }

/* ---------- Пустое состояние ---------- */
.empty { text-align: center; padding: 54px 20px; color: var(--muted); }
.empty > svg { width: 46px; height: 46px; color: var(--line-2); margin-bottom: 14px; }
.empty h4 { color: var(--ink-2); font-size: 17px; }
.empty p { margin-top: 6px; font-size: 14px; max-width: 420px; margin-left: auto; margin-right: auto; }
.err-state { padding: 60px 20px; }
.err-state .es-ic { width: 60px; height: 60px; border-radius: 16px; background: #fbe7e4; color: #b23120; display: inline-grid; place-items: center; margin-bottom: 16px; }

/* ---------- Скелетон загрузки ---------- */
.sk { display: block; border-radius: 8px; background: linear-gradient(100deg, var(--paper-2) 30%, var(--line) 50%, var(--paper-2) 70%);
  background-size: 200% 100%; animation: skShimmer 1.3s ease-in-out infinite; }
.sk-round { width: 42px; height: 42px; border-radius: 12px; }
@keyframes skShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------- Прогресс / полоски ---------- */
.progress { height: 8px; background: var(--paper-2); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--emerald-500), var(--emerald-400)); border-radius: 99px; }

/* ---------- Модалка ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(16,32,26,.5); backdrop-filter: blur(4px); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; visibility: hidden; transition: .25s; }
.modal-back.open { opacity: 1; visibility: visible; }
.modal { background: var(--card); border-radius: var(--r-lg); width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; transform: translateY(16px) scale(.98); transition: .3s var(--ease); box-shadow: var(--sh-lg); }
.modal-back.open .modal { transform: none; }
.modal-head { display: flex; align-items: center; padding: 22px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 2; }
.modal-head h3 { font-size: 20px; font-weight: 700; font-family: var(--font-display); }
.modal-head .x { margin-left: auto; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); }
.modal-head .x:hover { background: var(--paper-2); color: var(--ink); }
.modal-body { padding: 24px; }

/* ---------- Тосты ---------- */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 300; display: grid; gap: 10px; }
.toast { background: var(--ink); color: #fff; padding: 14px 18px; border-radius: var(--r-sm); box-shadow: var(--sh-lg); display: flex; align-items: center; gap: 11px; font-size: 14px; font-weight: 600; min-width: 260px; animation: toastIn .3s var(--ease); }
.toast svg { width: 20px; height: 20px; flex: none; }
.toast.ok { background: #0f6b46; } .toast.err { background: #b23120; }
@keyframes toastIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Детали / definition ---------- */
.dl { display: grid; grid-template-columns: auto 1fr; gap: 10px 20px; font-size: 14px; }
.dl dt { color: var(--muted); }
.dl dd { text-align: right; font-weight: 600; margin: 0; }

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin: 6px 0 14px; }
.timeline { display: grid; gap: 16px; position: relative; padding-left: 22px; }
.timeline::before { content:""; position:absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.tl-item { position: relative; }
.tl-item::before { content:""; position:absolute; left: -22px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--emerald-500); border: 2px solid var(--card); }
.tl-item .who { font-weight: 700; font-size: 13.5px; }
.tl-item .txt { font-size: 14px; color: var(--ink-2); margin-top: 2px; }
.tl-item .at { font-size: 12px; color: var(--faint); margin-top: 3px; }

/* ---------- Быстрые действия (плитки) ---------- */
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.quick a, .quick button { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); padding: 20px; text-align: left; transition: .25s var(--ease); display: block; }
.quick a:hover, .quick button:hover { border-color: var(--emerald-400); transform: translateY(-3px); box-shadow: var(--sh-md); }
.quick .ic { width: 40px; height: 40px; border-radius: 11px; background: var(--emerald-50); color: var(--emerald-600); display: grid; place-items: center; margin-bottom: 12px; }
.quick .ic svg { width: 20px; height: 20px; }
.quick .tt { font-weight: 700; font-size: 14.5px; }
.quick .ss { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

/* ---------- Мини-график (bars) ---------- */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 10px; }
.bars .b { flex: 1; background: var(--paper-2); border-radius: 7px 7px 3px 3px; position: relative; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; min-height: 6px; }
.bars .b > span { display: block; background: linear-gradient(180deg, var(--emerald-400), var(--emerald-600)); border-radius: 7px 7px 0 0; transition: height 1s var(--ease); }
.bars-x { display: flex; gap: 10px; margin-top: 8px; }
.bars-x span { flex: 1; text-align: center; font-size: 11.5px; color: var(--muted); }

/* ---------- Donut ---------- */
.donut { display: flex; align-items: center; gap: 22px; }
.donut svg { width: 128px; height: 128px; flex: none; }
.donut .legend { display: grid; gap: 10px; font-size: 13.5px; }
.donut .legend .li { display: flex; align-items: center; gap: 9px; }
.donut .legend .sw { width: 11px; height: 11px; border-radius: 3px; }

/* ---------- Квитанция (печать / PDF) ---------- */
#printArea { display: none; }
.rcpt { color: #10201a; font-size: 13px; line-height: 1.5; }
.rcpt-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; padding-bottom: 18px; border-bottom: 2px solid var(--emerald-700); }
.rcpt-brand { display: flex; align-items: center; gap: 12px; }
.rcpt-mark { width: 46px; height: 46px; border-radius: 11px; background: var(--emerald-700); color: #fff; display: grid; place-items: center; font-weight: 800; font-family: var(--font-display); font-size: 18px; }
.rcpt-org { font-family: var(--font-display); font-weight: 700; font-size: 19px; }
.rcpt-orgsub { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.rcpt-org-info { text-align: right; font-size: 11.5px; color: var(--ink-2); line-height: 1.7; }
.rcpt-title { display: flex; align-items: center; gap: 14px; margin: 22px 0 18px; }
.rcpt-title h1 { font-family: var(--font-display); font-weight: 700; font-size: 24px; }
.rcpt-status { padding: 4px 12px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.rcpt-status.paid { background: #e6f4ec; color: #0f7a4d; }
.rcpt-status.unpaid { background: #fbf1dc; color: #a9741a; }
.rcpt-status.overdue { background: #fbe7e4; color: #b23120; }
.rcpt-row2 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.rcpt-lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.rcpt-v { font-weight: 700; margin-top: 4px; font-size: 14px; }
.rcpt-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.rcpt-payer { padding: 16px 0; }
.rcpt-table { width: 100%; border-collapse: collapse; margin: 8px 0 18px; }
.rcpt-table th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px; background: var(--paper-2); }
.rcpt-table td { padding: 12px; border-bottom: 1px solid var(--line); }
.rcpt-table .r { text-align: right; }
.rcpt-table tfoot td { border-bottom: none; font-weight: 700; padding-top: 14px; }
.rcpt-table .total { font-size: 18px; color: var(--emerald-700); font-family: var(--font-display); }
.rcpt-reqs { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.rcpt-reqs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; margin-top: 8px; font-size: 12.5px; }
.rcpt-purpose { margin-top: 12px; font-size: 12px; color: var(--ink-2); }
.rcpt-sign { display: flex; gap: 60px; margin-top: 34px; }
.rcpt-sign > div { font-size: 12px; color: var(--muted); }
.rcpt-line { width: 180px; border-bottom: 1px solid var(--ink-2); margin-bottom: 6px; height: 24px; }
.rcpt-note { margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 11px; color: var(--faint); text-align: center; }

@media print {
  body.printing { background: #fff; }
  body.printing > *:not(#printArea) { display: none !important; }
  body.printing #printArea { display: block !important; padding: 4mm; background: #fff; }
  @page { margin: 12mm; }
}

/* ============================================================
   Адаптив кабинетов
   ============================================================ */
@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .cols-2, .cols-2e { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 120; width: 280px; transform: translateX(-100%);
    transition: transform .3s var(--ease); box-shadow: var(--sh-lg);
  }
  .sidebar.open { transform: none; }
  .menu-toggle { display: grid; }
  .sidebar-back { position: fixed; inset: 0; background: rgba(16,32,26,.4); z-index: 110; opacity: 0; visibility: hidden; transition: .25s; }
  .sidebar-back.open { opacity: 1; visibility: visible; }
}
@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .kpi .val { font-size: 24px; }
  .page, .topbar { padding-left: 16px; padding-right: 16px; }
  .form-row.two { grid-template-columns: 1fr; }
  .topbar { gap: 10px; }
  /* заголовок сжимается и усекается, а не выталкивает кнопки действий за экран */
  .topbar h1 { font-size: 20px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-actions { gap: 8px; }
  /* шапка карточки: кнопки/подписи переносятся под заголовок, а не уезжают за экран */
  .card-head { flex-wrap: wrap; row-gap: 10px; }
  .card-head h3 { min-width: 0; }
  .card-head .act { flex-wrap: wrap; }
}
@media (max-width: 400px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .page, .topbar { padding-left: 13px; padding-right: 13px; }
  .topbar h1 { font-size: 18px; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .btn-sm { padding: 8px 12px; }
  .icon-btn { width: 38px; height: 38px; }
}
