:root {
    color-scheme: dark;
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    --bg-input: #12122a;
    --border: #2a2a4a;
    --text-primary: #e0e0e0;
    --text-secondary: #888899;
    --text-muted: #66667f;
    --accent-blue: #3498db;
    --accent-blue-hover: #54a9df;
    --accent-green: #1b8a5a;
    --accent-green-hover: #22a66e;
    --accent-red: #c23152;
    --accent-red-hover: #e94560;
    --accent-navy: #0f3460;
    --ui-teal: rgba(64, 214, 198, 0.55);
    --ui-teal-muted: rgba(64, 214, 198, 0.28);
    --ui-teal-faint: rgba(64, 214, 198, 0.06);
    --glass-edge: rgba(255, 255, 255, 0.08);
    --glass-edge-faint: rgba(255, 255, 255, 0.04);
    --glass-surface: linear-gradient(
        165deg,
        rgba(30, 32, 52, 0.94) 0%,
        rgba(22, 24, 42, 0.97) 45%,
        rgba(18, 20, 36, 0.98) 100%
    );
    --radius: 8px;
    --radius-lg: 14px;
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
    font-synthesis: none;
}

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

html {
    min-height: 100%;
    background: var(--bg-primary);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text-primary);
    background:
        radial-gradient(ellipse 120% 80% at 50% -20%, rgba(64, 214, 198, 0.08), transparent 55%),
        radial-gradient(ellipse 90% 60% at 100% 100%, rgba(52, 152, 219, 0.05), transparent 50%),
        var(--bg-primary);
}

button,
input {
    font: inherit;
}

a {
    color: var(--accent-blue-hover);
    text-underline-offset: 3px;
}

a:hover {
    color: #8bc9ef;
}

:focus-visible {
    outline: 2px solid rgba(64, 214, 198, 0.8);
    outline-offset: 2px;
}

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

.auth-card {
    width: min(100%, 440px);
    padding: 38px;
    border: 1px solid var(--glass-edge-faint);
    border-top-color: var(--glass-edge);
    border-radius: var(--radius-lg);
    background: var(--glass-surface);
    box-shadow:
        0 24px 64px rgba(0, 0, 0, 0.45),
        0 0 0 1px var(--ui-teal-faint) inset,
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.auth-brand {
    margin: 0 0 8px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-align: center;
    text-transform: uppercase;
}

.auth-card h1 {
    margin: 0;
    font-size: 1.55rem;
    font-weight: 600;
    text-align: center;
}

.auth-intro {
    margin: 10px 0 26px;
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.55;
    text-align: center;
}

.auth-form {
    display: grid;
    gap: 17px;
}

.field {
    display: grid;
    gap: 7px;
}

.field label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
}

.field input {
    width: 100%;
    min-height: 44px;
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    background: var(--bg-input);
    color: var(--text-primary);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:hover {
    border-color: #3b3b61;
}

.field input:focus {
    border-color: var(--ui-teal-muted);
    box-shadow: 0 0 0 2px var(--ui-teal-faint);
}

.field-hint {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.75rem;
    line-height: 1.45;
}

.password-input {
    position: relative;
}

.password-input input {
    padding-right: 70px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    min-height: 34px;
    padding: 4px 8px;
    transform: translateY(-50%);
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.75rem;
}

.password-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.button {
    min-height: 42px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: #fff;
    cursor: pointer;
    font-weight: 650;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.button:disabled {
    cursor: wait;
    opacity: 0.55;
}

.button-primary {
    background: var(--accent-blue);
}

.button-primary:hover:not(:disabled) {
    background: #2980b9;
}

.button-success {
    background: var(--accent-green);
}

.button-success:hover:not(:disabled) {
    background: var(--accent-green-hover);
}

.button-danger {
    background: var(--accent-red);
}

.button-danger:hover:not(:disabled) {
    background: var(--accent-red-hover);
}

.button-secondary {
    border-color: var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.button-secondary:hover:not(:disabled) {
    border-color: var(--ui-teal-muted);
    background: #1c294b;
}

.button-small {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 0.78rem;
}

.auth-status,
.page-status {
    min-height: 20px;
    margin: 2px 0 0;
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.5;
    text-align: center;
}

.auth-status[data-kind="error"],
.page-status[data-kind="error"] {
    color: #ff8da2;
}

.auth-status[data-kind="success"],
.page-status[data-kind="success"] {
    color: #68d8a2;
}

.auth-status[data-kind="info"],
.page-status[data-kind="info"] {
    color: #7ddfd5;
}

.auth-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin: 22px 0 0;
    font-size: 0.82rem;
}

.auth-secondary {
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.auth-secondary summary {
    cursor: pointer;
    text-align: center;
}

.compact-form {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.process-note {
    margin: 0 0 22px;
    padding: 13px 15px;
    border: 1px solid rgba(64, 214, 198, 0.18);
    border-radius: var(--radius);
    background: rgba(64, 214, 198, 0.055);
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.5;
}

.process-note strong {
    color: var(--text-primary);
}

.hidden {
    display: none !important;
}

/* Standalone administration */
.admin-shell {
    width: min(1220px, calc(100% - 36px));
    margin: 0 auto;
    padding: 26px 0 50px;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
    padding: 18px 20px;
    border: 1px solid var(--glass-edge-faint);
    border-top-color: var(--glass-edge);
    border-radius: var(--radius-lg);
    background: var(--glass-surface);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.26);
}

.admin-title {
    min-width: 0;
}

.admin-title p {
    margin: 0 0 4px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.admin-title h1 {
    margin: 0;
    font-size: clamp(1.35rem, 2.5vw, 1.8rem);
}

.admin-account {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.identity {
    color: var(--text-secondary);
    font-size: 0.82rem;
    text-align: right;
}

.identity strong {
    display: block;
    color: var(--text-primary);
}

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

.admin-card {
    grid-column: span 12;
    min-width: 0;
    padding: 20px;
    border: 1px solid var(--glass-edge-faint);
    border-top-color: var(--glass-edge);
    border-radius: var(--radius-lg);
    background: var(--glass-surface);
    box-shadow:
        0 14px 38px rgba(0, 0, 0, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.admin-card-half {
    grid-column: span 6;
}

.admin-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 9px;
    border-bottom: 1px solid var(--border);
}

.admin-card-header h2 {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.82rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.admin-card-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.collection {
    display: grid;
    gap: 10px;
}

.empty-state,
.loading-state {
    padding: 18px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 0.82rem;
    text-align: center;
}

.record {
    display: grid;
    gap: 10px;
    padding: 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(0, 0, 0, 0.13);
}

.record-main {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.record-title {
    min-width: 0;
    font-size: 0.88rem;
    font-weight: 650;
    overflow-wrap: anywhere;
}

.record-subtitle {
    margin-top: 3px;
    color: var(--text-secondary);
    font-size: 0.76rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.record-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 7px 14px;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.record-meta span {
    overflow-wrap: anywhere;
}

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

.badge {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    min-height: 22px;
    padding: 3px 8px;
    border: 1px solid rgba(52, 152, 219, 0.45);
    border-radius: 999px;
    background: rgba(52, 152, 219, 0.12);
    color: #8bc9ef;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    text-transform: uppercase;
}

.badge[data-state="approved"],
.badge[data-state="active"],
.badge[data-state="completed"] {
    border-color: rgba(27, 138, 90, 0.6);
    background: rgba(27, 138, 90, 0.14);
    color: #68d8a2;
}

.badge[data-state="pending"] {
    border-color: rgba(64, 214, 198, 0.4);
    background: rgba(64, 214, 198, 0.1);
    color: #7ddfd5;
}

.badge[data-state="disabled"],
.badge[data-state="rejected"],
.badge[data-state="failed"] {
    border-color: rgba(194, 49, 82, 0.6);
    background: rgba(194, 49, 82, 0.14);
    color: #ff8da2;
}

.invite-form {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.invite-form .field {
    flex: 1 1 180px;
}

.one-time-code {
    margin-bottom: 14px;
    padding: 13px;
    border: 1px solid rgba(64, 214, 198, 0.3);
    border-radius: var(--radius);
    background: rgba(64, 214, 198, 0.07);
}

.one-time-code p {
    margin: 0 0 9px;
    color: var(--text-secondary);
    font-size: 0.78rem;
    line-height: 1.45;
}

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

.code-row code {
    flex: 1;
    min-width: 0;
    padding: 9px 10px;
    border-radius: 6px;
    background: var(--bg-primary);
    color: #a5eee7;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    overflow-wrap: anywhere;
    user-select: all;
}

@media (max-width: 760px) {
    .admin-card-half {
        grid-column: span 12;
    }

    .admin-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .admin-account {
        width: 100%;
        justify-content: space-between;
    }

    .identity {
        text-align: left;
    }
}

@media (max-width: 480px) {
    .auth-shell {
        align-items: start;
        padding: 18px 12px;
    }

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

    .admin-shell {
        width: min(100% - 20px, 1220px);
        padding-top: 10px;
    }

    .admin-card,
    .admin-header {
        padding: 16px;
    }

    .record-main {
        align-items: flex-start;
        flex-direction: column;
    }

    .button {
        min-height: 44px;
    }
}

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