/* ==========================================================================
   Developer Portal — thin theme layer over design-tokens.css + ui.css.
   Only portal-specific composition lives here; everything reusable (buttons,
   tables, modals, toasts, forms, shell) comes from ui.css.
   ========================================================================== */

/* --- Auth pages --------------------------------------------------------- */
.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: var(--sp-6);
    background:
        radial-gradient(60rem 40rem at 80% -10%, rgba(99, 102, 241, 0.16), transparent 60%),
        radial-gradient(50rem 40rem at -10% 110%, rgba(34, 211, 238, 0.10), transparent 60%),
        var(--bg);
}
.auth__card {
    width: min(28rem, 100%);
    background: var(--surface-1);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-3);
    padding: var(--sp-8);
}
.auth__brand {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    color: var(--text);
    font-weight: 700;
    margin-bottom: var(--sp-6);
}
.auth__brand:hover { text-decoration: none; }
.auth__brand .logo-mark { width: 32px; height: 32px; flex: none; }
.auth__card h1 { font-size: var(--fs-xl); margin-bottom: var(--sp-2); }
.auth__card > p { color: var(--text-muted); font-size: var(--fs-md); margin-bottom: var(--sp-6); }
/* There are two accounts on this platform -- this Developer Portal one for
   API keys, and the Platform account that saves channels -- and a visitor can
   arrive at either door with no way to tell them apart. This says which door
   they are standing at, so it must read as a standing note rather than as the
   page's own subtitle: quieter than the lead paragraph above it, and boxed. */
.auth__aside {
    margin-bottom: var(--sp-6);
    padding: var(--sp-3) var(--sp-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 8px);
    background: var(--surface-2, transparent);
    font-size: var(--fs-sm);
    color: var(--text-muted);
    line-height: 1.5;
}
.auth__card > p.auth__aside { margin-bottom: var(--sp-6); }

.auth__footer {
    margin-top: var(--sp-6);
    padding-top: var(--sp-5);
    border-top: 1px solid var(--border);
    font-size: var(--fs-md);
    color: var(--text-muted);
    text-align: center;
}
.auth__back { display: block; text-align: center; margin-top: var(--sp-5); font-size: var(--fs-md); }

/* The temporary password can be kept, and the dashboard nags until it is not.
   The link used to say "Skip for now", which made a standing warning sound
   like a dismissal. */
.auth__note {
    margin-top: var(--sp-2);
    text-align: center;
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

/* Password reveal toggle sits inside the input. */
.field--password { position: relative; }
.field--password .field__input { padding-right: 2.75rem; }
.field--password .reveal {
    position: absolute;
    right: 6px;
    top: 2.05rem;
    width: 32px; height: 32px;
    display: grid;
    place-items: center;
    background: none;
    border: 0;
    border-radius: var(--r-sm);
    color: var(--text-muted);
    cursor: pointer;
}
.field--password .reveal:hover { color: var(--text); }

/* --- Portal sign-in composition ---------------------------------------- */
.auth-shell {
    width: min(70rem, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(22rem, 28rem);
    overflow: hidden;
    border: 1px solid var(--border-strong);
    border-radius: calc(var(--r-xl) + 0.25rem);
    background: color-mix(in srgb, var(--surface-1) 92%, transparent);
    box-shadow: var(--shadow-3);
}
.auth__story {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 39rem;
    padding: clamp(2rem, 5vw, 4.5rem);
    overflow: hidden;
    background:
        linear-gradient(145deg, rgba(34, 211, 238, 0.10), transparent 42%),
        radial-gradient(circle at 82% 18%, rgba(99, 102, 241, 0.30), transparent 30%),
        var(--surface-2);
}
.auth__story::after {
    content: '';
    position: absolute;
    width: 18rem;
    height: 18rem;
    right: -7rem;
    bottom: -7rem;
    border: 1px solid rgba(99, 102, 241, 0.35);
    border-radius: 50%;
    box-shadow: 0 0 0 3rem rgba(99, 102, 241, 0.05), 0 0 0 6rem rgba(34, 211, 238, 0.03);
    pointer-events: none;
}
.auth__story .auth__brand { margin-bottom: auto; }
.auth__eyebrow,
.auth__kicker {
    color: var(--brand-ink);
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.auth__story h1 {
    max-width: 15ch;
    margin: var(--sp-3) 0 var(--sp-4);
    font-size: clamp(2.15rem, 4vw, 3.55rem);
    line-height: 1.04;
    letter-spacing: -0.04em;
}
.auth__lead { max-width: 34rem; color: var(--text-muted); font-size: var(--fs-base); line-height: 1.65; }
.auth__benefits { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); margin: var(--sp-7) 0; padding: 0; list-style: none; }
.auth__benefits li { min-height: 8.25rem; display: flex; flex-direction: column; gap: var(--sp-4); padding: var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-lg); background: color-mix(in srgb, var(--surface-1) 70%, transparent); color: var(--text-muted); }
.auth__benefits li span { width: 2rem; height: 2rem; display: grid; place-items: center; border: 1px solid rgba(99, 102, 241, 0.35); border-radius: 50%; color: var(--brand-ink); font-family: var(--font-mono); font-size: var(--fs-xs); }
.auth__benefits li div { display: grid; gap: var(--sp-1); }
.auth__benefits strong { color: var(--text); font-size: var(--fs-md); }
.auth__benefits small { color: var(--text-muted); font-size: var(--fs-sm); line-height: 1.45; }
.auth__links { display: flex; gap: var(--sp-5); flex-wrap: wrap; margin-top: auto; font-size: var(--fs-sm); }
.auth__card { width: auto; border: 0; border-left: 1px solid var(--border); border-radius: 0; box-shadow: none; padding: clamp(2rem, 4vw, 3.5rem); }
.auth__card h2 { margin: var(--sp-3) 0 var(--sp-2); font-size: var(--fs-xl); }
.auth__card > p { color: var(--text-muted); font-size: var(--fs-md); }
.auth__google {
    width: 100%;
    min-height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-3);
    margin-top: var(--sp-6);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.auth__google:hover { border-color: var(--brand); background: var(--brand-subtle); }
.auth__google:disabled { cursor: wait; opacity: 0.7; }
.auth__google-mark { width: 1.6rem; height: 1.6rem; display: grid; place-items: center; border-radius: 50%; background: #fff; color: #4285f4; font-weight: 800; }
.auth__google-status { min-height: 1.25rem; margin-top: var(--sp-2); text-align: center; font-size: var(--fs-sm) !important; }
.auth__access-notice { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-3); margin-top: var(--sp-3); padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--r-md); background: color-mix(in srgb, var(--surface-2) 76%, transparent); }
.auth__access-notice[hidden] { display: none; }
.auth__access-dot { width: .65rem; height: .65rem; margin-top: .35rem; border-radius: 50%; background: var(--text-muted); box-shadow: 0 0 0 4px color-mix(in srgb, var(--text-muted) 12%, transparent); }
.auth__access-notice[data-state="active"] .auth__access-dot { background: #22c55e; box-shadow: 0 0 0 4px rgba(34, 197, 94, .12); }
.auth__access-notice[data-state="pending"] .auth__access-dot { background: #f59e0b; box-shadow: 0 0 0 4px rgba(245, 158, 11, .12); }
.auth__access-notice strong { display: block; color: var(--text); font-size: var(--fs-sm); }
.auth__access-notice p { margin: .2rem 0 .35rem; color: var(--text-muted); font-size: var(--fs-xs); line-height: 1.45; }
.auth__access-notice a { font-size: var(--fs-xs); font-weight: 700; }
.auth__divider { display: flex; align-items: center; gap: var(--sp-3); margin: var(--sp-4) 0; color: var(--text-muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.08em; }
.auth__divider::before, .auth__divider::after { content: ''; height: 1px; flex: 1; background: var(--border); }
.auth__card > .auth__aside { margin: var(--sp-5) 0 0; }
@media (max-width: 820px) {
    .auth { padding: 0; place-items: stretch; }
    .auth-shell { grid-template-columns: 1fr; border: 0; border-radius: 0; }
    .auth__story { min-height: auto; padding: var(--sp-7) var(--sp-5); }
    .auth__story .auth__brand { margin-bottom: var(--sp-8); }
    .auth__story h1 { font-size: clamp(2.2rem, 12vw, 3.5rem); }
    .auth__benefits { display: none; }
    .auth__links { margin-top: var(--sp-6); }
    .auth__card { border-left: 0; border-top: 1px solid var(--border); padding: var(--sp-7) var(--sp-5); }
}

/* --- Panels ------------------------------------------------------------- */
.panel {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--sp-6);
}
.panel > h3 { font-size: var(--fs-base); margin-bottom: var(--sp-2); }
.panel__desc { font-size: var(--fs-md); color: var(--text-muted); margin-bottom: var(--sp-5); }
.panel + .panel { margin-top: var(--sp-5); }

.panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: var(--sp-5);
    align-items: start;
}

/* --- Quick actions ------------------------------------------------------ */
.actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--sp-3);
}
.action-card {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-4);
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    color: var(--text);
    font: inherit;
    font-size: var(--fs-md);
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}
.action-card:hover { background: var(--surface-2); border-color: var(--border-strong); text-decoration: none; }
.action-card .icon { color: var(--brand-ink); }
.action-card .external { margin-left: auto; color: var(--text-muted); }

/* --- Recent list -------------------------------------------------------- */
.recent-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.recent-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface-1);
}
.recent-item .icon { color: var(--brand-ink); }
.recent-item strong { display: block; color: var(--text); font-size: var(--fs-md); overflow-wrap: anywhere; }
.recent-item .meta { font-size: var(--fs-sm); color: var(--text-muted); }

/* --- Key chips ---------------------------------------------------------- */
.key-chip {
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    color: var(--text);
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 0.125rem 0.375rem;
    white-space: nowrap;
}
/* Outside a table row a chip may wrap rather than force horizontal scroll. */
.metric-item .key-chip,
.modal__body .key-chip { white-space: normal; overflow-wrap: anywhere; }

/* --- Usage -------------------------------------------------------------- */
.usage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--sp-5);
}
.usage-card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--sp-5);
}
.usage-card h3 { font-size: var(--fs-md); color: var(--text-muted); font-weight: 600; margin-bottom: var(--sp-4); }
.features-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.features-list li { display: flex; align-items: flex-start; gap: var(--sp-2); font-size: var(--fs-md); }
.features-list .icon { color: var(--success); margin-top: 0.15em; }

/* --- Metrics grid ------------------------------------------------------- */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--sp-4);
}
.metric-item {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    padding: var(--sp-3);
    background: var(--surface-2);
    border-radius: var(--r-md);
}
.metric-label { font-size: var(--fs-sm); color: var(--text-muted); }
.metric-value { font-size: var(--fs-base); font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

/* --- Message list (recovery) -------------------------------------------- */
.message-list { display: flex; flex-direction: column; gap: var(--sp-2); max-height: 26rem; overflow-y: auto; }
.message-item {
    padding: var(--sp-3);
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}
.message-item .meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1) var(--sp-3);
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin-bottom: var(--sp-2);
}
.message-item .content {
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    color: var(--text-body);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* --- Agent list --------------------------------------------------------- */
.agent-list { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.agent-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    font-size: var(--fs-sm);
}
.agent-pill .dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--success);
    flex: none;
}

/* --- Settings ----------------------------------------------------------- */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--sp-5);
    align-items: start;
}
