/* MoiTrack dashboard styles.
   No inline styles anywhere: the Content-Security-Policy forbids them.
   Light and dark themes follow the device setting. */

:root {
    --bg: #f2f5f9;
    --bg-glow-1: rgba(20, 149, 139, 0.10);
    --bg-glow-2: rgba(37, 99, 235, 0.08);
    --surface: #ffffff;
    --surface-2: #f7f9fc;
    --surface-3: #eef2f7;
    --border: #e2e7ee;
    --border-strong: #c9d1dc;
    --text: #141d28;
    --muted: #5d6b7b;
    --brand: #0f766e;
    --brand-strong: #0a5a54;
    --brand-soft: #dff4f1;
    --brand-grad: linear-gradient(135deg, #12a195 0%, #0f7f8a 48%, #1d5fd1 100%);
    --on-brand: #ffffff;
    --danger: #b9342a;
    --danger-soft: #fdebe9;
    --warn: #8a4f05;
    --warn-soft: #fcf0d6;
    --ok: #18703a;
    --ok-soft: #e0f5e7;
    --info: #1a579b;
    --info-soft: #e2eefc;
    --sidebar-grad: linear-gradient(180deg, #0c1a27 0%, #0f2233 55%, #0d2a36 100%);
    --sidebar-text: #c2cfdb;
    --sidebar-muted: #8195a7;
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --sidebar-active: rgba(45, 196, 182, 0.16);
    --sidebar-accent: #2dd4bf;
    --focus: #2563eb;
    --focus-ring: rgba(37, 99, 235, 0.22);
    --radius: 14px;
    --radius-sm: 9px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 14px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.06);
    --topbar-bg: rgba(242, 245, 249, 0.82);
    --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1219;
        --bg-glow-1: rgba(45, 212, 191, 0.07);
        --bg-glow-2: rgba(59, 130, 246, 0.07);
        --surface: #141e29;
        --surface-2: #192531;
        --surface-3: #1f2d3b;
        --border: #263442;
        --border-strong: #384a5c;
        --text: #e7edf3;
        --muted: #97a6b6;
        --brand: #34c3b6;
        --brand-strong: #5ad6ca;
        --brand-soft: #10383a;
        --brand-grad: linear-gradient(135deg, #1fb5a8 0%, #1791a0 48%, #3b7df0 100%);
        --on-brand: #ffffff;
        --danger: #f2857b;
        --danger-soft: #3b1b18;
        --warn: #ecb962;
        --warn-soft: #382a0f;
        --ok: #74d493;
        --ok-soft: #13321f;
        --info: #86bbf3;
        --info-soft: #142b44;
        --sidebar-grad: linear-gradient(180deg, #070d13 0%, #0a141d 55%, #0a1a20 100%);
        --focus: #7fb0ff;
        --focus-ring: rgba(127, 176, 255, 0.25);
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 18px rgba(0, 0, 0, 0.28);
        --shadow-lg: 0 14px 36px rgba(0, 0, 0, 0.5);
        --topbar-bg: rgba(11, 18, 25, 0.8);
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background-color: var(--bg);
    background-image:
        radial-gradient(900px 480px at 100% -10%, var(--bg-glow-2), transparent 70%),
        radial-gradient(760px 420px at 20% -15%, var(--bg-glow-1), transparent 70%);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, dl, dd, ol, ul {
    margin: 0;
}

a {
    color: var(--brand);
    text-underline-offset: 2px;
}

a:hover {
    color: var(--brand-strong);
}

code {
    font-family: var(--mono);
    font-size: 0.9em;
    background: var(--surface-3);
    border-radius: 6px;
    padding: 2px 6px;
}

::selection {
    background: color-mix(in srgb, var(--brand) 28%, transparent);
}

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

[hidden] {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: 8px;
    top: -60px;
    z-index: 100;
    background: var(--surface);
    color: var(--text);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
}

.skip-link:focus {
    top: 8px;
}

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

.small {
    font-size: 12px;
}

.nowrap {
    white-space: nowrap;
}

.icon {
    flex: none;
    vertical-align: middle;
}

/* ---------- App shell ---------- */

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

.sidebar {
    position: sticky;
    top: 0;
    flex: none;
    display: flex;
    flex-direction: column;
    width: 248px;
    height: 100vh;
    padding: 18px 14px 14px;
    background: var(--sidebar-grad);
    color: var(--sidebar-text);
    overflow-y: auto;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 4px 8px 22px;
    color: #ffffff;
    text-decoration: none;
}

.brand:hover {
    color: #ffffff;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: var(--brand-grad);
    color: #ffffff;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18px;
    box-shadow: 0 6px 16px rgba(18, 161, 149, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.brand-name {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 650;
    letter-spacing: 0.2px;
}

.nav-label {
    padding: 0 12px 6px;
    color: var(--sidebar-muted);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.9px;
    text-transform: uppercase;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--sidebar-text);
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
    background: var(--sidebar-hover);
    color: #ffffff;
}

.nav-link.is-active {
    background: var(--sidebar-active);
    color: #ffffff;
    font-weight: 600;
}

.nav-link.is-active::before {
    content: "";
    position: absolute;
    left: -14px;
    top: 9px;
    bottom: 9px;
    width: 4px;
    border-radius: 0 4px 4px 0;
    background: var(--sidebar-accent);
    box-shadow: 0 0 12px rgba(45, 212, 191, 0.7);
}

.nav-link.is-active .icon {
    color: var(--sidebar-accent);
}

.nav-link:focus-visible {
    outline-color: #9cc4ff;
}

.sidebar-foot {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sidebar-foot form {
    margin: 0;
}

.whoami {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 4px 8px 12px;
    min-width: 0;
}

.whoami-text {
    min-width: 0;
}

.whoami-name {
    color: #ffffff;
    font-weight: 600;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.whoami-role {
    color: var(--sidebar-muted);
    font-size: 12.5px;
}

.avatar {
    flex: none;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--brand-grad);
    color: #ffffff;
    font-weight: 650;
    font-size: 14px;
    letter-spacing: 0.4px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.avatar-sm {
    width: 30px;
    height: 30px;
    font-size: 12px;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(6, 12, 18, 0.55);
    backdrop-filter: blur(2px);
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 32px;
    background: var(--topbar-bg);
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

.page-title {
    font-family: var(--font-display);
    font-size: 23px;
    font-weight: 650;
    line-height: 1.25;
    letter-spacing: -0.2px;
}

.topbar-spacer {
    flex: 1;
}

.topbar-date {
    color: var(--muted);
    font-size: 13.5px;
    white-space: nowrap;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 4px 12px 4px 4px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.user-chip:hover {
    color: var(--text);
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
}

.menu-toggle {
    display: none;
}

.icon-button {
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.content {
    flex: 1;
    width: 100%;
    max-width: 1220px;
    padding: 24px 32px 32px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    animation: rise 0.28s ease both;
}

/* Movement only, never opacity: the page must stay readable even if an animation is paused. */
@keyframes rise {
    from {
        transform: translateY(8px);
    }
    to {
        transform: none;
    }
}

.footer {
    padding: 14px 32px 22px;
    color: var(--muted);
    font-size: 12.5px;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

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

.breadcrumb a {
    text-decoration: none;
    font-weight: 600;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

/* ---------- Stat tiles ---------- */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
    gap: 16px;
}

.stat {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 18px 20px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.stat::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--brand-grad);
}

.stat:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-ok::before {
    background: var(--ok);
}

.stat-warn::before {
    background: #e0a020;
}

.stat-neutral::before {
    background: var(--border-strong);
}

.stat-label {
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 650;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 650;
    line-height: 1.15;
    letter-spacing: -0.5px;
}

.stat-sub {
    color: var(--muted);
    font-size: 13.5px;
}

/* ---------- Cards and grids ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 13px;
    min-width: 0;
}

.card-flush {
    padding: 0;
    overflow: hidden;
}

.card-flush > .card-head {
    padding: 16px 22px 0;
}

.card-narrow {
    max-width: 580px;
}

.card-danger {
    border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
    background: linear-gradient(180deg, color-mix(in srgb, var(--danger-soft) 55%, var(--surface)) 0, var(--surface) 70px);
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-title {
    font-family: var(--font-display);
    font-size: 16.5px;
    font-weight: 650;
    letter-spacing: -0.1px;
}

.card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
}

.grid {
    display: grid;
    gap: 18px;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 350px), 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
}

.kv {
    display: grid;
    grid-template-columns: minmax(120px, max-content) 1fr;
    gap: 9px 20px;
    align-items: baseline;
}

.kv dt {
    color: var(--muted);
}

.kv dd {
    min-width: 0;
    overflow-wrap: anywhere;
}

.note {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--brand);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--muted);
    font-size: 14px;
}

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

/* ---------- Badges and alerts ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 650;
    line-height: 1.5;
    white-space: nowrap;
    vertical-align: baseline;
}

.badge-ok,
.badge-warn,
.badge-danger,
.badge-info {
    padding-left: 8px;
}

.badge-ok::before,
.badge-warn::before,
.badge-danger::before,
.badge-info::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge-ok {
    background: var(--ok-soft);
    color: var(--ok);
}

.badge-warn {
    background: var(--warn-soft);
    color: var(--warn);
}

.badge-danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.badge-info,
.badge-role-admin {
    background: var(--info-soft);
    color: var(--info);
}

.badge-role-owner {
    background: var(--brand-soft);
    color: var(--brand-strong);
}

.alert {
    border-radius: var(--radius-sm);
    border-left: 4px solid transparent;
    padding: 11px 16px;
    font-weight: 500;
    overflow-wrap: anywhere;
    box-shadow: var(--shadow-sm);
}

.alert-success {
    background: var(--ok-soft);
    border-left-color: var(--ok);
    color: var(--ok);
}

.alert-error {
    background: var(--danger-soft);
    border-left-color: var(--danger);
    color: var(--danger);
}

.alert-info {
    background: var(--info-soft);
    border-left-color: var(--info);
    color: var(--info);
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    line-height: 1.3;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.08s ease, filter 0.15s ease;
}

.btn:hover {
    background: var(--surface-2);
    border-color: color-mix(in srgb, var(--brand) 45%, var(--border-strong));
    color: var(--text);
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: var(--brand-grad);
    border-color: transparent;
    color: var(--on-brand);
    box-shadow: 0 4px 14px rgba(15, 127, 138, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-primary:hover {
    background: var(--brand-grad);
    border-color: transparent;
    color: var(--on-brand);
    filter: brightness(1.07);
    box-shadow: 0 6px 20px rgba(15, 127, 138, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-danger {
    background: var(--surface);
    border-color: color-mix(in srgb, var(--danger) 60%, var(--border));
    color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #ffffff;
}

.btn-quiet {
    border-color: transparent;
    background: transparent;
    color: var(--brand);
    box-shadow: none;
}

.btn-quiet:hover {
    background: var(--brand-soft);
    border-color: transparent;
    color: var(--brand-strong);
}

.btn-link {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--brand);
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 2px;
    box-shadow: none;
}

.btn-link:hover {
    background: transparent;
    color: var(--brand-strong);
}

.btn-block {
    width: 100%;
    padding-top: 11px;
    padding-bottom: 11px;
}

.btn:disabled,
.btn.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    filter: none;
}

/* ---------- Forms ---------- */

.form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 0;
}

.form-row {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
}

.form-row .field {
    flex: 1 1 240px;
    max-width: 360px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.field-grow {
    flex: 1 1 200px;
}

label {
    font-weight: 600;
    font-size: 14px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    line-height: 1.4;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder,
textarea::placeholder {
    color: color-mix(in srgb, var(--muted) 70%, transparent);
}

textarea {
    resize: vertical;
    min-height: 90px;
}

input:hover,
select:hover,
textarea:hover {
    border-color: color-mix(in srgb, var(--brand) 40%, var(--border-strong));
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none;
    border-color: var(--focus);
    box-shadow: 0 0 0 4px var(--focus-ring);
}

input:disabled,
select:disabled {
    background: var(--surface-3);
    border-color: var(--border);
    color: var(--muted);
}

.input-mono {
    font-family: var(--mono);
}

.input-code {
    font-family: var(--mono);
    font-size: 26px;
    font-weight: 600;
    letter-spacing: 8px;
    text-align: center;
    padding: 12px 10px;
}

.input-group {
    display: flex;
    gap: 6px;
    align-items: stretch;
}

.input-group input {
    flex: 1;
    min-width: 0;
}

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

.field-error {
    color: var(--danger);
    font-size: 13.5px;
    font-weight: 600;
}

.has-error input,
.has-error select,
.has-error textarea {
    border-color: var(--danger);
}

.check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-weight: 500;
    font-size: 15px;
    cursor: pointer;
}

.check input {
    width: 18px;
    height: 18px;
    margin: 3px 0 0;
    accent-color: var(--brand);
    flex: none;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 0;
}

.form-inline-center {
    display: flex;
    justify-content: center;
    margin: 14px 0 0;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin: 0;
}

.filters .field {
    flex: 0 1 170px;
}

.filters .field-grow {
    flex: 1 1 200px;
}

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

/* ---------- Tables ---------- */

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

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14.5px;
}

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

.table th:first-child,
.table td:first-child {
    padding-left: 22px;
}

.table th {
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    white-space: nowrap;
}

.table tbody tr {
    transition: background-color 0.12s ease;
}

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

.table tbody tr:hover {
    background: color-mix(in srgb, var(--brand-soft) 45%, transparent);
}

.table tr.is-muted td {
    color: var(--muted);
}

.row-link {
    font-weight: 600;
    text-decoration: none;
}

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

.cell-user {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

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

.cell-details {
    min-width: 220px;
    max-width: 460px;
    overflow-wrap: anywhere;
    font-size: 13.5px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

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

/* ---------- Sign-in pages ---------- */

.auth-body {
    position: relative;
    display: grid;
    place-items: start center;
    min-height: 100vh;
    padding: 7vh 16px 32px;
    overflow-x: hidden;
    background-color: #0c1a27;
    background-image:
        radial-gradient(700px 520px at 12% 8%, rgba(18, 161, 149, 0.55), transparent 65%),
        radial-gradient(760px 560px at 92% 18%, rgba(29, 95, 209, 0.5), transparent 65%),
        radial-gradient(900px 600px at 50% 110%, rgba(13, 148, 136, 0.35), transparent 70%),
        linear-gradient(160deg, #0b1724 0%, #0f2233 50%, #0b2530 100%);
    background-attachment: fixed;
}

.auth-wrap {
    position: relative;
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: rise 0.35s ease both;
}

.auth-wrap-wide {
    max-width: 920px;
}

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #ffffff;
}

.auth-brand .brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 13px;
    font-size: 22px;
}

.auth-brand .brand-name {
    font-size: 24px;
}

.auth-card {
    background: var(--surface);
    border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(3, 10, 18, 0.45), 0 2px 8px rgba(3, 10, 18, 0.2);
    padding: 30px 30px 26px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.auth-title {
    font-family: var(--font-display);
    font-size: 23px;
    font-weight: 650;
    letter-spacing: -0.2px;
}

.auth-foot {
    color: rgba(255, 255, 255, 0.72);
    font-size: 12.5px;
    text-align: center;
}

.hint {
    color: var(--muted);
    font-size: 13.5px;
    text-align: center;
}

.steps {
    padding-left: 22px;
    display: flex;
    flex-direction: column;
    gap: 13px;
}

.steps li::marker {
    color: var(--brand);
    font-weight: 700;
}

.qr {
    width: 228px;
    max-width: 100%;
    margin: 14px auto 8px;
    padding: 12px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    line-height: 0;
}

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

.manual-key {
    font-size: 14px;
    color: var(--muted);
}

.manual-key summary {
    cursor: pointer;
    color: var(--brand);
    font-weight: 600;
}

.manual-key p {
    margin: 8px 0;
}

.copy-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.secret {
    font-size: 15px;
    padding: 7px 11px;
    color: var(--text);
    overflow-wrap: anywhere;
}

.error-code {
    font-family: var(--font-display);
    font-size: 54px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -1px;
    background: var(--brand-grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.error-detail {
    margin: 0;
    padding: 12px;
    max-height: 420px;
    overflow: auto;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--mono);
    font-size: 12.5px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* ---------- Small screens ---------- */

@media (max-width: 860px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 40;
        width: min(86vw, 290px);
        transform: translateX(-105%);
        transition: transform 0.2s ease;
    }

    .sidebar.is-open {
        transform: translateX(0);
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
    }

    .menu-toggle {
        display: inline-flex;
    }

    .topbar {
        padding: 12px 16px;
    }

    .topbar-date,
    .user-chip-name {
        display: none;
    }

    .user-chip {
        padding: 3px;
    }

    .page-title {
        font-size: 19px;
    }

    .content {
        padding: 16px 16px 24px;
    }

    .footer {
        padding: 12px 16px 18px;
    }

    .card {
        padding: 16px;
    }

    .kv {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    .kv dd {
        margin-bottom: 9px;
    }

    .stat-value {
        font-size: 26px;
    }

    .auth-card {
        padding: 22px 20px 20px;
    }

    /* Comfortable touch targets on phones. */
    .btn,
    .nav-link,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="search"],
    select {
        min-height: 44px;
    }

    .btn-link {
        min-height: 0;
    }

    /* 16px stops iOS from zooming in when a field is tapped. */
    input,
    select,
    textarea {
        font-size: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}

@media print {
    .sidebar,
    .topbar,
    .footer,
    .menu-toggle {
        display: none !important;
    }

    body {
        background: #ffffff;
    }

    .card,
    .stat {
        box-shadow: none;
    }
}
