/* ═══════════════════════════════════════════════════════════════
   StaffParty.ai Studio — Stylesheet
   ═══════════════════════════════════════════════════════════════ */

:root {
    /* StaffParty green comes from brand.css (linked first by every page that
       loads this file) — the one token file. These are style.css's own
       names for it, kept so the ~200 templates that read them need no edit.
       --primary is the green dark enough for links and text on cream;
       --green-brand is the fill, and a green fill carries ink text.
       --green is SUCCESS (a semantic colour, not the brand), --red is
       danger/"waiting on you" and --yellow is warning. */
    --green-brand: var(--sp-brand);
    --green-hover: var(--sp-brand-hover);
    --green-rule: var(--sp-brand-rule);
    --bg: #fbf9f4;
    --bg-surface: #f7f3ea;
    --bg-card: #ffffff;
    --border: #e3ddcd;
    --text: var(--sp-ink);
    --text-muted: #7d7466;
    --primary: var(--sp-brand-text);
    --primary-hover: var(--sp-brand-deep);
    --green: var(--sp-success);
    --red: var(--sp-danger);
    --yellow: var(--sp-warning);
    --purple: #6d5a8f;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(28,26,22,.08);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ── NAV ─────────────────────────────────────────────────────── */

.nav {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    /* min-height, NOT height. A fixed 56px cannot contain a row that
       wraps, and .nav-primary wraps by design (see the overflow note
       below it) — so a second line escaped the bar and drew on top of
       the page. The owner portal hit this between 861px and 1366px:
       one line at 1366 and up, one line below 861 where the media query
       already relaxed the height, and a 12px spill everywhere between —
       which is why it survived so long. */
    min-height: 56px;
    display: flex;
    align-items: center;
}

.nav-inner {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    font-weight: 700;
    font-size: 18px;
    color: var(--text);
}

.nav-links { display: flex; gap: 20px; align-items: center; }
.nav-links a { color: var(--text-muted); font-size: 14px; }
.nav-links a:hover { color: var(--text); }
.nav-admin { border: 1px solid var(--border); padding: 4px 12px; border-radius: var(--radius); }

/* ── GROUPED NAV ──────────────────────────────────────────────
   Both the owner portal (32 pages) and the admin surface (25) used to
   render every page as one flat row of links, which wrapped into a
   two-line wall nobody could scan. Now: a few top-level destinations
   plus grouped menus. <details>/<summary> keeps it keyboard-operable
   with no JS; nav.js only adds close-on-outside-click and Escape. */

.nav { padding: 0 20px; }
.nav-inner { max-width: 1440px; gap: 20px; }
.nav-brand { display: flex; align-items: baseline; gap: 9px; white-space: nowrap; }
.nav-brand .nav-kicker {
    font-size: 10px; font-weight: 600; letter-spacing: .12em;
    text-transform: uppercase; color: var(--text-muted);
}
/* No overflow on this row, deliberately: the menus hang out of it, and
   `overflow-x: auto` computes overflow-y to `auto` as well, which clipped
   every open panel to the 56px nav. It wraps instead. */
.nav-primary {
    display: flex; align-items: center; gap: 2px; flex: 1 1 auto;
    min-width: 0; flex-wrap: wrap; row-gap: 4px;
}
.nav-primary > a, .nav-menu > summary {
    display: block; padding: 7px 11px; border-radius: var(--radius);
    font-size: 14px; color: var(--text-muted); white-space: nowrap;
    border: 1px solid transparent; cursor: pointer;
}
.nav-primary > a:hover, .nav-menu > summary:hover {
    color: var(--text); background: rgba(28,26,22,.05);
}
.nav-primary > a[aria-current="page"] {
    color: var(--text); font-weight: 600; background: var(--bg-card);
    border-color: var(--border);
}
.nav-sep { width: 1px; height: 22px; background: var(--border); margin: 0 8px; flex: none; }

.nav-menu { position: relative; flex: none; }
.nav-menu > summary { list-style: none; }
.nav-menu > summary::-webkit-details-marker { display: none; }
.nav-menu > summary::after {
    content: "▾"; font-size: 10px; margin-left: 6px; opacity: .65;
}
.nav-menu[open] > summary {
    color: var(--text); background: var(--bg-card); border-color: var(--border);
}
.nav-menu.is-active > summary { color: var(--text); font-weight: 600; }
.nav-panel {
    position: absolute; top: calc(100% + 6px); left: 0; z-index: 60;
    min-width: 210px; padding: 6px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: 0 8px 26px rgba(28,26,22,.14);
}
.nav-panel.align-right { left: auto; right: 0; }
.nav-panel a, .nav-panel button {
    display: block; width: 100%; text-align: left; padding: 7px 10px;
    font-size: 14px; color: var(--text); border-radius: 4px;
    border: none; background: none; cursor: pointer; font: inherit;
    font-size: 14px; white-space: nowrap;
}
.nav-panel a:hover, .nav-panel button:hover { background: var(--bg-surface); }
.nav-panel a[aria-current="page"] { font-weight: 600; background: var(--bg-surface); }
.nav-panel .nav-panel-label {
    padding: 8px 10px 4px; font-size: 10px; font-weight: 600;
    letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted);
}
.nav-panel hr { border: none; border-top: 1px solid var(--border); margin: 5px 0; }
.nav-right { display: flex; align-items: center; gap: 8px; flex: none; }

/* The one persistent, always-in-the-same-place way to reach the live
   site — every portal page, the moment a business isn't paused. Deliberately
   heavier than a plain nav link (a filled dot + its own border) so it reads
   as "go here," not as one more item in the list. */
.nav-live-site {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 12px; border-radius: var(--radius);
    font-size: 13px; font-weight: 600; color: var(--green);
    border: 1px solid var(--green); white-space: nowrap;
}
.nav-live-site:hover { background: var(--green); color: #fff; }
.nav-live-site .live-dot {
    width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex: none;
}
.nav-live-site:hover .live-dot { background: #fff; }

/* ── EMPTY STATES & DISCLOSURE ────────────────────────────────
   A dashboard that renders a headers-only table when it has no rows
   reads as broken. An empty state says what will appear here and what
   makes it appear — the same space, doing work. */
.empty-note {
    color: var(--text-muted); font-size: 14px; line-height: 1.55;
    margin: 10px 0 0; max-width: 70ch;
}
.empty-note b { color: var(--text); }

/* Low-signal rows (idle businesses, resolved items) stay one click away
   rather than padding the page. */
details.disclosure { margin-top: 10px; }
details.disclosure > summary {
    cursor: pointer; color: var(--text-muted); font-size: 13px;
    padding: 7px 10px; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--bg-surface);
    list-style: none; display: inline-block;
}
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::before { content: "▸ "; opacity: .7; }
details[open].disclosure > summary::before { content: "▾ "; }
details.disclosure > summary:hover { color: var(--text); }
details.disclosure > :not(summary) { margin-top: 10px; }

/* Section header: which menu did this page come from. Quiet by design —
   it orients, it doesn't compete with the page's own <h1>. */
.section-crumb {
    display: flex; align-items: center; gap: 7px;
    margin: 0 0 14px; font-size: 12px; letter-spacing: .04em;
}
.section-crumb .crumb-group { color: var(--text-muted); text-transform: uppercase;
    font-weight: 600; font-size: 11px; letter-spacing: .1em; }
.section-crumb .crumb-sep { color: var(--text-muted); opacity: .6; }
.section-crumb .crumb-page { color: var(--text); font-weight: 600; }

/* Inactivity ladder (helpers_business_dormancy). Deliberately calm: a
   business that woke up is good news, and a standing notice is a nudge the
   owner has already answered by being here. Neither is an error state, so
   neither borrows the red. */
.dormancy-banner {
    margin: 0 0 18px; padding: 12px 16px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--bg-surface);
    font-size: 14px; line-height: 1.55; color: var(--text);
}
.dormancy-banner strong { display: block; margin-bottom: 2px; }
.dormancy-woke { border-left: 3px solid var(--green); }
.dormancy-woke strong { color: var(--green); }
.dormancy-notice { border-left: 3px solid var(--yellow); }
.dormancy-notice strong { color: var(--yellow); }

@media (max-width: 860px) {
    .nav { padding: 8px 14px; }   /* height is min-height above now */
    .nav-inner { flex-wrap: wrap; gap: 8px; }
    .nav-primary { order: 3; width: 100%; }
    .nav-panel { position: fixed; left: 12px; right: 12px; min-width: 0; }
}

/* ── ADMIN SIDEBAR ────────────────────────────────────────────
   The tier-1 surface outgrew the top bar — 27 of its 30 destinations
   sat behind five dropdowns, and the row wrapped to two lines below
   ~1088px — so admin_base.html renders the same
   tree (_admin_nav.html; structure still helpers_nav.ADMIN_NAV) as a
   left rail. Groups are <details> sections: the current page's group
   starts open, the rest closed, and several can be open at once —
   which is why they are NOT .nav-menu (whose one-open-at-a-time /
   close-on-outside-click manners belong to dropdowns).
   ≥1024px: a sticky, self-scrolling rail beside the content column.
   Below: the rail is an off-canvas drawer behind the top bar's Menu
   button (nav.js toggles body.sidenav-open); with JS off, a <noscript>
   block in admin_base.html puts it back in flow. The portal/public
   top bar (.nav-*) is untouched by all of this. */

.admin-shell { --sidenav-w: 236px; }

.admin-columns { display: flex; min-height: 100vh; }

.sidenav {
    width: var(--sidenav-w); flex: none;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    background: var(--bg-surface); border-right: 1px solid var(--border);
    padding: 14px 12px 16px;
    display: flex; flex-direction: column;
}
/* The top-bar brand assumes a row with room to its right; in a 236px rail
   it clips. Slightly smaller, and the kicker may wrap under the name. */
.sidenav-brand { padding: 4px 11px 14px; font-size: 16px;
                 white-space: normal; flex-wrap: wrap; }

.sidenav-nav { display: flex; flex-direction: column; gap: 1px; }
.sidenav-nav a, .sidenav-group > summary, .sidenav-foot a {
    display: block; padding: 6px 11px; border-radius: var(--radius);
    font-size: 14px; color: var(--text-muted); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
    border: 1px solid transparent; cursor: pointer;
}
.sidenav-nav a:hover, .sidenav-group > summary:hover, .sidenav-foot a:hover {
    color: var(--text); background: rgba(28,26,22,.05);
}
.sidenav-nav a[aria-current="page"] {
    color: var(--text); font-weight: 600; background: var(--bg-card);
    border-color: var(--border);
}

.sidenav-group > summary {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    list-style: none;
}
.sidenav-group > summary::-webkit-details-marker { display: none; }
.sidenav-group > summary::after {
    content: "▸"; font-size: 10px; opacity: .65;
    transition: transform .15s ease;
}
.sidenav-group[open] > summary::after { transform: rotate(90deg); }
.sidenav-group.is-active > summary { color: var(--text); font-weight: 600; }
.sidenav-group-links {
    display: flex; flex-direction: column; gap: 1px;
    margin: 2px 0 6px 14px; padding-left: 8px;
    border-left: 1px solid var(--border);
}

.sidenav-foot {
    margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 1px;
}
.sidenav-foot a { font-size: 13px; }

.admin-content {
    flex: 1 1 auto; min-width: 0;
    display: flex; flex-direction: column;
}
/* .main's own min-height was sized for the 56px top bar; here the flex
   column owns the height and the footer sits at the bottom without it. */
.admin-content .main { flex: 1 1 auto; min-height: 0; width: 100%; }

.admin-topbar { display: none; }
.sidenav-scrim { display: none; }
.sidenav-toggle {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 7px 12px; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--bg-card);
    color: var(--text); font: inherit; font-size: 14px; cursor: pointer;
}
.sidenav-toggle:hover { color: var(--text); background: rgba(28,26,22,.05); }

@media (max-width: 1023.98px) {
    .admin-columns { display: block; min-height: 0; }
    .admin-topbar {
        display: flex; align-items: center; gap: 14px;
        position: sticky; top: 0; z-index: 70;
        background: var(--bg-surface); border-bottom: 1px solid var(--border);
        padding: 8px 14px; min-height: 52px;
    }
    /* The brand is nowrap; on a 360px phone "StaffParty.ai Studio ADMIN"
       beside the Menu button is ~4px too wide, so it truncates rather
       than pushing the whole page sideways. */
    .admin-topbar .nav-brand { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
    .sidenav-toggle { flex: none; }
    .sidenav {
        position: fixed; top: 0; left: 0; bottom: 0; z-index: 90;
        height: auto; width: min(320px, 86vw);
        transform: translateX(-102%); visibility: hidden;
        transition: transform .22s ease, visibility .22s;
        box-shadow: 0 12px 40px rgba(28,26,22,.28);
    }
    body.sidenav-open .sidenav { transform: none; visibility: visible; }
    .sidenav-scrim { position: fixed; inset: 0; z-index: 80; background: rgba(28,26,22,.45); }
    body.sidenav-open .sidenav-scrim { display: block; }
    /* The page behind the open drawer holds still. */
    body.sidenav-open { overflow: hidden; }
}

/* ── MAIN ────────────────────────────────────────────────────── */

.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
    min-height: calc(100vh - 56px - 60px);
}

/* ── HERO ────────────────────────────────────────────────────── */

.hero {
    text-align: center;
    padding: 80px 0 60px;
}

.hero h1 {
    font-size: 48px;
    font-weight: 800;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-sub {
    font-size: 20px;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto 32px;
}

.hero-actions { display: flex; gap: 16px; justify-content: center; }

/* ── SECTION ─────────────────────────────────────────────────── */

.section { margin: 48px 0; }
.section h2 {
    font-size: 24px;
    margin-bottom: 20px;
    color: var(--text);
}

.subtitle { color: var(--text-muted); margin-bottom: 24px; }

/* ── GRID ────────────────────────────────────────────────────── */

.grid { display: grid; gap: 20px; }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid-5 { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.grid-7 { grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); }

/* ── CARD ────────────────────────────────────────────────────── */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.card h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--primary);
}

.card p { color: var(--text-muted); font-size: 14px; }

/* ── STAT CARD ───────────────────────────────────────────────── */

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
}

.stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── TABLE ───────────────────────────────────────────────────── */

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.table tr:hover td { background: rgba(88, 166, 255, 0.04); }

/* ── BADGE ───────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--border);
    color: var(--text-muted);
}

.badge-green, .badge-active, .badge-done, .badge-live { background: rgba(63,185,80,.15); color: var(--green); }
.badge-red, .badge-stale, .badge-failed, .badge-critical, .badge-suspended { background: rgba(248,81,73,.15); color: var(--red); }
.badge-yellow, .badge-pending, .badge-building, .badge-draft, .badge-paused { background: rgba(210,153,34,.15); color: var(--yellow); }
.badge-portfolio { background: rgba(188,140,255,.15); color: var(--purple); }
.badge-external { background: rgba(88,166,255,.15); color: var(--primary); }
.badge-running { background: rgba(88,166,255,.15); color: var(--primary); }
.badge-archived { background: rgba(139,148,158,.15); color: var(--text-muted); }
.badge-disconnected { background: rgba(248,81,73,.15); color: var(--red); }

/* ── BUTTONS ─────────────────────────────────────────────────── */

.btn {
    display: inline-block;
    padding: 10px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    color: var(--text);
    transition: all 0.15s;
}

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

/* A disabled button had NO styling of its own, so it looked exactly like a
   live one — full contrast, pointer cursor, and a hover that still lit up the
   border. The only feedback was the click doing nothing, which reads as a
   broken page rather than an unavailable action. It matters most where the
   page has already explained the reason above the button (the deploy console
   before its CloudFormation update, for one) and the button underneath
   silently contradicted it.
   `:disabled` covers <button>; `.is-disabled` is for <a> elements styled as
   buttons, which cannot carry the attribute. The hover rules are re-stated
   here to beat the ones above on specificity. */
.btn:disabled,
.btn.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn:disabled:hover,
.btn.is-disabled:hover {
    border-color: var(--border);
    color: var(--text);
}
.btn-primary:disabled:hover { background: var(--green-brand); color: var(--text); }

.btn-primary {
    background: var(--green-brand);
    color: var(--text);
    border-color: var(--green-rule);
    font-weight: 600;
}
.btn-primary:hover { background: var(--green-hover); border-color: var(--green-rule); color: var(--text); }

.btn-secondary { background: var(--bg-card); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; text-align: center; }

/* ── FORMS ────────────────────────────────────────────────────── */

.form { max-width: 500px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 14px; color: var(--text-muted); margin-bottom: 4px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

.input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
}
.input:focus { outline: none; border-color: var(--primary); }

select.input { appearance: auto; }

/* The lifecycle control sits in a dense table row, where `.input`'s full width
   and 10px padding would push every other column off the screen. */
.lifecycle-select {
    width: auto;
    padding: 3px 6px;
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.lifecycle-select:disabled { opacity: .55; cursor: progress; }

/* align-items on the CONTAINER only: a quad plate raises the row, and
   without a bottom alignment every sibling control stretches to plate
   height. (A descendant align-self rule would reach the plate's own cell
   buttons and break its grid — container-level is the whole fix.) */
.form-inline { display: flex; gap: 12px; max-width: 500px; align-items: flex-end; flex-wrap: wrap; }
.form-inline .input { flex: 1; }

.form-message { margin-top: 12px; font-size: 14px; }
.form-message.success { color: var(--green); }
.form-message.error { color: var(--red); }

.form-card { margin-bottom: 24px; }

/* ── AUTH ─────────────────────────────────────────────────────── */

.auth-container {
    max-width: 400px;
    margin: 80px auto;
}

.auth-container h2 { margin-bottom: 24px; }

/* ── DASHBOARD ───────────────────────────────────────────────── */

.dashboard h1 { margin-bottom: 24px; }

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ── PRODUCT CARD ────────────────────────────────────────────── */

.product-card { display: flex; flex-direction: column; }

.product-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.product-price { font-size: 20px; font-weight: 700; color: var(--green); }

.product-actions {
    margin-top: auto;
    padding-top: 16px;
    display: flex;
    gap: 8px;
}

/* ── ERROR PAGE ──────────────────────────────────────────────── */

.error-page { text-align: center; padding: 100px 0; }
.error-page h1 { font-size: 72px; color: var(--text-muted); }
.error-page p { color: var(--text-muted); margin: 16px 0 32px; }

/* ── FOOTER ──────────────────────────────────────────────────── */

.footer {
    border-top: 1px solid var(--border);
    padding: 20px 24px;
    text-align: center;
}

.footer p { color: var(--text-muted); font-size: 13px; }

.text-muted { color: var(--text-muted); }
.text-danger { color: var(--red); }

/* ── INFRASTRUCTURE ─────────────────────────────────────────── */

.stat-detail { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Health panels */
.health-panel {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    padding: 1rem;
}
.health-panel-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border, #e5e7eb);
}
.health-table {
    width: 100%;
    font-size: 0.85rem;
    border-collapse: collapse;
}
.health-table td {
    padding: 4px 0;
    vertical-align: top;
}
.health-table tr:not(:last-child) td {
    border-bottom: 1px solid var(--border-light, rgba(0,0,0,0.05));
}
.health-label {
    color: var(--text-muted, #6b7280);
    width: 100px;
    white-space: nowrap;
    padding-right: 0.75rem;
}
.usage-bar-wrap {
    background: var(--border, #e5e7eb);
    border-radius: 4px;
    height: 8px;
    width: 100%;
    max-width: 180px;
    margin-bottom: 2px;
}
.usage-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}
.usage-bar-ok { background: var(--green); }
.usage-bar-warn { background: var(--yellow); }

.badge-yellow {
    background: rgba(234, 179, 8, 0.15);
    color: var(--yellow);
}

.alert {
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 8px;
}
.alert-warning { background: var(--sp-warning-wash); color: var(--yellow); border: 1px solid rgba(181, 71, 8, 0.3); }
.alert-error { background: var(--sp-danger-wash); color: var(--red); border: 1px solid rgba(180, 35, 24, 0.3); }
.alert-success { background: var(--sp-success-wash); color: var(--green); border: 1px solid rgba(62, 91, 58, 0.3); }

.btn-sm { padding: 4px 12px; font-size: 12px; }

a.active { color: var(--accent); }

/* ── TABS ────────────────────────────────────────────────────── */

.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 16px;
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── DRAG REORDER ────────────────────────────────────────────── */

.drag-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 14px;
    user-select: none;
}

.drag-handle:active { cursor: grabbing; }

tr.dragging { opacity: 0.4; }

tr[draggable="true"]:hover .drag-handle { color: var(--primary); }

/* ── FEEDBACK: toast, notice, dialog ──────────────────────────
   Three registers for "what just happened", by how long the answer has
   to live (see SP.toast / SP.notice / SP.confirm in app.js). Every
   colour is a token; the tone classes only ever tint a border and a
   glyph, so a state is never carried by colour alone — the glyph and
   the role attribute carry it too. */

.sp-toasts {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
    max-width: min(420px, calc(100vw - 48px));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 12px 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left-width: 4px;
    color: var(--text);
    box-shadow: 0 6px 20px rgba(28,26,22,.12);
    transform: translateY(12px);
    opacity: 0;
    transition: transform .25s ease, opacity .25s ease;
    pointer-events: auto;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast-text { flex: 1 1 auto; }
.toast-info    { border-left-color: var(--primary); }
.toast-success { border-left-color: var(--green); }
.toast-warning { border-left-color: var(--yellow); }
.toast-error   { border-left-color: var(--red); }
.toast-success .toast-text::before { content: "\2713\00a0"; color: var(--green); }
.toast-warning .toast-text::before { content: "\26A0\00a0"; color: var(--yellow); }
.toast-error   .toast-text::before { content: "\2715\00a0"; color: var(--red); }

.toast-action,
.toast-close {
    flex: 0 0 auto;
    background: transparent;
    border: 0;
    cursor: pointer;
    color: var(--text-muted);
    font: inherit;
    padding: 0 4px;
    border-radius: 4px;
}
.toast-action { color: var(--primary); font-weight: 600; text-decoration: underline; }
.toast-close  { font-size: 18px; line-height: 1; }
.toast-action:hover, .toast-close:hover { color: var(--text); background: var(--bg-surface); }
.toast-action:focus-visible, .toast-close:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* Inline status beside the control that caused it. */
.notice {
    display: inline-flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--text);
    padding: 6px 10px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    max-width: 100%;
}
.notice-text::before { font-weight: 700; margin-right: 2px; }
.notice--ok    { background: rgba(62,91,58,.08);  border-color: rgba(62,91,58,.25); }
.notice--ok    .notice-text::before { content: "\2713"; color: var(--green); }
.notice--info  { background: var(--bg-surface); border-color: var(--border); }
.notice--warn  { background: rgba(165,129,60,.10); border-color: rgba(165,129,60,.35); }
.notice--warn  .notice-text::before { content: "\26A0"; color: var(--yellow); }
.notice--error { background: rgba(156,43,30,.08); border-color: rgba(156,43,30,.35); }
.notice--error .notice-text::before { content: "\2715"; color: var(--red); }
.notice--busy  { background: var(--bg-surface); border-color: var(--border); color: var(--text-muted); }
.notice-action { margin-left: 4px; align-self: center; white-space: nowrap; }
/* A row's own feedback slot (admin tables, the add form): empty until an
   action writes to it, then a notice sitting under the buttons that caused it. */
.row-msg.notice { margin-top: 6px; max-width: 40rem; }

/* Dialog. The backdrop is the page going inert; the panel is a card. */
.sp-dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(28,26,22,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1100;
    opacity: 0;
    transition: opacity .18s ease;
}
.sp-dialog-backdrop.show { opacity: 1; }
.sp-dialog {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(28,26,22,.25);
    width: min(520px, 100%);
    max-height: calc(100vh - 48px);
    overflow: auto;
    padding: 22px 24px;
    transform: translateY(8px);
    transition: transform .18s ease;
    outline: none;
}
.sp-dialog-backdrop.show .sp-dialog { transform: none; }
.sp-dialog h3 { margin: 0 0 8px; font-size: 17px; color: var(--text); }
.sp-dialog--danger h3 { color: var(--red); }
.sp-dialog-body { color: var(--text); font-size: 14px; line-height: 1.5; margin: 0 0 8px; }
.sp-dialog-details { margin: 8px 0 0 18px; padding: 0; color: var(--text-muted); font-size: 13.5px; line-height: 1.5; }
.sp-dialog-details li { margin: 4px 0; }
.sp-dialog-content { margin: 10px 0; }
.sp-dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #7f2218; border-color: #7f2218; color: #fff; }

@media (prefers-reduced-motion: reduce) {
    .toast, .sp-dialog-backdrop, .sp-dialog { transition: none; }
}

/* ── RESPONSIVE ──────────────────────────────────────────────── */

@media (max-width: 768px) {
    .hero h1 { font-size: 32px; }
    .hero-sub { font-size: 16px; }
    .hero-actions { flex-direction: column; align-items: center; }
    .grid-3, .grid-4, .grid-5, .grid-7 { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; }
    .nav-links { gap: 10px; font-size: 12px; }
    .dashboard-header { flex-direction: column; gap: 12px; }
    /* Tables stay at 14px on small screens. Dropping to 12px made every
       data screen (the ones people read ON a phone, standing up) smaller
       than the body text around it; scroll the table instead of shrinking
       the type. Tightening the cell padding buys back the width. */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table th, .table td { padding: 8px 9px; }
}

/* Any table can be wrapped in .table-wrap to scroll itself rather than
   pushing the page sideways. */
.table-wrap { max-width: 100%; }

/* ── MOTION ───────────────────────────────────────────────────
   A handful of small, purpose-built cues — never decoration for its own
   sake. Each one marks a moment that's actually true: this is live, that
   step just finished, this number just moved. One kill switch covers all
   of them, including anything added here later. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Scroll-reveal: content below the fold arrives instead of just being
   there. .reveal-in is added by IntersectionObserver in the page that
   uses it; reduced-motion users get the end state with no observer. */
.reveal {
    opacity: 0; transform: translateY(14px);
    transition: opacity .5s ease, transform .5s cubic-bezier(.22,1,.36,1);
}
.reveal.reveal-in { opacity: 1; transform: none; }

/* A step/milestone flipping to done gets a small pop, not a silent swap. */
@keyframes tick-pop {
    0% { transform: scale(.4); opacity: 0; }
    60% { transform: scale(1.25); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* "This is genuinely live right now" — the pulse ring on .live-dot
   (templates/_portal_nav.html and the game-skin "View my site" buttons
   share this name; each skin defines its own copy since they're never
   loaded on the same page). */
@keyframes live-pulse {
    0% { box-shadow: 0 0 0 0 rgba(62,91,58,.55); }
    70% { box-shadow: 0 0 0 6px rgba(62,91,58,0); }
    100% { box-shadow: 0 0 0 0 rgba(62,91,58,0); }
}
.live-dot { animation: live-pulse 2.2s ease-out infinite; }

/* ── The quad selector on this skin ─────────────────────────────
   quad.css owns the component; a skin only re-tokenises it. White
   cells on the cream ground, the studio border as the rule, the
   studio radius — the same plate the homepage mark draws. */
.quad-field {
    --quad-surface: #fff;
    --quad-rule-color: var(--border);
    --quad-radius: var(--radius);
    --quad-ink: var(--text);
    --quad-ink-faint: var(--text-muted);
    --quad-focus: var(--primary);
}

/* ── Infrastructure mode badge ───────────────────────────────────────
   Shown beside the business name on the admin list, the admin per-business
   page, and every owner-portal page (topbar + rail). Two values, two colors:
   hosted (we run all of it) reads as the platform green; independent (their
   own site, parts hosted here) reads as a distinct purple so the two are
   never confused at a glance. Mode gates nothing else — that is why it must
   be SAID on the surface rather than inferred. */
.infra-mode {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: 999px;
    font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    line-height: 1.4; vertical-align: middle; white-space: nowrap;
    border: 1px solid transparent;
}
.infra-mode::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.infra-mode-hosted      { background: rgba(63,185,80,.14);  color: var(--green);  border-color: rgba(63,185,80,.35); }
.infra-mode-independent { background: rgba(163,113,247,.14); color: var(--purple); border-color: rgba(163,113,247,.4); }
h1 .infra-mode { font-size: 12px; margin-left: 10px; }
td .infra-mode { margin-left: 8px; }
.infra-mode-row { display: flex; flex-direction: column; gap: 4px; padding: 8px 14px 10px; }
.infra-mode-hint { font-size: 12px; color: var(--text-muted); line-height: 1.35; }
.portal-topbar .infra-mode { margin-left: 10px; }
