/* #700: the Account page was permanently dark (its only palette). It is now
   theme-aware: light is the default; dark is applied via [data-theme="dark"],
   set pre-paint by the <head> bootstrap from the shared localStorage['fraim-theme']
   key (or OS preference). Dark values below are the page's original palette. */
:root {
    color-scheme: light;
    --bg: #f5f5f7;
    --panel: #ffffff;
    --panel-2: #fafafa;
    --panel-3: #f0f0f3;
    --border: #e3e3e8;
    --border-strong: #d2d2d9;
    --text: #1a1a1a;
    --text-muted: #6b6b6b;
    --text-dim: #8a8a8a;
    --accent: #4f46e5;
    --accent-2: #6366f1;
    --accent-cta: #4f46e5;
    --accent-cta-hover: #4338ca;
    --accent-soft: rgba(99, 102, 241, .12);
    --success: #16a34a;
    --warn: #b8860b;
    --danger: #dc2626;
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0b0d12;
    --panel: #12151c;
    --panel-2: #171b24;
    --panel-3: #1c212c;
    --border: #232936;
    --border-strong: #2c3343;
    --text: #e6e9ef;
    --text-muted: #9aa3b2;
    --text-dim: #6b7280;
    --accent: #6366f1;
    --accent-2: #818cf8;
    --accent-cta: #4f46e5;
    --accent-cta-hover: #4338ca;
    --accent-soft: rgba(99, 102, 241, .15);
    --success: #22c55e;
    --warn: #f59e0b;
    --danger: #ef4444;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

/* HTML5 [hidden] attribute must beat CSS display rules. Without this,
   `.modal { display: flex }` and `.confirm-banner { display: flex }`
   override `hidden` and the modal sits on top of every interactive
   element on first paint, blocking clicks. Same root cause as the
   sign-in.css fix earlier in this issue. */
[hidden] { display: none !important; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
}

.account-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
    min-width: 0;
}

.sidebar {
    background: var(--panel-2);
    border-right: 1px solid var(--border);
    padding: 22px 0;
    min-width: 0;
}

.sidebar .brand {
    display: flex; align-items: center; gap: 10px;
    padding: 0 22px 20px;
    font-weight: 700;
}

.sidebar .brand .logo {
    width: 28px; height: 28px; border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.sidebar h4 {
    margin: 0 22px 8px;
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.sidebar ul { list-style: none; margin: 0; padding: 0; }

.sidebar li {
    padding: 9px 22px;
    font-size: 13.5px;
    color: var(--text-muted);
    cursor: pointer;
    border-left: 2px solid transparent;
}

.sidebar li.active {
    background: var(--accent-soft);
    color: var(--text);
    border-left-color: var(--accent);
}

.sidebar li:hover:not(.active) { background: var(--panel-3); color: var(--text); }

.content { padding: 28px 32px 64px; max-width: 920px; min-width: 0; }

.content header h1 { margin: 0; font-size: 22px; }
.content header .sub {
    margin: 4px 0 22px;
    color: var(--text-muted);
    font-size: 13px;
}

.row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    gap: 16px;
    min-width: 0;
}

.row .key { width: 200px; color: var(--text-muted); font-size: 13px; flex-shrink: 0; }
.row .val { flex: 1; min-width: 0; }
.row .val.plain { font-size: 14px; }
.row .val.mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: var(--text-muted); }
.row .actions { display: flex; gap: 8px; flex-shrink: 0; min-width: 0; }

.key-expiry-text {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.key-expiry-text.is-active {
    background: rgba(34, 197, 94, .12);
    border: 1px solid rgba(34, 197, 94, .35);
    color: var(--success);
}

.key-expiry-text.is-expired {
    background: rgba(239, 68, 68, .12);
    border: 1px solid rgba(239, 68, 68, .35);
    color: var(--danger);
}

.key-expiry-text.is-unavailable {
    background: rgba(107, 114, 128, .18);
    border: 1px solid rgba(107, 114, 128, .28);
    color: var(--text-muted);
}

.key-hidden {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
    padding: 4px 10px;
    background: var(--panel-2);
    border: 1px dashed var(--border-strong);
    border-radius: 6px;
    color: var(--text-dim);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12.5px;
}

button { font-family: inherit; cursor: pointer; }

button.primary {
    padding: 9px 14px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border: none;
    border-radius: 8px;
    color: #fff;
    font-weight: 600;
    font-size: 13px;
}

button.secondary,
.confirm-banner a.primary,
.modal-actions a.primary {
    padding: 8px 12px;
    background: transparent;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.modal-actions a.primary,
.confirm-banner a.primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border: none;
    color: #fff;
    font-weight: 600;
}

button.secondary[disabled] { opacity: .45; cursor: not-allowed; }

.confirm-banner {
    margin: 16px 0;
    padding: 14px 16px;
    background: rgba(245, 158, 11, .08);
    border: 1px solid rgba(245, 158, 11, .35);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    color: var(--text);
    font-size: 13px;
}

.confirm-banner .actions { display: flex; justify-content: flex-end; gap: 8px; }

.welcome-banner {
    margin: 0 0 20px;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(99, 102, 241, .10), rgba(99, 102, 241, .04));
    border: 1px solid rgba(99, 102, 241, .3);
    border-radius: 10px;
}
.welcome-heading {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}

.session-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.session-table th,
.session-table td {
    text-align: left;
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 12.5px;
}

.session-table th { color: var(--text-muted); font-weight: 500; background: var(--panel-2); }
.session-table .loading { color: var(--text-muted); }

.session-table .device { display: flex; flex-direction: column; gap: 2px; }
.session-table .device .d1 { color: var(--text); }
.session-table .device .d2 { color: var(--text-muted); font-size: 11.5px; }

.method-pill {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 10.5px;
    background: var(--accent-soft);
    color: var(--accent-2);
    border: 1px solid rgba(99, 102, 241, .35);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}

.method-pill.email-code { background: rgba(245, 158, 11, .15); color: var(--warn); border-color: rgba(245, 158, 11, .35); }
.method-pill.api-key { background: rgba(148, 163, 184, .15); color: var(--text-muted); border-color: rgba(148, 163, 184, .35); }

.badge-current {
    display: inline-block;
    margin-left: 6px;
    font-size: 10.5px;
    padding: 1px 7px;
    background: var(--accent-soft);
    color: var(--accent-2);
    border: 1px solid rgba(99, 102, 241, .35);
    border-radius: 999px;
}

.bulk-actions {
    margin-top: 14px;
    display: flex;
    justify-content: flex-end;
}

.link-danger {
    color: var(--danger);
    background: none;
    border: none;
    font-size: 12.5px;
    padding: 0;
    cursor: pointer;
}

.link-danger[disabled] { opacity: .45; cursor: not-allowed; }

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.modal-card {
    width: min(440px, 92vw);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .45);
}

.modal-card h3 { margin: 0 0 6px; font-size: 18px; }
.modal-card p { margin: 0 0 18px; color: var(--text-muted); font-size: 13.5px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Installer section */
.installer-section {
    margin-top: 28px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 12px;
    /* #700: end stop is token-driven so the fade follows the theme (was a
       hardcoded dark that turned the card near-black in light mode). */
    background: linear-gradient(180deg, rgba(99, 102, 241, .08), var(--panel-2));
}

.installer-heading {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 600;
}

.installer-sub {
    margin: 0 0 14px;
    color: var(--text-muted);
    font-size: 13px;
}

.installer-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.installer-card {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.installer-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.installer-card-title {
    font-weight: 600;
    font-size: 13.5px;
}

.installer-card-hint {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.platform-badge {
    flex-shrink: 0;
    border: 1px solid var(--border-strong);
    background: var(--panel-3);
    color: var(--text-muted);
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 700;
}

.installer-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-cta);
    color: #fff;
    text-decoration: none;
    border-radius: 7px;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 600;
}

.installer-btn:hover { background: var(--accent-cta-hover); color: #fff; }

/* Issue #646: macOS one-click installer note. */
.installer-mac-note {
    margin: 8px 0 0;
    font-size: 12px;
    color: var(--text-muted);
}

/* Issue #646 NEW-A: inline, retryable error for the setup-options reveal. */
.installer-error {
    margin: 10px 0 0;
    font-size: 13px;
    color: var(--danger);
}

.installer-code-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: 7px;
    padding: 8px 10px;
    min-width: 0;
}

.installer-code-row code {
    display: block;
    flex: 1;
    min-width: 0;
    max-width: 100%;
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11.5px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.installer-nodejs {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
    min-width: 0;
}

.installer-expire-note {
    margin: 0;
    font-size: 12px;
    color: var(--text-dim);
}

.link-btn {
    background: none;
    border: none;
    color: var(--accent-2);
    cursor: pointer;
    font-size: 12px;
    padding: 0;
    text-decoration: underline;
}

button.secondary.small {
    padding: 6px 10px;
    font-size: 12px;
    flex-shrink: 0;
}

@media (max-width: 760px) {
    .account-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .content {
        padding: 22px 18px 48px;
        max-width: none;
        width: 100%;
    }

    .row {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .row .key {
        width: auto;
    }

    .row .actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .installer-grid {
        grid-template-columns: 1fr;
    }

    .installer-section {
        padding: 16px;
    }
}

@media (max-width: 520px) {
    .installer-code-row {
        align-items: stretch;
        flex-direction: column;
    }

    .installer-code-row code {
        width: 100%;
    }

    button.secondary.small {
        width: 100%;
    }

    .session-table {
        display: block;
        overflow-x: auto;
    }
}
