:root {
    color-scheme: light;
    --bg: #f6f7f9;
    --panel: #ffffff;
    --panel-border: #dce2ea;
    --text: #172033;
    --muted: #657085;
    --primary: #1565c0;
    --primary-dark: #0d47a1;
    --green: #1b7f4c;
    --red: #b42318;
    --amber: #a05a00;
    --cyan: #006d77;
    --shadow: 0 10px 24px rgba(23, 32, 51, .08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

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

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
    background: #111827;
    color: #f9fafb;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.brand,
.auth-brand,
.install-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: #2f80ed;
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
}

.brand strong,
.auth-brand strong,
.install-brand strong {
    display: block;
    font-size: 17px;
}

.brand small,
.auth-brand small,
.install-brand small {
    display: block;
    color: #9ca3af;
    font-size: 12px;
}

.nav {
    display: grid;
    gap: 6px;
}

.nav a {
    color: #d1d5db;
    padding: 10px 12px;
    border-radius: 7px;
}

.nav a:hover,
.nav a.is-active {
    background: #263244;
    color: #fff;
}

.sidebar-footer {
    margin-top: auto;
    display: grid;
    gap: 12px;
}

.user-email {
    color: #d1d5db;
    font-size: 13px;
    overflow-wrap: anywhere;
}

.main {
    padding: 28px;
    min-width: 0;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
}

.topbar h1,
.auth-panel h1 {
    margin: 0;
    font-size: 26px;
}

.topbar p,
.section-head p {
    margin: 4px 0 0;
    color: var(--muted);
}

.panel,
.metric,
.auth-panel {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel {
    padding: 20px;
    margin-bottom: 18px;
}

.panel.narrow {
    max-width: 920px;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.metric {
    padding: 18px;
}

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

.metric strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
}

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

.section-head h2 {
    margin: 0;
    font-size: 18px;
}

.filters,
.action-row,
.form-actions,
.inline-form,
.extend-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.form {
    display: grid;
    gap: 15px;
}

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

label {
    display: grid;
    gap: 6px;
    color: #374151;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    padding: 10px 11px;
    color: var(--text);
    background: #fff;
    font: inherit;
    font-weight: 400;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(21, 101, 192, .18);
    border-color: var(--primary);
}

.button {
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 10px 14px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text);
    background: #fff;
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
}

.button-small {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 13px;
}

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

.button-primary:hover {
    background: var(--primary-dark);
}

.button-muted {
    border-color: #cbd5e1;
    color: #334155;
    background: #f8fafc;
}

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

.button:disabled {
    cursor: not-allowed;
    opacity: .45;
}

.button-warning {
    color: #221400;
    background: #f4b740;
}

.full-width {
    width: 100%;
}

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

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

th,
td {
    padding: 11px 10px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: top;
}

th {
    color: #475569;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0;
}

code,
pre {
    font-family: Consolas, Monaco, monospace;
}

pre {
    margin: 0;
    white-space: pre-wrap;
    font-size: 12px;
}

.pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 12px;
    font-weight: 800;
    background: #e5e7eb;
    color: #374151;
}

.pill-active {
    background: #dcfce7;
    color: var(--green);
}

.pill-expired,
.pill-suspended,
.pill-not_found,
.pill-rate_limited {
    background: #fee2e2;
    color: var(--red);
}

.pill-muted {
    background: #e5e7eb;
    color: #4b5563;
}

.flash {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 14px;
    border: 1px solid transparent;
    overflow-wrap: anywhere;
}

.flash.success {
    background: #ecfdf3;
    color: var(--green);
    border-color: #bbf7d0;
}

.flash.error {
    background: #fef2f2;
    color: var(--red);
    border-color: #fecaca;
}

.flash.secret {
    background: #fff7ed;
    color: #7c2d12;
    border-color: #fed7aa;
    font-family: Consolas, Monaco, monospace;
}

.field-error {
    color: var(--red);
    font-size: 13px;
    font-weight: 700;
}

.empty {
    color: var(--muted);
    text-align: center;
}

.row-actions {
    text-align: right;
    white-space: nowrap;
}

.row-actions form {
    display: inline-flex;
    margin: 0 0 0 6px;
    vertical-align: middle;
}

.truncate {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.readonly-grid > div {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    background: #f8fafc;
}

.readonly-grid span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.readonly-grid strong {
    display: block;
    margin-top: 4px;
}

.extend-form input {
    width: 92px;
}

.twofa-setup {
    display: flex;
    margin-bottom: 16px;
}

.qr-card {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f8fafc;
    padding: 16px;
    max-width: 300px;
}

.qr-card p {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.qr-code {
    width: 220px;
    min-height: 220px;
    display: grid;
    place-items: center;
    color: var(--muted);
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px;
}

.qr-code svg {
    display: block;
    width: 100%;
    height: auto;
}

.auth-body {
    background: #eef2f7;
}

.install-body {
    background: #eef2f7;
}

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

.install-shell {
    width: min(1040px, 100%);
    margin: 0 auto;
    padding: 28px;
}

.auth-panel {
    width: min(420px, 100%);
    padding: 26px;
}

.auth-brand,
.install-brand {
    margin-bottom: 24px;
}

.install-panel {
    padding: 24px;
}

.install-panel h1 {
    margin: 0;
    font-size: 28px;
}

.install-form h2 {
    margin: 10px 0 0;
    font-size: 17px;
}

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

.check-item {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    background: #f8fafc;
}

.check-item span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.check-item strong {
    display: block;
    margin-top: 4px;
}

.check-item.ok {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.check-item.fail {
    border-color: #fecaca;
    background: #fef2f2;
}

.checkline {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkline input {
    width: auto;
}

.success-state {
    text-align: center;
    display: grid;
    gap: 14px;
    justify-items: center;
    padding: 28px 0;
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        padding: 16px;
    }

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

    .main {
        padding: 18px;
    }

    .metrics,
    .check-grid,
    .form-grid,
    .readonly-grid {
        grid-template-columns: 1fr;
    }

    .section-head {
        align-items: stretch;
        flex-direction: column;
    }

    .filters input,
    .filters select {
        min-width: 100%;
    }
}
