:root {
    color-scheme: light;
    --bg: #f3f5f9;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #111827;
    --muted: #6b7280;
    --primary: #111827;
    --primary-soft: #e5e7eb;
    --border: #e5e7eb;
    --success: #047857;
    --success-bg: #ecfdf5;
    --danger: #b91c1c;
    --danger-bg: #fef2f2;
    --shadow: 0 24px 60px rgba(15, 23, 42, .12);
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    min-height: 100%;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top right, rgba(99, 102, 241, .08), transparent 34rem),
        var(--bg);
}

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

button, input { font: inherit; }

.app-shell { min-height: 100vh; }

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

.auth-card {
    width: 100%;
    max-width: 430px;
    padding: 28px;
    background: rgba(255, 255, 255, .96);
    border: 1px solid rgba(255, 255, 255, .9);
    border-radius: 28px;
    box-shadow: var(--shadow);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 19px;
    letter-spacing: -.03em;
}

.brand-mark {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--primary);
    border-radius: 13px;
    font-weight: 800;
}

.brand-small .brand-mark { width: 34px; height: 34px; border-radius: 11px; }

.auth-heading { margin: 30px 0 22px; }
.auth-heading h1 { margin: 0 0 8px; font-size: clamp(27px, 7vw, 36px); letter-spacing: -.04em; }
.auth-heading p, .welcome p, .section-heading p, .empty-state p, .profile-card p {
    margin: 0; color: var(--muted); line-height: 1.55;
}

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

.field { display: grid; gap: 8px; }
.field > span { font-weight: 700; font-size: 14px; }
.field small { color: var(--muted); line-height: 1.4; }

.field input {
    width: 100%;
    min-height: 52px;
    padding: 0 15px;
    color: var(--text);
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 15px;
    outline: none;
    transition: .2s ease;
}

.field input:focus {
    background: #fff;
    border-color: #9ca3af;
    box-shadow: 0 0 0 4px rgba(17, 24, 39, .06);
}

.btn {
    min-height: 50px;
    padding: 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 15px;
    font-weight: 800;
    cursor: pointer;
}

.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { color: #fff; background: var(--primary); }
.btn-secondary { color: var(--text); background: var(--primary-soft); }

.alert {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 15px;
    line-height: 1.5;
    font-size: 14px;
}
.alert-success { color: var(--success); background: var(--success-bg); }
.alert-error { color: var(--danger); background: var(--danger-bg); }

.auth-switch { margin: 22px 0 0; text-align: center; color: var(--muted); }
.auth-switch a { color: var(--text); font-weight: 800; }
.captcha-wrap { overflow-x: auto; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 70px;
    padding: max(14px, env(safe-area-inset-top)) 18px 12px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    background: rgba(243, 245, 249, .88);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(229, 231, 235, .8);
}
.topbar .brand { justify-self: start; }
.topbar .avatar { justify-self: end; }
.back-link { justify-self: start; color: var(--muted); font-weight: 700; }

.avatar, .profile-avatar {
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--primary);
    border-radius: 50%;
    font-weight: 800;
}
.avatar { width: 40px; height: 40px; }

.dashboard-page {
    width: min(100%, 900px);
    margin: 0 auto;
    padding: 28px 18px calc(110px + env(safe-area-inset-bottom));
}

.welcome h1 { margin: 4px 0 0; font-size: 34px; letter-spacing: -.04em; }

.status-card, .profile-card, .settings-list, .empty-state {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
}

.status-card { margin-top: 24px; padding: 20px; }
.status-card > div { display: flex; align-items: center; gap: 9px; }
.status-card p { margin: 9px 0 0; color: var(--muted); }

.status-dot {
    width: 10px;
    height: 10px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 0 5px rgba(16, 185, 129, .12);
}

.section-heading {
    margin: 30px 0 16px;
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
}
.section-heading h2 { margin: 0 0 5px; font-size: 22px; }

.empty-state { padding: 42px 24px; text-align: center; }
.empty-state h3 { margin: 15px 0 7px; }
.empty-icon {
    width: 64px; height: 64px; margin: auto; display: grid; place-items: center;
    background: var(--surface-soft); border-radius: 20px; font-size: 31px;
}

.bottom-nav {
    position: fixed;
    z-index: 20;
    left: 50%;
    bottom: max(12px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: calc(100% - 24px);
    max-width: 560px;
    padding: 9px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: rgba(17, 24, 39, .94);
    backdrop-filter: blur(18px);
    border-radius: 22px;
    box-shadow: 0 18px 40px rgba(17, 24, 39, .25);
}
.bottom-nav a {
    min-height: 56px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 3px;
    color: #9ca3af;
    border-radius: 15px;
}
.bottom-nav a.active { color: #fff; background: rgba(255, 255, 255, .1); }
.bottom-nav span { font-size: 20px; }
.bottom-nav small { font-size: 11px; font-weight: 700; }

.profile-card { padding: 22px; display: flex; align-items: center; gap: 15px; }
.profile-avatar { width: 58px; height: 58px; font-size: 22px; }
.profile-card h1 { margin: 0 0 5px; font-size: 21px; }

.settings-list { margin-top: 18px; overflow: hidden; }
.settings-row {
    min-height: 58px;
    padding: 0 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: 0; }
.settings-row strong { font-size: 14px; }
.settings-row.danger { color: var(--danger); }

.install-note {
    margin-bottom: 18px;
    padding: 14px 16px;
    background: var(--surface-soft);
    border-radius: 15px;
}
.install-note p { margin: 6px 0 0; color: var(--muted); line-height: 1.5; }
code { word-break: break-all; }

@media (min-width: 760px) {
    .dashboard-page { padding-left: 30px; padding-right: 30px; }
    .auth-card { padding: 36px; }
}
