:root {
    color-scheme: light;
    --bg: #0f172a;
    --bg-soft: #111c33;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --line: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    --radius: 16px;
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--text);
    background: #f1f5f9;
}

a { color: inherit; }

/* Login */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.18), transparent 30%),
        radial-gradient(circle at bottom right, rgba(14, 165, 233, 0.12), transparent 28%),
        linear-gradient(180deg, #0f172a 0%, #172554 100%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 24px;
    padding: 32px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.login-logo {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #2563eb, #0ea5e9);
    color: #fff;
    font-weight: 800;
    font-size: 18px;
}

.login-brand h1 {
    margin: 0;
    font-size: 22px;
}

.login-brand p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.field { margin-bottom: 16px; }

.field label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
}

.input-wrap { position: relative; }

.input, .textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    font: inherit;
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}

.input:focus, .textarea:focus {
    outline: none;
    border-color: #60a5fa;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.textarea { min-height: 140px; resize: vertical; }

.toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    padding: 6px 8px;
    font-size: 13px;
}

/* Admin shell */
.admin-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
}

.sidebar {
    background: var(--bg);
    color: #e2e8f0;
    padding: 24px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    padding: 8px 10px 24px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    margin-bottom: 18px;
}

.sidebar-brand strong {
    display: block;
    font-size: 18px;
    color: #fff;
}

.sidebar-brand span {
    display: block;
    margin-top: 6px;
    font-size: 13px;
    color: #94a3b8;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    color: #cbd5e1;
    text-decoration: none;
    margin-bottom: 6px;
    font-size: 14px;
}

.nav-link:hover, .nav-link.active {
    background: rgba(37, 99, 235, 0.18);
    color: #fff;
}

.sidebar-meta {
    margin-top: 24px;
    padding: 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.5;
}

.main {
    padding: 24px;
}

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

.topbar h2 {
    margin: 0 0 6px;
    font-size: 28px;
}

.topbar p {
    margin: 0;
    color: var(--muted);
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}

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

.card-header h3 {
    margin: 0;
    font-size: 18px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
}

.stat {
    padding: 18px;
    border-radius: 14px;
    background: var(--surface-2);
    border: 1px solid var(--line);
}

.stat strong {
    display: block;
    font-size: 28px;
    line-height: 1.1;
    margin-bottom: 6px;
}

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

.stat.available strong { color: var(--success); }
.stat.telegram strong { color: var(--primary); }

.flash {
    padding: 14px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 14px;
}

.flash.ok {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.flash.err {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border: 0;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
}

.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #475569; }
.btn.success { background: var(--success); }
.btn.danger { background: var(--danger); }
.btn.ghost {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--line);
}

.btn.sm { padding: 7px 10px; font-size: 13px; }
.btn.block { width: 100%; }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #334155;
    text-decoration: none;
    font-size: 13px;
    border: 1px solid transparent;
}

.chip.active {
    background: #dbeafe;
    color: #1d4ed8;
    border-color: #93c5fd;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge.available { background: #dcfce7; color: #166534; }
.badge.registered { background: #e0e7ff; color: #3730a3; }
.badge.blocked { background: #fef3c7; color: #92400e; }
.badge.unknown { background: #f3f4f6; color: #374151; }
.badge.on { background: #dcfce7; color: #166534; }
.badge.off { background: #fee2e2; color: #991b1b; }

.progress {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
    margin-top: 6px;
}

.progress > span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #16a34a);
}

.table-wrap { overflow-x: auto; }

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

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

th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
}

.domain-name {
    font-size: 15px;
    font-weight: 700;
}

.meta {
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.45;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.row-actions form { margin: 0; }

.empty {
    text-align: center;
    padding: 36px 20px;
    color: var(--muted);
}

.empty strong {
    display: block;
    color: var(--text);
    font-size: 18px;
    margin-bottom: 8px;
}

.split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.hint {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.code-box {
    display: block;
    padding: 14px;
    border-radius: 12px;
    background: #0f172a;
    color: #e2e8f0;
    overflow-x: auto;
    font-size: 13px;
}

.mobile-logout { display: none; }

@media (max-width: 960px) {
    .admin-shell { display: block; }

    .sidebar {
        position: static;
        height: auto;
        padding-bottom: 12px;
    }

    .sidebar nav {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    .nav-link { margin-bottom: 0; }
    .sidebar-meta { display: none; }

    .main { padding: 16px; }
    .topbar h2 { font-size: 22px; }
    .split { grid-template-columns: 1fr; }
    .mobile-logout { display: inline-flex; }
    .desktop-logout { display: none; }

    th:nth-child(4), td:nth-child(4),
    th:nth-child(5), td:nth-child(5) {
        display: none;
    }
}
