:root {
    --primary: #42c58a;
    --primary-strong: #63d39f;
    --primary-soft: rgba(66, 197, 138, 0.1);
    --brand: #7c9fc8;
    --brand-strong: #94b2d5;
    --brand-soft: rgba(124, 159, 200, 0.09);
    --brand-border: rgba(124, 159, 200, 0.24);
    --danger: #e66a6a;
    --bg-0: #0f1216;
    --bg-1: #14181d;
    --surface: rgba(255, 255, 255, 0.025);
    --surface-2: rgba(255, 255, 255, 0.045);
    --surface-3: rgba(255, 255, 255, 0.075);
    --border: rgba(255, 255, 255, 0.085);
    --border-strong: rgba(255, 255, 255, 0.14);
    --text-primary: rgba(255, 255, 255, 0.9);
    --text-secondary: rgba(255, 255, 255, 0.66);
    --text-muted: rgba(255, 255, 255, 0.5);
    --radius: 10px;
    --font-sans: "Hanken Grotesk", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "Spline Sans Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg-0); color-scheme: dark; scroll-behavior: smooth; }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.45;
    background: linear-gradient(165deg, var(--bg-1), var(--bg-0) 58%);
    background-attachment: fixed;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; }
code, .mono { font-family: var(--font-mono); }
a:focus-visible, button:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.desktop-topbar {
    min-height: 4.5rem;
    padding: max(0.8rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.8rem max(1rem, env(safe-area-inset-left));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(8, 11, 15, 0.78);
    backdrop-filter: blur(18px);
}
.brand { display: inline-flex; align-items: center; gap: 0.6rem; min-width: 0; }
.brand-mark { width: 38px; height: 28px; object-fit: contain; }
.brand-text { display: grid; line-height: 1; }
.brand-eyebrow {
    color: #1cd685;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.17em;
    text-transform: uppercase;
}
.brand-name {
    margin-top: 0.2rem;
    font-size: 1rem;
    font-weight: 700;
}
.identity-actions { display: flex; align-items: center; gap: 0.45rem; min-width: 0; }
.identity-chip {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2.65rem;
    max-width: 42vw;
    padding: 0.35rem 0.65rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.68);
    background: rgba(255, 255, 255, 0.045);
}
.identity-chip span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity-dot {
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #1cd685;
    box-shadow: 0 0 12px #1cd685;
}
.logout-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.65rem;
    padding: 0.35rem 0.85rem;
    border: 1px solid rgba(229, 179, 100, 0.55);
    border-radius: 999px;
    color: #2b1905;
    background: linear-gradient(135deg, #f2c66f, #e9943f);
    box-shadow: 0 8px 22px rgba(229, 145, 58, 0.18);
    font-weight: 700;
}
.content {
    width: min(1120px, calc(100% - 2rem));
    min-height: calc(100vh - 9rem);
    margin: 0 auto;
    padding: clamp(2rem, 5vw, 4.25rem) 0 3rem;
}
.site-footer {
    display: flex;
    justify-content: flex-start;
    gap: 1rem;
    width: min(1120px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.2rem 0 1.8rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.72rem;
}

.login-shell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 520px;
}
.eyebrow, .card-kicker {
    color: var(--brand-strong);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}
.ready-pill, .verified-badge, .key-ready {
    display: inline-flex;
    align-items: center;
    gap: 0.42rem;
    width: max-content;
    border: 1px solid rgba(66, 197, 138, 0.24);
    border-radius: 6px;
    padding: 0.28rem 0.58rem;
    color: var(--primary-strong);
    background: var(--primary-soft);
    font-size: 0.68rem;
    font-weight: 600;
}
.ready-pill i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}
.glass-card {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(20, 24, 29, 0.82);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.authenticator-logo { display: flex; align-items: center; gap: 0.68rem; position: relative; }
.authenticator-logo img { width: 82px; height: auto; object-fit: contain; object-position: left; }
.authenticator-logo span {
    padding-left: 0.7rem;
    border-left: 1px solid var(--border-strong);
    color: var(--text-secondary);
    font-size: 0.78rem;
    letter-spacing: 0.08em;
}
.login-card-copy { margin: 1.5rem 0 0.5rem; }
.login-card-copy h1 { margin: 0 0 0.4rem; font-size: 1.55rem; letter-spacing: -0.015em; }
.login-card-copy p { margin: 0; color: var(--text-secondary); font-size: 0.88rem; text-align: center; }
.login-card-copy a {
    color: var(--brand-strong);
    text-decoration: underline;
    text-decoration-color: var(--brand-border);
    text-underline-offset: 0.16em;
}
.login-card-copy a:hover { color: var(--text-primary); }
.primary-button, .secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    min-height: 2.75rem;
    border-radius: 7px;
    padding: 0.65rem 1rem;
    cursor: pointer;
    font-weight: 650;
    transition: border-color 0.16s, background 0.16s;
}
.primary-button {
    border: 1px solid #4bcb91;
    color: #08140f;
    background: var(--primary);
}
.primary-button:hover { background: #55ce98; }
.primary-button.compact { min-height: 2.45rem; padding: 0.5rem 0.85rem; font-size: 0.8rem; }
.secondary-button {
    min-height: 2.4rem;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    background: var(--surface-2);
    font-size: 0.78rem;
}
.secondary-button:hover { color: var(--text-primary); border-color: var(--border-strong); background: var(--surface-3); }
[hidden] { display: none !important; }
.auth-dialog {
    position: relative;
    width: min(430px, 100%);
    padding: 1.5rem;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    background: #12161b;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.auth-dialog h2 { margin: 0.4rem 0 0.3rem; font-size: 1.55rem; }
.auth-dialog p { margin: 0 0 1.25rem; color: var(--text-secondary); font-size: 0.84rem; }
.qr-frame {
    position: relative;
    width: min(265px, 78vw);
    aspect-ratio: 1;
    margin: 1.25rem auto;
    padding: 13px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    background: #fff;
}
.qr-frame img { display: block; width: 100%; height: 100%; }
.waiting-status {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.71rem;
}
.waiting-status time { margin-left: auto; font-family: var(--font-mono); }
.pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--brand);
}
.progress-view { padding: 1.6rem 0 1rem; text-align: center; }
.progress-emblem {
    position: relative;
    display: grid;
    place-items: center;
    width: 84px;
    height: 84px;
    margin: 0 auto 1.4rem;
}
.progress-emblem img { width: 38px; }
.progress-ring {
    position: absolute;
    inset: 0;
    border: 1px solid var(--border-strong);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-track {
    height: 8px;
    margin-top: 1.35rem;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.035);
}
.progress-track span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
    transition: width 0.35s ease;
}
.progress-meta { display: flex; justify-content: space-between; margin-top: 0.55rem; color: var(--text-muted); font: 0.69rem var(--font-mono); }
.error-view { padding: 1.6rem 0 0.5rem; text-align: center; }
.error-symbol {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin: 0 auto 1.2rem;
    border: 1px solid rgba(230, 106, 106, 0.4);
    border-radius: 50%;
    color: var(--danger);
    background: rgba(230, 106, 106, 0.08);
    font-size: 1.6rem;
}
.error-view .primary-button { width: 100%; margin-top: 0.5rem; }

.dashboard-hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.4rem;
}
.dashboard-hero h1 { margin: 0.28rem 0 0.25rem; font-size: clamp(1.9rem, 4vw, 2.8rem); line-height: 1.08; letter-spacing: -0.025em; }
.dashboard-hero p { margin: 0; color: var(--text-secondary); }
.hero-actions { display: flex; align-items: center; gap: 0.55rem; padding-top: 0.25rem; }
.dashboard-grid { display: grid; grid-template-columns: 1.35fr 0.85fr; gap: 1rem; }
.profile-card, .session-card, .key-card { padding: 1.1rem; }
.card-header, .key-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 0.9rem;
    border-bottom: 1px solid var(--border);
}
.card-header h2 { margin: 0.15rem 0 0; font-size: 1rem; }
.profile-summary { display: flex; align-items: center; gap: 0.85rem; padding: 1rem 0; }
.avatar {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    object-fit: cover;
    background: var(--brand-soft);
}
.avatar-fallback { color: var(--brand-strong); font-weight: 700; }
.profile-summary > div { display: grid; gap: 0.1rem; }
.profile-summary strong { font-size: 1rem; }
.profile-summary span { color: var(--text-muted); font-size: 0.76rem; }
.identity-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 7px;
    overflow: hidden;
}
.identity-grid div { padding: 0.72rem 0.8rem; border-bottom: 1px solid var(--border); }
.identity-grid div:nth-child(odd) { border-right: 1px solid var(--border); }
.identity-grid div:nth-last-child(-n + 2) { border-bottom: 0; }
.identity-grid dt { margin-bottom: 0.2rem; color: var(--text-muted); font-size: 0.67rem; }
.identity-grid dd { margin: 0; overflow-wrap: anywhere; font-size: 0.8rem; }
.session-lines { display: grid; gap: 0.62rem; padding-top: 0.8rem; }
.session-lines div { display: flex; justify-content: space-between; gap: 1rem; padding-top: 0.62rem; border-top: 1px solid var(--border); font-size: 0.72rem; }
.session-lines span { color: var(--text-muted); }
.session-lines strong { color: var(--text-secondary); font-weight: 500; text-align: right; }

.credentials-section { margin-top: 2.2rem; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 0.9rem; }
.section-heading h2 { margin: 0.2rem 0 0.12rem; font-size: 1.5rem; }
.section-heading p { margin: 0; color: var(--text-muted); font-size: 0.78rem; }
.section-heading code { padding: 0.12rem 0.35rem; border-radius: 5px; background: var(--surface-2); }
.key-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.key-card-header { justify-content: flex-start; }
.key-card-header > div { margin-right: auto; }
.key-card-header h3 { margin: 0.1rem 0 0; font-size: 1rem; }
.key-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--brand-border);
    border-radius: 7px;
    color: var(--brand-strong);
    background: var(--brand-soft);
    font-size: 1.3rem;
}
.key-ready { padding-inline: 0.5rem; }
.key-card > p { min-height: 2.2rem; color: var(--text-secondary); font-size: 0.78rem; }
.file-name, .fingerprint {
    display: grid;
    gap: 0.28rem;
    margin-top: 0.7rem;
}
.file-name span, .fingerprint span { color: var(--text-muted); font-size: 0.66rem; }
.file-name code, .fingerprint code {
    display: block;
    overflow: hidden;
    padding: 0.6rem 0.68rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    background: rgba(7, 10, 14, 0.54);
    font-size: 0.7rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.key-actions { display: flex; gap: 0.45rem; margin-top: 1rem; }
.key-actions .secondary-button { flex: 1 1 auto; }
.icon-button {
    flex: 0 0 2.4rem;
    width: 2.4rem;
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text-secondary);
    background: var(--surface-2);
    cursor: pointer;
}
.icon-button:hover, .icon-button.copied { color: var(--primary); border-color: rgba(66, 197, 138, 0.3); }
.access-recovery {
    width: min(540px, 100%);
    margin: 6vh auto;
    padding: 2rem;
    text-align: center;
}
.access-recovery img { width: 52px; margin-bottom: 1rem; }
.access-recovery h1 { margin: 0.4rem 0; font-size: 1.8rem; }
.access-recovery p { color: var(--text-secondary); }

@media (max-width: 880px) {
    .login-shell { min-height: auto; }
    .dashboard-grid, .key-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .content { width: min(100% - 1.25rem, 1220px); padding-top: 2rem; }
    .site-footer { width: min(100% - 1.25rem, 1220px); flex-direction: column; }
    .auth-dialog { padding: 1.1rem; }
    .dashboard-hero, .section-heading { align-items: stretch; flex-direction: column; }
    .hero-actions { align-items: stretch; flex-direction: column; }
    .identity-grid { grid-template-columns: 1fr; }
    .identity-grid div, .identity-grid div:nth-child(odd), .identity-grid div:nth-last-child(-n + 2) {
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }
    .identity-grid div:last-child { border-bottom: 0; }
    .key-actions { flex-wrap: wrap; }
    .key-actions .secondary-button { flex: 1 1 calc(50% - 0.5rem); }
}
