:root {
    color-scheme: dark;
    --bg: #0f1110;
    --top: #181a18;
    --sidebar: #161918;
    --surface: #191c1b;
    --surface-2: #202321;
    --surface-3: #242826;
    --text: #f0f4f2;
    --muted: #98a39f;
    --faint: #6f7774;
    --line: #2a302d;
    --line-bright: #33413c;
    --primary: #21a875;
    --primary-2: #33c58e;
    --primary-dark: #16835a;
    --gold: #d6a821;
    --danger: #d55353;
    --danger-bg: #351c1d;
    --warning-bg: #2c2616;
    --warning-text: #efd17a;
    --shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}

html {
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 18% 0%, rgba(33, 168, 117, 0.12), transparent 28rem),
        linear-gradient(180deg, #111312 0%, var(--bg) 42%);
    color: var(--text);
    display: grid;
    grid-template-columns: 276px minmax(0, 1fr);
    grid-template-rows: 38px minmax(0, 1fr);
    font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

a {
    color: inherit;
}

.top-nav {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 38px;
    padding: 0 22px;
    background: rgba(24, 26, 24, 0.96);
    border-bottom: 1px solid #202420;
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(14px);
}

.brand {
    display: flex;
    gap: 11px;
    align-items: center;
    color: #d8dfdc;
    font-weight: 800;
    text-decoration: none;
}

.brand-mark {
    width: 32px;
    height: 24px;
    display: inline-block;
    background:
        linear-gradient(135deg, transparent 0 28%, var(--primary) 29% 100%);
    clip-path: polygon(0 100%, 18% 20%, 30% 58%, 48% 0, 58% 48%, 78% 13%, 100% 100%);
}

.top-links {
    display: flex;
    gap: 18px;
    align-items: center;
    color: #b6beb9;
    font-size: 14px;
}

.top-links a {
    text-decoration: none;
}

.top-links a:hover {
    color: #ffffff;
}

.live-dot {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--primary-2);
    font-weight: 700;
}

.live-dot::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-2);
    box-shadow: 0 0 0 5px rgba(33, 168, 117, 0.13);
}

.sidebar {
    grid-row: 2;
    background: linear-gradient(180deg, rgba(22, 25, 24, 0.96), rgba(18, 21, 20, 0.96));
    color: #f7fafb;
    padding: 16px 14px 24px 22px;
    border-right: 1px solid #202420;
}

.sidebar-cta {
    display: grid;
    gap: 8px;
    padding: 16px 18px;
    margin-bottom: 16px;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(33, 168, 117, 0.24), rgba(33, 168, 117, 0.08));
    border: 1px solid rgba(33, 168, 117, 0.28);
}

.sidebar-cta strong {
    font-size: 16px;
}

.sidebar-cta span {
    color: #aac4ba;
    font-size: 13px;
}

nav {
    display: grid;
    gap: 5px;
}

.nav-group {
    color: #737d79;
    font-size: 13px;
    font-weight: 700;
    margin: 18px 0 5px;
}

nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    padding: 9px 13px;
    color: #dce4e0;
    text-decoration: none;
    border-radius: 7px;
    border: 1px solid transparent;
}

nav a::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: #515a56;
    box-shadow: inset 0 0 0 2px #6b7470;
}

nav a.active,
nav a:hover {
    background: rgba(33, 168, 117, 0.13);
    border-color: rgba(33, 168, 117, 0.25);
    color: #ffffff;
}

nav a.active::before,
nav a:hover::before {
    background: var(--primary);
    box-shadow: 0 0 0 4px rgba(33, 168, 117, 0.12);
}

.content {
    grid-row: 2;
    padding: 18px 22px 36px;
    min-width: 0;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin: 8px 0 18px;
}

.eyebrow {
    margin: 0 0 2px;
    color: var(--primary-2);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: 30px;
    line-height: 1.1;
}

h2 {
    font-size: 18px;
    margin-bottom: 16px;
}

.warning,
.flash {
    padding: 11px 13px;
    border-radius: 8px;
}

.warning {
    background: var(--warning-bg);
    color: var(--warning-text);
    border: 1px solid rgba(214, 168, 33, 0.34);
}

.flash {
    margin-bottom: 18px;
    background: rgba(33, 168, 117, 0.12);
    color: #bff3d8;
    border: 1px solid rgba(33, 168, 117, 0.28);
}

.flash.error {
    background: var(--danger-bg);
    border-color: rgba(213, 83, 83, 0.35);
    color: #ffbdbd;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 14px;
    margin-bottom: 14px;
}

.metric,
.panel {
    background: linear-gradient(180deg, rgba(29, 32, 30, 0.98), rgba(23, 26, 25, 0.98));
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.metric {
    min-height: 112px;
    padding: 16px;
    position: relative;
    overflow: hidden;
}

.metric::after {
    content: "";
    position: absolute;
    inset: auto 14px 13px auto;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(33, 168, 117, 0.11);
    border: 1px solid rgba(33, 168, 117, 0.18);
}

.metric span {
    color: var(--muted);
    display: block;
    margin-bottom: 9px;
    font-weight: 700;
}

.metric strong {
    font-size: 32px;
    line-height: 1;
}

.panel {
    padding: 18px;
    margin-bottom: 14px;
    overflow-x: auto;
}

.panel:first-of-type {
    border-color: rgba(214, 168, 33, 0.46);
}

.panel.narrow {
    max-width: 820px;
}

.guide-panel {
    background: linear-gradient(180deg, rgba(29, 32, 30, 0.98), rgba(20, 23, 22, 0.98));
}

.panel-note {
    margin: 6px 0 0;
    color: var(--muted);
}

.panel-header,
.split {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
}

.panel-header {
    grid-template-columns: 1fr auto;
    align-items: center;
}

.wide-split {
    grid-template-columns: minmax(360px, 0.92fr) minmax(360px, 1.08fr);
}

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

.check-item,
.info-card {
    min-height: 112px;
    padding: 14px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid var(--line);
}

.check-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    color: inherit;
    text-decoration: none;
}

.check-item:hover {
    border-color: rgba(33, 168, 117, 0.36);
    background: rgba(33, 168, 117, 0.08);
}

.check-item.done {
    border-color: rgba(33, 168, 117, 0.36);
}

.check-icon {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(214, 168, 33, 0.14);
    color: var(--gold);
    border: 1px solid rgba(214, 168, 33, 0.28);
    font-weight: 900;
}

.check-item.done .check-icon {
    background: rgba(33, 168, 117, 0.18);
    color: #bff3d8;
    border-color: rgba(33, 168, 117, 0.38);
}

.check-item strong,
.info-card strong {
    display: block;
    margin-bottom: 6px;
}

.check-item small,
.info-card span,
.field-hint,
.test-box span,
.step p {
    color: var(--muted);
}

.info-card {
    display: grid;
    align-content: start;
}

.field-hint {
    font-size: 13px;
    font-weight: 500;
}

.steps {
    display: grid;
    gap: 12px;
}

.step {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    padding: 13px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid var(--line);
}

.step > span {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(33, 168, 117, 0.16);
    color: #bff3d8;
    border: 1px solid rgba(33, 168, 117, 0.32);
    font-weight: 900;
}

.step p {
    margin: 4px 0 0;
}

.test-box {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    margin-top: 16px;
    padding: 14px;
    border-radius: 8px;
    background: rgba(214, 168, 33, 0.08);
    border: 1px solid rgba(214, 168, 33, 0.25);
}

.test-box div {
    display: grid;
    gap: 4px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 13px 11px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

tbody tr {
    transition: background 0.16s ease, border-color 0.16s ease;
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.025);
}

th {
    font-size: 12px;
    color: #89948f;
    background: rgba(255, 255, 255, 0.03);
    text-transform: uppercase;
}

code {
    white-space: normal;
    word-break: break-all;
    color: #c8e6da;
}

.muted {
    color: var(--muted);
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 999px;
    background: #272d2a;
    color: #c4ccc8;
    font-size: 13px;
    border: 1px solid #343b38;
}

.status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #7f8984;
}

.status.active {
    background: rgba(33, 168, 117, 0.13);
    color: #bff3d8;
    border-color: rgba(33, 168, 117, 0.28);
}

.status.active::before {
    background: var(--primary-2);
}

.status.error,
.status.limited {
    background: rgba(213, 83, 83, 0.13);
    color: #ffbdbd;
    border-color: rgba(213, 83, 83, 0.28);
}

.status.error::before,
.status.limited::before {
    background: var(--danger);
}

.status.code_sent,
.status.password_required,
.status.pending {
    background: rgba(214, 168, 33, 0.12);
    color: #efd17a;
    border-color: rgba(214, 168, 33, 0.28);
}

.status.code_sent::before,
.status.password_required::before,
.status.pending::before {
    background: var(--gold);
}

form {
    margin: 0;
}

.stack {
    display: grid;
    gap: 14px;
}

.grid-form {
    display: grid;
    grid-template-columns: minmax(180px, 2fr) minmax(160px, 1.3fr) minmax(160px, 1fr) auto;
    gap: 14px;
    align-items: end;
}

.inline-edit,
.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.top-gap {
    margin-top: 8px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-weight: 700;
}

input,
select,
button {
    min-height: 40px;
    border-radius: 7px;
    border: 1px solid var(--line-bright);
    font: inherit;
}

input,
select {
    padding: 8px 11px;
    background: var(--surface-2);
    color: var(--text);
    outline: none;
}

input::placeholder {
    color: #747d79;
}

input:focus,
select:focus {
    border-color: rgba(33, 168, 117, 0.72);
    box-shadow: 0 0 0 3px rgba(33, 168, 117, 0.12);
}

button {
    padding: 8px 15px;
    background: linear-gradient(180deg, #2bab7d, #19845d);
    color: #ffffff;
    border-color: rgba(33, 168, 117, 0.68);
    cursor: pointer;
    font-weight: 800;
}

button:hover {
    background: linear-gradient(180deg, #38bd8d, #1c9368);
}

button.danger {
    background: linear-gradient(180deg, #cf5858, #983535);
    border-color: rgba(213, 83, 83, 0.72);
}

.message-cell,
.error-cell {
    max-width: 420px;
    white-space: pre-wrap;
    word-break: break-word;
}

.error-cell {
    color: #ffbdbd;
}

@media (max-width: 980px) {
    body {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto minmax(0, 1fr);
    }

    .top-nav {
        position: static;
        min-height: 54px;
    }

    .sidebar {
        grid-row: 2;
        border-right: 0;
        border-bottom: 1px solid #202420;
    }

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

    .nav-group {
        grid-column: 1 / -1;
    }

    .content {
        grid-row: 3;
        padding: 18px;
    }

    .metrics,
    .split,
    .wide-split,
    .grid-form,
    .panel-header,
    .checklist,
    .info-grid,
    .test-box {
        grid-template-columns: 1fr;
    }

    .topbar,
    .top-links {
        flex-wrap: wrap;
    }
}

/* Account keywords section */
.account-keywords-block {
    padding: 16px;
    margin-bottom: 14px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid var(--line);
}

.account-keywords-block h3 {
    margin: 0 0 12px;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 11px;
    border-radius: 7px;
    background: var(--surface-2);
    border: 1px solid var(--line-bright);
    cursor: pointer;
    color: var(--text);
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    min-height: unset;
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

.checkbox-label:hover {
    border-color: rgba(33, 168, 117, 0.4);
    background: rgba(33, 168, 117, 0.07);
}

.match-badge {
    margin-left: auto;
    font-size: 11px;
    color: var(--faint);
    font-weight: 600;
    text-transform: uppercase;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: #272d2a;
    color: #c4ccc8;
    border: 1px solid #343b38;
}

.badge-active {
    background: rgba(33, 168, 117, 0.13);
    color: #bff3d8;
    border-color: rgba(33, 168, 117, 0.28);
}

.badge-error, .badge-limited {
    background: rgba(213, 83, 83, 0.13);
    color: #ffbdbd;
    border-color: rgba(213, 83, 83, 0.28);
}

.mt-sm {
    margin-top: 4px;
}

textarea {
    padding: 8px 11px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--line-bright);
    border-radius: 7px;
    font: inherit;
    resize: vertical;
    outline: none;
    width: 100%;
}

textarea:focus {
    border-color: rgba(33, 168, 117, 0.72);
    box-shadow: 0 0 0 3px rgba(33, 168, 117, 0.12);
}

details summary {
    padding: 8px 0;
    user-select: none;
}

input[type="file"] {
    padding: 6px 8px;
    background: var(--surface-2);
    color: var(--muted);
    min-height: unset;
}

/* Load balancer */
.lb-page {
    display: grid;
    gap: 14px;
}

.lb-hero {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

.lb-hero h2 {
    margin-bottom: 6px;
}

.lb-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(140px, 1fr));
    gap: 14px;
}

.lb-stats .metric {
    margin: 0;
}

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

.lb-health-grid .info-card span {
    color: var(--text);
    font-size: 28px;
    font-weight: 800;
}

.lb-strategy-note {
    padding: 11px 13px;
    border-radius: 8px;
    background: rgba(33, 168, 117, 0.08);
    border: 1px solid rgba(33, 168, 117, 0.22);
    color: #ccefe0;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
}

.lb-table {
    min-width: 1120px;
}

.lb-table th {
    white-space: nowrap;
}

.lb-table td {
    color: #dce4e0;
}

.health-status.healthy {
    background: rgba(33, 168, 117, 0.13);
    color: #bff3d8;
    border-color: rgba(33, 168, 117, 0.28);
}

.health-status.warning {
    background: rgba(214, 168, 33, 0.12);
    color: #efd17a;
    border-color: rgba(214, 168, 33, 0.28);
}

.health-status.floodwait,
.health-status.limited,
.health-status.disconnected,
.health-status.banned,
.health-status.overloaded {
    background: rgba(213, 83, 83, 0.13);
    color: #ffbdbd;
    border-color: rgba(213, 83, 83, 0.28);
}

.health-healthy:hover {
    background: rgba(33, 168, 117, 0.05);
}

.health-warning {
    background: rgba(214, 168, 33, 0.05);
}

.health-floodwait,
.health-limited,
.health-disconnected,
.health-banned,
.health-overloaded {
    background: rgba(213, 83, 83, 0.045);
}

@media (max-width: 1180px) {
    .lb-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 680px) {
    .lb-hero {
        align-items: stretch;
        flex-direction: column;
    }

    .lb-stats,
    .lb-health-grid {
        grid-template-columns: 1fr;
    }
}

/* Broadcast detail — правая колонка не вылезает за экран */
.broadcast-detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 320px);
    gap: 14px;
    align-items: start;
    width: 100%;
}

.broadcast-detail-grid .panel {
    overflow: visible;
}

.broadcast-detail-sidebar {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

@media (max-width: 1100px) {
    .broadcast-detail-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 280px);
    }
}

@media (max-width: 860px) {
    .broadcast-detail-grid {
        grid-template-columns: 1fr;
    }
}
