:root {
    --bg: #020617;
    --surface: #0F172A;
    --surface-2: #1E293B;
    --text: #F8FAFC;
    --muted: #94A3B8;
    --border: #1E293B;
    --accent: #2563EB;
    --success: #16A34A;
    --warning: #F59E0B;
    --radius: 18px;
    --radius-lg: 24px;
    --font: Manrope, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html,
body {
    min-height: 100%;
    margin: 0;
    background:
        radial-gradient(circle at 50% -20%, rgba(37, 99, 235, .18), transparent 32%),
        var(--bg);
    color: var(--text);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
}

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

button,
input,
select,
textarea {
    font: inherit;
}

.app-shell {
    width: min(100%, 430px);
    min-height: 100dvh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    border-left: 1px solid rgba(148, 163, 184, .12);
    border-right: 1px solid rgba(148, 163, 184, .12);
    background: var(--bg);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 60px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(2, 6, 23, .9);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(18px);
}

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

.brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    display: inline-grid;
    place-items: center;
    background: #F8FAFC;
    color: #0F172A;
    font-weight: 800;
}

.brand strong,
.brand small {
    display: block;
}

.brand strong { font-size: 15px; }
.brand small { color: var(--muted); font-size: 11px; margin-top: 2px; }

.mode-pill {
    border-radius: 999px;
    padding: 6px 10px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.page {
    flex: 1;
    padding: 16px 16px 92px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.page-centered {
    justify-content: center;
    padding-bottom: 28px;
}

.bottom-nav {
    position: fixed;
    left: 50%;
    bottom: 0;
    width: min(100%, 430px);
    transform: translateX(-50%);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom, 0px));
    background: rgba(2, 6, 23, .94);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(18px);
}

.bottom-nav a {
    min-height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.bottom-nav a.active {
    background: rgba(248, 250, 252, .08);
    color: var(--text);
}

.card {
    background: rgba(15, 23, 42, .92);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .03);
}

.hero {
    padding: 20px;
}

.eyebrow {
    display: block;
    color: #93C5FD;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 8px;
    font-size: 28px;
    line-height: 1.1;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 0;
    font-size: 16px;
}

p,
.muted {
    color: var(--muted);
    line-height: 1.5;
}

.primary-action,
.button {
    min-height: 50px;
    border: 0;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 18px;
    background: #F8FAFC;
    color: #0F172A;
    font-weight: 800;
    cursor: pointer;
}

.button-large {
    min-height: 56px;
    font-size: 15px;
}

.button.secondary {
    background: var(--surface-2);
    color: var(--text);
}

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

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

.section-head a {
    color: #60A5FA;
    font-size: 13px;
    font-weight: 800;
}

.list-card strong,
.list-card small {
    display: block;
}

.list-card strong {
    font-size: 15px;
    margin-bottom: 4px;
}

.list-card small {
    color: var(--muted);
    font-size: 12px;
}

.list-card b {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.empty,
.soft-note {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.error-note {
    color: #FBBF24;
    border-color: rgba(245, 158, 11, .35);
    background: rgba(245, 158, 11, .08);
    font-size: 13px;
    line-height: 1.5;
}

.form {
    display: grid;
    gap: 14px;
    border-radius: var(--radius-lg);
}

label {
    display: grid;
    gap: 7px;
    color: #CBD5E1;
    font-size: 12px;
    font-weight: 800;
}

.field-group {
    display: grid;
    gap: 8px;
}

.field-label {
    color: #CBD5E1;
    font-size: 12px;
    font-weight: 800;
}

.direction-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.choice-card {
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(30, 41, 59, .62);
    padding: 13px;
    display: grid;
    gap: 5px;
    cursor: pointer;
}

.choice-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.choice-card:has(input:checked) {
    border-color: rgba(37, 99, 235, .7);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .16);
}

.choice-card span {
    font-size: 13px;
    color: var(--text);
}

.choice-card small {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
}

input,
select,
textarea {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-2);
    color: var(--text);
    padding: 0 13px;
    outline: none;
}

textarea {
    min-height: 92px;
    padding-top: 12px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .18);
}

.summary dl {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 0;
}

.summary dt {
    color: var(--muted);
    font-size: 12px;
}

.summary dd {
    margin: 0;
    text-align: right;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.timeline {
    display: grid;
    gap: 12px;
}

.timeline-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
}

.timeline-row span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.timeline-row.active {
    color: var(--text);
}

.timeline-row.active span {
    background: var(--accent);
    box-shadow: 0 0 0 5px rgba(37, 99, 235, .18);
}

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

.message {
    width: fit-content;
    max-width: 86%;
    padding: 11px 13px;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    line-height: 1.45;
}

.message.user {
    margin-left: auto;
    background: #F8FAFC;
    color: #0F172A;
}

.message small {
    display: block;
    margin-top: 6px;
    opacity: .65;
    font-size: 10px;
}

.login-shell {
    display: grid;
    gap: 14px;
    text-align: center;
    padding: 22px 2px;
}

.login-shell.is-authenticating {
    opacity: .72;
    pointer-events: none;
}

.login-mark {
    width: 70px;
    height: 70px;
    margin: 0 auto 4px;
    border-radius: 20px;
    display: grid;
    place-items: center;
    background: #F8FAFC;
    color: #0F172A;
    font-size: 30px;
    font-weight: 900;
    box-shadow: 0 18px 42px rgba(37, 99, 235, .18);
}

.login-shell h1 {
    font-size: 32px;
    margin-bottom: 0;
}

.login-shell p {
    margin-bottom: 0;
}

.login-note {
    font-size: 12px;
}

@media (max-width: 380px) {
    .direction-grid {
        grid-template-columns: 1fr;
    }
}

.composer {
    display: flex;
    gap: 8px;
}

.composer input {
    flex: 1;
    border-radius: 999px;
}

.composer button {
    border: 0;
    border-radius: 999px;
    padding: 0 14px;
    background: #F8FAFC;
    color: #0F172A;
    font-weight: 800;
}

.admin-shell {
    min-height: 100dvh;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    background:
        radial-gradient(circle at 70% -10%, rgba(37, 99, 235, .16), transparent 30%),
        var(--bg);
}

.admin-sidebar {
    position: sticky;
    top: 0;
    height: 100dvh;
    padding: 18px;
    border-right: 1px solid var(--border);
    background: rgba(2, 6, 23, .9);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.admin-brand {
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.admin-nav {
    display: grid;
    gap: 6px;
}

.admin-nav a,
.admin-logout button {
    width: 100%;
    min-height: 42px;
    border: 0;
    border-radius: 12px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.admin-nav a.active,
.admin-nav a:hover,
.admin-logout button:hover {
    background: rgba(248, 250, 252, .08);
    color: var(--text);
}

.admin-logout {
    margin-top: auto;
}

.admin-main {
    min-width: 0;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.admin-topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.admin-topbar h1 {
    margin: 0;
    font-size: 30px;
}

.admin-auth {
    width: min(100%, 420px);
    margin: min(10vh, 80px) auto;
    padding: 26px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: rgba(15, 23, 42, .92);
    display: grid;
    gap: 14px;
    text-align: center;
}

.admin-alert {
    border: 1px solid rgba(22, 163, 74, .35);
    border-radius: 14px;
    padding: 12px 14px;
    background: rgba(22, 163, 74, .1);
    color: #BBF7D0;
    font-size: 13px;
    font-weight: 700;
}

.admin-alert.error {
    border-color: rgba(245, 158, 11, .35);
    background: rgba(245, 158, 11, .1);
    color: #FDE68A;
}

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

.admin-metric,
.admin-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(15, 23, 42, .92);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .03);
}

.admin-metric {
    padding: 16px;
    display: grid;
    gap: 10px;
}

.admin-metric span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.admin-metric strong {
    font-size: 28px;
    font-variant-numeric: tabular-nums;
}

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

.admin-panel {
    padding: 16px;
    min-width: 0;
}

.admin-panel h2 {
    margin-bottom: 12px;
}

.admin-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
    font-size: 13px;
}

.admin-table th {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
}

.admin-table a {
    color: #93C5FD;
    font-weight: 800;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 999px;
    padding: 0 10px;
    background: rgba(37, 99, 235, .14);
    color: #BFDBFE;
    font-size: 11px;
    font-weight: 800;
}

.admin-dl {
    display: grid;
    grid-template-columns: minmax(110px, .7fr) minmax(0, 1.3fr);
    gap: 10px 14px;
    margin: 0;
}

.admin-dl dt {
    color: var(--muted);
    font-size: 12px;
}

.admin-dl dd {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
    font-weight: 800;
}

.admin-row {
    min-height: 48px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.admin-row span {
    color: var(--muted);
    font-size: 12px;
}

.admin-thread .message.admin {
    margin-left: auto;
    background: #F8FAFC;
    color: #0F172A;
}

.bot-preview {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px;
    background: rgba(2, 6, 23, .4);
}

.bot-preview p {
    margin: 10px 0;
}

.bot-preview span {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    border-radius: 12px;
    padding: 0 12px;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
}

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

    .admin-sidebar {
        position: static;
        height: auto;
        padding: 12px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .admin-nav {
        display: flex;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .admin-nav a {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .admin-logout {
        margin-top: 0;
    }

    .admin-main {
        padding: 16px;
    }

    .admin-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .admin-grid,
    .admin-detail {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 520px) {
    .admin-topbar {
        display: grid;
    }

    .admin-metrics {
        grid-template-columns: 1fr;
    }

    .admin-auth {
        margin: 16px auto;
        border-radius: 18px;
    }
}
