:root {
    --bg: #f5f0e3;
    --surface: #fffaf0;
    --surface-2: #f0e9d9;
    --text: #211d15;
    --muted: #6f6655;
    --line: #ded2ba;
    --brand: #2d6fff;
    --brand-strong: #0b5fff;
    --brand-ink: #ffffff;
    --accent: #fc5b22;
    --chat-bg: #faf4e7;
    --chat-user: #ced9fd;
    --usage: #1a9e54;
    --warn: #d99614;
    --danger: #c93a4b;
    --ok: #1a7f37;
    --radius: 12px;
    --shadow: 0 10px 30px rgba(22, 28, 45, .08);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
html[data-theme="dark"] {
    --bg: #20242b;
    --surface: #272c33;
    --surface-2: #303740;
    --text: #ebe6da;
    --muted: #aaa395;
    --line: #3b434d;
    --chat-bg: #23282f;
    --shadow: 0 10px 30px rgba(0, 0, 0, .30);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .6rem; line-height: 1.2; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.15rem; }
p { line-height: 1.55; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.app-body { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: .7rem 1.2rem; background: var(--surface); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 20;
}
.brand { display: inline-flex; align-items: center; gap: .55rem; color: var(--text); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-mark {
    display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
    background: var(--brand); color: var(--brand-ink); font-size: .78rem; letter-spacing: .04em;
}
.topnav { display: flex; gap: 1rem; align-items: center; font-size: .92rem; }
.page { width: min(1120px, 100%); margin: 0 auto; padding: 1.4rem; flex: 1; }
.footer {
    display: flex; gap: .5rem; justify-content: center; padding: 1rem; color: var(--muted);
    font-size: .82rem; border-top: 1px solid var(--line); background: var(--surface);
}
.card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1.2rem;
}
.card + .card { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.row { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.field { display: flex; flex-direction: column; gap: .35rem; }
.field label { font-size: .84rem; color: var(--muted); font-weight: 600; }
input, select, textarea {
    width: 100%; padding: .62rem .7rem; border: 1px solid var(--line); border-radius: 9px;
    background: var(--surface); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .62rem .95rem; border-radius: 9px; border: 1px solid transparent;
    background: var(--brand-strong); color: var(--brand-ink); font-weight: 650; font-size: .9rem;
    cursor: pointer;
}
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.btn.secondary { background: #fff; color: #1c1c1e; border-color: #cfd3da; }
.btn.buy { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.success { background: #157347; border-color: #157347; color: #fff; }
.btn.danger { background: var(--danger); }
.btn.small { padding: .4rem .65rem; font-size: .8rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.badge {
    display: inline-flex; align-items: center; padding: .18rem .5rem; border-radius: 999px;
    background: var(--surface-2); color: var(--muted); font-size: .76rem; font-weight: 650;
}
.badge.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, #c47a00 18%, transparent); color: #9a5f00; }
.badge.danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.alert { padding: .8rem 1rem; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); }
.alert.error { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); color: var(--danger); }
.alert.ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); color: var(--ok); }
.alert code, .code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .86rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .65rem .55rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tbody tr:hover { background: color-mix(in srgb, var(--brand) 4%, transparent); }
.center-narrow { width: min(430px, 100%); margin: 8vh auto; }
.checkbox { display: inline-flex; gap: .5rem; align-items: center; }
.checkbox input { width: auto; }
@media (max-width: 800px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .page { padding: 1rem; }
}

/* Login branding */
.login-body {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem 1rem;
    background:
        radial-gradient(900px 500px at 10% 0%, rgba(45, 111, 255, .18), transparent 65%),
        radial-gradient(700px 400px at 100% 100%, rgba(255, 91, 46, .14), transparent 60%),
        var(--bg);
}
.login-shell {
    width: min(1040px, 100%);
    display: grid;
    grid-template-columns: 1.08fr .92fr;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(11, 31, 77, .16);
}
.login-brand-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1.35rem;
    padding: 3rem;
    color: #fff;
    background:
        radial-gradient(700px 420px at 85% 10%, rgba(255, 106, 61, .75), transparent 60%),
        radial-gradient(600px 400px at 0% 100%, rgba(45, 111, 255, .55), transparent 60%),
        linear-gradient(145deg, #0a1733 0%, #102c66 55%, #2d6fff 100%);
}
.login-brand-panel::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255,255,255,.18) 1px, transparent 1px);
    background-size: 22px 22px;
    mask-image: linear-gradient(180deg, rgba(0,0,0,.35), transparent 75%);
    pointer-events: none;
}
.socialme-logo {
    position: relative;
    z-index: 1;
    width: 230px;
    max-width: 75%;
    background: #fff;
    border-radius: 12px;
    padding: .55rem .75rem;
    box-shadow: 0 12px 30px rgba(0,0,0,.18);
}
.login-eyebrow {
    margin: 0 0 .2rem;
    text-transform: uppercase;
    letter-spacing: .16em;
    font-size: .72rem;
    font-weight: 750;
    color: rgba(255,255,255,.72);
}
.login-brand-title { font-size: 2rem; margin: 0 0 .4rem; position: relative; z-index: 1; }
.login-brand-sub { margin: 0; max-width: 38ch; color: rgba(255,255,255,.82); line-height: 1.6; position: relative; z-index: 1; }
.login-features { list-style: none; margin: .4rem 0 0; padding: 0; display: grid; gap: .55rem; font-size: .9rem; position: relative; z-index: 1; }
.login-features li::before { content: "✓"; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin-right: .55rem; border-radius: 999px; background: rgba(255,255,255,.16); font-size: .72rem; }
.login-site-link { color: rgba(255,255,255,.78); font-size: .82rem; position: relative; z-index: 1; width: fit-content; }
.login-site-link:hover { color: #fff; }
.login-form-panel { display: flex; align-items: center; justify-content: center; padding: 2.5rem; }
.login-card { width: min(360px, 100%); display: flex; flex-direction: column; gap: 1.1rem; }
.login-card-head h1 { font-size: 1.6rem; margin: 0 0 .35rem; }
.login-submit { width: 100%; padding: .75rem 1rem; font-size: .95rem; border-radius: 10px; }
.login-help { margin: 0; text-align: center; }
.login-footer { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; color: var(--muted); font-size: .82rem; }
.login-footer a { color: var(--muted); }
.login-footer a:hover { color: var(--text); }
@media (max-width: 820px) {
    .login-body { padding: 1rem; justify-content: flex-start; }
    .login-shell { grid-template-columns: 1fr; border-radius: 18px; }
    .login-brand-panel { padding: 1.6rem; gap: .9rem; }
    .login-brand-title { font-size: 1.55rem; }
    .login-features { display: none; }
    .login-form-panel { padding: 1.5rem; }
}
