:root {
    color-scheme: dark;
    --bg: #07111f;
    --panel: #0d1b2e;
    --panel-soft: #10243b;
    --text: #e7f0ff;
    --muted: #90a8c4;
    --line: #203a5a;
    --accent: #38bdf8;
    --accent-dark: #0ea5e9;
    --accent-soft: rgba(56, 189, 248, 0.18);
    --danger: #fb7185;
    --warn: #fbbf24;
    --ok: #34d399;
    --shadow: 0 20px 48px rgba(0, 8, 24, 0.42);
    --soft-shadow: 0 10px 26px rgba(0, 8, 24, 0.35);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        radial-gradient(circle at top left, rgba(56, 189, 248, 0.16), transparent 34rem),
        radial-gradient(circle at top right, rgba(37, 99, 235, 0.14), transparent 30rem),
        linear-gradient(180deg, #0b1730 0%, var(--bg) 42rem);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
}

button,
input,
textarea {
    font: inherit;
}

code {
    overflow-wrap: anywhere;
    color: #bfdbfe;
    font-family: "Cascadia Mono", Consolas, monospace;
    font-size: 12px;
}

a {
    color: #7dd3fc;
    text-decoration-color: rgba(125, 211, 252, 0.45);
    text-underline-offset: 3px;
}

a:hover {
    color: #bae6fd;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 30px;
    background: linear-gradient(135deg, #020617 0%, #0b2a55 54%, #0e7490 100%);
    color: white;
    border-bottom: 1px solid rgba(148, 197, 255, 0.16);
    box-shadow: 0 18px 44px rgba(0, 8, 24, 0.42);
}

.topbar h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 750;
}

.topbar p {
    margin: 4px 0 0;
    color: #a9c4e8;
}

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

.page {
    width: min(1800px, calc(100% - 32px));
    margin: 24px auto 44px;
}

.alerts {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

.alert,
.error-strip {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--panel);
}

.alert.success {
    background: rgba(52, 211, 153, 0.1);
    border-color: rgba(52, 211, 153, 0.34);
    color: var(--ok);
}

.alert.error,
.error-strip {
    background: rgba(251, 113, 133, 0.1);
    border-color: rgba(251, 113, 133, 0.35);
    color: var(--danger);
}

.alert.warning {
    background: rgba(251, 191, 36, 0.1);
    border-color: rgba(251, 191, 36, 0.35);
    color: var(--warn);
}

.metrics {
    display: grid;
    grid-template-columns: repeat(5, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.metric,
.system-grid,
.settings-panel,
.bulk-limits,
.create-user,
.created-user,
.events {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.metric {
    min-height: 84px;
    padding: 16px;
    position: relative;
    overflow: hidden;
}

.metric::after {
    content: "";
    position: absolute;
    inset: auto 14px 12px auto;
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: var(--accent-soft);
    box-shadow: 0 0 22px rgba(56, 189, 248, 0.32);
}

.metric span,
.label {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.metric strong {
    display: block;
    margin-top: 10px;
    font-size: 26px;
    line-height: 1.15;
}

.metric.wide strong {
    font-size: 18px;
}

.system-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 12px;
    padding: 16px;
    margin-bottom: 14px;
}

.system-grid code {
    display: block;
    margin-top: 6px;
}

.settings-panel {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 14px;
    align-items: end;
    padding: 16px;
    margin-bottom: 14px;
}

.bulk-limits {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 14px;
    align-items: end;
    padding: 16px;
    margin-bottom: 14px;
}

.settings-panel h2,
.bulk-limits h2 {
    margin: 0 0 4px;
    font-size: 16px;
}

.settings-panel p,
.bulk-limits p {
    margin: 0;
    color: var(--muted);
}

.settings-form,
.bulk-limit-form {
    display: grid;
    grid-template-columns: 90px 90px auto;
    gap: 8px;
    align-items: end;
}

.create-user {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 2fr;
    gap: 14px;
    align-items: end;
    padding: 16px;
    margin-bottom: 14px;
}

.create-user h2,
.created-user h2 {
    margin: 0 0 4px;
    font-size: 16px;
}

.create-user p,
.created-user p {
    margin: 0;
    color: var(--muted);
}

.create-user-form {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) minmax(100px, 0.7fr) auto;
    gap: 8px;
    align-items: end;
}

.created-user {
    width: min(980px, 100%);
    padding: 16px;
    margin-bottom: 14px;
    border-color: rgba(56, 189, 248, 0.36);
}

.created-user-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.created-user-links {
    display: flex;
    gap: 8px;
}

.created-user-body {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.qr-card {
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: linear-gradient(180deg, #10243b 0%, #0b1728 100%);
    box-shadow: var(--soft-shadow);
}

.qr-card img {
    width: 148px;
    height: 148px;
    border: 1px solid rgba(191, 219, 254, 0.25);
    border-radius: 10px;
    background: white;
}

.qr-card span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.config-preview {
    min-width: 0;
}

.connection-field {
    margin-bottom: 10px;
}

.connection-field textarea {
    min-height: 74px;
    font-family: "Cascadia Mono", Consolas, monospace;
    font-size: 12px;
}

.config-preview-header {
    display: flex;
    align-items: center;
    min-height: 30px;
    padding: 0 2px 8px;
    color: var(--muted);
    font-size: 12px;
}

.config-preview-body,
.created-user-body textarea {
    min-height: 180px;
    font-family: "Cascadia Mono", Consolas, monospace;
    font-size: 12px;
    background: #06101f;
    color: #dbeafe;
    border-color: #1b3352;
}

.table-wrap {
    overflow-x: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

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

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

th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #10243b;
    color: #a9c4e8;
    font-size: 12px;
    text-transform: uppercase;
}

td strong,
td span {
    display: block;
}

tr.offline {
    background: rgba(8, 18, 32, 0.72);
}

tbody tr:hover {
    background: rgba(56, 189, 248, 0.07);
}

.pill {
    display: inline-flex;
    align-items: center;
    min-width: 72px;
    justify-content: center;
    border-radius: 999px;
    padding: 5px 8px;
    font-size: 12px;
    font-weight: 750;
}

.pill.online {
    background: rgba(52, 211, 153, 0.13);
    color: var(--ok);
}

.pill.idle {
    background: rgba(251, 191, 36, 0.14);
    color: var(--warn);
}

.pill.inactive {
    background: rgba(144, 168, 196, 0.14);
    color: var(--muted);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 7px 12px;
    background: #10243b;
    color: var(--text);
    cursor: pointer;
    font-weight: 700;
    text-decoration: none;
    transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.button:hover {
    transform: translateY(-1px);
    box-shadow: var(--soft-shadow);
}

.button.primary {
    border-color: var(--accent);
    background: linear-gradient(135deg, #0284c7 0%, var(--accent) 100%);
    color: #02111f;
    box-shadow: 0 10px 24px rgba(14, 165, 233, 0.22);
}

.button.primary:hover {
    background: linear-gradient(135deg, var(--accent-dark) 0%, #7dd3fc 100%);
}

.button.ghost {
    background: rgba(255, 255, 255, 0.04);
    color: white;
    border-color: rgba(191, 219, 254, 0.24);
}

.button.compact {
    min-height: 32px;
    padding: 5px 10px;
}

.button.link {
    min-height: 28px;
    padding: 0;
    border: 0;
    color: var(--danger);
    background: transparent;
}

.button.link.danger {
    color: var(--danger);
}

.button.full {
    width: 100%;
}

.limit-form,
.profile-form {
    display: grid;
    gap: 8px;
}

.limit-form {
    grid-template-columns: 72px 72px auto;
    align-items: end;
}

label {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px;
    background: #071426;
    color: var(--text);
}

input::placeholder,
textarea::placeholder {
    color: #6683a4;
}

input:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.16);
    outline: none;
}

textarea {
    resize: vertical;
}

details summary {
    cursor: pointer;
    color: var(--accent);
    font-weight: 750;
}

dl {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 8px;
    margin: 10px 0 0;
}

dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

dd {
    margin: 0;
    overflow-wrap: anywhere;
}

small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
}

.break {
    overflow-wrap: anywhere;
}

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

.events {
    margin-top: 14px;
    padding: 16px;
}

.events h2 {
    margin: 0 0 12px;
    font-size: 16px;
}

.events ol {
    display: grid;
    gap: 8px;
    margin: 0;
    padding-left: 20px;
}

.events li {
    color: var(--muted);
}

.events time {
    color: var(--text);
    font-weight: 700;
}

.login-body {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 22px;
}

.login-shell {
    display: grid;
    grid-template-columns: minmax(220px, 0.9fr) minmax(320px, 420px);
    gap: 18px;
    width: min(860px, 100%);
}

.login-hero,
.login-box {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(13, 27, 46, 0.88);
    box-shadow: var(--shadow);
}

.login-hero {
    display: grid;
    align-content: end;
    min-height: 330px;
    padding: 28px;
    background:
        radial-gradient(circle at 30% 15%, rgba(56, 189, 248, 0.22), transparent 16rem),
        linear-gradient(145deg, #0b1730 0%, #0d1b2e 100%);
}

.login-hero h1 {
    margin: 10px 0 8px;
    font-size: 34px;
}

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

.login-box {
    padding: 24px;
}

.login-box h2 {
    margin: 0 0 18px;
    font-size: 22px;
}

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

@media (max-width: 980px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 16px;
    }

    .metrics,
    .settings-panel,
    .settings-form,
    .bulk-limits,
    .bulk-limit-form,
    .create-user,
    .create-user-form,
    .created-user-body,
    .system-grid {
        grid-template-columns: 1fr;
    }

    .created-user-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .page {
        width: min(100% - 20px, 1800px);
        margin-top: 12px;
    }
}

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

    .login-hero {
        min-height: 190px;
    }
}
