/* Views of the API workspace: dashboard, ranks, models, docs, support.
   Written against the tokens of theme.css (the app's palette). Billing lives
   in billing.css, the affiliate programme in affiliate.css. */

/* ───────── Dashboard ───────── */
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 20px; }
.overview-grid + .overview-grid,
.grid + .overview-grid { margin-top: 20px; }
.balance-card {
    padding: 26px 28px;
    background:
        radial-gradient(ellipse at 92% -18%, rgba(139, 92, 246, 0.20), transparent 60%),
        var(--surface-flat);
}
.balance-card .eyebrow { margin-bottom: 6px; }
.balance-num {
    font-family: var(--font-display);
    font-size: 46px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.balance-num span { margin-left: 8px; font-family: var(--font-body); font-size: 15px; font-weight: 500; letter-spacing: 0; color: var(--text-faint); }
.balance-note { margin-top: 10px; font-size: 13.5px; color: var(--text-secondary); }
.balance-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.balance-foot p { margin-top: 3px; }
.wallet-symbol {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    border-radius: 13px;
    border: 1px solid var(--accent-line);
    background: var(--accent-tint);
    color: var(--accent-strong);
}
.wallet-symbol svg { width: 23px; height: 23px; }

.rank-card { padding: 26px 28px; display: flex; flex-direction: column; justify-content: center; }
.rank-card .eyebrow { margin-bottom: 2px; }
.rank-medal {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 12px;
    border: 1px solid var(--rank-line, var(--border-strong));
    background: var(--rank-bg, rgba(255, 255, 255, 0.04));
    color: var(--rank-fg, var(--text-dim));
}
.rank-medal svg { width: 22px; height: 22px; }
.rank-label { font-family: var(--font-display); font-size: 24px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.2; }
.rank-progress { margin-top: 20px; }
.rank-track { height: 6px; margin: 12px 0 9px; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, 0.06); }
.rank-track span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); }
.rank-caption { margin-top: 14px; font-size: 12.5px; color: var(--text-faint); }

.getting-started { margin-top: 20px; padding: 24px 26px; }
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin-top: 20px; }
.step { display: flex; align-items: flex-start; gap: 12px; }
.step-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 1px solid var(--accent-line);
    background: var(--accent-tint);
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 700;
}
.step h3 { margin-bottom: 4px; font-size: 14px; }
.step p { margin-bottom: 8px; font-size: 13px; line-height: 1.5; color: var(--text-secondary); }

.chart-wrap { padding: 0 24px 18px; }
.chart { display: block; width: 100%; height: 180px; overflow: visible; }
.chart text { fill: var(--text-faint); font-size: 10px; font-family: var(--font-body); }
.chart .grid-line { stroke: rgba(255, 255, 255, 0.06); stroke-width: 1; stroke-dasharray: 4 5; }
.chart-stop-top { stop-color: var(--accent); stop-opacity: 0.28; }
.chart-stop-bottom { stop-color: var(--accent); stop-opacity: 0; }
.chart-line { stroke: var(--accent-strong); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart-labels { display: flex; justify-content: space-between; margin-left: 25px; font-size: 11px; color: var(--text-faint); }
.legend { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-faint); }
.legend .dot { width: 6px; height: 6px; }
.model-usage { padding: 0 26px 14px; }
.model-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 0; }
.model-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: var(--accent-tint);
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 800;
}
.model-icon svg { width: 16px; height: 16px; }
.model-row b { font-size: 13px; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.mini-bar { max-width: 95%; height: 4px; margin-top: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); }
.mini-bar i { display: block; height: 4px; border-radius: 999px; background: var(--accent); }

/* ───────── Ranks ───────── */
.rank-card-wide { margin-bottom: 24px; }
.rank-tile { position: relative; padding: 26px; }
.rank-tile.current { border-color: var(--accent-line); background: linear-gradient(160deg, rgba(139, 92, 246, 0.10), transparent 55%), var(--surface-flat); }
.rank-tile > .pill { position: absolute; top: 24px; right: 22px; }
.rank-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    border: 1px solid var(--rank-line, var(--border-strong));
    background: var(--rank-bg, rgba(255, 255, 255, 0.04));
    color: var(--rank-fg, var(--text-dim));
}
.rank-icon svg { width: 26px; height: 26px; }
.rank-tile h2 { margin: 18px 0 4px; font-family: var(--font-display); font-size: 24px; font-weight: 800; }
.rank-tile .threshold { margin-top: 18px; font-family: var(--font-display); font-size: 26px; font-weight: 800; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.rank-tile .threshold span { display: block; margin-top: 2px; font-family: var(--font-body); font-size: 12px; font-weight: 500; letter-spacing: 0; color: var(--text-faint); }
.rank-tile ul { display: grid; gap: 11px; margin: 22px 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--text-secondary); }
.rank-tile li { display: flex; align-items: flex-start; gap: 9px; }
.rank-tile li svg { width: 16px; height: 16px; margin-top: 1px; color: var(--accent-strong); }

/* ───────── Models ───────── */
.model-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.model-card { display: flex; flex-direction: column; gap: 14px; padding: 22px; transition: border-color 0.15s; }
.model-card:hover { border-color: var(--border-strong); }
.model-card .model-icon { width: 40px; height: 40px; border-radius: 12px; font-size: 15px; }
.model-card h3 { font-size: 15px; }
.model-card code { display: block; margin-top: 2px; font-size: 11.5px; color: var(--text-faint); overflow-wrap: anywhere; }
.model-card p { margin-top: 8px; font-size: 13px; line-height: 1.55; color: var(--text-secondary); }
.model-card .text-link { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }

/* ───────── Support + settings ───────── */
.quicklink { display: flex; align-items: flex-start; gap: 14px; padding: 22px 24px; transition: border-color 0.15s; }
.quicklink:hover { border-color: var(--border-strong); }
.quicklink > svg:first-child { width: 22px; height: 22px; color: var(--accent-strong); }
.quicklink h3 { margin-bottom: 4px; font-size: 15px; }
.quicklink p { font-size: 13px; color: var(--text-secondary); }
.quicklink .arrow { width: 16px; height: 16px; margin-left: auto; color: var(--text-faint); }
.help-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.settings-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* ───────── Documentation ───────── */
.docs-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 26px; align-items: start; }
.docs-nav {
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    padding-right: 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}
.docs-nav-group { margin: 18px 12px 8px; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-tertiary); }
.docs-nav-group:first-child { margin-top: 0; }
.docs-nav a {
    display: block;
    padding: 8px 12px;
    border-left: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-secondary);
    transition: color 0.15s, background 0.15s;
}
.docs-nav a:hover { color: var(--text); }
.docs-nav a.active { border-left: 2px solid var(--accent); padding-left: 11px; background: var(--accent-tint); color: var(--accent-strong); font-weight: 600; }
.docs-mobile-select { display: none; }
.doc-search-results { display: grid; gap: 10px; margin-bottom: 22px; }
.doc-search-results:empty { display: none; }
.doc-result { display: block; padding: 14px 16px; background: var(--surface-flat); border: 1px solid var(--border); border-radius: 12px; font-size: 13px; transition: border-color 0.15s; }
.doc-result:hover { border-color: var(--accent-line); }
.doc-result strong { color: var(--text); }
.doc-result span { display: block; margin-top: 4px; font-size: 12.5px; color: var(--text-faint); }
.docs-article { min-width: 0; padding: 34px 36px; }
.doc-meta { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.doc-toc { margin-bottom: 26px; padding: 4px 0 4px 16px; border-left: 2px solid var(--accent-line); }
.doc-toc > span { display: block; margin-bottom: 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.doc-toc a { display: block; padding: 4px 0; font-size: 13px; color: var(--accent-strong); }
.doc-toc a:hover { text-decoration: underline; text-underline-offset: 3px; }
.docs-article h1 { margin-bottom: 18px; font-size: 32px; }
.docs-article h2 { margin: 0 0 18px; font-family: var(--font-display); font-size: 27px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.docs-article h3 { margin: 36px 0 12px; font-size: 18px; font-weight: 700; line-height: 1.45; overflow-wrap: anywhere; }
.docs-article h4 { margin: 24px 0 10px; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.docs-article p, .docs-article li { margin-bottom: 12px; font-size: 14px; line-height: 1.75; color: var(--text-secondary); overflow-wrap: anywhere; }
.docs-article ul, .docs-article ol { padding-left: 20px; }
.docs-article a { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }
.docs-article strong { color: var(--text); }
.docs-article code { padding: 2px 5px; border-radius: 5px; background: var(--accent-tint); color: var(--accent-strong); font-size: 0.88em; overflow-wrap: anywhere; }
.docs-article pre {
    overflow: auto;
    max-height: 660px;
    padding: 18px 76px 18px 20px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-dim);
    font-size: 12.5px;
    line-height: 1.75;
    white-space: pre;
}
.docs-article pre code { padding: 0; background: none; color: inherit; }
.docs-article .code-block { position: relative; min-width: 0; margin: 16px 0; }
.docs-article .copy-btn {
    position: absolute;
    top: 9px;
    right: 9px;
    z-index: 1;
    padding: 4px 10px;
    border: 1px solid var(--border-strong);
    border-radius: 7px;
    background: var(--surface-3);
    color: var(--text-dim);
    font-size: 11px;
    font-weight: 600;
}
.docs-article .copy-btn:hover { color: var(--text); }
.docs-article hr { margin: 30px 0; border: 0; border-top: 1px solid var(--border); }
.docs-article table { display: block; overflow-x: auto; margin: 16px 0 24px; border: 1px solid var(--border); border-radius: 12px; white-space: normal; }
.docs-article th { padding: 10px 14px; background: rgba(255, 255, 255, 0.02); }
.docs-article td { min-width: 90px; padding: 11px 14px; font-size: 13px; line-height: 1.65; vertical-align: top; }
.docs-article td code { white-space: normal; word-break: normal; overflow-wrap: anywhere; }
.docs-article .endpoint {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 4px 0 10px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: var(--mono);
    font-size: 13px;
    color: var(--text);
    overflow-wrap: anywhere;
}
.docs-article .method { padding: 2px 8px; border-radius: 6px; font-family: var(--font-body); font-size: 11px; font-weight: 800; letter-spacing: 0.06em; background: var(--accent-tint); color: var(--accent-strong); }
.docs-article .method-get { background: var(--accent-green); color: var(--green); }
.docs-article .method-delete { background: var(--danger-tint); color: var(--danger); }
.docs-article .tag { display: inline-flex; margin: 0 6px 10px 0; padding: 2px 9px; border-radius: 6px; font-size: 11.5px; font-weight: 600; background: rgba(255, 255, 255, 0.06); color: var(--text-secondary); }
.docs-article .tag-async { background: var(--blue-tint); color: var(--blue); }
.docs-article .tag-credits { background: var(--accent-tint); color: var(--accent-strong); }
.docs-article .note { padding-left: 14px; border-left: 2px solid var(--accent-line); font-size: 13px; color: var(--text-faint); }
.docs-article .category-intro { font-size: 15px; color: var(--text-secondary); }
.doc-nav-buttons { display: flex; justify-content: space-between; gap: 10px; margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--border); }
.doc-nav-buttons .btn { white-space: normal; text-align: left; }

/* ───────── Responsive ───────── */
@media (min-width: 1600px) {
    .balance-num { font-size: 52px; }
    .chart { height: 205px; }
}
@media (max-width: 1150px) {
    .overview-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .model-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .docs-layout { grid-template-columns: 180px minmax(0, 1fr); gap: 18px; }
    .docs-article { padding: 26px; }
    .steps { gap: 16px; }
}
@media (max-width: 860px) {
    .overview-grid { grid-template-columns: minmax(0, 1fr); }
    .balance-card, .rank-card { padding: 22px; }
    .balance-num { font-size: 40px; }
    .steps { grid-template-columns: minmax(0, 1fr); gap: 18px; }
    .model-grid { grid-template-columns: minmax(0, 1fr); }
    .docs-layout { grid-template-columns: minmax(0, 1fr); }
    .docs-nav { display: none; }
    .docs-mobile-select { display: block; width: 100%; margin-bottom: 16px; }
    .docs-article { padding: 22px 18px; }
    .docs-article h1 { font-size: 26px; }
    .docs-article h2 { font-size: 23px; }
    .chart-wrap { padding: 0 16px 16px; }
    .model-usage { padding: 0 20px 12px; }
}
@media (max-width: 560px) {
    .balance-num { font-size: 36px; }
    .balance-foot { flex-wrap: wrap; }
    .chart { height: 150px; }
    .docs-article h3 { font-size: 16px; }
    .doc-nav-buttons .btn { font-size: 12px; padding: 9px 12px; }
}
