:root {
    color-scheme: dark;
    --background: #08111f;
    --panel: #111d2d;
    --panel-secondary: #17263a;
    --text: #f4f7fb;
    --muted: #9fb0c5;
    --border: #293b52;
    --accent: #4ea1ff;
    --success: #38d996;
    --warning: #f6bd5b;
    --danger: #ff647c;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 240px;
    background: #111827;
    border-right: 1px solid #2d3748;
}

.logo {
    padding: 30px 20px;
    border-bottom: 1px solid #2d3748;
    text-align: center;
}

.logo h2 {
    margin: 0;
    color: #4da3ff;
}

.logo small,
.muted,
.subtitle,
.server-label {
    color: var(--muted);
}

.sidebar a {
    display: block;
    padding: 16px 22px;
    border-bottom: 1px solid #1f2937;
    color: white;
    text-decoration: none;
}

.sidebar a:hover,
.sidebar a.active {
    background: #2563eb;
}

.content {
    min-height: 100vh;
    margin-left: 240px;
}

header {
    border-bottom: 1px solid var(--border);
    background: #0b1727;
}

.header-inner,
main {
    width: min(1200px, calc(100% - 48px));
    margin: 0 auto;
}

.header-inner {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    font-size: 1.35rem;
    font-weight: 700;
}

.brand span {
    color: var(--accent);
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.header-logout {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid rgba(255, 100, 124, .65);
    border-radius: 7px;
    background: rgba(180, 35, 59, .2);
    color: #ffd3da;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.header-logout:hover {
    background: #b4233b;
    color: white;
}

main {
    padding: 28px 0 50px;
}

h1 {
    margin: 0 0 8px;
    font-size: 1.8rem;
}

.subtitle {
    margin: 0 0 24px;
}

.back-link {
    display: inline-block;
    margin-bottom: 18px;
    color: #8fc5ff;
    text-decoration: none;
}

.back-link:hover {
    text-decoration: underline;
}

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

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

.card {
    padding: 20px;
}

.card-label {
    margin-bottom: 9px;
    color: var(--muted);
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.card-value {
    font-size: 1.4rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.panel {
    overflow: hidden;
    margin-bottom: 22px;
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--panel-secondary);
}

.panel-heading h2 {
    margin: 0;
    font-size: 1.12rem;
}

.panel-body {
    padding: 20px;
}

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

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

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

th {
    background: #132238;
    color: var(--muted);
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}

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

.status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--danger);
}

.dot.online {
    background: var(--success);
}

.dot.idle {
    background: var(--warning);
}

.dot.unknown {
    background: var(--muted);
}

.badge {
    display: inline-block;
    padding: 6px 10px;
    border: 1px solid rgba(78, 161, 255, .35);
    border-radius: 999px;
    background: rgba(78, 161, 255, .16);
    color: #8fc5ff;
    font-size: .82rem;
    white-space: nowrap;
}

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

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 9px 12px;
    border: 0;
    border-radius: 7px;
    background: #2563eb;
    color: white;
    text-decoration: none;
    font: inherit;
    cursor: pointer;
}

.button.download {
    background: #157a55;
}

.button.secondary {
    background: #374151;
}

.button.danger {
    background: #b4233b;
}

.button:hover {
    filter: brightness(1.14);
}

.search {
    display: flex;
    gap: 10px;
    margin-bottom: 22px;
}

.search input {
    width: min(440px, 100%);
    padding: 11px 13px;
    border: 1px solid #4b5563;
    border-radius: 7px;
    background: #0f172a;
    color: white;
    font: inherit;
}

.notice {
    padding: 18px 20px;
    margin-bottom: 22px;
    line-height: 1.5;
}

.notice.error {
    border-color: var(--danger);
    color: #ffc2cb;
}

.notice.success {
    border-color: var(--success);
    background: rgba(56, 217, 150, .1);
    color: #baf5dc;
}

.notice.warning {
    border-color: var(--warning);
    background: rgba(246, 189, 91, .08);
    color: #ffe0a3;
}

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

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

.setting {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #0d1928;
}

.setting strong {
    display: block;
    margin-top: 7px;
    overflow-wrap: anywhere;
}

.logout-card {
    width: min(560px, 100%);
    margin: 60px auto;
    padding: 28px;
    text-align: center;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: min(480px, 100%);
    padding: 30px;
}

.auth-brand {
    margin-bottom: 24px;
    color: var(--text);
    font-size: 1.5rem;
    font-weight: 700;
}

.auth-brand span {
    color: var(--accent);
}

label {
    display: block;
    color: var(--muted);
    font-weight: 700;
}

label input,
label select,
.auth-card input {
    width: 100%;
    margin: 7px 0 18px;
    padding: 12px 13px;
    border: 1px solid #4b5563;
    border-radius: 7px;
    background: #0f172a;
    color: white;
    font: inherit;
}

.auth-submit {
    width: 100%;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 18px;
}

.form-action {
    display: flex;
    align-items: center;
}

.family-sections {
    display: grid;
    gap: 24px;
}

.policy-form {
    display: grid;
    gap: 14px;
}

.check-label {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--text);
}

.check-label input {
    width: auto;
    margin: 0;
}

.schedule-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.inline-assignment {
    display: grid;
    grid-template-columns: minmax(140px, 1fr) minmax(160px, 1fr) auto;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.inline-assignment input,
.inline-assignment select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #4b5563;
    border-radius: 7px;
    background: #0f172a;
    color: white;
    font: inherit;
}

.domain-list form {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
}

.totp-qr {
    width: min(260px, 100%);
    padding: 12px;
    border-radius: 10px;
    background: white;
}

.recovery-codes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.recovery-codes code {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #0f172a;
    text-align: center;
}

footer {
    margin-top: 22px;
    color: var(--muted);
    font-size: .8rem;
    text-align: center;
}

@media (max-width: 900px) {
    .cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    table {
        min-width: 850px;
    }
}

@media (max-width: 700px) {
    .sidebar {
        position: static;
        width: 100%;
    }

    .sidebar a {
        display: inline-block;
        border-bottom: 0;
    }

    .content {
        margin-left: 0;
    }

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

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

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

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

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

@media (max-width: 560px) {
    .header-inner {
        align-items: flex-start;
        flex-direction: column;
        padding: 16px 0;
    }

    .header-inner,
    main {
        width: min(100% - 28px, 1200px);
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

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

    .search {
        flex-direction: column;
    }

    .search .button {
        width: 100%;
    }
}
