:root {
  color-scheme: dark;
  --ink: #f5f2ea;
  --muted: #9ea7ad;
  --faint: #69737b;
  --bg: #0d1113;
  --surface: #14191c;
  --surface-2: #1a2024;
  --surface-3: #20272b;
  --line: rgba(255, 255, 255, 0.09);
  --green: #77e4b3;
  --green-deep: #173a2e;
  --amber: #efc476;
  --red: #ff8e82;
  --blue: #8ebcf5;
  --body-glow-green: rgba(65, 135, 108, 0.11);
  --body-glow-blue: rgba(101, 121, 159, 0.08);
  --login-card: linear-gradient(145deg, rgba(27, 34, 37, 0.98), rgba(17, 22, 24, 0.98));
  --field: #101518;
  --sidebar: rgba(14, 18, 20, 0.8);
  --accent-card: linear-gradient(135deg, #153126, #17221e);
  --panel: rgba(20, 25, 28, 0.92);
  --table-ink: #dfe3e1;
  --row-hover: rgba(255, 255, 255, 0.018);
  --overlay: rgba(3, 7, 8, 0.65);
  --drawer: #111618;
  --drawer-head: rgba(17, 22, 24, 0.94);
  --modal: #171d20;
  --preview: #101517;
  --toast: #20272b;
  --primary-ink: #0d1713;
  --danger-ink: #23100d;
  --focus: rgba(119, 228, 179, 0.58);
  --focus-ring: rgba(119, 228, 179, 0.1);
  --green-soft: rgba(51, 137, 100, 0.16);
  --green-line: rgba(119, 228, 179, 0.23);
  --amber-soft: rgba(145, 103, 41, 0.17);
  --red-soft: rgba(169, 63, 52, 0.15);
  --danger-line: rgba(255, 142, 130, 0.23);
  --code-line: rgba(255, 255, 255, 0.16);
  --noise-opacity: 0.025;
  --radius: 18px;
  --shadow: 0 26px 80px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --ink: #16231d;
  --muted: #576a61;
  --faint: #718279;
  --bg: #e7eee8;
  --surface: #f3f7f2;
  --surface-2: #edf3ed;
  --surface-3: #dfe9e1;
  --line: rgba(24, 68, 48, 0.13);
  --green: #197552;
  --green-deep: #d5e9dc;
  --amber: #9a651c;
  --red: #b9493f;
  --blue: #376ca1;
  --body-glow-green: rgba(74, 145, 104, 0.16);
  --body-glow-blue: rgba(105, 134, 164, 0.1);
  --login-card: linear-gradient(145deg, rgba(247, 250, 246, 0.98), rgba(233, 241, 234, 0.98));
  --field: #f8faf7;
  --sidebar: rgba(232, 240, 233, 0.86);
  --accent-card: linear-gradient(135deg, #d5eadc, #e4efe7);
  --panel: rgba(243, 247, 242, 0.94);
  --table-ink: #26372f;
  --row-hover: rgba(27, 102, 69, 0.045);
  --overlay: rgba(33, 50, 42, 0.36);
  --drawer: #eef4ef;
  --drawer-head: rgba(238, 244, 239, 0.95);
  --modal: #f2f7f2;
  --preview: #e7eee8;
  --toast: #e0ebe2;
  --primary-ink: #f4fff8;
  --danger-ink: #fff8f5;
  --focus: rgba(25, 117, 82, 0.55);
  --focus-ring: rgba(25, 117, 82, 0.12);
  --green-soft: rgba(25, 117, 82, 0.11);
  --green-line: rgba(25, 117, 82, 0.25);
  --amber-soft: rgba(154, 101, 28, 0.11);
  --red-soft: rgba(185, 73, 63, 0.1);
  --danger-line: rgba(185, 73, 63, 0.25);
  --code-line: rgba(24, 68, 48, 0.2);
  --noise-opacity: 0.018;
  --shadow: 0 26px 70px rgba(36, 60, 48, 0.14);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 92% 7%, var(--body-glow-green), transparent 27rem),
    radial-gradient(circle at 15% 88%, var(--body-glow-blue), transparent 30rem),
    var(--bg);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: color 180ms ease, background-color 180ms ease;
}

button, input, select { font: inherit; }

button { color: inherit; }

[hidden] { display: none !important; }

.system-toolbar, .system-node-head, .system-check, .system-issue { display:flex; justify-content:space-between; align-items:center; gap:16px; }
.system-toolbar { margin: 8px 0 22px; flex-wrap:wrap; }
.system-toolbar h2 { margin:0; font-size:24px; letter-spacing:-.025em; }
.system-actions { display:flex; gap:8px; flex-wrap:wrap; }
.system-note { color:var(--muted); font-size:12px; line-height:1.7; margin:10px 0; }
.system-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; margin-bottom:22px; }
.system-card { min-width:0; padding:20px; background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); }
.system-card-title { display:block; font-size:15px; font-weight:600; margin-bottom:12px; }
.system-badge { display:inline-flex; align-items:center; flex-shrink:0; padding:5px 9px; border-radius:8px; font-size:11px; font-weight:600; color:var(--muted); background:var(--surface-3); }
.system-healthy { color:var(--green); background:var(--green-soft); }
.system-warning, .system-stale { color:var(--amber); background:var(--amber-soft); }
.system-critical { color:var(--red); background:var(--red-soft); }
.system-panel { margin-bottom:20px; padding:22px; }
.system-panel .panel-head { padding:0 0 15px; flex-wrap:wrap; gap:12px; }
.system-node-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }
.system-node { padding:18px; border:1px solid var(--line); border-radius:12px; min-width:0; }
.system-node h3 { font-size:14px; margin:0; overflow-wrap:anywhere; }
.system-node-head { align-items:flex-start; }
.system-meter { display:block; color:var(--muted); font-size:12px; margin:12px 0; }
.system-meter progress { display:block; width:100%; height:5px; margin-top:7px; accent-color:var(--green); border:0; border-radius:5px; overflow:hidden; }
.system-meter progress::-webkit-progress-bar { background:var(--surface-3); }
.system-meter progress::-webkit-progress-value { background:var(--green); }
.system-columns { display:grid; grid-template-columns:1.1fr 1fr; gap:20px; }
.system-check { padding:12px 0; border-bottom:1px solid var(--line); align-items:flex-start; }
.system-check strong { display:block; font-size:12px; overflow-wrap:anywhere; }
.system-check small, .system-issue small { display:block; margin-top:5px; color:var(--muted); font-size:11px; }
.system-issue { padding:16px 0; border-top:1px solid var(--line); flex-wrap:wrap; }
.system-issue p { margin:5px 0; font-size:12px; }
.system-alert { border:1px solid var(--danger-line); color:var(--red); background:var(--red-soft); padding:14px; border-radius:12px; }
@media(max-width:1100px) { .system-columns { grid-template-columns:1fr; } .system-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media(max-width:650px) { .system-node-grid,.system-grid { grid-template-columns:1fr; } .system-panel { padding:16px; } .system-node-head { flex-wrap:wrap; } }

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: var(--noise-opacity);
  z-index: 20;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.6'/%3E%3C/svg%3E");
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 420px);
  padding: 38px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--login-card);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: -0.025em;
  font-size: 18px;
}

.login-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 46px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: block;
  object-fit: contain;
  flex: 0 0 auto;
  filter: drop-shadow(0 10px 20px rgba(45, 158, 143, 0.2));
}

.theme-toggle {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  font-size: 11px;
  font-weight: 550;
  white-space: nowrap;
  transition: transform 150ms ease, color 150ms ease, background 150ms ease;
}

.theme-toggle:hover { color: var(--ink); transform: translateY(-1px); }
.theme-toggle:focus-visible { outline: 3px solid var(--focus-ring); border-color: var(--focus); }
.theme-icon { width: 16px; font-size: 15px; line-height: 1; }

.eyebrow {
  margin: 0 0 7px;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 10px;
  font-weight: 600;
}

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-weight: 580; }

h1 {
  margin-bottom: 8px;
  font-size: clamp(25px, 2.6vw, 34px);
  letter-spacing: -0.038em;
}

h2 { letter-spacing: -0.035em; }

.login-copy {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  margin: 0 0 26px;
}

.login-form { display: grid; gap: 17px; }

label > span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

input, select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0 13px;
  color: var(--ink);
  background: var(--field);
  font-size: 13px;
  font-weight: 400;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input:focus, select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 0 16px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 560;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.button-wide { width: 100%; }
.button-primary { color: var(--primary-ink); background: var(--green); }
.button-secondary { border-color: var(--line); background: var(--surface-3); }
.button-ghost { border-color: var(--line); background: transparent; color: var(--muted); }
.button-danger { color: var(--danger-ink); background: var(--red); }

.form-error {
  min-height: 19px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 26px 20px 20px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  z-index: 2;
}

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

.nav-item {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  border: 0;
  border-radius: 11px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-size: 13px;
  font-weight: 450;
}

.nav-item.is-active { color: var(--ink); background: var(--surface-2); }
.nav-icon { color: var(--green); font-size: 17px; }
.soon { margin-left: auto; color: var(--faint); font-size: 10px; }
.sidebar-foot { margin-top: auto; display: grid; gap: 15px; }

.operator-chip { display: flex; align-items: center; gap: 10px; }
.operator-chip strong, .operator-chip small { display: block; }
.operator-chip strong { font-size: 12px; font-weight: 570; }
.operator-chip small { color: var(--faint); font-size: 11px; margin-top: 2px; }

.operator-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--green);
  background: var(--surface-2);
  font-size: 10px;
  font-weight: 650;
}

.workspace { min-width: 0; padding: 28px clamp(20px, 3.5vw, 48px) 52px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.topbar h1 { margin: 0; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.environment-pill {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  background: var(--surface);
  font-size: 11px;
}

.pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 5px var(--focus-ring);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-card {
  min-height: 104px;
  padding: 17px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
}

.summary-card span, .summary-card small { display: block; color: var(--muted); }
.summary-card span { font-size: 11px; }
.summary-card strong { display: block; margin: 6px 0 1px; font-size: 27px; font-weight: 560; letter-spacing: -0.04em; }
.summary-card small { font-size: 10px; }
.summary-accent { background: var(--accent-card); }

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.13);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 19px 20px 14px;
}

.panel-head h2 { margin: 0; font-size: 17px; font-weight: 570; }

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 178px 178px;
  gap: 8px;
  padding: 0 20px 15px;
}

.search-field input {
  padding-left: 42px;
  background-image: linear-gradient(45deg, transparent 48%, var(--faint) 48%, var(--faint) 55%, transparent 55%);
  background-size: 8px 8px;
  background-position: 19px 19px;
  background-repeat: no-repeat;
}

.table-wrap { position: relative; min-height: 270px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 860px; font-variant-numeric: tabular-nums; }
th, td { padding: 11px 12px; text-align: left; vertical-align: middle; border-top: 1px solid var(--line); }
th { color: var(--faint); font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; white-space: nowrap; }
td { color: var(--table-ink); font-size: 12px; line-height: 1.35; }
tbody tr { transition: background 120ms ease; }
tbody tr:hover { background: var(--row-hover); }

.id-cell { color: var(--faint); font-variant-numeric: tabular-nums; }
.telegram-owner-cell { min-width: 110px; max-width: 160px; }
.telegram-owner-name { display: block; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 450; color: var(--table-ink); }
a.telegram-owner-name { color: var(--green); text-decoration: none; }
a.telegram-owner-name:hover { text-decoration: underline; }
a.telegram-owner-name:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.telegram-owner-cell small { display: block; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; color: var(--faint); margin-top: 2px; }
.client-cell strong, .client-cell small { display: block; }
.client-cell strong { font-weight: 560; }
.client-cell small { color: var(--faint); margin-top: 2px; font-size: 10px; font-weight: 400; }
.date-primary { display: block; }
.purchase-date-cell { width: 1%; padding-inline: 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.purchase-date-cell { font-size: 11px; font-weight: 400; }
th.purchase-date-cell .sort-button { display: block; position: relative; padding-right: 13px; line-height: 1.45; text-align: left; }
th.purchase-date-cell .sort-button span { position: absolute; right: 0; top: 50%; transform: translateY(-50%); }
.date-secondary { display: block; color: var(--faint); font-size: 10px; margin-top: 2px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 7px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 560;
  background: var(--surface-3);
  color: var(--muted);
}

.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-active { color: var(--green); background: var(--green-soft); }
.badge-suspended, .badge-expired { color: var(--amber); background: var(--amber-soft); }
.badge-archived { color: var(--faint); }
.badge-failed { color: var(--red); background: var(--red-soft); }

.protocol-stack { white-space: nowrap; }
.protocol-stack .protocol-pill + .protocol-pill { margin-left: 5px; }
.protocol-pill { border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; color: var(--faint); font-size: 9px; white-space: nowrap; }
.protocol-pill.is-active { color: var(--green); border-color: var(--green-line); }
.protocol-pill::before { content: '•'; margin-right: 4px; }
.protocol-pill.is-active { background: var(--green-soft, rgba(91, 217, 173, .06)); }
.protocol-legend { margin: 0; padding: 0 20px 12px; color: var(--faint); font-size: 10px; line-height: 1.6; }
.network-cell { min-width: 128px; }
.network-badges { display: flex; align-items: center; gap: 5px; }
.provider-badge { display: inline-flex; align-items: center; vertical-align: middle; }
.provider-mark { display: inline-flex; align-items: center; justify-content: center; min-width: 27px; height: 23px; padding: 0 5px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 10px; font-weight: 500; letter-spacing: .02em; }
.provider-badge[data-provider="megafon"] .provider-mark, .provider-badge[data-provider="sbermobile"] .provider-mark { border-color: var(--green-line); color: var(--green); }
.provider-badge[data-provider="mts"] .provider-mark { color: #cf7d87; }
.provider-badge[data-provider="beeline"] .provider-mark, .provider-badge[data-provider="tmobile"] .provider-mark { color: #b7a769; }
.provider-badge[data-provider="yota"] .provider-mark { color: #72adb9; }
.network-more { font-size: 10px; color: var(--muted); }
.network-overview { margin: 0 0 16px; }
.network-overview > summary { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding: 15px 20px; cursor: pointer; color: var(--muted); font-size: 11px; }
.network-overview > summary > :first-child { color: var(--ink); }
.network-overview > summary > :last-child { margin-left: auto; color: var(--green); }
.network-detail { border-top: 1px solid var(--line); padding: 14px 20px; }
.network-totals { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 10px; }
.network-total { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.network-total strong { font-size: 12px; font-weight: 500; color: var(--ink); }
.network-detail a { color: var(--green); }
.row-button { min-height: 30px; padding: 0 10px; font-size: 11px; }

.empty-state, .loading-state {
  position: absolute;
  inset: 50px 0 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 7px;
  color: var(--muted);
  background: var(--surface);
}

.empty-state span { color: var(--faint); font-size: 12px; }
.spinner { width: 25px; height: 25px; border: 2px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.pagination {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 13px;
  padding: 11px 18px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 12px;
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--overlay);
  backdrop-filter: blur(5px);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 31;
  width: min(680px, 94vw);
  border-left: 1px solid var(--line);
  background: var(--drawer);
  box-shadow: -30px 0 90px rgba(0, 0, 0, 0.35);
  transform: translateX(102%);
  transition: transform 220ms ease;
  overflow-y: auto;
}

.drawer.is-open { transform: translateX(0); }
.drawer-head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: 24px; border-bottom: 1px solid var(--line); background: var(--drawer-head); backdrop-filter: blur(16px); }
.drawer-head h2 { margin: 0; font-size: 19px; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface-2); cursor: pointer; font-size: 24px; line-height: 1; }
.drawer-content { padding: 22px 24px 50px; }

.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.detail-item { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.detail-item span, .detail-item strong { display: block; }
.detail-item span { margin-bottom: 6px; color: var(--faint); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.detail-item strong { font-size: 12px; font-weight: 550; overflow-wrap: anywhere; }
.section-title { margin: 26px 0 11px; font-size: 14px; font-weight: 580; }
.action-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.action-control { display: grid; gap: 6px; align-content: start; }
.action-control select { min-height: 36px; font-size: 11px; }
.action-card { min-height: 72px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); cursor: pointer; text-align: left; }
.action-card strong, .action-card small { display: block; }
.action-card strong { font-size: 12px; font-weight: 560; }
.action-card small { margin-top: 5px; color: var(--faint); font-size: 11px; line-height: 1.35; }
.action-card.is-danger { border-color: var(--danger-line); }
.action-card:disabled { opacity: .42; cursor: not-allowed; }

.history-list { display: grid; gap: 8px; }
.history-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.history-item strong, .history-item small { display: block; }
.history-item strong { font-size: 12px; font-weight: 560; }
.history-item small { color: var(--faint); margin-top: 4px; font-size: 10px; }
.history-status { align-self: start; }

.modal-wrap { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 18px; }
.modal-backdrop { z-index: 0; }
.modal { position: relative; z-index: 1; width: min(100%, 520px); padding: 26px; border: 1px solid var(--line); border-radius: 20px; background: var(--modal); box-shadow: var(--shadow); }
.modal h2 { margin-bottom: 18px; font-size: 19px; }
.confirmation-preview { display: grid; gap: 8px; padding: 14px; border-radius: 12px; background: var(--preview); color: var(--muted); font-size: 13px; line-height: 1.5; }
.confirmation-preview ul { margin: 0; padding-left: 19px; }
.confirmation-label { display: block; margin-top: 18px; }
.confirmation-label code { display: block; margin: 7px 0 10px; padding: 9px 11px; border: 1px dashed var(--code-line); border-radius: 8px; color: var(--amber); background: var(--preview); user-select: all; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 15px; }

.toast-region { position: fixed; right: 22px; bottom: 22px; z-index: 70; display: grid; gap: 9px; width: min(380px, calc(100vw - 44px)); }
.toast { padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--toast); box-shadow: var(--shadow); animation: toast-in 180ms ease-out; }
.toast.is-error { border-color: rgba(255, 142, 130, 0.3); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

.noscript-warning {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  max-width: 360px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--danger-line);
  border-radius: 11px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.sort-button { display: inline-flex; align-items: center; gap: 7px; min-height: 32px; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; white-space: nowrap; }
.sort-button span { font-size: 12px; opacity: .55; }
.sort-button:hover, th[aria-sort="ascending"], th[aria-sort="descending"] { color: var(--green); }
.sort-button:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: 3px; }
.traffic-cell { white-space: nowrap; font-variant-numeric: tabular-nums; }
.traffic-overview { margin-bottom: 16px; box-shadow: none; }
.traffic-overview summary { display: flex; align-items: center; gap: 36px; padding: 17px 20px; cursor: pointer; list-style: none; }
.traffic-overview summary::-webkit-details-marker { display: none; }
.traffic-overview summary:focus-visible { outline: 2px solid var(--focus); border-radius: var(--radius); }
.traffic-label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.traffic-overview summary strong { font-size: 18px; font-weight: 550; font-variant-numeric: tabular-nums; letter-spacing: -.025em; }
.traffic-expand { margin-left: auto; color: var(--green); font-size: 12px; }
.traffic-detail { padding: 0 20px 16px; border-top: 1px solid var(--line); }
.traffic-nodes { display: grid; grid-template-columns: repeat(auto-fit,minmax(200px,1fr)); gap: 12px; padding-top: 16px; }
.traffic-node { display: grid; gap: 5px; padding: 13px 15px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; }
.traffic-node > span { font-size: 12px; color: var(--muted); }
.traffic-node strong { font-size: 19px; font-weight: 550; }
.traffic-node small, .traffic-note { color: var(--muted); font-size: 11px; line-height: 1.6; }
.traffic-note { margin: 12px 0 0; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar { padding: 24px 14px; }
  .sidebar .brand > span:last-child, .nav-item > :not(.nav-icon), .operator-chip > span:last-child, .sidebar .button { display: none; }
  .brand { justify-content: center; }
  .nav-item { justify-content: center; padding: 0; }
  .operator-chip { justify-content: center; }
  .filters { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .traffic-overview summary { flex-wrap: wrap; gap: 15px 24px; padding: 15px; }
  .traffic-expand { flex-basis: 100%; margin: 0; }
  .traffic-overview summary strong { font-size: 16px; }
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; flex-direction: row; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar { flex-wrap: wrap; gap: 16px; }
  .nav { display: flex; order: 3; width: 100%; gap: 8px; }
  .nav-item { flex: 1; gap: 8px; padding: 10px; }
  .sidebar-foot { margin: 0 0 0 auto; }
  .operator-chip { display: none; }
  .sidebar .button { display: block; width: auto; }
  .workspace { padding: 22px 14px 45px; }
  .summary-grid { grid-template-columns: 1fr; }
  .summary-card { min-height: 100px; }
  .filters { grid-template-columns: 1fr; padding-inline: 15px; }
  .search-field { grid-column: auto; }
  .panel-head { padding-inline: 15px; }
  .detail-grid, .action-grid { grid-template-columns: 1fr; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .button { width: 100%; }
  .login-card { padding: 30px 24px; }
  .topbar { align-items: flex-start; gap: 16px; }
  .topbar-actions { flex-direction: column; align-items: flex-end; }
  .theme-toggle { min-height: 36px; }
}

@media (max-width: 430px) {
  .login-brand-row { align-items: flex-start; }
  .login-brand-row .theme-toggle { padding-inline: 10px; }
  .topbar-actions .environment-pill { display: none; }
}

#partner-confirm-dialog {
  width: min(580px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  padding: 24px;
  color: var(--ink);
  background: var(--modal);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
#partner-confirm-dialog::backdrop { background: var(--overlay); backdrop-filter: blur(4px); }
#partner-confirm-dialog p { margin: 0; line-height: 1.6; }
#partner-detail { margin-top: 24px; }
#partner-detail h3 { margin-top: 28px; }
#partner-detail .table-scroll { overflow-x: auto; max-width: 100%; }
#partner-detail > .button { margin: 8px 8px 8px 0; }
#partner-create { grid-template-columns: 1fr 1fr auto; align-items: end; }
@media (max-width: 700px) {
  #partner-create, #partner-detail .filters { grid-template-columns: 1fr; }
}
.usage-source { margin: 10px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.usage-source strong { font-size: 12px; font-weight: 500; }
.usage-source p { margin: 5px 0; font-size: 12px; }
.usage-source small { display: block; margin-top: 4px; font-size: 10px; color: var(--muted); }

/* Compact client overview: keep every column visible on a laptop. */
.clients-table { table-layout: fixed; min-width: 0; }
.clients-table col:nth-child(1) { width: 10%; }
.clients-table col:nth-child(2) { width: 3%; }
.clients-table col:nth-child(3) { width: 9%; }
.clients-table col:nth-child(4), .clients-table col:nth-child(5) { width: 6.5%; }
.clients-table col:nth-child(6) { width: 9%; }
.clients-table col:nth-child(7), .clients-table col:nth-child(8), .clients-table col:nth-child(10) { width: 7%; }
.clients-table col:nth-child(9) { width: 10%; }
.clients-table col:nth-child(11) { width: 10%; }
.clients-table col:nth-child(12) { width: 8%; }
.clients-table col:nth-child(13) { width: 7%; }
.clients-table th, .clients-table td { padding: 6px 5px; min-width: 0; overflow-wrap: anywhere; }
.clients-table th { font-size: 8px; letter-spacing: .035em; white-space: normal; }
.clients-table td { font-size: 11px; font-weight: 400; }
.clients-table .sort-button { white-space: normal; line-height: 1.35; gap: 3px; text-align: left; }
.clients-table .sort-button span { font-size: 10px; }
.clients-table .telegram-owner-cell, .clients-table .network-cell { min-width: 0; max-width: none; }
.clients-table .telegram-owner-name, .clients-table .telegram-owner-cell small { max-width: 100%; }
.clients-table .date-secondary, .clients-table .client-cell small { font-size: 9px; }
.clients-table .traffic-cell .date-secondary { white-space: normal; }
.clients-table .purchase-date-cell { width: auto; white-space: nowrap; }
.clients-table .purchase-date-cell .sort-button { white-space: nowrap; padding-right: 0; letter-spacing: 0; }
.clients-table .purchase-date-cell .sort-button span { position: static; transform: none; }
.clients-table .badge { max-width: 100%; padding: 3px 4px; font-size: 9px; font-weight: 500; gap: 4px; }
.clients-table .badge::before { flex-shrink: 0; width: 4px; height: 4px; }
.clients-table .protocol-stack { white-space: normal; }
.clients-table .protocol-pill { display: inline-block; font-size: 8px; padding: 2px 3px; margin: 2px 2px 2px 0; }
.clients-table .protocol-pill + .protocol-pill { margin-left: 0; }
.clients-table .protocol-pill::before { display: none; }
.clients-table .row-button { padding: 0 5px; min-height: 28px; font-size: 10px; white-space: nowrap; }
.clients-table .order-cell .date-secondary { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clients-table .region-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.last-seen-cell { font-variant-numeric: tabular-nums; }
.last-seen-clock { display: block; margin-top: 2px; font-size: 10px; color: var(--muted); white-space: nowrap; }
.last-seen-clock.is-online { color: var(--green); }
th.last-seen-cell .sort-button { position: relative; display: block; padding-right: 9px; }
th.last-seen-cell .sort-button span { position: absolute; right: 0; top: 50%; transform: translateY(-50%); }
#clients-view .summary-grid { gap: 8px; margin-bottom: 10px; }
#clients-view .summary-card { min-height: 44px; padding: 6px 14px; display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 8px; }
#clients-view .summary-card strong { grid-column: 2; grid-row: 1 / 3; font-size: 24px; margin: 0; }
#clients-view .summary-card small { grid-column: 1; }
#clients-view .traffic-overview, #clients-view .network-overview { margin-bottom: 10px; }
#clients-view .traffic-overview > summary { padding: 6px 14px; gap: 25px; }
#clients-view .traffic-overview summary strong { font-size: 16px; }
#clients-view .traffic-label { margin-bottom: 1px; font-size: 10px; }
#clients-view .network-overview > summary { padding: 7px 14px; font-size: 10px; }
#clients-view .panel-head { padding: 8px 14px; }
#clients-view .panel-head .button { min-height: 32px; font-size: 12px; }
#clients-view .panel-head h2 { font-size: 15px; }
#clients-view .panel-head .eyebrow { font-size: 8px; margin-bottom: 3px; }
#clients-view .filters { padding: 0 14px 9px; grid-template-columns: minmax(140px, 1fr) 152px 152px; }
#clients-view .filters input, #clients-view .filters select { min-height: 34px; font-size: 12px; }
#clients-view .protocol-legend { padding: 0 14px 9px; font-size: 9px; }
#clients-view .pagination { padding: 8px 14px; }
#clients-view .pagination .button { min-height: 30px; font-size: 11px; }
#clients-view .table-wrap { min-height: 230px; }
@media (min-width: 1000px) {
  .app-shell { grid-template-columns: 172px minmax(0, 1fr); }
  .sidebar { padding: 22px 12px 16px; }
  .workspace { padding: 14px 18px 20px; }
  .topbar { margin-bottom: 10px; }
  .topbar .eyebrow { font-size: 9px; line-height: 1.2; margin-bottom: 3px; }
  .topbar h1 { font-size: 25px; line-height: 1.2; }
}
@media (min-width: 641px) and (max-width: 1399px) {
  .app-shell { grid-template-columns: 66px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .sidebar .brand > span:last-child, .nav-item > :not(.nav-icon), .operator-chip > span:last-child, .sidebar .button { display: none; }
  .brand, .nav-item, .operator-chip { justify-content: center; }
  .nav-item { padding-inline: 0; font-size: 0; }
}
@media (max-width: 999px) {
  .clients-table { min-width: 1000px; }
}
@media (max-width: 640px) {
  #clients-view .filters { grid-template-columns: 1fr; }
  #clients-view .summary-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  #clients-view .summary-card { display: block; padding: 10px; }
  #clients-view .summary-card span { font-size: 10px; }
}
/* Passive installation observations; do not widen the customer table. */
.device-count { display:inline; margin-left:3px; color:var(--accent); font-size:9px; font-weight:400; }
.clients-table .device-platform-label { display:block; font-size:10px; font-weight:400; line-height:1.4; }
.clients-table .device-platform-cell .date-secondary { font-size:9px; white-space:normal; }
#clients-view .device-summary { margin-bottom:0; padding-bottom:3px; }
#clients-view #protocol-legend { padding-bottom:3px; }
@media (max-width:1150px) {
  .clients-table .row-button { font-size:9px; padding-inline:3px; }
  .clients-table .device-count { font-size:8px; margin-left:1px; }
}
.device-statistics { margin-block:22px; }
.device-empty { font-size:13px; line-height:1.6; color:var(--muted); }
.device-observation strong,.device-observation small { overflow-wrap:anywhere; }
