/* ============================================================
   PatchWork Account portal (app/index.html).
   Built on the PatchWork Standard: tokens and `.sl-*` components
   come from /css/slate.css (loaded first). This file only lays the
   portal out; anything portal-specific is a `.pa-*` class. No token
   copies here — change a colour in slate.css.
   ============================================================ */

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

:root { --pa-topbar: 48px; }

html { -webkit-text-size-adjust: 100%; }

body {
    background: var(--sl-app);
    color: var(--sl-text-1);
    font-family: var(--sl-font-ui);
    font-size: 13px;
    line-height: 1.45;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a { color: var(--sl-link); text-decoration: none; }
a:hover { color: var(--sl-link-hover); }
a.sl-btn-secondary, a.sl-btn-primary { text-decoration: none; }
a.sl-btn-secondary:hover { color: var(--sl-text-1); }
[hidden] { display: none !important; }

/* ─── Top bar ─── */
.pa-topbar {
    position: sticky; top: 0; z-index: 100;
    height: var(--pa-topbar);
    background: var(--sl-panel);
    border-bottom: 1px solid var(--sl-hairline);
}
.pa-topbar-inner {
    max-width: 1200px; height: 100%; margin: 0 auto; padding: 0 32px;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.pa-brand { display: flex; align-items: center; gap: 10px; color: var(--sl-text-1); min-width: 0; }
.pa-brand:hover { color: var(--sl-text-1); }
.pa-brand img { width: 22px; height: 22px; flex: none; }
.pa-brand-name { font-size: 13.5px; font-weight: 700; }
.pa-env-badge {
    font-family: var(--sl-font-mono); font-size: 9.5px; letter-spacing: 0.12em;
    text-transform: uppercase; color: var(--sl-text-3);
}
.pa-user-block { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pa-link {
    display: inline-flex; align-items: center; height: var(--sl-h-sm); padding: 0 8px;
    border-radius: var(--sl-r-6); font-size: 12px; font-weight: 600; color: var(--sl-text-2); white-space: nowrap;
}
.pa-link:hover { background: var(--sl-wash); color: var(--sl-text-1); }
.pa-user-badge { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pa-avatar {
    width: 26px; height: 26px; border-radius: 50%; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--sl-control); color: var(--sl-text-1);
    font-size: 11px; font-weight: 700;
}
.pa-user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.pa-user-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.pa-user-tier { font-family: var(--sl-font-mono); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--sl-text-3); }
.pa-user-tier.is-studio { color: var(--sl-link); }

/* ─── Sign in (design: SignIn.dc.html) ─── */
.pa-auth {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    min-height: calc(100vh - var(--pa-topbar));
}
.pa-auth-col { display: flex; flex-direction: column; padding: 28px 48px; min-width: 0; }
.pa-auth-card { flex: 1; display: flex; flex-direction: column; justify-content: center; width: 100%; max-width: 360px; margin: 0 auto; padding: 32px 0; }
.pa-auth-form { display: flex; flex-direction: column; gap: 12px; }
.pa-auth-form .sl-h1 { margin: 0; }
.pa-auth-sub { font-size: 13px; line-height: 1.55; color: var(--sl-text-2); margin: -4px 0 14px; }
.pa-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pa-label { font-size: 12px; font-weight: 600; color: oklch(0.8 0.005 250); }
.pa-label-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pa-field .sl-input, .pa-inline-form .sl-input { width: 100%; height: var(--sl-h-xl); font-size: 13px; border-radius: var(--sl-r-10); }
.pa-code { font-family: var(--sl-font-mono); letter-spacing: 0.04em; text-transform: uppercase; }
.pa-code::placeholder { letter-spacing: 0.04em; }
.pa-pw { position: relative; }
.pa-pw .sl-input { padding-right: 40px; }
.pa-pw-toggle {
    position: absolute; right: 6px; top: 6px; width: 28px; height: 28px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border: none; border-radius: var(--sl-r-6); background: transparent; color: oklch(0.62 0.005 250); cursor: pointer;
}
.pa-pw-toggle:hover { color: var(--sl-text-1); background: var(--sl-wash); }
.pa-text-btn {
    padding: 0; border: none; background: none; cursor: pointer;
    font-family: var(--sl-font-ui); font-size: 11.5px; font-weight: 600; color: var(--sl-link);
}
.pa-text-btn:hover { color: var(--sl-link-hover); }
.pa-form-error {
    display: flex; align-items: center; gap: 8px; padding: 9px 11px; border-radius: var(--sl-r-8);
    background: var(--sl-danger-wash); font-size: 12px; color: var(--sl-danger-text);
}
.pa-submit { width: 100%; height: var(--sl-h-xl); margin-top: 4px; font-size: 13.5px; border-radius: var(--sl-r-10); }
.pa-switch { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; font-size: 12.5px; color: oklch(0.64 0.005 250); }
.pa-switch a { font-weight: 600; }
.pa-auth-foot { display: flex; gap: 16px; font-size: 11.5px; }
.pa-auth-foot a { color: var(--sl-text-3); }
.pa-auth-foot a:hover { color: var(--sl-text-1); }

.pa-auth-aside {
    display: flex; flex-direction: column; justify-content: center; padding: 48px 56px; min-width: 0;
    background: var(--sl-panel); border-left: 1px solid var(--sl-hairline);
}
.pa-aside-title {
    font-size: 34px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.12;
    margin-top: 14px; max-width: 460px; text-wrap: pretty;
}
.pa-aside-tools { display: flex; flex-direction: column; gap: 10px; margin-top: 32px; max-width: 460px; }
.pa-aside-tool {
    display: flex; align-items: center; gap: 14px; padding: 12px 14px;
    border-radius: var(--sl-r-12); background: var(--sl-card); border: 1px solid var(--sl-hairline);
}
.pa-aside-thumb {
    width: 52px; aspect-ratio: 4 / 3; border-radius: var(--sl-r-8); flex: none;
    display: flex; align-items: center; justify-content: center; color: oklch(1 0 0 / 0.85);
}
.pa-aside-thumb.is-studio { background: linear-gradient(155deg, oklch(0.5 0.07 230), oklch(0.28 0.045 230)); }
.pa-aside-thumb.is-canvas { background: linear-gradient(155deg, oklch(0.5 0.07 42), oklch(0.28 0.045 42)); }
.pa-aside-thumb.is-editor { background: linear-gradient(155deg, oklch(0.5 0.07 155), oklch(0.28 0.045 155)); }
.pa-aside-name { font-size: 13.5px; font-weight: 600; }
.pa-aside-line { font-size: 12px; color: oklch(0.64 0.005 250); margin-top: 2px; }

/* invite / forgot / reset flows (built in app/js/app.js) */
.pa-label-hint { font-weight: 400; color: var(--sl-text-3); }
.pa-uses { flex-wrap: wrap; width: 100%; }
.pa-uses .sl-seg-btn { flex: none; }
.pa-field textarea.sl-input { width: 100%; min-height: 72px; font-size: 13px; border-radius: var(--sl-r-10); }
.pa-hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.pa-done { display: flex; flex-direction: column; gap: 12px; }
.pa-done-ic {
    width: 40px; height: 40px; border-radius: var(--sl-r-12); margin-bottom: 4px;
    display: inline-flex; align-items: center; justify-content: center;
    background: oklch(0.76 0.16 156 / 0.14); color: var(--sl-success);
}
.pa-done .pa-auth-sub { margin: 0 0 8px; }

/* ─── Signed-in layout (design: Settings.dc.html — sections rail + pane) ─── */
.pa-layout {
    max-width: 1200px; margin: 0 auto; padding: 28px 32px 56px;
    display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 32px; align-items: start;
}
.pa-nav {
    position: sticky; top: calc(var(--pa-topbar) + 20px);
    display: flex; flex-direction: column; gap: 1px;
}
.pa-nav-label { padding: 4px 9px 8px; }
.pa-main { min-width: 0; max-width: 760px; }

.portal-panel { display: none; flex-direction: column; gap: 16px; }
.portal-panel.is-active { display: flex; }
.pa-pane-head { display: flex; align-items: center; gap: 11px; }
.pa-pane-rule { flex: 1; height: 1px; background: oklch(1 0 0 / 0.07); }
.pa-pane-blurb { font-size: 12px; line-height: 1.5; color: var(--sl-text-2); margin-top: -10px; margin-bottom: 4px; max-width: 560px; }

.pa-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.pa-kpi { padding: 14px 16px; border-radius: var(--sl-r-12); background: var(--sl-card); border: 1px solid var(--sl-hairline); min-width: 0; }
.pa-kpi-label { font-size: 11.5px; color: var(--sl-text-3); }
.pa-kpi-val {
    font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pa-kpi-val.is-text { font-size: 17px; letter-spacing: -0.01em; margin-top: 10px; }

.pa-card { padding: 16px; border-radius: var(--sl-r-12); background: var(--sl-card); border: 1px solid var(--sl-hairline); min-width: 0; }
.pa-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.pa-card-titles { flex: 1 1 240px; min-width: 0; }
.pa-card-title { font-size: 13.5px; font-weight: 600; color: var(--sl-text-1); }
.pa-card-sub { font-size: 12px; color: var(--sl-text-2); margin-top: 3px; line-height: 1.5; }
.pa-card-text { font-size: 12.5px; color: var(--sl-text-2); margin: 14px 0 12px; line-height: 1.55; }
.pa-actions { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; }
.pa-note { font-size: 11.5px; color: var(--sl-text-3); }
.pa-meter { margin-top: 14px; height: 6px; border-radius: 3px; }
.pa-meter > span { border-radius: 3px; transition: width 0.3s ease; }

.pa-plan-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 1px solid var(--sl-hairline); }
.pa-plan-name { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.pa-plan-price { display: flex; align-items: baseline; gap: 6px; flex: none; }
.pa-plan-amount { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.pa-plan-per { font-size: 12px; color: var(--sl-text-2); }
.pa-plan-status { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--sl-hairline); }
.pa-plan-kicker { margin: 16px 0 10px; }
.pa-features { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.pa-features li { position: relative; padding-left: 18px; font-size: 12.5px; line-height: 1.5; color: var(--sl-text-2); }
.pa-features li::before {
    content: ""; position: absolute; left: 3px; top: 7px; width: 5px; height: 5px; border-radius: 50%; background: var(--sl-accent);
}
.pa-features b { color: var(--sl-text-1); font-weight: 600; }

/* projects table — grid rows on .sl-table */
.pa-table { background: var(--sl-card); }
.pa-trow { display: grid; grid-template-columns: minmax(0, 1fr) 80px 110px auto; gap: 12px; align-items: center; }
.pa-trow .pa-r { justify-self: end; }
.pa-proj-name { font-size: 12.5px; font-weight: 600; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pa-proj-meta { font-family: var(--sl-font-mono); font-size: 11px; color: var(--sl-text-2); white-space: nowrap; }
.pa-proj-sub { display: none; }
.pa-table-empty { padding: 28px 16px; text-align: center; font-size: 12.5px; color: var(--sl-text-2); border-top: 1px solid oklch(1 0 0 / 0.05); }

.pa-form { display: flex; flex-direction: column; gap: 14px; max-width: 440px; }
.pa-inline-form { display: flex; gap: 8px; max-width: 440px; }
.pa-inline-form .sl-input { flex: 1; min-width: 0; }
.pa-inline-form .sl-btn-primary { height: var(--sl-h-xl); flex: none; }

/* ─── Toast ─── */
#portal-toast {
    position: fixed; right: 24px; bottom: 24px; z-index: 1000;
    display: flex; align-items: center; gap: 8px; max-width: min(360px, calc(100vw - 32px)); padding: 8px 12px;
    background: var(--sl-raised); border: 1px solid var(--sl-line-pop);
    border-radius: var(--sl-r-10); box-shadow: var(--sl-shadow-pop);
    color: var(--sl-text-1); font-size: 12.5px; font-weight: 500;
    opacity: 0; transform: translateY(8px); pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
#portal-toast.is-shown { opacity: 1; transform: none; }
.pa-toast-dot { width: 6px; height: 6px; border-radius: 50%; flex: none; background: var(--sl-success); }
#portal-toast.is-error .pa-toast-dot { background: var(--sl-error); }

/* ─── Narrow screens ─── */
@media (max-width: 900px) {
    .pa-auth { grid-template-columns: minmax(0, 1fr); }
    .pa-auth-aside { display: none; }
}

@media (max-width: 760px) {
    .pa-topbar-inner { padding: 0 16px; }
    .pa-link, .pa-user-text { display: none; }
    .pa-auth-col { padding: 20px 16px; }
    .pa-auth-card { padding: 16px 0 24px; justify-content: flex-start; }

    /* sections rail → one scrolling row of chips under the top bar */
    .pa-layout { display: block; padding: 0 0 40px; }
    .pa-nav {
        position: sticky; top: var(--pa-topbar); z-index: 50;
        flex-direction: row; gap: 4px; padding: 8px 16px;
        overflow-x: auto; scrollbar-width: none;
        background: var(--sl-app); border-bottom: 1px solid var(--sl-hairline);
    }
    .pa-nav::-webkit-scrollbar { display: none; }
    .pa-nav-label { display: none; }
    .pa-nav .sl-navitem { width: auto; flex: none; height: 36px; white-space: nowrap; }
    .pa-main { padding: 20px 16px 0; max-width: none; }

    .pa-trow { grid-template-columns: minmax(0, 1fr) auto; }
    .pa-col-size, .pa-col-date { display: none; }
    .pa-proj-sub { display: block; margin-top: 2px; }
    .pa-plan-head { align-items: flex-start; }
    #portal-toast { left: 16px; right: 16px; bottom: 16px; max-width: none; }
}
