/* ─────────────────────────────────────────────────────────────────────────────
   Developer API pages (2026-10-16): /developer/api-tokens and /account/api-tokens.

   One flat panel per page (.as-card from admin-settings.css, inside .admin-pane for
   its tokens). Named sections are separated by a header with a hairline above
   (.ak-sec); every row, list header and section header shares the same 1.25rem
   side gutter so titles, labels and columns line up down the page.
   ───────────────────────────────────────────────────────────────────────────── */

.ak-page { margin: 1rem 0 3rem; display: grid; gap: 1rem; }
.ak-page .as-card + .as-card { margin-top: 0; }
.ak-page .as-card { overflow: hidden; }

/* ── Section header: title + hint on the left, controls on the right ── */
.ak-sec {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    flex-wrap: wrap;
    padding: 1.1rem 1.25rem 0.85rem;
    border-top: 1px solid var(--as-section-divider, rgba(0,0,0,0.14));
}
.ak-sec:first-child { border-top: 0; }
.ak-sec-text { min-width: 0; flex: 1 1 320px; }
.ak-sec-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary, #111827);
}
.ak-sec-title .bi { color: var(--text-secondary, #6b7280); font-size: 0.95rem; }
.ak-sec-hint { margin: 0.2rem 0 0; font-size: 0.8rem; line-height: 1.45; color: var(--text-secondary, #6b7280); max-width: 760px; }
.ak-sec-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-left: auto; }
.ak-check { display: inline-flex; align-items: center; gap: 0.45rem; min-height: 32px; font-size: 0.82rem; color: var(--text-secondary, #4b5563); cursor: pointer; }
.ak-check input { margin: 0; }

/* Setting key / token prefix: quiet monospace chip, never the browser's pink <code>. */
.ak-key {
    display: inline-block;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.5;
    padding: 0 0.4rem;
    border-radius: 0.3rem;
    color: var(--text-secondary, #4b5563);
    background: rgba(107,114,128,0.1);
    white-space: nowrap;
}
[data-theme="dark"] .ak-key { color: #cbd5e1; background: rgba(255,255,255,0.07); }

/* ── Kill switches: .as-row.toggle rows with the flat green switch ── */
.ak-page .as-row { padding: 0.85rem 1.25rem; }
.ak-row-label { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; font-weight: 600; font-size: 0.9rem; color: var(--text-primary, #111827); }
.ak-switch {
    position: relative;
    flex: 0 0 auto;
    width: 44px;
    height: 24px;
    border-radius: 999px;
    border: 0;
    padding: 0;
    background: rgba(107,114,128,0.35);
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.ak-switch.is-on { background: #16a34a; }
.ak-switch-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    transition: left 0.15s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.ak-switch.is-on .ak-switch-knob { left: 23px; }
.ak-switch:focus-visible { outline: 2px solid var(--brand-primary, #0366d6); outline-offset: 2px; }
.ak-switch:disabled { opacity: 0.5; cursor: default; }

/* ── Notices (pepper missing, 2FA needed) — inline, inside the panel ── */
.ak-notice {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    margin: 0 1.25rem 1rem;
    padding: 0.7rem 0.9rem;
    border-radius: 0.6rem;
    font-size: 0.85rem;
    line-height: 1.45;
    border: 1px solid;
}
.ak-notice .bi { margin-top: 0.1rem; }
.ak-notice.danger { color: #991b1b; background: rgba(220,38,38,0.06); border-color: rgba(220,38,38,0.25); }
.ak-notice.warning { color: #92400e; background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.3); }
.ak-notice a { color: inherit; font-weight: 600; }
[data-theme="dark"] .ak-notice.danger { color: #fca5a5; }
[data-theme="dark"] .ak-notice.warning { color: #fcd34d; }

/* ── Record lists: aligned columns in one flat panel (Employees pattern) ── */
.ak-list { display: grid; column-gap: 1.25rem; }
.ak-list > .ak-row,
.ak-list > .ak-head {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
    align-items: center;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--as-divider, rgba(0,0,0,0.06));
}
.ak-list > .ak-head {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    border-top: 0;
    border-bottom: 1px solid var(--as-border, rgba(0,0,0,0.1));
    background: var(--surface-muted, rgba(0,0,0,0.02));
}
.ak-list > .ak-head + .ak-row { border-top: 0; }
.ak-head > span {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary, #6b7280);
    white-space: nowrap;
}
.ak-row { font-size: 0.85rem; }
.ak-row:hover { background: var(--surface-hover, rgba(0,0,0,0.02)); }
.ak-row.is-off { color: var(--text-secondary, #6b7280); }
.ak-row.is-off .ak-primary { color: var(--text-secondary, #6b7280); }
.ak-cell { min-width: 0; }
.ak-primary { display: block; font-weight: 600; color: var(--text-primary, #111827); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ak-secondary { display: block; margin-top: 0.1rem; font-size: 0.74rem; color: var(--text-secondary, #6b7280); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ak-muted { color: var(--text-secondary, #6b7280); }
.ak-num { font-variant-numeric: tabular-nums; }
.ak-scopes { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.ak-scopes .as-pill { font-size: 0.68rem; padding: 0.1rem 0.5rem; font-weight: 500; }
.ak-scopes .test-pill { margin-left: 0; }
.ak-actions { display: flex; justify-content: flex-end; gap: 0.4rem; }
.ak-dot { font-size: 0.5rem; }
.ak-page a.as-btn, .ak-page a.as-btn:hover { text-decoration: none; }
.ak-inline-pill { margin-left: 0.35rem; }
.ak-bad { color: #b91c1c; font-weight: 700; }
[data-theme="dark"] .ak-bad { color: #f87171; }
.ak-empty { padding: 1.75rem 1.25rem 2rem; text-align: center; color: var(--text-secondary, #6b7280); font-size: 0.88rem; }
.ak-empty .bi { display: block; margin-bottom: 0.35rem; font-size: 1.4rem; opacity: 0.6; }
.ak-flash { padding: 0.65rem 1.25rem; font-size: 0.82rem; color: var(--text-secondary, #6b7280); border-top: 1px solid var(--as-divider, rgba(0,0,0,0.06)); }

/* Column templates */
.ak-list.admin-tokens { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1.6fr) auto auto auto auto; }
.ak-list.my-tokens { grid-template-columns: minmax(0, 1.3fr) minmax(0, 2fr) auto auto auto auto auto; }
.ak-list.activity { grid-template-columns: auto auto minmax(0, 2fr) auto auto auto auto; }

/* ── Help list ── */
.ak-help { margin: 0; padding: 0 1.25rem 1.1rem 2.5rem; font-size: 0.85rem; line-height: 1.55; color: var(--text-secondary, #4b5563); }
.ak-help li + li { margin-top: 0.3rem; }
.ak-help strong { color: var(--text-primary, #111827); }

/* ── New-token dialog (portal — OverlayService) ── */
.ak-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,0.5); z-index: calc(var(--z-modal, 1500) - 10); }
.ak-modal-wrap { position: fixed; inset: 0; z-index: var(--z-modal, 1500); display: flex; align-items: center; justify-content: center; padding: 1rem; pointer-events: none; }
.ak-modal {
    pointer-events: auto;
    width: min(680px, 100%);
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    background: var(--surface-card, #fff);
    border: 1px solid var(--as-border, rgba(0,0,0,0.1));
    border-radius: 0.9rem;
    box-shadow: 0 20px 50px rgba(15,23,42,0.25);
    --as-border: var(--surface-border, rgba(0,0,0,0.1));
    --as-divider: var(--surface-border-light, rgba(0,0,0,0.06));
    --as-section-divider: rgba(0,0,0,0.14);
}
[data-theme="dark"] .ak-modal { --as-border: rgba(255,255,255,0.1); --as-divider: rgba(255,255,255,0.07); --as-section-divider: rgba(255,255,255,0.18); }
.ak-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--as-border, rgba(0,0,0,0.1)); }
.ak-modal-title { display: flex; align-items: center; gap: 0.5rem; margin: 0; font-size: 1.02rem; font-weight: 700; color: var(--text-primary, #111827); }
.ak-modal-body { overflow-y: auto; min-height: 0; }
.ak-modal-body .ak-sec { padding-top: 0.95rem; padding-bottom: 0.6rem; }
.ak-fields { display: grid; gap: 0.75rem; padding: 0 1.25rem 1rem; }
.ak-field { display: grid; gap: 0.3rem; min-width: 0; }
.ak-label { font-size: 0.78rem; font-weight: 600; color: var(--text-secondary, #4b5563); margin: 0; }
.ak-hint { font-size: 0.78rem; line-height: 1.45; color: var(--text-secondary, #6b7280); }
.ak-modal .form-control, .ak-modal .form-select { min-height: 40px; border-radius: 0.6rem; font-size: 0.9rem; }
.ak-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 0.75rem; }
.ak-scope-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.1rem 1.25rem; padding: 0 1.25rem 1rem; }
.ak-scope-opt { display: flex; align-items: center; gap: 0.55rem; min-height: 32px; font-size: 0.84rem; color: var(--text-primary, #111827); cursor: pointer; min-width: 0; }
.ak-scope-opt input { margin: 0; flex: 0 0 auto; }
.ak-scope-opt .ak-scope-name { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ak-scope-opt.is-disabled { color: var(--text-secondary, #9ca3af); cursor: default; }
.ak-scope-opt .as-pill { margin-left: auto; font-size: 0.64rem; padding: 0.05rem 0.45rem; }
.ak-stepup { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; padding: 0 1.25rem 1rem; }
.ak-code { max-width: 220px; letter-spacing: 0.25em; text-align: center; }
.ak-error { margin: 0 1.25rem 1rem; }
.ak-modal-foot { display: flex; justify-content: flex-end; gap: 0.5rem; flex-wrap: wrap; padding: 0.85rem 1.25rem; border-top: 1px solid var(--as-border, rgba(0,0,0,0.1)); }
.ak-token-row { display: flex; gap: 0.5rem; align-items: center; padding: 0 1.25rem 1.1rem; }
.ak-token { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.8rem; }

/* ── Tablet + phone: each row stacks — a full-width lead line, then labelled fields in an even grid ── */
@media (max-width: 1199.98px) {
    .ak-list { display: block; }
    .ak-list > .ak-head { display: none; }
    .ak-list > .ak-row {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 0.6rem 1.25rem;
        align-items: start;
    }
    .ak-list > .ak-row > .ak-lead { grid-column: 1 / -1; order: -1; }
    .ak-list > .ak-row > .ak-scopes { grid-column: 1 / -1; }
    .ak-list > .ak-row > .ak-actions { grid-column: 1 / -1; justify-content: flex-end; }
    .ak-list > .ak-row > .ak-actions:empty { display: none; }
    .ak-list > .ak-row > .ak-cell:not(.ak-lead)[data-label]::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 0.15rem;
        font-size: 0.62rem;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: var(--text-secondary, #6b7280);
    }
    .ak-list > .ak-row > .ak-scopes::before { flex: 1 1 100%; margin-bottom: 0; }
}
@media (max-width: 767.98px) {
    .ak-sec-actions { margin-left: 0; width: 100%; }
    .ak-two, .ak-scope-grid { grid-template-columns: 1fr; }
    .ak-token-row { flex-direction: column; align-items: stretch; }
    .ak-modal-foot .as-btn { flex: 1 1 auto; }
}
