/* Horus Trader shell — brand palette (2026-07-03 command-deck alignment).
   Tokens now mirror the Toobit deck (Toobit/static/ui/tokens.css): same dark
   #0b0c0f + gold #e8b454, Sora / Hanken Grotesk / JetBrains Mono. The shell
   home, admin, profile and agent pages all read from these variables. */

:root,
:root[data-theme="dark"] {
    --bg:         #0b0c0f;
    --bg-panel:   #12151c;
    --bg-card:    #171b24;
    --fg:         #e8eaf0;
    --fg-dim:     #8b90a2;
    --faint:      #5b6072;
    --border:     #242833;
    --border-2:   #2e3340;
    --gold:       #e8b454;
    --gold-bright:#f6cd76;
    --gold-soft:  rgba(232, 180, 84, 0.14);
    --green:      #3fb950;
    --red:        #f85149;
    --warn:       #d8a02a;          /* J.6.1 cost banner */
    --warn-soft:  rgba(216, 160, 42, 0.14);
    --warn-fg:    #2a1f00;          /* readable on yellow strip */
    --header-bg:  rgba(15, 17, 22, 0.84);
    --card-shadow: 0 1px 0 rgba(255,255,255,.02) inset, 0 18px 40px -24px rgba(0,0,0,.9);
    --font-disp:  "Sora", system-ui, sans-serif;
    --font-body:  "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono:  "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;
}

:root[data-theme="light"] {
    --bg:         #f3f4f7;
    --bg-panel:   #ffffff;
    --bg-card:    #f7f8fb;
    --fg:         #1a1d24;
    --fg-dim:     #5a6172;
    --faint:      #8a90a0;
    --border:     #dfe2e9;
    --border-2:   #cdd2dc;
    --gold:       #b07d18;
    --gold-bright:#946812;
    --gold-soft:  rgba(176, 125, 24, 0.12);
    --green:      #2c9c40;
    --red:        #d4342b;
    --warn:       #b07d18;
    --warn-soft:  rgba(176, 125, 24, 0.14);
    --warn-fg:    #4a3500;
    --header-bg:  rgba(255, 255, 255, 0.86);
    --card-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 12px 30px -22px rgba(20,24,40,.35);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    letter-spacing: 0.1px;
    -webkit-font-smoothing: antialiased;
}

/* Aura + engineering grid backdrop — shell pages only (body.shell-body). */
body.shell-body {
    background-image:
        radial-gradient(900px 500px at 82% -8%, rgba(232, 180, 84, 0.07), transparent 60%),
        radial-gradient(700px 600px at -6% 4%, rgba(68, 147, 248, 0.05), transparent 55%),
        linear-gradient(rgba(255, 255, 255, 0.014) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.014) 1px, transparent 1px);
    background-size: auto, auto, 38px 38px, 38px 38px;
}
:root[data-theme="light"] body.shell-body {
    background-image:
        radial-gradient(900px 500px at 82% -8%, rgba(176, 125, 24, 0.06), transparent 60%),
        radial-gradient(700px 600px at -6% 4%, rgba(47, 125, 224, 0.05), transparent 55%),
        linear-gradient(rgba(20, 24, 40, 0.028) 1px, transparent 1px),
        linear-gradient(90deg, rgba(20, 24, 40, 0.028) 1px, transparent 1px);
    background-size: auto, auto, 38px 38px, 38px 38px;
}

a {
    color: var(--gold);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

/* ---------- Login page ---------- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(circle at 30% 20%, rgba(201, 162, 75, 0.08), transparent 60%),
        radial-gradient(circle at 70% 80%, rgba(201, 162, 75, 0.05), transparent 60%),
        var(--bg);
}

.login-shell {
    width: 100%;
    max-width: 420px;
    padding: 32px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 32px 28px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}

.login-logo {
    display: block;
    width: 100%;
    max-width: 260px;
    margin: 0 auto 28px;
}

.field { display: block; margin-bottom: 16px; }
.field-label {
    display: block;
    font-size: 12px;
    color: var(--fg-dim);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 6px;
}
.field input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--fg);
    font-size: 15px;
}
.field input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-soft);
}
.field select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--fg);
    font-size: 15px;
}
.field select:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-soft);
}

.btn {
    display: inline-block;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s, background 0.15s;
}
.btn-primary {
    background: var(--gold);
    color: #1a1408;
    width: 100%;
    margin-top: 6px;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost {
    background: transparent;
    color: var(--fg);
    border-color: var(--border);
}
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }

/* ---------- Shell header (2026-07-03: sticky glass bar + user menu) ---------- */
.shell-header {
    position: sticky;
    top: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 26px;
    border-bottom: 1px solid var(--border);
    background: var(--header-bg);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}
.shell-brand-link {
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--fg);
}
.shell-brand-link:hover { text-decoration: none; }
.shell-logo { width: 52px; height: 52px; object-fit: contain;
    filter: drop-shadow(0 0 16px rgba(232, 180, 84, .28)); }
.shell-title {
    font-family: var(--font-disp);
    font-weight: 700;
    letter-spacing: 0.02em;
    font-size: 17px;
}
.shell-title-ai { color: var(--gold); font-weight: 800; }
.shell-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}
.inline-form { display: inline; margin: 0; }

.badge {
    display: inline-block;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 4px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.badge-admin { background: var(--gold-soft); color: var(--gold); }

/* Subscription countdown chip — same visual language as the Toobit deck. */
.subchip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 11px;
    border-radius: 11px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 500;
    color: var(--fg-dim);
    text-decoration: none;
    white-space: nowrap;
}
.subchip:hover { text-decoration: none; filter: brightness(1.08); }
.subchip .sc-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.subchip.ok   { background: rgba(63, 185, 80, 0.10);  border-color: rgba(63, 185, 80, 0.30);  color: #b6f0c0; }
.subchip.ok .sc-dot { background: var(--green); }
.subchip.warn { background: rgba(216, 160, 42, 0.13); border-color: rgba(216, 160, 42, 0.40); color: #f0cb74; }
.subchip.warn .sc-dot { background: #e8b454; box-shadow: 0 0 0 4px rgba(216, 160, 42, 0.18); }
.subchip.bad  { background: rgba(248, 81, 73, 0.13);  border-color: rgba(248, 81, 73, 0.40);  color: #ff9b95; }
.subchip.bad .sc-dot { background: var(--red); box-shadow: 0 0 0 4px rgba(248, 81, 73, 0.18); }
:root[data-theme="light"] .subchip.ok   { color: #1d7a30; }
:root[data-theme="light"] .subchip.warn { color: #8a6210; }
:root[data-theme="light"] .subchip.bad  { color: #b02a22; }

/* Avatar + dropdown user menu (replaces the raw username link). */
.usermenu { position: relative; }
.avatar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--border-2, var(--border));
    background: var(--gold-soft);
    cursor: pointer;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.avatar-btn:hover,
.avatar-btn[aria-expanded="true"] {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-soft);
}
.avatar-ini {
    font-family: var(--font-disp);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--gold);
    -webkit-user-select: none;
    user-select: none;
}
.avatar-ini.lg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gold-soft);
    font-size: 14px;
}
.usermenu-pop {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    min-width: 250px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 13px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
    padding: 8px;
    z-index: 80;
}
.usermenu-pop[hidden] { display: none; }
.usermenu-head {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 10px 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
}
.usermenu-id { min-width: 0; }
.usermenu-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--fg);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
}
.usermenu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--fg);
    font: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    text-decoration: none;
}
.usermenu-item svg { color: var(--fg-dim); flex: 0 0 auto; }
.usermenu-item:hover { background: var(--bg-card); text-decoration: none; color: var(--gold); }
.usermenu-item:hover svg { color: var(--gold); }
.usermenu-signout { margin: 6px 0 0; padding-top: 6px; border-top: 1px solid var(--border); }
.usermenu-danger:hover { color: var(--red); background: rgba(248, 81, 73, 0.08); }
.usermenu-danger:hover svg { color: var(--red); }

/* ---------- Flashes ---------- */
.flashes {
    list-style: none;
    padding: 0;
    margin: 12px 0;
}
.shell-flashes { margin: 12px 24px; }
.flash {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 13px;
}
.flash-error { background: rgba(220, 40, 40, 0.12); color: #ff8b8b; border: 1px solid rgba(220, 40, 40, 0.35); }
.flash-info { background: rgba(201, 162, 75, 0.12); color: var(--gold); border: 1px solid rgba(201, 162, 75, 0.35); }

/* ---------- Shell sections ---------- */
.shell-main { padding: 28px 24px; }
.shell-section { margin-bottom: 40px; }
.section-heading {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fg-dim);
    margin: 0 0 14px;
    font-weight: 600;
}
.section-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--fg-dim);
    text-decoration: none;
    margin-bottom: 14px;
}
.section-back:hover { color: var(--gold); }

/* ---------- Home page: hero + section heads + card grid (2026-07-03) ---------- */
.hd-hero { margin: 6px 0 34px; max-width: 720px; }
.hd-kicker {
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.28em;
    color: var(--gold);
    margin-bottom: 8px;
}
.hd-title {
    font-family: var(--font-disp);
    font-size: clamp(24px, 3.4vw, 34px);
    font-weight: 700;
    letter-spacing: -0.015em;
    margin: 0 0 8px;
    color: var(--fg);
}
.hd-sub { margin: 0; color: var(--fg-dim); font-size: 14.5px; max-width: 560px; }

.hd-sechead {
    display: flex;
    align-items: baseline;
    gap: 14px;
    margin-bottom: 16px;
}
.hd-sechead .section-heading { margin: 0; white-space: nowrap; }
.hd-secline { flex: 1 1 auto; height: 1px; background: var(--border); align-self: center; }
.hd-seclink {
    font-size: 12.5px;
    color: var(--fg-dim);
    white-space: nowrap;
    transition: color 0.15s ease;
}
.hd-seclink:hover { color: var(--gold); text-decoration: none; }

.hd-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

/* ---------- Cards (exchanges + AI providers) ---------- */
.exchange-tile {
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    padding: 16px 16px 14px;
    background: var(--bg-card);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--card-shadow);
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    text-align: left;
    transition: transform 0.14s ease, border-color 0.15s ease, box-shadow 0.2s ease;
}
.exchange-tile::before {                     /* status spine */
    content: "";
    position: absolute;
    left: 0;
    top: 12px;
    bottom: 12px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--faint);
    opacity: 0.5;
}
.exchange-tile.active::before { background: var(--green); opacity: 1; }
.exchange-tile.ai.keyed::before { background: var(--green); opacity: 1; }
.exchange-tile[data-credit-error="true"]::before { background: var(--red); opacity: 1; }
.exchange-tile:hover {
    transform: translateY(-2px);
    border-color: var(--border-2, var(--border));
    box-shadow: 0 22px 44px -22px rgba(0, 0, 0, 0.85);
}
.exchange-tile.active:hover { border-color: rgba(63, 185, 80, 0.45); }
.exchange-tile:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.exchange-tile.inactive { cursor: default; opacity: 0.62; }
.exchange-tile.inactive:hover { transform: none; }

.tile-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tile-mono {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: var(--gold-soft);
    color: var(--gold);
    font-family: var(--font-disp);
    font-size: 18px;
    font-weight: 800;
    -webkit-user-select: none;
    user-select: none;
}
/* Real brand mark (Phase AT) — the letter monogram stays as sibling fallback:
   the img precedes the span, so this rule hides the monogram while the img is
   in the DOM; onerror="this.remove()" restores it on a missing asset. */
.tile-logo {
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    padding: 5px;
    border-radius: 11px;
    object-fit: contain;
    background: var(--gold-soft);
    box-sizing: border-box;
}
.tile-logo + .tile-mono { display: none; }
.exchange-tile.ai .tile-logo { background: var(--surface-2, rgba(255, 255, 255, 0.05)); }
.tile-mono.ai-claude { background: rgba(217, 119, 87, 0.14);  color: #d97757; }
.tile-mono.ai-openai { background: rgba(116, 170, 156, 0.14); color: #74aa9c; }
.tile-mono.ai-gemini { background: rgba(68, 147, 248, 0.14);  color: #6ba5f5; }
:root[data-theme="light"] .tile-mono.ai-claude { color: #bc5b3f; }
:root[data-theme="light"] .tile-mono.ai-openai { color: #3f8a77; }
:root[data-theme="light"] .tile-mono.ai-gemini { color: #2f6fd0; }
.tile-id { flex: 1 1 auto; min-width: 0; }
.tile-name {
    font-family: var(--font-disp);
    font-size: 15.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--fg);
}
.tile-sub {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--fg-dim);
    margin-top: 1px;
}
.tile-slot { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; }

.tile-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 12px;
}
.tile-link { color: var(--fg-dim); transition: color 0.15s ease; }
.tile-link:hover { color: var(--gold); text-decoration: none; }
.tile-sep { color: var(--faint); -webkit-user-select: none; user-select: none; }
.tile-hint { color: var(--faint); font-size: 11.5px; }

/* ---------- Admin row ---------- */
.admin-row { display: flex; gap: 16px; flex-wrap: wrap; }
.admin-tile {
    display: flex;
    align-items: center;
    gap: 13px;
    min-width: 250px;
    padding: 15px 18px;
    background: var(--bg-card);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--card-shadow);
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    text-align: left;
    transition: transform 0.14s ease, border-color 0.15s ease;
}
.admin-tile:disabled { opacity: 0.5; cursor: not-allowed; }
.admin-tile:not(:disabled):hover {
    border-color: var(--gold);
    box-shadow: 0 0 18px var(--gold-soft);
    transform: translateY(-2px);
}
.admin-tile-ic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 11px;
    background: var(--gold-soft);
    color: var(--gold);
}
.admin-tile-tx { display: flex; flex-direction: column; gap: 2px; }
.admin-tile-label { font-family: var(--font-disp); font-size: 15px; font-weight: 600; }
.admin-tile-status {
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--fg-dim);
}

/* Staggered entrance (matches the Toobit deck's rise animation). */
@keyframes hd-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.an { opacity: 0; animation: hd-rise 0.55s cubic-bezier(0.2, 0.7, 0.2, 1) forwards; }
.d1 { animation-delay: 0.04s; } .d2 { animation-delay: 0.10s; }
.d3 { animation-delay: 0.16s; } .d4 { animation-delay: 0.22s; }
@media (prefers-reduced-motion: reduce) { .an { animation: none; opacity: 1; } }

/* ---------- Admin users modal ---------- */
.admin-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: stretch;
    justify-content: center;
    z-index: 100;
    padding: 40px;
}
.admin-modal[hidden] { display: none; }

.admin-modal-surface {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 100%;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.6);
}

.admin-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}
.admin-modal-header h2 {
    margin: 0;
    font-size: 15px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--fg-dim);
}
.admin-modal-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
#admin-users-close {
    font-size: 22px;
    line-height: 1;
    padding: 2px 12px;
}

.admin-modal-body {
    display: flex;
    min-height: 0;
    height: 70vh;
}

.admin-users-list {
    width: 320px;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    padding: 8px;
    background: var(--bg);
}

.admin-user-row {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    color: var(--fg);
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 4px;
    font-family: inherit;
}
.admin-user-row:hover {
    background: var(--bg-card);
    border-color: var(--border);
}
.admin-user-row.selected {
    background: var(--bg-card);
    border-color: var(--gold);
    box-shadow: 0 0 0 1px var(--gold-soft);
}
.admin-user-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
}
.admin-user-meta {
    font-size: 11px;
    color: var(--fg-dim);
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
.admin-user-handle { letter-spacing: 0.02em; }

.badge-on  { background: rgba(38, 200, 90, 0.15); color: var(--green); }
.badge-off { background: rgba(220, 40, 40, 0.15); color: #ff8b8b; }

.admin-users-form {
    flex: 1;
    padding: 22px 26px;
    overflow-y: auto;
}

.admin-form-empty {
    color: var(--fg-dim);
    font-size: 14px;
    margin-top: 20px;
}

.admin-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 20px;
}

.admin-form-checkbox {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}
.admin-form-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--gold);
}
.admin-form-checkbox .field-label {
    margin-bottom: 0;
    text-transform: none;
    letter-spacing: 0;
    font-size: 13px;
    color: var(--fg);
}

.admin-form-password[hidden] { display: none; }
.field-label-hint {
    font-size: 10px;
    color: var(--fg-dim);
    margin-left: 4px;
    text-transform: none;
    letter-spacing: 0;
}

.admin-form-meta {
    margin-top: 18px;
    font-size: 11px;
    color: var(--fg-dim);
    letter-spacing: 0.02em;
}

.admin-form-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.admin-form-buttons .btn-primary { width: auto; margin-top: 0; }

/* ---------- Toast ---------- */
#shell-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 16px;
    color: var(--fg);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.18s, transform 0.18s;
    pointer-events: none;
    font-size: 13px;
}
#shell-toast.shown {
    opacity: 1;
    transform: translateY(0);
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    margin-left: 4px;
    background: transparent;
    color: var(--fg-dim);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: color .15s ease, background-color .15s ease, border-color .15s ease;
}
.theme-toggle:hover {
    color: var(--gold);
    background: var(--gold-soft);
    border-color: var(--gold);
}
.theme-toggle:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}
.theme-toggle svg { display: none; }
:root[data-theme="dark"]  .theme-toggle .ti-sun  { display: block; }
:root[data-theme="light"] .theme-toggle .ti-moon { display: block; }

/* ---------- Light-mode tweaks for hardcoded reds ---------- */
:root[data-theme="light"] .flash-error {
    background: rgba(185, 28, 28, 0.08);
    color: #8a1717;
    border-color: rgba(185, 28, 28, 0.35);
}
:root[data-theme="light"] .exchange-tile.inactive .exchange-tile-status,
:root[data-theme="light"] .badge-off {
    color: #8a1717;
}
:root[data-theme="light"] .badge-off {
    background: rgba(185, 28, 28, 0.10);
}

/* Toast on light */
:root[data-theme="light"] #shell-toast {
    background: #1a1e26;
    color: #f7f4ec;
    box-shadow: 0 6px 24px rgba(40, 30, 10, 0.18);
}

/* ---------- Tile key-status pill (J.6.0; restyled 2026-07-03) ---------- */
.tile-pill {
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid transparent;
    pointer-events: none;
    white-space: nowrap;
}
.tile-pill.has-key {
    background: rgba(63, 185, 80, 0.12);
    color: var(--green);
    border-color: rgba(63, 185, 80, 0.40);
}
.tile-pill.needs-key {
    background: var(--gold-soft);
    color: var(--gold);
    border-color: rgba(232, 180, 84, 0.45);
}
.tile-pill.soon {
    background: transparent;
    color: var(--faint);
    border-color: var(--border);
}
.tile-pill.err {
    background: rgba(248, 81, 73, 0.12);
    color: var(--red);
    border-color: rgba(248, 81, 73, 0.40);
}

/* ---------- Exchange tile config icon (T.1) ---------- */
.tile-config-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    color: var(--fg-dim);
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    -webkit-user-select: none;
    user-select: none;
}
.tile-config-btn:hover { color: var(--gold); border-color: var(--gold); background: var(--gold-soft); }
.tile-config-btn svg { pointer-events: none; }

/* ---------- AI provider credit-error line (T.2) ---------- */
.exchange-tile[data-credit-error="true"] { border-color: rgba(248, 81, 73, 0.45); }
.tile-credit-error {
    font-size: 0.74rem;
    color: var(--red);
    letter-spacing: 0.01em;
}

/* ---------- Field hint (shared) ---------- */
.field-hint {
    margin: 4px 0 0;
    font-size: 11px;
    color: var(--fg-dim);
}

/* ---------- Credentials modal (compact redesign, 2026-07-03) ---------- */
.cred-modal {
    position: fixed;
    inset: 0;
    z-index: 120;
    background: rgba(8, 10, 14, 0.66);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.cred-modal[hidden] { display: none; }
.cred-surface {
    position: relative;
    width: 100%;
    max-width: 440px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-top: 2px solid var(--gold);
    border-radius: 14px;
    padding: 22px 24px;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.6);
    animation: hd-rise 0.18s ease-out;
}
.cred-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--fg-dim);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.cred-close:hover { color: var(--fg); background: var(--bg-card); }
.cred-head { display: flex; align-items: center; gap: 13px; margin-bottom: 18px; padding-right: 28px; }
.cred-logo {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 6px;
    border-radius: 11px;
    object-fit: contain;
    background: var(--gold-soft);
    box-sizing: border-box;
}
/* author display beats the UA [hidden] rule — keep this or the monogram
   shows next to the brand mark (same gotcha as pos_chart's .cp-note) */
.cred-mono[hidden] { display: none; }
.cred-mono {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 11px;
    background: var(--gold-soft);
    color: var(--gold);
    font-family: var(--font-disp);
    font-size: 19px;
    font-weight: 800;
}
.cred-head-tx h2 {
    margin: 0;
    font-family: var(--font-disp);
    font-size: 16px;
    font-weight: 700;
    color: var(--fg);
}
.cred-sub { margin: 2px 0 0; font-size: 12px; color: var(--fg-dim); }
.cred-form .field { margin-bottom: 14px; }
.cred-form .field[hidden] { display: none; }
.cred-links {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 2px 0 0;
    font-size: 12.5px;
}
.cred-links:empty { display: none; }
.cred-links a { color: var(--fg-dim); }
.cred-links a:hover { color: var(--gold); text-decoration: none; }
.cred-links .tile-sep { color: var(--faint); }
.cred-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.cred-buttons .btn-primary { width: auto; margin-top: 0; }
/* .btn's display:inline-block beats the UA [hidden] rule — same gotcha as
   .cred-mono[hidden] above; without this the Remove button always shows */
.cred-buttons .btn[hidden] { display: none; }
/* Remove key — danger-tinted ghost, pushed to the far left of the row */
.cred-buttons .cred-remove {
    margin-right: auto;
    order: -1;
    color: #f85149;
    border-color: rgba(248, 81, 73, 0.35);
}
.cred-buttons .cred-remove:hover {
    color: #ff6a63;
    border-color: #f85149;
}


/* ── J.6.1 — running cost banner + popover ───────────────────── */
/* Deliberately understated — visible enough to glance, quiet enough
   to ignore. Solid-yellow strip was too loud (user feedback 2026-04-26). */
.ai-cost-banner {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 14px;
    margin: 0 0 14px;
    background: var(--warn-soft);
    color: var(--fg-dim);
    border: 1px solid var(--warn-soft);
    border-left: 2px solid var(--warn);
    border-radius: 4px;
    font-size: 11.5px;
    font-weight: 400;
    letter-spacing: 0.02em;
}
.ai-cost-label {
    font-weight: 500;
    text-transform: uppercase;
    font-size: 10.5px;
    letter-spacing: 0.10em;
    color: var(--fg-dim);
    opacity: 0.75;
}
.ai-cost-amount {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--fg);
}
.ai-cost-calls {
    color: var(--fg-dim);
    opacity: 0.55;
    font-size: 11px;
}
/* Master Trader Review v2 Session 2 — DailyAiBudgetUsd readout. Quiet
   on the green/normal path; turns red when the cap is reached so the
   user notices their advisors are now HOLD-gated. */
.ai-cost-budget {
    color: var(--fg-dim);
    opacity: 0.65;
    font-size: 11px;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.ai-cost-budget-exhausted {
    color: #d04a4a;
    opacity: 1;
    font-weight: 600;
}
.ai-cost-detail {
    margin-left: auto;
    background: transparent;
    color: var(--fg-dim);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 2px 8px;
    font-size: 10.5px;
    letter-spacing: 0.04em;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 160ms ease, color 160ms ease;
}
.ai-cost-detail:hover {
    opacity: 1;
    color: var(--fg);
    background: var(--warn-soft);
}

.ai-cost-popover {
    position: absolute;
    right: 6px;
    top: calc(100% + 6px);
    min-width: 280px;
    padding: 14px 16px;
    background: var(--bg-panel);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    font-size: 13px;
    font-weight: 400;
    z-index: 50;
}
.ai-cost-popover[hidden] { display: none; }
.ai-cost-popover-heading {
    margin: 0 0 8px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--fg-dim);
}
.ai-cost-popover-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ai-cost-popover-list li {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    align-items: baseline;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 12.5px;
}
.ai-cost-popover-label {
    font-family: inherit;
    font-weight: 500;
    color: var(--fg);
}
.ai-cost-popover-calls {
    color: var(--fg-dim);
    font-size: 11.5px;
}
.ai-cost-popover-foot {
    margin: 10px 0 0;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--fg-dim);
    line-height: 1.4;
}


/* ── Cost-confirm modal extras (reuses .admin-modal-* classes) ───── */
.cost-confirm-surface {
    max-width: 460px;
}
.cost-confirm-action-label {
    margin: 0 0 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--fg);
}
.cost-confirm-summary {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.cost-confirm-summary-row {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 10px;
    font-size: 13px;
}
.cost-confirm-summary-key {
    color: var(--fg-dim);
}
.cost-confirm-summary-val {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-weight: 600;
    color: var(--fg);
}
.cost-confirm-skip {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--fg);
    margin-bottom: 10px;
    cursor: pointer;
}
.cost-confirm-skip input { cursor: pointer; }
.cost-confirm-foot {
    margin: 4px 0 0;
    font-size: 11.5px;
    line-height: 1.45;
}
.cost-confirm-buttons {
    margin-top: 16px;
    justify-content: flex-end;
}


/* Research-page styles live in agent/templates/agent_research.html
   (page-scoped under .flow-page — editorial broadsheet, J.6.1 redesign). */


/* ── My Profile page (2026-06-27) ─────────────────────────────────────── */
.profile-wrap { max-width: 620px; margin: 0 auto; }
.profile-title { font-size: 1.5rem; font-weight: 700; margin: 10px 0 24px; color: var(--fg); }
.profile-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px 26px;
}
.profile-card .section-heading { margin-top: 0; }
.profile-hint { color: var(--fg-dim); font-size: 0.85rem; margin: -4px 0 18px; }
.profile-form .field { margin-bottom: 16px; }
.profile-actions { display: flex; align-items: center; gap: 14px; margin-top: 4px; }
.profile-msg { font-size: 0.85rem; min-height: 1em; }
.profile-msg.ok { color: var(--green); }
.profile-msg.err { color: var(--red); }


/* ── Toobit tile Start/Stop control (2026-06-27) ──────────────────────── */
.tile-trade-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.tile-trade-status {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--fg-dim);
}
.tile-trade-status.stopped { color: var(--fg-dim); }
.tile-trade-status.dry { color: var(--gold); }
.tile-trade-status.live { color: var(--green); }
.tile-trade-btn {
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 7px;
    border: 1px solid var(--gold);
    color: var(--gold);
    -webkit-user-select: none;
    user-select: none;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.tile-trade-btn:hover { background: var(--gold-soft); }
.tile-trade-btn.stop { border-color: var(--red); color: var(--red); }
.tile-trade-btn.stop:hover { background: rgba(220, 40, 40, 0.12); }




/* ═══════════ /admin/ User Management — 2026-07-02 redesign ═══════════
   Dark command-deck styling for the admin console: Users directory +
   detail panel, Subscriptions payment history, System Billing cards.
   Typography rides the Toobit deck fonts (Sora display / Hanken Grotesk
   body / JetBrains Mono figures — loaded by admin_manage.html head_extra,
   graceful system-ui fallback). JS-rendered class names are load-bearing:
   .am-card/.am-table/.am-mono/.am-state/.am-proof*/.admin-user-row/… */

.am-page { font-family: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif; }

.am-pagehead { margin-bottom: 6px; }
.am-title {
    font-family: "Sora", system-ui, sans-serif;
    font-size: 26px; font-weight: 700; letter-spacing: -0.01em;
    margin: 0 0 2px; color: var(--fg);
}
.am-subtitle { margin: 0; color: var(--fg-dim); font-size: 13.5px; }

/* ---- top tab bar ---- */
.am-tabs { display: flex; gap: 4px; margin: 18px 0 20px; border-bottom: 1px solid var(--border); }
.am-tab {
    background: none; border: none; border-bottom: 2px solid transparent;
    color: var(--fg-dim); font: inherit; font-size: 14px; font-weight: 600;
    padding: 10px 16px 12px; cursor: pointer; letter-spacing: 0.01em;
    margin-bottom: -1px; transition: color .15s ease;
}
.am-tab:hover { color: var(--fg); }
.am-tab.active { color: var(--gold); border-bottom-color: var(--gold); }

/* ---- toolbar (search / range) ---- */
.am-toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.am-search { position: relative; flex: 1 1 320px; max-width: 460px; display: flex; align-items: center; color: var(--fg-dim); }
.am-search svg { position: absolute; left: 12px; pointer-events: none; }
.am-search input {
    width: 100%; padding: 10px 14px 10px 38px;
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: 10px;
    color: var(--fg); font: inherit; font-size: 14px;
}
.am-search input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.am-search input::placeholder { color: var(--fg-dim); opacity: .7; }
.am-newuser { width: auto; margin: 0; white-space: nowrap; }

/* ---- Users: directory + detail panel ---- */
.am-users-layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 20px; align-items: start; }
.am-users-list {
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px;
    padding: 8px; max-height: calc(100vh - 300px); min-height: 220px; overflow-y: auto;
}
.am-page .admin-user-row {
    display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
    background: transparent; border: 1px solid transparent; border-radius: 10px;
    color: var(--fg); padding: 11px 12px; margin-bottom: 2px; cursor: pointer; font: inherit;
    transition: background .12s ease, border-color .12s ease;
}
.am-page .admin-user-row:hover { background: var(--bg-card); border-color: var(--border); }
.am-page .admin-user-row.selected {
    background: var(--bg-card); border-color: rgba(201, 162, 75, 0.55);
    box-shadow: inset 3px 0 0 var(--gold);
}
.am-avatar {
    flex: 0 0 38px; width: 38px; height: 38px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--gold-soft); color: var(--gold);
    font-family: "Sora", sans-serif; font-weight: 700; font-size: 14px; letter-spacing: .02em;
}
.am-user-cell { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.am-page .admin-user-name { font-weight: 600; font-size: 14px; margin: 0; }
.admin-user-mail { color: var(--fg-dim); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.am-list-empty { color: var(--fg-dim); font-size: 13px; padding: 18px 14px; margin: 0; }

.am-panel { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px; padding: 22px 24px; }
.am-user-detail { min-height: 420px; }

/* segmented Profile | Billing control */
.am-subtabs {
    display: inline-flex; gap: 2px; padding: 3px;
    background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
    margin-bottom: 20px;
}
.am-subtabs[hidden] { display: none; }
.am-subtab {
    background: none; border: none; border-radius: 8px; padding: 7px 18px;
    color: var(--fg-dim); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.am-subtab.active { background: var(--bg-card); color: var(--gold); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25); }

/* empty states */
.am-empty { text-align: center; color: var(--fg-dim); padding: 64px 20px; font-size: 14px; }
.am-empty-glyph { font-size: 40px; color: var(--gold); opacity: .5; margin-bottom: 10px; }
.am-empty p { margin: 0; line-height: 1.7; }
.am-empty-slim { padding: 36px 20px; }

.am-page .admin-form-grid { gap: 16px 22px; }

/* ---- Subscriptions tab ---- */
.am-glabel { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--fg-dim); }
.am-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.am-pill {
    background: transparent; border: 1px solid var(--border); border-radius: 999px;
    color: var(--fg-dim); font: inherit; font-size: 12.5px; font-weight: 600;
    padding: 7px 16px; cursor: pointer;
    transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.am-pill:hover { color: var(--fg); border-color: var(--fg-dim); }
.am-pill.on { background: var(--gold-soft); border-color: var(--gold); color: var(--gold); }
.am-range-custom { display: flex; align-items: center; gap: 10px; margin: -6px 0 18px; flex-wrap: wrap; }
.am-range-custom[hidden] { display: none; }
.am-range-custom input[type="date"] {
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: 8px;
    color: var(--fg); font: inherit; font-size: 13px; padding: 7px 10px; color-scheme: dark;
}
:root[data-theme="light"] .am-range-custom input[type="date"] { color-scheme: light; }
.am-range-arrow { color: var(--fg-dim); }
.am-range-hint { font-size: 12px; color: var(--red); }

.am-band { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.am-band:empty { display: none; }
.am-stat {
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px;
    padding: 16px 18px; display: flex; flex-direction: column; gap: 6px;
}
.am-stat .k { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--fg-dim); }
.am-stat .v { font-family: "Sora", sans-serif; font-size: 22px; font-weight: 700; color: var(--fg); line-height: 1.2; }
.am-stat .v.am-mono { font-family: "JetBrains Mono", ui-monospace, monospace; }

.am-sub-tablewrap { padding: 6px 18px 14px; overflow-x: auto; }
.am-user-inline { display: block; font-weight: 600; }
.am-user-mail-inline { display: block; color: var(--fg-dim); font-size: 11.5px; }
.am-plan-chip {
    display: inline-block; padding: 2px 10px; border-radius: 999px;
    background: var(--gold-soft); color: var(--gold);
    font-size: 11px; font-weight: 700; letter-spacing: .05em;
}
.am-amount { font-weight: 700; color: var(--green); }
.am-num { text-align: right; }
.am-method { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.am-method.auto { background: rgba(38, 200, 90, 0.15); color: var(--green); }
.am-method.manual { background: rgba(56, 139, 253, 0.16); color: #58a6ff; }
.am-method.admin { background: var(--gold-soft); color: var(--gold); }

/* ---- shared cards + tables (System Billing / per-user Billing) ---- */
.am-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 20px; }
.am-card {
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px;
    padding: 20px 22px; overflow-x: auto;
}
.am-card h3 {
    margin: 0 0 14px; font-family: "Sora", sans-serif; font-size: 14px; font-weight: 600;
    letter-spacing: .02em; color: var(--fg);
}
.am-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.am-table th {
    text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border);
    font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
    color: var(--fg-dim); white-space: nowrap;
}
.am-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.am-table tbody tr:last-child td { border-bottom: none; }
.am-table tbody tr:hover td { background: rgba(201, 162, 75, 0.04); }
.am-table th.am-num, .am-table td.am-num { text-align: right; }
.am-mono { font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; }
.am-toast {
    position: fixed; bottom: 24px; right: 24px;
    background: var(--bg-card); border: 1px solid var(--gold); color: var(--fg);
    padding: 12px 18px; border-radius: 10px; z-index: 200;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
}
.am-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.am-billing-status { display: flex; gap: 14px; align-items: baseline; margin-bottom: 14px; flex-wrap: wrap; }
.am-state { padding: 2px 10px; border-radius: 999px; font-size: 12px; text-transform: uppercase; font-weight: 700; }
.am-state.active { background: rgba(46,160,67,.18); color: #3fb950; }
.am-state.grace { background: rgba(210,153,34,.18); color: #d29922; }
.am-state.expired, .am-state.none { background: rgba(248,81,73,.18); color: #f85149; }
.am-state.lifetime { background: rgba(56,139,253,.18); color: #58a6ff; }

/* login-page .field/.btn-primary full-width rules break card layouts; scope down */
.am-card .field { margin-bottom: 20px; }
.am-card .field .am-actions input { width: auto; flex: 1 1 260px; }
.am-page .btn-primary { width: auto; margin-top: 0; }
.am-table input:not([type="checkbox"]) {
    width: 100%; min-width: 110px; padding: 6px 8px;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 6px; color: var(--fg); font-size: 13px;
}
.am-table .sba-address, .am-table input.sba-address { min-width: 330px; }
#sb-addresses, #sb-proofs { grid-column: 1 / -1; }

/* ---- Phase AR Slice 5 — proof review card (System Billing tab) ---- */
.am-proof { display: flex; gap: 14px; padding: 14px 0; border-top: 1px solid var(--border); }
.am-proof:first-child { border-top: 0; }
.am-proof-img { max-width: 180px; max-height: 220px; border-radius: 8px; border: 1px solid var(--border); object-fit: contain; }
.am-proof-missing { display: flex; align-items: center; justify-content: center; width: 120px; height: 80px; font-size: 12px; opacity: 0.6; }
.am-proof-meta { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.am-proof-proposal { font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.am-clear-proofs { margin-top: 12px; align-items: center; }

/* ---- Pending Orders tab (mig 153) ---- */
.am-po-toolbar { margin-bottom: 14px; }
.am-po-counts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.am-count-chip {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 6px 14px; border-radius: 999px;
    background: var(--bg-panel); border: 1px solid var(--border);
    color: var(--fg-dim); font-size: 12.5px; font-weight: 600;
}
.am-count-chip b { color: var(--fg); font-family: "JetBrains Mono", ui-monospace, monospace; font-weight: 700; }
.am-count-chip.warn { border-color: var(--warn); color: var(--warn); }
.am-po-balances {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px;
    padding: 12px 16px; margin-bottom: 18px;
}
.am-bal-chip {
    display: inline-flex; align-items: baseline; gap: 8px;
    padding: 5px 12px; border-radius: 8px;
    background: var(--bg); border: 1px solid var(--border); font-size: 12.5px;
}
.am-bal-chip .c { color: var(--fg-dim); font-weight: 600; }
.am-bal-chip .b { font-family: "JetBrains Mono", ui-monospace, monospace; font-weight: 700; color: var(--fg); }
.am-bal-chip.funded { border-color: rgba(38, 200, 90, 0.5); }
.am-bal-chip.funded .b { color: var(--green); }
.am-po-card {
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px;
    padding: 18px 22px; margin-bottom: 14px;
}
.am-po-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.am-po-head .am-mono { font-size: 13.5px; font-weight: 700; }
.am-po-expect { margin-left: auto; text-align: right; }
.am-po-expect .k { display: block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--fg-dim); }
.am-po-expect .v { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 20px; font-weight: 700; color: var(--gold); }
.am-po-sub { color: var(--fg-dim); font-size: 12.5px; margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.am-po-status { padding: 2px 10px; border-radius: 999px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.am-po-status.issued { background: var(--gold-soft); color: var(--gold); }
.am-po-status.awaiting_review { background: rgba(56, 139, 253, 0.16); color: #58a6ff; }
.am-po-proofs { margin-top: 14px; border-top: 1px dashed var(--border); padding-top: 4px; }
.am-po-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.am-po-empty-note { color: var(--fg-dim); font-size: 12px; }
.am-po-status.funds { background: rgba(38, 200, 90, 0.15); color: var(--green); }
.am-funds-note { margin-top: 6px; }
.am-po-sec-title {
    font-family: "Sora", system-ui, sans-serif; font-size: 14px; font-weight: 600;
    color: var(--fg); margin: 26px 0 12px;
}
#po-unmatched select.pou-inv {
    background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
    color: var(--fg); font: inherit; font-size: 12.5px; padding: 6px 8px; max-width: 340px;
}
.am-page .btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.am-page .btn[disabled]:hover { filter: none; border-color: var(--border); color: inherit; }

/* ---------- HModal — styled promise dialogs (replaces native confirm/prompt) ---------- */
.hmodal-backdrop {
    position: fixed; inset: 0; z-index: 300;
    background: rgba(8, 10, 14, 0.66);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center;
    padding: 24px; opacity: 0; transition: opacity .13s ease;
}
.hmodal-backdrop.open { opacity: 1; }
.hmodal {
    width: 100%; max-width: 460px;
    background: var(--bg-panel); border: 1px solid var(--border);
    border-top: 2px solid var(--gold);
    border-radius: 14px; padding: 22px 24px;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.6);
    transform: translateY(10px) scale(0.98); transition: transform .13s ease;
    font-family: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
}
.hmodal-backdrop.open .hmodal { transform: none; }
.hmodal-title {
    margin: 0 0 8px; font-family: "Sora", system-ui, sans-serif;
    font-size: 16px; font-weight: 700; color: var(--fg);
}
.hmodal-msg { color: var(--fg-dim); font-size: 13.5px; line-height: 1.6; white-space: pre-line; }
.hmodal-input {
    width: 100%; margin-top: 14px; padding: 10px 12px;
    background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
    color: var(--fg); font-size: 14px;
}
.hmodal-input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.hmodal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.hmodal-actions .btn-primary { width: auto; margin: 0; }
.hmodal-ok.danger { background: var(--red); color: #fff; }
.hmodal-ok.danger:hover { filter: brightness(1.1); }

/* ---- responsive ---- */
@media (max-width: 960px) {
    .am-users-layout { grid-template-columns: 1fr; }
    .am-users-list { max-height: 320px; }
    .am-band { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .am-cards { grid-template-columns: 1fr; }
    .am-po-expect { margin-left: 0; text-align: left; }
}


/* ═══════════ /help/api-keys — API key guide page (2026-07-03) ═══════════ */
.kg-wrap { max-width: 860px; margin: 0 auto; }
.kg-wrap .hd-hero { margin-top: 14px; max-width: none; }
.kg-toc { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.kg-chip {
    display: inline-flex;
    align-items: center;
    padding: 7px 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--fg-dim);
    font-size: 12.5px;
    font-weight: 600;
    transition: color 0.12s ease, border-color 0.12s ease;
}
.kg-chip:hover { color: var(--gold); border-color: var(--gold); text-decoration: none; }

.kg-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--card-shadow);
    padding: 24px 26px;
    margin-bottom: 20px;
    scroll-margin-top: 84px;      /* sticky header offset for #anchors */
}
.kg-card-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 16px; }
.kg-card-head .tile-mono { flex: 0 0 46px; width: 46px; height: 46px; font-size: 20px; }
.kg-card-head h2 {
    margin: 2px 0 4px;
    font-family: var(--font-disp);
    font-size: 18px;
    font-weight: 700;
    color: var(--fg);
}
.kg-tag {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--fg-dim);
    margin-left: 8px;
}
.kg-lede { margin: 0; color: var(--fg-dim); font-size: 13.5px; }

.kg-steps { margin: 0 0 6px; padding-left: 22px; display: flex; flex-direction: column; gap: 9px; }
.kg-steps li { font-size: 13.5px; line-height: 1.65; color: var(--fg); }
.kg-steps li b { color: var(--fg); }
.kg-steps li i { color: var(--fg-dim); font-style: normal; font-weight: 600; }
.kg-steps li code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 1px 6px;
}
.kg-steps li::marker { color: var(--gold); font-family: var(--font-mono); font-weight: 700; }
.kg-bullets { list-style: disc; }

.kg-warn {
    margin: 14px 0 4px;
    padding: 12px 15px;
    border: 1px solid rgba(216, 160, 42, 0.4);
    border-left: 3px solid var(--warn);
    border-radius: 9px;
    background: var(--warn-soft);
    font-size: 13px;
    line-height: 1.6;
    color: var(--fg);
}

.kg-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.kg-actions .btn { width: auto; margin-top: 0; }
.kg-security { margin-bottom: 60px; }

/* ---- shell responsive polish (2026-07-03) ---- */
@media (max-width: 760px) {
    .shell-header { padding: 10px 16px; }
    .shell-main { padding: 20px 16px; }
    .shell-title { font-size: 15px; }
    .subchip .sc-tx { display: none; }
    .hd-grid { grid-template-columns: 1fr; }
    .admin-row .admin-tile { flex: 1 1 100%; }
    .kg-card { padding: 20px 18px; }
}
