:root {
    --bg: #070b14;
    --bg-soft: #0d1320;
    --panel: rgba(15, 22, 36, 0.94);
    --panel-2: rgba(18, 27, 44, 0.96);
    --line: rgba(255, 255, 255, 0.08);

    --text: #eef3fb;
    --text-soft: #aeb9cc;
    --text-dim: #7d8aa2;

    --accent: #ff3f78;
    --accent-2: #e62f66;
    --success: #49d17d;
    --danger: #ff5b6f;

    --radius: 18px;
    --radius-sm: 12px;
}

/* =========================================================
   Base
========================================================= */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Arial, sans-serif;
    background:
        radial-gradient(circle at 15% 10%, rgba(255, 63, 120, 0.10), transparent 30%),
        radial-gradient(circle at 85% 85%, rgba(53, 113, 255, 0.08), transparent 30%),
        var(--bg);
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

/* =========================================================
   Auth
========================================================= */

.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-shell {
    width: 100%;
    max-width: 460px;
}

.auth-card {
    padding: 34px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(18, 27, 44, 0.98), rgba(10, 15, 25, 0.98));
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.38);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
}

.auth-brand__mark,
.sidebar__mark {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--accent), #a31556);
    font-size: 28px;
    font-weight: 800;
    box-shadow: 0 16px 30px rgba(255, 63, 120, 0.22);
}

.auth-brand__title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.auth-brand__subtitle {
    margin-top: 4px;
    color: var(--text-soft);
    font-size: 14px;
    line-height: 1.4;
}

.auth-form {
    display: grid;
    gap: 16px;
}

.field {
    display: grid;
    gap: 8px;
}

.field span {
    color: var(--text-soft);
    font-size: 14px;
}

.field input {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.045);
    color: var(--text);
    font-size: 16px;
    outline: none;
    transition: 0.2s ease;
}

.field input:focus {
    border-color: rgba(255, 63, 120, 0.65);
    box-shadow: 0 0 0 4px rgba(255, 63, 120, 0.12);
}

/* =========================================================
   Buttons
========================================================= */

.btn {
    height: 50px;
    border: 0;
    border-radius: 14px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    transition: 0.2s ease;
}

.btn--primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    box-shadow: 0 16px 34px rgba(255, 63, 120, 0.22);
}

.btn--primary:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.btn--full {
    width: 100%;
    margin-top: 6px;
}

/* =========================================================
   Notices
========================================================= */

.notice {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
}

.notice--error {
    border: 1px solid rgba(255, 91, 111, 0.35);
    background: rgba(255, 91, 111, 0.12);
    color: #ffdbe0;
}

.notice--success {
    border: 1px solid rgba(73, 209, 125, 0.35);
    background: rgba(73, 209, 125, 0.12);
    color: #dfffe9;
}

code {
    padding: 2px 6px;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.08);
}

/* =========================================================
   Admin Layout
========================================================= */

.admin-body {
    min-height: 100vh;
}

.layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 250px 1fr;
}

.sidebar {
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
    border-right: 1px solid var(--line);
    background: rgba(8, 12, 20, 0.82);
    backdrop-filter: blur(14px);
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 4px 6px 26px;
    border-bottom: 1px solid var(--line);
}

.sidebar__mark {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    font-size: 24px;
}

.sidebar__title {
    font-size: 20px;
    font-weight: 700;
}

.sidebar__subtitle {
    color: var(--text-dim);
    font-size: 13px;
}

.sidebar__nav {
    display: grid;
    gap: 8px;
    padding-top: 22px;
}

.nav-item {
    display: block;
    min-height: 44px;
    padding: 12px 14px;
    border-radius: 12px;
    color: var(--text-soft);
    transition: 0.18s ease;
}

.nav-item:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item--active {
    color: #fff;
    background: rgba(255, 63, 120, 0.16);
    border: 1px solid rgba(255, 63, 120, 0.20);
}

.nav-item--disabled {
    opacity: 0.55;
    cursor: default;
}

.nav-item--disabled:hover {
    background: transparent;
    color: var(--text-soft);
}

.sidebar__footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.sidebar__user {
    color: var(--text-soft);
    font-size: 14px;
    margin-bottom: 10px;
}

.sidebar__logout {
    color: #ffdbe0;
    font-size: 14px;
}

.content {
    padding: 34px 38px;
}

.topbar h1 {
    margin: 0 0 8px;
    font-size: 32px;
    line-height: 1.15;
    letter-spacing: -0.03em;
}

.topbar p {
    margin: 0;
    color: var(--text-soft);
    font-size: 16px;
}

.panel {
    margin-top: 30px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.24);
}

.panel--compact {
    max-width: 760px;
    padding: 24px;
}

.panel__title {
    margin-bottom: 18px;
    font-size: 18px;
    font-weight: 700;
}

.status-list {
    display: grid;
}

.status-row {
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-top: 1px solid var(--line);
}

.status-row:first-child {
    border-top: 0;
}

.status-row span {
    color: var(--text-soft);
}

.status-row strong {
    color: var(--success);
    font-weight: 700;
}

/* =========================================================
   Responsive
========================================================= */

@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        min-height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .sidebar__footer {
        margin-top: 18px;
    }

    .content {
        padding: 24px 18px;
    }

    .topbar h1 {
        font-size: 26px;
    }
}

/* =========================================================
   Clients page
========================================================= */

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 22px;
    margin-bottom: 26px;
}

.page-head h1 {
    margin: 0 0 8px;
    font-size: 32px;
    line-height: 1.15;
    letter-spacing: -0.03em;
}

.page-head p {
    margin: 0;
    color: var(--text-soft);
    font-size: 16px;
}

.btn--auto {
    width: auto;
    min-width: 0;
    padding: 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn--ghost {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

.btn--ghost:hover {
    background: rgba(255, 255, 255, 0.08);
}

.stats-line {
    display: grid;
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.stats-line--dashboard {
    margin-top: 28px;
}

.stat-mini {
    min-height: 82px;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(15, 22, 36, 0.88);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
}

.stat-mini span {
    color: var(--text-soft);
    font-size: 13px;
}

.stat-mini strong {
    font-size: 28px;
    line-height: 1;
    letter-spacing: -0.03em;
}

.stat-mini--warn strong {
    color: #ffcc66;
}

.form-panel,
.table-panel {
    padding: 22px;
}

.form-panel {
    margin-bottom: 22px;
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.panel-head--table {
    margin-bottom: 16px;
}

.panel__subtitle {
    margin-top: 5px;
    color: var(--text-soft);
    font-size: 14px;
}

.link-muted {
    color: var(--text-soft);
    font-size: 14px;
}

.link-muted:hover {
    color: var(--text);
}

.client-form {
    display: grid;
    gap: 16px;
}

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

.field textarea {
    width: 100%;
    min-height: 92px;
    resize: vertical;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.045);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: 0.2s ease;
}

.field textarea:focus {
    border-color: rgba(255, 63, 120, 0.65);
    box-shadow: 0 0 0 4px rgba(255, 63, 120, 0.12);
}

.field--wide {
    grid-column: 1 / -1;
}

.field--toggle {
    align-content: start;
}

.switch-row {
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.045);
}

.switch-row input {
    width: 18px;
    height: 18px;
    margin: 0;
}

.switch-row label {
    color: var(--text);
    font-size: 15px;
}

.code-preview {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    gap: 14px;
    min-height: 52px;
    padding: 0 16px;
    border: 1px solid rgba(255, 63, 120, 0.22);
    border-radius: 14px;
    background: rgba(255, 63, 120, 0.10);
}

.code-preview span {
    color: var(--text-soft);
    font-size: 14px;
}

.code-preview strong {
    font-size: 22px;
    letter-spacing: 0.08em;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

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

.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1080px;
}

.admin-table th,
.admin-table td {
    padding: 15px 14px;
    border-top: 1px solid var(--line);
    vertical-align: top;
    text-align: left;
}

.admin-table thead th {
    padding-top: 8px;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 600;
    border-top: 0;
}

.admin-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.025);
}

.th-actions {
    width: 370px;
}

.cell-main {
    color: var(--text);
    font-weight: 600;
    line-height: 1.35;
}

.cell-sub {
    margin-top: 4px;
    color: var(--text-dim);
    font-size: 13px;
    line-height: 1.35;
}

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

.code-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 78px;
    height: 34px;
    padding: 0 10px;
    border-radius: 10px;
    background: rgba(255, 63, 120, 0.12);
    border: 1px solid rgba(255, 63, 120, 0.22);
    font-weight: 700;
    letter-spacing: 0.06em;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
}

.badge--success {
    color: #dfffe9;
    background: rgba(73, 209, 125, 0.14);
    border: 1px solid rgba(73, 209, 125, 0.28);
}

.badge--warning {
    color: #ffe7b5;
    background: rgba(255, 190, 64, 0.14);
    border: 1px solid rgba(255, 190, 64, 0.28);
}

.badge--danger {
    color: #ffdbe0;
    background: rgba(255, 91, 111, 0.14);
    border: 1px solid rgba(255, 91, 111, 0.28);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: flex-start;
}

.inline-form {
    display: inline;
    margin: 0;
}

.table-link {
    padding: 0;
    border: 0;
    background: transparent;
    color: #dbe7fb;
    font-size: 13px;
    cursor: pointer;
    line-height: 1.4;
}

.table-link:hover {
    color: #fff;
    text-decoration: underline;
}

.table-link--danger {
    color: #ff9aaa;
}

.empty-state {
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-soft);
    border-top: 1px solid var(--line);
    text-align: center;
    padding: 24px;
}

/* =========================================================
   Responsive clients
========================================================= */

@media (max-width: 1100px) {
    .stats-line {
        grid-template-columns: repeat(2, minmax(140px, 1fr));
    }

    .form-grid {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }
}

@media (max-width: 700px) {
    .page-head {
        flex-direction: column;
    }

    .stats-line {
        grid-template-columns: 1fr;
    }

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

    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .btn--auto {
        width: 100%;
    }
}

/* =========================================================
   IPTV Settings
========================================================= */

.form-grid--settings {
    grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr);
    max-width: 900px;
}

.settings-panel {
    max-width: 1100px;
}

.info-panel {
    max-width: 900px;
    padding: 22px;
}

.hint-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px 18px;
    border-radius: 14px;
    border: 1px solid rgba(73, 209, 125, 0.18);
    background: rgba(73, 209, 125, 0.08);
    color: var(--text-soft);
    line-height: 1.5;
}

.hint-box strong {
    color: var(--text);
    font-size: 14px;
}

.hint-box span {
    font-size: 14px;
}

@media (max-width: 900px) {
    .form-grid--settings {
        grid-template-columns: 1fr;
    }
}