:root {
    --bg: #0b1020;
    --bg-elevated: #121a2f;
    --panel: #151f38;
    --border: rgba(255, 255, 255, 0.08);
    --text: #eef2ff;
    --muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(59, 130, 246, 0.18), transparent 30%),
        radial-gradient(circle at bottom right, rgba(34, 197, 94, 0.12), transparent 25%),
        var(--bg);
    color: var(--text);
}

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

.auth-page {
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: min(100%, 420px);
    background: rgba(21, 31, 56, 0.92);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px;
    backdrop-filter: blur(12px);
}

.brand {
    text-align: center;
    margin-bottom: 28px;
}

.brand-icon {
    display: inline-grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(34, 197, 94, 0.18));
    font-size: 1.5rem;
    margin-bottom: 12px;
}

.brand h1,
.panel-header h1 {
    margin: 0 0 8px;
    font-size: 1.75rem;
}

.brand p,
.muted,
.subtitle {
    color: var(--muted);
}

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

label {
    display: grid;
    gap: 8px;
    font-size: 0.95rem;
}

input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(11, 16, 32, 0.85);
    color: var(--text);
    font: inherit;
}

input:focus {
    outline: 2px solid rgba(59, 130, 246, 0.45);
    border-color: rgba(59, 130, 246, 0.6);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 16px;
    border-radius: 12px;
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border);
    color: var(--text);
}

.btn-success {
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(34, 197, 94, 0.35);
    color: #bbf7d0;
}

.btn-warning {
    background: rgba(245, 158, 11, 0.18);
    border-color: rgba(245, 158, 11, 0.35);
    color: #fde68a;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.35);
    color: #fecaca;
}

.btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}

.btn-block {
    width: 100%;
}

.topbar {
    border-bottom: 1px solid var(--border);
    background: rgba(11, 16, 32, 0.75);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-inner,
.container {
    width: min(1100px, calc(100% - 32px));
    margin: 0 auto;
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 0;
}

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

.topbar-brand strong {
    display: block;
    font-size: 1.05rem;
}

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

.user-pill {
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--muted);
    font-size: 0.9rem;
}

.container {
    padding: 28px 0 48px;
}

.panel {
    background: rgba(21, 31, 56, 0.88);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 4px);
    box-shadow: var(--shadow);
    padding: 24px;
}

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

.servers-grid {
    display: grid;
    gap: 16px;
}

.server-card,
.loading-card,
.empty-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(11, 16, 32, 0.55);
    padding: 20px;
}

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

.server-name {
    margin: 0 0 6px;
    font-size: 1.15rem;
}

.server-ip {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 1rem;
    color: #93c5fd;
    margin-bottom: 6px;
}

.server-ip-missing {
    color: var(--muted);
    font-family: inherit;
    font-size: 0.92rem;
}

.server-meta {
    color: var(--muted);
    font-size: 0.92rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-badge::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.status-on {
    color: #86efac;
    background: rgba(34, 197, 94, 0.12);
}

.status-off {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.12);
}

.status-unknown {
    color: #fde68a;
    background: rgba(245, 158, 11, 0.12);
}

.server-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.alert {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.alert-error {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.35);
    color: #fecaca;
}

.alert-success {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.35);
    color: #bbf7d0;
}

.alert-info {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.35);
    color: #bfdbfe;
}

.settings-form {
    display: grid;
    gap: 24px;
}

.settings-section {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(11, 16, 32, 0.55);
    padding: 20px;
    margin: 0;
    display: grid;
    gap: 14px;
}

.settings-section legend {
    font-size: 1.05rem;
    font-weight: 700;
    padding: 0 4px;
}

.section-note {
    margin: 0;
    font-size: 0.92rem;
}

.section-note a {
    color: #93c5fd;
    text-decoration: underline;
}

.config-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.config-badge-ok {
    color: #86efac;
    background: rgba(34, 197, 94, 0.15);
}

.config-badge-missing {
    color: #fde68a;
    background: rgba(245, 158, 11, 0.15);
}

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

.test-result {
    font-size: 0.92rem;
    flex: 1 1 220px;
}

.test-result-info {
    color: #bfdbfe;
}

.test-result-success {
    color: #bbf7d0;
}

.test-result-error {
    color: #fecaca;
}

.hidden {
    display: none;
}

.page-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.page-tab {
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.page-tab.active {
    background: rgba(59, 130, 246, 0.18);
    border-color: rgba(59, 130, 246, 0.45);
    color: #bfdbfe;
}

.page-panel.hidden {
    display: none;
}

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

.manage-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.manage-tab {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
}

.manage-tab.active {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.16);
}

.manage-pane {
    display: none;
}

.manage-pane.active {
    display: block;
}

.feature-section {
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.feature-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
}

.feature-section h3 {
    margin: 0 0 10px;
    font-size: 1rem;
}

.feature-form,
.compact-form {
    display: grid;
    gap: 12px;
}

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

.form-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.form-actions {
    display: flex;
    gap: 10px;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
}

.inline-form:last-child {
    margin-bottom: 0;
}

.inline-form input,
.inline-form select,
.inline-form textarea {
    min-width: 140px;
}

textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(11, 16, 32, 0.85);
    color: var(--text);
    font: inherit;
    resize: vertical;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 0.92rem;
}

.checkbox-label input {
    width: auto;
}

.details-list {
    display: grid;
    gap: 10px;
    margin: 0;
}

.details-list > div {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 12px;
    align-items: start;
}

.details-list dt {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.details-list dd {
    margin: 0;
}

.info-block {
    margin-bottom: 12px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 0.92rem;
}

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

.data-table th {
    color: var(--muted);
    font-weight: 600;
}

.data-table code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.85rem;
    color: #93c5fd;
}

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

.btn-sm {
    padding: 7px 12px;
    font-size: 0.85rem;
}

.danger-zone {
    padding: 14px;
    border-radius: 12px;
    border: 1px solid rgba(239, 68, 68, 0.25);
    background: rgba(239, 68, 68, 0.06);
}

@media (max-width: 640px) {
    .panel-header,
    .server-card-header,
    .topbar-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .server-actions .btn {
        flex: 1 1 calc(50% - 10px);
    }

    .details-list > div {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .inline-form input,
    .inline-form select {
        width: 100%;
    }
}
