/* BraginRate — B2B SaaS UI (TZ §13) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg-app: #F6F8FB;
  --bg-card: #FFFFFF;
  --text: #111827;
  --text-muted: #6B7280;
  --border: #E5E7EB;
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-soft: #EFF6FF;
  --accent: #4F46E5;
  --success: #16A34A;
  --warn: #D97706;
  --danger: #DC2626;
  --neutral-badge: #F3F4F6;
  --sidebar-w: 260px;
  --header-h: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --content-max: 1440px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}

.tabular { font-variant-numeric: tabular-nums; }

a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

/* ——— Auth (login/register) ——— */
body.layout-auth {
  margin: 0;
  padding: 0;
  background: var(--bg-card);
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
}

body.layout-auth > .auth-split {
  display: grid;
  grid-template-columns: minmax(0, 45%) minmax(0, 55%);
  min-height: 100vh;
  width: 100%;
  max-width: none;
  margin: 0;
}

.auth-split {
  display: grid;
  grid-template-columns: minmax(0, 45%) minmax(0, 55%);
  min-height: 100vh;
  width: 100%;
}

.auth-marketing {
  background: linear-gradient(160deg, #1e3a8a 0%, #2563eb 55%, #4f46e5 100%);
  color: #fff;
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-marketing .brand-lg {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 32px;
}

.auth-marketing h1 {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 16px;
  max-width: 420px;
}

.auth-marketing .lead {
  font-size: 16px;
  opacity: 0.9;
  margin: 0 0 32px;
  max-width: 400px;
}

.auth-features {
  list-style: none;
  padding: 0;
  margin: 0;
}

.auth-features li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 15px;
}

.auth-features .icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.auth-panel-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  background: var(--bg-app);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
}

.auth-card h2 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
}

.auth-card .sub {
  color: var(--text-muted);
  margin: 0 0 24px;
  font-size: 14px;
}

.password-field {
  position: relative;
  display: block;
  width: 100%;
}
.password-field input {
  width: 100%;
  padding-right: 44px;
}
.password-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
}
.password-toggle:hover {
  color: var(--text);
  background: var(--primary-soft);
}
.password-toggle:focus-visible {
  outline: 2px solid #93C5FD;
  outline-offset: 0;
}
.password-toggle .icon-eye-off {
  display: none;
}
.password-toggle.is-visible .icon-eye {
  display: none;
}
.password-toggle.is-visible .icon-eye-off {
  display: block;
}

.br-suggest-wrap {
  position: relative;
}
.br-suggest-wrap .hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}
.br-suggest-list {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 6px 0;
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
}
.br-suggest-list.hidden { display: none; }
.br-suggest-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.br-suggest-item:hover,
.br-suggest-item.active {
  background: #eff6ff;
}
.br-suggest-item-title {
  font-size: 14px;
  color: var(--text);
}
.br-suggest-item-meta {
  font-size: 12px;
  color: var(--text-muted);
}

@media (max-width: 767px) {
  body.layout-auth > .auth-split,
  .auth-split {
    grid-template-columns: 1fr;
    width: 100%;
  }
  .auth-marketing { display: none; }
  .auth-panel-wrap {
    min-height: 100vh;
    width: 100%;
    padding: 20px 16px;
    box-sizing: border-box;
  }
  .auth-card {
    max-width: none;
    width: 100%;
    border: none;
    border-radius: 0;
    padding: 24px 20px;
    box-shadow: none;
  }
}

/* ——— App shell ——— */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(17,24,39,0.4);
  z-index: 1090;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1100;
  transition: transform 0.2s ease;
}

.sidebar-brand {
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand a {
  text-decoration: none;
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.sidebar-brand .org {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
}

.nav-section {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 12px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 2px;
}

.nav-item:hover { background: var(--primary-soft); color: var(--primary); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-item.disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: default;
}

.nav-item .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
  opacity: 0.85;
}

.nav-with-submenu {
  position: relative;
}
.nav-with-submenu > .nav-item {
  padding-right: 40px;
}
.nav-submenu-toggle {
  position: absolute;
  right: 8px;
  top: 7px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.nav-submenu-toggle:hover {
  background: var(--primary-soft);
  color: var(--primary);
}
.nav-submenu {
  margin: 2px 0 8px 26px;
  border-left: 1px dashed var(--border);
  padding-left: 10px;
}
.nav-submenu-item {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 5px 4px;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-submenu-item:hover {
  background: var(--primary-soft);
  color: var(--primary);
}
.nav-submenu-item.active {
  color: var(--primary);
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.sidebar-footer .import-status {
  padding: 8px 10px;
  background: var(--bg-app);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.sidebar-footer .import-status.ok { border-left: 3px solid var(--success); }
.sidebar-footer .import-status.warn { border-left: 3px solid var(--warn); }
.sidebar-footer .import-status-updated {
  display: inline-block;
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-muted);
}

.app-body {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.topbar {
  height: var(--header-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  font-size: 18px;
}

.topbar-titles { flex: 1; min-width: 0; }
.topbar-titles h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.topbar-titles .subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.breadcrumbs a { color: var(--text-muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs span.sep { opacity: 0.5; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topbar-user {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: 8px;
}

.topbar-user a { color: var(--text-muted); }

.client-bell {
  position: relative;
}
.client-bell-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
}
.client-bell-icon { font-size: 16px; line-height: 1; }
.client-bell-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: #b91c1c;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.client-bell-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(360px, calc(100vw - 24px));
  max-height: 420px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  z-index: 40;
}
.client-bell-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.client-bell-list {
  overflow: auto;
  max-height: 360px;
}
.client-bell-empty {
  margin: 0;
  padding: 16px 12px;
  font-size: 13px;
}
.client-bell-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: #fff;
  padding: 10px 12px;
  cursor: pointer;
  color: inherit;
  text-decoration: none;
  font: inherit;
}
.client-bell-item:hover { background: #F9FAFB; }
.client-bell-item.is-unread { background: #FFF7ED; }
.client-bell-title { font-size: 13px; font-weight: 600; }
.client-bell-body { font-size: 13px; margin-top: 2px; }
.client-bell-reason { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.client-bell-meta { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

.app-content {
  flex: 1;
  padding: 24px 28px 32px;
  max-width: var(--content-max);
  width: 100%;
}

/* ——— Page blocks ——— */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-header-text h1 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 700;
}

.page-header-text .lead {
  margin: 0;
  color: var(--text-muted);
  font-size: 15px;
  max-width: 560px;
}

.page-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
}

.panel h2, .panel h3 {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 600;
}

.panel-accent {
  background: var(--primary-soft);
  border-color: #BFDBFE;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
  width: 100%;
}

.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
}

.kpi .kpi-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.kpi .val {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.kpi .val.accent { color: var(--primary); }
.kpi .hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.kpi .delta {
  font-size: 12px;
  font-weight: 600;
  margin-top: 6px;
}

.kpi .delta.up { color: var(--success); }
.kpi .delta.warn { color: var(--warn); }

.alerts-panel .alert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.alerts-panel .alert-row:last-child { border-bottom: none; }

/* Forms & buttons */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  align-items: end;
}

.form-grid-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 2px;
}

.form-grid-actions .btn {
  white-space: normal;
  text-align: center;
}

label span, label { font-size: 13px; font-weight: 500; color: var(--text-muted); }
label { display: flex; flex-direction: column; gap: 6px; }

input, select, textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--text);
  background: #fff;
}

input:focus, select:focus {
  outline: 2px solid #93C5FD;
  border-color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
a.btn-primary,
a.btn-primary:hover,
a.btn-primary:focus-visible {
  color: #fff;
}
.btn-secondary { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }
a.btn-secondary,
a.btn-secondary:hover {
  color: var(--text);
}
.btn-secondary:hover { background: var(--bg-app); }
.btn-ghost { background: transparent; color: var(--primary); border: 1px solid transparent; }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-danger-ghost { background: transparent; color: var(--danger, #c62828); border: 1px solid transparent; }
.btn-danger-ghost:hover { background: rgba(198, 40, 40, 0.08); }
.portfolio-unit-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: center; }
.toolbar-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}
.toolbar-title-group h2 {
  margin: 0;
  line-height: 1.3;
}

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -4px; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

table.data th, table.data td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.data th {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: none;
  background: #F9FAFB;
}

table.data tbody tr:hover td { background: #F9FAFB; }

table.data .col-nowrap,
table.data th.col-nowrap,
table.data td.col-nowrap {
  white-space: nowrap;
}

table.data .price-range {
  white-space: nowrap;
}

.portfolio-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.portfolio-units-table {
  width: 100%;
  min-width: 960px;
  table-layout: auto;
}

table.portfolio-units-table th:first-child,
table.portfolio-units-table td:first-child {
  min-width: 180px;
}

table.portfolio-units-table .object-name {
  display: block;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.object-name { font-weight: 600; color: var(--text); }
.object-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Mobile object cards */
.object-cards { display: none; }

.object-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.object-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 12px;
}

.object-card-prices {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-variant-numeric: tabular-nums;
  margin-bottom: 8px;
}

.object-card-prices .arrow { color: var(--text-muted); }
.object-card-footer { display: flex; gap: 8px; margin-top: 12px; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
}

.badge-up { background: #DCFCE7; color: #166534; }
.badge-down { background: #FEE2E2; color: #991B1B; }
.badge-hold { background: #E0E7FF; color: #3730A3; }
.badge-warn { background: #FEF3C7; color: #92400E; }
.badge-ok { background: #DCFCE7; color: #166534; }
.badge-neutral { background: var(--neutral-badge); color: var(--text-muted); }

/* Шкала качества: 5 = лучше (зелёный) → 1 = хуже (красный) */
.badge-scale-5 { background: #DCFCE7; color: #14532D; }
.badge-scale-4 { background: #ECFCCB; color: #365314; }
.badge-scale-3 { background: #FEF9C3; color: #854D0E; }
.badge-scale-2 { background: #FFEDD5; color: #9A3412; }
.badge-scale-1 { background: #FEE2E2; color: #991B1B; }

.cal-day-conf {
  display: block;
  font-size: 9px;
  font-weight: 600;
  margin-top: 2px;
  padding: 1px 4px;
  border-radius: 4px;
  line-height: 1.2;
}
.cal-day-conf.badge-scale-5 { background: #DCFCE7; color: #14532D; }
.cal-day-conf.badge-scale-4 { background: #ECFCCB; color: #365314; }
.cal-day-conf.badge-scale-3 { background: #FEF9C3; color: #854D0E; }
.cal-day-conf.badge-scale-2 { background: #FFEDD5; color: #9A3412; }
.cal-day-conf.badge-scale-1 { background: #FEE2E2; color: #991B1B; }

/* Unit price calendar grid */
.cal-pager-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 14px;
  background: #F9FAFB;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.cal-pager-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  min-width: min(100%, 420px);
}

.cal-grid-wrap {
  display: flex;
  flex-direction: column;
  gap: 28px;
  width: 100%;
  margin-top: 8px;
}

.cal-month {
  width: 100%;
}

.cal-month-title {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 600;
  text-transform: capitalize;
}

.cal-weekdays,
.cal-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.cal-weekdays {
  margin-bottom: 6px;
}

.cal-weekdays span {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 0;
  letter-spacing: 0.02em;
}

.cal-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 76px;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font: inherit;
  text-align: center;
  box-sizing: border-box;
  width: 100%;
}

button.cal-day {
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

button.cal-day:hover {
  border-color: #93C5FD;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.12);
  transform: translateY(-1px);
}

button.cal-day:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.cal-day--empty {
  border: none;
  background: transparent;
  min-height: 0;
  padding: 0;
  pointer-events: none;
}

.cal-day--muted {
  background: #F3F4F6;
  border-color: #E5E7EB;
  opacity: 0.75;
}

/* Архив: прошедшие даты — только просмотр цены */
.cal-day--past,
button.cal-day.cal-day--past {
  background: #F3F4F6 !important;
  border-color: #D1D5DB !important;
  box-shadow: none !important;
  opacity: 0.92;
  cursor: pointer;
}
.cal-day--past .cal-day-rec {
  color: #4B5563;
  font-weight: 600;
}
.cal-day--past .cal-day-num {
  color: #9CA3AF;
}
.cal-day--past-empty {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
}
button.cal-day.cal-day--past:hover {
  border-color: #9CA3AF !important;
  box-shadow: none !important;
  transform: none;
}
.cal-tag--past {
  background: #E5E7EB;
  color: #6B7280;
}
.cal-tag--occ {
  background: #FEE2E2;
  color: #991B1B;
}
.cal-tag--unk {
  background: #FEF3C7;
  color: #92400E;
}
.cal-tag--free {
  background: #DCFCE7;
  color: #166534;
}
.cal-day--occupied:not(.cal-day--past) {
  background: repeating-linear-gradient(
    -45deg,
    #FEF2F2,
    #FEF2F2 6px,
    #FFF7F7 6px,
    #FFF7F7 12px
  );
  border-color: #FCA5A5;
}
.cal-day--unknown:not(.cal-day--past) {
  border-style: dashed;
  border-color: #F59E0B;
}
.cal-day-rec--history {
  opacity: 0.72;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}
#cal-table tbody tr.cal-row--occupied {
  background: rgba(254, 226, 226, 0.35);
}
#cal-table tbody tr.cal-row--unknown {
  background: rgba(254, 243, 199, 0.4);
}
#cal-table tbody tr.cal-row--past {
  background: #F9FAFB;
  color: #6B7280;
}
#cal-table tbody tr.cal-row--past td {
  border-color: #F3F4F6;
}
#cal-table tbody tr.cal-row--past strong {
  color: #4B5563;
}

/* Lead-time zone: фон и рамка ячейки (главный смысл цвета) */
.cal-day--lt-min {
  background: linear-gradient(180deg, #FEF2F2 0%, #FFF5F5 100%);
  border-color: #FCA5A5;
  box-shadow: inset 0 0 0 1px rgba(220, 38, 38, 0.2);
}
.cal-day--lt-base {
  background: linear-gradient(180deg, #EFF6FF 0%, #F0F9FF 100%);
  border-color: #93C5FD;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.18);
}
.cal-day--lt-max {
  background: linear-gradient(180deg, #ECFDF5 0%, #F0FDF4 100%);
  border-color: #86EFAC;
  box-shadow: inset 0 0 0 1px rgba(22, 163, 74, 0.2);
}

/* Тренд vs текущая цена — только стрелка, не фон ячейки */
.cal-day-trend--up .cal-day-arrow { color: #16A34A; }
.cal-day-trend--down .cal-day-arrow { color: #DC2626; }
.cal-day-trend--hold .cal-day-arrow { color: var(--text-muted); }

/* Fallback, если зона не определена */
.cal-day--up:not(.cal-day--lt-min):not(.cal-day--lt-base):not(.cal-day--lt-max) {
  background: linear-gradient(180deg, #ECFDF5 0%, #F0FDF4 100%);
  border-color: #86EFAC;
}
.cal-day--down:not(.cal-day--lt-min):not(.cal-day--lt-base):not(.cal-day--lt-max) {
  background: linear-gradient(180deg, #FEF2F2 0%, #FFF5F5 100%);
  border-color: #FCA5A5;
}
.cal-day--hold:not(.cal-day--lt-min):not(.cal-day--lt-base):not(.cal-day--lt-max) {
  background: #F9FAFB;
  border-color: var(--border);
}

.cal-day--accepted {
  box-shadow: inset 0 0 0 2px var(--primary);
}
.cal-day--weekend {
  border-style: dashed;
}
.cal-day--lm {
  box-shadow: inset 0 0 0 2px rgba(220, 38, 38, 0.45);
}

.cal-day-num {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.2;
}

.cal-day-rec {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.cal-day-arrow {
  font-size: 12px;
  font-weight: 600;
  margin-top: 2px;
  line-height: 1;
}
.cal-day-tags {
  display: flex;
  gap: 4px;
  margin-top: 3px;
  min-height: 14px;
}
.cal-tag {
  display: inline-block;
  border-radius: 4px;
  padding: 1px 4px;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.02em;
}
.cal-tag--weekend {
  background: #FEF3C7;
  color: #92400E;
}
.cal-tag--lm {
  background: #FEE2E2;
  color: #991B1B;
}
.cal-tag--lt-min {
  background: #FEE2E2;
  color: #991B1B;
}
.cal-tag--lt-base {
  background: #DBEAFE;
  color: #1D4ED8;
}
.cal-tag--lt-max {
  background: #DCFCE7;
  color: #166534;
}

.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin-top: 4px;
  padding: 12px 16px;
  background: #F9FAFB;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
}

.cal-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.cal-legend-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}

.cal-legend-swatch--up { background: #ECFDF5; border-color: #86EFAC; }
.cal-legend-swatch--down { background: #FEF2F2; border-color: #FCA5A5; }
.cal-legend-swatch--hold { background: #F9FAFB; border-color: var(--border); }
.cal-legend-swatch--accepted { background: #fff; box-shadow: inset 0 0 0 2px var(--primary); }
.cal-legend-swatch--lt-min { background: #FEE2E2; border-color: #FCA5A5; }
.cal-legend-swatch--lt-base { background: #DBEAFE; border-color: #93C5FD; }
.cal-legend-swatch--lt-max { background: #DCFCE7; border-color: #86EFAC; }
.cal-legend-swatch--past { background: #F3F4F6; border-color: #D1D5DB; }
.cal-legend-swatch--occ { background: #FEE2E2; border-color: #FCA5A5; }
.cal-legend-swatch--unk { background: #FEF3C7; border-color: #F59E0B; border-style: dashed; }

.cal-lt-legend {
  margin-top: 12px;
}

.cal-lt-zone .cal-tag {
  font-size: 11px;
  padding: 2px 8px;
}

#cal-table tbody tr.cal-row--lt-min {
  background: linear-gradient(90deg, rgba(254, 226, 226, 0.35) 0%, transparent 48%);
}
#cal-table tbody tr.cal-row--lt-base {
  background: linear-gradient(90deg, rgba(219, 234, 254, 0.35) 0%, transparent 48%);
}
#cal-table tbody tr.cal-row--lt-max {
  background: linear-gradient(90deg, rgba(220, 252, 231, 0.35) 0%, transparent 48%);
}
#cal-table tbody tr.cal-row--lt-min td:first-child {
  box-shadow: inset 3px 0 0 #DC2626;
}
#cal-table tbody tr.cal-row--lt-base td:first-child {
  box-shadow: inset 3px 0 0 #2563EB;
}
#cal-table tbody tr.cal-row--lt-max td:first-child {
  box-shadow: inset 3px 0 0 #16A34A;
}

@media (max-width: 900px) {
  .cal-weekdays,
  .cal-days {
    gap: 4px;
  }
  .cal-day {
    min-height: 64px;
    padding: 6px 4px;
  }
  .cal-day-rec {
    font-size: 11px;
  }
}

@media (max-width: 520px) {
  .cal-day {
    min-height: 56px;
    padding: 4px 2px;
  }
  .cal-day-num {
    font-size: 10px;
  }
  .cal-day-rec {
    font-size: 10px;
  }
  .cal-day-conf {
    display: none;
  }
  .cal-day-arrow {
    font-size: 10px;
  }
}

/* Unit page */
.object-hero {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  justify-content: space-between;
  align-items: flex-start;
}

.object-hero-main h1 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
}

.object-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.tag {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--neutral-badge);
  color: var(--text-muted);
  font-weight: 500;
}

.object-hero-prices {
  text-align: right;
  min-width: 200px;
}

.object-hero-prices .price-lg {
  font-size: 32px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
}

.object-hero-prices .price-label { font-size: 12px; color: var(--text-muted); }

.recommendation-card {
  background: linear-gradient(135deg, #EFF6FF 0%, #EEF2FF 100%);
  border: 1px solid #BFDBFE;
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
}

.recommendation-card h3 { margin: 0 0 8px; font-size: 20px; }
.recommendation-card p { margin: 0 0 14px; color: var(--text-muted); font-size: 14px; }

.steps {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
}

.step {
  flex: 1;
  padding: 12px 14px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-right: 1px solid var(--border);
}

.step:last-child { border-right: none; }
.step.done { background: #ECFDF5; color: var(--success); }
.step.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab {
  padding: 12px 18px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}

.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active {
  display: block;
  width: 100%;
  min-width: 0;
}

.unit-page {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
}

.unit-page .kpi-row {
  margin-bottom: 20px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.kpi .val--badge {
  font-size: inherit;
  font-weight: inherit;
  line-height: 1.2;
  display: flex;
  align-items: center;
  min-height: 34px;
}

.econ-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}

.econ-mode-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin: 0 0 12px;
  padding: 10px 12px;
  background: #F9FAFB;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.econ-mode-option {
  margin: 0;
  font-weight: 600;
}
.econ-mode-badge {
  margin: 0 0 10px;
  font-size: 13px;
}

.org-expenses-legend {
  margin: 8px 0 12px 1.1em;
  padding: 0;
  line-height: 1.45;
}
.org-exp-unit-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px 12px;
  margin-top: 10px;
  max-height: 280px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.org-expenses-period,
.org-expenses-create,
.org-expenses-add-item {
  max-width: 720px;
}
/* Длинный лейбл «Знаменатель…» не должен сдвигать соседние инпуты вниз */
.org-expenses-create {
  align-items: start;
}
.org-expenses-create > label {
  display: grid;
  grid-template-rows: minmax(2.8em, auto) auto auto;
  gap: 6px;
  align-content: start;
}
.org-expenses-create .field-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.35;
}

@media (max-width: 900px) {
  .econ-mode-toggle {
    flex-direction: column;
  }
  .org-exp-unit-list {
    grid-template-columns: 1fr;
    max-height: 220px;
  }
}

.econ-live {
  position: sticky;
  top: calc(var(--header-h) + 16px);
}

.econ-live .kpi { margin-bottom: 12px; text-align: left; }

.econ-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px 16px;
  margin: 0 0 16px;
}
.econ-fieldset legend {
  font-weight: 600;
  padding: 0 6px;
}
.econ-grid {
  margin-top: 8px;
  align-items: start;
}
.econ-grid label {
  display: grid;
  grid-template-rows: minmax(2.7em, auto) auto auto;
  gap: 4px;
  align-content: start;
}
.econ-grid .field-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.35;
  font-weight: 400;
}
.econ-intro,
.econ-section-hint,
.econ-aside-hint {
  font-size: 13px;
  line-height: 1.45;
}
.econ-intro { margin: 0 0 14px; }
.econ-section-hint { margin: 0 0 8px; }
.econ-aside-hint { margin: 14px 0 0; font-size: 12px; }
.econ-breakdown {
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.econ-breakdown dt { color: var(--text-muted); font-size: 12px; }
.econ-breakdown dd { margin: 0 0 8px; font-weight: 500; }

.econ-profit {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #F9FAFB;
}
.econ-profit-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
}
.econ-profit-badge {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-muted);
}
.econ-profit-badge strong {
  color: var(--text);
  font-weight: 600;
}
.econ-profit .econ-breakdown {
  margin-top: 8px;
  padding-top: 8px;
}
.econ-profit-hint {
  font-size: 12px;
  margin: 8px 0 0;
  line-height: 1.4;
}
.econ-profit-assumptions {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.econ-profit-assumptions summary {
  cursor: pointer;
  user-select: none;
}
.econ-profit-assumptions ul {
  margin: 6px 0 0;
  padding-left: 1.2em;
}
.econ-profit--pos {
  border-color: #86efac;
  background: #f0fdf4;
}
.econ-profit--pos .econ-profit-val {
  color: #166534;
}
.econ-profit--neg {
  border-color: #fca5a5;
  background: #fef2f2;
}
.econ-profit--neg .econ-profit-val {
  color: #b91c1c;
  font-weight: 700;
}
.econ-profit-neg-note {
  color: #b91c1c;
}
.econ-profit--zero .econ-profit-val {
  color: var(--text);
}

.cal-explain-hint {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.45;
}

.listing-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 14px;
  background: #F9FAFB;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
}

.listing-preview dt { font-size: 12px; color: var(--text-muted); }
.listing-preview dd { margin: 0 0 8px; font-weight: 500; }

.confidence-block-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.confidence-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px 16px;
  margin: 12px 0 0;
}

.confidence-facts > div { margin: 0; }

.confidence-facts dt {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 2px;
}

.confidence-facts dd {
  margin: 0;
  font-weight: 500;
}

.confidence-inline-desc {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.45;
}

.cal-table-hint {
  margin: 0 0 10px;
  font-size: 13px;
}

.cal-conf-cell {
  min-width: 120px;
  max-width: 200px;
}

.cal-conf-hint {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.35;
}

.drawer-conf-desc {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.45;
}

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 13px;
}

.alert-info { background: #EFF6FF; border: 1px solid #BFDBFE; color: #1E40AF; }
.alert-warn { background: #FFFBEB; border: 1px solid #FDE68A; color: #92400E; }
.alert-error { background: #FEF2F2; border: 1px solid #FECACA; color: #991B1B; }

.hidden { display: none !important; }
.mono { font-family: ui-monospace, 'SF Mono', monospace; font-size: 13px; }
.mono-block {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  background: #F9FAFB;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  overflow: auto;
  max-height: 360px;
}

.text-muted { color: var(--text-muted); font-size: 13px; }
.text-right { text-align: right; }

@media (max-width: 767px) {
  .hidden-mobile { display: none; }
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state h3 { color: var(--text); margin: 0 0 8px; }

/* Bottom nav mobile */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}

.mobile-bottom-nav a {
  flex: 1;
  text-align: center;
  padding: 6px 2px;
  font-size: 9px;
  color: var(--text-muted);
  text-decoration: none;
}

.mobile-bottom-nav a.active { color: var(--primary); font-weight: 600; }
.mobile-bottom-nav .ico { display: block; font-size: 16px; margin-bottom: 2px; }

/* Responsive */
@media (max-width: 1279px) {
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1023px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .app-body { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .econ-layout { grid-template-columns: 1fr; }
  .econ-live { position: static; }
}

@media (max-width: 767px) {
  body.layout-app { overflow-x: hidden; }

  .app-content {
    padding: 16px;
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
    overflow-x: hidden;
    min-width: 0;
  }

  .kpi-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi { padding: 14px 12px; }
  .kpi .val { font-size: 22px; }

  .panel {
    padding: 16px;
    overflow-x: hidden;
    min-width: 0;
  }

  .topbar {
    flex-wrap: wrap;
    align-items: flex-start;
    height: auto;
    min-height: 56px;
    padding: 10px 12px;
    gap: 8px;
  }

  .menu-toggle { flex-shrink: 0; }

  .topbar-titles {
    flex: 1 1 0;
    min-width: 0;
    max-width: calc(100% - 100px);
  }

  .topbar-titles h1 {
    font-size: 17px;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  .topbar-titles .subtitle {
    font-size: 12px;
    line-height: 1.35;
    margin-top: 4px;
    overflow-wrap: anywhere;
  }

  .topbar-user {
    flex-shrink: 0;
    margin-left: auto;
    font-size: 12px;
    white-space: nowrap;
  }

  .topbar-actions {
    flex: 1 1 100%;
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
    order: 10;
    padding-top: 2px;
  }

  .topbar-actions .btn {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    white-space: normal;
    text-align: center;
    padding-left: 12px;
    padding-right: 12px;
  }

  .topbar-actions .btn-secondary { display: none; }

  .page-header-text h1 { font-size: 22px; }
  .table-desktop { display: none; }
  .object-cards { display: block; }
  .mobile-bottom-nav { display: flex; }
  .object-hero-prices { text-align: left; width: 100%; }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .form-grid > label,
  .form-grid > .btn,
  .form-grid label[style*="grid-column"] {
    grid-column: 1 / -1 !important;
  }

label input,
label select,
label textarea,
input.br-date-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
input.br-date-input,
input.br-date-list-input {
  font-variant-numeric: tabular-nums;
}

  .form-grid .btn {
    width: 100%;
    white-space: normal;
  }

  .toolbar {
    gap: 6px;
  }

  .toolbar .btn-sm {
    flex: 1 1 auto;
    min-width: 0;
    white-space: normal;
    padding-left: 10px;
    padding-right: 10px;
  }

  .steps {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
  }

  .step {
    flex: 0 0 auto;
    min-width: 118px;
    font-size: 12px;
    padding: 10px 12px;
  }

  .listing-preview { grid-template-columns: 1fr; }

  .object-hero {
    padding: 16px;
  }

  .object-hero-main h1 {
    font-size: 20px;
    overflow-wrap: anywhere;
  }

  .portfolio-matrix-wrap {
    margin-left: -16px;
    margin-right: -16px;
    padding: 12px 0 12px 16px;
    border-left: none;
    border-right: none;
    border-radius: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .portfolio-matrix-wrap .table-wrap {
    margin: 0;
    overflow: visible;
  }

  .portfolio-matrix {
    min-width: 520px;
  }

  .portfolio-matrix th.matrix-sticky,
  .portfolio-matrix td.matrix-sticky {
    min-width: 130px;
    max-width: 42vw;
  }

  .portfolio-matrix .matrix-sticky strong,
  .portfolio-matrix .matrix-sticky a {
    overflow-wrap: anywhere;
  }

  .alerts-panel .alert-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .drawer-panel {
    width: 100%;
    max-width: 100%;
  }

  .wizard-panel .form-grid .btn {
    width: 100%;
  }

  #wiz-to-calc {
    margin-left: 0 !important;
    margin-top: 8px;
  }
}

.btn-link {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
}
.btn-link:hover { color: var(--primary-dark, #1d4ed8); }

/* Onboarding wizard */
.wizard-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.wizard-step {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  background: var(--surface-2, #f3f4f6);
  color: var(--text-muted, #6b7280);
  border: none;
  font-family: inherit;
  line-height: 1.3;
  cursor: default;
}
.wizard-step.clickable {
  cursor: pointer;
}
.wizard-step.clickable:hover {
  filter: brightness(0.96);
}
.wizard-step:disabled {
  cursor: default;
  opacity: 1;
}
.wizard-step.active {
  background: #dbeafe;
  color: #1d4ed8;
  font-weight: 600;
}
.wizard-step.done {
  background: #dcfce7;
  color: #15803d;
}
.wizard-panel { display: none; }
.wizard-panel.active { display: block; }
.wiz-step-summary {
  margin: 0 0 12px;
  padding: 12px 14px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
}
.wiz-status-block {
  margin: 12px 0;
  padding: 12px 14px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
}

/* br-ui: toasts and modals */
.br-toast-root {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10050;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.br-toast {
  padding: 12px 16px;
  border-radius: 8px;
  background: #1f2937;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
}
.br-toast.show { opacity: 1; transform: translateY(0); }
.br-toast-error { background: #b91c1c; }
.br-toast-success { background: #15803d; }
.br-toast-warn { background: #b45309; }
.br-modal-root {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.br-modal-root.hidden { display: none !important; }
.br-modal-backdrop {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(15, 23, 42, 0.45);
}
.br-modal-panel {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 12px;
  padding: 20px 22px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.18);
}
.br-modal-title { margin: 0 0 8px; font-size: 18px; }
.br-modal-message { margin: 0 0 16px; color: #4b5563; font-size: 14px; line-height: 1.5; }
.br-modal-input-wrap { margin-bottom: 16px; }
.br-modal-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 15px;
}
.br-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
body.br-modal-open { overflow: hidden; }

/* Global confirm/prompt dialog (layout_footer) */
.br-dialog {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 25000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}
.br-dialog.hidden { display: none !important; }
.br-dialog__backdrop {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(15, 23, 42, 0.5);
}
.br-dialog__panel {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 12px;
  padding: 22px 24px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.22);
}
.br-dialog__title {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.br-dialog__message {
  margin: 0 0 18px;
  color: #4b5563;
  font-size: 14px;
  line-height: 1.55;
}
.br-dialog__input-wrap { margin-bottom: 16px; }
.br-dialog__input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  box-sizing: border-box;
}
.br-dialog__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
body.br-dialog-open { overflow: hidden; }

/* Holiday dates picker modal */
.br-holiday-dates-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
}
.br-holiday-dates-row .br-date-list-input {
  flex: 1 1 200px;
  min-width: 0;
}
.br-holiday-dates-row .btn {
  flex-shrink: 0;
  white-space: nowrap;
}
.br-holiday-modal {
  position: fixed;
  inset: 0;
  z-index: 26000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}
.br-holiday-modal.hidden {
  display: none !important;
}
.br-holiday-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}
.br-holiday-modal__panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.22);
}
.br-holiday-modal__title {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 700;
}
.br-holiday-modal__modes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.br-holiday-modal__modes .btn.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary);
}
.br-holiday-modal__hint {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.45;
}
.br-holiday-calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.br-holiday-calendar-title {
  font-size: 15px;
  font-weight: 600;
}
.br-holiday-cal-weekdays,
.br-holiday-cal-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.br-holiday-cal-weekdays {
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}
.br-holiday-cal-day {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font: inherit;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.br-holiday-cal-day:hover:not(.br-holiday-cal-day--empty) {
  border-color: #93c5fd;
  background: #eff6ff;
}
.br-holiday-cal-day--empty {
  border: none;
  background: transparent;
  pointer-events: none;
}
.br-holiday-cal-day--selected {
  background: #dbeafe;
  border-color: #2563eb;
  color: #1d4ed8;
  font-weight: 600;
}
.br-holiday-cal-day--staging {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
  font-weight: 600;
}
.br-holiday-cal-day--range-start {
  box-shadow: inset 0 0 0 2px #2563eb;
}
.br-holiday-modal__staging {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}
.br-holiday-modal__chips-wrap {
  margin-top: 14px;
}
.br-holiday-modal__chips-label {
  display: block;
  font-size: 12px;
  margin-bottom: 6px;
}
.br-holiday-modal__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
}
.br-holiday-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f3f4f6;
  border: 1px solid var(--border);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.br-holiday-chip-remove {
  border: none;
  background: none;
  padding: 0 2px;
  font-size: 16px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}
.br-holiday-chip-remove:hover {
  color: #dc2626;
}
.br-holiday-modal__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* KPI link + competitors map modal */
.kpi-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(37, 99, 235, 0.35);
  text-underline-offset: 3px;
}
.kpi-link:hover { color: #2563eb; }
.conf-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: #2563eb;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
#comp-map-modal.comp-map-modal {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}
#comp-map-modal.hidden { display: none !important; }
.comp-map-modal__backdrop {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(15, 23, 42, 0.45);
}
.comp-map-modal__panel {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 12px;
  padding: 20px 22px;
  max-width: min(920px, calc(100vw - 32px));
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.18);
}
.comp-map-modal__title { margin: 0 0 8px; font-size: 18px; }
.comp-map-modal__hint { margin: 0 0 8px; font-size: 14px; }
.comp-map-modal__actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}
#comp-map-modal-map {
  height: 420px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  margin: 12px 0;
}
.comp-map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  font-size: 13px;
  color: #4b5563;
}
.comp-map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.comp-map-legend i {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .kpi-row { grid-template-columns: 1fr; }
  .mobile-bottom-nav a { font-size: 8px; }
  .topbar-titles { max-width: calc(100% - 88px); }
}

@media (min-width: 1600px) {
  .app-content { margin: 0 auto; }
}

/* Price chart (object overview) */
.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.chart-range-btns { display: flex; gap: 6px; }
.chart-range.active { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.chart-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.chart-dot--current { background: #6B7280; }
.chart-dot--reco { background: #2563EB; }
.chart-dot--market { background: #16A34A; }
#price-chart { width: 100%; max-width: 100%; display: block; }

/* Strategy tab */
.strategy-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}
@media (max-width: 900px) {
  .strategy-cards { grid-template-columns: 1fr; }
}
.strategy-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 100%;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.strategy-card input { position: absolute; opacity: 0; pointer-events: none; }
.strategy-card--active,
.strategy-card:has(input:checked) {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.strategy-card-title { display: block; font-weight: 600; margin-bottom: 4px; }
.strategy-card-desc {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  flex: 1;
}
.strategy-card-factor {
  display: inline-flex;
  align-items: center;
  margin-top: 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1.2;
}
.form-label-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 2.2em;
  line-height: 1.35;
}
.form-label-check input[type="checkbox"] {
  width: auto;
  min-width: 0;
  margin: 0;
  flex-shrink: 0;
}
.form-label-check > span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}
.form-label-inline small {
  font-weight: 400;
  color: var(--text-muted);
}
.strategy-params-grid {
  align-items: start;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.strategy-params-grid > label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.strategy-params-grid .field-label {
  display: block;
  min-height: 2.2em;
  line-height: 1.35;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}
.strategy-params-grid > label input[type="number"],
.strategy-params-grid > label input[type="text"],
.strategy-params-grid > label select,
.strategy-params-grid > label textarea {
  width: 100%;
  box-sizing: border-box;
}
.strategy-params-grid > label small {
  font-size: 12px;
  line-height: 1.4;
  font-weight: 400;
}
.strategy-field-wide {
  grid-column: 1 / -1;
}

/* Intraday ladder (strategy tab) */
.intraday-ladder-panel {
  margin-top: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f8fafc;
}
.intraday-ladder-panel summary {
  padding: 14px 16px;
  cursor: pointer;
  font-size: 14px;
}
.intraday-ladder-panel[open] summary {
  border-bottom: 1px solid var(--border);
}
.intraday-ladder-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.intraday-ladder-formula {
  margin: 0;
}
.intraday-ladder-safety {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}
.intraday-ladder-safety strong {
  font-weight: 600;
}
.br-intraday-slots-budget {
  margin: 0 0 12px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: var(--radius-sm);
  color: var(--text);
}
.br-intraday-slots-budget.hidden {
  display: none !important;
}
.br-intraday-slots-budget strong {
  font-weight: 600;
}
.intraday-ladder-toggle {
  font-weight: 500;
  color: var(--text);
}
.intraday-ladder-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(280px, 1.15fr);
  gap: 20px 24px;
  align-items: start;
}
.intraday-ladder-col--settings {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.intraday-field--timezone {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 0 0 4px;
}
.intraday-tz-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.intraday-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  min-width: 0;
}
.intraday-field--days {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}
.intraday-field--days legend {
  padding: 0;
  margin: 0 0 6px;
}
.intraday-field .field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.35;
}
.intraday-day-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}
.check-row {
  display: inline-flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
}
.check-row input[type="checkbox"] {
  width: auto;
  min-width: 0;
  margin: 2px 0 0;
  flex-shrink: 0;
}
.check-row > span {
  line-height: 1.4;
}
.intraday-field--free {
  padding-top: 2px;
}
.intraday-field--steps textarea {
  width: 100%;
  min-height: 148px;
  box-sizing: border-box;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
}
.intraday-ladder-steps-hidden {
  display: none !important;
}
.br-intraday-slots-preview-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px 12px;
}
.br-intraday-slots-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1 1 180px;
  min-width: 0;
  min-height: 32px;
  align-items: center;
}
.br-intraday-slots-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
}
.br-intraday-slots-modal__panel {
  max-width: 560px;
}
.br-intraday-slots-table-wrap {
  overflow-x: auto;
  margin-bottom: 12px;
}
.br-intraday-slots-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.br-intraday-slots-table th,
.br-intraday-slots-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.br-intraday-slots-table th {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.br-intraday-slots-table input[type="time"],
.br-intraday-slots-table input[type="number"] {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.br-intraday-slots-table input[type="time"] {
  max-width: 120px;
}
.br-intraday-slots-table input[type="number"] {
  max-width: 100px;
}
.br-intraday-slots-col-actions {
  width: 40px;
  text-align: center;
}
.br-intraday-slots-remove {
  min-width: 32px;
  padding: 2px 8px;
  font-size: 18px;
  line-height: 1;
}
.br-intraday-slots-preview-cell {
  color: var(--text-muted);
  font-size: 13px;
}
.br-intraday-slots-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.br-intraday-slots-error {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.4;
}
.br-intraday-slots-error.hidden {
  display: none !important;
}
.intraday-field .field-hint {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.45;
}
.strategy-save-toolbar {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  gap: 12px 20px;
}
.strategy-save-toolbar .strategy-recalc {
  margin: 0;
}
.econ-save-toolbar {
  margin-top: 16px;
  gap: 12px 20px;
  flex-wrap: wrap;
}
.form-sync-status {
  margin: 8px 0 0;
  font-size: 13px;
  color: #4B5563;
}
.form-sync-status--dirty {
  color: #92400E;
  font-weight: 600;
}
.form-sync-status--stale {
  color: #9A3412;
}
.form-sync-status--saved {
  color: #166534;
}
.drawer-effect-notes {
  margin: 6px 0 0 1.1em;
  padding: 0;
}

@media (max-width: 900px) {
  .strategy-params-grid {
    grid-template-columns: 1fr;
  }
  .intraday-ladder-grid {
    grid-template-columns: 1fr;
  }
}
.strategy-recalc {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
}
.inline-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 8px;
}
.inline-checks label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.strategy-effective-preview {
  display: inline-block;
  margin-top: 8px;
  font-weight: 600;
  color: var(--primary);
}
.comp-map {
  height: 520px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 12px;
}
.zones-list .link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.zones-row--active td {
  background: var(--primary-soft);
}
.zone-edit-form {
  margin-top: 12px;
  max-width: 640px;
}
.comp-view-toggle .btn.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary);
}
.drawer {
  position: fixed;
  inset: 0;
  z-index: 1200;
}
.drawer.hidden {
  display: none;
}
.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
}
.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(560px, 96vw);
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  padding: 20px 18px 18px;
  overflow: auto;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.16);
}
.drawer-close {
  position: absolute;
  top: 10px;
  right: 10px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  width: 30px;
  height: 30px;
  cursor: pointer;
}
.drawer-dl {
  margin: 0;
}
.drawer-dl > div {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  margin: 0 0 10px;
}
.drawer-dl dt {
  font-size: 13px;
  color: var(--text-muted);
}
.drawer-dl dd {
  margin: 0;
  font-weight: 500;
}

/* Portfolio calendar matrix */
.portfolio-matrix-wrap { overflow: auto; }
.portfolio-matrix { font-size: 12px; min-width: 640px; }
.portfolio-matrix th.matrix-sticky,
.portfolio-matrix td.matrix-sticky {
  position: sticky;
  left: 0;
  background: var(--bg-card);
  z-index: 2;
  min-width: 160px;
  box-shadow: 2px 0 4px rgba(0,0,0,0.04);
}
.portfolio-matrix th.matrix-date { text-align: center; white-space: nowrap; min-width: 72px; }
.matrix-cell { text-align: center; vertical-align: middle; }
.matrix-cell--empty { color: var(--text-muted); }
.matrix-cell--up { background: #ECFDF5; }
.matrix-cell--down { background: #FEF2F2; }
.matrix-cell--hold { background: #F9FAFB; }
.matrix-cell { position: relative; }
.matrix-occ {
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 9px;
  line-height: 1;
  font-weight: 700;
}
.matrix-occ--busy { color: #1D4ED8; }
.matrix-occ--unk { color: #9CA3AF; }
.matrix-occ--free { display: none; }
.matrix-cell--occ:not(.matrix-cell--empty) {
  box-shadow: inset 0 -2px 0 #3B82F6;
}
.matrix-cell--occ-unk:not(.matrix-cell--empty) {
  box-shadow: inset 0 -2px 0 #D1D5DB;
}
.matrix-badge { font-size: 10px; color: var(--success); margin-left: 2px; }

.portfolio-matrix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
}
.portfolio-matrix-legend-title { font-weight: 600; color: var(--text); }
.portfolio-matrix-legend-item { display: inline-flex; align-items: center; gap: 6px; }

.portfolio-add-details {
  margin-top: 16px;
}
.portfolio-add-summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  list-style: none;
}
.portfolio-add-summary::-webkit-details-marker { display: none; }
.portfolio-add-summary::before {
  content: '▸ ';
  color: var(--text-muted, #6b7280);
}
.portfolio-add-details[open] > .portfolio-add-summary::before {
  content: '▾ ';
}
.portfolio-add-details .panel {
  box-shadow: none;
  border: 1px solid var(--border, #e5e7eb);
}
.legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.08);
  flex-shrink: 0;
}
.legend-swatch--up { background: #ECFDF5; }
.legend-swatch--down { background: #FEF2F2; }
.legend-swatch--hold { background: #F9FAFB; }
.legend-swatch--empty { background: #fff; }

.portfolio-onboarding-banner .portfolio-onboarding-steps {
  margin: 0;
  padding-left: 1.25em;
  color: var(--text-muted);
}
.portfolio-onboarding-banner .portfolio-onboarding-steps li { margin: 6px 0; }

/* Reports */
.reports-page {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 100%;
}

.reports-page .reports-meta {
  margin: 0 0 4px;
}

.reports-page .kpi-row {
  margin-bottom: 0;
}

.reports-page .panel h2 {
  margin-top: 0;
}

.reports-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.reports-table-toolbar h2 {
  margin: 0;
}

.reports-table-panel .portfolio-table-wrap {
  width: 100%;
}

.alerts-panel .alert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.alerts-panel .alert-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.report-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 560px;
}
.report-bar-row { display: grid; grid-template-columns: 100px 1fr 40px; align-items: center; gap: 10px; font-size: 13px; }
.report-bar-track { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.report-bar-fill { height: 100%; border-radius: 4px; }
.report-bar-fill--up { background: var(--success); }
.report-bar-fill--hold { background: #9CA3AF; }
.report-bar-fill--down { background: var(--danger); }
.report-bar-fill--neutral { background: var(--border); }

/* Export */
.export-form .form-grid { margin-bottom: 16px; }
.export-units-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.export-unit-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.export-unit-list li { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.export-unit-list li:last-child { border-bottom: none; }
.export-unit-list label { cursor: pointer; display: block; }
.export-links { margin: 0; padding-left: 20px; }
.export-links a { text-decoration: none; }
.integration-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
@media (max-width: 767px) {
  .integration-grid { grid-template-columns: 1fr; }
}
.integration-card {
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-app);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.integration-card--soon { opacity: 0.75; }

/* RealtyCalendar sync help */
.rc-sync-help {
  margin: 0 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-app);
}
.rc-sync-help summary {
  cursor: pointer;
  padding: 12px 16px;
  font-weight: 600;
  list-style: none;
}
.rc-sync-help summary::-webkit-details-marker { display: none; }
.rc-sync-help-body { padding: 0 16px 16px; }
.rc-sync-help-steps { margin: 8px 0 12px; padding-left: 20px; }
.rc-sync-help-steps li { margin-bottom: 6px; }
.rc-sync-help-note { font-size: 13px; margin: 8px 0 0; }
.rc-sync-help-link { margin: 12px 0 0; font-size: 13px; }
.rc-sync-webhook { margin-top: 12px; }
.rc-sync-webhook-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.rc-sync-webhook-input { flex: 1; min-width: 200px; font-size: 12px; }
.rc-sync-status {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.rc-sync-status-warn a { color: var(--warn, #b45309); }
.rc-sync-status-legend {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border, #e2e8f0);
  font-size: 13px;
}
.rc-sync-status-legend-title {
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text-muted, #64748b);
}
.rc-sync-status-legend-row {
  margin: 0 0 10px;
}
.rc-sync-status-legend-row dt {
  font-weight: 600;
  margin: 0 0 2px;
}
.rc-sync-status-legend-row dd {
  margin: 0;
  color: var(--text-muted, #64748b);
  line-height: 1.45;
}
.rc-sync-status-legend-row dd a {
  margin-left: 6px;
  white-space: nowrap;
}
.rc-connect-steps {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.rc-connect-step {
  border: 1px solid var(--border);
  border-radius: var(--radius, 8px);
  padding: 12px 14px;
  background: var(--bg-card, #fff);
}
.rc-connect-step.is-done {
  border-color: color-mix(in srgb, var(--ok, #15803d) 35%, var(--border));
}
.rc-connect-step-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.rc-connect-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  background: var(--bg-muted, #f1f5f9);
  color: var(--text, #0f172a);
}
.rc-connect-step.is-done .rc-connect-step-num {
  background: var(--ok, #15803d);
  color: #fff;
}
.rc-connect-step-hint {
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.45;
}
.rc-check-panel {
  margin-top: 4px;
}
.rc-check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.rc-check-row:last-of-type {
  border-bottom: none;
}
.badge-rc {
  background: #e0e7ff;
  color: #3730a3;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
}
.rc-export-hint { margin-top: 12px; font-size: 13px; }
.rc-drawer-hint { margin: 0 0 12px; font-size: 13px; }
.form-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.form-inline select { min-width: 140px; }
.rc-api-outreach template { display: none; }

/* Help center */
.help-center {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 28px;
  align-items: start;
  max-width: 1280px;
}
.help-sidebar {
  position: sticky;
  top: 20px;
}
.help-sidebar-inner {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}
.help-sidebar-search {
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-app) 100%);
}
.help-search-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 8px;
  color: var(--text-muted);
}
.help-search-input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg-card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236B7280' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242 1.006a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E") no-repeat 12px center;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.help-search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.help-search-results {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  max-height: 280px;
  overflow: auto;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  z-index: 20;
  position: absolute;
  left: 16px;
  right: 16px;
  margin-top: 6px;
}
.help-sidebar-search { position: relative; }
.help-search-results.hidden { display: none; }
.help-search-hit {
  display: block;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}
.help-search-hit:last-child { border-bottom: 0; }
.help-search-hit:hover { background: var(--primary-soft); }
.help-search-hit strong { display: block; margin-bottom: 4px; color: var(--text); }
.help-search-empty { padding: 12px; font-size: 13px; }

/* Sidebar navigation */
.help-nav {
  padding: 8px 0 12px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}
.help-nav-section {
  padding: 8px 0 4px;
}
.help-nav-section + .help-nav-section {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 12px;
}
.help-nav-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 6px 16px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.help-nav-section-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  flex-shrink: 0;
}
.help-nav-links {
  list-style: none !important;
  margin: 0;
  padding: 0 8px;
}
.help-nav-item {
  list-style: none !important;
  margin: 0;
  padding: 0;
}
.help-nav-item::marker { content: none; }
.help-nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.35;
  color: var(--text);
  text-decoration: none !important;
  border-left: 3px solid transparent;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.help-nav-link::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  margin-left: 2px;
  transition: background 0.12s, transform 0.12s;
}
.help-nav-link:hover {
  background: var(--bg-app);
  color: var(--primary);
}
.help-nav-link:hover::before {
  background: var(--primary);
  transform: scale(1.3);
}
.help-nav-link.is-active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
  border-left-color: var(--primary);
}
.help-nav-link.is-active::before {
  background: var(--primary);
  transform: scale(1.4);
}
.help-nav-link-text {
  flex: 1;
  min-width: 0;
}

.help-main { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.help-hero { padding: 24px 28px !important; }
.help-hero-label {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
}
.help-hero-title { margin: 0 0 8px; font-size: 24px; font-weight: 700; line-height: 1.25; }
.help-hero-lead { margin: 0; font-size: 15px; max-width: 560px; }
.help-section-title { margin: 0 0 14px; font-size: 17px; font-weight: 600; }
.help-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.help-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-app) 100%);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.help-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.12);
}
.help-card strong { font-size: 15px; color: var(--text); }
.help-popular-list { margin: 0; padding: 0; list-style: none; }
.help-popular-list li { margin-bottom: 8px; }
.help-popular-list a {
  display: inline-block;
  padding: 6px 0;
  text-decoration: none;
  font-weight: 500;
}
.help-category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.help-category-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-app);
}
.help-category-card h3 { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.help-category-card ul { margin: 0; padding: 0; list-style: none; }
.help-category-card li { margin-bottom: 6px; }
.help-category-card a { font-size: 13px; text-decoration: none; }
.help-intro .help-md { font-size: 14px; color: var(--text-muted); }
.help-article-layout {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 20px;
  align-items: start;
}
.help-article-content { min-width: 0; }
.help-toc-sticky {
  position: sticky;
  top: 20px;
  padding: 16px !important;
  max-height: calc(100vh - 120px);
  overflow: auto;
}
.help-toc-title {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.help-toc { list-style: none; margin: 0; padding: 0; }
.help-toc li { margin: 0; border-left: 2px solid var(--border); }
.help-toc-l2 { padding-left: 0; }
.help-toc-l3 { padding-left: 0; }
.help-toc a {
  display: block;
  padding: 6px 10px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.35;
  border-left: 2px solid transparent;
  margin-left: -2px;
  transition: color 0.12s, border-color 0.12s;
}
.help-toc a:hover { color: var(--primary); }
.help-toc a.active {
  color: var(--primary);
  font-weight: 600;
  border-left-color: var(--primary);
  background: var(--primary-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.help-related h2 { margin: 0 0 12px; font-size: 16px; }
.help-related-list { margin: 0; padding: 0; list-style: none; }
.help-related-list li { margin-bottom: 8px; }
.help-related-list a { font-weight: 500; text-decoration: none; }

/* Article typography */
.help-md {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
}
.help-md h1 { font-size: 22px; margin: 0 0 16px; }
.help-md h2 {
  font-size: 19px;
  font-weight: 600;
  margin: 32px 0 12px;
  padding-top: 8px;
  scroll-margin-top: 88px;
  border-top: 1px solid var(--border);
}
.help-md h2:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.help-md h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 22px 0 8px;
  scroll-margin-top: 88px;
  color: var(--text);
}
.help-md p { margin: 0 0 14px; }
.help-md ul, .help-md ol { margin: 0 0 16px; padding-left: 0; list-style: none; }
.help-md ul > li, .help-md ol > li {
  position: relative;
  margin-bottom: 8px;
  padding-left: 22px;
}
.help-md ul > li::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 0.65em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0.55;
}
.help-md ol { counter-reset: help-ol; }
.help-md ol > li { counter-increment: help-ol; }
.help-md ol > li::before {
  content: counter(help-ol);
  position: absolute;
  left: 0;
  top: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

/* Help tables — как table.data в кабинете */
.help-table-wrap {
  overflow-x: auto;
  margin: 20px 0 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.help-md .help-table-wrap { margin-left: 0; margin-right: 0; }
table.help-table {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  margin: 0;
}
table.help-table thead { background: #F9FAFB; }
table.help-table th,
table.help-table td {
  padding: 12px 16px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  line-height: 1.45;
}
table.help-table th {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}
table.help-table tbody tr:last-child td { border-bottom: 0; }
table.help-table tbody tr:hover td { background: #F9FAFB; }
table.help-table td:first-child { font-weight: 500; color: var(--text); }
table.help-table td strong { font-weight: 600; }

/* Fallback если таблица без обёртки */
.help-md > table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.help-md > table th,
.help-md > table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.help-md > table th { background: #F9FAFB; font-weight: 600; font-size: 12px; color: var(--text-muted); }

.help-md pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px;
  border-radius: var(--radius-sm);
  overflow: auto;
  font-size: 13px;
  margin: 16px 0;
}
.help-md code {
  font-family: ui-monospace, 'SF Mono', monospace;
  font-size: 0.9em;
  background: var(--bg-app);
  padding: 2px 6px;
  border-radius: 4px;
}
.help-md pre code { background: transparent; padding: 0; font-size: 13px; color: inherit; }

/* Callouts */
.help-md blockquote,
.help-callout {
  margin: 18px 0;
  padding: 14px 16px 14px 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  border-left-width: 4px;
  background: var(--bg-app);
  position: relative;
}
.help-md blockquote::before,
.help-callout::before {
  position: absolute;
  left: 14px;
  top: 14px;
  font-size: 16px;
  line-height: 1;
}
.help-callout--tip,
.help-md blockquote:not([class]) {
  border-left-color: var(--primary);
  background: var(--primary-soft);
}
.help-callout--tip::before,
.help-md blockquote:not([class])::before { content: '💡'; }
.help-callout--important {
  border-left-color: var(--accent);
  background: #EEF2FF;
}
.help-callout--important::before { content: 'ℹ️'; }
.help-callout--warn {
  border-left-color: var(--warn);
  background: #FFFBEB;
}
.help-callout--warn::before { content: '⚠️'; }
.help-callout--danger {
  border-left-color: var(--danger);
  background: #FEF2F2;
}
.help-callout--danger::before { content: '⛔'; }
.help-md blockquote p:last-child,
.help-callout p:last-child { margin-bottom: 0; }
.help-md blockquote strong:first-child,
.help-callout strong:first-child { color: inherit; }

.help-md a { color: var(--primary); font-weight: 500; text-decoration: none; }
.help-md a:hover { text-decoration: underline; }
.help-article-body, .help-body { padding: 24px 28px !important; }

@media (max-width: 1023px) {
  .help-center { grid-template-columns: 1fr; gap: 16px; }
  .help-sidebar { position: static; }
  .help-nav { max-height: none; }
  .help-article-layout { grid-template-columns: 1fr; }
  .help-toc-sticky {
    position: static;
    max-height: none;
    order: -1;
  }
}

@media (max-width: 767px) {
  .help-hero-title { font-size: 20px; }
  .help-article-body, .help-body { padding: 18px 16px !important; }
  table.help-table { min-width: 320px; font-size: 13px; }
  table.help-table th, table.help-table td { padding: 10px 12px; }
}

/* Admin panel */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-sidebar, #1e293b);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 16px 0;
}
.admin-brand { padding: 0 16px 16px; font-weight: 700; }
.admin-brand a { color: #fff; text-decoration: none; }
.admin-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }
.admin-nav-item {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: #cbd5e1;
  text-decoration: none;
  font-size: 14px;
}

.bookings-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14px, 1fr));
  gap: 4px;
  margin-top: 8px;
}
.bookings-day {
  height: 18px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-app);
}
.bookings-day.occupied {
  background: rgba(59, 130, 246, var(--occ-opacity, 0.6));
  border-color: rgba(59, 130, 246, 0.55);
}
.bookings-mini {
  margin-top: 12px;
}
.bookings-mini .table-wrap {
  max-height: 250px;
}
.admin-nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.admin-nav-item.active { background: rgba(255,255,255,0.12); color: #fff; }
.admin-sidebar-foot { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.admin-main { flex: 1; padding: 24px 28px; overflow: auto; background: var(--bg-app); }
.admin-page-title { margin: 0 0 20px; font-size: 22px; }
.admin-log-pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
}

/* Пакет B: портфель — низкая уверенность и фильтр */
.portfolio-row--low-conf {
  background: rgba(245, 158, 11, 0.06);
}
.portfolio-row--low-conf td:first-child {
  box-shadow: inset 3px 0 0 var(--warn, #f59e0b);
}
.portfolio-low-conf-badge {
  margin-left: 6px;
  font-size: 11px;
  vertical-align: middle;
}
.kpi-clickable.portfolio-kpi-link {
  text-decoration: none;
  color: inherit;
  display: block;
  border-radius: var(--radius-sm);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.kpi-clickable.portfolio-kpi-link:hover {
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.35);
  transform: translateY(-1px);
}
.portfolio-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.export-readiness-kpi .val.warn {
  color: var(--warn, #d97706);
}
.export-readiness-row--warn {
  background: rgba(245, 158, 11, 0.05);
}
.export-readiness-details summary {
  cursor: pointer;
  font-weight: 600;
}

/* Leaflet: скрыть ссылку на leafletjs.com, оставить OpenStreetMap */
.leaflet-control-attribution a[href="https://leafletjs.com"],
.leaflet-control-attribution a[href="https://leafletjs.com/"] {
  display: none !important;
}

/* Billing */
.billing-sidebar {
  font-size: 12px;
  line-height: 1.45;
  padding: 10px 10px 8px;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border-left: 3px solid var(--accent, #3b82f6);
}
.billing-sidebar.trial { border-left-color: #0ea5e9; }
.billing-sidebar.hold { border-left-color: var(--danger, #dc2626); background: rgba(220, 38, 38, 0.08); }
.billing-sidebar-warn { color: var(--danger, #dc2626); font-weight: 600; }
.billing-sidebar-vip { color: #a855f7; font-weight: 600; }
.billing-sidebar-link { display: inline-block; margin-top: 4px; font-weight: 600; }
.billing-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.billing-card {
  background: var(--panel, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.billing-card-label { font-size: 12px; color: var(--muted, #6b7280); margin-bottom: 4px; }
.billing-card-value { font-size: 20px; font-weight: 700; }
.billing-card-sub { font-size: 12px; color: var(--muted, #6b7280); margin-top: 4px; }
.billing-quick-amounts { display: flex; flex-wrap: wrap; gap: 8px; grid-column: 1 / -1; }
.billing-methods { grid-column: 1 / -1; border: none; padding: 0; }
.billing-methods label { display: inline-flex; align-items: center; gap: 6px; margin-right: 16px; }
.billing-alerts .alert { margin-bottom: 8px; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; }
.billing-alerts .alert-info { background: #eff6ff; color: #1d4ed8; }
.billing-alerts .alert-warn { background: #fffbeb; color: #b45309; }
.billing-alerts .alert-danger { background: #fef2f2; color: #b91c1c; }
.billing-alerts .alert-success { background: #ecfdf5; color: #047857; }
.text-success { color: #047857; }
.text-danger { color: #b91c1c; }
.admin-nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 12px 16px 4px; }
.admin-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.admin-stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.admin-stat .label { font-size: 12px; color: var(--muted); }
.admin-stat .value { font-size: 18px; font-weight: 700; }
.admin-kv { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }

/* Admin UX: формы, таблицы, подсказки */
.admin-main .admin-page-head {
  margin-bottom: 20px;
}
.admin-main .admin-page-head h1 {
  margin: 0 0 6px;
  font-size: 24px;
}
.admin-main .admin-page-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  max-width: 720px;
  line-height: 1.5;
}
.admin-help {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.55;
  color: #1e3a5f;
}
.admin-help strong { color: #1e40af; }
.admin-help ul { margin: 8px 0 0; padding-left: 18px; }
.admin-help li { margin: 4px 0; }
.admin-help a { color: var(--primary); font-weight: 600; }

.admin-main .form-grid,
.admin-main .admin-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
  align-items: start;
}
.admin-main .form-grid.admin-form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.admin-main .form-grid .col-full,
.admin-main .admin-form-grid .col-full {
  grid-column: 1 / -1;
}
.admin-main .form-grid h2,
.admin-main .admin-form-grid h2,
.admin-main .form-grid .admin-form-section-title {
  grid-column: 1 / -1;
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 16px;
}
.admin-main .form-grid h2:first-child,
.admin-main .admin-form-grid h2:first-child,
.admin-main .form-grid .admin-form-section-title:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
.admin-main .form-grid p.muted,
.admin-main .admin-form-grid p.muted {
  grid-column: 1 / -1;
  margin: -4px 0 0;
}
.admin-main label.checkbox-inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}
.admin-main label.checkbox-inline input[type="checkbox"] {
  width: auto;
  margin: 0;
}
.admin-main .admin-form-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.admin-main .form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.admin-main .form-inline label {
  min-width: 140px;
}
.admin-main .form-inline .btn {
  margin-bottom: 2px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.admin-actions .btn-sm {
  padding: 5px 10px;
}

.admin-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}
.admin-badge--admin { background: #ede9fe; color: #5b21b6; }
.admin-badge--vip { background: #fae8ff; color: #86198f; }
.admin-badge--active { background: #dcfce7; color: #166534; }
.admin-badge--blocked { background: #fee2e2; color: #991b1b; }
.admin-badge--hold { background: #fef3c7; color: #92400e; }
.admin-badge--trial { background: #e0f2fe; color: #0369a1; }
.admin-badge--neutral { background: #f1f5f9; color: #475569; }

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.admin-toolbar input[type="search"],
.admin-toolbar input[type="text"] {
  min-width: 220px;
  max-width: 320px;
}

.admin-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.admin-modal-backdrop[hidden] { display: none; }
.admin-modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  width: min(520px, 100%);
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.15);
}
.admin-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.admin-modal-head h2 { margin: 0; font-size: 18px; }
.admin-modal-body { padding: 20px; }
.admin-modal-body .form-grid { grid-template-columns: 1fr; }
.admin-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.admin-kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 20px;
  margin: 0;
}
.admin-kv-grid > div { display: flex; flex-direction: column; gap: 4px; }
.admin-kv-grid dt { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.admin-kv-grid dd { margin: 0; font-size: 14px; font-weight: 600; }

.admin-breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.admin-breadcrumb a { color: var(--primary); text-decoration: none; }
.admin-breadcrumb a:hover { text-decoration: underline; }

/* Admin shell v2 */
.admin-main {
  max-width: 1280px;
}
.admin-main .panel {
  padding: 0;
  overflow: hidden;
}
.admin-main .panel > h2,
.admin-main .panel > .panel-head {
  margin: 0;
  padding: 16px 20px;
  font-size: 15px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}
.admin-main .panel > .panel-body {
  padding: 20px;
}
.admin-main .panel > .table-wrap,
.admin-main .panel > table.data {
  margin: 0;
}
.admin-main .panel > .table-wrap table.data th:first-child,
.admin-main .panel > .table-wrap table.data td:first-child,
.admin-main .panel > table.data th:first-child,
.admin-main .panel > table.data td:first-child {
  padding-left: 20px;
}
.admin-main .panel > .table-wrap table.data th:last-child,
.admin-main .panel > .table-wrap table.data td:last-child,
.admin-main .panel > table.data th:last-child,
.admin-main .panel > table.data td:last-child {
  padding-right: 20px;
}
.admin-panel-desc {
  margin: 0;
  padding: 12px 20px 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.admin-entity-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.admin-entity-head-main { min-width: 0; }
.admin-entity-title {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.2;
}
.admin-entity-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.admin-entity-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.admin-stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.admin-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.admin-stat-card-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.admin-stat-card-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.admin-stat-card-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.admin-stat-card--vip { border-color: #e9d5ff; background: #fdf4ff; }
.admin-stat-card--hold { border-color: #fde68a; background: #fffbeb; }
.admin-stat-card--trial { border-color: #bae6fd; background: #f0f9ff; }

.admin-layout-2col {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.admin-stack { display: flex; flex-direction: column; gap: 16px; }

.admin-field-card {
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
}
.admin-field-card h3 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
}
.admin-field-card p {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}
.admin-field-card .form-grid {
  grid-template-columns: 1fr;
  gap: 12px;
}
.admin-field-card .admin-form-actions {
  border-top: none;
  padding-top: 4px;
  margin-top: 4px;
}

.admin-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  background: #fafbfc;
}
.admin-tab {
  appearance: none;
  border: none;
  background: transparent;
  padding: 12px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.admin-tab-panel { display: none; padding: 0 4px 4px; }
.admin-tab-panel.active { display: block; }
.admin-tab-panel .panel-head:first-child { margin-top: 0; }

.admin-empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--text-muted);
}
.admin-empty-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.admin-empty-hint { font-size: 13px; }

.admin-toast-host {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.admin-toast {
  pointer-events: auto;
  min-width: 260px;
  max-width: 380px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  font-size: 14px;
  animation: adminToastIn .2s ease;
}
.admin-toast--ok { border-left: 4px solid #16a34a; }
.admin-toast--err { border-left: 4px solid #dc2626; }
@keyframes adminToastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.admin-sidebar { width: 240px; }
.admin-nav-item { font-size: 13px; }
.admin-nav-section {
  color: #94a3b8;
  padding-left: 12px;
}

@media (max-width: 1100px) {
  .admin-stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-layout-2col { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .admin-main .form-grid,
  .admin-main .admin-form-grid,
  .admin-main .form-grid.admin-form-grid-3 {
    grid-template-columns: 1fr;
  }
  .admin-main { padding: 16px; }
}

@media (max-width: 768px) {
  .billing-cards { grid-template-columns: 1fr 1fr; }
  .billing-card-value { font-size: 17px; }
}

/* R5 UX: compact portfolio KPIs + matrix scroll hint */
.portfolio-kpi-compact {
  display: none;
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg-muted, #f3f4f6);
  font-size: 13px;
  line-height: 1.4;
}
.portfolio-matrix-scroll-hint {
  display: none;
  margin: 0 0 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--primary-soft, #eff6ff);
  color: var(--text, #111827);
  font-size: 13px;
}
.cal-accept-hint {
  font-size: 12px;
  align-self: center;
  max-width: 220px;
  line-height: 1.3;
}
@media (max-width: 640px) {
  .portfolio-kpi-row {
    display: none;
  }
  .portfolio-kpi-compact {
    display: block;
  }
  .portfolio-matrix-scroll-hint {
    display: block;
  }
  .unit-page .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .unit-page .kpi {
    padding: 10px;
  }
  .unit-page .kpi .val {
    font-size: 18px;
  }
  .unit-page .kpi .hint,
  .unit-page .kpi .delta {
    font-size: 11px;
  }
  .cal-accept-hint {
    max-width: 100%;
    flex-basis: 100%;
  }
}
