:root {
    color-scheme: dark;
    --bg: #08111f;
    --panel: #0f1b2d;
    --panel-soft: #132238;
    --border: #233754;
    --text: #f5f8fc;
    --muted: #94a7bf;
    --accent: #4aa3ff;
    --accent-strong: #78bbff;
    --success: #39d98a;
    --danger: #ff6b7a;
    --warning: #f5c451;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top right, #142b4b 0, var(--bg) 34rem);
    color: var(--text);
}
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; }

.portal-shell { min-height: 100vh; }
.topbar {
    height: 76px;
    border-bottom: 1px solid var(--border);
    background: rgba(8, 17, 31, .92);
    backdrop-filter: blur(18px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 20;
}
.brand { display: inline-flex; gap: 12px; align-items: center; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #1c75d8, #54b7ff);
    font-weight: 800;
    letter-spacing: -.04em;
}
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); margin-top: 2px; }
.topbar-user { display: flex; align-items: center; gap: 18px; color: var(--muted); }
.link-button { background: none; border: 0; color: var(--accent-strong); cursor: pointer; padding: 0; }

.portal-grid { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: calc(100vh - 76px); }
.sidebar { border-right: 1px solid var(--border); padding: 26px 18px; background: rgba(9, 20, 35, .72); }
.sidebar nav { display: grid; gap: 8px; }
.sidebar nav a { color: #c8d6e8; padding: 11px 13px; border-radius: 10px; }
.sidebar nav a:hover { background: var(--panel-soft); text-decoration: none; color: white; }
.sidebar-note { margin-top: 26px; border: 1px solid var(--border); border-radius: 14px; padding: 14px; background: var(--panel); }
.sidebar-note strong, .sidebar-note span { display: block; }
.sidebar-note span { color: var(--muted); font-size: 13px; line-height: 1.45; margin-top: 6px; }
.content { padding: 34px; max-width: 1500px; width: 100%; margin: 0 auto; }
.auth-content { min-height: calc(100vh - 76px); display: grid; place-items: center; padding: 30px 18px; }

.auth-card { width: min(440px, 100%); background: rgba(15, 27, 45, .94); border: 1px solid var(--border); border-radius: 22px; padding: 30px; box-shadow: 0 28px 80px rgba(0,0,0,.34); }
.auth-card-wide { width: min(520px, 100%); }
.auth-card h1, .page-heading h1 { margin: 8px 0 8px; letter-spacing: -.035em; }
.auth-footer { text-align: center; color: var(--muted); margin: 22px 0 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-weight: 700; color: var(--accent); font-size: 12px; }
.muted { color: var(--muted); line-height: 1.55; }

.form-stack { display: grid; gap: 16px; margin-top: 24px; }
.form-stack > div, .inline-form > div { display: grid; gap: 7px; }
label { color: #d9e4f2; font-size: 14px; font-weight: 650; }
input, select {
    width: 100%;
    border: 1px solid #2d4261;
    background: #0a1525;
    color: var(--text);
    border-radius: 10px;
    padding: 11px 12px;
    outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(74,163,255,.14); }
.check-row { display: flex; align-items: center; gap: 9px; color: var(--muted); font-weight: 400; }
.check-row input { width: auto; }
.field-help { color: var(--muted); font-size: 12px; line-height: 1.5; }

.button { display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 10px; padding: 11px 15px; font-weight: 750; cursor: pointer; text-decoration: none; }
.button:hover { text-decoration: none; }
.button-primary { background: linear-gradient(135deg, #2582e6, #51b1ff); color: #041120; }
.button-primary:hover { filter: brightness(1.08); }
.button-secondary { background: #13263f; color: #dbeafe; border: 1px solid #2d4a6f; }
.button-danger { background: rgba(255,107,122,.12); color: #ff9aa5; border: 1px solid rgba(255,107,122,.35); }
.button-small { padding: 7px 10px; font-size: 12px; }
.button-block { width: 100%; }

.alert { border-radius: 12px; padding: 12px 14px; margin: 18px 0; line-height: 1.5; }
.alert-error { color: #ffc4ca; border: 1px solid rgba(255,107,122,.35); background: rgba(255,107,122,.1); }
.alert-success { color: #b7f4d4; border: 1px solid rgba(57,217,138,.35); background: rgba(57,217,138,.09); }
.secret-reveal { margin: 18px 0; border: 1px solid rgba(57,217,138,.4); background: rgba(57,217,138,.08); border-radius: 14px; padding: 16px; }
.secret-reveal strong, .secret-reveal code, .secret-reveal p { display: block; }
.secret-reveal code { margin: 10px 0; white-space: pre-wrap; word-break: break-all; color: #c9f7df; }
.secret-reveal p { color: var(--muted); margin: 0; }

.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.metric-card, .panel { background: linear-gradient(180deg, rgba(17,32,53,.96), rgba(13,25,42,.96)); border: 1px solid var(--border); border-radius: 16px; }
.metric-card { padding: 20px; }
.metric-card span, .metric-card small { color: var(--muted); display: block; }
.metric-card strong { font-size: 27px; display: block; margin: 10px 0 8px; }
.metric-card small { line-height: 1.45; }
.panel { padding: 22px; margin-bottom: 20px; }
.panel h2 { margin: 0 0 12px; font-size: 18px; }
.panel-heading { display: flex; justify-content: space-between; gap: 20px; align-items: center; }
.panel-heading p { margin: 3px 0 0; }
.narrow-panel { max-width: 720px; }
.security-panel ul { color: var(--muted); line-height: 1.75; }
.inline-form { display: grid; grid-template-columns: minmax(180px, 1fr) 180px auto; gap: 12px; align-items: end; }
.usage-progress { width: 100%; height: 12px; appearance: none; border: 0; border-radius: 999px; overflow: hidden; background: #07101c; }
.usage-progress::-webkit-progress-bar { background: #07101c; border-radius: 999px; }
.usage-progress::-webkit-progress-value { background: linear-gradient(90deg, #2888ee, #47d6b4); border-radius: 999px; }
.usage-progress::-moz-progress-bar { background: linear-gradient(90deg, #2888ee, #47d6b4); border-radius: 999px; }

.onboarding-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.onboarding-step { display: flex; gap: 13px; min-height: 120px; border: 1px solid var(--border); border-radius: 14px; padding: 16px; background: rgba(7,16,28,.54); color: var(--text); }
.onboarding-step:hover { border-color: #376392; text-decoration: none; background: rgba(18,38,63,.8); }
.onboarding-step strong, .onboarding-step small { display: block; }
.onboarding-step small { color: var(--muted); line-height: 1.5; margin-top: 6px; }
.step-number { flex: 0 0 32px; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: rgba(74,163,255,.14); color: #9ed0ff; font-weight: 800; }

.plan-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.plan-card { border: 1px solid var(--border); background: linear-gradient(180deg, rgba(17,32,53,.96), rgba(9,20,35,.96)); border-radius: 18px; padding: 22px; display: flex; flex-direction: column; min-height: 430px; }
.plan-card.plan-current { border-color: rgba(57,217,138,.55); box-shadow: inset 0 0 0 1px rgba(57,217,138,.12); }
.plan-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.plan-card h2 { margin: 8px 0 0; }
.plan-quota { display: grid; margin: 18px 0; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: rgba(7,16,28,.46); }
.plan-quota strong { font-size: 24px; }
.plan-quota span { color: var(--muted); font-size: 12px; margin-top: 4px; }
.feature-list { padding-left: 20px; color: var(--muted); line-height: 1.65; flex: 1; }

.status-pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 750; border: 1px solid transparent; }
.status-good { background: rgba(57,217,138,.09); color: #8ce9b8; border-color: rgba(57,217,138,.26); }
.status-bad { background: rgba(255,107,122,.09); color: #ff9aa5; border-color: rgba(255,107,122,.26); }
.status-neutral { background: rgba(148,167,191,.09); color: #b6c5d8; border-color: rgba(148,167,191,.26); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { color: var(--muted); font-weight: 650; text-align: left; padding: 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 10px; border-bottom: 1px solid rgba(35,55,84,.65); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.empty-state { color: var(--muted); padding: 18px 0; }
code, pre { font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace; }
pre { white-space: pre-wrap; word-break: break-word; }
.code-panel pre, .docs-grid pre { margin: 0; background: #07101c; padding: 16px; border-radius: 12px; overflow-x: auto; color: #c7d8ec; border: 1px solid #182b45; }
.docs-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.docs-grid h2 { margin-bottom: 10px; }

@media (max-width: 1180px) {
    .plan-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1050px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .onboarding-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .topbar { padding: 0 16px; }
    .topbar-user > span { display: none; }
    .portal-grid { grid-template-columns: 1fr; }
    .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
    .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sidebar-note { display: none; }
    .content { padding: 22px 16px; }
    .metric-grid, .plan-grid, .docs-grid { grid-template-columns: 1fr; }
    .inline-form { grid-template-columns: 1fr; }
    .page-heading { display: block; }
    .page-heading > .status-pill { margin-top: 10px; }
}
