:root {
    --bg: #f4f5f7;
    --panel: #ffffff;
    --panel-2: #f9fafb;
    --sidebar: #111827;
    --sidebar-muted: #9ca3af;
    --primary: #2563eb;
    --ok: #16a34a;
    --warn: #d97706;
    --danger: #dc2626;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --input-border: #d1d5db;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --panel: #1e293b;
    --panel-2: #263449;
    --sidebar: #0b1220;
    --sidebar-muted: #94a3b8;
    --primary: #3b82f6;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --border: #334155;
    --input-border: #475569;
}

[data-theme="dark"] {
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: var(--primary);
}

.shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 230px;
    flex-shrink: 0;
    background: var(--sidebar);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 22px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    font-weight: 700;
    font-size: 18px;
    color: #fff;
    text-decoration: none;
    display: block;
    margin: 0 10px 22px;
}

.nav a {
    display: block;
    color: var(--sidebar-muted);
    text-decoration: none;
    padding: 8px 10px;
    border-radius: 8px;
    margin-bottom: 2px;
    font-size: 14px;
}

.nav a:hover,
.nav a.active {
    background: #1f2937;
    color: #fff;
}

.sidebar-footer {
    margin-top: auto;
    font-size: 13px;
    color: var(--sidebar-muted);
    padding: 0 10px;
}

.main {
    flex: 1;
    padding: 28px 32px 60px;
    max-width: 1250px;
}

h1 {
    font-size: 22px;
    margin: 0 0 4px;
}

h2 {
    font-size: 16px;
    margin: 28px 0 10px;
}

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

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

.grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
}

.card h3 {
    margin: 0 0 2px;
    font-size: 15.5px;
}

.card-link {
    text-decoration: none;
    color: inherit;
}

.card-link:hover {
    color: var(--primary);
}

.card-footer {
    margin-top: 12px;
}

.badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.badge {
    font-size: 12px;
    background: #eef2ff;
    color: #3730a3;
    padding: 2px 9px;
    border-radius: 999px;
    white-space: nowrap;
}

.badge.ok {
    background: #dcfce7;
    color: #166534;
}

.badge.warn {
    background: #fef3c7;
    color: #92400e;
}

.badge.danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge.muted {
    background: #f3f4f6;
    color: #4b5563;
}

.dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 6px;
}

.dot.up {
    background: var(--ok);
}

.dot.down {
    background: var(--danger);
}

.dot.unknown {
    background: #9ca3af;
}

.btn {
    display: inline-block;
    border: 0;
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 13.5px;
    cursor: pointer;
    background: #e5e7eb;
    color: #111827;
    text-decoration: none;
}

.btn:hover {
    filter: brightness(0.96);
}

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

.btn.ok {
    background: var(--ok);
    color: #fff;
}

.btn.danger {
    background: var(--danger);
    color: #fff;
}

.btn.small {
    padding: 4px 9px;
    font-size: 12.5px;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    font-size: 14px;
    margin-bottom: 8px;
}

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

th {
    background: var(--panel-2);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
}

tr:last-child td {
    border-bottom: 0;
}

form.inline {
    display: inline;
}

.alert {
    padding: 11px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert.success {
    background: #dcfce7;
    color: #14532d;
}

.alert.error {
    background: #fee2e2;
    color: #7f1d1d;
}

.alert.warning {
    background: #fef3c7;
    color: #78350f;
}

.alert.info {
    background: #dbeafe;
    color: #1e3a8a;
}

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--panel);
    color: inherit;
}

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin: 14px 0 5px;
}

.field-error {
    color: var(--danger);
    font-size: 12.5px;
    margin-top: 4px;
}

.form-card {
    max-width: 560px;
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.actions.top {
    margin-top: 0;
}

.secret-box {
    background: #111827;
    color: #a7f3d0;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    padding: 12px;
    border-radius: 10px;
    word-break: break-all;
    font-size: 13px;
}

.kv {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px 20px;
    margin: 0;
}

.kv dt {
    color: var(--muted);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.kv dd {
    margin: 3px 0 0;
    font-weight: 600;
    font-size: 14px;
}

.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sidebar);
    padding: 20px;
}

.auth-card {
    background: var(--panel);
    padding: 32px;
    border-radius: 14px;
    width: 400px;
    max-width: 94vw;
}

.auth-card h1 {
    font-size: 19px;
    margin-bottom: 2px;
}

.pagination {
    margin-top: 14px;
    display: flex;
    gap: 8px;
    font-size: 13px;
    align-items: center;
}

.pagination a,
.pagination span {
    padding: 5px 10px;
    border-radius: 6px;
    background: var(--panel);
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
}

.recovery-codes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 13px;
    background: var(--panel-2);
    padding: 12px;
    border-radius: 10px;
    margin-top: 8px;
}

.server-heading {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 28px 0 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--border);
    font-size: 15px;
    font-weight: 700;
}

.server-heading:first-of-type {
    margin-top: 8px;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-wrap table {
    margin-bottom: 0;
}

@media (max-width: 820px) {
    .shell {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        padding: 14px 12px;
    }

    .brand {
        margin: 0 0 10px;
    }

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

    .nav a {
        margin-bottom: 0;
        padding: 7px 10px;
    }

    .sidebar-footer {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        margin-top: 12px;
        padding: 0;
    }

    .main {
        padding: 18px 14px 40px;
    }

    h1 {
        font-size: 19px;
    }

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

    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .card {
        padding: 14px;
    }

    th,
    td {
        padding: 8px 10px;
        font-size: 13px;
    }

    .auth-card {
        padding: 22px;
    }

    .table-wrap {
        margin: 0 -14px;
        padding: 0 14px;
    }
}

[data-theme="dark"] .btn {
    background: #334155;
    color: #f1f5f9;
}

[data-theme="dark"] .btn.primary {
    background: var(--primary);
    color: #fff;
}

[data-theme="dark"] .btn.ok {
    background: #15803d;
    color: #fff;
}

[data-theme="dark"] .btn.danger {
    background: #b91c1c;
    color: #fff;
}

[data-theme="dark"] .badge {
    background: #1e3a8a;
    color: #bfdbfe;
}

[data-theme="dark"] .badge.ok {
    background: #14532d;
    color: #bbf7d0;
}

[data-theme="dark"] .badge.warn {
    background: #78350f;
    color: #fde68a;
}

[data-theme="dark"] .badge.danger {
    background: #7f1d1d;
    color: #fecaca;
}

[data-theme="dark"] .badge.muted {
    background: #334155;
    color: #cbd5e1;
}

[data-theme="dark"] .alert.success {
    background: #052e16;
    color: #bbf7d0;
}

[data-theme="dark"] .alert.error {
    background: #450a0a;
    color: #fecaca;
}

[data-theme="dark"] .alert.warning {
    background: #451a03;
    color: #fde68a;
}

[data-theme="dark"] .alert.info {
    background: #172554;
    color: #bfdbfe;
}

.footer-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}
