:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --bg-soft: #eef3fa;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --text: #172033;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --good: #15803d;
  --good-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .04);
  --radius: 14px;
  --radius-sm: 9px;
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220;
  --bg-soft: #101a2d;
  --panel: #121d31;
  --panel-2: #17243a;
  --text: #e5edf8;
  --muted: #9aa9c0;
  --line: #263650;
  --line-strong: #38506f;
  --accent: #60a5fa;
  --accent-soft: #172554;
  --good: #4ade80;
  --good-soft: #12351f;
  --warn: #fbbf24;
  --warn-soft: #3b2a08;
  --bad: #f87171;
  --bad-soft: #3b1212;
  --shadow: 0 1px 2px rgba(0,0,0,.2), 0 12px 28px rgba(0,0,0,.16);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; font-size: .9em; overflow-wrap: anywhere; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.02em; }
h1 { font-size: clamp(1.45rem, 2.2vw, 2rem); }
h2 { font-size: 1.08rem; margin: 0 0 12px; }
h3 { font-size: .98rem; }
p { margin: .35rem 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.help { color: var(--muted); font-size: 12.5px; margin-top: 6px; overflow-wrap: anywhere; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: nowrap;
  padding: 11px 24px; background: color-mix(in srgb, var(--panel) 94%, transparent);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 750; white-space: nowrap; }
.brand .logo-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.nav { display: flex; flex-wrap: nowrap; gap: 2px; align-items: center; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--muted); font-size: 13px; padding: 7px 8px; border-radius: 8px; white-space: nowrap; }
.nav a:hover, .nav-more summary:hover { color: var(--text); background: var(--bg-soft); text-decoration: none; }
.nav-more { position: relative; display: flex; align-items: center; align-self: center; }
.nav-more summary { list-style: none; cursor: pointer; color: var(--muted); font-size: 13px; padding: 7px 8px; border-radius: 8px; line-height: 19.5px; display: flex; align-items: center; }
.nav-more summary::-webkit-details-marker { display: none; }
.nav-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 190px; display: none; flex-direction: column; gap: 2px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 16px 40px rgba(15,23,42,.14); z-index: 60; }
.nav-more[open] .nav-menu { display: flex; }
.nav-menu a { padding: 8px 10px; font-size: 13.5px; }
.top-actions { white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 24px; }
.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.two-col { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 14px; }
.kpi { font-size: clamp(1.35rem, 2.1vw, 1.8rem); font-weight: 750; letter-spacing: -.03em; overflow-wrap: anywhere; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; white-space: nowrap; }
.badge.good { color: var(--good); border-color: color-mix(in srgb, var(--good) 30%, var(--line)); background: var(--good-soft); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, var(--line)); background: var(--warn-soft); }
.badge.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, var(--line)); background: var(--bad-soft); }
.money-pos { color: var(--good); font-variant-numeric: tabular-nums; }
.money-neg { color: var(--bad); font-variant-numeric: tabular-nums; }
.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 8px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--text);
  cursor: pointer; font: inherit; font-weight: 600; text-decoration: none; transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover, button:hover { border-color: var(--accent); text-decoration: none; }
.btn:active, button:active { transform: translateY(1px); }
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover, button.primary:hover { filter: brightness(.95); }
.btn.danger, button.danger { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); color: var(--bad); }
.btn.ghost, button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.small, button.small { min-height: 30px; padding: 4px 8px; font-size: 12px; }
form.inline { display: inline; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.stack { display: grid; gap: 10px; }
input, select, textarea {
  width: 100%; min-height: 40px; padding: 9px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus, button:focus-visible, .btn:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 1px; border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; }
label { display: block; margin: 10px 0 5px; color: var(--muted); font-size: 13px; font-weight: 600; }
form p { margin: 0 0 10px; }
form p label { margin-top: 0; }
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 11px 13px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--panel); margin-bottom: 7px; box-shadow: var(--shadow); animation: toastIn .2s ease-out; }
.messages li.success { border-color: color-mix(in srgb, var(--good) 40%, var(--line)); background: var(--good-soft); }
.messages li.error { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); background: var(--bad-soft); }
.messages li.warning { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); background: var(--warn-soft); }
.messages li.info { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); background: var(--accent-soft); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.tablescroll, .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
th { color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; background: var(--panel-2); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--panel-2); }
td .row, th .row { gap: 6px; }
.login { max-width: 420px; margin: 8vh auto; }
.login h1 { margin-top: 0; }
details:not(.nav-more) { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.nav-toggle { display: none; }
.nav-backdrop { display: none; }
.sidebar-open .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 45; }
.hide-mobile { display: inline; }
@media (max-width: 1300px) {
  .top-actions .hide-mobile { display: none; }
}
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .topbar { padding: 10px 14px; gap: 10px; }
  .nav-toggle { display: inline-flex; }
  .hide-mobile { display: none; }
  .nav {
    display: none; position: fixed; left: 0; top: 0; bottom: 0; width: min(82vw, 310px);
    flex-wrap: nowrap; overflow-x: visible;
    background: var(--panel); border-right: 1px solid var(--line); z-index: 50;
    flex-direction: column; align-items: stretch; gap: 2px; padding: 18px 12px; overflow-y: auto;
    box-shadow: 12px 0 32px rgba(15,23,42,.15);
  }
  .sidebar-open .nav { display: flex; }
  .nav a { padding: 12px 12px; font-size: 15px; border-radius: 9px; }
  .wrap { padding: 16px 14px 28px; }
  .grid-4, .grid-2 { grid-template-columns: 1fr; }
  .card { padding: 14px; border-radius: 12px; overflow-x: auto; }
  .card table { min-width: 620px; }
  .card h2 { font-size: 1rem; }
  .row { gap: 8px; }
  button, .btn, input, select { min-height: 44px; }
  button.small, .btn.small { min-height: 36px; }
  .topbar .brand .small { display: none; }
  .nav-more { width: 100%; }
  .nav-more summary { padding: 12px 12px; font-size: 15px; }
  .nav-menu { position: static; display: none; box-shadow: none; border: 0; background: transparent; padding: 0 0 0 10px; }
  .nav-more[open] .nav-menu { display: flex; }
}
@media (max-width: 520px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 380px) {
  .grid-4 { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .wrap { padding: 12px 10px 24px; }
  .card { padding: 12px; }
  .kpi { font-size: 1.35rem; }
  .topbar { padding: 9px 10px; }
  .card table { min-width: 560px; }
  h1 { font-size: 1.3rem; }
}
/* Mobile card tables: explicit opt-in, preserves desktop tables. */
@media (max-width: 820px) {
  .responsive-table { min-width: 0 !important; display: block; }
  .responsive-table thead { display: none; }
  .responsive-table tbody, .responsive-table tr, .responsive-table td { display: block; width: 100%; }
  .responsive-table tr { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; background: var(--panel); }
  .responsive-table td { border: 0; padding: 6px 0; display: flex; justify-content: space-between; gap: 14px; text-align: right; }
  .responsive-table td::before { content: attr(data-label); color: var(--muted); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; text-align: left; flex: 0 0 42%; }
  .responsive-table td:first-child { font-weight: 600; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}


dialog.modal {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text);
  padding: 0; width: min(94vw, 460px); box-shadow: 0 24px 80px rgba(15,23,42,.22);
}
dialog.modal::backdrop { background: rgba(15,23,42,.45); backdrop-filter: blur(2px); }
.modal-card { padding: 20px; }
.modal-card h2 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
body.modal-open { overflow: hidden; }
@keyframes modalIn { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
dialog.modal[open] { animation: modalIn .18s ease-out; }


dialog.form-dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); padding: 0; width: min(94vw, 760px); max-height: min(90vh, 900px); box-shadow: 0 24px 80px rgba(15,23,42,.24); }
dialog.form-dialog::backdrop { background: rgba(15,23,42,.45); backdrop-filter: blur(2px); }
.form-dialog .modal-card { padding: 20px; max-height: min(90vh, 900px); overflow-y: auto; }
.form-dialog .modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.form-dialog .modal-head h2 { margin: 0; }
.form-dialog .modal-actions { position: sticky; bottom: -20px; background: var(--panel); padding: 12px 0 0; border-top: 1px solid var(--line); }
@media (max-width: 820px) {
  dialog.form-dialog { width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  .form-dialog .modal-card { max-height: 100dvh; min-height: 100dvh; padding: 16px 14px 80px; }
  .form-dialog .modal-actions { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 14px; background: var(--panel); border-top: 1px solid var(--line); z-index: 2; }
}

/* Application shell / sidebar */
.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 238px; display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line); z-index: 70; padding: 16px 12px;
}
.side-brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 17px; padding: 4px 8px 18px; }
.brand-tag { font-size: 10px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 5px; padding: 2px 5px; letter-spacing: .06em; }
.side-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; }
.nav-group { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; font-weight: 750; padding: 15px 10px 5px; }
.side-nav a { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13.5px; padding: 9px 10px; border-radius: 8px; }
.side-nav a:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.side-nav a.active { background: var(--accent-soft); color: var(--accent); }
.side-nav svg, .icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-user { display: flex; align-items: center; gap: 9px; min-width: 0; }
.side-user b, .side-user small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }
.side-user small { color: var(--muted); font-size: 11.5px; }
.avatar { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 800; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; min-height: 36px; padding: 0; border: 0; background: transparent; color: var(--muted); }
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }
.app-main { margin-left: 238px; min-width: 0; }
.app-main .topbar { height: 62px; padding: 11px 26px; }
.topbar-title { font-size: 14px; font-weight: 750; color: var(--text); }
.nav-toggle { display: none !important; }
@media (max-width: 820px) {
  .app-main { margin-left: 0; }
  .app-main .topbar { padding: 9px 14px; height: 58px; }
  .sidebar { transform: translateX(-105%); transition: transform .22s ease; box-shadow: 12px 0 32px rgba(15,23,42,.18); width: min(86vw, 300px); }
  .sidebar-open .sidebar { transform: none; }
  .nav-toggle { display: inline-flex !important; }
  body.sidebar-open .nav-backdrop { display: block; }
}

/* Shared page and wizard components */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 2px 0 4px; }
.page-head p { margin: 0; max-width: 760px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.eyebrow { color: var(--muted); font-size: 11.5px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.notice { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); margin: 12px 0; overflow-wrap: anywhere; }
.notice-warning { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); background: var(--warn-soft); }
.notice-danger { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); background: var(--bad-soft); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0 0 2px; }
.card-head p { margin: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 10px; min-width: 0; }
.stat span { display: block; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.stat strong { display: block; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.form-grid { display: grid; gap: 2px; }
.form-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.inline-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.inline-form label { margin: 0; }
.confirm-line { display: flex; align-items: center; gap: 8px; max-width: 360px; }
.confirm-line input { flex: 0 0 auto; }
.tiny { font-size: 11px; }
.data-table.compact th, .data-table.compact td { padding: 8px 9px; }
@media (max-width: 820px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head { gap: 10px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  .inline-form { align-items: stretch; }
  .inline-form label, .inline-form input, .inline-form .btn, .inline-form button { width: 100%; }
}
@media (max-width: 380px) { .stat-grid { grid-template-columns: 1fr; } }

/* Topbar profile menu */
.top-user { position: relative; }
.top-user summary { list-style: none; display: flex; align-items: center; gap: 7px; cursor: pointer; padding: 3px 5px; border-radius: 999px; color: var(--text); font-size: 12.5px; font-weight: 650; }
.top-user summary::-webkit-details-marker { display: none; }
.top-user summary:hover { background: var(--bg-soft); }
.top-user-menu { position: absolute; right: 0; top: calc(100% + 8px); width: 230px; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 11px; box-shadow: 0 16px 40px rgba(15,23,42,.16); z-index: 80; }
.top-user-menu .side-user { margin-bottom: 10px; }
.top-user-menu form { margin: 0; }
@media (max-width: 820px) {
  .top-user summary .hide-mobile { display: none; }
  .top-user-menu { position: fixed; right: 10px; top: 54px; width: min(90vw, 260px); }
}

/* Loading skeletons */
.skeleton-stack { display: grid; gap: 10px; padding: 6px 0; }
.skeleton { background: linear-gradient(90deg, var(--panel-2) 25%, var(--line) 37%, var(--panel-2) 63%); background-size: 400% 100%; animation: skeletonShimmer 1.2s ease infinite; border-radius: 7px; }
.sk-line { height: 38px; }
.sk-block { height: 150px; }
@keyframes skeletonShimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

.public-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 10%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 38%),
    radial-gradient(circle at 90% 90%, color-mix(in srgb, var(--warn) 12%, transparent), transparent 35%),
    var(--bg);
}
.blocked-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.blocked-card {
  width: min(100%, 760px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 5px solid var(--accent);
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .15);
  padding: clamp(22px, 5vw, 42px);
}
.blocked-card.is-blocked, .blocked-card.is-terminated { border-top-color: var(--bad); }
.blocked-card.is-frozen, .blocked-card.is-pending { border-top-color: var(--warn); }
.blocked-card.is-active { border-top-color: var(--good); }
.blocked-brand { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 800; margin-bottom: 28px; }
.blocked-icon {
  width: 62px; height: 62px; display: grid; place-items: center; border-radius: 20px;
  background: var(--bad-soft); color: var(--bad); font-size: 30px; font-weight: 800;
  border: 1px solid color-mix(in srgb, var(--bad) 25%, var(--line)); margin-bottom: 18px;
}
.blocked-card.is-frozen .blocked-icon, .blocked-card.is-pending .blocked-icon { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, var(--line)); }
.blocked-card.is-terminated .blocked-icon { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, var(--line)); }
.blocked-card.is-active .blocked-icon { background: var(--good-soft); color: var(--good); border-color: color-mix(in srgb, var(--good) 25%, var(--line)); }
.blocked-eyebrow { margin: 0 0 8px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.blocked-card h1 { margin: 0 0 12px; font-size: clamp(1.7rem, 5vw, 2.5rem); }
.blocked-lead { max-width: 620px; margin: 0 0 24px; color: var(--muted); font-size: clamp(1rem, 2.2vw, 1.14rem); }
.blocked-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 22px 0; }
.blocked-meta > div { min-width: 0; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); }
.blocked-meta span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.blocked-meta strong { display: block; overflow-wrap: anywhere; font-size: 14px; }
.blocked-reason { padding: 14px 16px; margin: 16px 0; border: 1px solid color-mix(in srgb, var(--bad) 25%, var(--line)); border-radius: 13px; background: var(--bad-soft); }
.blocked-reason span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.blocked-reason p { margin: 0; font-weight: 650; }
.blocked-balance { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 15px 17px; margin: 16px 0 22px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel-2); }
.blocked-balance span { color: var(--muted); font-weight: 700; }
.blocked-balance strong { font-size: clamp(1.35rem, 4vw, 1.9rem); font-variant-numeric: tabular-nums; }
.blocked-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 20px; }
.blocked-actions .btn { min-height: 44px; }
.blocked-footer { padding-top: 20px; margin-top: 22px; border-top: 1px solid var(--line); }
.blocked-footer p { margin: 0 0 7px; }
@media (max-width: 620px) {
  .blocked-shell { padding: 14px; }
  .blocked-card { padding: 22px 18px; border-radius: 16px; }
  .blocked-meta { grid-template-columns: 1fr; }
  .blocked-actions .btn { width: 100%; }
  .blocked-balance { align-items: flex-start; flex-direction: column; gap: 4px; }
}

/* ============================================================
   KENI-BILL / Шел-Сервис — визуальный слой 2026
   ============================================================ */
:root {
  --bg: #edf4ff;
  --bg-soft: #e6efff;
  --panel: #ffffff;
  --panel-2: #f6f9ff;
  --text: #0f172a;
  --muted: #5b6b84;
  --line: #dbe6f5;
  --line-strong: #b8c9e2;
  --accent: #2563eb;
  --accent-2: #06b6d4;
  --accent-3: #7c3aed;
  --accent-soft: #dbeafe;
  --good: #047857;
  --good-soft: #d1fae5;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #be123c;
  --bad-soft: #ffe4e6;
  --shadow: 0 2px 4px rgba(15, 23, 42, .03), 0 16px 40px rgba(37, 99, 235, .08);
  --shadow-lift: 0 12px 30px rgba(37, 99, 235, .16);
  --radius: 18px;
  --radius-sm: 11px;
}
[data-theme="dark"] {
  --bg: #07101f;
  --bg-soft: #0b172b;
  --panel: #0f1d33;
  --panel-2: #132540;
  --text: #eaf2ff;
  --muted: #9db0cb;
  --line: #213a5b;
  --line-strong: #345578;
  --accent: #61a5ff;
  --accent-2: #2dd4bf;
  --accent-3: #a78bfa;
  --accent-soft: #122e5c;
  --shadow: 0 2px 4px rgba(0,0,0,.2), 0 18px 44px rgba(0,0,0,.28);
  --shadow-lift: 0 16px 36px rgba(0,0,0,.36);
}
body {
  background:
    radial-gradient(1100px 520px at 8% -8%, color-mix(in srgb, var(--accent-2) 16%, transparent), transparent 65%),
    radial-gradient(900px 520px at 100% 0%, color-mix(in srgb, var(--accent-3) 10%, transparent), transparent 62%),
    var(--bg);
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background: linear-gradient(115deg, transparent 30%, color-mix(in srgb, var(--accent) 5%, transparent) 50%, transparent 70%);
  animation: ambientShift 18s ease-in-out infinite alternate;
}
@keyframes ambientShift { from { transform: translate3d(-3%, 0, 0); } to { transform: translate3d(3%, 0, 0); } }
@keyframes riseIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes softPulse { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 18%, transparent); } 50% { box-shadow: 0 0 0 7px transparent; } }

.sidebar {
  background: linear-gradient(165deg, #0b1730 0%, #11264b 55%, #0a3a5f 100%);
  border-right: 0;
  padding: 18px 14px;
  box-shadow: 12px 0 40px rgba(2, 12, 27, .18);
}
.side-brand { padding: 4px 8px 20px; color: #fff; text-decoration: none; }
.side-brand:hover { text-decoration: none; }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; box-shadow: 0 7px 18px rgba(6, 182, 212, .32); flex: 0 0 auto; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.brand-copy b { color: #fff; font-size: 16px; letter-spacing: -.02em; }
.brand-copy small { color: #9fc4ee; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-top: 4px; }
.side-nav a { color: #fff; border-radius: 11px; padding: 10px 11px; transition: background .2s, color .2s, transform .2s; }
.side-nav a:hover { background: rgba(255,255,255,.08); color: #fff; transform: translateX(2px); }
.side-nav a.active { background: linear-gradient(90deg, rgba(34,211,238,.22), rgba(37,99,235,.28)); color: #fff; box-shadow: inset 3px 0 0 #22d3ee; }
.nav-group { color: #6f8cb3; }
.side-foot { border-top-color: rgba(255,255,255,.12); }
.side-user b { color: #fff; }
.side-user small { color: #9fc4ee; }
.sidebar .avatar { background: rgba(34,211,238,.16); color: #8be9f6; }
.sidebar .icon-btn { color: #a9bfdc; }
.sidebar .icon-btn:hover { background: rgba(255,255,255,.09); color: #fff; }

.topbar { background: color-mix(in srgb, var(--panel) 82%, transparent); box-shadow: 0 1px 0 var(--line); }
.topbar-title { font-size: 15px; letter-spacing: -.01em; }
.card {
  border-radius: var(--radius);
  border-color: color-mix(in srgb, var(--line) 82%, transparent);
  box-shadow: var(--shadow);
  animation: riseIn .38s ease both;
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: color-mix(in srgb, var(--accent) 22%, var(--line)); }
.kpi { background: linear-gradient(120deg, var(--text), color-mix(in srgb, var(--accent) 72%, var(--text))); -webkit-background-clip: text; background-clip: text; color: transparent; }
.btn, button { border-radius: 11px; transition: background .2s, border-color .2s, transform .16s, box-shadow .2s; }
.btn:hover, button:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(37,99,235,.12); }
.btn.primary, button.primary { background: linear-gradient(135deg, #2563eb, #0891b2); border-color: transparent; box-shadow: 0 7px 18px rgba(37,99,235,.22); }
.btn.primary:hover, button.primary:hover { filter: brightness(1.06); box-shadow: 0 10px 24px rgba(37,99,235,.3); }
.btn.danger, button.danger { background: linear-gradient(135deg, #fff1f2, #ffe4e6); }
input, select, textarea { background: color-mix(in srgb, var(--panel) 90%, var(--bg)); transition: border-color .2s, box-shadow .2s, background .2s; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line-strong)); }
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); background: var(--panel); }
th { background: color-mix(in srgb, var(--accent-soft) 34%, var(--panel-2)); }
tbody tr { transition: background .18s; }
.badge.good { background: color-mix(in srgb, var(--good-soft) 80%, var(--panel)); animation: softPulse 2.8s ease-in-out infinite; }
.brand-tag { background: rgba(34,211,238,.16); color: #8be9f6; }
.login {
  position: relative; max-width: 470px; margin: 7vh auto; padding: 30px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(18px); border-color: color-mix(in srgb, var(--accent) 22%, var(--line));
  box-shadow: 0 30px 80px rgba(15,23,42,.16);
}
.login::before {
  content: ""; position: absolute; inset: -1px; z-index: -1; border-radius: calc(var(--radius) + 1px);
  background: linear-gradient(120deg, color-mix(in srgb, var(--accent-2) 55%, transparent), transparent 42%, color-mix(in srgb, var(--accent-3) 45%, transparent));
  opacity: .8; filter: blur(10px);
}
.login h1 { margin-top: 0; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-brand img { width: 46px; height: 46px; border-radius: 14px; box-shadow: 0 8px 20px rgba(6,182,212,.3); }
.auth-brand b { display: block; font-size: 20px; letter-spacing: -.03em; }
.auth-brand small { display: block; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; margin-top: 3px; }

/* Абонентский кабинет */
.portal-shell { max-width: 1120px; margin: 0 auto; animation: riseIn .45s ease both; }
.portal-topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.portal-brand { display: flex; align-items: center; gap: 12px; color: var(--text); }
.portal-brand:hover { text-decoration: none; }
.portal-brand img { width: 46px; height: 46px; border-radius: 14px; box-shadow: 0 8px 20px rgba(6,182,212,.24); }
.portal-brand b { display: block; font-size: 19px; letter-spacing: -.03em; }
.portal-brand small { display: block; color: var(--muted); font-size: 10.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; margin-top: 3px; }
.portal-head { padding: 24px 26px; border-radius: 22px; color: #fff; background: linear-gradient(120deg, #0f172a, #1d4ed8 65%, #0891b2); box-shadow: 0 22px 50px rgba(29,78,216,.22); margin-bottom: 16px; }
.portal-head h1 { margin: 0 0 5px; }
.portal-head .muted { color: #d6e6ff; }
.portal-nav { display: flex; gap: 4px; flex-wrap: wrap; padding: 6px; background: color-mix(in srgb, var(--panel) 82%, transparent); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); margin-bottom: 16px; backdrop-filter: blur(12px); }
.portal-nav a { color: var(--muted); padding: 8px 12px; border-radius: 9px; font-size: 13px; font-weight: 650; }
.portal-nav a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.portal-balance { background: linear-gradient(135deg, #eff6ff, #ecfeff); border-color: #bfdbfe; }
[data-theme="dark"] .portal-balance { background: linear-gradient(135deg, #0c2447, #0b3440); border-color: #1e4d72; }
.portal-page-enter { animation: riseIn .5s ease both; }

/* Модальные окна и подсказки */
dialog.modal, dialog.form-dialog { animation: modalIn .24s cubic-bezier(.2,.8,.2,1) both; }
dialog.modal::backdrop, dialog.form-dialog::backdrop { background: rgba(7, 16, 31, .58); backdrop-filter: blur(6px); }
.modal-card { border-radius: inherit; }
.form-dialog .modal-head h2 { font-size: 1.2rem; }
@media (max-width: 820px) {
  .sidebar { background: linear-gradient(170deg, #0b1730, #11264b 70%, #0a3a5f); }
  .portal-shell { padding: 0; }
  .portal-head { padding: 20px 18px; border-radius: 18px; }
  .portal-nav { overflow-x: auto; flex-wrap: nowrap; }
  .portal-nav a { white-space: nowrap; }
  .login { margin: 4vh auto; padding: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* Рабочий стол сотрудника */
.dashboard-hero {
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
  padding: 26px 28px; margin-bottom: 16px; border-radius: 22px; color: #fff;
  background:
    radial-gradient(520px 220px at 92% 8%, rgba(34,211,238,.3), transparent 65%),
    linear-gradient(120deg, #0b1730, #1e3a8a 60%, #0e7490);
  box-shadow: 0 22px 50px rgba(30,58,138,.24);
  animation: riseIn .42s ease both;
}
.dashboard-hero h1 { margin: 3px 0 5px; color: #fff; }
.hero-eyebrow { color: #8be9f6; font-size: 10.5px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.hero-muted { color: #d6e6ff; font-size: 13.5px; }
.hero-secondary { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.22); }
.hero-secondary:hover { background: rgba(255,255,255,.2); color: #fff; }
@media (max-width: 620px) {
  .dashboard-hero { padding: 20px; }
  .dashboard-hero .row { width: 100%; }
  .dashboard-hero .btn, .dashboard-hero button { flex: 1 1 auto; }
}

/* Компактный рабочий режим */
.wrap { max-width: 1200px; padding: 18px 22px 28px; }
.sidebar { width: 216px; padding: 14px 10px; }
.app-main { margin-left: 216px; }
.app-main .topbar { height: 54px; padding: 8px 20px; }
.side-brand { padding: 2px 8px 14px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; }
.brand-copy b { font-size: 15px; }
.brand-copy small { font-size: 9px; margin-top: 2px; }
.side-nav a { padding: 8px 9px; font-size: 13px; gap: 8px; }
.side-nav svg { width: 16px; height: 16px; }
.nav-group { padding: 11px 9px 3px; font-size: 9.5px; }
.side-foot { padding-top: 10px; }
.card { padding: 14px; border-radius: 14px; }
.card + .card { margin-top: 10px; }
.grid { gap: 10px; }
.dashboard-hero { padding: 17px 20px; border-radius: 16px; margin-bottom: 12px; }
.dashboard-hero h1 { font-size: 1.5rem; }
.hero-muted { font-size: 12.5px; }
.kpi { font-size: 1.45rem; }
.card h2 { margin-bottom: 9px; }
.table-wrap, .tablescroll { margin: -2px 0; }
th, td { padding: 8px 9px; }
th { font-size: 10.5px; }
.two-col { gap: 12px; }
.portal-head { padding: 18px 20px; border-radius: 16px; margin-bottom: 12px; }
.portal-head h1 { font-size: 1.55rem; }
.portal-nav { padding: 4px; margin-bottom: 12px; border-radius: 11px; }
.portal-nav a { padding: 7px 10px; font-size: 12.5px; }
.portal-topbar { margin-bottom: 14px; }
.btn, button { min-height: 34px; padding: 6px 11px; font-size: 13px; }
.btn.small, button.small { min-height: 27px; padding: 3px 7px; font-size: 11.5px; }
input, select, textarea { min-height: 37px; padding: 7px 10px; }
.login { padding: 24px; }
.auth-brand { margin-bottom: 18px; }

/* Модули */
.module-group h2 { display: flex; align-items: center; gap: 8px; }
.module-grid { display: grid; gap: 7px; }
.module-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px;
  background: var(--panel-2); transition: border-color .2s, background .2s, transform .2s;
}
.module-row:hover { border-color: color-mix(in srgb, var(--accent) 38%, var(--line)); transform: translateX(2px); }
.module-row.module-off { opacity: .72; background: color-mix(in srgb, var(--panel-2) 72%, var(--bg)); }
.module-info { min-width: 0; }
.module-title { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.module-title strong { font-size: 13.5px; }
.module-row form { flex: 0 0 auto; }
@media (max-width: 820px) {
  .app-main { margin-left: 0; }
  .wrap { padding: 14px 12px 24px; }
  .card { padding: 12px; }
  .dashboard-hero { padding: 16px; }
  .module-row { align-items: flex-start; }
}
@media (max-width: 520px) {
  .module-row { flex-direction: column; align-items: stretch; }
  .module-row form button { width: 100%; }
}

/* Сотруднический кабинет: тёмная NOC-тема 2a */
body.staff-noc, body.staff-login {
  color-scheme: dark;
  --bg: #06111c;
  --bg-soft: #0a1828;
  --panel: #0c1b2b;
  --panel-2: #102337;
  --text: #e8f3fc;
  --muted: #809bb6;
  --line: #18344d;
  --line-strong: #214b6a;
  --accent: #3ee5f0;
  --accent-2: #0a7f9d;
  --accent-3: #4b6c8b;
  --accent-soft: #083448;
  --good: #61e6ae;
  --good-soft: #0b2a22;
  --warn: #ffc857;
  --warn-soft: #33280d;
  --bad: #ff7185;
  --bad-soft: #35131c;
  --shadow: 0 1px 2px rgba(0,0,0,.25), 0 14px 36px rgba(0,0,0,.28);
  --shadow-lift: 0 18px 42px rgba(0,0,0,.38);
  --table-head: #0a1725;
  --hover: #10283c;
  --active-line: #15506a;
  --ok-bg: #0b2a22;
  --ok-line: #1a4f40;
  --warn-bg: #33280d;
  --warn-line: #5d491e;
  --bad-bg: #35131c;
  --bad-line: #5d2232;
  background:
    radial-gradient(900px 500px at 88% -8%, rgba(20, 112, 145, .22), transparent 65%),
    radial-gradient(700px 450px at 5% 10%, rgba(11, 87, 125, .14), transparent 60%),
    var(--bg);
  color: var(--text);
}
body.staff-noc::before, body.staff-login::before { opacity: .35; }
body.staff-noc .topbar { background: rgba(6, 17, 28, .9); border-bottom-color: var(--line); }
body.staff-noc .topbar-title { color: var(--text); }
body.staff-noc .icon-btn { color: var(--muted); }
body.staff-noc .icon-btn:hover { background: var(--panel-2); color: var(--accent); }
body.staff-noc .card {
  background: var(--panel); border-color: var(--line); box-shadow: var(--shadow);
}
body.staff-noc .card:hover { border-color: var(--active-line, #15506a); box-shadow: var(--shadow-lift); }
body.staff-noc .card h2 { color: var(--text); }
body.staff-noc .muted { color: var(--muted); }
body.staff-noc .kpi { background: linear-gradient(120deg, #e8f3fc, #7eeaf3); -webkit-background-clip: text; background-clip: text; color: transparent; }
body.staff-noc th { background: var(--table-head); color: var(--muted); }
body.staff-noc td { border-bottom-color: var(--line-soft); }
body.staff-noc tbody tr:hover td { background: var(--hover); }
body.staff-noc .badge { background: var(--table-head); border-color: var(--line); color: var(--muted); }
body.staff-noc .badge.good { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
body.staff-noc .badge.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
body.staff-noc .badge.bad { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); }
body.staff-noc .btn, body.staff-noc button { background: var(--panel); border-color: var(--line-strong); color: var(--text); }
body.staff-noc .btn:hover, body.staff-noc button:hover { border-color: var(--accent); color: var(--accent); box-shadow: 0 6px 16px rgba(0,0,0,.25); }
body.staff-noc .btn.primary, body.staff-noc button.primary { background: var(--accent-2); border-color: var(--accent-2); color: #dffdff; }
body.staff-noc .btn.danger, body.staff-noc button.danger { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); }
body.staff-noc .btn.ghost, body.staff-noc button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
body.staff-noc input, body.staff-noc select, body.staff-noc textarea { background: var(--bg-soft); border-color: var(--line-strong); color: var(--text); }
body.staff-noc input:hover, body.staff-noc select:hover, body.staff-noc textarea:hover { border-color: var(--accent-2); }
body.staff-noc input:focus, body.staff-noc select:focus, body.staff-noc textarea:focus { background: var(--panel); box-shadow: 0 0 0 4px rgba(62,229,240,.12); border-color: var(--accent); }
body.staff-noc label { color: var(--muted); }
body.staff-noc .dashboard-hero { background: radial-gradient(520px 220px at 92% 8%, rgba(62,229,240,.25), transparent 65%), linear-gradient(120deg,#081522,#0b2d40 60%,#0a5062); }
body.staff-noc .hero-muted { color: #a8c9dc; }
body.staff-noc .hero-eyebrow { color: var(--accent); }
body.staff-noc .hero-secondary { background: rgba(255,255,255,.08); color: var(--text); border-color: var(--line-strong); }
body.staff-noc .messages li { background: var(--panel); border-color: var(--line); color: var(--text); }
body.staff-noc .messages li.success { background: var(--good-soft); border-color: var(--good); color: var(--good); }
body.staff-noc .messages li.error { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
body.staff-noc .messages li.warning { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
body.staff-noc .messages li.info { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
body.staff-noc dialog.modal, body.staff-noc dialog.form-dialog { background: var(--panel); border-color: var(--line); color: var(--text); }
body.staff-noc .module-row { background: var(--table-head); border-color: var(--line); }
body.staff-noc .module-row:hover { border-color: var(--accent-2); }
body.staff-noc .module-row.module-off { background: color-mix(in srgb, var(--panel) 75%, var(--bg)); }
body.staff-noc .side-brand { border-color: var(--line); }
body.staff-noc #themeToggle { display: none; }

/* Вход сотрудника — та же тёмная тема */
body.staff-login .login { background: var(--panel); border-color: var(--line); color: var(--text); box-shadow: 0 28px 70px rgba(0,0,0,.42); }
body.staff-login .login h1 { color: var(--text); }
body.staff-login .login .muted { color: var(--muted); }
body.staff-login .login label { color: var(--muted); }
body.staff-login .login input { background: var(--bg-soft); border-color: var(--line-strong); color: var(--text); }
body.staff-login .login input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(62,229,240,.12); }
body.staff-login .login a { color: var(--accent); }

/* Контраст числовых KPI в тёмном кабинете */
body.staff-noc .kpi {
  background: none !important;
  -webkit-background-clip: initial !important;
  background-clip: initial !important;
  color: var(--text) !important;
  text-shadow: 0 0 18px rgba(62, 229, 240, .08);
}

/* Карточка абонента */
.customer-crumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; margin-bottom: 9px; }
.customer-crumbs a { color: var(--accent); text-decoration: none; }
.customer-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 18px;
  padding: 16px 18px; margin-bottom: 10px; border: 1px solid var(--line);
  border-radius: 12px; background: linear-gradient(110deg, var(--panel), color-mix(in srgb, var(--accent) 8%, var(--panel)));
  box-shadow: var(--shadow);
}
.customer-identity { display: flex; align-items: flex-start; gap: 13px; min-width: 0; }
.person-avatar {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--line-strong);
  font-size: 15px; font-weight: 800; flex: 0 0 auto;
}
.customer-head h1 { margin: 0 0 4px; font-size: 1.65rem; letter-spacing: -.04em; }
.customer-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: 11.5px; }
.customer-meta b { color: var(--text); font-weight: 650; }
.customer-head .badges { margin-top: 8px; }
.customer-balance { min-width: 220px; text-align: right; border-left: 1px solid var(--line); padding-left: 18px; }
.customer-balance .label { color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: 9px; }
.customer-balance .sum { font-size: 1.85rem; font-weight: 800; letter-spacing: -.05em; margin: 2px 0; font-variant-numeric: tabular-nums; }
.customer-balance .sub { color: var(--muted); font-size: 10.5px; }
.customer-balance .head-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 9px; flex-wrap: wrap; }
.customer-tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.customer-tabs a { color: var(--muted); text-decoration: none; white-space: nowrap; font-size: 12px; padding: 8px 10px; border-bottom: 2px solid transparent; }
.customer-tabs a:hover { color: var(--text); }
.customer-tabs a:first-child { color: var(--accent); border-color: var(--accent); }
.customer-head, #services, #payment, #history, #ledger, #promises { scroll-margin-top: 70px; }
@media (max-width: 900px) {
  .customer-head { display: block; }
  .customer-balance { border-left: 0; border-top: 1px solid var(--line); padding: 12px 0 0; margin-top: 12px; text-align: left; }
  .customer-balance .head-actions { justify-content: flex-start; }
}
@media (max-width: 520px) {
  .customer-identity { display: block; }
  .person-avatar { margin-bottom: 8px; }
  .customer-head h1 { font-size: 1.4rem; }
  .customer-balance .head-actions .btn { flex: 1 1 auto; }
}

/* Общая компактная шапка раздела, как в карточке абонента */
.workspace-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 13px 16px; margin-bottom: 11px; border: 1px solid var(--line); border-radius: 10px;
  background: linear-gradient(110deg, var(--panel), color-mix(in srgb, var(--accent-2) 13%, var(--panel)));
  box-shadow: var(--shadow);
}
.workspace-head h1 { margin: 2px 0 3px; font-size: 1.45rem; letter-spacing: -.04em; }
.workspace-eyebrow { color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.workspace-meta { color: var(--muted); font-size: 11.5px; }
.workspace-head .head-actions { display: flex; gap: 6px; flex-wrap: wrap; }
body.staff-noc .workspace-head { background: linear-gradient(110deg, var(--panel), color-mix(in srgb, var(--accent-2) 14%, var(--panel))); }
@media (max-width: 600px) {
  .workspace-head { display: block; }
  .workspace-head .head-actions { margin-top: 10px; }
  .workspace-head .head-actions .btn, .workspace-head .head-actions button { flex: 1 1 auto; }
}


/* ЛК абонента в 2a — той же палитрой, что abonent-card */
body.portal-noc {
  color-scheme: dark;
  --bg: #06111c;
  --bg-soft: #0a1828;
  --panel: #0c1b2b;
  --panel-2: #102337;
  --text: #e8f3fc;
  --muted: #809bb6;
  --line: #18344d;
  --line-strong: #214b6a;
  --accent: #3ee5f0;
  --accent-2: #0a7f9d;
  --accent-3: #4b6c8b;
  --accent-soft: #083448;
  --good: #61e6ae;
  --good-soft: #0b2a22;
  --warn: #ffc857;
  --warn-soft: #33280d;
  --bad: #ff7185;
  --bad-soft: #35131c;
  --shadow: 0 1px 2px rgba(0,0,0,.25), 0 14px 36px rgba(0,0,0,.28);
  --table-head: #0a1725;
  --hover: #10283c;
  --active-line: #15506a;
  --ok: #61e6ae;
  --ok-bg: #0b2a22;
  --ok-line: #1a4f40;
  --warn-bg: #33280d;
  --warn-line: #5d491e;
  --bad-bg: #35131c;
  --bad-line: #5d2232;
  background:
    radial-gradient(900px 500px at 88% -8%, rgba(20,112,145,.22), transparent 65%),
    radial-gradient(700px 450px at 5% 10%, rgba(11,87,125,.14), transparent 60%),
    var(--bg);
  color: var(--text);
}
body.portal-noc .portal-head {
  background: radial-gradient(480px 200px at 92% 8%, rgba(62,229,240,.25), transparent 65%), linear-gradient(120deg,#081522,#0b2d40 60%,#0a5062);
  box-shadow: 0 20px 48px rgba(6, 40, 58, .42);
}
body.portal-noc .portal-head .muted { color: #a8c9dc; }
body.portal-noc .portal-nav { background: color-mix(in srgb, var(--panel) 90%, transparent); border-color: var(--line); }
body.portal-noc .portal-nav a { color: var(--muted); }
body.portal-noc .portal-nav a:hover { background: var(--active); color: var(--accent); }
body.portal-noc .portal-balance { background: linear-gradient(135deg,#0d2236,#0a1c2d); border-color: var(--active-line); }
body.portal-noc .card { background: var(--panel); border-color: var(--line); }
body.portal-noc .card:hover { border-color: var(--accent-2); }
body.portal-noc .btn { background: var(--panel); border-color: var(--line-strong); color: var(--text); }
body.portal-noc .btn:hover { border-color: var(--accent); color: var(--accent); }
body.portal-noc .btn.primary { background: var(--accent-2); border-color: var(--accent-2); color: #dffdff; }
body.portal-noc input, body.portal-noc select, body.portal-noc textarea { background: var(--bg-soft); border-color: var(--line-strong); color: var(--text); }
body.portal-noc input:focus, body.portal-noc select:focus, body.portal-noc textarea:focus { background: var(--panel); border-color: var(--accent); box-shadow: 0 0 0 4px rgba(62,229,240,.12); }
body.portal-noc .badge.good { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
body.portal-noc .badge.bad { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); }
body.portal-noc .badge.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
body.portal-noc .messages li { background: var(--panel); border-color: var(--line); color: var(--text); }
body.portal-noc .messages li.success { background: var(--good-soft); border-color: var(--good); color: var(--good); }
body.portal-noc .messages li.error { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
body.portal-noc .login { background: var(--panel); border-color: var(--line); color: var(--text); box-shadow: 0 28px 70px rgba(0,0,0,.42); }
body.portal-noc .login::before { background: linear-gradient(120deg, rgba(62,229,240,.4), transparent 42%, rgba(37,99,235,.35)); }
body.portal-noc .login .muted, body.portal-noc .login label { color: var(--muted); }
body.portal-noc .login a { color: var(--accent); }
body.portal-noc .login input { background: var(--bg-soft); border-color: var(--line-strong); color: var(--text); }
body.portal-noc .login input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(62,229,240,.12); }
body.portal-noc .portal-brand small { color: var(--muted); }

/* Вкладки и блоки карточки абонента */
.customer-tabs button {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  padding: 8px 10px; font: inherit; font-size: 12px; border-bottom: 2px solid transparent;
  border-radius: 0; min-height: 32px; white-space: nowrap; cursor: pointer;
}
.customer-tabs button:hover { color: var(--text); }
.customer-tabs button.is-active { color: var(--accent); border-color: var(--accent); }
.tab-panel[hidden] { display: none !important; }
.customer-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .72fr); gap: 10px; }
.stack { display: grid; gap: 10px; align-content: start; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.panel-title h2 { margin: 0; }
.panel-title a, .link-button { color: var(--accent); font-size: 10.5px; text-decoration: none; background: transparent; border: 0; padding: 0; min-height: 0; }
.link-button:hover { text-decoration: underline; }
.service-summary { padding: 2px 0 0; }
.service-summary-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.service-summary-top strong { font-size: 13px; }
.fact-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 10px; }
.fact { background: var(--table-head); border: 1px solid var(--line); border-radius: 4px; padding: 7px 8px; }
.fact .k { color: var(--muted); font-size: 8.5px; text-transform: uppercase; letter-spacing: .07em; }
.fact .v { color: var(--text); font-size: 11px; margin-top: 2px; overflow-wrap: anywhere; }
.fact .v.mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.service-actions { margin-top: 10px; gap: 5px; }
.service-group { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.service-group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.service-block { border: 1px solid var(--line); background: var(--panel-2); border-radius: 6px; padding: 10px 11px; margin-top: 8px; }
.service-block details { border-top: 1px solid var(--line); margin-top: 8px; }
.form-grid { display: grid; gap: 6px; margin-top: 6px; }
.form-grid p { margin: 0; }
.info-list { display: grid; gap: 0; }
.info-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 10.5px; }
.info-row:last-child { border-bottom: 0; }
.info-row .k { color: var(--muted); }
.info-row .v { text-align: right; color: var(--text); overflow-wrap: anywhere; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.action-grid .btn { justify-content: flex-start; text-align: left; flex-direction: column; align-items: flex-start; gap: 1px; min-height: 48px; }
.action-grid .btn span { color: var(--muted); font-size: 9px; font-weight: 400; }
.timeline { padding-top: 2px; }
.timeline .event { display: grid; grid-template-columns: 6px 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 10.5px; }
.timeline .event:last-child { border-bottom: 0; }
.timeline .dot { width: 6px; height: 6px; border-radius: 50%; margin-top: 4px; }
.timeline b { display: block; font-size: 10.5px; }
.timeline small { color: var(--muted); font-size: 9.5px; }
@media (max-width: 1000px) {
  .customer-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .fact-grid { grid-template-columns: 1fr 1fr; }
  .action-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .customer-tabs { gap: 0; }
  .customer-tabs button { padding: 8px 7px; font-size: 11px; }
  .service-summary-top { display: block; }
  .service-summary-top .badge { display: inline-block; margin-top: 4px; }
}

/* Ширина рабочих областей: не «узкая колонка» */
.wrap { max-width: 1520px; padding-left: 26px; padding-right: 26px; }
.portal-shell { max-width: 1320px; }
.customer-grid { grid-template-columns: minmax(0, 1.5fr) minmax(340px, .68fr); }
.customer-head { padding: 18px 20px; }
.customer-tabs { margin-bottom: 14px; }
@media (min-width: 1700px) {
  .wrap { max-width: 1640px; }
}
@media (max-width: 1000px) {
  .wrap { padding-left: 18px; padding-right: 18px; }
  .customer-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .wrap { padding-left: 12px; padding-right: 12px; }
}

.balance-help { display: grid; gap: 7px; margin: 12px 0; }
.balance-help > div { border: 1px solid var(--line); background: var(--table-head); border-radius: 6px; padding: 9px 10px; font-size: 11.5px; color: var(--muted); }
.balance-help b { color: var(--text); }
.balance-help code { color: var(--accent); }
.balance-modal .modal-actions { margin-top: 14px; }

/* Нормальный читаемый размер интерфейса */
body { font-size: 16px; }
.sidebar { width: 240px; padding: 16px 12px; }
.app-main { margin-left: 240px; }
.side-brand { padding: 2px 9px 18px; }
.brand-mark { width: 38px; height: 38px; }
.brand-copy b { font-size: 17px; }
.brand-copy small { font-size: 9.5px; }
.side-nav a { font-size: 14px; padding: 10px 11px; }
.side-nav svg { width: 18px; height: 18px; }
.nav-group { font-size: 10px; padding: 14px 10px 5px; }
.app-main .topbar { height: 60px; padding: 10px 24px; }
.topbar-title { font-size: 15px; }
.card { font-size: 14px; }
th { font-size: 11px; }
th, td { padding: 9px 10px; }
.btn, button { font-size: 13.5px; }
.btn.small, button.small { font-size: 12px; }
input, select, textarea { font-size: 14px; }
label { font-size: 13px; }
.customer-meta, .info-row { font-size: 12px; }
.customer-tabs button { font-size: 13.5px; padding: 10px 12px; }
.fact .k { font-size: 9.5px; }
.fact .v { font-size: 12px; }
.service-summary-top strong { font-size: 14px; }
@media (max-width: 820px) {
  .sidebar { width: 240px; }
  .app-main { margin-left: 0; }
}

/* Единые аккуратные скроллбары */
html { scrollbar-gutter: stable; }
* { scrollbar-width: thin; scrollbar-color: rgba(96, 165, 250, .45) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(96, 165, 250, .42);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(96, 165, 250, .68); background-clip: padding-box; }
.side-nav { overflow-x: hidden; scrollbar-gutter: stable; padding-right: 2px; }
.side-nav::-webkit-scrollbar { width: 6px; }
.side-nav::-webkit-scrollbar-thumb { background: rgba(139, 233, 246, .34); border: 1px solid transparent; background-clip: padding-box; }
.side-nav::-webkit-scrollbar-thumb:hover { background: rgba(139, 233, 246, .58); background-clip: padding-box; }
.side-nav a { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table-wrap { max-width: 100%; }

/* Компактное меню на невысоких экранах, чтобы не было лишнего скролла */
@media (min-width: 821px) and (max-height: 860px) {
  .sidebar { padding: 12px 10px; }
  .side-brand { padding: 0 8px 10px; }
  .brand-mark { width: 32px; height: 32px; border-radius: 10px; }
  .brand-copy b { font-size: 15px; }
  .brand-copy small { font-size: 8.5px; margin-top: 2px; }
  .side-nav { gap: 1px; }
  .side-nav a { font-size: 13.5px; padding: 6px 10px; gap: 8px; }
  .side-nav svg { width: 16px; height: 16px; }
  .nav-group { padding: 8px 10px 2px; font-size: 9.5px; }
  .side-foot { padding-top: 8px; }
}

/* Единый вид полей во всех формах кабинета */
.form-stack { display: grid; gap: 0; }
.form-fields { display: grid; gap: 14px; }
.form-field { min-width: 0; }
.form-field > label { margin: 0 0 6px; color: var(--text); font-size: 13px; font-weight: 650; }
.form-field > input, .form-field > select, .form-field > textarea { display: block; }
.form-field .help { margin-top: 5px; font-size: 12px; line-height: 1.4; }
.form-field.has-error > input, .form-field.has-error > select, .form-field.has-error > textarea { border-color: var(--bad); }
.form-intro { margin: 0 0 15px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.form-errors { list-style: none; padding: 0; margin: 0 0 14px; }
.form-errors li { border: 1px solid color-mix(in srgb, var(--bad) 40%, var(--line)); background: var(--bad-soft); color: var(--bad); border-radius: var(--radius-sm); padding: 9px 11px; font-size: 12.5px; }
.field-error { color: var(--bad); font-size: 12px; margin-top: 5px; }
.req { color: var(--bad); }
.checkline {
  display: flex; align-items: flex-start; gap: 10px; margin: 0; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2);
  color: var(--text); font-size: 13px; font-weight: 650; cursor: pointer;
}
.checkline input { width: 18px; height: 18px; margin: 2px 0 0; flex: 0 0 auto; accent-color: var(--accent); }
.check-copy { display: block; min-width: 0; }
.check-copy b { display: block; }
.check-copy small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.4; margin-top: 2px; }
.form-card { max-width: 820px; }
.form-card .form-stack { max-width: 100%; }

/* Окно формы: неподвижная шапка, прокрутка только у полей */
dialog.form-dialog { width: min(96vw, 760px); max-height: min(92dvh, 900px); overflow: hidden; }
.form-dialog .modal-card {
  display: flex; flex-direction: column; max-height: min(92dvh, 900px);
  overflow: hidden; padding: 0;
}
.form-dialog .modal-head {
  flex: 0 0 auto; margin: 0; padding: 18px 20px 12px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
#formDialogBody {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
  padding: 16px 20px 20px; scrollbar-gutter: stable; overscroll-behavior: contain;
}
#formDialogBody .form-intro { margin-top: 0; }
.form-dialog .modal-actions {
  position: sticky; bottom: 0; z-index: 1; margin: 18px -20px -20px;
  padding: 12px 20px; background: color-mix(in srgb, var(--panel) 96%, transparent);
  border-top: 1px solid var(--line); backdrop-filter: blur(8px);
}
@media (max-width: 820px) {
  dialog.form-dialog { width: 100vw; height: 100dvh; max-height: 100dvh; }
  .form-dialog .modal-card { height: 100dvh; max-height: 100dvh; padding: 0; }
  .form-dialog .modal-head { padding: 13px 14px 10px; }
  #formDialogBody { padding: 14px 14px 18px; }
  .form-dialog .modal-actions {
    position: sticky; left: auto; right: auto; bottom: 0;
    margin: 16px -14px -18px; padding: 11px 14px calc(11px + env(safe-area-inset-bottom));
  }
}

/* На телефоне окно формы занимает всю ширину, без белой полосы справа */
@media (max-width: 820px) {
  html { scrollbar-gutter: auto; }
  dialog.form-dialog { width: 100vw; max-width: 100vw; margin: 0; }
  .form-dialog .modal-card { width: 100%; }
}

/* Карточка абонента: услуги, обещанный платёж и смена тарифа */
.service-page-intro { margin-bottom: 12px; }
.service-page-intro h2 { margin-bottom: 4px; }
.service-page-intro p { margin: 0; max-width: 780px; }
.service-contract { padding: 16px 18px; }
.service-contract-head,
.service-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.service-contract-head h2 { margin: 0 0 2px; }
.service-card { border: 1px solid var(--line); border-radius: 14px; background: var(--panel-2); padding: 14px; margin-top: 12px; }
.service-card h3 { margin: 0 0 3px; font-size: 15px; }
.service-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.service-fact { min-width: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 9px 10px; }
.service-fact > span { display: block; color: var(--muted); font-size: 9.5px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.service-fact > b { display: block; margin-top: 3px; font-size: 13px; overflow-wrap: anywhere; }
.service-fact > small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; overflow-wrap: anywhere; }
.service-card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.service-accordions { margin-top: 12px; display: grid; gap: 6px; }
.service-accordions > details { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 0 11px; margin: 0; }
.service-accordions > details > summary { padding: 10px 0; font-size: 13px; font-weight: 650; color: var(--text); }
.service-accordions > details[open] > summary { border-bottom: 1px solid var(--line); }
.service-detail-body { padding: 10px 0 12px; display: grid; gap: 9px; }
.service-line { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; min-width: 0; font-size: 12px; }
.service-line > span { color: var(--muted); min-width: 120px; }
.service-line > b { overflow-wrap: anywhere; }
.service-line > small { color: var(--muted); }
.nested-details { margin-top: 4px; padding-top: 8px; }
.danger-details > summary { color: var(--bad); }
.inline-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.inline-row select { width: auto; min-width: 170px; }
.promise-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.promise-summary > div { border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); padding: 9px 10px; min-width: 0; }
.promise-summary span { display: block; color: var(--muted); font-size: 9.5px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.promise-summary b { display: block; margin-top: 3px; font-size: 13px; overflow-wrap: anywhere; }
.notice.warn { border-color: color-mix(in srgb, var(--warn) 42%, var(--line)); background: var(--warn-soft); color: var(--warn); }
button:disabled, .btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
@media (max-width: 1000px) {
  .service-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .service-facts, .promise-summary { grid-template-columns: 1fr; }
  .service-contract { padding: 12px; }
  .service-card { padding: 12px; }
  .service-line > span { min-width: 100%; }
  .service-card-actions .btn, .service-card-actions button { flex: 1 1 auto; }
}

/* Глобальный поиск */
.top-search { position: relative; flex: 1 1 340px; max-width: 500px; min-width: 180px; margin: 0 10px; }
.top-search > svg { position: absolute; left: 12px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; pointer-events: none; }
.top-search input { width: 100%; min-height: 36px; padding: 7px 74px 7px 36px; border-radius: 10px; background: color-mix(in srgb, var(--panel-2) 80%, transparent); font-size: 13px; }
.top-search kbd { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 10px; border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; background: var(--panel); pointer-events: none; }
.search-page-form { display: flex; gap: 8px; margin-bottom: 16px; max-width: 760px; }
.search-page-form input { min-width: 0; }
.search-results { display: grid; gap: 12px; }
.search-results .card { padding: 15px 17px; }
.search-results h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.result-list { display: grid; }
.result-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border-top: 1px solid var(--line); color: var(--text); text-decoration: none; }
.result-row:first-child { border-top: 0; }
.result-row:hover { text-decoration: none; color: var(--accent); }
.result-row span:first-child { min-width: 0; display: grid; gap: 2px; }
.result-row b { font-size: 13px; overflow-wrap: anywhere; }
.result-row small { color: var(--muted); font-size: 11.5px; overflow-wrap: anywhere; }
.result-action { color: var(--accent); font-size: 12px; white-space: nowrap; }
@media (max-width: 1100px) { .top-search { max-width: 300px; } }
@media (max-width: 820px) { .top-search { display: none; } .search-page-form { flex-direction: column; } }

.search-mobile { display: none; }
@media (max-width: 820px) { .search-mobile { display: inline-flex; } }

/* Электросеть в карточке абонента */
.power-alert { display: flex; align-items: flex-start; gap: 14px; margin: 0 0 14px; padding: 14px 16px; border: 1px solid rgba(251,191,36,.45); border-radius: 14px; background: linear-gradient(120deg, rgba(120,73,9,.45), rgba(40,38,30,.42)); box-shadow: 0 12px 28px rgba(0,0,0,.12); }
.power-alert-icon { width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 11px; background: rgba(251,191,36,.18); color: #fbbf24; font-size: 20px; }
.power-alert-main { min-width: 0; flex: 1; }
.power-alert-main strong { display: block; font-size: 14px; color: var(--warn); }
.power-alert-main .addr { margin-top: 3px; font-size: 13px; color: var(--text); overflow-wrap: anywhere; }
.power-alert-main .meta { margin-top: 5px; font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }
.power-alert-main .meta b { color: var(--text); font-weight: 600; }
.power-alert .badge { flex: 0 0 auto; }
.power-card .power-row { display: flex; gap: 8px; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 11.5px; }
.power-card .power-row:last-of-type { border-bottom: 0; }
.power-card .power-row span { color: var(--muted); }
.power-card .power-row b { text-align: right; color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.power-card .power-note { margin-top: 8px; color: var(--muted); font-size: 10.5px; line-height: 1.5; }
.power-card .power-note a { color: var(--accent); }
.power-card .power-note form { display: inline; }
@media (max-width: 600px) {
  .power-alert { gap: 10px; padding: 12px; }
  .power-alert .badge { display: none; }
}
.power-card .power-source { margin: 9px 0 3px; color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.power-card .power-source:first-of-type { margin-top: 0; }

/* Каталог заглушек плана развития */
.roadmap-group h2 { display: flex; align-items: center; gap: 8px; }
.roadmap-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.roadmap-card { display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: var(--panel-2); text-decoration: none; }
.roadmap-card:hover { border-color: var(--accent); text-decoration: none; }
.roadmap-num { flex: 0 0 auto; min-width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 800; }
.roadmap-copy { min-width: 0; flex: 1; display: grid; gap: 2px; }
.roadmap-copy b { font-size: 12.5px; }
.roadmap-copy small { color: var(--muted); font-size: 11px; line-height: 1.4; }
.roadmap-card .badge { flex: 0 0 auto; font-size: 10px; }
.stub-preview { border: 1px dashed var(--line-strong); border-radius: 12px; background: var(--panel-2); padding: 12px; }
.stub-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.stub-metrics { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 6px; margin: 12px 0; }
.stub-metrics > div, .stub-table > div { border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--panel); min-width: 0; }
.stub-metrics span, .stub-table span { display: block; color: var(--muted); font-size: 10px; }
.stub-metrics b, .stub-table b { display: block; margin-top: 3px; font-size: 12px; }
.stub-table { display: grid; gap: 6px; }
.stub-actions { display: flex; gap: 7px; margin-top: 12px; }
.checklist { margin: 8px 0; padding-left: 18px; color: var(--muted); font-size: 12.5px; line-height: 1.65; }
@media (max-width: 900px) { .roadmap-grid { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .stub-metrics { grid-template-columns: 1fr; } }
.util { width: 120px; height: 7px; border-radius: 999px; background: var(--line); overflow: hidden; }
.util span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--good)); }
.knowledge-body { font-size: 14px; line-height: 1.7; }
.site-grid { display: grid; gap: 7px; }
.site-node { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--text); text-decoration: none; }
.site-node:hover { border-color: var(--accent); text-decoration: none; }
.site-node > span:nth-child(2) { flex: 1; min-width: 0; display: grid; gap: 2px; }
.site-node b { font-size: 13px; }
.site-node small { color: var(--muted); font-size: 11px; }
.site-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.site-dot.good { background: var(--good); box-shadow: 0 0 0 4px var(--good-soft); }
.site-dot.bad { background: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }
@media (max-width: 820px) {
  main .card > .table-wrap { margin: 0 -2px; padding: 0 2px 5px; }
  main .card > .table-wrap table { margin: 0; }
}
.filter-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-field { display: grid; gap: 4px; margin: 0; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.filter-field input { min-width: 150px; }
.nowrap { white-space: nowrap; }
@media (max-width: 820px) {
  .filter-row { align-items: stretch; }
  .filter-field { flex: 1 1 150px; }
  .filter-row button { width: 100%; }
}
.two-col { align-items: start; }

/* Технический доступ в карточке абонента */
.access-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(240px, .65fr); gap: 10px; margin-top: 12px; }
.access-panel { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 12px; min-width: 0; }
.access-panel h3 { margin: 0 0 8px; font-size: 14px; }
.access-panel .service-line { padding: 4px 0; }
.access-panel .service-actions { margin-top: 4px; }
.danger-panel { border-color: color-mix(in srgb, var(--bad) 30%, var(--line)); }
@media (max-width: 900px) { .access-grid { grid-template-columns: 1fr; } }

/* Меню второстепенных действий в шапке */
.action-menu { position: relative; border: 0; margin: 0; padding: 0; }
.action-menu > summary { list-style: none; }
.action-menu > summary::-webkit-details-marker { display: none; }
.action-menu-panel { position: absolute; right: 0; top: calc(100% + 7px); z-index: 90; min-width: 210px; display: none; padding: 7px; background: var(--panel); border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow); }
.action-menu[open] .action-menu-panel { display: grid; gap: 3px; }
.action-menu-panel .btn { width: 100%; justify-content: flex-start; }

/* Выравнивание шапки и видимая кнопка темы */
.top-actions, .top-user, .top-user summary { align-items: center; }
.top-user summary { min-height: 36px; }
.top-search { align-self: center; }

/* Светлая тема кабинета */
html[data-theme="light"] body.staff-noc {
  color-scheme: light;
  --bg: #f4f7fb; --bg-soft: #eef3fa; --panel: #ffffff; --panel-2: #f8fafc;
  --text: #172033; --muted: #64748b; --line: #e2e8f0; --line-strong: #cbd5e1;
  --accent: #2563eb; --accent-2: #2563eb; --accent-3: #0891b2; --accent-soft: #dbeafe;
  --good: #15803d; --good-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7;
  --bad: #b91c1c; --bad-soft: #fee2e2;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.04);
  --shadow-lift: 0 14px 36px rgba(15,23,42,.09);
  --table-head: #f1f5f9; --hover: #f1f5f9; --active-line: #bfdbfe;
  --ok-bg: #dcfce7; --ok-line: #86efac; --warn-bg: #fef3c7; --warn-line: #fcd34d;
  --bad-bg: #fee2e2; --bad-line: #fca5a5;
  background: radial-gradient(900px 500px at 88% -8%, rgba(37,99,235,.06), transparent 65%), var(--bg);
  color: var(--text);
}
html[data-theme="light"] body.staff-noc .sidebar { background: #fff; border-right: 1px solid var(--line); box-shadow: 12px 0 40px rgba(15,23,42,.06); }
html[data-theme="light"] body.staff-noc .side-brand, html[data-theme="light"] body.staff-noc .brand-copy b { color: var(--text); }
html[data-theme="light"] body.staff-noc .brand-copy small { color: var(--accent); }
html[data-theme="light"] body.staff-noc .side-nav a { color: var(--text); }
html[data-theme="light"] body.staff-noc .side-nav a:hover { background: var(--bg-soft); color: var(--text); }
html[data-theme="light"] body.staff-noc .side-nav a.active { background: var(--accent-soft); color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
html[data-theme="light"] body.staff-noc .nav-group { color: var(--muted); }
html[data-theme="light"] body.staff-noc .topbar { background: rgba(255,255,255,.9); border-bottom-color: var(--line); }
html[data-theme="light"] body.staff-noc .topbar-title { color: var(--text); }
html[data-theme="light"] body.staff-noc .btn.primary, html[data-theme="light"] body.staff-noc button.primary { color: #fff; }
html[data-theme="light"] body.staff-noc .btn:hover, html[data-theme="light"] body.staff-noc button:hover { box-shadow: 0 6px 16px rgba(15,23,42,.08); }
html[data-theme="light"] body.staff-noc .dashboard-hero { background: radial-gradient(520px 220px at 92% 8%, rgba(37,99,235,.13), transparent 65%), linear-gradient(120deg,#eff6ff,#dbeafe 60%,#cffafe); color: var(--text); box-shadow: 0 18px 40px rgba(37,99,235,.12); }
html[data-theme="light"] body.staff-noc .dashboard-hero h1 { color: var(--text); }
html[data-theme="light"] body.staff-noc .hero-muted { color: #475569; }
html[data-theme="light"] body.staff-noc .hero-eyebrow { color: var(--accent); }
html[data-theme="light"] body.staff-noc .hero-secondary { background: rgba(255,255,255,.6); color: var(--text); border-color: var(--line-strong); }
html[data-theme="light"] body.staff-noc .power-alert { background: #fffbeb; border-color: #fcd34d; box-shadow: 0 10px 24px rgba(180,83,9,.08); }
html[data-theme="light"] body.staff-noc .side-user b { color: var(--text); }
html[data-theme="light"] body.staff-noc .side-user small { color: var(--muted); }
html[data-theme="light"] body.staff-noc .sidebar .avatar { background: var(--accent-soft); color: var(--accent); }
html[data-theme="light"] body.staff-noc .sidebar .icon-btn { color: var(--muted); }
html[data-theme="light"] body.staff-noc .sidebar .icon-btn:hover { background: var(--bg-soft); color: var(--text); }
html[data-theme="light"] body.staff-noc .top-user-menu { background: var(--panel); }
html[data-theme="light"] body.staff-noc .module-row { background: var(--panel-2); }

.recent-customers-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.recent-customer { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: var(--panel-2); text-decoration: none; }
.recent-customer:hover { border-color: var(--accent); text-decoration: none; }
.recent-customer .avatar { width: 28px; height: 28px; font-size: 10px; flex: 0 0 auto; }
.recent-customer-main { min-width: 0; flex: 1; display: grid; gap: 1px; }
.recent-customer-main b { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-customer-main small { color: var(--muted); font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-customer-balance { font-size: 11px; white-space: nowrap; }
@media (max-width: 900px) { .recent-customers-grid { grid-template-columns: 1fr; } }

/* Верхний ряд рабочего стола */
.dashboard-top { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, .85fr); gap: 12px; align-items: stretch; }
.dashboard-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.dashboard-top .recent-customers { margin: 0; }
.dashboard-top .recent-customers-grid { grid-template-columns: 1fr; }
.dashboard-top .recent-customer { padding: 8px 9px; }
@media (max-width: 1100px) { .dashboard-top { grid-template-columns: 1fr; } .dashboard-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 700px) { .dashboard-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .dashboard-kpis { grid-template-columns: 1fr; } }
.top-user { height: 36px; padding: 0; margin: 0; border: 0; display: flex; align-items: center; }
.top-user summary { height: 36px; padding: 0 5px; }

/* Точное выравнивание профиля и меню действий в шапке */
.topbar details.top-user {
  height: 36px; min-height: 36px; margin: 0; padding: 0; border: 0;
  display: flex; align-items: center;
}
.topbar details.top-user > summary {
  height: 36px; min-height: 36px; margin: 0; padding: 0 5px;
  display: flex; align-items: center;
}
.head-actions details.action-menu {
  margin: 0; padding: 0; border: 0; display: inline-flex; align-items: center;
}
.head-actions details.action-menu > summary {
  height: 38px; margin: 0; padding: 0 13px; display: inline-flex; align-items: center;
}
html[data-theme="light"] body.staff-noc .kpi,
html[data-theme="light"] body.staff-noc .recent-customer,
html[data-theme="light"] body.staff-noc .recent-customer-main b,
html[data-theme="light"] body.staff-noc .recent-customer-balance {
  color: #172033 !important; background-image: none !important;
}
html[data-theme="light"] body.staff-noc .recent-customer-main small,
html[data-theme="light"] body.staff-noc .muted,
html[data-theme="light"] body.staff-noc th {
  color: #64748b !important;
}
html[data-theme="light"] body.staff-noc .recent-customer-balance.money-pos { color: #15803d !important; }
html[data-theme="light"] body.staff-noc .recent-customer-balance.money-neg { color: #b91c1c !important; }
.dashboard-top { align-items: start; }

/* Контраст текста по темам */
html[data-theme="light"] body.staff-noc { --text: #0b1220; --muted: #475569; }
html[data-theme="dark"] body.staff-noc, html[data-theme="dark"] body.staff-login {
  --text: #f7fbff; --muted: #b7c9de;
}
html[data-theme="light"] body.staff-noc th,
html[data-theme="light"] body.staff-noc label { color: #475569; }
html[data-theme="dark"] body.staff-noc th,
html[data-theme="dark"] body.staff-noc label { color: #b7c9de; }
html[data-theme="light"] body.staff-noc .kpi,
html[data-theme="light"] body.staff-noc .recent-customer,
html[data-theme="light"] body.staff-noc .recent-customer-main b,
html[data-theme="light"] body.staff-noc .recent-customer-balance { color: #0b1220 !important; }
html[data-theme="light"] body.staff-noc .recent-customer-main small,
html[data-theme="light"] body.staff-noc .muted,
html[data-theme="light"] body.staff-noc th { color: #475569 !important; }

/* Улучшенная типографика кабинета и ЛК */
body.staff-noc, body.portal-noc { font-size: 16px; }
body.staff-noc .small, body.staff-noc .help, body.portal-noc .small, body.portal-noc .help { font-size: 13.5px; }
body.staff-noc label, body.portal-noc label { font-size: 14px; }
body.staff-noc .badge, body.portal-noc .badge { font-size: 12.5px; }
body.staff-noc .btn.small, body.staff-noc button.small, body.portal-noc .btn.small, body.portal-noc button.small { font-size: 12.5px; }
body.staff-noc table, body.portal-noc table { font-size: 14px; }
body.staff-noc th, body.portal-noc th { font-size: 12px; }
body.staff-noc .responsive-table td::before { font-size: 12px; }
body.staff-noc .customer-meta { font-size: 12.5px; }
body.staff-noc .customer-balance .label { font-size: 10px; }
body.staff-noc .customer-balance .sub { font-size: 11.5px; }
body.staff-noc .customer-crumbs { font-size: 12px; }
body.staff-noc .customer-tabs button { font-size: 13.5px; }
body.staff-noc .fact .k { font-size: 10.5px; }
body.staff-noc .fact .v { font-size: 13px; }
body.staff-noc .info-row { font-size: 12.5px; }
body.staff-noc .timeline .event { font-size: 12px; }
body.staff-noc .timeline b { font-size: 12px; }
body.staff-noc .timeline small { font-size: 11px; }
body.staff-noc .service-line { font-size: 13px; }
body.staff-noc .service-fact > span, body.staff-noc .promise-summary span { font-size: 10.5px; }
body.staff-noc .service-fact > small { font-size: 12px; }
body.staff-noc .service-fact > b { font-size: 13.5px; }
body.staff-noc .topbar-title { font-size: 15.5px; }
body.staff-noc .top-search input { font-size: 14px; }
body.staff-noc .side-nav a { font-size: 14px; }
body.staff-noc .nav-group { font-size: 10.5px; }
body.staff-noc .brand-copy small { font-size: 10px; }
body.staff-noc .eyebrow, body.staff-noc .workspace-meta { font-size: 12px; }
body.staff-noc .power-card .power-row { font-size: 12.5px; }
body.staff-noc .power-card .power-note { font-size: 11.5px; }
body.staff-noc .power-alert-main .meta { font-size: 12px; }
body.staff-noc .recent-customer-main b { font-size: 13px; }
body.staff-noc .recent-customer-main small { font-size: 11.5px; }
body.staff-noc .recent-customer-balance { font-size: 12px; }
body.staff-noc .filter-field { font-size: 12px; }
body.staff-noc .topbar .hide-mobile { font-size: 13px; }

/* ЛК абонента: контраст и размер */
body.portal-noc { --muted: #b7c9de; }
body.portal-noc .portal-brand small { font-size: 11.5px; color: #b7c9de; }
body.portal-noc .portal-head .muted { color: #e0efff; font-size: 15px; }
body.portal-noc .portal-nav a { font-size: 14px; padding: 9px 13px; }
body.portal-noc .portal-nav { gap: 5px; }
body.portal-noc .card p { line-height: 1.55; }
body.portal-noc .portal-balance .small { color: #c2d6e8; }
body.portal-noc .login .muted, body.portal-noc .login label { color: #c2d6e8; }
@media (max-width: 820px) {
  body.staff-noc .side-nav a { font-size: 14px; }
  body.staff-noc .side-nav .nav-group { font-size: 10px; }
  body.portal-noc .portal-nav a { font-size: 13px; padding: 8px 10px; }
}

/* Смысловые цвета текста */
.text-accent { color: var(--accent) !important; }
.text-good { color: var(--good) !important; }
.text-bad { color: var(--bad) !important; }
.text-warn { color: var(--warn) !important; }
.text-info { color: var(--accent-2, var(--accent)) !important; }

/* Семантические KPI не должны терять цвет из-за темы */
body.staff-noc .kpi.text-good, body.staff-noc .kpi.money-pos { color: var(--good) !important; }
body.staff-noc .kpi.text-bad, body.staff-noc .kpi.money-neg { color: var(--bad) !important; }
body.staff-noc .kpi.text-warn { color: var(--warn) !important; }
body.staff-noc .kpi.text-accent { color: var(--accent) !important; }
html[data-theme="light"] body.staff-noc .kpi.text-good,
html[data-theme="light"] body.staff-noc .kpi.money-pos { color: var(--good) !important; }
html[data-theme="light"] body.staff-noc .kpi.text-bad,
html[data-theme="light"] body.staff-noc .kpi.money-neg { color: var(--bad) !important; }
html[data-theme="light"] body.staff-noc .kpi.text-warn { color: var(--warn) !important; }

/* Финальная типографическая шкала кабинета и ЛК */
body.staff-noc, body.portal-noc {
  line-height: 1.6;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.staff-noc h1, body.portal-noc h1,
body.staff-noc h2, body.portal-noc h2,
body.staff-noc h3, body.portal-noc h3 {
  font-weight: 750;
  line-height: 1.18;
  letter-spacing: -0.018em;
  text-wrap: balance;
}
body.staff-noc .card h2, body.portal-noc .card h2 { font-size: 1.15rem; margin-bottom: 10px; }
body.staff-noc .card h3, body.portal-noc .card h3 { font-size: 1.02rem; }
body.staff-noc .topbar-title { font-size: 16px; font-weight: 700; }
body.staff-noc .kpi, body.staff-noc .customer-balance .sum, body.staff-noc .money-pos, body.staff-noc .money-neg {
  font-variant-numeric: tabular-nums;
}
body.staff-noc .money-pos, body.staff-noc .money-neg { font-weight: 650; }
body.staff-noc input, body.staff-noc select, body.staff-noc textarea,
body.portal-noc input, body.portal-noc select, body.portal-noc textarea {
  font-size: 15px;
  line-height: 1.45;
}
body.staff-noc .btn, body.staff-noc button, body.portal-noc .btn, body.portal-noc button { font-size: 14px; }
body.staff-noc .btn.small, body.staff-noc button.small { font-size: 13px; }
body.staff-noc .fact .k { font-size: 11px; }
body.staff-noc .fact .v { font-size: 13.5px; }
body.staff-noc .power-card .power-source { font-size: 10.5px; }
body.staff-noc .power-card .power-note { font-size: 12px; }
body.staff-noc .workspace-eyebrow { font-size: 10.5px; }
body.staff-noc .customer-balance .label { font-size: 10.5px; }
body.staff-noc .customer-balance .sub { font-size: 12px; }
body.staff-noc .nav-group { font-size: 10.5px; }
body.staff-noc .brand-copy small { font-size: 10.5px; }
body.staff-noc .small { font-size: 13.5px; }
body.staff-noc .help { font-size: 13px; }
body.staff-noc .info-row, body.staff-noc .timeline .event { font-size: 12.5px; }
body.staff-noc .timeline small { font-size: 11.5px; }
body.staff-noc .roadmap-copy small { font-size: 12px; }
body.portal-noc .portal-head h1 { font-size: 1.7rem; }
body.portal-noc .portal-nav a { font-size: 14px; font-weight: 700; }
body.portal-noc .portal-brand b { font-size: 20px; }
body.portal-noc .portal-head .muted { font-size: 15px; }
body.portal-noc .small { font-size: 13.5px; }
body.portal-noc .card h2 { font-size: 1.18rem; }
@media (max-width: 820px) {
  body.staff-noc h1, body.portal-noc h1 { font-size: 1.55rem; }
  body.staff-noc .btn, body.staff-noc button, body.portal-noc .btn, body.portal-noc button { font-size: 14px; }
}

/* Мобильная шапка и действия */
@media (max-width: 820px) {
  .app-main .topbar { height: 60px; padding: 9px 12px; gap: 8px; }
  .nav-toggle { width: 40px; height: 40px; min-height: 40px; flex: 0 0 40px; }
  .nav-toggle svg { width: 22px; height: 22px; fill: currentColor; stroke: none; }
  .topbar-title { font-size: 16px; }
  .top-actions { gap: 4px; }
}
@media (max-width: 520px) {
  .customer-balance .head-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .customer-balance .head-actions > .btn { width: 100%; }
  .customer-balance .head-actions > .btn.primary:first-child { grid-column: 1 / -1; }
  .customer-balance .head-actions > form { display: block; min-width: 0; }
  .customer-balance .head-actions > form .btn { width: 100%; }
  .customer-balance .head-actions details.action-menu { width: 100%; min-width: 0; }
  .customer-balance .head-actions details.action-menu > summary { width: 100%; }
  .customer-balance .head-actions details.action-menu .action-menu-panel { right: 0; min-width: 200px; }
}

/* KENI-BILL: финальная шкала читаемости и рабочие панели */
:root {
  --fs-body: 16px;
  --fs-small: 13.5px;
  --fs-label: 14px;
  --fs-h1: 28px;
  --fs-h2: 20px;
  --fs-h3: 17px;
  --fs-table: 14.5px;
  --fs-th: 12.5px;
  --fs-button: 15px;
  --fs-button-sm: 13px;
  --fs-input: 16px;
}
body.staff-noc, body.portal-noc { font-size: var(--fs-body); line-height: 1.55; }
body.staff-noc h1, body.portal-noc h1 { font-size: var(--fs-h1); line-height: 1.18; }
body.staff-noc h2, body.portal-noc h2 { font-size: var(--fs-h2); line-height: 1.22; }
body.staff-noc h3, body.portal-noc h3 { font-size: var(--fs-h3); line-height: 1.25; }
body.staff-noc .card h2, body.portal-noc .card h2 { font-size: var(--fs-h2); }
body.staff-noc .card h3, body.portal-noc .card h3 { font-size: var(--fs-h3); }
body.staff-noc .small, body.staff-noc .help, body.portal-noc .small, body.portal-noc .help { font-size: var(--fs-small); }
body.staff-noc label, body.portal-noc label { font-size: var(--fs-label); }
body.staff-noc table, body.portal-noc table { font-size: var(--fs-table); }
body.staff-noc th, body.portal-noc th { font-size: var(--fs-th); }
body.staff-noc input, body.staff-noc select, body.staff-noc textarea,
body.portal-noc input, body.portal-noc select, body.portal-noc textarea { font-size: var(--fs-input); }
body.staff-noc .btn, body.staff-noc button, body.portal-noc .btn, body.portal-noc button { font-size: var(--fs-button); }
body.staff-noc .btn.small, body.staff-noc button.small, body.portal-noc .btn.small, body.portal-noc button.small { font-size: var(--fs-button-sm); }
body.staff-noc .nav-group { font-size: 11px; }
body.staff-noc .fact .k { font-size: 12px; }
body.staff-noc .fact .v { font-size: 13.5px; }
body.staff-noc .customer-meta { font-size: 13px; }
body.staff-noc .customer-tabs button { font-size: 14px; }
body.staff-noc .power-card .power-source { font-size: 11.5px; }
body.staff-noc .power-card .power-note { font-size: 12px; }
body.staff-noc .timeline small { font-size: 12px; }
body.staff-noc .table-wrap { overflow-x: auto; }
body.staff-noc .table-wrap table { margin-bottom: 0; }
body.staff-noc .responsive-table td::before { font-size: 12px; }

.dash-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.dash-kpi { display: grid; gap: 4px; min-height: 132px; color: var(--text); text-decoration: none; transition: transform .15s, border-color .15s, box-shadow .15s; }
.dash-kpi:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.dash-kpi-label { color: var(--muted); font-size: 13px; font-weight: 650; }
.dash-kpi-value { font-size: 30px; line-height: 1.08; font-weight: 800; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.dash-kpi-note { color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.dash-status-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.dash-status { display: grid; gap: 3px; min-height: 96px; color: var(--text); text-decoration: none; }
.dash-status:hover { text-decoration: none; border-color: var(--accent); }
.dash-status > span { color: var(--muted); font-size: 12.5px; }
.dash-status > strong { font-size: 22px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.dash-status > small { color: var(--muted); font-size: 11.5px; }
.customer-filters { align-items: stretch; }
.customer-filters .filter-search { flex: 1 1 320px; }
.customer-filters .filter-search input { min-width: 0; }
.customer-filters select { min-width: 145px; }
.filter-row .filter-search { position: relative; display: flex; align-items: center; }
.filter-row .filter-search input { width: 100%; padding-left: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.service-summary + .service-summary { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.finance-kpis .card { min-height: 122px; }
.notice { display: grid; gap: 2px; margin: 10px 0; padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-2); }
.notice b { font-size: 13.5px; }
.notice span { color: var(--muted); font-size: 12.5px; }
.notice-info { border-color: color-mix(in srgb, var(--accent) 25%, var(--line)); background: var(--accent-soft); }
@media (max-width: 1100px) {
  .dash-kpis, .dash-status-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .dash-kpis, .dash-status-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-kpi { min-height: 118px; padding: 12px; }
  .dash-kpi-value { font-size: 24px; }
  .dash-kpi-note { font-size: 11.5px; }
  .dash-status { min-height: 88px; padding: 12px; }
  .dash-status > strong { font-size: 19px; }
  .customer-filters .filter-search, .customer-filters select, .customer-filters button, .customer-filters .btn { flex: 1 1 100%; width: 100%; }
  .customer-filters .filter-search { min-width: 0; }
  .finance-kpis .card { min-height: 0; }
  body.staff-noc h1, body.portal-noc h1 { font-size: 24px; }
  body.staff-noc .nav-group { font-size: 10.5px; }
}
@media (max-width: 380px) {
  .dash-kpis, .dash-status-row { grid-template-columns: 1fr; }
}

.column-settings { position: relative; margin: 0; border: 0; padding: 0; }
.column-settings > summary { list-style: none; }
.column-settings > summary::-webkit-details-marker { display: none; }
.column-settings-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 205px;
  display: none; gap: 4px; padding: 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); box-shadow: var(--shadow);
}
.column-settings[open] .column-settings-panel { display: grid; }
.column-settings-panel label { display: flex; align-items: center; gap: 7px; margin: 0; color: var(--text); font-size: 13px; font-weight: 500; }
.column-settings-panel input { width: 16px; height: 16px; min-height: 0; accent-color: var(--accent); }
@media (max-width: 620px) {
  .column-settings { flex: 0 0 auto; }
  .column-settings-panel { right: auto; left: 0; }
}
[data-col][hidden] { display: none !important; }

.customer-filters select { width: auto; min-width: 145px; max-width: 220px; flex: 0 1 190px; }
.customer-filters .filter-search { flex: 1 1 360px; min-width: 240px; }
.customer-filters > button, .customer-filters > .btn { flex: 0 0 auto; }
.two-col .recent-customers-grid { grid-template-columns: 1fr; }
@media (max-width: 620px) {
  .customer-filters select { width: 100%; max-width: none; flex: 1 1 100%; }
  .customer-filters .filter-search { width: 100%; min-width: 0; flex: 1 1 100%; }
}

/* Рабочий стол: широкий журнал действий не должен сжимать колонки */
.dashboard-bottom { grid-template-columns: minmax(0, 1fr); align-items: stretch; }
.dashboard-bottom .card { min-width: 0; }
.dashboard-bottom .data-table { table-layout: auto; }
.dashboard-bottom .data-table td:nth-child(1),
.dashboard-bottom .data-table td:nth-child(2) { white-space: nowrap; }
.dashboard-bottom .data-table td:nth-child(3),
.dashboard-bottom .data-table td:nth-child(4) { overflow-wrap: anywhere; }
@media (max-width: 1100px) {
  .dashboard-bottom { grid-template-columns: minmax(0, 1fr); }
}
.dashboard-bottom table { table-layout: auto; }

/* Читаемость подписей и доступность кнопок */
body.staff-noc .filter-field { font-size: 13.5px; }
body.staff-noc .top-search input { font-size: 15px; }
@media (max-width: 820px) {
  body.staff-noc .btn.small,
  body.staff-noc button.small { min-height: 40px; padding: 7px 10px; }
  body.staff-noc .icon-btn { min-width: 44px; min-height: 44px; }
  body.staff-noc .top-user summary { min-height: 44px; }
}

@media (max-width: 820px) {
  body.staff-noc .btn, body.staff-noc button { min-height: 44px; }
  body.staff-noc .btn.small, body.staff-noc button.small { min-height: 44px; }
}

.simple-filters { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 12px; }
.simple-filters .filter-chip { text-decoration: none; display: inline-flex; align-items: center; }
.simple-filters .filter-chip:hover { text-decoration: none; border-color: var(--accent); }
.simple-search { margin-bottom: 16px; flex-wrap: nowrap; }
.simple-search input { flex: 1 1 auto; min-width: 0; }
.simple-search button { flex: 0 0 auto; }
@media (max-width: 820px) {
  .simple-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .simple-filters .filter-chip { justify-content: center; min-height: 44px; }
  .simple-search { flex-wrap: wrap; }
  .simple-search input, .simple-search button, .simple-search .btn { flex: 1 1 100%; width: 100%; }
}
.dash-kpis-six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) {
  .dash-kpis-six { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .dash-kpis-six { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 380px) {
  .dash-kpis-six { grid-template-columns: 1fr; }
}
.simple-filters .filter-chip {
  padding: 6px 11px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); color: var(--muted); font-size: 13px; font-weight: 650;
}
.simple-filters .filter-chip.is-active {
  background: var(--accent-soft); color: var(--accent-strong);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}
@media (max-width: 820px) {
  .simple-filters .filter-chip { min-height: 44px; justify-content: center; }
}

.dash-network-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .55fr); gap: 14px; }
.dash-sites { display: grid; gap: 12px; }
.dash-site { display: grid; gap: 6px; }
.dash-site-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dash-site-head > span { color: var(--muted); font-size: 12px; }
.dash-network-side { display: grid; gap: 12px; align-content: start; }
.network-side-block { display: grid; gap: 7px; }
.network-side-block h3 { margin: 0; font-size: 14px; }
.network-alert-row { display: flex; align-items: flex-start; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.network-alert-row:last-child { border-bottom: 0; }
.network-alert-row > span:last-child { display: grid; gap: 1px; min-width: 0; }
.network-alert-row small { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.ubnt-placeholder { margin-top: 4px; padding: 11px; border: 1px dashed var(--line-strong); border-radius: 10px; background: var(--panel-2); }
.ubnt-placeholder p { margin: 4px 0 8px; }
.ubnt-slots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.ubnt-slots span { padding: 5px; border: 1px solid var(--line); border-radius: 6px; text-align: center; color: var(--muted); font-size: 10.5px; }
.network-chain { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 10px 0; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.network-node { padding: 4px 7px; border-radius: 6px; background: var(--panel); border: 1px solid var(--line); font-size: 12px; }
.network-node.good { border-color: color-mix(in srgb, var(--good) 35%, var(--line)); color: var(--good); }
.network-node.muted-node { color: var(--muted); }
.network-arrow { color: var(--muted); font-size: 13px; }
@media (max-width: 1100px) { .dash-network-grid { grid-template-columns: 1fr; } }
@media (max-width: 620px) {
  .ubnt-slots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .network-chain { gap: 4px; }
}
.dash-network-grid { align-items: start; }
.dash-sites, .dash-site { align-content: start; }
.dash-network-grid { grid-template-columns: 1fr; }
.dash-sites { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dash-network-side { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
.dash-network-side .ubnt-placeholder { margin-top: 0; }
@media (max-width: 1100px) {
  .dash-network-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .dash-sites, .dash-network-side { grid-template-columns: 1fr; }
}
.network-map-card .panel-title { align-items: center; }
.network-map-legend { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; color: var(--muted); font-size: 11.5px; }
.network-map-legend .site-dot { margin-left: 5px; }
.network-map-board { display: grid; gap: 8px; margin-top: 12px; }
.network-site-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel-2); }
.network-site-label { display: grid; align-content: center; gap: 2px; min-width: 0; }
.network-site-label b { font-size: 14px; }
.network-site-label small { color: var(--muted); font-size: 11.5px; }
.network-site-routers { display: flex; flex-wrap: wrap; gap: 7px; align-items: stretch; }
.network-router-node, .network-ubnt-node { display: flex; align-items: center; gap: 8px; min-width: 185px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); color: var(--text); text-decoration: none; }
.network-router-node { flex: 1 1 210px; }
.network-router-node:hover { border-color: var(--accent); text-decoration: none; }
.network-router-node > span:nth-child(2), .network-ubnt-node > span:nth-child(2) { display: grid; gap: 1px; min-width: 0; flex: 1; }
.network-router-node b, .network-ubnt-node b { font-size: 12.5px; }
.network-router-node small, .network-ubnt-node small { color: var(--muted); font-size: 10.5px; }
.network-router-node.is-offline { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.network-ubnt-node { flex: 0 1 220px; border-style: dashed; color: var(--muted); }
.network-ubnt-mark { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--bg-soft); color: var(--muted); font-size: 17px; font-weight: 700; }
.network-map-footer { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); gap: 18px; margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.network-map-footer > div { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; min-width: 0; }
.network-map-footer b { color: var(--text); font-size: 12.5px; }
.network-footer-item { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); text-decoration: none; }
.network-footer-item:hover { color: var(--accent); text-decoration: none; }
@media (max-width: 820px) {
  .network-map-legend { display: none; }
  .network-site-row { grid-template-columns: 1fr; gap: 7px; }
  .network-site-label { grid-auto-flow: column; justify-content: start; align-items: center; gap: 8px; }
  .network-router-node, .network-ubnt-node { flex: 1 1 100%; min-height: 44px; }
  .network-map-footer { grid-template-columns: 1fr; gap: 9px; }
}

/* Рабочий стол: оперативная сводка */
.ops-summary { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); padding: 0; overflow: hidden; }
.ops-metric { display: grid; gap: 2px; padding: 15px 16px; border-right: 1px solid var(--line); color: var(--text); text-decoration: none; min-width: 0; }
.ops-metric:last-child { border-right: 0; }
.ops-metric:hover { background: var(--panel-soft); text-decoration: none; }
.ops-metric strong { font-size: 23px; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.ops-metric > span { color: var(--muted); font-size: 12.5px; }
.ops-metric small { color: var(--muted); font-size: 11px; }
.ops-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px; margin-top: 14px; align-items: start; }
.ops-list { display: grid; gap: 0; }
.ops-row { display: flex; align-items: flex-start; gap: 9px; padding: 8px 0; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: 12.5px; min-width: 0; }
.ops-row:last-child { border-bottom: 0; }
.ops-row:hover { color: var(--accent); text-decoration: none; }
.ops-row > span:nth-child(2), .ops-row > span:last-child:not(.badge) { display: grid; gap: 1px; min-width: 0; flex: 1; }
.ops-row b { font-size: 12.5px; font-weight: 650; overflow-wrap: anywhere; }
.ops-row small { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.ops-row > strong { margin-left: auto; white-space: nowrap; font-size: 12.5px; }
.ops-calm { display: flex; align-items: center; gap: 8px; padding: 12px 0; color: var(--muted); }
.ops-calm b { color: var(--text); font-size: 13px; }
.ops-calm small { font-size: 11.5px; }
.ops-money-totals { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.ops-money-totals > div { display: grid; gap: 2px; padding: 8px; border-radius: 8px; background: var(--panel-soft); }
.ops-money-totals span { color: var(--muted); font-size: 11px; }
.ops-money-totals b { font-size: 14px; font-variant-numeric: tabular-nums; }
.ops-events .ops-row { align-items: flex-start; }
@media (max-width: 1100px) {
  .ops-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ops-metric:nth-child(3n) { border-right: 0; }
  .ops-metric:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .ops-grid { grid-template-columns: 1fr 1fr; }
  .ops-events { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  .ops-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ops-metric:nth-child(2n) { border-right: 0; }
  .ops-metric:nth-child(3n) { border-right: 1px solid var(--line); }
  .ops-metric:nth-child(-n+4) { border-bottom: 1px solid var(--line); }
  .ops-grid { grid-template-columns: 1fr; }
  .ops-events { grid-column: auto; }
}

/* KENI-BILL mobile containment and readable cards */
html, body { max-width: 100%; overflow-x: hidden; }
*, *::before, *::after { box-sizing: border-box; }
img, video, canvas { max-width: 100%; height: auto; }
svg { max-width: 100%; }
.wrap, .app-main, .card, .portal-shell, .workspace, .login { min-width: 0; max-width: 100%; }
.table-wrap, .tablescroll { max-width: 100%; }
dialog.modal, dialog.form-dialog { width: min(720px, calc(100vw - 24px)); max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); margin: auto; }
.form-dialog .modal-card { width: 100%; max-width: 100%; }
.modal-card, .form-dialog .modal-card { min-width: 0; }
@media (max-width: 820px) {
  .wrap { padding-left: 12px; padding-right: 12px; }
  .card { padding: 12px; }
  .card table { min-width: 0 !important; }
  .card table th, .card table td { padding: 8px 7px; }
  .page-head, .card-head { gap: 8px; }
  .page-head h1 { font-size: 1.35rem; line-height: 1.15; overflow-wrap: anywhere; }
  .card h2, .panel-title h2 { font-size: 1.05rem; line-height: 1.2; }
  .btn, button { white-space: normal; text-align: center; max-width: 100%; }
  .row, .page-actions, .card-head, .modal-actions { min-width: 0; }
  dialog.modal, dialog.form-dialog { width: calc(100vw - 16px); max-width: calc(100vw - 16px); }
  .form-dialog .modal-card { min-height: 100dvh; max-height: 100dvh; padding: 14px 12px 82px; }
  .portal-topbar { gap: 8px; }
  .portal-brand img { width: 38px; height: 38px; }
  .portal-brand b { font-size: 17px; }
  .portal-brand small { font-size: 9px; }
  .portal-head h1 { font-size: 1.35rem; }
  .portal-nav { gap: 2px; padding: 4px; }
  .portal-nav a { padding: 9px 8px; font-size: 12px; }
  .blocked-card { width: 100%; max-width: 100%; padding: 18px 14px; }
  .blocked-meta { grid-template-columns: 1fr; }
  .finance-kpis, .stat-grid { grid-template-columns: 1fr; }
  .fact-grid, .customer-facts { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 430px) {
  .wrap { padding-left: 8px; padding-right: 8px; }
  .card { padding: 10px; border-radius: 12px; }
  .auth-brand { gap: 8px; }
  .auth-brand img { width: 38px; height: 38px; }
  .auth-brand b { font-size: 17px; }
  .auth-brand small { font-size: 9px; }
  .fact-grid, .customer-facts { grid-template-columns: 1fr; }
  .kpi { font-size: 1.35rem; }
}
