:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f7;
  --surface-3: #fafbfc;
  --panel: var(--surface);
  --panel-2: var(--surface-2);
  --ink: #0f1115;
  --ink-2: #2a2e37;
  --muted: #6b7280;
  --muted-2: #98a0ad;
  --line: #e6e8ee;
  --line-2: #eef0f4;
  --line-strong: #d6dae3;
  --accent: #605bff;
  --accent-ink: #ffffff;
  --accent-soft: #eeedff;
  --accent-strong: #4d48e6;
  --warn: #c2701b;
  --warn-soft: #fff2dd;
  --error: #c2362a;
  --error-soft: #fdecea;
  --info: #2c6dd4;
  --info-soft: #eaf1fc;
  --ok: #1c8e5a;
  --ok-soft: #e8f5ee;
  --table-head: #f1f3f7;
  --input: #ffffff;
  --sidebar-bg: #0e0f12;
  --sidebar-ink: #e6e7ec;
  --sidebar-muted: #8a8d96;
  --sidebar-line: #1d1f25;
  --sidebar-active-bg: #1a1c22;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --pad-x: 28px;
  --pad-y: 24px;
  --row-h: 36px;
  --font-sans: "Geist", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, monospace;
  --shadow-sm: 0 1px 2px rgba(15, 17, 21, .04), 0 1px 1px rgba(15, 17, 21, .03);
  --shadow: 0 1px 3px rgba(15, 17, 21, .06), 0 8px 24px rgba(15, 17, 21, .05);
}

/* Phase 4 Mercury shell */
.app {
  grid-template-columns: 240px minmax(0, 1fr);
  background: var(--bg);
}

.app.is-sidebar-collapsed {
  grid-template-columns: 68px minmax(0, 1fr);
}

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  border-right: 1px solid var(--sidebar-line);
  padding: 18px 12px;
}

.brand {
  padding: 6px 8px 14px;
  gap: 10px;
  border-bottom: 1px solid var(--sidebar-line);
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, #605bff 0%, #b388ff 100%);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  position: relative;
  overflow: hidden;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 5px 5px auto auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,.5);
}

.brand-text strong {
  display: block;
  font-size: 15px;
  font-weight: 650;
}

.brand span {
  color: var(--sidebar-muted);
  font-size: 11px;
}

.sidebar-toggle {
  width: 28px;
  height: 28px;
  border-color: var(--sidebar-line);
  background: var(--sidebar-active-bg);
  color: var(--sidebar-muted);
  border-radius: 8px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 14px;
}

.nav-section {
  margin: 14px 8px 6px;
  color: var(--sidebar-muted);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.sidebar-context {
  margin: 12px 0 8px;
  padding: 10px 8px;
  border: 1px solid var(--sidebar-line);
  border-radius: 8px;
  background: rgba(255,255,255,.03);
}

.context-title {
  margin-bottom: 8px;
  color: var(--sidebar-muted);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.context-controls {
  display: grid;
  gap: 8px;
}

.context-controls label {
  display: grid;
  gap: 4px;
  color: var(--sidebar-muted);
  font-size: 11px;
}

.context-controls select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--sidebar-line);
  border-radius: 7px;
  background: var(--sidebar-active-bg);
  color: var(--sidebar-ink);
  padding: 7px 8px;
  font-size: 12px;
}

.nav-group {
  display: grid;
  gap: 2px;
}

.nav-mode-btn {
  margin-top: 4px;
  font-weight: 650;
}

.nav-caret {
  margin-left: auto;
  color: var(--sidebar-muted);
  transform: rotate(0deg);
  transition: transform .14s ease;
}

.nav-group.is-open .nav-caret {
  transform: rotate(90deg);
}

.nav-children {
  display: none;
  gap: 1px;
  padding-left: 10px;
  margin-left: 17px;
}

.nav-group.is-open .nav-children {
  display: grid;
}

.nav-sub-btn {
  min-height: 32px;
  padding: 7px 9px;
  font-size: 12.5px;
  color: #c9ccd4;
}

.nav-sub-btn .nav-icon {
  width: 16px;
  height: 16px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--sidebar-ink);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  color: var(--sidebar-muted);
  flex-shrink: 0;
}

.nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-btn:hover,
.nav-btn.is-active {
  background: var(--sidebar-active-bg);
  color: #fff;
}

.nav-btn.is-active .nav-icon {
  color: #fff;
}

.app.is-sidebar-collapsed .sidebar {
  padding: 18px 10px;
}

.app.is-sidebar-collapsed .brand {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 4px 0 14px;
}

.app.is-sidebar-collapsed .brand-text,
.app.is-sidebar-collapsed .nav-section,
.app.is-sidebar-collapsed .sidebar-context,
.app.is-sidebar-collapsed .nav-children,
.app.is-sidebar-collapsed .nav-caret,
.app.is-sidebar-collapsed .nav-label {
  display: none;
}

.app.is-sidebar-collapsed .nav-btn {
  justify-content: center;
  padding: 9px 0;
  font-size: 13.5px;
}

.app.is-sidebar-collapsed .nav-btn::first-letter {
  font-size: inherit;
}

.app.is-sidebar-collapsed .sidebar-toggle {
  position: static;
  flex: 0 0 auto;
}

body.density-compact {
  --pad-x: 16px;
  --pad-y: 12px;
  --row-h: 28px;
  font-size: 13px;
}

body.density-compact .topbar {
  padding-top: 10px;
  padding-bottom: 10px;
}

body.density-compact .dashboard {
  gap: 8px;
  margin-bottom: 12px;
}

body.density-compact .metric {
  min-height: 72px;
  padding: 10px 12px;
}

body.density-compact .metric strong {
  font-size: 20px;
}

body.density-compact .page {
  gap: 12px;
}

body.density-compact .page-title {
  font-size: 22px;
}

body.density-compact .panel-head,
body.density-compact .card-head {
  padding: 10px 12px;
}

body.density-compact .card-pad,
body.density-compact .quick-actions {
  padding: 12px;
}

body.density-compact .btn {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12px;
}

body.density-compact .tab {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

body.density-compact th,
body.density-compact td {
  padding: 5px 7px;
  font-size: 12px;
}

body.density-compact input.cell-input,
body.density-compact select,
body.density-compact .month-picker-button {
  min-height: 26px;
}

body.density-compact .control-chip {
  min-height: 30px;
  padding: 3px 7px;
}

body.density-roomy {
  --pad-x: 44px;
  --pad-y: 38px;
  --row-h: 50px;
  font-size: 15px;
}

body.density-roomy .topbar {
  padding-top: 20px;
  padding-bottom: 20px;
}

body.density-roomy .dashboard {
  gap: 18px;
  margin-bottom: 28px;
}

body.density-roomy .metric {
  min-height: 124px;
  padding: 22px 24px;
}

body.density-roomy .metric strong {
  font-size: 30px;
}

body.density-roomy .page {
  gap: 28px;
}

body.density-roomy .page-title {
  font-size: 30px;
}

body.density-roomy .panel-head,
body.density-roomy .card-head {
  padding: 18px 22px;
}

body.density-roomy .card-pad,
body.density-roomy .quick-actions {
  padding: 24px;
}

body.density-roomy .btn {
  min-height: 40px;
  padding: 9px 18px;
  font-size: 14px;
}

body.density-roomy .tab {
  min-height: 44px;
  padding: 10px 18px;
  font-size: 14px;
}

body.density-roomy th,
body.density-roomy td {
  padding: 10px 12px;
  font-size: 13.5px;
}

body.density-roomy input.cell-input,
body.density-roomy select,
body.density-roomy .month-picker-button {
  min-height: 36px;
}

body.density-roomy .control-chip {
  min-height: 40px;
  padding: 6px 12px;
}

.main {
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--bg);
}

.topbar {
  margin: 0;
  padding: 12px var(--pad-x);
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  /* P.2a v2 sticky: topbar прилипает к верху viewport — owner хочет
     чтобы кнопки «Сохранить», поиск и Месяц/Квартал/Год оставались
     видны при скролле длинных страниц. */
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title {
  min-width: 0;
}

.topbar h1 {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -.01em;
}

.topbar p {
  margin-top: 5px;
}

/* Phase M.5 v3.7 — breadcrumb стиль. */
.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-2, #64748b);
  flex-wrap: wrap;
  min-width: 0;
}

.breadcrumb-mode {
  color: var(--text-2, #64748b);
}

.breadcrumb-sep {
  color: var(--text-2, #94a3b8);
}

.breadcrumb-tab {
  color: var(--text-1, #0f172a);
  font-weight: 700;
  font-size: 16px;
}

.breadcrumb-context {
  color: var(--text-2, #94a3b8);
  font-size: 13px;
}

.save-status-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

/* Save-status pill — заменяет старый .save-dirty-indicator. */
.save-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: rgba(34, 197, 94, 0.12);
  color: #15803d;
  border: 1px solid rgba(34, 197, 94, 0.25);
  white-space: nowrap;
  cursor: pointer;
}

.save-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #16a34a;
}

.save-status[data-state="warn"] {
  background: rgba(245, 158, 11, 0.14);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.3);
}

.save-status[data-state="warn"] .save-status-dot {
  background: #f59e0b;
  animation: save-status-pulse 1.6s ease-in-out infinite;
}

.save-status[data-state="saving"] {
  background: rgba(99, 102, 241, 0.12);
  color: #4338ca;
  border-color: rgba(99, 102, 241, 0.3);
}

.save-status[data-state="saving"] .save-status-dot {
  background: #6366f1;
  animation: save-status-pulse 0.9s ease-in-out infinite;
}

.save-status[data-state="error"] {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.3);
}

.save-status[data-state="error"] .save-status-dot {
  background: #dc2626;
}

.save-status-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 1400;
  width: 220px;
  padding: 6px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  background: var(--card, #fff);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
}

.save-status-menu[hidden] {
  display: none;
}

.save-status-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-1, #0f172a);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.save-status-menu-item:hover {
  background: rgba(99, 102, 241, 0.08);
  color: var(--accent, #5b5cf6);
}

.save-status-menu-item.is-primary {
  color: #b45309;
}

@keyframes save-status-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* Settings money redesign (2026-05-17): pill превратился в кнопку,
   menu открывается под ней с пунктами «Сохранить» / «Перечитать с сервера». */
.save-status-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.save-status[data-action="save-status-menu"] {
  cursor: pointer;
  border-style: solid;
}

.save-status[data-action="save-status-menu"]:hover {
  filter: brightness(.97);
}

.save-status-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  background: var(--surface, #fff);
  border: 1px solid var(--line, #e6e8ee);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 17, 21, 0.10);
  padding: 4px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.save-status-menu[hidden] {
  display: none;
}

.save-status-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink, #0f1115);
  text-align: left;
}

.save-status-menu-item:hover {
  background: var(--surface-2, #f1f3f7);
}

.save-status-menu-item.is-primary {
  background: var(--accent-soft, #eeedff);
  color: var(--accent-strong, #4d48e6);
  font-weight: 600;
}

.save-status-menu-item.is-primary:hover {
  background: var(--accent, #6366f1);
  color: #fff;
}

/* Settings page: локальная Save-кнопка справа от вкладок настроек.
   Видима только когда dirty (body.has-dirty-settings). */
.settings-local-save {
  margin-left: auto;
  display: none;
}

body.has-dirty-settings .settings-local-save {
  display: inline-flex;
  align-items: center;
}

.topbar-auth {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.topbar-notif-icon {
  font-size: 16px;
}

.topbar-notif-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #dc2626;
}

#topbar-search,
#topbar-notifications {
  position: relative;
  font-size: 16px;
}

.actions {
  align-items: center;
  gap: 8px;
  margin-top: 0;
}

.topbar-controls {
  gap: 8px;
  margin-right: 0;
}

.control-chip {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 12px;
}

.control-chip select {
  min-width: 92px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
}

.auth-chip {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 4px 10px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.notices,
.dashboard,
.content {
  margin-left: var(--pad-x);
  margin-right: var(--pad-x);
}

.notices {
  margin-top: 16px;
}

/* Phase M.5 v3.8 — пустой notices/dashboard не должны "съедать"
   вертикальное пространство над контентом. */
.notices:empty {
  margin: 0;
  padding: 0;
}

.dashboard[hidden] {
  display: none !important;
  margin: 0;
}

.overview-page {
  padding-top: 4px;
}

.content {
  padding-bottom: var(--pad-y);
}

.dashboard {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-top: var(--pad-y);
  margin-bottom: 18px;
}

.metric,
.panel,
.card,
.notice,
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.metric {
  min-height: 96px;
  padding: 16px 18px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.metric strong {
  color: var(--ink);
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -.02em;
}

.page {
  padding: 0 0 var(--pad-y);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  gap: 16px;
}

.page-title {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -.02em;
}

.page-sub {
  color: var(--muted);
  font-size: 13.5px;
}

.page-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr);
  gap: 14px;
}

.card {
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}

.card-pad {
  padding: 18px 20px;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 18px;
}

.quick-action {
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-3);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.quick-action span {
  color: var(--accent);
}

.overview-status strong {
  display: block;
  font-size: 24px;
  letter-spacing: -.02em;
}

.flow-lane-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.flow-lane {
  display: grid;
  grid-template-columns: minmax(130px, .8fr) 22px minmax(180px, 1fr) 22px minmax(130px, .8fr);
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-3);
}

.pill-node {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  border-color: var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 550;
  padding: 7px 14px;
  box-shadow: none;
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  box-shadow: none;
}

.btn-primary,
.btn-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-small {
  min-height: 28px;
  padding: 4px 10px;
  font-size: 12.5px;
}

.btn-icon {
  width: 34px;
  padding: 0;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 38px;
  padding: 8px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 550;
}

.tab:hover,
.tab.active {
  color: var(--ink);
}

.tab.active {
  border-bottom-color: var(--accent);
}

.panel {
  overflow: hidden;
}

.panel-head {
  background: var(--surface);
  padding: 14px 18px;
}

.panel-head h2 {
  font-size: 15px;
  font-weight: 650;
}

.table-wrap {
  background: var(--surface);
}

table {
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  min-height: var(--row-h);
  border-right: 0;
  border-bottom: 1px solid var(--line-2);
  padding: 7px 9px;
  font-size: 12.5px;
}

th {
  background: var(--table-head);
  color: var(--ink-2);
  font-weight: 650;
  padding: 6px 9px;
}

input.cell-input,
select,
.month-picker-button {
  min-height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--input);
  color: var(--ink);
}

.toggle-control {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 22px;
  cursor: pointer;
}

.toggle-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--line-strong);
  position: relative;
  transition: background-color .14s;
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15,17,21,.22);
  transition: transform .14s;
}

.toggle-control input:checked + .toggle-track {
  background: var(--accent);
}

.toggle-control input:checked + .toggle-track::after {
  transform: translateX(14px);
}

.settings-page {
  gap: 12px;
}

.settings-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
  margin-top: -2px;
}

.settings-tabs .tab {
  flex: 0 0 auto;
}

.settings-local-save {
  display: none;
  align-items: center;
  margin-left: auto;
  padding-left: 12px;
  flex: 0 0 auto;
}

body.has-dirty-settings .settings-local-save {
  display: inline-flex;
}

.settings-save-button {
  min-height: 32px;
  padding: 7px 12px;
  border-radius: 9px;
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.18), 0 8px 22px rgba(99, 102, 241, 0.18);
  animation: settings-save-pulse 1.8s ease-in-out infinite;
}

@keyframes settings-save-pulse {
  0%, 100% {
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.18), 0 8px 22px rgba(99, 102, 241, 0.14);
  }
  50% {
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.26), 0 10px 26px rgba(99, 102, 241, 0.24);
  }
}

.settings-grid {
  display: grid;
  gap: 14px;
}

.ui-prefs-panel {
  position: fixed;
  right: 18px;
  top: 72px;
  z-index: 1500;
  width: 304px;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.6);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  color: var(--ink);
  box-shadow: 0 16px 44px rgba(15,17,21,.18);
  backdrop-filter: blur(24px) saturate(160%);
}

.ui-prefs-head,
.ui-pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ui-pref-row {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 6px;
}

.ui-pref-row > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 8px;
  background: var(--surface-2);
  width: 100%;
}

.segmented button {
  flex: 1 1 0;
  min-width: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  min-height: 24px;
  padding: 3px 9px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 550;
}

.segmented button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 2px 8px;
  font-size: 11.5px;
  font-weight: 650;
}

.flow-service-chip,
.tag {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 650;
}

@media (max-width: 980px) {
  .app,
  .app.is-sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    height: auto;
    overflow: visible;
  }

  .nav {
    flex-direction: row;
    overflow-x: auto;
  }

  .nav-group {
    min-width: max-content;
  }

  .nav-group.is-open .nav-children {
    display: flex;
    flex-direction: row;
    padding-left: 0;
    margin-left: 0;
    border-left: 0;
  }

  .nav-section {
    display: none;
  }

  .nav-btn {
    width: auto;
    min-width: max-content;
  }

  .topbar,
  .page-header,
  .overview-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .actions,
  .page-actions {
    justify-content: flex-start;
    margin-left: 0;
  }

  .dashboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-actions,
  .flow-lane {
    grid-template-columns: 1fr;
  }

  .ui-prefs-panel {
    left: 14px;
    right: 14px;
    top: 82px;
    width: auto;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.theme-dark {
  color-scheme: dark;
  --bg: #0b0c0f;
  --surface: #14161b;
  --surface-2: #1b1e25;
  --surface-3: #181b21;
  --panel: var(--surface);
  --panel-2: var(--surface-2);
  --ink: #f3f4f6;
  --ink-2: #d3d6dd;
  --muted: #8d93a0;
  --muted-2: #6c727e;
  --line: #232730;
  --line-2: #1d2028;
  --line-strong: #2c313c;
  --accent: #7d79ff;
  --accent-soft: #1f1d3d;
  --accent-strong: #9591ff;
  --table-head: #1b1e25;
  --input: #111319;
  --sidebar-bg: #07080a;
  --sidebar-line: #14161b;
  --sidebar-active-bg: #14161b;
}

body.density-compact {
  --pad-x: 16px;
  --pad-y: 12px;
  --row-h: 28px;
}

body.density-roomy {
  --pad-x: 44px;
  --pad-y: 38px;
  --row-h: 50px;
}

button,
input,
select {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  transition: grid-template-columns .16s ease;
}

.app.is-sidebar-collapsed {
  grid-template-columns: 70px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  background: #15211d;
  color: #f5fbf8;
  padding: 20px 14px;
  border-right: 1px solid #0e1714;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px 18px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  position: relative;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: #e6f4ee;
  color: #12684d;
  border-radius: 8px;
  font-weight: 800;
}

.brand span {
  display: block;
  margin-top: 2px;
  color: #a8bbb2;
  font-size: 13px;
}

.sidebar-toggle {
  margin-left: auto;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.08);
  color: #f5fbf8;
  border-radius: 6px;
  cursor: pointer;
}

.app.is-sidebar-collapsed .sidebar {
  padding: 18px 10px;
}

.app.is-sidebar-collapsed .brand {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 4px 0 14px;
}

.app.is-sidebar-collapsed .brand-text,
.app.is-sidebar-collapsed .nav-btn {
  font-size: 0;
}

.app.is-sidebar-collapsed .brand-mark {
  width: 34px;
  height: 34px;
}

.app.is-sidebar-collapsed .sidebar-toggle {
  position: static;
  flex: 0 0 auto;
  font-size: 14px;
}

.app.is-sidebar-collapsed .nav-btn {
  text-align: center;
  padding: 10px 0;
}

.app.is-sidebar-collapsed .nav-btn::first-letter {
  font-size: 14px;
}

.nav {
  display: grid;
  gap: 6px;
  margin-top: 18px;
}

.nav-btn {
  width: 100%;
  border: 0;
  background: transparent;
  color: #dbe8e2;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.nav-btn:hover,
.nav-btn.is-active {
  background: rgba(255,255,255,.1);
  color: #ffffff;
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: -24px -24px 16px;
  padding: 18px 24px 14px;
  background: rgba(247, 250, 248, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

p {
  margin: 6px 0 0;
  color: var(--muted);
}

.topbar-controls {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-right: 10px;
}

.topbar-controls label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.auth-chip {
  display: inline-flex;
  align-items: center;
  min-height: 31px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 13px;
}

.source-meta {
  display: inline-block;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  padding: 9px 13px;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .12s ease, box-shadow .16s ease;
  text-decoration: none;
}

.login-card {
  max-width: 460px;
  margin: 9vh auto 0;
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 12px 34px rgba(21, 33, 29, .08);
}

.login-card h2 {
  margin: 0;
  font-size: 22px;
}

.login-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.muted-text {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.auth-create-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(160px, 1fr) minmax(120px, .7fr) minmax(150px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.auth-create-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.auth-permission-grid {
  display: grid;
  gap: 8px;
  min-width: 420px;
}

.auth-permission-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) repeat(4, minmax(74px, auto));
  gap: 8px;
  align-items: center;
}

.auth-permission-row label {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  color: var(--muted);
  white-space: nowrap;
  font-size: 12px;
}

.login-actions {
  display: flex;
  justify-content: flex-end;
}

.btn:hover {
  background: #eef6f1;
  border-color: var(--accent);
  box-shadow: 0 3px 10px rgba(33, 94, 72, .12);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn:disabled {
  opacity: .65;
  cursor: progress;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover {
  background: #14613f;
  border-color: #14613f;
}

.btn-small {
  padding: 6px 9px;
  font-size: 12px;
}

.btn-danger {
  color: var(--error);
  border-color: #e4b6b6;
}

.btn-danger:hover {
  background: #fff1f1;
  border-color: var(--error);
}

.action-delete {
  min-width: 76px;
}

.notices {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.notice {
  border: 1px solid var(--line);
  background: var(--panel);
  border-left: 4px solid var(--info);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.notice.error {
  border-left-color: var(--error);
}

.notice-text { flex: 1 1 auto; }

.notice-close {
  flex-shrink: 0;
  background: transparent;
  border: 0;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted, #6b7280);
  padding: 4px 8px;
  border-radius: 4px;
}

.notice-close:hover {
  background: var(--bg-soft, #f3f4f6);
  color: var(--text, #111827);
}

.dirty-settings-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(22, 32, 28, .32);
}

.dirty-modal-card {
  width: min(440px, 100%);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(33, 47, 41, .22);
  padding: 18px;
}

.dirty-modal-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.dirty-modal-card p,
.dirty-modal-card ul {
  margin: 0 0 12px;
  color: var(--muted);
}

.dirty-modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 86px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 20px;
  line-height: 1.15;
}

.overview-compare-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.overview-compare-toggle input {
  margin: 0;
}

.overview-delta-chip {
  display: inline-flex;
  width: fit-content;
  margin-top: 6px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.overview-delta-chip.is-up {
  color: var(--error);
}

.overview-delta-chip.is-down {
  color: var(--ok);
}

.content {
  min-width: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.panel-head h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0;
}

.panel-head p {
  font-size: 13px;
}

.panel-actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.panel-body[hidden] {
  display: none;
}

.column-controls {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-3);
}

.column-controls summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  display: inline-block;
  margin-right: 8px;
}

.column-controls-menu {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 0;
}

.column-controls .btn {
  font-size: 11px;
}

.btn.is-muted {
  color: var(--muted);
  background: var(--surface-2);
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 5px 7px;
  vertical-align: middle;
  text-align: center;
  white-space: nowrap;
  font-size: 13px;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--table-head);
  color: #2b3832;
  font-weight: 650;
  white-space: pre-line;
  line-height: 1.1;
  padding: 3px 7px;
}

.column-title,
.column-unit {
  display: block;
}

.column-unit {
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

th[draggable="true"] {
  cursor: grab;
}

td:has(.action-delete) {
  width: 96px;
  min-width: 96px;
  max-width: 96px;
}

tr.start-row td {
  background: #f1f6fa;
  font-weight: 650;
}

tfoot td {
  background: #f7faf8;
  font-weight: 700;
  border-top: 2px solid var(--line-strong);
}

input.cell-input {
  width: 78px;
  min-width: 0;
  border: 1px solid #ccd8d2;
  border-radius: 6px;
  background: var(--input);
  padding: 5px 6px;
  text-align: center;
}

input.cell-input[type="number"] {
  padding-right: 24px;
}

input.cell-input.text {
  width: 150px;
  text-align: left;
}

input.cell-input.full-width,
input.meter-name-input {
  width: 100%;
  min-width: 180px;
  box-sizing: border-box;
}

input.cell-input.date {
  width: 128px;
}

input.cell-input.money,
input.cell-input.rate {
  width: 86px;
}

input.cell-input.kwh,
input.cell-input.quantity,
input.cell-input.number {
  width: 96px;
}

input.cell-input.compact {
  width: 64px;
  margin-top: 6px;
}

select {
  min-width: 70px;
  border: 1px solid #ccd8d2;
  border-radius: 6px;
  background: var(--input);
  padding: 5px 6px;
}

.settings-grid {
  display: grid;
  gap: 14px;
}

.settings-table-controls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 0 0 8px;
}

.settings-table-controls label {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  margin: 0;
}

.settings-table-controls input[type="search"] {
  min-width: 180px;
}

.settings-table-controls select {
  min-width: 150px;
}

.input-origin-block {
  display: grid;
  gap: 8px;
}

.input-origin-block[data-input-origin-group="supplier"] {
  border-left: 3px solid var(--info);
  padding-left: 10px;
}

.input-origin-block[data-input-origin-group="service"] {
  border-left: 3px solid var(--accent);
  padding-left: 10px;
}

.input-origin-block[data-input-origin-group="readings"] {
  border-left: 3px solid var(--line-strong);
  padding-left: 10px;
}

.settings-groups {
  display: grid;
  gap: 22px;
}

.settings-group {
  display: grid;
  gap: 12px;
}

.settings-group-head {
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.settings-group-head h2 {
  margin: 0;
  font-size: 18px;
}

.consumer-stack,
.investor-stack {
  grid-template-columns: minmax(0, 1fr);
}

.consumer-year-matrix {
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.consumer-year-matrix .panel {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  box-shadow: none;
  overflow: hidden;
}

.consumer-year-matrix .panel-head {
  align-items: flex-start;
  background: var(--surface, #fff);
  border-bottom: 1px solid var(--border, #e2e8f0);
  padding: 14px 16px 8px;
}

.consumer-year-matrix .panel-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.consumer-year-matrix .panel-head p {
  margin: 6px 0 0;
  color: var(--text-2, #64748b);
  font-size: 12.5px;
  line-height: 1.35;
}

.consumer-year-matrix .panel-actions .btn {
  border-color: var(--border, #e2e8f0);
  background: transparent;
  color: var(--text-2, #64748b);
}

.consumer-matrix {
  --consumer-label-width: 200px;
  min-width: 0;
  table-layout: fixed;
}

.consumer-matrix .consumer-row-label,
.consumer-matrix th.consumer-row-label-head {
  min-width: var(--consumer-label-width);
  width: var(--consumer-label-width);
  white-space: normal;
}

.consumer-matrix .consumer-row-label {
  position: sticky;
  padding: 7px 10px;
  padding-right: 36px;
  padding-bottom: 14px;
  border-left: 2px solid transparent;
  border-right: 2px solid transparent;
}

.consumer-matrix .consumer-row-name {
  display: block;
  overflow: visible;
  line-height: 1.2;
  text-align: left;
  white-space: normal;
  text-overflow: clip;
}

.consumer-matrix .consumer-row-unit {
  display: inline-block;
  position: absolute;
  right: 10px;
  bottom: 5px;
  color: var(--accent, #6366f1);
  font-weight: 400;
  text-align: right;
  line-height: 1.1;
  white-space: nowrap;
}

.consumer-matrix .consumer-month-head {
  min-width: 0;
  width: calc((100% - var(--consumer-label-width)) / 12);
}

.consumer-month-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.consumer-status-row .status-wrap,
.consumer-money-cell .money-explain {
  justify-content: center;
}

.consumer-total-row .consumer-row-label,
.consumer-subtotal-row .consumer-row-label {
  background: color-mix(in srgb, var(--muted) 5%, var(--surface));
}

.consumer-total-row .consumer-row-name,
.consumer-subtotal-row .consumer-row-name {
  font-weight: 700;
}

.consumer-key-row .consumer-row-name,
.consumer-key-row .consumer-month-cell {
  color: color-mix(in srgb, var(--accent, #4f46e5) 52%, var(--text-1, #0f172a));
  font-weight: 700;
}

.consumer-key-row .consumer-row-unit {
  color: var(--accent, #4f46e5);
}

.consumer-key-row .money-explain {
  font-weight: 700;
}

.consumer-matrix tbody tr:nth-child(odd) .consumer-row-label,
.consumer-matrix tbody tr:nth-child(odd) .input-v2-cell:not(.is-selected):not(.is-closed) {
  background-color: color-mix(in srgb, var(--accent, #6366f1) 3%, var(--surface, #fff));
}

.consumer-matrix tbody tr:nth-child(even) .consumer-row-label,
.consumer-matrix tbody tr:nth-child(even) .input-v2-cell:not(.is-selected):not(.is-closed) {
  background-color: var(--surface, #fff);
}

.consumer-year-matrix .input-v2-table-wrap {
  overflow-x: hidden;
}

.consumer-matrix .consumer-group-row .consumer-group-label {
  padding: 10px 12px 9px;
  color: color-mix(in srgb, var(--accent, #6366f1) 42%, var(--text-1, #0f172a));
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--accent, #6366f1) 8%, var(--surface, #fff)) 0%,
    color-mix(in srgb, var(--accent, #6366f1) 4%, var(--surface, #fff)) 38%,
    var(--surface, #fff) 100%
  );
  border-top: 1px solid color-mix(in srgb, var(--accent, #6366f1) 14%, var(--border, #e2e8f0));
  border-bottom: 1px solid color-mix(in srgb, var(--accent, #6366f1) 10%, var(--border, #e2e8f0));
  border-left: 2px solid color-mix(in srgb, var(--accent, #6366f1) 42%, transparent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.consumer-matrix .consumer-month-cell:last-child {
  border-right: 2px solid transparent;
}

.consumer-matrix tbody tr .consumer-row-label {
  border-left-color: transparent;
  border-right-color: transparent;
}

.consumer-matrix tbody tr .consumer-month-cell:last-child {
  border-right-color: transparent;
}

.consumer-matrix tbody tr:nth-child(odd) .consumer-row-label {
  border-left-color: color-mix(in srgb, var(--accent, #4f46e5) 42%, transparent);
  border-right-color: transparent;
}

.consumer-matrix tbody tr:nth-child(odd) .consumer-month-cell:last-child {
  border-right: 2px solid color-mix(in srgb, var(--accent, #4f46e5) 28%, transparent);
}

.consumer-matrix tbody tr:nth-child(even) .consumer-row-label {
  border-left-color: transparent;
  border-right-color: transparent;
}

.consumer-matrix tbody tr:nth-child(even) .consumer-month-cell:last-child {
  border-right-color: transparent;
}

.consumer-matrix tbody tr:last-child .consumer-month-cell.is-selected {
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
}

.solar-year-matrix {
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.solar-year-matrix .panel {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  box-shadow: none;
  overflow: hidden;
}

.solar-year-matrix .panel-head {
  align-items: flex-start;
  background: var(--surface, #fff);
  border-bottom: 1px solid var(--border, #e2e8f0);
  padding: 14px 16px 8px;
}

.solar-year-matrix .panel-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.solar-year-matrix .panel-head p {
  margin: 6px 0 0;
  color: var(--text-2, #64748b);
  font-size: 12.5px;
  line-height: 1.35;
}

.solar-year-matrix .panel-actions .btn {
  border-color: var(--border, #e2e8f0);
  background: transparent;
  color: var(--text-2, #64748b);
}

.solar-matrix {
  --solar-label-width: 200px;
  min-width: 0;
  table-layout: fixed;
}

.solar-matrix .solar-row-label,
.solar-matrix th.solar-row-label-head {
  min-width: var(--solar-label-width);
  width: var(--solar-label-width);
  white-space: normal;
}

.solar-matrix .solar-row-label {
  position: sticky;
  padding: 7px 10px;
  padding-right: 36px;
  padding-bottom: 14px;
}

.solar-matrix .solar-row-name {
  display: block;
  overflow: visible;
  line-height: 1.2;
  text-align: left;
  white-space: normal;
  text-overflow: clip;
}

.solar-matrix .solar-row-unit {
  display: inline-block;
  position: absolute;
  right: 10px;
  bottom: 5px;
  color: var(--accent, #6366f1);
  font-weight: 400;
  text-align: right;
  line-height: 1.1;
  white-space: nowrap;
}

.solar-matrix .solar-month-head {
  min-width: 0;
  width: calc((100% - var(--solar-label-width)) / 12);
}

.solar-month-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.solar-status-row .status-wrap,
.solar-money-cell .money-explain {
  justify-content: center;
}

.solar-status-cell .status {
  max-width: 82px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

.solar-total-row .solar-row-label {
  background: color-mix(in srgb, var(--muted) 5%, var(--surface));
}

.solar-total-row .solar-row-name {
  font-weight: 700;
}

.solar-key-row .solar-row-name {
  color: color-mix(in srgb, var(--accent, #6366f1) 30%, var(--text-1, #0f172a));
  font-weight: 700;
}

.solar-matrix tbody tr:nth-child(odd) .solar-row-label,
.solar-matrix tbody tr:nth-child(odd) .input-v2-cell:not(.is-selected):not(.is-closed) {
  background-color: color-mix(in srgb, var(--accent, #6366f1) 3%, var(--surface, #fff));
}

.solar-matrix tbody tr:nth-child(even) .solar-row-label,
.solar-matrix tbody tr:nth-child(even) .input-v2-cell:not(.is-selected):not(.is-closed) {
  background-color: var(--surface, #fff);
}

.solar-diff-stack {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  line-height: 1.15;
}

.solar-diff-percent {
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.solar-diff-percent.is-ok {
  color: var(--ok);
}

.solar-diff-percent.is-warn {
  color: var(--warn);
}

.solar-diff-percent.is-danger {
  color: var(--error);
}

.solar-control-signal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 78px;
  min-height: 18px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.solar-control-signal.is-warn {
  color: var(--warn, #b45309);
  background: color-mix(in srgb, var(--warn, #f59e0b) 9%, transparent);
}

.solar-control-signal.is-danger {
  color: var(--error, #b91c1c);
  background: color-mix(in srgb, var(--error, #dc2626) 9%, transparent);
}

.solar-text-cell {
  font-size: 12px;
  line-height: 1.25;
  text-align: left;
  white-space: normal;
}

.solar-final {
  display: grid;
  gap: 14px;
}

.solar-year-matrix .input-v2-table-wrap {
  overflow-x: hidden;
}

.solar-hero-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.solar-hero-kpi-grid.control-kpi-row {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-bottom: 0;
}

.solar-hero-kpi-card {
  min-width: 0;
}

.solar-hero-kpi-card.is-energy {
  border-color: color-mix(in srgb, #16a34a 22%, var(--line, #e2e8f0));
}

.solar-hero-kpi-card.is-money,
.solar-hero-kpi-card.is-bank,
.solar-hero-kpi-card.is-investor {
  border-color: color-mix(in srgb, #f59e0b 22%, var(--line, #e2e8f0));
}

.solar-hero-kpi-card.is-client {
  border-color: color-mix(in srgb, #0ea5e9 22%, var(--line, #e2e8f0));
}

.solar-hero-kpi-card.is-warn {
  border-color: color-mix(in srgb, var(--warn, #f59e0b) 32%, var(--line, #e2e8f0));
  background: color-mix(in srgb, var(--warn, #f59e0b) 5%, var(--surface));
}

.solar-hero-kpi-card.is-ok {
  border-color: color-mix(in srgb, var(--ok, #22c55e) 28%, var(--line, #e2e8f0));
}

.solar-hero-kpi-label,
.solar-hero-kpi-hint {
  color: var(--text-2, #64748b);
  font-size: 11px;
  line-height: 1.25;
}

.solar-hero-kpi-label {
  text-transform: uppercase;
}

.solar-hero-kpi-value {
  color: var(--text);
  font-size: 19px;
  line-height: 1.1;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.solar-hero-kpi-value span {
  color: var(--text-2, #64748b);
  font-size: 11px;
  font-weight: 600;
}

.solar-matrix .solar-row-label {
  border-left: 2px solid transparent;
  border-right: 2px solid transparent;
}

.solar-matrix .solar-month-cell:last-child {
  border-right: 2px solid transparent;
}

.solar-matrix tbody tr .solar-row-label {
  border-left-color: transparent;
  border-right-color: transparent;
}

.solar-matrix tbody tr .solar-month-cell:last-child {
  border-right-color: transparent;
}

.solar-matrix tbody tr:nth-child(odd) .solar-row-label {
  border-left-color: color-mix(in srgb, var(--accent, #4f46e5) 42%, transparent);
  border-right-color: transparent;
}

.solar-matrix tbody tr:nth-child(odd) .solar-month-cell:last-child {
  border-right: 2px solid color-mix(in srgb, var(--accent, #4f46e5) 28%, transparent);
}

.solar-matrix tbody tr:nth-child(even) .solar-row-label {
  border-left-color: transparent;
  border-right-color: transparent;
}

.solar-matrix tbody tr:nth-child(even) .solar-month-cell:last-child {
  border-right-color: transparent;
}

tr.is-muted td {
  color: var(--muted);
  background: #f8faf9;
}

.text-cell {
  min-width: 320px;
  max-width: 520px;
  white-space: normal;
  text-align: left;
}

.rule-cell {
  min-width: 150px;
  text-align: left;
}

.rule-cell label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.mini-controls {
  display: grid;
  grid-template-columns: 62px 82px;
  align-items: center;
  gap: 8px;
  margin-top: 0;
}

.mini-controls select {
  min-width: 0;
  width: 62px;
  height: 32px;
  padding: 5px 6px;
}

.mini-controls input.cell-input.compact {
  width: 82px;
  height: 32px;
  margin-top: 0;
}

.flow-service-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding-right: 10px;
}

.flow-service-picker {
  width: 100%;
  min-height: 34px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfb;
  cursor: pointer;
  text-align: left;
}

.flow-service-picker:hover,
.month-picker-button:hover {
  border-color: #9bb8ad;
  box-shadow: 0 0 0 2px rgba(28, 127, 92, 0.08);
}

.flow-service-chip {
  display: inline-flex;
  align-items: center;
  max-width: 210px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #eaf3ef;
  color: #20362c;
  font-size: 12px;
  line-height: 1.25;
}

.flow-service-chip.service-electricity,
.flow-service-option.service-electricity span {
  background: #edf7ef;
  color: #245a3b;
}

.flow-service-chip.service-water,
.flow-service-option.service-water span {
  background: #edf6fa;
  color: #24576a;
}

.flow-service-chip.service-gas,
.flow-service-option.service-gas span {
  background: #f8f3e7;
  color: #6a5326;
}

.flow-service-chip.service-reactive,
.flow-service-option.service-reactive span {
  background: #f2eff8;
  color: #55446e;
}

.flow-service-chip.service-solar_bank,
.flow-service-option.service-solar_bank span {
  background: #fff7df;
  color: #66511c;
}

.flow-service-chip.service-bank_fee,
.flow-service-option.service-bank_fee span {
  background: #f0f2f7;
  color: #3d4a5d;
}

.flow-service-chip.service-compensation,
.flow-service-option.service-compensation span {
  background: #f7eff3;
  color: #684255;
}

.flow-service-empty {
  color: var(--muted);
  font-size: 12px;
}

.floating-popover {
  position: fixed;
  z-index: 1000;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 38px rgba(20, 35, 28, 0.18);
}

.flow-services-popover {
  width: min(540px, 78vw);
  padding: 9px;
  text-align: left;
  white-space: normal;
}

.flow-services-popover-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 6px 10px;
}

.flow-services-popover label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.flow-service-option span {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 999px;
  line-height: 1.25;
}

.popover-message {
  min-height: 18px;
  margin-top: 7px;
  color: var(--error);
  font-size: 12px;
  white-space: normal;
}

.popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
}

.month-picker-button {
  width: 132px;
  min-width: 132px;
  height: 32px;
  border: 1px solid #ccd8d2;
  border-radius: 6px;
  background: var(--input);
  padding: 5px 8px;
  text-align: left;
  cursor: pointer;
}

.month-picker-popover {
  width: 260px;
  padding: 10px;
}

.month-picker-year-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.month-picker-year-input {
  width: 100%;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--input);
  text-align: center;
  font: inherit;
  font-weight: 700;
}

.month-picker-title {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.month-option {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  padding: 6px 5px;
  cursor: pointer;
  font-size: 12px;
}

.month-option:hover,
.month-option.is-active {
  border-color: var(--accent);
  background: #eef7f2;
  color: var(--accent);
}

.metric-accent {
  background: transparent;
  color: color-mix(in srgb, var(--accent, #6366f1) 30%, var(--text-1, #0f172a));
  font-weight: 700;
}

.meter-title {
  display: block;
}

.meter-header {
  min-width: 110px;
  max-width: 138px;
}

.meter-header .meter-name,
.meter-header .meter-number,
.meter-header .meter-title,
.meter-header .column-unit {
  display: block;
  margin: 0;
  line-height: 1.08;
  white-space: nowrap;
}

.meter-header .meter-name {
  overflow: hidden;
  text-overflow: ellipsis;
  color: #2b3832;
  font-size: 13px;
  font-weight: 650;
}

.meter-header .meter-number {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 550;
}

.meter-header .meter-title {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 550;
}

.meter-header .column-unit {
  font-size: 10.5px;
}

.signed-negative {
  color: var(--error);
  font-weight: 700;
}

.signed-positive,
.signed-ok {
  color: var(--ok);
  font-weight: 700;
}

.signed-info {
  color: var(--info);
  font-weight: 500;
}

.signed-warn {
  color: var(--warn);
  font-weight: 500;
}

.meter-mode-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 999px;
  background: #e8f1ee;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.meter-no-start {
  display: inline-block;
  color: var(--muted);
  font-size: 12px;
}

/* Phase M.9 v2 → v7 — денежные потоки на Сводный → Обзор.
   v7: single-row layout (dot + label + bar + amount + status в одной
   строке). Padding 14px 16px = совпадает с .panel-head padding,
   чтобы labels выровнялись с заголовком панели. */
.cashflow-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 14px 16px;
}

.cashflow-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cashflow-section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

/* Phase M.9 v9 — section-level settlement hint под «К распределению». */
.cashflow-section-hint {
  font-size: 12.5px;
  line-height: 1.4;
  padding: 4px 0 2px;
}

.cashflow-section-hint[data-tone="ok"] {
  color: #15803d;
}

.cashflow-section-hint[data-tone="warn"] {
  color: #b45309;
}

.cashflow-section-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2, #64748b);
}

.cashflow-section-total {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-1, #0f172a);
}

.cashflow-section-total[data-tone="warn"] {
  color: #b45309;
}

.cashflow-section-total[data-tone="ok"] {
  color: #15803d;
}

.cashflow-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Phase M.9 v7 → v8 → v9 — Single-row layout.
   v9: 4 фиксированных колонки — left edge bars одинаковый,
   right edge тоже (amount column fixed 140px).
   Status-chip per-row убран — settlement info через section-hint
   под header «К распределению» + bar tooltip. */
.cashflow-row {
  display: grid;
  grid-template-columns: 10px 180px 1fr 160px;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  min-height: 22px;
}

.cashflow-row-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  color: var(--text-1, #0f172a);
}

.cashflow-row-amount {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
}

@media (max-width: 900px) {
  .cashflow-row {
    grid-template-columns: 10px 1fr auto;
    grid-template-rows: auto auto;
    row-gap: 4px;
  }
  .cashflow-row-bar {
    grid-column: 1 / -1;
  }
}

.cashflow-row-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.cashflow-row-label {
  font-weight: 600;
  color: var(--text-1, #0f172a);
}

.cashflow-row-bar {
  display: block;
  position: relative;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--card-muted, #f1f5f9);
  overflow: visible;
}

.cashflow-row-fill {
  display: block;
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  border-radius: 4px;
  transition: width 0.2s ease-out;
}

/* Phase M.9 v6 — target-marker и зоны excess/gap для receivers.
   Marker — вертикальная пунктирная линия в точке справедливой доли
   (toDistribute / receiversCount). Excess — оранжевый overlay над
   правой частью fill (= то что владелец должен отдать). Gap —
   штриховка между концом bar и marker (= то что владелец должен
   получить). */
.cashflow-bar-marker {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 0;
  border-left: 1.5px dashed rgba(15, 23, 42, 0.45);
  pointer-events: none;
}

.cashflow-bar-excess {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(180, 83, 9, 0.7);
  border-radius: 0 4px 4px 0;
}

.cashflow-bar-gap {
  position: absolute;
  top: 0;
  height: 100%;
  background: repeating-linear-gradient(
    -45deg,
    rgba(22, 163, 74, 0.25),
    rgba(22, 163, 74, 0.25) 4px,
    transparent 4px,
    transparent 8px
  );
  border-radius: 0 4px 4px 0;
}

/* Phase M.9 v10 — delta-метка «+N ₴» / «−N ₴» над/под bar,
   привязанная к target-маркеру (начинается / заканчивается на нём).
   Цвет соответствует tone зоны (excess = orange, gap = green). */
.cashflow-bar-delta-top,
.cashflow-bar-delta-bottom {
  position: absolute;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.cashflow-bar-delta-top {
  bottom: calc(100% + 4px);
  padding-left: 3px;
  color: #b45309;
}

.cashflow-bar-delta-bottom {
  top: calc(100% + 4px);
  padding-right: 3px;
  color: #15803d;
}

.cashflow-row.has-delta-top {
  min-height: 32px;
}

.cashflow-row.has-delta-bottom {
  min-height: 32px;
}

.cashflow-row-amount {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
  text-align: right;
}


/* Phase M.8 — Anomaly badge для подозрительных показаний счётчика.
   Жёлтый кружок справа от input. Warn (default) — оранжевый.
   Error (отрицательная дельта) — красный.
   Phase M.8 v6 — wrapper full-width, slot всегда 22px (резерв даже
   когда badge пуст). Так input стабильной ширины во всех строках,
   не «уезжает влево» при появлении значка. */
.meter-cell-wrapper {
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
  width: 100%;
}

.meter-cell-wrapper > input,
.meter-cell-wrapper > .tariff-copy-cell {
  flex: 1 1 auto;
  min-width: 0;
}

/* Tariff-copy pill — появляется в пустой ячейке при фокусе. */
.tariff-copy-cell {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.tariff-copy-cell > input {
  flex: 1 1 auto;
  min-width: 0;
}

.input-v2-cell .tariff-copy-cell {
  justify-content: center;
}

.input-v2-cell .tariff-copy-cell > input {
  flex: 0 1 80px;
  width: 100%;
  max-width: 80px;
}

.tariff-copy-pill {
  position: absolute;
  /* v2.4 fix: pill под cell (не поверх input) — input остаётся читаемым,
     pill не перекрывает соседние месяцы по горизонтали (overflow vertical).
     При focus on input pill всплывает below; click на pill применяет
     тариф (через global delegate `apply-tariff-from-month`). mousedown
     preventDefault держит focus, чтобы blur не убрал pill раньше click. */
  top: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  display: none;
  white-space: nowrap;
  font-size: 11px;
  line-height: 1.2;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

.tariff-copy-pill:hover,
.tariff-copy-pill:focus-visible {
  background: var(--accent);
  color: var(--surface);
  outline: none;
}

.tariff-copy-cell.is-focused .tariff-copy-pill {
  display: inline-flex;
}

.meter-anomaly-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  flex-shrink: 0;
}

.meter-anomaly-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 11px;
  cursor: help;
  user-select: none;
  flex-shrink: 0;
  line-height: 1;
}

.meter-anomaly-badge[data-severity="warn"] {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fbbf24;
}

.meter-anomaly-badge[data-severity="error"] {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #f87171;
}

.meter-anomaly-badge:hover {
  filter: brightness(0.92);
}

.settings-note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 7px 9px;
  margin: 0 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fbfa;
  color: var(--muted);
  font-size: 12px;
  white-space: normal;
}

.readonly-rent {
  gap: var(--space-4);
}

.rent-dashboard {
  margin-bottom: var(--space-2);
}

.rent-metric strong {
  font-variant-numeric: tabular-nums;
}

.rent-cam-coverage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
  margin: 10px 0 14px;
}

.rent-cam-coverage-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(135deg, #fbfdfc 0%, var(--surface) 100%);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.rent-cam-coverage-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.rent-cam-coverage-head h4 {
  margin: 3px 0;
  font-size: 15px;
}

.rent-cam-coverage-head strong {
  min-width: 62px;
  text-align: right;
  color: var(--info);
  font-size: 24px;
  line-height: 1;
}

.rent-cam-coverage-flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.rent-cam-coverage-flow div {
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px;
}

.rent-cam-coverage-flow span,
.rent-cam-coverage-meta dt {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.rent-cam-coverage-flow strong {
  display: block;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

.rent-cam-coverage-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin: 0;
}

.rent-cam-coverage-meta div,
.rent-cam-coverage-meta dd {
  min-width: 0;
}

.rent-cam-coverage-meta dd {
  margin: 2px 0 0;
  font-size: 12px;
}

.rent-document-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: var(--space-2);
}

.rent-document-controls .cell-input {
  min-width: 100px;
}

.readonly-rent .subsection-title {
  margin: var(--space-3) 0 var(--space-2);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.editable-rent .table-wrap {
  overflow-x: auto;
}

.editable-rent .cell-input,
.editable-rent select {
  min-width: 112px;
}

.editable-rent .cell-input.text {
  min-width: 148px;
}

.rent-hub {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.rent-hub-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rent-hub-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.rent-hub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.rent-hub-kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.rent-hub-kpi-card {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.rent-hub-kpi-label {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.1;
}

.rent-hub-kpi-value {
  font-size: 20px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.rent-hub-kpi-ytd {
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.rent-hub-actions {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.rent-hub-actions-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rent-hub-actions-head h3 {
  margin: 0;
  font-size: 15px;
}

.rent-hub-action-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.rent-hub-action {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-3, #f8fafc);
  flex-wrap: wrap;
}

.rent-hub-action strong {
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}

.page-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  margin-bottom: 12px;
}

.page-tab {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-3, #f8fafc);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.page-tab:hover,
.page-tab:focus-visible {
  background: var(--surface);
  border-color: var(--accent, #6b8aff);
  outline: none;
}

.page-tab.is-active {
  background: var(--accent, #6b8aff);
  border-color: var(--accent, #6b8aff);
  color: #fff;
  font-weight: 500;
}

.page-tab[data-page-tab="__all__"] {
  border-style: dashed;
}

.page-tab[data-page-tab="__all__"].is-active {
  border-style: solid;
}

.page-tab-panel {
  min-width: 0;
}

.rent-row-index {
  width: 1%;
  white-space: nowrap;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  cursor: help;
}

.combined-breakdown-total td {
  background: var(--surface-3, #f8fafc);
  border-top: 2px solid var(--line);
}

.combined-row-settled td {
  background: rgba(16, 185, 129, 0.08);
  color: var(--text-2, #475569);
}

.combined-row-settled td:first-child {
  border-left: 3px solid rgba(16, 185, 129, 0.55);
}

.settlement-hero {
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--line, #e2e8f0);
  background: var(--surface-2, #ffffff);
  display: inline-flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.settlement-hero-open {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.06), rgba(99, 102, 241, 0.02));
  border-color: rgba(99, 102, 241, 0.35);
}

.settlement-hero-closed {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.06), rgba(16, 185, 129, 0.02));
  border-color: rgba(16, 185, 129, 0.35);
}

.settlement-hero-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-2, #64748b);
  padding: 2px 8px;
  background: rgba(148, 163, 184, 0.16);
  border-radius: 999px;
  white-space: nowrap;
}

.settlement-hero-direction {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: var(--text-1, #0f172a);
}

.settlement-hero-arrow {
  color: var(--text-2, #64748b);
  font-weight: 400;
}

/* Phase D.7 — aggregate widget for open settlements across multiple
   counterparties. Sits above the per-counterparty selector when ≥2
   counterparties have a non-zero open balance. */
/* Phase G.2 — виджет «Открытые взаиморасчёты» одной строкой. Каждый
   открытый долг — clickable chip, между ними расстояние из flex-gap.
   Только counterparty с balance ≠ 0 попадают, без «нет долга»-плашек. */
.rent-shared-open-balances {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 14px 0;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.05);
  border: 1px solid rgba(99, 102, 241, 0.15);
}

.rent-shared-open-balances-empty {
  background: rgba(148, 163, 184, 0.06);
  border-color: rgba(148, 163, 184, 0.18);
}

.rent-shared-open-eyebrow {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2, #475569);
  white-space: nowrap;
}

.rent-shared-open-chip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rent-shared-open-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border-1, #cbd5e1);
  border-radius: 999px;
  background: var(--surface-1, #fff);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-1, #0f172a);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.rent-shared-open-chip:hover {
  border-color: var(--accent-1, #6366f1);
  box-shadow: 0 1px 4px rgba(99, 102, 241, 0.18);
}

.rent-shared-open-chip-active {
  border-color: var(--accent-1, #6366f1);
  background: rgba(99, 102, 241, 0.1);
}

.rent-shared-open-sep {
  color: var(--text-2, #94a3b8);
}

.rent-shared-open-cp {
  font-weight: 600;
}

.rent-shared-open-prose {
  font-variant-numeric: tabular-nums;
  color: var(--text-2, #475569);
}

/* Phase E.3 — компактная карточка контрагента + список article-правил.
   Owner: «у тебя сейчас здесь очень-очень-очень это всё размазано, не
   помещается в экран». Целимся в одну строку на header, одну на базовое
   правило, и однострочные article rules без табличной сетки. */
.rent-shared-cp-block {
  border: 1px solid var(--border-1, #e2e8f0);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 10px 0;
  background: var(--surface-1, #fff);
}

.rent-shared-cp-block.rent-asset-inactive {
  opacity: 0.55;
}

.rent-shared-cp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.rent-shared-cp-row .cell-input {
  min-width: 0;
}

.rent-shared-cp-row > input[type="text"]:nth-of-type(1) {
  flex: 1 1 200px;
  min-width: 160px;
  font-weight: 600;
}

.rent-shared-cp-row > input[type="text"]:nth-of-type(2) {
  flex: 2 1 240px;
  min-width: 200px;
}

.rent-shared-cp-base-rule {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0 6px 0;
  padding: 8px 10px;
  background: rgba(241, 245, 249, 0.55);
  border-radius: 6px;
  font-size: 13px;
}

.rent-shared-cp-base-rule input[type="number"] {
  width: 70px;
  text-align: right;
}

.rent-shared-cp-base-rule select {
  min-width: 160px;
}

.rent-shared-cp-base-label {
  font-weight: 600;
  color: var(--text-1, #0f172a);
}

.rent-shared-cp-base-suffix {
  color: var(--text-2, #475569);
}

.rent-shared-cp-base-hint {
  font-size: 11px;
}

.rent-shared-cp-rules {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.rent-shared-cp-rules-eyebrow {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2, #64748b);
}

.rent-shared-cp-rules-empty {
  margin: 4px 0;
  font-size: 12px;
}

.rent-shared-article-rule-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 4px 6px;
  border: 1px dashed var(--border-1, #e2e8f0);
  border-radius: 6px;
  background: rgba(248, 250, 252, 0.6);
  font-size: 13px;
}

.rent-shared-article-rule-row select {
  flex: 1 1 160px;
  min-width: 140px;
}

.rent-shared-article-rule-row input[type="number"] {
  width: 64px;
  text-align: right;
}

.rent-shared-article-rule-percent {
  color: var(--text-2, #475569);
}

/* Phase E.5 — monthly drill-down without per-month subtotal rows.
   First charge of each month gets a stronger top border so months
   stay visually separated. Settlement dividers (rendered between
   periods) use the same accent on top. */
.rent-shared-month-boundary > td {
  border-top: 2px solid var(--border-1, #cbd5e1);
}

.rent-shared-settlement-divider > td {
  background: rgba(16, 185, 129, 0.08);
  border-top: 2px solid rgba(16, 185, 129, 0.4);
  border-bottom: 1px solid rgba(16, 185, 129, 0.2);
  font-style: italic;
}

/* Phase H.1 — top-level Система mode (UI prefs + Audit log).
   Простые pill-tabs сверху + панели контента ниже. Сохраняем тот
   же визуальный язык что и rent / combined section tabs. */
.system-mode-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.system-mode-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.system-mode-tab {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-1, #cbd5e1);
  background: var(--surface-1, #fff);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-1, #0f172a);
  transition: border-color 0.15s, background 0.15s;
}

.system-mode-tab:hover {
  border-color: var(--accent-1, #6366f1);
}

.system-mode-tab.is-active {
  background: var(--accent-1, #6366f1);
  border-color: var(--accent-1, #6366f1);
  color: #fff;
}

.ui-prefs-inline {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0;
}

/* Phase F.8 — бегущая строка для длинных «Примечание» / «Заметка».
   Применяется ко всем read-only ячейкам note через `marqueeText(text)`
   helper. По умолчанию текст обрезан ellipsis-ом; на hover (если
   реально overflow) внутренний span медленно прокручивается, owner
   видит весь текст без скачка к новой странице. Title-tooltip
   дублирует full text как мгновенный fallback. */
.oblik-marquee {
  display: inline-block;
  max-width: 240px;
  overflow: hidden;
  white-space: nowrap;
  vertical-align: middle;
  cursor: help;
  position: relative;
}

.oblik-marquee .oblik-marquee-inner {
  display: inline-block;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 100%;
  overflow: hidden;
  vertical-align: middle;
}

.oblik-marquee:hover .oblik-marquee-inner {
  max-width: none;
  animation: oblik-marquee-scroll 10s linear infinite;
  text-overflow: clip;
}

@keyframes oblik-marquee-scroll {
  0%, 10% { transform: translateX(0); }
  90%, 100% { transform: translateX(calc(-100% + 240px)); }
}

/* Phase F.5 — приглушённая «Зафиксировать» на ранее незакрытых
   месяцах (backdate). На latest unsettled месяце остаётся primary. */
.btn.rent-shared-settle-secondary {
  background: transparent;
  color: var(--accent-1, #6366f1);
  border: 1px dashed var(--accent-1, #6366f1);
  opacity: 0.75;
}

.btn.rent-shared-settle-secondary:hover {
  opacity: 1;
  background: rgba(99, 102, 241, 0.05);
}

/* Phase G.3 — owner: «Не делить этот раз нужно в таком же стиле, как
   Иван Стефанов по правилу. Такой же размер кнопки, такой же размер
   шрифта. Может отличаться по цвету». Кнопка теперь pill-badge той
   же высоты что .tag — visually две одинаковые pill-таблетки одна
   под другой, отличаются только цветом. */
.rent-shared-flag-cell {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  max-width: 220px;
}

.rent-shared-flag-cell .tag,
.rent-shared-flag-btn.btn,
.rent-shared-flag-btn {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 650;
  line-height: 1.25;
  white-space: nowrap;
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--surface-1, #fff);
}

.rent-shared-flag-auto .tag {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.35);
  color: rgb(67, 56, 202);
}

.rent-shared-flag-excluded .tag {
  background: rgba(148, 163, 184, 0.18);
  border-color: rgba(100, 116, 139, 0.35);
  color: var(--text-2, #475569);
}

.rent-shared-flag-auto .rent-shared-flag-btn {
  background: var(--surface-1, #fff);
  border-color: rgba(100, 116, 139, 0.35);
  color: var(--text-2, #475569);
}

.rent-shared-flag-auto .rent-shared-flag-btn:hover {
  background: rgba(148, 163, 184, 0.12);
}

.rent-shared-flag-excluded .rent-shared-flag-btn {
  background: rgba(99, 102, 241, 0.06);
  border-color: rgba(99, 102, 241, 0.35);
  color: rgb(67, 56, 202);
}

.rent-shared-flag-excluded .rent-shared-flag-btn:hover {
  background: rgba(99, 102, 241, 0.14);
}

.oblik-print-actions {
  display: flex;
  gap: 8px;
  margin: 12px 0;
  flex-wrap: wrap;
}

.oblik-print-actions .btn {
  text-decoration: none;
}

.settlement-hero-prose {
  display: block;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-1, #0f172a);
  margin-bottom: 4px;
}

.settlement-hero-amount {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-1, #0f172a);
  line-height: 1.1;
  white-space: nowrap;
}

.settlement-hero-currency {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2, #64748b);
}

.combined-amount-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  line-height: 1.2;
}

.combined-amount-main {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-1, #0f172a);
}

.combined-amount-delta {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  opacity: 0.85;
}

.combined-delta-up {
  color: rgb(180, 83, 9);
}

.combined-delta-down {
  color: rgb(15, 118, 110);
}

.combined-delta-muted {
  color: var(--text-3, #94a3b8);
  font-size: 12px;
}

.combined-direction-arrow {
  font-weight: 500;
  white-space: nowrap;
}

.combined-direction-paritet {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  color: var(--text-2, #64748b);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.combined-settle-btn {
  white-space: nowrap;
}

.combined-settled-badge {
  white-space: nowrap;
}

/* Pyramid layout: total centered on top, rent left and solar right below.
   Uses inline-flex so the cell shrinks to content width — the breakdown row
   defines width (rent + small gap + solar) and total naturally centers above
   it. No `space-between` edges, no min-width forcing the column wider. */
.combined-party-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.combined-party-header-name {
  font-weight: 600;
  color: var(--text-1, #0f172a);
}

.combined-party-header-hint {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  opacity: 0.85;
  color: var(--text-2, #64748b);
}

.combined-party-header-plus {
  color: var(--text-3, #94a3b8);
  margin: 0 1px;
  font-weight: 600;
}

.combined-party-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  line-height: 1.2;
}

.combined-party-total {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-1, #0f172a);
}

/* Phase G.1 — breakdown в одну строку «Аренда + Взаиморасчёт + Солнце».
   Все компоненты inline-flex с разделителем-span « + », без переноса. */
.combined-party-breakdown {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  opacity: 0.95;
  line-height: 1.3;
}

.combined-party-breakdown-rent {
  color: rgb(79, 70, 229);
  white-space: nowrap;
}

.combined-party-breakdown-settlement {
  color: rgb(16, 185, 129);
  white-space: nowrap;
}

.combined-party-breakdown-solar {
  color: rgb(217, 119, 6);
  white-space: nowrap;
}

.combined-party-breakdown-plus {
  color: var(--text-2, #64748b);
  padding: 0 2px;
  font-weight: 500;
}

.combined-party-breakdown-empty {
  color: var(--text-3, #cbd5e1);
}


.page-tab-panel.is-all {
  display: grid;
  gap: 14px;
}

.page-tab-panel.is-all > .page-tab-panel-section + .page-tab-panel-section {
  border-top: 1px dashed var(--line);
  padding-top: 14px;
}

.rent-asset-inactive td {
  opacity: 0.55;
  background: rgba(148, 163, 184, 0.06);
}

.rent-review-scope-hint {
  margin: 0 0 10px;
  padding: 6px 12px;
  border-left: 3px solid var(--line);
  background: rgba(148, 163, 184, 0.08);
  border-radius: 4px;
  font-size: 12.5px;
}

/* Muted state: month picker stays visible to preserve layout, but click is
   blocked and visual cue says "this tab does not depend on month". */
.rent-month-tabs-muted {
  opacity: 0.45;
  filter: grayscale(0.6);
  cursor: not-allowed;
}

.rent-month-tabs-muted .tab {
  pointer-events: none;
}

.rent-month-status {
  display: grid;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.rent-month-status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.rent-month-status-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.rent-month-status-details {
  display: block;
  margin-top: 2px;
}

.rent-month-status-details > summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  padding: 4px 0;
  list-style: none;
  user-select: none;
}

.rent-month-status-details > summary::-webkit-details-marker {
  display: none;
}

.rent-month-status-details > summary::after {
  content: " ▾";
  font-size: 10px;
  color: var(--muted);
}

.rent-month-status-details[open] > summary::after {
  content: " ▴";
}

.rent-close-checklist-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.rent-close-checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--surface-3, #f8fafc);
  flex-wrap: wrap;
}

.rent-close-checklist-item strong {
  font-variant-numeric: tabular-nums;
}

.rent-close-checklist-item .btn {
  margin-left: auto;
}

.rent-ledger-sticky-summary {
  position: sticky;
  top: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 10px;
  padding: 10px 0;
  margin-bottom: 8px;
  background: linear-gradient(180deg, var(--surface) 0%, rgba(255, 255, 255, .94) 100%);
  border-bottom: 1px solid var(--line);
}

.rent-ledger-sticky-summary .metric-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
}

.rent-ledger-sticky-summary .metric-card span,
.rent-ledger-sticky-summary .metric-card small {
  color: var(--muted);
}

.rent-ledger-sticky-summary .metric-card strong {
  display: block;
  margin: 4px 0 2px;
  font-size: 18px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.rent-ledger-dual-pane {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.rent-ledger-pane {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.rent-ledger-pane .subsection-title {
  margin: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-3);
}

.rent-ledger-pane .table-wrap {
  border: 0;
  border-radius: 0;
}

.ledger-inline-fields {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px;
  background: var(--surface-3, #f8fafc);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ledger-compact-field {
  display: grid;
  grid-template-columns: minmax(92px, 110px) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ledger-compact-field span {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.2;
  margin: 0;
  text-align: right;
}

.ledger-compact-field input,
.ledger-compact-field select {
  width: 100%;
  min-width: 0;
}

.ledger-currency-toggle {
  display: block;
  min-width: 0;
}

.ledger-currency-toggle > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--muted);
  list-style: none;
  user-select: none;
  white-space: nowrap;
}

.ledger-currency-toggle > summary::-webkit-details-marker {
  display: none;
}

.ledger-currency-toggle > summary::after {
  content: "▾";
  font-size: 10px;
  color: var(--muted);
  margin-left: 2px;
}

.ledger-currency-toggle[open] > summary::after {
  content: "▴";
}

.ledger-currency-toggle[open] > summary {
  margin-bottom: 6px;
  border-style: solid;
  color: var(--text);
}

.ledger-currency-default {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.ledger-currency-summary {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.ledger-row-hint {
  display: grid;
  gap: 4px;
  margin-top: 5px;
}

.ledger-row-hint small {
  color: var(--muted);
}

.ledger-compact-field {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.ledger-compact-field span {
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.1;
}

.tag {
  display: inline-block;
  flex: 0 0 auto;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid #bad5e8;
  background: #f0f7fc;
  color: var(--info);
  font-size: 11px;
  line-height: 1.2;
}

.tag.warn {
  border-color: #e6cc9f;
  background: #fff7e8;
  color: var(--warn);
}

.tag.ok {
  border-color: #b7dfca;
  background: var(--ok-soft);
  color: var(--ok);
}

.tag.info {
  border-color: #bad5e8;
  background: var(--info-soft);
  color: var(--info);
}

.meter-select-cell {
  display: grid;
  gap: 2px;
  justify-items: center;
}

.template-layout {
  display: grid;
  gap: 10px;
  padding: 10px;
}

.template-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 8px;
}

.template-switcher {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.template-chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.template-other {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.template-create {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.template-create label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.template-layout h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.template-list {
  display: grid;
  gap: 10px;
}

.template-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.template-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.template-meta label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.template-section {
  border-top: 1px solid var(--line);
  padding-top: 8px;
  margin-top: 8px;
}

.template-section-head,
.template-row-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.template-row {
  display: grid;
  gap: 6px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  padding: 6px;
  margin-top: 6px;
  background: #fbfdfc;
}

.template-fields {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.template-field {
  display: flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  padding: 4px;
}

.template-field select {
  min-width: 88px;
  height: 29px;
  padding: 3px 5px;
  font-size: 12px;
}

.template-field select.template-visible {
  min-width: 92px;
}

.template-field input.cell-input.text {
  width: 130px;
  height: 29px;
  padding: 3px 5px;
  font-size: 12px;
}

.drag-handle {
  color: var(--muted);
  cursor: grab;
  user-select: none;
}

.template-service-table {
  margin-top: 8px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fbfa;
  color: var(--muted);
  font-size: 12px;
}

.requisites-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(190px, 1fr));
  gap: 8px;
}

.requisites-grid label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.requisites-grid input.cell-input.text {
  width: 100%;
  height: 30px;
}

.document-toolbar {
  display: grid;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f8f6;
}

.invoice-preview-controls,
.invoice-filters {
  display: grid;
  grid-template-columns: minmax(280px, 2fr) minmax(180px, 1fr) minmax(260px, auto);
}

.invoice-preview-controls label,
.invoice-filters label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--ink);
  font-weight: 600;
}

.invoice-preview-controls select,
.invoice-filters select,
.invoice-filters input {
  width: 100%;
  height: 36px;
}

.invoice-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.invoice-preview-frame {
  display: block;
  width: 100%;
  min-height: 620px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.readme-block {
  padding: 14px 16px;
  line-height: 1.5;
}

.readme-block p {
  max-width: 980px;
}

.status {
  display: inline-block;
  min-width: 28px;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f8fbfa;
  text-align: center;
  font-size: 12px;
}

.status-col {
  width: 74px;
  min-width: 74px;
  text-align: center;
}

.col-check {
  width: 74px;
  min-width: 74px;
}

.status-wrap {
  position: relative;
  display: inline-flex;
  justify-content: center;
}

/* M.13a — Контроль: цветной dot вместо emoji-status в compact-таблице.
   Сохраняем тот же tooltip-механизм через data-status-detail. */
.control-dot-wrap {
  position: relative;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  cursor: help;
  outline: none;
}

.control-dot-wrap:focus-visible {
  box-shadow: 0 0 0 2px var(--accent-1, #6366f1);
  border-radius: 50%;
}

.control-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid transparent;
  flex-shrink: 0;
}

.control-dot[data-tone="ok"] {
  background: #16a34a;
  border-color: rgba(22, 163, 74, 0.3);
}

.control-dot[data-tone="warn"] {
  background: #f59e0b;
  border-color: rgba(245, 158, 11, 0.35);
}

.control-dot[data-tone="error"] {
  background: #ef4444;
  border-color: rgba(239, 68, 68, 0.35);
}

.control-dot[data-tone="info"] {
  background: #6366f1;
  border-color: rgba(99, 102, 241, 0.35);
}

.control-dot[data-tone="muted"] {
  background: var(--text-muted, #9ca3af);
  border-color: var(--border, #e6e8ec);
}

/* M.13a — KPI «Состояние года» сверху страницы. 4 карточки в ряд. */
.control-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

@media (max-width: 900px) {
  .control-kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.control-kpi-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border, #e6e8ec);
  border-radius: 10px;
  background: var(--card, #fff);
}

.control-kpi-card[data-tone="ok"] {
  border-color: rgba(22, 163, 74, 0.35);
  background: rgba(22, 163, 74, 0.05);
}

.control-kpi-card[data-tone="warn"] {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.05);
}

.control-kpi-card[data-tone="error"] {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.05);
}

.control-kpi-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted, #9ca3af);
}

.control-kpi-card[data-tone="ok"] .control-kpi-dot { background: #16a34a; }
.control-kpi-card[data-tone="warn"] .control-kpi-dot { background: #f59e0b; }
.control-kpi-card[data-tone="error"] .control-kpi-dot { background: #ef4444; }

.control-kpi-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.control-kpi-label {
  font-size: 11px;
  color: var(--text-muted, #6b7280);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.control-kpi-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--text, #111827);
}

.control-kpi-hint {
  font-size: 11px;
}

/* M.13d — Контроль использует общий `.input-v2-table .solar-matrix`
   стиль (rounded month-pick, zebra, sticky первая колонка) — не
   дублируем CSS. Здесь только Контроль-специфика поверх. */

.control-matrix .control-check-cell {
  /* Центрирование dot в ячейке статуса; sizing наследуется от
     .input-v2-cell-status. */
  text-align: center;
}

.control-matrix .control-check-row-final th.input-v2-row-label,
.control-matrix .control-check-row-final td.input-v2-cell {
  /* «Итог» — итоговая строка матрицы. Чуть выделена бордером
     сверху и жирностью. */
  border-top: 1px solid var(--border, #e6e8ec);
  font-weight: 600;
}

/* M.13a — Сигналы: группировка по месяцу. Заголовок группы — лёгкая
   полоска. Цвет уровня — слева на строке. */
.control-signal-group th {
  background: var(--bg-soft, #f9fafb);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted, #6b7280);
  text-align: left;
  padding: 6px 10px;
  font-weight: 600;
  border-top: 1px solid var(--border, #e6e8ec);
}

/* M.13e — выбранный месяц подсвечен и поднят в начало списка сигналов. */
.control-signal-group.is-selected-month th {
  background: rgba(99, 102, 241, 0.10);
  color: var(--accent-1, #6366f1);
  border-top: 1px solid rgba(99, 102, 241, 0.35);
  box-shadow: inset 3px 0 0 var(--accent-1, #6366f1);
}

.control-signal-row.is-selected-month {
  background: rgba(99, 102, 241, 0.04);
}

.control-signal-empty-selected td {
  padding: 10px 12px;
  background: rgba(22, 163, 74, 0.06);
  color: var(--text, #111827);
  font-size: 13px;
  border-top: 1px solid rgba(22, 163, 74, 0.30);
  box-shadow: inset 3px 0 0 #16a34a;
}

.control-signal-empty-selected .control-dot {
  vertical-align: middle;
  margin-right: 6px;
}

.control-signal-row[data-tone="error"] {
  box-shadow: inset 3px 0 0 #ef4444;
}

.control-signal-row[data-tone="warn"] {
  box-shadow: inset 3px 0 0 #f59e0b;
}

.control-signal-row[data-tone="info"] {
  box-shadow: inset 3px 0 0 #6366f1;
}

/* M.13a/b — новая раскладка сигналов: 3 колонки. Уровень+раздел /
   Сигнал и числа (заголовок + список) / Что проверить (список). */
.control-signals-table {
  table-layout: fixed;
  width: 100%;
}

.control-signals-th-level { width: 14%; }
.control-signals-th-detail { width: 46%; }
.control-signals-th-actions { width: 40%; }

.control-signals-table td {
  vertical-align: top;
  padding: 10px 12px;
}

.control-signal-level {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-signal-section-label {
  font-weight: 500;
  font-size: 13px;
}

.control-signal-detail {
  font-variant-numeric: tabular-nums;
}

.control-signal-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text, #111827);
}

.control-signal-numbers {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.control-signal-numbers li {
  font-size: 12.5px;
  line-height: 1.45;
}

.control-signal-num {
  display: inline;
}

.control-signal-num strong {
  font-weight: 600;
}

.control-signal-num.warn strong { color: #d97706; }
.control-signal-num.info strong { color: #6366f1; }

.control-signal-actions ul.control-signal-actions-list {
  list-style: disc;
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.control-signal-actions ul.control-signal-actions-list li {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-muted, #4b5563);
}

.control-signal-text-line {
  display: block;
  font-size: 12.5px;
  line-height: 1.45;
}

.status-tooltip {
  display: none;
}

.status-floating-tooltip {
  position: fixed;
  z-index: 1400;
  width: max-content;
  max-width: 320px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #13201b;
  color: #fff;
  padding: 7px 9px;
  box-shadow: 0 12px 30px rgba(18, 32, 26, .22);
  white-space: normal;
  text-align: left;
  font-size: 12px;
  line-height: 1.35;
}

.status-floating-tooltip.tooltip-left {
  text-align: left;
}

.status-floating-tooltip.tooltip-below {
  box-shadow: 0 10px 24px rgba(18, 32, 26, .2);
}

.money-explain {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.money-explain-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--info);
  font-size: 10px;
  line-height: 1;
}

.status.ok {
  color: var(--ok);
  border-color: #b9dbc9;
  background: #eff8f3;
}

.status.info {
  color: var(--info);
  border-color: #bad5e8;
  background: #f0f7fc;
}

.status.warn {
  color: var(--warn);
  border-color: #e6cc9f;
  background: #fff7e8;
}

.status.error {
  color: var(--error);
  border-color: #e4b6b6;
  background: #fff1f1;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, .45fr);
  gap: 14px;
}

.side-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.issue {
  border: 1px solid var(--line);
  border-left: 4px solid var(--info);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.issue.warn {
  border-left-color: var(--warn);
}

.issue.error {
  border-left-color: var(--error);
}

.issue strong {
  display: block;
  margin-bottom: 4px;
}

@media (max-width: 980px) {
  .app,
  .app.is-sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    height: auto;
    overflow: visible;
    padding: 12px;
  }

  .brand {
    padding-bottom: 10px;
  }

  .nav {
    display: flex;
    overflow-x: auto;
    margin-top: 10px;
  }

  .nav-btn {
    white-space: nowrap;
    width: auto;
  }

  .main {
    padding: 14px;
  }

  .topbar,
  .panel-head,
  .two-col {
    display: block;
  }

  .actions {
    justify-content: flex-start;
    margin-top: 12px;
  }

  .dashboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .auth-create-grid {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .auth-permission-grid {
    min-width: 0;
  }

  .auth-permission-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* Phase 4 final Mercury overrides. Kept last intentionally. */
.app {
  grid-template-columns: 240px minmax(0, 1fr);
  background: var(--bg);
}

.app.is-sidebar-collapsed {
  grid-template-columns: 68px minmax(0, 1fr);
}

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  border-right: 1px solid var(--sidebar-line);
  padding: 18px 12px;
}

.brand {
  padding: 6px 8px 14px;
  gap: 10px;
  border-bottom: 1px solid var(--sidebar-line);
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, #605bff 0%, #b388ff 100%);
  font-size: 14px;
  font-weight: 700;
  position: relative;
  overflow: hidden;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 5px 5px auto auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,.5);
}

.brand-text strong {
  display: block;
  font-size: 15px;
  font-weight: 650;
}

.brand span {
  color: var(--sidebar-muted);
  font-size: 11px;
}

.sidebar-toggle {
  width: 28px;
  height: 28px;
  border-color: var(--sidebar-line);
  background: var(--sidebar-active-bg);
  color: var(--sidebar-muted);
  border-radius: 8px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 14px;
}

.nav-section {
  display: block;
  margin: 14px 8px 6px;
  color: var(--sidebar-muted);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--sidebar-ink);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  color: var(--sidebar-muted);
  flex-shrink: 0;
}

.nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-btn:hover,
.nav-btn.is-active {
  background: var(--sidebar-active-bg);
  color: #fff;
}

.nav-btn.is-active .nav-icon {
  color: #fff;
}

.app.is-sidebar-collapsed .sidebar {
  padding: 18px 10px;
}

.app.is-sidebar-collapsed .brand {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 4px 0 14px;
}

.app.is-sidebar-collapsed .brand-text,
.app.is-sidebar-collapsed .nav-section,
.app.is-sidebar-collapsed .nav-label {
  display: none;
}

.app.is-sidebar-collapsed .nav-btn {
  justify-content: center;
  padding: 9px 0;
  font-size: 13.5px;
}

.app.is-sidebar-collapsed .nav-btn::first-letter {
  font-size: inherit;
}

.app.is-sidebar-collapsed .sidebar-toggle {
  position: static;
  flex: 0 0 auto;
}

/* Sidebar v2 polish — owner context + bottom user card. */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  position: relative;
  padding-right: 34px;
}

.brand-text {
  display: flex;
  align-items: center;
  min-width: 0;
}

.brand-text strong {
  line-height: 1.1;
}

.brand span {
  display: none;
}

.sidebar-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-left: 0;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 999px;
  background: rgba(255,255,255,.045);
  color: var(--sidebar-muted);
  box-shadow: 0 8px 18px rgba(0,0,0,.16);
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}

.sidebar-toggle:hover {
  border-color: rgba(255,255,255,.16);
  background: var(--sidebar-active-bg);
  color: var(--sidebar-ink);
  transform: translateY(calc(-50% - 1px));
}

.nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 18px;
}

.sidebar-context {
  margin: 18px 0 12px;
  padding: 0;
  border: 0;
  background: transparent;
}

.context-title {
  display: none;
}

.context-controls {
  display: grid;
  gap: 12px;
}

.context-field {
  position: relative;
  display: grid;
  gap: 8px;
}

.context-label {
  padding-left: 2px;
  color: var(--sidebar-muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.context-select-shell {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 48px;
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 14px;
  background: rgba(255,255,255,.055);
}

.context-select-button {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 14px;
  background: rgba(255,255,255,.055);
  color: var(--sidebar-ink);
  padding: 0 42px 0 42px;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}

.context-select-button:hover,
.context-select-button[aria-expanded="true"] {
  border-color: rgba(96, 91, 255, .55);
  background: rgba(96, 91, 255, .14);
  box-shadow: 0 0 0 3px rgba(96, 91, 255, .12);
}

.context-select-value {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-select-chevron {
  position: absolute;
  right: 16px;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid rgba(230, 231, 236, .72);
  border-bottom: 1.5px solid rgba(230, 231, 236, .72);
  transform: rotate(45deg) translateY(-2px);
  pointer-events: none;
}

.context-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 70;
  display: grid;
  gap: 4px;
  padding: 6px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 14px;
  background: #121820;
  box-shadow: 0 18px 42px rgba(0,0,0,.34);
}

.context-menu-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--sidebar-ink);
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
}

.context-menu-option:hover,
.context-menu-option.is-active {
  background: rgba(96, 91, 255, .16);
}

.context-menu-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(96, 91, 255, .11);
  flex: 0 0 auto;
}

.context-menu-spacer {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
}

.context-menu-text {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-select-shell::after {
  content: "";
  position: absolute;
  right: 16px;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid rgba(230, 231, 236, .72);
  border-bottom: 1.5px solid rgba(230, 231, 236, .72);
  transform: rotate(45deg) translateY(-2px);
  pointer-events: none;
}

.context-dot {
  position: absolute;
  left: 16px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(96, 91, 255, .12);
  pointer-events: none;
}

.context-controls select {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--sidebar-ink);
  padding: 0 36px 0 42px;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.2;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
}

.nav-children {
  border-left: 0;
}

.sidebar-user {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 58px;
  margin-top: auto;
  padding: 14px 8px 4px;
  border-top: 1px solid var(--sidebar-line);
}

.sidebar-user-button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  padding: 6px;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color .15s ease;
}

.sidebar-user-button:hover,
.sidebar-user-button[aria-expanded="true"] {
  background: rgba(255,255,255,.06);
}

.sidebar-user-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #605bff 0%, #7c5cff 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  flex: 0 0 auto;
}

.sidebar-user-meta {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.sidebar-user-meta strong {
  overflow: hidden;
  color: var(--sidebar-ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-meta span {
  overflow: hidden;
  color: var(--sidebar-muted);
  font-size: 12px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-menu {
  position: absolute;
  right: 8px;
  bottom: 64px;
  left: 8px;
  z-index: 40;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 12px;
  background: #121820;
  box-shadow: 0 18px 42px rgba(0,0,0,.34);
}

.sidebar-user-menu-head {
  display: grid;
  gap: 3px;
  padding: 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-user-menu-head strong {
  color: var(--sidebar-ink);
  font-size: 13px;
  line-height: 1.2;
}

.sidebar-user-menu-head span {
  overflow: hidden;
  color: var(--sidebar-muted);
  font-size: 12px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-menu-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--sidebar-ink);
  padding: 11px 12px;
  text-align: left;
  cursor: pointer;
}

.sidebar-user-menu-item:hover {
  background: rgba(255,255,255,.07);
}

.app.is-sidebar-collapsed .sidebar-user {
  justify-content: center;
  padding: 12px 0 4px;
}

.app.is-sidebar-collapsed .sidebar-user-button {
  justify-content: center;
  padding: 4px 0;
}

.app.is-sidebar-collapsed .sidebar-user-meta {
  display: none;
}

.app.is-sidebar-collapsed .sidebar-user-menu {
  right: auto;
  bottom: 8px;
  left: calc(100% + 10px);
  width: 220px;
}

.app.is-sidebar-collapsed .brand {
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  padding: 8px 3px;
}

.app.is-sidebar-collapsed .brand-mark {
  width: 28px;
  height: 28px;
}

.app.is-sidebar-collapsed .sidebar-toggle {
  position: static;
  width: 18px;
  height: 22px;
  margin: 0;
  font-size: 11px;
  transform: none;
  box-shadow: none;
}

.app.is-sidebar-collapsed .sidebar-toggle:hover {
  transform: translateY(-1px);
}

.main {
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--bg);
}

.topbar {
  margin: 0;
  padding: 14px var(--pad-x);
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -.01em;
}

.actions {
  align-items: center;
  gap: 8px;
  margin-top: 0;
}

.control-chip {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 12px;
}

.control-chip select {
  min-width: 92px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
}

.auth-chip {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 4px 10px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.notices,
.dashboard,
.content {
  margin-left: var(--pad-x);
  margin-right: var(--pad-x);
}

.content {
  padding-bottom: var(--pad-y);
}

.dashboard {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-top: var(--pad-y);
  margin-bottom: 18px;
}

.metric,
.panel,
.card,
.notice,
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.metric {
  min-height: 96px;
  padding: 16px 18px;
}

.metric strong {
  color: var(--ink);
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -.02em;
}

.page {
  padding: 0 0 var(--pad-y);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  gap: 16px;
}

.page-title {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -.02em;
}

.page-sub {
  color: var(--muted);
  font-size: 13.5px;
}

.page-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr);
  gap: 14px;
}

.card {
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}

.card-pad {
  padding: 18px 20px;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 18px;
}

.quick-action {
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-3);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.quick-action span {
  color: var(--accent);
}

.flow-lane {
  display: grid;
  grid-template-columns: minmax(130px, .8fr) 22px minmax(180px, 1fr) 22px minmax(130px, .8fr);
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-3);
}

.pill-node {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  border-color: var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 550;
  padding: 7px 14px;
  box-shadow: none;
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  box-shadow: none;
}

.btn-primary,
.btn-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-small {
  min-height: 28px;
  padding: 4px 10px;
  font-size: 12.5px;
}

.btn-icon {
  width: 34px;
  padding: 0;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 38px;
  padding: 8px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 550;
}

.tab.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.panel-head {
  background: var(--surface);
  padding: 14px 18px;
}

.panel-head h2 {
  font-size: 15px;
  font-weight: 650;
}

th,
td {
  border-right: 0;
  border-bottom: 1px solid var(--line-2);
  padding: 7px 9px;
  font-size: 12.5px;
}

th {
  background: var(--table-head);
  color: var(--ink-2);
  font-weight: 650;
  padding: 6px 9px;
}

input.cell-input,
select,
.month-picker-button {
  min-height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--input);
  color: var(--ink);
}

.toggle-control {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 22px;
  cursor: pointer;
}

.toggle-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--line-strong);
  position: relative;
  transition: background-color .14s;
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15,17,21,.22);
  transition: transform .14s;
}

.toggle-control input:checked + .toggle-track {
  background: var(--accent);
}

.toggle-control input:checked + .toggle-track::after {
  transform: translateX(14px);
}

.settings-page {
  gap: 16px;
}

.settings-tabs {
  overflow-x: auto;
  scrollbar-width: thin;
}

.ui-prefs-panel {
  position: fixed;
  right: 18px;
  top: 72px;
  z-index: 1500;
  width: 304px;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.6);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 16px 44px rgba(15,17,21,.18);
}

.ui-prefs-head,
.ui-pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ui-pref-row {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 6px;
}

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 8px;
  background: var(--surface-2);
  width: 100%;
}

.segmented button {
  flex: 1 1 0;
  min-width: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  min-height: 24px;
  padding: 3px 9px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 550;
}

.segmented button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.badge,
.flow-service-chip,
.tag {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 650;
}

@media (max-width: 980px) {
  .app,
  .app.is-sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    height: auto;
    overflow: visible;
  }

  .nav {
    flex-direction: row;
    overflow-x: auto;
  }

  .nav-section {
    display: none;
  }

  .nav-btn {
    width: auto;
    min-width: max-content;
  }

  .topbar,
  .page-header,
  .overview-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .actions,
  .page-actions {
    justify-content: flex-start;
    margin-left: 0;
  }

  .dashboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-actions,
  .flow-lane {
    grid-template-columns: 1fr;
  }

  .rent-ledger-sticky-summary,
  .rent-cam-coverage-flow,
  .rent-cam-coverage-meta {
    grid-template-columns: 1fr;
  }

  .rent-ledger-sticky-summary {
    position: static;
  }
}

/* Phase D.3 — generic owner-facing radio modal (settlement receiver
   picker is the first user). Replaces window.prompt with a portal-style
   overlay that fits the existing design language. */
.oblik-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 24px;
}

.oblik-modal-card {
  background: var(--surface-1, #ffffff);
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  max-width: 480px;
  width: 100%;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.oblik-modal-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  color: var(--text-1, #0f172a);
}

.oblik-modal-prose {
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
  color: var(--text-2, #475569);
}

.oblik-modal-radio-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.oblik-modal-radio {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border-1, #e2e8f0);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.oblik-modal-radio:hover {
  border-color: var(--accent-1, #6366f1);
  background: rgba(99, 102, 241, 0.04);
}

.oblik-modal-radio input[type="radio"] {
  margin: 0;
  flex-shrink: 0;
}

.oblik-modal-radio-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text-1, #0f172a);
}

.oblik-modal-radio-hint {
  font-size: 12px;
  color: var(--text-2, #64748b);
}

.oblik-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Phase M.10 Step 4 — destructive modal flavour для cascade-delete. */
.oblik-modal-danger {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
}

.oblik-modal-danger:hover {
  background: #991b1b;
  border-color: #991b1b;
}

.oblik-modal-detail-list {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-1, #0f172a);
}

.oblik-modal-detail-list li {
  margin: 2px 0;
}

/* Phase M.10 Step 4 — three-state delete button в Аренда → Объекты. */
.rent-asset-delete-cascade {
  border-color: #b45309;
  color: #b45309;
}

.rent-asset-delete-cascade:hover:not(:disabled) {
  background: rgba(180, 83, 9, 0.08);
}

.rent-asset-delete-frozen,
.rent-asset-delete-no-permission {
  border-color: var(--border-1, #cbd5e1);
  color: var(--text-2, #64748b);
  cursor: not-allowed;
  opacity: 0.7;
}

/* Phase M.3.a — структура вкладки Счета: заголовок + KPI-карточки +
   tabbed page. Стили совместимы с density-compact/roomy через rem. */
.invoice-page {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.invoice-page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}

.invoice-page-title h2 {
  margin: 0 0 4px 0;
  font-size: 20px;
  font-weight: 700;
}

.invoice-page-title p {
  margin: 0;
  font-size: 13px;
}

.invoice-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.invoice-kpi-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  min-width: 0;
}

.invoice-kpi-card-muted {
  background: var(--card-muted, #fafafa);
  color: var(--text-2, #64748b);
}

.invoice-kpi-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2, #64748b);
  font-weight: 600;
}

.invoice-kpi-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-1, #0f172a);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.invoice-kpi-unit {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2, #64748b);
}

.invoice-kpi-hint {
  font-size: 11.5px;
  color: var(--text-2, #64748b);
}

@media (max-width: 1100px) {
  .invoice-kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Phase M.3.b — Шаблоны счетов как карточная сетка (2×2 на десктопе,
   1 колонка на узких экранах). Card-внутренний layout: title row,
   tag row, actions row. */
.invoice-template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 1100px) {
  .invoice-template-grid {
    grid-template-columns: 1fr;
  }
}

/* N.4 — раскрытая карта шаблона расширяется на всю ширину grid-а,
   чтобы редактор не теснился в полу-колонке. */
.invoice-template-card.is-open {
  grid-column: 1 / -1;
  border-color: var(--accent-1, #6366f1);
  box-shadow: inset 3px 0 0 var(--accent-1, #6366f1), 0 1px 8px rgba(99, 102, 241, 0.15);
}

/* N.4c-fix — focus mode: когда template editor открыт, прячем KPI
   ряд, саб-табы и panel-head («Шаблоны счетов» + описание).
   N.4d-fix — period-nav скрывается и в focus mode, и на саб-табе
   Шаблоны (бесполезен для template config). */
.invoice-page.is-template-focus .invoice-kpi-row,
.invoice-page.is-template-focus > nav.page-tabs,
.invoice-page.is-template-focus .page-tab-panel > .panel > .panel-head {
  display: none;
}

/* N.4d-fix — toolbar над сеткой шаблонов: заголовок + кнопка
   «+ Новый шаблон». Заменил panel-head, который был лишним. */
.invoice-template-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 12px 0;
}

.invoice-template-toolbar-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text, #111827);
}

/* В focus mode toolbar скрываем тоже (карта раскрыта на всю ширину). */
.invoice-page.is-template-focus .invoice-template-toolbar {
  display: none;
}

/* N.4c-fix — slim header в раскрытой карте: title + actions в одной
   строке, без subtitle/badges/tags. Это убирает ~40-60px вертикального
   шума и даёт editor / preview больше места. */
.invoice-template-card-header-compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0 8px 0;
  border-bottom: 1px solid var(--border, #e5e7eb);
}

.invoice-template-card-header-compact h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text, #111827);
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invoice-template-card-header-compact .invoice-template-card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.invoice-template-card.is-open {
  /* Уменьшаем внутренние отступы в open mode для компактности. */
  padding: 12px 14px;
  gap: 0;
}

/* N.4b — split layout: слева редактор, справа live-превью. */
.invoice-template-editor-inline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 16px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border, #e5e7eb);
}

@media (max-width: 1200px) {
  .invoice-template-editor-inline {
    grid-template-columns: 1fr;
  }
}

.invoice-template-editor-form {
  min-width: 0;
}

.invoice-template-editor-preview {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.invoice-template-preview-label {
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted, #6b7280);
}

.invoice-template-preview-frame {
  width: 100%;
  height: 700px;
  min-height: 600px;
  border: 1px solid var(--border, #e6e8ec);
  border-radius: 8px;
  background: #fff;
}

/* Inline-редактор внутри карты — те же template-* классы что в Настройках. */
.invoice-template-editor-inline .template-card {
  background: var(--bg-soft, #f9fafb);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  padding: 12px;
}

/* N.4d — шпаргалка-статусбар над editor: что заполнено / куда дальше. */
.invoice-template-statusbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  margin-top: 8px;
  font-size: 12px;
}

.template-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
  background: var(--bg-soft, #f3f4f6);
  color: var(--text-muted, #6b7280);
  border: 1px solid var(--border, #e6e8ec);
  white-space: nowrap;
}

.template-status-chip.ok {
  background: rgba(22, 163, 74, 0.10);
  color: #15803d;
  border-color: rgba(22, 163, 74, 0.30);
}

.template-status-chip.warn {
  background: rgba(245, 158, 11, 0.10);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.30);
}

.template-status-link {
  margin-left: auto;
  color: var(--accent-1, #6366f1);
  font-weight: 500;
  text-decoration: none;
}

.template-status-link:hover {
  text-decoration: underline;
}

/* N.5b — реквизиты постачальника inline в template editor (раскрываемый
   <details>, default открыт). Глобально на объект, не per-template. */
.template-supplier-section {
  margin: 10px 0;
  padding: 8px 10px;
  background: rgba(99, 102, 241, 0.04);
  border: 1px solid rgba(99, 102, 241, 0.20);
  border-radius: 6px;
}

.template-supplier-section > summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text, #111827);
  padding: 2px 0;
  user-select: none;
}

.template-supplier-section > summary:hover {
  color: var(--accent-1, #6366f1);
}

.template-supplier-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
  margin-top: 8px;
}

.template-supplier-grid label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
}

.template-supplier-grid label > span {
  color: var(--text-muted, #6b7280);
  font-weight: 500;
}

.template-supplier-grid input {
  font-size: 12px;
  padding: 3px 6px;
}

/* N.8 — template editor: dropdown «Постачальник» + hint о переезде. */
.template-supplier-controls {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
  margin-top: 8px;
}

.template-supplier-controls > label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  min-width: 240px;
  flex: 1;
}

.template-supplier-controls > label > span {
  color: var(--text-muted, #6b7280);
  font-weight: 500;
}

.template-supplier-hint {
  font-size: 11px;
  margin-top: 6px;
  font-style: italic;
}

/* N.8 / N.8a — вкладка «Реквизиты»: справочник поставщиков. Карточки
   в 2-колоночной сетке (auto-fill min 320px), в стиле .template-card. */
.supplier-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

.supplier-empty-text {
  font-size: 14px;
  max-width: 520px;
}

.supplier-page {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0 16px;
}

.supplier-page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.supplier-page-hint {
  font-size: 12px;
  color: var(--muted);
  max-width: 720px;
}

/* N.8b — сетка зеркалит .invoice-template-grid: фиксированные 2 колонки,
   на узких экранах падает в 1. Раньше был auto-fill 340px, но при
   открытом сайдбаре панель узкая и карта оставалась одна в ряду. */
.supplier-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 1100px) {
  .supplier-grid {
    grid-template-columns: 1fr;
  }
}

.supplier-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.supplier-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-2);
}

.supplier-card-name {
  flex: 1;
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.supplier-card-usage {
  font-size: 11.5px;
  color: var(--muted);
  padding: 2px 0;
}

.supplier-card-usage.is-free {
  color: var(--muted-2, #94a3b8);
  font-style: italic;
}

.supplier-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
}

.supplier-card-grid label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
}

.supplier-card-grid label > span {
  color: var(--muted);
  font-weight: 500;
}

.supplier-card-grid input {
  font-size: 12px;
  padding: 4px 7px;
}

.supplier-card-grid-wide {
  grid-column: 1 / -1;
}

.supplier-delete-btn {
  background: transparent;
  border: 1px solid var(--line);
  padding: 4px 6px;
  height: 26px;
  width: 26px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.supplier-delete-btn:hover:not(.is-blocked) {
  background: rgba(239, 68, 68, 0.10);
  border-color: rgba(239, 68, 68, 0.40);
  color: #b91c1c;
}

.supplier-delete-btn.is-blocked {
  opacity: 0.45;
  cursor: not-allowed;
}

/* N.4d — inline-помощь над секцией шапки: что есть Текст vs Поле. */
.template-field-help {
  font-size: 12px;
  margin: 8px 0;
  padding: 8px 10px;
  background: rgba(99, 102, 241, 0.06);
  border-left: 3px solid var(--accent-1, #6366f1);
  border-radius: 4px;
  color: var(--text, #111827);
}

/* N.4e — flash-подсветка ячейки/строки в Настройках, когда туда
   перенаправили кликом из карты шаблона. 2-секундная вспышка
   фиолетовым accent, потом тихо. */
@keyframes settings-flash {
  0%   { background: rgba(99, 102, 241, 0.35); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.45); }
  60%  { background: rgba(99, 102, 241, 0.15); }
  100% { background: transparent; box-shadow: none; }
}

.is-flash {
  animation: settings-flash 2s ease-out;
}

/* N.4e+fix — chip-теги в карте шаблона теперь button-элементы. Полностью
   сбрасываем browser-defaults кнопки (чёрная толстая обводка), оставляя
   только chip-стиль от .invoice-template-tag. */
button.invoice-template-tag {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  font-family: inherit;
  cursor: pointer;
  /* base .invoice-template-tag handles bg/color/padding/radius */
}

button.invoice-template-tag:hover {
  background: rgba(99, 102, 241, 0.16);
}

button.invoice-template-tag:focus-visible {
  outline: 2px solid var(--accent-1, #6366f1);
  outline-offset: 1px;
}

/* N.4d — resolved value рядом с dropdown «Поле». */
.template-field-hint {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  color: var(--text-muted, #6b7280);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.template-field-hint[data-empty="1"] {
  color: #b45309;
}

/* N.4d — density polish: ужать вертикальные отступы в template editor
   inline, чтобы помещалось больше без скролла. */
.invoice-template-editor-inline .template-section {
  margin: 8px 0;
}

.invoice-template-editor-inline .template-section-head {
  padding: 4px 0;
  font-size: 13px;
}

.invoice-template-editor-inline .template-row {
  padding: 6px 0;
}

.invoice-template-editor-inline .template-field {
  padding: 3px 6px;
  gap: 6px;
}

.invoice-template-editor-inline .template-field .drag-handle {
  font-size: 10px;
  opacity: 0.5;
  cursor: grab;
}

.invoice-template-editor-inline .template-field select,
.invoice-template-editor-inline .template-field input {
  font-size: 12px;
  padding: 3px 6px;
}

.invoice-template-editor-inline .template-meta {
  gap: 8px;
  padding: 4px 0;
}

.invoice-template-editor-inline .template-meta label {
  font-size: 12px;
}

.invoice-template-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.invoice-template-card:hover {
  border-color: var(--accent-1, #6366f1);
  box-shadow: 0 1px 4px rgba(99, 102, 241, 0.12);
}

.invoice-template-card.is-muted {
  opacity: 0.65;
  background: var(--card-muted, #fafafa);
}

.invoice-template-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.invoice-template-card-title h3 {
  margin: 0 0 2px 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1, #0f172a);
}

.invoice-template-card-title p {
  margin: 0;
  font-size: 12px;
}

.invoice-template-card-badges {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

.invoice-template-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.invoice-template-badge-accent {
  background: rgba(99, 102, 241, 0.12);
  color: #4338ca;
}

.invoice-template-badge-muted {
  background: var(--card-muted, #f1f5f9);
  color: var(--text-2, #64748b);
}

.invoice-template-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.invoice-template-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  background: rgba(99, 102, 241, 0.08);
  color: #4338ca;
}

.invoice-template-tag::before {
  content: "●";
  font-size: 7px;
  opacity: 0.6;
}

.invoice-template-tag-more {
  background: var(--card-muted, #f1f5f9);
  color: var(--text-2, #64748b);
}

.invoice-template-tag-more::before {
  content: "";
}

.invoice-template-tag-empty {
  background: transparent;
  color: var(--text-2, #94a3b8);
  font-style: italic;
}

.invoice-template-tag-empty::before {
  content: "";
}

.invoice-template-card-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.invoice-template-card-actions .btn-primary {
  margin-left: auto;
}

/* Phase M.3.d — таблицы Готовы/Черновики/Журнал. Единый layout
   для consistency. Avatar-кружок + двухстрочная ячейка получателя. */
.invoice-list-filters {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.invoice-list-filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2, #64748b);
}

.invoice-list-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.invoice-list-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2, #64748b);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border, #e5e7eb);
}

.invoice-list-table thead th.num {
  text-align: right;
}

.invoice-list-table tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border, #f1f5f9);
  vertical-align: middle;
}

.invoice-list-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.03);
}

/* N.1 — групповой заголовок месяца внутри объединённой ленты счетов. */
.invoice-list-group th {
  background: var(--bg-soft, #f9fafb);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted, #6b7280);
  text-align: left;
  padding: 8px 12px;
  font-weight: 600;
  border-top: 1px solid var(--border, #e6e8ec);
  border-bottom: 1px solid var(--border, #f1f5f9);
}

.invoice-list-row[data-tone="muted"] td {
  opacity: 0.55;
}

.invoice-list-row[data-tone="muted"]:hover {
  background: transparent;
}

/* N.1 — chip состояния счёта. Tone применяется через data-tone (ok / warn
   / info / muted), синхронно со shared токенами проекта. */
.invoice-state-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-soft, #f3f4f6);
  color: var(--text-muted, #6b7280);
  border: 1px solid var(--border, #e6e8ec);
  white-space: nowrap;
}

.invoice-state-chip[data-tone="ok"] {
  background: rgba(22, 163, 74, 0.10);
  color: #15803d;
  border-color: rgba(22, 163, 74, 0.30);
}

.invoice-state-chip[data-tone="info"] {
  background: rgba(99, 102, 241, 0.10);
  color: var(--accent-1, #6366f1);
  border-color: rgba(99, 102, 241, 0.30);
}

.invoice-state-chip[data-tone="warn"] {
  background: rgba(245, 158, 11, 0.10);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.30);
}

.invoice-state-chip[data-tone="muted"] {
  background: var(--bg-soft, #f3f4f6);
  color: var(--text-muted, #6b7280);
}

/* Shared compact chips — invoice templates, invoice states and service pickers. */
.flow-service-chip,
.flow-service-option span,
.invoice-template-tag,
.invoice-template-badge,
.invoice-state-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-sizing: border-box;
  height: 22px;
  padding: 0 8px;
  border: 1px solid color-mix(in srgb, var(--accent-1, #6366f1) 24%, var(--border, #e6e8ec));
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-1, #6366f1) 7%, var(--surface, #fff));
  color: color-mix(in srgb, var(--accent-1, #6366f1) 72%, var(--text-1, #0f172a));
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

button.invoice-template-tag {
  border: 1px solid color-mix(in srgb, var(--accent-1, #6366f1) 24%, var(--border, #e6e8ec));
  background: color-mix(in srgb, var(--accent-1, #6366f1) 7%, var(--surface, #fff));
}

button.invoice-template-tag:hover {
  border-color: color-mix(in srgb, var(--accent-1, #6366f1) 40%, var(--border, #e6e8ec));
  background: color-mix(in srgb, var(--accent-1, #6366f1) 12%, var(--surface, #fff));
}

.invoice-template-tag::before {
  color: currentColor;
  opacity: 0.48;
}

.invoice-template-tag-more {
  border-color: color-mix(in srgb, var(--text-2, #64748b) 18%, var(--border, #e6e8ec));
  background: var(--bg-soft, #f8fafc);
  color: var(--text-2, #64748b);
}

.invoice-template-tag-empty {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--text-2, #64748b) 24%, var(--border, #e6e8ec));
  background: var(--surface, #fff);
  color: var(--text-2, #94a3b8);
}

.invoice-template-badge-accent {
  border-color: color-mix(in srgb, var(--accent-1, #6366f1) 24%, var(--border, #e6e8ec));
  background: color-mix(in srgb, var(--accent-1, #6366f1) 7%, var(--surface, #fff));
  color: color-mix(in srgb, var(--accent-1, #6366f1) 72%, var(--text-1, #0f172a));
}

.invoice-template-badge-muted {
  border-color: color-mix(in srgb, var(--text-2, #64748b) 18%, var(--border, #e6e8ec));
  background: var(--bg-soft, #f8fafc);
  color: var(--text-2, #64748b);
}

.flow-service-picker {
  border-color: var(--border, #e5e7eb);
  border-radius: 10px;
  background: var(--surface, #fff);
  box-shadow: inset 0 0 0 1px transparent;
}

.flow-service-picker:hover,
.flow-service-picker:focus-visible {
  border-color: color-mix(in srgb, var(--accent-1, #6366f1) 34%, var(--border, #e5e7eb));
  background: color-mix(in srgb, var(--accent-1, #6366f1) 3%, var(--surface, #fff));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-1, #6366f1) 10%, transparent);
}

.flow-service-summary {
  align-items: center;
}

.flow-service-chip.service-electricity,
.flow-service-option.service-electricity span,
.invoice-template-tag.service-electricity,
.flow-service-chip.service-water,
.flow-service-option.service-water span,
.invoice-template-tag.service-water,
.flow-service-chip.service-gas,
.flow-service-option.service-gas span,
.invoice-template-tag.service-gas,
.flow-service-chip.service-reactive,
.flow-service-option.service-reactive span,
.invoice-template-tag.service-reactive,
.flow-service-chip.service-solar_bank,
.flow-service-option.service-solar_bank span,
.invoice-template-tag.service-solar_bank,
.flow-service-chip.service-bank_fee,
.flow-service-option.service-bank_fee span,
.invoice-template-tag.service-bank_fee,
.flow-service-chip.service-compensation,
.flow-service-option.service-compensation span,
.invoice-template-tag.service-compensation {
  border-color: color-mix(in srgb, var(--chip-color, var(--accent-1, #6366f1)) 24%, var(--border, #e6e8ec));
  background: color-mix(in srgb, var(--chip-color, var(--accent-1, #6366f1)) 8%, var(--surface, #fff));
  color: color-mix(in srgb, var(--chip-color, var(--accent-1, #6366f1)) 78%, var(--text-1, #0f172a));
}

.flow-service-chip.service-electricity,
.flow-service-option.service-electricity span,
.invoice-template-tag.service-electricity {
  --chip-color: #4f46e5;
}

.flow-service-chip.service-water,
.flow-service-option.service-water span,
.invoice-template-tag.service-water {
  --chip-color: #0284c7;
}

.flow-service-chip.service-gas,
.flow-service-option.service-gas span,
.invoice-template-tag.service-gas {
  --chip-color: #b45309;
}

.flow-service-chip.service-reactive,
.flow-service-option.service-reactive span,
.invoice-template-tag.service-reactive {
  --chip-color: #7c3aed;
}

.flow-service-chip.service-solar_bank,
.flow-service-option.service-solar_bank span,
.invoice-template-tag.service-solar_bank {
  --chip-color: #ca8a04;
}

.flow-service-chip.service-bank_fee,
.flow-service-option.service-bank_fee span,
.invoice-template-tag.service-bank_fee {
  --chip-color: #475569;
}

.flow-service-chip.service-compensation,
.flow-service-option.service-compensation span,
.invoice-template-tag.service-compensation {
  --chip-color: #be185d;
}

.invoice-state-chip[data-tone="ok"] {
  border-color: color-mix(in srgb, #16a34a 30%, var(--border, #e6e8ec));
  background: color-mix(in srgb, #16a34a 9%, var(--surface, #fff));
  color: #15803d;
}

.invoice-state-chip[data-tone="info"] {
  border-color: color-mix(in srgb, var(--accent-1, #6366f1) 30%, var(--border, #e6e8ec));
  background: color-mix(in srgb, var(--accent-1, #6366f1) 9%, var(--surface, #fff));
  color: var(--accent-1, #6366f1);
}

.invoice-state-chip[data-tone="warn"] {
  border-color: color-mix(in srgb, #f59e0b 30%, var(--border, #e6e8ec));
  background: color-mix(in srgb, #f59e0b 9%, var(--surface, #fff));
  color: #b45309;
}

.invoice-state-chip[data-tone="muted"] {
  border-color: color-mix(in srgb, var(--text-2, #64748b) 18%, var(--border, #e6e8ec));
  background: var(--bg-soft, #f8fafc);
  color: var(--text-2, #64748b);
}

.settings-table-controls .toggle-control,
.rule-cell .toggle-control,
.settings-inline-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: auto;
  min-width: 38px;
  height: auto;
  min-height: 22px;
  white-space: normal;
}

.settings-table-controls .toggle-track,
.rule-cell .toggle-track,
.settings-inline-toggle .toggle-track {
  flex: 0 0 auto;
}

.settings-table-controls .toggle-control > span:not(.toggle-track),
.rule-cell .toggle-control > span:not(.toggle-track),
.settings-inline-toggle > span:not(.toggle-track) {
  color: var(--text-2, #64748b);
  line-height: 1.2;
}

.invoice-state-chip svg {
  flex-shrink: 0;
}

/* Settings / Money compact layout */
.settings-money-page {
  display: grid;
  gap: 14px;
}

.settings-money-page > .panel {
  margin: 0;
}

.settings-money-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.settings-money-metric {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 12px 14px;
  border: 1px solid var(--border, #e6e8ec);
  border-radius: 10px;
  background: var(--surface, #fff);
}

.settings-money-metric-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--metric-color, var(--text-2, #64748b));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--metric-color, #64748b) 10%, transparent);
  flex: 0 0 auto;
}

.settings-money-metric strong {
  display: block;
  color: var(--text-1, #0f172a);
  font-size: 18px;
  line-height: 1.1;
}

.settings-money-metric span:last-child {
  color: var(--text-2, #64748b);
  font-size: 12px;
  line-height: 1.25;
}

.settings-money-metric.is-ok { --metric-color: #16a34a; }
.settings-money-metric.is-info { --metric-color: var(--accent-1, #6366f1); }
.settings-money-metric.is-warn { --metric-color: #f59e0b; }
.settings-money-metric.is-muted { --metric-color: #94a3b8; }

.settings-money-table-wrap {
  overflow-x: auto;
}

.settings-compact-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto;
}

.settings-compact-table th {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border, #e6e8ec);
  background: var(--bg-soft, #f8fafc);
  color: var(--text-2, #64748b);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
}

.settings-compact-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border-soft, #eef1f5);
  vertical-align: middle;
}

.settings-compact-table tr:last-child td {
  border-bottom: 0;
}

.settings-compact-table tr.is-muted {
  opacity: .58;
}

.invoice-rule-matrix th:not(:first-child),
.invoice-rule-matrix td:not(:first-child) {
  text-align: center;
}

.invoice-rule-matrix th:first-child,
.invoice-rule-matrix td:first-child {
  width: 150px;
  min-width: 150px;
}

.invoice-rule-matrix .rule-cell {
  min-width: 138px;
}

.invoice-rule-matrix .rule-cell.service-bank_fee {
  min-width: 260px;
}

.invoice-rule-cell-body {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.rule-cell .rule-charge-toggle {
  justify-content: center;
}

.rule-extra {
  width: 100%;
}

.rule-rate-extra {
  display: inline-grid;
  grid-template-columns: auto minmax(74px, 1fr);
  align-items: center;
  gap: 6px;
  max-width: 118px;
  color: var(--text-2, #64748b);
  font-size: 12px;
}

.rule-fee-grid {
  display: grid;
  grid-template-columns: minmax(54px, .7fr) minmax(98px, 1.2fr) minmax(74px, .9fr);
  gap: 6px;
  align-items: end;
}

.rule-fee-grid label,
.settings-rule-period label,
.investor-compact-field {
  display: grid;
  gap: 4px;
}

.rule-fee-grid label > span,
.settings-rule-period label > span,
.investor-compact-field > span:first-child {
  color: var(--text-2, #64748b);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .01em;
}

.rule-fee-grid select,
.rule-fee-grid .cell-input,
.settings-rule-period .month-picker-button {
  width: 100%;
  min-width: 0;
}

.money-flow-rules-table th:nth-child(2),
.money-flow-rules-table td:nth-child(2) {
  min-width: 310px;
}

.settings-rule-period {
  display: grid;
  grid-template-columns: repeat(2, minmax(104px, 1fr));
  gap: 6px;
}

.settings-compact-table td:last-child {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.investor-compact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.investor-compact-card {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(86px, .65fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--border, #e6e8ec);
  border-radius: 10px;
  background: var(--surface, #fff);
}

.investor-share-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
}

.investor-share-input > span {
  color: var(--text-2, #64748b);
  font-size: 12px;
}

.investor-share-total {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--share-color, #64748b) 24%, var(--border, #e6e8ec));
  border-radius: 999px;
  background: color-mix(in srgb, var(--share-color, #64748b) 8%, var(--surface, #fff));
  color: color-mix(in srgb, var(--share-color, #64748b) 78%, var(--text-1, #0f172a));
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.investor-share-total.is-ok { --share-color: #16a34a; }
.investor-share-total.is-warn { --share-color: #f59e0b; }

@media (max-width: 1180px) {
  .settings-money-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .settings-money-summary,
  .investor-compact-grid,
  .investor-compact-card {
    grid-template-columns: 1fr;
  }
}

/* N.2 — inline row expansion: раскрывается под строкой счёта в той
   же таблице. Содержит превью + поля + actions. Левая колонка
   (label / actions), правая — iframe. */
.invoice-list-row.is-open td {
  background: rgba(99, 102, 241, 0.04);
}

.invoice-row-expansion-row td {
  padding: 0;
  background: rgba(99, 102, 241, 0.04);
  border-bottom: 1px solid var(--border, #e6e8ec);
  box-shadow: inset 3px 0 0 var(--accent-1, #6366f1);
}

.invoice-row-expansion {
  padding: 16px 18px;
}

.invoice-row-expansion-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 18px;
  align-items: stretch;
}

@media (max-width: 1100px) {
  .invoice-row-expansion-grid {
    grid-template-columns: 1fr;
  }
}

.invoice-row-expansion-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.invoice-row-expansion-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted, #6b7280);
}

.invoice-row-expansion-row-inputs {
  display: flex;
  gap: 8px;
  align-items: center;
}

.invoice-row-expansion-row-inputs input[type="text"] {
  flex: 1 1 auto;
}

.invoice-row-expansion-row-inputs input[type="number"] {
  width: 110px;
}

.invoice-row-expansion-total {
  font-size: 14px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-variant-numeric: tabular-nums;
  padding-top: 4px;
}

.invoice-row-expansion-total strong {
  font-size: 16px;
  font-weight: 700;
}

.invoice-row-expansion-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.invoice-row-expansion-preview {
  display: flex;
  flex-direction: column;
  min-height: 600px;
}

.invoice-row-expansion-frame {
  width: 100%;
  height: 600px;
  min-height: 600px;
  border: 1px solid var(--border, #e6e8ec);
  border-radius: 8px;
  background: #fff;
}

/* После того, как JS измерил scrollHeight и выставил `style.height`,
   зацепим переход для плавного роста. */
.invoice-row-expansion-frame[data-autosized="done"] {
  height: auto;
}

.invoice-list-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.invoice-row-recipient {
  display: flex;
  align-items: center;
  gap: 10px;
}

.invoice-row-recipient-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.invoice-row-recipient-text strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1, #0f172a);
  line-height: 1.2;
}

.invoice-row-recipient-text .muted {
  font-size: 11px;
  color: var(--text-2, #64748b);
  line-height: 1.2;
}

.invoice-row-avatar {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #818cf8);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}

.invoice-row-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  align-items: center;
}

.invoice-row-actions .btn {
  font-size: 12px;
}

/* Phase M.3.c — right-side slide-out для «Сформировать счёт».
   Backdrop затемняет фон + ловит клик для закрытия. Сама панель
   slide-in справа, fixed позиционирование, ~520px ширина.
   Внутри: header (title + close) / scrollable body (selectors +
   total + iframe-preview) / footer (Отменить / PDF / Сформировать). */
.invoice-page-actions {
  display: flex;
  gap: 8px;
}

.invoice-slide-out-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 90;
  animation: invoice-slide-fade-in 0.18s ease-out;
}

@keyframes invoice-slide-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.invoice-slide-out {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 100vw);
  background: var(--card, #fff);
  border-left: 1px solid var(--border, #e5e7eb);
  box-shadow: -8px 0 24px rgba(15, 23, 42, 0.12);
  z-index: 100;
  display: flex;
  flex-direction: column;
  animation: invoice-slide-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes invoice-slide-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.invoice-slide-out-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border, #e5e7eb);
}

.invoice-slide-out-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.invoice-slide-out-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.invoice-slide-out-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.invoice-slide-out-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2, #64748b);
}

.invoice-slide-out-controls input,
.invoice-slide-out-controls select {
  width: 100%;
  box-sizing: border-box;
}

.invoice-slide-out-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 12px;
  background: rgba(99, 102, 241, 0.06);
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
}

.invoice-slide-out-total strong {
  font-size: 16px;
  font-weight: 700;
}

.invoice-slide-out-preview {
  flex: 1;
  min-height: 320px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
}

.invoice-slide-out-preview-frame {
  width: 100%;
  height: 100%;
  min-height: 320px;
  border: 0;
  display: block;
}

.invoice-slide-out-preview-empty {
  padding: 16px;
}

.invoice-slide-out-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border, #e5e7eb);
  background: var(--card-muted, #fafafa);
}

@media (max-width: 720px) {
  .invoice-slide-out {
    width: 100vw;
  }
  .invoice-slide-out-controls {
    grid-template-columns: 1fr;
  }
}

/* Phase L.3 — постоянный visible-индикатор «есть несохранённые
   изменения» рядом с кнопкой Сохранить. По умолчанию скрыт; виден
   когда body имеет класс `has-dirty-settings` (его ставит markDirty()
   во всех скоупах: settings/rent/combined/exchange_rates/etc.).
   Сама кнопка Сохранить уже умеет flash «Сохранение..»/«Сохранено»/
   «Ошибка» через setSaveButtonState() — это дополняет картину. */
.save-dirty-indicator {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.3);
  white-space: nowrap;
  user-select: none;
}

.save-dirty-indicator::before {
  content: "●";
  font-size: 8px;
  color: #f59e0b;
  animation: save-dirty-pulse 1.6s ease-in-out infinite;
}

@keyframes save-dirty-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

body.has-dirty-settings .save-dirty-indicator {
  display: inline-flex;
}

/* Phase J.10 — fix наезжающих ячеек в таблицах Настройки → Клиенты
   /Услуги/Счётчики. Длинные имена клиентов и услуг визуально вылазят
   за свою ячейку и накладываются на соседнюю. Здесь:
   - даём text-input минимальную ширину, чтобы он не схлопывался,
     и одновременно фиксируем box-sizing (без него padding ломает
     инлайн расчёт ширины);
   - padding для td/th таблицы настроек, чтобы между ячейками был
     визуальный зазор, и vertical-align: top — длинные значения и
     bool-селекты не «прыгают» по высоте;
   - white-space: normal на td, чтобы текст внутри ячейки переносился
     вместо горизонтального скролла. */
[data-settings-table-collection] {
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 0;
}

[data-settings-table-collection] th,
[data-settings-table-collection] td {
  padding: 6px 10px;
  vertical-align: middle;
  white-space: normal;
}

[data-settings-table-collection] input.cell-input.text {
  min-width: 160px;
  box-sizing: border-box;
}

[data-settings-table-collection] select {
  box-sizing: border-box;
}

/* Phase M.4 — журнал действий: filter chips + controls. */
.audit-filters {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.audit-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.audit-filter-chip {
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e5e7eb);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2, #64748b);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.audit-filter-chip:hover {
  border-color: var(--accent-1, #6366f1);
  color: var(--text-1, #0f172a);
}

.audit-filter-chip.is-active {
  background: var(--accent-1, #6366f1);
  border-color: var(--accent-1, #6366f1);
  color: #fff;
}

.audit-filter-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.audit-filter-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.audit-table-wrap {
  overflow-x: auto;
}

.audit-log-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.audit-log-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2, #64748b);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  vertical-align: top;
}

.audit-log-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border, #f1f5f9);
  vertical-align: top;
  font-size: 12.5px;
  word-break: break-word;
}

.audit-log-table colgroup col,
.audit-log-table thead th:nth-child(1) { width: 14%; }
.audit-log-table thead th:nth-child(2) { width: 20%; }
.audit-log-table thead th:nth-child(3) { width: 14%; }
.audit-log-table thead th:nth-child(4) { width: 12%; }
.audit-log-table thead th:nth-child(5) { width: 40%; }

.audit-cell-date {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.audit-cell-action strong {
  display: block;
  font-weight: 600;
  color: var(--text-1, #0f172a);
}

.audit-tech-key {
  display: inline-block;
  margin-top: 2px;
  padding: 1px 6px;
  font-size: 10.5px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  background: var(--card-muted, #f1f5f9);
  color: var(--text-2, #64748b);
  border-radius: 4px;
}

.audit-cell-details {
  font-size: 12px;
}

/* Phase M.5 v2 — полная переработка Коммунальные → Обзор.
   Структура: period-nav (mode+arrows) → hero-row (main number + status
   light) → trend chart → grid (suggested actions + invoices). */
.overview-page {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Phase M.5 v3.6 — period-nav компактнее: оба контрола (mode + arrows)
   слева, занимают одну row без лишнего пустого пространства. */
/* Phase M.5 v3.9 — period-nav компактнее и справа: Месяц/Год чётче
   разделён бордером, label центрирован между стрелками,
   шрифты/размеры уменьшены. */
.overview-period-nav {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

.overview-period-mode {
  display: inline-flex;
  padding: 2px;
  background: var(--card-muted, #f1f5f9);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 999px;
  gap: 2px;
}

.overview-mode-btn {
  padding: 3px 11px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2, #64748b);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.overview-mode-btn:hover {
  color: var(--text-1, #0f172a);
}

.overview-mode-btn.is-active {
  background: var(--card, #fff);
  color: var(--text-1, #0f172a);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1);
}

.overview-period-picker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 999px;
  padding: 2px;
  background: var(--card, #fff);
}

.overview-period-arrow {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--text-2, #64748b);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.overview-period-arrow:hover:not(:disabled) {
  background: var(--card-muted, #f1f5f9);
  color: var(--accent-1, #6366f1);
}

.overview-period-arrow:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.overview-period-label {
  font-size: 12.5px;
  font-weight: 700;
  min-width: 96px;
  text-align: center;
  color: var(--text-1, #0f172a);
  letter-spacing: 0.01em;
}

/* Slice P.1: shared period nav — алиас на overview-period-* стили,
   чтобы любая страница (Аренда, Сводный, Счета) могла переиспользовать
   тот же UI. Существующие .overview-period-* остаются для обратной
   совместимости с другими стилями.
   P.2a v2 sticky: прилипает под topbar (top: 60px ≈ высота topbar) при
   скролле длинных страниц. Background + padding чтобы visually
   «перекрывала» контент под собой. */
.period-nav {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
  padding: 10px var(--pad-x, 24px) 8px;
  background: var(--surface, #fff);
  position: sticky;
  top: 60px;
  z-index: 90;
  border-bottom: 1px solid color-mix(in srgb, var(--line, #e2e8f0) 50%, transparent);
}
.period-mode { display: inline-flex; padding: 2px; background: var(--card-muted, #f1f5f9); border: 1px solid var(--border, #e5e7eb); border-radius: 999px; gap: 2px; }
.period-mode-btn { padding: 3px 11px; border: 0; border-radius: 999px; background: transparent; font-size: 11.5px; font-weight: 600; color: var(--text-2, #64748b); cursor: pointer; transition: background 0.15s, color 0.15s; }
.period-mode-btn:hover:not(:disabled) { color: var(--text-1, #0f172a); }
.period-mode-btn.is-active { background: var(--card, #fff); color: var(--text-1, #0f172a); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1); }
.period-mode-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.period-picker { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border, #e5e7eb); border-radius: 999px; padding: 2px; background: var(--card, #fff); }
.period-arrow { width: 22px; height: 22px; border-radius: 50%; border: 0; background: transparent; color: var(--text-2, #64748b); font-size: 13px; line-height: 1; cursor: pointer; transition: background 0.15s, color 0.15s; display: inline-flex; align-items: center; justify-content: center; }
.period-arrow:hover:not(:disabled) { background: var(--card-muted, #f1f5f9); color: var(--accent-1, #6366f1); }
.period-arrow:disabled { opacity: 0.3; cursor: not-allowed; }
.period-label { font-size: 12.5px; font-weight: 700; min-width: 96px; text-align: center; color: var(--text-1, #0f172a); letter-spacing: 0.01em; }

/* Phase M.5 v3.3 — KPI grid: 4 metric-карточки в ряд, status-card
   полной ширины ниже. На узких экранах перенос. */
.overview-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 1100px) {
  .overview-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .overview-kpi-grid {
    grid-template-columns: 1fr;
  }
}

.overview-kpi-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.04), rgba(99, 102, 241, 0.01));
  border: 1px solid rgba(99, 102, 241, 0.18);
  border-radius: 12px;
  min-width: 0;
}

.overview-kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2, #64748b);
  font-weight: 600;
}

.overview-kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-1, #0f172a);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  word-break: break-word;
}

.overview-kpi-unit {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2, #64748b);
}

/* Phase M.5 v3.11 — sparkline под главной цифрой: 100% ширина,
   высота 24px, чёткий контраст с фоном карточки. */
.overview-kpi-sparkline {
  width: 100%;
  height: 22px;
  display: block;
  margin: 2px 0 4px;
  opacity: 0.85;
}

.overview-kpi-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-2, #64748b);
  width: fit-content;
  margin-top: 2px;
}

.overview-kpi-chip[data-trend="up"] {
  background: rgba(34, 197, 94, 0.12);
  color: #15803d;
}

.overview-kpi-chip[data-trend="down"] {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

.overview-kpi-chip-pct {
  font-weight: 700;
}

.overview-kpi-chip-abs {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* Phase M.5 v3.5 + v3.8 — bottom row: 2 col равные (Состояние | Счета),
   same height/width как chart-карточки сверху. */
.overview-bottom-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

.overview-bottom-grid > * {
  height: 100%;
  box-sizing: border-box;
}

@media (max-width: 900px) {
  .overview-bottom-grid {
    grid-template-columns: 1fr;
  }
}

/* M.12 Слайс A — Monthly stepper. 4 шага в строку (на узких экранах
   wrap). Каждый шаг — карточка с номером, лейблом, деталью и иконкой
   статуса. Цвет рамки/иконки = tone. Locked = visually disabled. */
.monthly-stepper {
  background: var(--card, #fff);
  border: 1px solid var(--border, #e6e8ec);
  border-radius: 12px;
  padding: 14px 16px;
}

.monthly-stepper-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.monthly-stepper-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted, #6b7280);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.monthly-stepper-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
}

.monthly-stepper-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 900px) {
  .monthly-stepper-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .monthly-stepper-list {
    grid-template-columns: 1fr;
  }
}

.monthly-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border, #e6e8ec);
  border-radius: 10px;
  background: var(--bg-soft, #f9fafb);
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.monthly-step:hover:not([aria-disabled="true"]) {
  border-color: var(--accent-1, #6366f1);
  background: var(--card, #fff);
}

.monthly-step:active:not([aria-disabled="true"]) {
  transform: translateY(1px);
}

.monthly-step[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.55;
}

.monthly-step-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e6e8ec);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: var(--text-muted, #6b7280);
}

.monthly-step-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1 1 auto;
}

.monthly-step-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #111827);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.monthly-step-detail {
  font-size: 11px;
  color: var(--text-muted, #6b7280);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.monthly-step-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: var(--text-muted, #6b7280);
}

.monthly-step[data-status="done"] {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.06);
}
.monthly-step[data-status="done"] .monthly-step-num {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
}
.monthly-step[data-status="done"] .monthly-step-icon {
  color: #16a34a;
}

.monthly-step[data-status="todo"] {
  border-color: rgba(99, 102, 241, 0.4);
  background: rgba(99, 102, 241, 0.06);
}
.monthly-step[data-status="todo"] .monthly-step-num {
  background: var(--accent-1, #6366f1);
  border-color: var(--accent-1, #6366f1);
  color: #fff;
}
.monthly-step[data-status="todo"] .monthly-step-icon {
  color: var(--accent-1, #6366f1);
}

.monthly-step[data-status="warn"] {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.07);
}
.monthly-step[data-status="warn"] .monthly-step-num {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #fff;
}
.monthly-step[data-status="warn"] .monthly-step-icon {
  color: #f59e0b;
}

.monthly-step[data-status="blocked"] {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.07);
}
.monthly-step[data-status="blocked"] .monthly-step-num {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
}
.monthly-step[data-status="blocked"] .monthly-step-icon {
  color: #ef4444;
}

.monthly-step[data-status="locked"] {
  background: var(--bg-soft, #f9fafb);
}

/* Phase M.5 v3.11 — mini-progress dots для «Счета: выпущено N из M».
   Маленькие точки 6px, filled = accent, empty = border-color. */
.overview-mini-progress {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  margin-right: 4px;
}

.overview-mini-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border, #e5e7eb);
  border: 1px solid var(--border, #e5e7eb);
}

.overview-mini-dot.is-filled {
  background: #16a34a;
  border-color: #16a34a;
}

/* Phase M.5 v3.9 + v3.10 — action-кнопки в светофоре/счетах унифицированы:
   pill, тонкий бордер, accent-цвет текста. .overview-status-action
   имеет min-width 120px, чтоб «Проверить →» и «Сформировать →»
   были одинаковой ширины (по самой длинной строке). */
.overview-status-action,
.overview-invoices-action {
  padding: 4px 12px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 999px;
  background: var(--card, #fff);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-1, #6366f1);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  line-height: 1.4;
  text-align: center;
}

.overview-status-action {
  min-width: 120px;
}

.overview-status-action:hover,
.overview-invoices-action:hover {
  background: rgba(99, 102, 241, 0.08);
  border-color: var(--accent-1, #6366f1);
}

/* Invoices card — компактный список + footer total */
.overview-invoices-card {
  padding: 16px 18px;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.overview-invoices-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.overview-invoices-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2, #64748b);
}

.overview-invoice-row {
  grid-template-columns: 1fr auto auto;
  padding: 8px 0;
  font-size: 13px;
}

.overview-invoice-row:first-child {
  padding-top: 0;
}

.overview-invoice-status {
  font-size: 14px;
  width: 22px;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.overview-invoice-status[data-tone="ok"] { color: #16a34a; }
.overview-invoice-status[data-tone="warn"] { color: #f59e0b; }

.overview-invoice-footer {
  display: flex;
  justify-content: flex-start;
  gap: 14px;
  padding-top: 10px;
  margin-top: auto;
  border-top: 1px solid var(--border, #f1f5f9);
  font-size: 12.5px;
  flex-wrap: wrap;
}

.overview-invoice-footer strong {
  font-variant-numeric: tabular-nums;
}

/* Phase M.5 v3.11 — Pending/OK attention chips в футере. */
.overview-pending-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  border: 1px solid transparent;
}

.overview-pending-chip[data-tone="warn"] {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.32);
  color: #b45309;
}

.overview-pending-chip[data-tone="warn"] strong { color: #92400e; }
.overview-pending-chip[data-tone="warn"] .muted { color: #b45309; }
.overview-pending-chip[data-tone="warn"] svg { color: #d97706; }

.overview-pending-chip[data-tone="ok"] {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.32);
  color: #166534;
}

.overview-pending-chip[data-tone="ok"] strong { color: #14532d; }
.overview-pending-chip[data-tone="ok"] .muted { color: #166534; }
.overview-pending-chip[data-tone="ok"] svg { color: #16a34a; }

/* Status light */
.overview-status-card {
  padding: 16px 18px;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.overview-status-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2, #64748b);
}

.overview-status-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
}

.overview-status-item {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.overview-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-2, #94a3b8);
}

.overview-status-item[data-tone="ok"] .overview-status-dot { background: #16a34a; }
.overview-status-item[data-tone="warn"] .overview-status-dot { background: #f59e0b; }
.overview-status-item[data-tone="error"] .overview-status-dot { background: #dc2626; }
.overview-status-item[data-tone="muted"] .overview-status-dot { background: #cbd5e1; }

.overview-status-text {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.overview-status-text strong {
  font-weight: 600;
  color: var(--text-1, #0f172a);
}

.overview-status-text .muted {
  font-size: 12px;
}

/* Phase M.5 v3 — charts grid: 2 на ширину на десктопе, 1 на узком.
   Phase M.5 v3.6 — grid-auto-rows: 1fr выравнивает высоты всех 4
   карточек (Income / Tariff / Consumption / Coverage) даже когда
   header-controls у них разной высоты. */
.overview-charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 14px;
}

@media (max-width: 900px) {
  .overview-charts-grid {
    grid-template-columns: 1fr;
  }
}

.overview-chart-card {
  padding: 14px 16px;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}

/* Phase M.5 v3.11 + v3.12 — когда наводим на KPI карточку, связанный
   чарт подсвечивается своим цветом (через --chart-color) — owner
   видит источник данных в его собственной color-семантике. */
.overview-chart-card.is-kpi-linked {
  border-color: var(--chart-color, var(--accent-1, #6366f1));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--chart-color, #6366f1) 18%, transparent);
}

/* Phase M.5 v3.11 — KPI карточка тоже визуально подсвечивается
   при hover, чтобы pair был bi-directional. */
.overview-kpi-card[data-overview-related-chart] {
  cursor: default;
  transition: border-color 0.2s, transform 0.15s;
}

.overview-kpi-card[data-overview-related-chart]:hover {
  border-color: color-mix(in srgb, var(--chart-color, #6366f1) 50%, transparent);
  transform: translateY(-1px);
}

.overview-chart-card > .overview-chart-scroll {
  flex: 1 1 auto;
  display: flex;
  align-items: stretch;
}

.overview-chart-card > .overview-chart-scroll > svg {
  flex: 1 1 auto;
}

.overview-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.overview-chart-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2, #64748b);
}

.overview-chart-meta {
  font-size: 11px;
  color: var(--text-2, #64748b);
}

.overview-chart-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.overview-chart-toggles {
  display: inline-flex;
  padding: 2px;
  background: var(--card-muted, #f1f5f9);
  border-radius: 999px;
  gap: 2px;
}

.overview-chart-toggle {
  padding: 3px 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2, #64748b);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.overview-chart-toggle:hover {
  color: var(--text-1, #0f172a);
}

.overview-chart-toggle.is-active {
  background: var(--card, #fff);
  color: var(--text-1, #0f172a);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.overview-chart-select {
  padding: 4px 8px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  font-size: 12px;
  background: var(--card, #fff);
  color: var(--text-1, #0f172a);
}

.overview-chart-scroll {
  width: 100%;
  overflow-x: auto;
  /* position relative — для overview-chart-avg-marker overlay (P.1c v2).
     Подпись «ср X» абсолютно позиционируется относительно scroll, а не
     внутри SVG viewBox — так она реально прижата к правому краю DOM
     контейнера, независимо от preserveAspectRatio. */
  position: relative;
}

.overview-chart-svg {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 160px;
}

/* HTML overlay для подписи среднего. Позиционирована относительно
   .overview-chart-scroll: right=10px = реально у правого края DOM.
   top=var(--avg-top) — процент от высоты scroll (= высота SVG в DOM),
   что совпадает с avgY на SVG-линии. transform translateY(-50%)
   центрирует текст по линии. Background var(--card) перекрывает
   пунктирную линию под текстом, чтобы было читаемо. */
.overview-chart-avg-marker {
  position: absolute;
  right: 10px;
  top: var(--avg-top, 50%);
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 700;
  background: var(--card, #fff);
  padding: 0 6px;
  pointer-events: none;
  z-index: 2;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Phase M.5 v3.12 — bar fill через chart-card CSS-переменную
   --chart-color, чтобы Доход (amber) / Потребление (purple) /
   и другие чарты могли иметь разные цвета баров. */
.overview-chart-card {
  --chart-color: #6366f1;
}

.overview-chart-bar rect {
  fill: var(--chart-color);
  fill-opacity: 0.65;
  transition: fill-opacity 0.15s;
}

.overview-chart-bar {
  cursor: pointer;
}

.overview-chart-bar:hover rect {
  fill-opacity: 0.9;
}

.overview-chart-bar.is-selected rect {
  fill-opacity: 1;
}

/* P.1c: подсветка квартала — 3 столбца квартала выделяются вместе
   при scope=quarter. Чуть плотнее обычных столбцов, бордюр одинаковый,
   чтобы 3 шт читались как одна группа. На bar-чартах. */
.overview-chart-bar.is-quarter-active rect {
  fill-opacity: 0.95;
  stroke: var(--chart-color, var(--accent-1, #6366f1));
  stroke-width: 1.5;
}
.overview-chart-bar.is-quarter-active .overview-chart-value-label {
  font-weight: 700;
}
/* Аналог для line-point. Точка чуть крупнее, обводка accent. */
.overview-chart-line-point.is-quarter-active .overview-chart-dot {
  r: 5;
  stroke: var(--chart-color, var(--accent-1, #6366f1));
  stroke-width: 2;
}

/* Phase M.5 v3.14 — две версии подписи месяца: short (янв) видна
   по умолчанию, full (январь) скрыта и показывается при hover/selected.
   Жирность + цвет чарта на активном. */
.overview-chart-axis-full {
  opacity: 0;
  transition: opacity 0.12s;
}

.overview-chart-axis-short {
  transition: opacity 0.12s;
}

.overview-chart-bar:hover .overview-chart-axis-short,
.overview-chart-bar.is-selected .overview-chart-axis-short,
.overview-chart-line-point:hover .overview-chart-axis-short,
.overview-chart-line-point.is-selected .overview-chart-axis-short {
  opacity: 0;
}

.overview-chart-bar:hover .overview-chart-axis-full,
.overview-chart-bar.is-selected .overview-chart-axis-full,
.overview-chart-line-point:hover .overview-chart-axis-full,
.overview-chart-line-point.is-selected .overview-chart-axis-full {
  opacity: 1;
  font-weight: 700;
  fill: var(--chart-color, var(--text-1, #0f172a));
}

/* Phase M.5 v3.6 + v3.8 + v3.9 — line-chart точка: hover увеличивает +
   bold значение + еле видная вертикальная пунктирная линия.
   Selected месяц = orange dot + opacity 0.22 на vline. */
.overview-chart-line-point {
  cursor: pointer;
}

.overview-chart-vline {
  transition: opacity 0.15s;
}

.overview-chart-line-point:hover .overview-chart-vline {
  opacity: 0.22 !important;
}

.overview-chart-line-point .overview-chart-dot {
  transition: r 0.15s, stroke-width 0.15s, fill 0.15s;
}

.overview-chart-line-point:hover .overview-chart-dot {
  r: 5;
  stroke: #fff;
  stroke-width: 2;
}

.overview-chart-line-point.is-selected .overview-chart-value-label {
  font-weight: 700;
}

.overview-chart-line-point:hover .overview-chart-value-label {
  font-weight: 700;
}

.overview-chart-axis {
  font-size: 10px;
  fill: var(--text-2, #64748b);
}

.overview-chart-value-label {
  font-size: 10px;
  font-weight: 600;
  fill: var(--text-1, #0f172a);
  font-variant-numeric: tabular-nums;
}

/* Phase M.5 v3.11 — Year-mode avg reference label на чартах. */
.overview-chart-avg-label {
  font-size: 9.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}

/* Invoices card */
.overview-invoices-card {
  display: flex;
  flex-direction: column;
}

.overview-invoice-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

.overview-invoice-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 16px;
  border-top: 1px solid var(--border, #f1f5f9);
  font-size: 13px;
}

.overview-invoice-row:first-child {
  border-top: 0;
}

.overview-invoice-row[data-tone="muted"] {
  color: var(--text-2, #64748b);
}

.overview-invoice-name {
  font-weight: 500;
  color: var(--text-1, #0f172a);
}

.overview-invoice-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

/* Phase M.5 — sparkline (мини-график тренда 12 месяцев) на metric-картах. */
.metric-sparkline {
  display: block;
  width: 100%;
  height: 24px;
  color: var(--accent-1, #6366f1);
  margin-top: 4px;
}

/* Phase M.6 — sparkline на rent-hub KPI карточках. */
.rent-hub-kpi-sparkline {
  display: block;
  width: 100%;
  height: 22px;
  color: var(--accent-1, #6366f1);
  margin-top: 6px;
}

/* Phase M.7 — Сводный финрезультат → Обзор: KPI hero ряд с sparklines.
   Featured карточка («Итог») визуально выделена крупнее. */
.combined-kpi-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 1200px) {
  .combined-kpi-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .combined-kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.combined-kpi-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  min-width: 0;
  color: var(--accent-1, #6366f1);
}

.combined-kpi-card[data-tone="ok"] { color: #16a34a; }
.combined-kpi-card[data-tone="warn"] { color: #b45309; }
.combined-kpi-card[data-tone="info"] { color: #6366f1; }

.combined-kpi-card.is-featured {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(99, 102, 241, 0.02));
  border-color: rgba(99, 102, 241, 0.3);
  grid-column: span 1;
}

.combined-kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2, #64748b);
  font-weight: 600;
}

.combined-kpi-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-1, #0f172a);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.combined-kpi-card.is-featured .combined-kpi-value {
  font-size: 22px;
}

.combined-kpi-unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2, #64748b);
}

/* Phase M.5 — компактный details cell: 1-строчная сводка + expand-кнопка. */
.audit-details-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.audit-summary-line {
  display: inline-block;
  color: var(--text-1, #0f172a);
  word-break: break-word;
  line-height: 1.4;
}

.audit-expand-btn {
  align-self: flex-start;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.08);
  color: #4338ca;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.audit-expand-btn:hover {
  background: rgba(99, 102, 241, 0.16);
  border-color: rgba(99, 102, 241, 0.3);
}

/* Phase J.9 — журнал действий: metadata рендерится как
   определение-список вместо «k: v; k: v» строки. dt/dd идут парами
   в две колонки, длинные значения переносятся внутри своей ячейки. */
.audit-metadata-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 12px;
  row-gap: 2px;
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
}

.audit-metadata-list dt {
  font-weight: 600;
  color: var(--text-2, #64748b);
  white-space: nowrap;
}

.audit-metadata-list dd {
  margin: 0;
  color: var(--text-1, #0f172a);
  word-break: break-word;
}

/* ===== Показания · новые (input_v2) ================================ */

.input-v2-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-v2-page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 0 4px;
}

.input-v2-page-title h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.input-v2-page-eyebrow {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.input-v2-banner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  border: 1px solid var(--warn, #f59e0b);
  background: color-mix(in srgb, var(--warn, #f59e0b) 8%, var(--surface, #fff));
  border-radius: 10px;
  font-size: 13px;
}

.input-v2-banner.is-closed {
  border-color: var(--text-2, #64748b);
  background: color-mix(in srgb, var(--text-2, #64748b) 6%, var(--surface, #fff));
}

.input-v2-banner-title {
  font-weight: 600;
}

.input-v2-banner-text {
  color: var(--text-2, #64748b);
}

.input-v2-kpi-bar {
  display: grid;
  /* v2.4: auto-fit вместо fixed 4 — «Покрыто солнцем» может быть скрыта
   * для объектов без солнца, и оставшиеся 3 карты должны заполнить
   * ширину равномерно. auto-fit с minmax даёт responsive поведение
   * без отдельного media query. */
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

/* v2.1: уменьшенный padding/font для KPI — меньше вертикального места. */
.input-v2-kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
}

.input-v2-kpi-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-2, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input-v2-kpi-value {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.input-v2-kpi-unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2, #64748b);
  margin-left: 2px;
}

.input-v2-kpi-meta {
  font-size: 12px;
  color: var(--text-2, #64748b);
  min-height: 16px;
}

.input-v2-kpi-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
}

.input-v2-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-2, #64748b);
}

/* A11y fix #5: затемнённый ready-зелёный для AA-контраста (>=4.5:1 на
   светло-зелёном фоне). Был #16a34a (3.0:1) → стал #0f6b34 (5.3:1). */
.input-v2-kpi-status.is-status-ready {
  color: #0f6b34;
  background: color-mix(in srgb, var(--accent-green, #16a34a) 14%, transparent);
}

.input-v2-kpi-status.is-status-ready .input-v2-status-dot {
  background: var(--accent-green, #16a34a);
}

.input-v2-kpi-status.is-status-check {
  color: var(--warn, #b45309);
  background: color-mix(in srgb, var(--warn, #f59e0b) 14%, transparent);
}

.input-v2-kpi-status.is-status-check .input-v2-status-dot {
  background: var(--warn, #f59e0b);
}

.input-v2-kpi-status.is-status-blocked {
  color: var(--error, #b91c1c);
  background: color-mix(in srgb, var(--error, #dc2626) 12%, transparent);
}

.input-v2-kpi-status.is-status-blocked .input-v2-status-dot {
  background: var(--error, #dc2626);
}

.input-v2-kpi-status.is-status-new {
  color: var(--text-2, #64748b);
  background: color-mix(in srgb, var(--text-2, #64748b) 10%, transparent);
}

.input-v2-kpi-status.is-status-new .input-v2-status-dot {
  background: var(--text-2, #64748b);
  opacity: 0.5;
}

.input-v2-section {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  overflow: hidden;
}

.input-v2-section-header {
  padding: 14px 16px 8px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.input-v2-section-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.input-v2-table-wrap {
  overflow-x: auto;
}

.input-v2-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.input-v2-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface, #fff);
  font-weight: 500;
  font-size: 11px;
  color: var(--text-2, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  vertical-align: bottom;
}

.input-v2-table th.input-v2-row-label-head {
  text-align: left;
  padding-left: 14px;
  width: 180px;
  min-width: 180px;
  /* v2.4: top-left угол sticky (top + left). Пересечение sticky-top
     col-headers и sticky-left row-labels — z-index выше обоих, чтобы
     при горизонтальном скролле текст не просвечивал. */
  left: 0;
  z-index: 3;
}

.input-v2-col-header {
  width: 86px;
  min-width: 86px;
}

/* v2: 3 видимых уровня — default «таблетка» с лёгким бордером, hover
   усилен, selected ярко выделен. Owner ловил «всё сливается» в v1. */
.input-v2-col-pick {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 6px 4px;
  background: transparent;
  border: 1px solid var(--border, #e2e8f0);
  cursor: pointer;
  font: inherit;
  color: var(--text-2, #64748b);
  border-radius: 6px;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.input-v2-col-pick:hover {
  background: color-mix(in srgb, var(--accent, #6366f1) 10%, transparent);
  border-color: color-mix(in srgb, var(--accent, #6366f1) 40%, transparent);
  color: var(--text-1, #0f172a);
}

.input-v2-col-header.is-selected .input-v2-col-pick {
  background: color-mix(in srgb, var(--accent, #6366f1) 16%, transparent);
  border-color: var(--accent, #6366f1);
  color: var(--accent, #6366f1);
  font-weight: 600;
}

.input-v2-col-header.is-closed .input-v2-col-pick {
  opacity: 0.55;
}

.input-v2-col-name {
  font-size: 11px;
  letter-spacing: 0.04em;
}

.input-v2-row-label {
  text-align: left;
  padding: 8px 12px 8px 14px;
  font-weight: 500;
  font-size: 13px;
  color: var(--text-1, #0f172a);
  vertical-align: middle;
  background: var(--surface, #fff);
  border-bottom: 1px solid color-mix(in srgb, var(--border, #e2e8f0) 50%, transparent);
  /* v2.4: первая колонка sticky при горизонтальном скролле. Сохраняем
     контекст какой именно строки сейчас в фокусе. Background обязателен,
     чтобы перекрывать едущие ячейки. */
  position: sticky;
  left: 0;
  z-index: 2;
}

.input-v2-row-name {
  display: block;
  line-height: 1.3;
}

.input-v2-row-sub {
  display: block;
  font-size: 11px;
  color: var(--text-2, #64748b);
  font-weight: 400;
}

.input-v2-group-row .input-v2-group-label {
  padding: 8px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2, #64748b);
  background: color-mix(in srgb, var(--text-2, #64748b) 5%, transparent);
  border-top: 1px solid var(--border, #e2e8f0);
}

/* v2.1: цифры центрируются под меткой месяца. Anomaly-badge ставится
   абсолютно справа — input не съёжается. */
.input-v2-cell {
  padding: 4px 4px;
  text-align: center;
  vertical-align: middle;
  border-bottom: 1px solid color-mix(in srgb, var(--border, #e2e8f0) 50%, transparent);
  position: relative;
}

.input-v2-cell .input-v2-readonly,
.input-v2-cell output.input-v2-readonly {
  display: inline-block;
  width: 100%;
  text-align: center;
}

.input-v2-cell .meter-cell-wrapper {
  position: relative;
  display: block;
}

.input-v2-cell .meter-cell-wrapper .meter-anomaly-slot {
  position: absolute;
  right: -2px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: auto;
}

/* Y4 (owner-feedback): длинные числа («1 234 567») в ячейке Показаний
   налезали на anomaly-slot (он absolute поверх правого края). Делаем
   padding-right у input внутри meter-cell-wrapper, чтобы цифры не
   доходили до значка. Применяется ко всем ячейкам с slot, даже если
   badge пуст — layout остаётся стабильным. */
.input-v2-cell .meter-cell-wrapper > input {
  padding-right: 20px;
}

.input-v2-cell.is-selected {
  /* v2.5: selected month column is rendered as a separate capsule inside
     the table cells. It visually matches the month button width without
     attaching to the header, and keeps row dividers quiet. */
  background: transparent;
}

.input-v2-cell.is-selected::before {
  content: "";
  position: absolute;
  inset: 0 4px;
  pointer-events: none;
  background: color-mix(in srgb, var(--accent, #6366f1) 8%, transparent);
  border-right: 1px solid color-mix(in srgb, var(--accent, #6366f1) 38%, transparent);
  border-left: 1px solid color-mix(in srgb, var(--accent, #6366f1) 38%, transparent);
  border-bottom: 1px dashed color-mix(in srgb, var(--accent, #6366f1) 18%, transparent);
}

.input-v2-table tbody tr:first-child .input-v2-cell.is-selected::before {
  border-top: 1px solid color-mix(in srgb, var(--accent, #6366f1) 38%, transparent);
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
}

.input-v2-table tbody tr:not(:has(.input-v2-cell.is-selected)) + tr .input-v2-cell.is-selected::before {
  border-top: 1px solid color-mix(in srgb, var(--accent, #6366f1) 38%, transparent);
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
}

.input-v2-table tbody tr:last-child .input-v2-cell.is-selected::before {
  border-bottom: 1px solid color-mix(in srgb, var(--accent, #6366f1) 38%, transparent);
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
}

.input-v2-table tbody tr:has(.input-v2-cell.is-selected):has(+ tr:not(:has(.input-v2-cell.is-selected))) .input-v2-cell.is-selected::before {
  border-bottom: 1px solid color-mix(in srgb, var(--accent, #6366f1) 38%, transparent);
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
}

.input-v2-cell.is-closed {
  background: color-mix(in srgb, var(--text-2, #64748b) 4%, transparent);
  opacity: 0.55;
}

.input-v2-cell input {
  width: 100%;
  max-width: 80px;
  padding: 4px 6px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 4px;
  color: inherit;
}

.input-v2-cell input:focus {
  outline: none;
  border-color: var(--accent, #6366f1);
  background: var(--surface, #fff);
}

.input-v2-cell input:disabled {
  cursor: not-allowed;
  color: var(--text-2, #64748b);
}

.input-v2-cell.is-selected input {
  /* v2.4: input border 30% → 40% — согласовано с мягкой заливкой 8%. */
  border-color: color-mix(in srgb, var(--accent, #6366f1) 40%, transparent);
}

.input-v2-cell-readonly .input-v2-readonly {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--text-1, #0f172a);
}

.input-v2-cell-readonly .money-explain {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  position: relative;
  width: 100%;
  box-sizing: border-box;
  padding: 0;
  text-align: center;
}

.input-v2-cell-readonly .money-explain .money-explain-icon {
  position: static;
  transform: none;
}

/* v2.2: signed-tone — положительная зелёная (солнце покрыло),
   отрицательная красная (потери), ноль нейтральный. */
.input-v2-delta-row .input-v2-cell.is-tone-zero .input-v2-readonly {
  color: var(--text-2, #64748b);
  font-weight: 500;
}

.input-v2-delta-row .input-v2-cell.is-tone-positive .input-v2-readonly {
  color: #0f6b34;
  font-weight: 600;
}

.input-v2-delta-row .input-v2-cell.is-tone-negative .input-v2-readonly {
  color: var(--error, #b91c1c);
  font-weight: 600;
}

.input-v2-delta-row .input-v2-cell.is-tone-muted .input-v2-readonly {
  color: var(--text-2, #64748b);
}

.input-v2-sum-row .input-v2-row-label,
.input-v2-delta-row .input-v2-row-label {
  font-weight: 600;
  background: color-mix(in srgb, var(--text-2, #64748b) 3%, var(--surface, #fff));
}

.input-v2-sum-row,
.input-v2-delta-row {
  border-top: 1px solid var(--border, #e2e8f0);
}

.input-v2-start {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  padding: 4px 16px;
}

.input-v2-start summary {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  cursor: pointer;
  list-style: none;
}

.input-v2-start summary::-webkit-details-marker { display: none; }

.input-v2-start summary::before {
  content: "›";
  display: inline-block;
  transform: rotate(0deg);
  transition: transform 0.15s ease;
  color: var(--text-2, #64748b);
  font-weight: 600;
}

.input-v2-start[open] summary::before {
  transform: rotate(90deg);
}

.input-v2-start-title {
  font-weight: 600;
}

.input-v2-start-summary {
  color: var(--text-2, #64748b);
  font-size: 12px;
}

.input-v2-start-body {
  padding-bottom: 12px;
}

.input-v2-start-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.input-v2-start-table th,
.input-v2-start-table td {
  padding: 6px 8px;
  border-bottom: 1px solid color-mix(in srgb, var(--border, #e2e8f0) 50%, transparent);
}

.input-v2-start-table th {
  text-align: left;
  font-weight: 500;
}

/* v2.1: start-toggle — отдельная кнопка в section header (НЕ в шапке
   таблицы). Колонка стартовых показаний появляется в таблице только
   когда expanded — alignment с DTEK / Солнце сохраняется. */
.input-v2-section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.input-v2-start-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--border, #e2e8f0);
  color: var(--text-2, #64748b);
  font-family: inherit;
}

.input-v2-start-button:hover {
  border-color: var(--accent, #6366f1);
  color: var(--accent, #6366f1);
}

.input-v2-start-button[aria-expanded="true"] {
  background: color-mix(in srgb, var(--accent, #6366f1) 8%, transparent);
  border-color: var(--accent, #6366f1);
  color: var(--accent, #6366f1);
}

.input-v2-start-button-icon {
  font-size: 11px;
}

.input-v2-start-th {
  width: 110px;
  min-width: 110px;
  padding: 6px 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.input-v2-start-th-label {
  display: block;
}

.input-v2-start-th-date {
  display: block;
  margin-top: 2px;
}

.input-v2-start-th-date input {
  width: 100%;
  max-width: 100px;
  padding: 2px 4px;
  font-size: 10px;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--surface, #fff);
  border-radius: 3px;
  text-align: center;
}

/* v2.3a: статус-строка внизу каждой таблицы (как колонка «Проверка» в renderInput). */
.input-v2-status-row .input-v2-cell-status {
  padding: 4px 2px;
  text-align: center;
  vertical-align: middle;
}

.input-v2-status-row .input-v2-row-label {
  font-weight: 600;
  background: color-mix(in srgb, var(--text-2, #64748b) 3%, var(--surface, #fff));
}

/* v2.3a: lock-бейдж в шапке закрытых месяцев (visible для всех закрытых,
   не только selected). */
.input-v2-col-lock {
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
  opacity: 0.75;
}

/* v2.4: scoped — CHECK/READY pills в input_v2 status row делаем тише.
   Глобальный .status оставляем для overview/rent/combined как есть. */
.input-v2-cell-status .status {
  border-color: transparent;
  background: transparent;
  font-size: 11px;
  padding: 1px 6px;
  min-width: 0;
}
.input-v2-cell-status .status.ok {
  color: var(--text-2, #64748b);
}
.input-v2-cell-status .status.warn {
  color: var(--warn, #b45309);
  background: color-mix(in srgb, var(--warn, #f59e0b) 8%, transparent);
}
.input-v2-cell-status .status.error {
  color: var(--error, #b91c1c);
  background: color-mix(in srgb, var(--error, #dc2626) 8%, transparent);
}

/* v2.4: row hover — при наведении любая строка таблицы тинтуется accent-ом,
   чтобы глаз не «терялся» при чтении длинных горизонтальных строк. Это
   касается ручных input rows и расчётных sum/delta/status rows. is-selected
   ячейки сохраняют свой accent, чтобы выбранный месяц оставался главным. */
.input-v2-table tbody tr:hover .input-v2-row-label,
.input-v2-table tbody tr:hover .input-v2-group-label {
  background-color: color-mix(in srgb, var(--accent, #6366f1) 4%, var(--surface, #fff));
}

.input-v2-table tbody tr:hover .input-v2-cell:not(.is-selected):not(.is-closed),
.input-v2-table tbody tr:hover .input-v2-start-cell:not(.is-closed) {
  background-color: color-mix(in srgb, var(--accent, #6366f1) 4%, transparent);
}

.input-v2-start-cell {
  padding: 4px 2px;
  vertical-align: middle;
  border-bottom: 1px solid color-mix(in srgb, var(--border, #e2e8f0) 50%, transparent);
  background: color-mix(in srgb, var(--text-2, #64748b) 3%, var(--surface, #fff));
  width: 96px;
  min-width: 96px;
  text-align: center;
}

.input-v2-start-cell input {
  width: 100%;
  max-width: 86px;
  padding: 4px 6px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 4px;
}

.input-v2-start-cell input:focus {
  border-color: var(--accent, #6366f1);
  background: var(--surface, #fff);
  outline: none;
}

.input-v2-start-cell.is-na {
  background: transparent;
}

.input-v2-start-cell.is-na .meter-no-start {
  font-size: 10px;
  font-style: italic;
}

/* Дата под label месяца («МАЙ 01.06»). */
.input-v2-col-date {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-2, #64748b);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

/* Y5: editable date input под label выбранного месяца. Компактный,
   подключён к autosave через data-month + data-field="date". */
.input-v2-col-date-input {
  display: block;
  width: 100%;
  margin-top: 2px;
  padding: 2px 4px;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--surface, #fff);
  color: var(--text-2, #64748b);
  border-radius: 3px;
  cursor: text;
}
.input-v2-col-date-input:focus {
  outline: none;
  border-color: var(--accent, #6366f1);
  color: var(--text-1, #0f172a);
}
.input-v2-col-header.is-closed .input-v2-col-date-input {
  opacity: 0.55;
  cursor: not-allowed;
}

/* A11y helper: visually hidden, но доступно screen-reader'у. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
