/* Pxie Dashboard — design tokens match pxie.ai */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:           #04060f;
    --bg-surface:   rgba(255, 255, 255, 0.03);
    --bg-elevated:  rgba(255, 255, 255, 0.05);
    --border:       rgba(255, 255, 255, 0.07);
    --border-hover: rgba(255, 255, 255, 0.14);
    --text:         #e4e8f0;
    --text-dim:     #8a92a8;
    --accent:       #1d5aff;
    --accent-hover: #4074ff;
    --accent-mcp:   #a78bfa;   /* purple — MCP only */
    --success:      #4ade80;
    --warning:      #fbbf24;
    --danger:       #f87171;
    --danger-bg:    rgba(239, 68, 68, 0.08);
    --radius-sm:    6px;
    --radius-md:    8px;
    --radius-lg:    12px;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
/* Grid background matching pxie.ai, fading out toward the edges */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(29, 90, 255, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(29, 90, 255, 0.06) 1px, transparent 1px);
    background-size: 48px 48px;
    -webkit-mask-image: radial-gradient(ellipse at center, #000 40%, transparent 90%);
    mask-image: radial-gradient(ellipse at center, #000 40%, transparent 90%);
    pointer-events: none;
    z-index: 0;
}

.layout {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: 100vh;
}

/* ── Nav ────────────────────────────────────────────────────────────────── */
nav {
    background: rgba(4, 6, 15, 0.85);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

nav .logo {
    display: block;
    margin-bottom: 32px;
    padding: 0 4px;
}

nav .logo img {
    height: 28px;
    width: auto;
}

nav a {
    display: block;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    text-decoration: none;
    margin-bottom: 2px;
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
}

nav a:hover {
    background: var(--bg-elevated);
    color: var(--text);
}

nav a.active {
    background: rgba(29, 90, 255, 0.12);
    color: var(--text);
    border-left: 2px solid var(--accent);
    padding-left: 10px;
}

nav .nav-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    font-size: 0.78rem;
    color: var(--text-dim);
}

/* ── Main ───────────────────────────────────────────────────────────────── */
main { padding: 40px; }

h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.subtitle {
    color: var(--text-dim);
    margin-bottom: 40px;
    font-size: 0.95rem;
}

/* ── Stat cards ─────────────────────────────────────────────────────────── */
.stats { display: grid; gap: 16px; margin-bottom: 40px; }
.stats-3 { grid-template-columns: repeat(3, 1fr); }
.stats-4 { grid-template-columns: repeat(4, 1fr); }

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: border-color 0.15s;
}

.stat-card:hover { border-color: var(--border-hover); }

.stat-card .label {
    font-size: 0.72rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    margin-top: 8px;
    line-height: 1;
}

.stat-card .sub {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 6px;
}

.stat-card .sub a { color: var(--accent); text-decoration: none; }
.stat-card .sub a:hover { color: var(--accent-hover); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    font-weight: 500;
    transition: background 0.15s;
}

.btn:hover    { background: var(--accent-hover); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-outline {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    transition: border-color 0.15s, color 0.15s;
}

.btn-outline:hover { border-color: var(--text-dim); color: var(--text); }

.btn-sm {
    background: var(--bg-elevated);
    border: 1px solid var(--border-hover);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    font-size: 0.78rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-sm:hover { background: rgba(255, 255, 255, 0.08); }

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: inherit;
    transition: background 0.15s;
}

.btn-danger:hover { background: var(--danger-bg); }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 10px;
    transition: border-color 0.15s;
}

.card:hover { border-color: var(--border-hover); }

/* ── Tier badges ────────────────────────────────────────────────────────── */
.tier-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tier-xplorer { background: rgba(138, 146, 168, 0.12); color: var(--text-dim); }
.tier-builder  { background: rgba(29,  90, 255, 0.15);  color: #7aa3ff; }
.tier-scale    { background: rgba(167, 139, 250, 0.15); color: var(--accent-mcp); }

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: rgba(4, 6, 15, 0.95);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-md);
    padding: 12px 20px;
    font-size: 0.88rem;
    backdrop-filter: blur(12px);
    z-index: 999;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
}

.toast.show    { opacity: 1; transform: translateY(0); }
.toast.error   { border-color: rgba(239, 68, 68, 0.4);  color: var(--danger); }
.toast.success { border-color: rgba(74, 222, 128, 0.4); color: var(--success); }

/* ── Inputs ─────────────────────────────────────────────────────────────── */
input[type="text"],
input[type="email"],
input[type="number"] {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}

input:focus { border-color: var(--accent); }

/* ── Monospace ──────────────────────────────────────────────────────────── */
.mono {
    font-family: 'Courier New', ui-monospace, monospace;
    font-size: 0.85rem;
    color: var(--accent-mcp);
}

/* ── Section header ─────────────────────────────────────────────────────── */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-title { font-size: 1rem; font-weight: 600; }

/* ── Skeleton loading ───────────────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg,
        rgba(255,255,255,0.04) 25%,
        rgba(255,255,255,0.08) 50%,
        rgba(255,255,255,0.04) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    color: transparent !important;
    user-select: none;
}

@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(4, 6, 15, 0.8);
    z-index: 100;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-overlay.open { display: flex; }

.modal {
    background: #090c1a;
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 420px;
    max-width: calc(100vw - 32px);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.modal h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 20px; }

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ── Account setup notice (config.js pxieApi) ───────────────────────────── */
.setup-notice {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    background: rgba(29, 90, 255, 0.15);
    border: 1px solid rgba(29, 90, 255, 0.4);
    color: var(--text);
    border-radius: var(--radius-md);
    padding: 10px 18px;
    font-size: 0.9rem;
}

nav .nav-signout {
    display: block;
    margin-top: 10px;
    width: 100%;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    padding: 7px 10px;
    font-size: 0.82rem;
    text-align: left;
    cursor: pointer;
}
nav .nav-signout:hover { border-color: var(--border-hover); color: var(--text); }

/* ── Nav icons ──────────────────────────────────────────────────────────────
   Pure CSS (mask + currentColor) so links that config.js injects get icons too,
   with no flash on load. Icon shapes: Lucide (ISC licence). */
nav a:not(.logo), nav .nav-signout {
    display: flex;
    align-items: center;
    gap: 10px;
}
nav a:not(.logo)::before, nav .nav-signout::before {
    content: "";
    flex: none;
    width: 16px;
    height: 16px;
    background: currentColor;
    opacity: 0.7;
    -webkit-mask: var(--icon) center / contain no-repeat;
    mask: var(--icon) center / contain no-repeat;
    transition: opacity 0.15s;
}
nav a:not(.logo):hover::before, nav .nav-signout:hover::before { opacity: 1; }
nav a.active::before { background: var(--accent); opacity: 1; }

nav a[href="index.html"]:not(.logo) { --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect width='7' height='9' x='3' y='3' rx='1'/><rect width='7' height='5' x='14' y='3' rx='1'/><rect width='7' height='9' x='14' y='12' rx='1'/><rect width='7' height='5' x='3' y='16' rx='1'/></svg>"); }
nav a[href="keys.html"] { --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='7.5' cy='15.5' r='5.5'/><path d='m21 2-9.6 9.6'/><path d='m15.5 7.5 3 3L22 7l-3-3'/></svg>"); }
nav a[href="playground.html"] { --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='4 17 10 11 4 5'/><line x1='12' x2='20' y1='19' y2='19'/></svg>"); }
nav a[href="billing.html"] { --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect width='20' height='14' x='2' y='5' rx='2'/><line x1='2' x2='22' y1='10' y2='10'/></svg>"); }
nav a[href="account.html"] { --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2'/><circle cx='12' cy='7' r='4'/></svg>"); }
nav a[target="_blank"] { --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z'/><path d='M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z'/></svg>"); }
nav .nav-signout { --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/><polyline points='16 17 21 12 16 7'/><line x1='21' x2='9' y1='12' y2='12'/></svg>"); }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ── Phone menu button (hidden on desktop) ──────────────────────────────── */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    margin-left: auto;
    padding: 0 11px;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.nav-toggle span {
    display: block;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}
.nav-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.nav-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Phone layout: nav becomes a top bar ────────────────────────────────── */
@media (max-width: 760px) {
    .layout { grid-template-columns: 1fr; }
    nav {
        position: static;
        height: auto;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 4px;
        padding: 12px 16px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    nav .logo { margin: 0 8px 0 0; }
    nav a { padding: 6px 10px; margin: 0; }
    nav a.active { border-left: none; padding-left: 10px; }
    nav .nav-footer { display: none; }
    nav .nav-signout { width: auto; margin: 0 0 0 auto; }

    /* ☰ menu (config.js adds the button and .has-toggle) */
    nav.has-toggle { position: sticky; top: 0; z-index: 50; gap: 0; }
    nav.has-toggle > a:not(.logo),
    nav.has-toggle > .nav-footer,
    nav.has-toggle > .nav-signout { display: none; }
    nav.has-toggle .nav-toggle { display: flex; }
    nav.has-toggle.nav-open { padding-bottom: 16px; }
    nav.has-toggle.nav-open > a:not(.logo) {
        display: flex; width: 100%; padding: 12px; margin-top: 2px; font-size: 1rem;
    }
    nav.has-toggle.nav-open > a.active { border-left: 2px solid var(--accent); padding-left: 10px; }
    nav.has-toggle.nav-open > .nav-footer {
        display: block; width: 100%; margin-top: 10px; padding: 12px 12px 0;
    }
    nav.has-toggle.nav-open > .nav-signout {
        display: flex; width: 100%; margin: 10px 0 0; padding: 10px 12px; font-size: 0.95rem;
    }
    main { padding: 24px 16px; }
    .stats-3, .stats-4 { grid-template-columns: 1fr; }
}

/* ── Scrollbars (theme) ─────────────────────────────────────────────────── */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--accent) rgba(255, 255, 255, 0.04);
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.04); border-radius: 8px; }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-hover); }
::-webkit-scrollbar-corner { background: transparent; }
