:root {
    --bg: #07070b;
    --bg-soft: #0d0d14;
    --bg-card: #12121c;
    --bg-card-hover: #171724;
    --bg-input: #0a0a12;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);
    --text: #f5f5f7;
    --muted: #9ca0ad;
    --muted-2: #6f7584;
    --red: #e50914;
    --red-2: #ff3b4e;
    --red-soft: rgba(229, 9, 20, 0.14);
    --green: #22c55e;
    --green-soft: rgba(34, 197, 94, 0.14);
    --yellow: #f59e0b;
    --yellow-soft: rgba(245, 158, 11, 0.14);
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    --radius: 16px;
    --radius-sm: 12px;
    --sidebar-width: 280px;
}

* { box-sizing: border-box; }

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

body {
    font-family: Inter, system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

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

.admin-shell {
    min-height: 100vh;
    display: flex;
    background:
        radial-gradient(circle at top left, rgba(229, 9, 20, 0.12), transparent 28%),
        radial-gradient(circle at top right, rgba(99, 102, 241, 0.08), transparent 24%),
        var(--bg);
}

.sidebar {
    width: var(--sidebar-width);
    background: rgba(10, 10, 16, 0.92);
    border-right: 1px solid var(--border);
    backdrop-filter: blur(18px);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: linear-gradient(180deg, var(--red-2), var(--red));
    display: grid;
    place-items: center;
    box-shadow: 0 10px 30px rgba(229, 9, 20, 0.28);
}

.brand-mark svg {
    width: 22px;
    height: 22px;
    color: white;
}

.sidebar-brand strong {
    display: block;
    font-size: 1.02rem;
    font-weight: 700;
}

.sidebar-brand span {
    color: var(--muted);
    font-size: 0.82rem;
}

.sidebar-nav {
    padding: 18px 14px;
    flex: 1;
    overflow-y: auto;
}

.sidebar-section + .sidebar-section {
    margin-top: 18px;
}

.sidebar-section-title {
    display: block;
    padding: 0 12px 8px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted-2);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-weight: 500;
    transition: 0.2s ease;
    margin-bottom: 4px;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

.sidebar-link.is-active {
    background: var(--red-soft);
    color: white;
    border: 1px solid rgba(229, 9, 20, 0.22);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.sidebar-icon {
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.sidebar-icon svg {
    width: 18px;
    height: 18px;
}

.sidebar-footer {
    padding: 16px 14px 20px;
    border-top: 1px solid var(--border);
}

.sidebar-link.subtle {
    font-size: 0.92rem;
}

.danger-text { color: #ff8f96 !important; }

.admin-main {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 28px;
    border-bottom: 1px solid var(--border);
    background: rgba(7, 7, 11, 0.82);
    backdrop-filter: blur(16px);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-title h1 {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 700;
}

.topbar-title p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

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

.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    border: 1px solid transparent;
}

.badge-online {
    background: var(--green-soft);
    color: #86efac;
    border-color: rgba(34, 197, 94, 0.22);
}

.badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.18);
}

.topbar-user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px 8px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.02);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(180deg, var(--red-2), var(--red));
    font-weight: 700;
}

.topbar-user-card strong {
    display: block;
    font-size: 0.9rem;
}

.topbar-user-card span {
    color: var(--muted);
    font-size: 0.78rem;
}

.admin-content {
    padding: 28px;
    flex: 1;
}

.admin-footer {
    padding: 18px 28px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 0.86rem;
}

.stats-grid,
.content-grid {
    display: grid;
    gap: 20px;
}

.stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 24px;
}

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

.card,
.stat-card {
    background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: "";
    position: absolute;
    inset: auto -20px -20px auto;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: var(--red-soft);
}

.stat-label {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.stat-value {
    font-size: 2.2rem;
    font-weight: 800;
    margin-top: 8px;
}

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

.card-header {
    margin-bottom: 20px;
}

.card-header h2,
.card-header h3,
.form-section h3 {
    margin: 0 0 6px;
    font-size: 1.15rem;
    font-weight: 700;
}

.card-header p {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.form-grid,
.form-sections,
.form-section {
    display: grid;
    gap: 14px;
}

.form-grid.two-cols {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid .full,
.form-section .full {
    grid-column: 1 / -1;
}

label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 600;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    padding: 13px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg-input);
    color: var(--text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(229, 9, 20, 0.55);
    box-shadow: 0 0 0 4px rgba(229, 9, 20, 0.12);
}

textarea {
    min-height: 140px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9rem;
}

.btn,
button.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, var(--red-2), var(--red));
    color: white;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(229, 9, 20, 0.22);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(229, 9, 20, 0.28);
}

.btn-secondary {
    background: #242433;
    box-shadow: none;
}

.btn-danger,
.btn-small.btn-danger {
    background: #8b1530;
    box-shadow: none;
}

.btn-small {
    padding: 8px 12px;
    font-size: 0.84rem;
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

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

th {
    background: rgba(255, 255, 255, 0.02);
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.015);
}

code,
pre {
    background: #0b0b12;
    border: 1px solid var(--border);
    border-radius: 10px;
}

code {
    padding: 3px 8px;
    font-size: 0.86rem;
}

pre {
    padding: 16px;
    overflow: auto;
    font-size: 0.88rem;
}

.table-actions,
.card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.status-pill {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.status-pill.ok {
    background: var(--green-soft);
    color: #86efac;
}

.status-pill.off {
    background: rgba(120, 120, 120, 0.14);
    color: #d1d5db;
}

.status-pill.warn {
    background: var(--yellow-soft);
    color: #fcd34d;
}

.alert {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    border: 1px solid rgba(229, 9, 20, 0.28);
    background: var(--red-soft);
    color: #ffb4ba;
    font-weight: 500;
}

.alert.success,
.alert.ok {
    border-color: rgba(34, 197, 94, 0.28);
    background: var(--green-soft);
    color: #bbf7d0;
}

.alert.error {
    border-color: rgba(229, 9, 20, 0.28);
}

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

.method-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 18px;
    display: grid;
    gap: 6px;
    background: rgba(255,255,255,0.02);
}

.method-item.enabled {
    border-color: rgba(229, 9, 20, 0.28);
    background: var(--red-soft);
}

.method-item.disabled { opacity: 0.55; }

.preview-login {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    min-height: 220px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.preview-left {
    padding: 24px;
    background: linear-gradient(90deg, #2a0810, #12080d 55%, #050505);
}

.preview-right { background: #050505; }

.preview-tabs {
    display: flex;
    gap: 8px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.preview-tabs span {
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 0.82rem;
}

.api-block {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.checkbox-line {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    color: var(--text);
}

.inline-activate-form {
    display: grid;
    gap: 8px;
    min-width: 260px;
}

.icon-button,
.mobile-only { display: none; }

.sidebar-overlay { display: none; }

.auth-body {
    min-height: 100vh;
    background: var(--bg);
}

.auth-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
}

.auth-hero {
    position: relative;
    padding: 56px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background:
        radial-gradient(circle at 20% 20%, rgba(229, 9, 20, 0.22), transparent 30%),
        linear-gradient(135deg, #1a0508, #09090d 65%);
    overflow: hidden;
}

.auth-hero h1 {
    font-size: 3.2rem;
    margin: 0 0 14px;
    font-weight: 800;
}

.auth-hero p,
.auth-hero li {
    color: var(--muted);
    line-height: 1.7;
    max-width: 520px;
}

.auth-hero ul {
    padding-left: 18px;
    margin-top: 24px;
}

.auth-panel {
    display: grid;
    place-items: center;
    padding: 32px;
}

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

.auth-card h2 {
    margin: 0 0 8px;
    font-size: 1.6rem;
}

.auth-card p {
    color: var(--muted);
    margin-top: 0;
}

@media (max-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .content-grid,
    .form-grid.two-cols,
    .method-grid,
    .auth-layout,
    .preview-login { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar-overlay.is-visible {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.55);
        z-index: 35;
    }
    .admin-main { margin-left: 0; width: 100%; }
    .mobile-only { display: inline-flex; }
    .icon-button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        border-radius: 12px;
        border: 1px solid var(--border);
        background: rgba(255,255,255,0.03);
        color: var(--text);
    }
    .icon-button svg { width: 20px; height: 20px; }
    .admin-content,
    .admin-footer,
    .topbar { padding-left: 18px; padding-right: 18px; }
}

body.modal-open { overflow: hidden; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(6px);
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 24px;
}

.modal-overlay[hidden] { display: none !important; }

.modal-card {
    width: min(560px, 100%);
    max-height: 90vh;
    overflow: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 24px;
}

.modal-card.modal-wide { width: min(760px, 100%); }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    font-size: 1.4rem;
    cursor: pointer;
}

.modal-body { display: grid; gap: 12px; }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 8px;
}

.detail-grid span {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    margin-bottom: 4px;
}

.detail-grid strong {
    display: block;
    word-break: break-all;
}

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

.support-preview {
    display: inline-flex;
    padding: 12px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.03);
}

.support-preview-image {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 50%;
}

.hint-list {
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
    line-height: 1.7;
}
