/* ========================================
   Scrap Price Viewer — unified stylesheet
   ========================================

   Structural rules only. Colors come from a /schemes/<name>.css that
   each page loads after this file (see appSchemeLinkTag()). A page
   that loads this file MUST also load exactly one scheme file.

   Discipline:
   - Every color value goes through var(--...). Hardcoded literals
     belong only in /schemes/*.css.
   - One rule per element kind (one .btn, one .card, one .header, …).
     Page-specific components live alongside in their own sections,
     each with selectors unique to that page's content.
   - Single-file source of truth: per-page styles.css and darkmode.css
     are deleted; include/header.css is folded in here. Pages link
     only /styles.css + /schemes/<name>.css.
   ======================================== */

/* === Reset ============================================================= */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* === Body & page background ========================================== */
/* One base rule, used by every page. Pages below 56px fixed header have
   padding-top:56px clearance. Body bg is the brand gradient by default —
   most pages float a white .card on top of it. Home opts out of the
   gradient (it shows a flat surface; gradient lives in the header bar). */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--body-bg);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
    padding-top: 40px;
}

body.page-home {
    background: var(--bg-page);
}

/* === Page header (.header) =========================================== */
/* Fixed-pinned gradient bar at the top of every page (provided by
   include/header.php). Pages clear it via body padding-top above.
   z-index sits ABOVE .modal (1000) so the hamburger button stays
   reachable when a modal is open. Toast .message floats above us at
   1100; the drawer + its overlay are 1300 / 1200. */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 48px;
    background: var(--bg-gradient);
    color: var(--text-on-color);
    box-shadow: var(--shadow-header);
}

.header-brand {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-align: center;
    margin: 0;
    line-height: 1.2;
}

.hamburger-btn {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 1;
}
.hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-on-color);
    border-radius: 2px;
    transition: opacity 0.2s ease;
}
.hamburger-btn:hover span,
.hamburger-btn:focus span {
    opacity: 0.8;
}

/* === Drawer (.hamburger-menu, .menu-*) ============================== */
/* Drawer + its overlay sit above the header (1050) and any open modal
   (1000) so the menu surfaces above everything when open. */
.hamburger-menu {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100vh;
    background: var(--surface);
    box-shadow: var(--shadow-menu);
    z-index: 1300;
    transition: left 0.3s ease;
    overflow-y: auto;
}
.hamburger-menu.open { left: 0; }

.menu-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 32px;
    color: var(--text-light);
    cursor: pointer;
    padding: 5px 10px;
    line-height: 1;
}
.menu-close:hover { color: var(--text-dark); }

/* Flex column so .menu-footer can margin-top:auto itself to the bottom
   of the drawer, regardless of how many menu items are above it. */
.menu-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

/* Build/copyright stamp at the bottom of the drawer. Same info as the
   home page's <footer>; visible everywhere via the shared drawer. */
.menu-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-light);
    font-size: 11px;
    line-height: 1.5;
}
.menu-footer p { margin: 2px 0; }
.menu-footer-link {
    color: var(--primary-color);
    text-decoration: none;
}
.menu-footer-link:hover { text-decoration: underline; }
/* Button-as-link in the footer (Terms & Conditions trigger). Strip the
   browser's button chrome so it sits inline with the surrounding text
   and inherits font/color from the .menu-footer block. */
button.menu-footer-btn {
    background: transparent;
    border: 0;
    padding: 0;
    font: inherit;
    cursor: pointer;
    line-height: inherit;
}
.menu-footer-icon {
    display: inline-block;
    margin-right: 4px;
    font-size: 13px;
    line-height: 1;
    vertical-align: -1px;
}
.menu-footer-sep {
    color: var(--text-light);
    margin: 0 2px;
}

.menu-header {
    text-align: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.menu-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 15px;
}

.menu-greeting {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
}

.menu-nav {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    color: var(--text-dark);
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.2s ease, color 0.2s ease;
    font-size: 15px;
}
/* Reset <button> defaults so a <button class="menu-item"> looks identical
   to an <a class="menu-item"> across every scheme. Without this the
   browser's ButtonFace background paints over the scheme-aware menu
   color, producing light-on-light text in dark / black / red. */
button.menu-item {
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    line-height: inherit;
}
.menu-item:hover {
    background: var(--menu-item-hover-bg, var(--bg-soft));
    color: var(--menu-item-hover-color, var(--text-dark));
}

.menu-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

.menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 15px 0;
}

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay);
    z-index: 1200;
    display: none;
}
.menu-overlay.active { display: block; }

/* === Card surface (.card and .modal-card) =========================== */
/* Used for: inner-page card on auth/profile/directory/dashboard, and
   inside every modal (price detail, picker, location picker, item edit,
   upload raw text). .modal modifier adds the positioning + overlay. */
.card {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-modal);
    padding: 40px;
    max-width: 500px;
    width: 100%;
    margin: 30px auto 40px;
    position: relative;
}
.card.card-wide   { max-width: 880px; }
.card.card-medium { max-width: 600px; }

/* Card close (×) — top-right pill */
.card-close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: none;
    font-size: 34px;
    font-weight: 700;
    line-height: 1;
    color: var(--close-color);
    cursor: pointer;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}
.card-close:hover,
.card-close:focus {
    background: var(--close-bg-hover);
    color: var(--close-color-hover);
    outline: none;
}

/* Card header region (title + optional subtitle + optional logo image) */
.card-header {
    text-align: center;
    margin-bottom: 30px;
}
.card-header img {
    width: 80px;
    height: 80px;
    margin-bottom: 10px;
}
.card h1 {
    color: var(--text-dark);
    font-size: 24px;
    margin-bottom: 6px;
    text-align: center;
}
.card .subtitle {
    color: var(--text-light);
    font-size: 14px;
    text-align: center;
    margin-bottom: 8px;
}

/* === Modal (positioning modifier on top of .card) =================== */
/* z-index sits below .header (1050) intentionally — the hamburger button
   must remain clickable when a modal is open so the user can reach the
   menu without first dismissing the modal. Top padding (60px = 40px
   header + 20px gap) keeps the modal-card from slipping behind the
   pinned header. */
.modal {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px 20px;
    z-index: 1000;
    overflow-y: auto;
}
.modal.hidden,
.modal[hidden] { display: none; }

/* Modal's .card uses margin: 0 to defeat the page-card top/bottom margin. */
.modal > .card,
.modal .modal-card {
    margin: 0;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

/* Standalone .modal-card (without also having .card on the element).
   Same surface treatment as .card; used inside .modal where we don't
   want .card's outer page-margin to interfere. */
.modal-card {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-modal);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}
.modal-card.modal-card-wide   { max-width: 800px; }
/* Optional internal padding for modals whose body is a single rendered
   form/text block (item-edit, raw-text upload). Picker/location modals
   stay unpadded because their .picker-header / .picker-list set their
   own internal spacing. */
.modal-card.modal-card-padded { padding: 30px; }

/* Modal-internal header strip (used by the home detail modal and the
   picker/location modals). Sticks visually at the top of the modal card. */
.modal-header {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    row-gap: 4px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface);
    border-radius: 12px 12px 0 0;
    flex-shrink: 0;
}
.modal-header h2,
.modal-header h3 {
    grid-column: 1;
    font-size: 19px;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}
.modal-header .subtitle {
    grid-column: 1 / -1;
    font-size: 13px;
    color: var(--text-light);
    margin: 0;
}
.modal-header .card-close {
    grid-column: 2;
    position: static;
    width: 36px;
    height: 36px;
    background: var(--danger-color);
    color: var(--text-on-color);
    font-size: 28px;
}
.modal-header .card-close:hover {
    background: var(--danger-hover);
    color: var(--text-on-color);
    transform: scale(1.05);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    min-height: 0;
}

/* === Buttons ========================================================= */
.btn {
    width: 100%;
    padding: 14px;
    background: var(--bg-gradient);
    color: var(--text-on-color);
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px var(--primary-glow-strong);
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn.btn-secondary {
    background: var(--surface);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}
.btn.btn-secondary:hover:not(:disabled) {
    background: var(--primary-color);
    color: var(--text-on-color);
    box-shadow: 0 6px 14px var(--primary-glow-strong);
}

.btn.btn-danger {
    background: var(--danger-color);
    color: var(--text-on-color);
}
.btn.btn-danger:hover:not(:disabled) {
    background: var(--danger-hover);
}

.btn.btn-restore {
    background: var(--neutral-bg);
    color: var(--neutral-text);
}
.btn.btn-restore:hover:not(:disabled) {
    background: var(--neutral-bg-hover);
}

.btn.btn-neutral {
    background: var(--neutral-bg);
    color: var(--neutral-text);
}
.btn.btn-neutral:hover:not(:disabled) {
    background: var(--neutral-bg-hover);
}

.btn-small {
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--surface);
    color: var(--text-dark);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}
.btn-small:hover:not(:disabled) {
    background: var(--bg-soft);
    border-color: var(--primary-color);
}
.btn-small.btn-danger {
    background: var(--surface);
    color: var(--danger-color);
    border-color: var(--danger-soft-border);
}
.btn-small.btn-danger:hover:not(:disabled) {
    background: var(--danger-soft-bg);
    border-color: var(--danger-color);
}
.btn-small:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-retry {
    background: var(--primary-color);
    color: var(--text-on-color);
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 16px;
}
.btn-retry:hover { background: var(--secondary-color); }

.btn-primary {
    display: inline-block;
    padding: 12px 20px;
    background: var(--bg-gradient);
    color: var(--text-on-color);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn.loading .btn-text { display: none; }
.btn.loading .spinner { display: block; }

/* === Spinner ========================================================= */
.spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 3px solid var(--text-on-color-faint);
    border-top-color: var(--text-on-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}
.spinner.show { display: block; }
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Larger page-loading spinner (home + directory state blocks) */
.spinner-lg {
    display: inline-block;
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

/* === Forms =========================================================== */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    color: var(--text-dark);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
}
label .req {
    font-weight: 500;
    color: var(--text-light);
    font-size: 12px;
}

input[type="text"],
input[type="tel"],
input[type="email"],
input[type="password"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text-dark);
    transition: border-color 0.3s ease;
}
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* === Messages (floating toast) ====================================== */
/* Fixed-positioned at top of viewport so long forms scrolled to bottom
   still surface the response. Sits above header (1050) and modals
   (1000); the drawer + its overlay (1300 / 1200) cover it when open. */
.message {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1100;
    width: min(90vw, 480px);
    padding: 12px 16px;
    border-radius: 6px;
    display: none;
    font-size: 14px;
    box-shadow: var(--shadow-toast);
}
.message.show { display: block; }
.message.error {
    background: var(--bg-error);
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}
.message.success {
    background: var(--bg-success);
    color: var(--success-color);
    border: 1px solid var(--success-color);
}
.message-details {
    margin-top: 10px;
    font-size: 14px;
    line-height: 1.6;
}

/* === Utility & misc ================================================== */
.hidden { display: none !important; }

.links {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
}
.links a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}
.links a:hover { text-decoration: underline; }

.divider {
    margin: 20px 0;
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
}

.hint {
    color: var(--text-light);
    font-size: 13px;
    font-weight: 400;
}

.section-rule {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 30px 0 24px;
}
.section-heading {
    color: var(--text-dark);
    font-size: 16px;
    margin-bottom: 14px;
    font-weight: 600;
}
.contacts-fieldset {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 14px 4px;
    margin-bottom: 14px;
}
.contacts-fieldset > legend {
    padding: 0 6px;
    font-weight: 600;
    color: var(--text-dark);
    font-size: 14px;
}
.contacts-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px 14px;
}
@media (max-width: 640px) {
    .contacts-row { grid-template-columns: 1fr; }
}
.contacts-row .form-group { margin-bottom: 8px; }

/* === Status icon (logout success/error circle, future flows) ======== */
.status-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-on-color);
    font-size: 32px;
    line-height: 1;
}
.status-icon-success { background: var(--success-color); }
.status-icon-error   { background: var(--danger-color); }

/* === Role badge ====================================================== */
.role-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 999px;
    line-height: 1;
    vertical-align: middle;
    margin-left: 8px;
}
.role-badge[hidden] { display: none; }
.role-badge-admin {
    background: var(--admin-badge-bg);
    color: var(--admin-badge-text);
}

/* === Verify-email banner (soft amber) ============================== */
.verify-banner[hidden] { display: none; }
.verify-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    margin: 0 0 12px;
    padding: 12px 16px;
    background: var(--warn-bg);
    border: 2px solid var(--warn-border);
    border-radius: 8px;
    color: var(--warn-text);
    font-size: 14px;
    line-height: 1.4;
}
.verify-banner-text { flex: 1 1 240px; font-weight: 600; }
.verify-banner-actions {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}
.verify-banner-btn {
    background: transparent;
    border: 1.5px solid var(--warn-text);
    color: var(--warn-text);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}
.verify-banner-btn:hover,
.verify-banner-btn:focus {
    background: var(--warn-text);
    color: var(--warn-bg);
    outline: none;
}
.verify-banner-btn[disabled] { opacity: 0.6; cursor: progress; }
.verify-banner-status {
    flex-basis: 100%;
    font-size: 13px;
    font-weight: 500;
    color: var(--warn-text);
}

/* === "List your scrap yard" CTA (home page, per-location subs) ===== */
.buyer-cta-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    margin: 0 0 12px;
    padding: 12px 16px;
    background: var(--primary-glow);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.4;
}
.buyer-cta-text { flex: 1 1 240px; }
.buyer-cta-text strong { color: var(--primary-color); }
.buyer-cta-btn {
    background: var(--primary-color);
    border: 1.5px solid var(--primary-color);
    color: #fff;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}
.buyer-cta-btn:hover,
.buyer-cta-btn:focus {
    background: var(--primary-glow-strong);
    color: #fff;
    outline: none;
}

/* === Subscription expiration banner (dashboard, Phase 4) =========== */
.subscription-banner {
    max-width: 600px;
    margin: 12px auto 0;
    padding: 12px 16px;
    background: var(--warn-bg);
    border: 2px solid var(--warn-border);
    border-radius: 8px;
    color: var(--warn-text);
    font-size: 14px;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.subscription-banner-message { flex: 1 1 240px; font-weight: 600; }
.subscription-banner-cta {
    background: transparent;
    border: 1.5px solid var(--warn-text);
    color: var(--warn-text);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}
.subscription-banner-cta:hover,
.subscription-banner-cta:focus {
    background: var(--warn-text);
    color: var(--warn-bg);
    outline: none;
}

/* Profile: subscription block layout (no colors — just spacing) */
.subscription-block p { margin: 0 0 12px; }
.subscription-block .btn + .btn { margin-top: 8px; }
.subscription-block #portalMessage { margin-top: 8px; }

/* === Verify-required (buyer-must-verify gate) ====================== */
.verify-required-msg {
    background: var(--warn-bg);
    border: 2px solid var(--warn-border);
    color: var(--warn-text);
    border-radius: 8px;
    padding: 14px 16px;
    margin: 0 0 20px;
    font-size: 14px;
    line-height: 1.5;
    font-weight: 600;
}
.verify-required-status {
    margin-top: 8px;
    font-weight: 500;
    font-size: 13px;
}

/* === Home: app layout =============================================== */
body.page-home .app {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 40px);
    padding: 20px;
    padding-bottom: 0;
}

body.page-home .content-container {
    flex: 1;
    min-height: 0;
}

/* === Home: buyer-source (between header and search) ================= */
.buyer-source-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 12px;
}
.buyer-source-row > .buyer-source {
    flex: 1;
    margin-bottom: 0;
}
.buyer-terms-btn {
    flex: 0 0 auto;
    width: 40px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
    color: var(--text-light);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 0;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.buyer-terms-btn:hover,
.buyer-terms-btn:focus {
    background: var(--bg-soft);
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
    outline: none;
}
.terms-modal-body {
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text-dark);
    line-height: 1.5;
    margin-top: 8px;
    max-height: 60vh;
    overflow-y: auto;
}
/* Inline info-icon button next to a buyer name (directory cards, picker rows) */
.terms-info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-left: 6px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    vertical-align: middle;
    border-radius: 50%;
    transition: color 0.15s ease, background 0.15s ease;
}
.terms-info-btn:hover,
.terms-info-btn:focus {
    color: var(--primary-color);
    background: var(--bg-soft);
    outline: none;
}
.location-modal-row {
    display: flex;
    align-items: center;
    gap: 4px;
}
.location-modal-row > .location-modal-item {
    flex: 1;
}
/* Install App modal — per-platform blocks */
.install-block {
    margin-top: 8px;
}
.install-block h3 {
    margin: 0 0 8px;
    font-size: 15px;
    color: var(--text-dark);
}
.install-steps {
    margin: 0;
    padding-left: 22px;
    color: var(--text-dark);
    line-height: 1.55;
}
.install-steps li {
    margin-bottom: 6px;
}
.install-note {
    margin-top: 12px;
    color: var(--text-light);
    font-size: 13px;
}
/* History modal: title row holds h2 + optional "Edit item" deep-link */
.modal-header-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    min-width: 0;
}
.modal-header-title-row h2 {
    margin: 0;
}
.btn-edit-item {
    flex: 0 0 auto;
    padding: 6px 14px;
    background: var(--primary-color);
    color: var(--text-on-color);
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}
.btn-edit-item:hover,
.btn-edit-item:focus {
    box-shadow: 0 0 0 3px var(--primary-glow);
    transform: translateY(-1px);
    outline: none;
}
.btn-edit-item[hidden] {
    display: none;
}
.buyer-source {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 10px 36px 10px 16px;
    margin-bottom: 12px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
    position: relative;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.buyer-source:hover,
.buyer-source:focus {
    background: var(--bg-soft);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
    outline: none;
}
.buyer-source::after {
    content: '›';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 22px;
    line-height: 1;
}
.buyer-source-label {
    font-size: 13px;
    color: var(--text-light);
}
.buyer-source-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark);
}

/* === Home: search =================================================== */
.search-container {
    margin-bottom: 12px;
    position: relative;
}
.search-input {
    width: 100%;
    padding: 12px 44px 12px 20px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-dark);
    transition: all 0.3s ease;
}
.search-input::placeholder { color: var(--text-light); }
.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.search-clear {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: var(--border-color);
    color: var(--text-on-color);
    font-size: 20px;
    line-height: 1;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s ease;
}
.search-clear:hover { background: var(--danger-color); }

/* === Home: states (loading, error, empty) =========================== */
.loading,
.modal-loading {
    text-align: center;
    padding: 60px 20px;
}
.error,
.modal-error {
    text-align: center;
    padding: 40px 20px;
    color: var(--danger-color);
}
.no-results,
.no-buyer {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}
.no-buyer p { margin-bottom: 16px; }

/* === Home: price grid ============================================== */
.price-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 20px 0;
}

.price-card {
    background: var(--surface);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}
.price-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.price-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    flex: 1;
    line-height: 1.4;
}
.item-desc {
    margin-top: 8px;
    font-size: 13px;
    font-style: italic;
    color: var(--text-light);
    line-height: 1.4;
}

.price-display {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    min-width: 120px;
    justify-content: flex-end;
}
.price-indicator {
    font-size: 28px;
    font-weight: bold;
    flex-shrink: 0;
    line-height: 1;
    width: 32px;
    text-align: center;
}
.price-indicator.up { color: var(--success-color); }
.price-indicator.down { color: var(--danger-color); }

.price-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    white-space: nowrap;
}
.price-value.price-call,
.current-price-value.price-call {
    color: var(--secondary-color);
    letter-spacing: 0.05em;
}

/* === Home: price detail modal ====================================== */
/* Uses .modal + an inner element that has card surface treatment. The
   home modal's inner element is .modal-content (legacy markup). */
.modal-content {
    background: var(--surface);
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    box-shadow: var(--shadow-modal);
    animation: modalSlideIn 0.3s ease;
    display: flex;
    flex-direction: column;
}
@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Detail modal-specific item-description under the title */
.modal-item-desc {
    grid-column: 1 / -1;
    font-size: 14px;
    font-style: italic;
    color: var(--text-light);
    line-height: 1.4;
}

.current-price-display {
    text-align: center;
    padding: 16px;
    background: var(--bg-page);
    border-radius: 8px;
    margin-bottom: 20px;
}
.current-price-label {
    display: block;
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 4px;
}
.current-price-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-color);
}
.current-price-display .price-indicator {
    font-size: 28px;
    font-weight: bold;
    margin-left: 8px;
}

.modal-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.time-range-selector,
.graph-type-selector {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}
.time-range-label,
.graph-type-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    margin-right: 4px;
}
.btn-range,
.btn-graph-type {
    padding: 8px 16px;
    background: var(--surface);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-dark);
}
.btn-range { min-width: 44px; }
.btn-graph-type { padding: 8px 20px; }
.btn-range:hover,
.btn-graph-type:hover {
    border-color: var(--primary-color);
}
.btn-range.active,
.btn-graph-type.active {
    background: var(--primary-color);
    color: var(--text-on-color);
    border-color: var(--primary-color);
}

.chart-container {
    position: relative;
    height: 300px;
    margin-bottom: 24px;
}

.modal-stats {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.stat-section {
    background: var(--surface);
    border-radius: 8px;
    padding: 16px;
    box-shadow: var(--shadow);
}
.stat-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 12px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.stat-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.stat-item {
    text-align: center;
    padding: 12px;
    background: var(--bg-page);
    border-radius: 6px;
}
.stat-label {
    display: block;
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 4px;
}
.stat-value {
    display: block;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
}
.stat-value.stat-positive { color: var(--success-color); }
.stat-value.stat-negative { color: var(--danger-color); }
.stat-date {
    display: block;
    font-size: 11px;
    color: var(--text-light);
    margin-top: 2px;
}

.modal-no-history {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
    font-style: italic;
}
.modal-no-history.hidden { display: none; }

/* === Register: role-selector ======================================== */
.role-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}
.role-option {
    padding: 20px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s ease;
    color: var(--text-dark);
    background: var(--surface);
}
.role-option:hover {
    border-color: var(--primary-color);
    background: var(--bg-soft);
}
.role-option.selected {
    border-color: var(--primary-color);
    background: var(--bg-gradient);
    color: var(--text-on-color);
}
.role-option input[type="radio"] { display: none; }
.role-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}
.role-description {
    font-size: 12px;
    opacity: 0.8;
}
.password-requirements {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
}
.password-strength {
    margin-top: 6px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.password-strength-stars {
    letter-spacing: 1px;
    color: var(--primary-color);
    font-size: 14px;
}
.password-strength-label {
    color: var(--text-light);
    font-size: 12px;
}
.password-mismatch {
    margin-top: 4px;
    font-size: 12px;
    color: var(--warn-text);
    background: var(--warn-bg);
    border: 1px solid var(--warn-border);
    border-radius: 4px;
    padding: 4px 8px;
}

/* === Auth: password reveal + divider ================================ */
.password-wrapper { position: relative; }
.password-wrapper input { padding-right: 44px; }
.password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}
.password-toggle:hover,
.password-toggle:focus {
    color: var(--text-dark);
    outline: none;
}

/* === Profile: active-buyer selector pill ============================ */
.active-buyer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    padding: 10px 14px;
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    font-size: 14px;
}
.active-buyer label {
    color: var(--text-light);
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 0;
}
.active-buyer select {
    width: auto;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    min-width: 200px;
    max-width: 100%;
}
.active-buyer select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.active-buyer select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--bg-soft);
}

/* === Profile: preferred buyers list ================================= */
.preferred-list { margin: 0 0 14px; }
.preferred-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-light);
    font-style: italic;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
}
.preferred-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    margin-bottom: 8px;
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
}
.preferred-row.is-default {
    background: var(--preferred-default-bg);
    border-color: var(--preferred-default-border);
}
.preferred-row-body { flex: 1; min-width: 0; }
.preferred-row-name {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 15px;
    line-height: 1.3;
    word-break: break-word;
}
.preferred-row-address {
    color: var(--text-light);
    font-size: 13px;
    margin-top: 4px;
    line-height: 1.4;
}
.preferred-row-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

/* === Profile: picker-modal (uses generic .modal + .modal-card) ===== */
/* Inner header strip used by picker / location modals. Sticks to the
   top of the modal card; flex row so a back button + title + close
   coexist. */
.picker-header {
    padding: 18px 56px 14px 22px;  /* right pad reserves space for card-close */
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.picker-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
    flex: 1;
}
.picker-header + .card-close,
.picker-header > .card-close {
    position: absolute;
    top: 10px;
    right: 12px;
}

.picker-back {
    background: transparent;
    border: none;
    color: var(--primary-color);
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 6px;
    margin-right: 8px;
}
.picker-back:hover,
.picker-back:focus {
    background: var(--bg-soft);
    outline: none;
}
.picker-back.hidden { display: none; }
.picker-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px;
    margin: 0;
    list-style: none;
}
.picker-item {
    display: block;
    width: 100%;
    text-align: left;
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
    font: inherit;
    color: inherit;
}
.picker-item:hover,
.picker-item:focus {
    background: var(--surface);
    border-color: var(--primary-color);
    transform: translateX(2px);
    outline: none;
}
.picker-item:last-child { margin-bottom: 0; }
.picker-item-name {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 15px;
    line-height: 1.3;
}
.picker-item-meta {
    color: var(--text-light);
    font-size: 13px;
    margin-top: 4px;
    line-height: 1.4;
}
.picker-item-chevron::after {
    content: '›';
    float: right;
    color: var(--text-light);
    font-size: 18px;
    line-height: 1;
}
.picker-item.already-added {
    opacity: 0.5;
    cursor: not-allowed;
}
.picker-item.already-added:hover { transform: none; }
/* When picker open, hide page card-close so it doesn't read as a duplicate */
body.picker-open > .card > .card-close { display: none; }

/* === Directory: buyer grid ========================================== */
.state-block {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
    font-size: 14px;
}
.error-text {
    color: var(--danger-color);
    margin-bottom: 12px;
}

.buyer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.buyer-card {
    background: var(--surface-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 18px;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.buyer-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card-hover);
}
.buyer-card.is-default {
    border-color: var(--preferred-default-border);
    box-shadow: var(--preferred-default-shadow);
}
.buyer-name {
    color: var(--text-dark);
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 6px;
    line-height: 1.3;
}
.buyer-address {
    color: var(--text-light);
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 14px;
    flex-grow: 1;
}
.buyer-locations {
    color: var(--text-light);
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 14px;
    flex-grow: 1;
    font-style: italic;
}

.btn-view {
    display: inline-block;
    text-align: center;
    text-decoration: none;
    background: var(--bg-gradient);
    color: var(--text-on-color);
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-view:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px var(--primary-glow-strong);
}

.btn-select {
    display: inline-block;
    text-align: center;
    text-decoration: none;
    background: var(--surface);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    font-family: inherit;
}
.btn-select:hover,
.btn-select:focus {
    background: var(--primary-color);
    color: var(--text-on-color);
    outline: none;
}

/* Preferred/All segmented toggle (sellers, above grid) */
.prefs-toggle {
    display: flex;
    width: fit-content;
    margin: 0 auto 36px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--primary-color);
    user-select: none;
}
.prefs-toggle-btn {
    background: var(--surface);
    color: var(--primary-color);
    border: none;
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.prefs-toggle-btn:not(.active):hover { background: var(--bg-soft); }
.prefs-toggle-btn.active {
    background: var(--primary-color);
    color: var(--text-on-color);
    cursor: default;
}
.prefs-toggle-btn + .prefs-toggle-btn {
    border-left: 1px solid var(--primary-color);
}
.prefs-toggle-btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.default-tag {
    display: inline-block;
    margin-left: 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--admin-badge-bg);
    color: var(--admin-badge-text);
    vertical-align: middle;
}

.prefs-empty {
    text-align: center;
    padding: 36px 24px;
    color: var(--text-light);
    background: var(--surface-card);
    border: 1px dashed var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.5;
}
.prefs-empty a { color: var(--primary-color); font-weight: 600; }

/* === Directory: location-picker modal (uses generic .modal) ======== */
.location-modal-list {
    overflow-y: auto;
    padding: 12px;
    margin: 0;
    list-style: none;
}
.location-modal-item {
    display: block;
    background: var(--surface-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 8px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
    cursor: pointer;
}
.location-modal-item:last-child { margin-bottom: 0; }
.location-modal-item:hover,
.location-modal-item:focus {
    background: var(--surface);
    border-color: var(--primary-color);
    transform: translateX(2px);
    outline: none;
}
.location-modal-item-name {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 15px;
    line-height: 1.3;
}
.location-modal-item-address {
    color: var(--text-light);
    font-size: 13px;
    margin-top: 4px;
    line-height: 1.4;
}
/* Selection feedback while the picked location navigates to ../?buyer=N.
   Distinct border + a "Loading…" suffix via ::after so the click is
   unmistakably acknowledged in the brief gap before the page loads. */
.location-modal-item.is-selecting {
    border-color: var(--primary-color);
    background: var(--bg-soft);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.location-modal-item.is-selecting::after {
    content: ' Loading…';
    display: inline-block;
    margin-top: 6px;
    color: var(--primary-color);
    font-size: 12px;
    font-weight: 600;
}
.picker-footer {
    display: flex;
    justify-content: flex-end;
    padding: 12px 20px 16px;
}
.picker-footer .btn {
    width: auto;
    padding: 8px 18px;
    font-size: 14px;
}

/* === Dashboard: upload area ========================================= */
.upload-area {
    border: 2px dashed var(--primary-color);
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    background: var(--bg-soft);
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}
.upload-area:hover {
    border-color: var(--secondary-color);
    background: var(--bg-soft-hover);
}
.upload-area.dragover {
    border-color: var(--secondary-color);
    background: var(--bg-soft-active);
    transform: scale(1.02);
}
.upload-area.locked {
    pointer-events: none;
    opacity: 0.5;
    cursor: not-allowed;
}
.upload-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 10px;
}
.upload-text {
    color: var(--text-light);
    margin-bottom: 10px;
}
.file-input { display: none; }
.file-info {
    background: var(--bg-soft);
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    display: none;
}
.file-info.show { display: block; }
.file-name {
    color: var(--text-dark);
    font-weight: 600;
    margin-bottom: 5px;
}
.file-size {
    color: var(--text-light);
    font-size: 14px;
}

/* === Dashboard: collapsible section ================================= */
.collapsible-section + .collapsible-section { margin-top: 12px; }
.collapsible-section {
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--bg-soft);
    overflow: hidden;
}
.collapsible-section > summary {
    cursor: pointer;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 15px;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 10px;
    list-style: none;
    user-select: none;
}
.collapsible-section > summary::-webkit-details-marker { display: none; }
.collapsible-section > summary::before {
    content: '';
    width: 0;
    height: 0;
    border-left: 6px solid var(--text-light);
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    transition: transform 0.15s ease;
}
.collapsible-section[open] > summary::before { transform: rotate(90deg); }
.collapsible-section > summary:hover { background: var(--bg-soft-hover); }
.collapsible-body {
    padding: 16px;
    background: var(--surface);
    border-top: 1px solid var(--border-color);
}

/* === Dashboard: items list ========================================= */
.items-section .empty,
.items-section .loading {
    color: var(--text-light);
    font-size: 14px;
    text-align: center;
    padding: 20px;
}
.items-list { display: flex; flex-direction: column; gap: 6px; }
.item-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.item-row:hover,
.item-row:focus {
    background: var(--bg-soft-hover);
    border-color: var(--border-soft-hover);
    outline: none;
}
.item-row.is-hidden { opacity: 0.55; }
.item-row-meta { display: flex; flex-direction: column; min-width: 0; }
.item-row-name {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.item-row-name-original {
    color: var(--text-light);
    font-weight: 400;
    font-size: 12px;
    margin-left: 6px;
}
.item-row-desc {
    color: var(--text-light);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.item-row-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.item-row-price {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text-dark);
}
.item-row-badges {
    display: inline-flex;
    align-items: center;
    font-size: 16px;
    line-height: 1;
}
.item-badge {
    padding: 0 1px;
    font-weight: 700;
}
.item-badge.hidden { color: var(--danger-soft-text); }
.item-badge.call   { color: var(--secondary-color); }
.item-badge.nohist { color: var(--info-soft-text); }

/* === Dashboard: item edit modal ==================================== */
.item-modal-meta {
    color: var(--text-light);
    font-size: 12px;
    margin-bottom: 16px;
}
.item-modal-toggle {
    display: flex !important;
    align-items: center;
    gap: 8px;
    margin-top: 16px !important;
    cursor: pointer;
    font-weight: 500 !important;
    color: var(--text-dark) !important;
}
.item-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}
.item-modal-actions .btn {
    width: auto;
    min-width: 90px;
    padding: 8px 18px;
    font-size: 14px;
}
.item-modal-actions .item-modal-delete {
    margin-right: auto;
}
.item-modal-error {
    display: none;
    margin-top: 12px;
    padding: 8px 12px;
    background: var(--danger-soft-bg);
    color: var(--danger-soft-text);
    border-radius: 6px;
    font-size: 13px;
}
.item-modal-error.show { display: block; }

/* === Dashboard: past uploads list ================================== */
.uploads-list { display: flex; flex-direction: column; gap: 6px; }
.upload-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    font-size: 14px;
}
.upload-row:hover,
.upload-row:focus {
    background: var(--bg-soft-hover);
    border-color: var(--border-soft-hover);
    outline: none;
}
.upload-row.is-deleted { opacity: 0.55; }
.upload-row-when {
    color: var(--text-dark);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.upload-row-size {
    color: var(--text-light);
    font-variant-numeric: tabular-nums;
    font-size: 13px;
}
.upload-row-dpe {
    display: inline-flex;
    gap: 4px;
    margin-left: auto;
}
.dpe-icon-btn {
    background: var(--bg-soft);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-light);
    font-size: 12px;
    line-height: 1;
    padding: 2px 5px;
    cursor: pointer;
    font-family: monospace;
}
.dpe-icon-btn:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
}
.deleted-badge {
    font-size: 10px;
    text-transform: uppercase;
    background: var(--danger-soft-bg);
    color: var(--danger-soft-text);
    border-radius: 3px;
    padding: 2px 6px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

/* === Dashboard: upload raw-text modal (wider for PRN-width lines) === */
.upload-modal-meta {
    color: var(--text-light);
    font-size: 12px;
    margin-bottom: 16px;
}
.upload-modal-card pre {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 6px;
    padding: 12px;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-dark);
    white-space: pre;
    overflow: auto;
    flex: 1;
    min-height: 0;
}
.upload-modal-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
}

/* === Responsive breakpoints ========================================= */
@media (max-width: 768px) {
    .card { padding: 28px 20px; }
    body.page-home .app { padding: 16px; padding-bottom: 0; }
    .header { padding: 0 44px; }
    .header-brand { font-size: 16px; }
    .price-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 12px;
    }
    .price-card { padding: 16px; }
    .chart-container { height: 250px; }
    .modal-stats { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 540px) {
    .buyer-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .price-grid { grid-template-columns: 1fr; }
    .modal-stats { grid-template-columns: 1fr; }
    .time-range-label,
    .graph-type-label {
        flex-basis: 100%;
        text-align: center;
        margin-right: 0;
    }
    .btn-range {
        flex: 0 0 calc((100% - 16px) / 3);
        min-width: 0;
        padding-left: 4px;
        padding-right: 4px;
        text-align: center;
    }
    .btn-graph-type {
        flex: 1 1 calc((100% - 8px) / 2);
        text-align: center;
    }
    .role-selector { grid-template-columns: 1fr; }
}

@media print {
    .search-container,
    .modal,
    .header,
    .hamburger-menu,
    .menu-overlay { display: none; }
    .price-card { break-inside: avoid; }
    body { padding-top: 0; }
}

/* =================================================================
   Admin shell — landing, sub-nav, stat grid, tables, action modal,
   filter strips, badges. All colors flow through scheme vars; do
   not introduce hex literals here.
   ================================================================= */

/* Admin pages get a flat surface so the dense data UI stays readable
   against the brand gradient. */
body.page-admin {
    background: var(--bg-page);
}

.admin-nav {
    position: sticky;
    top: 40px;
    z-index: 90;
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}
.admin-nav-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 2px;
    overflow-x: auto;
}
.admin-tab {
    display: inline-block;
    padding: 10px 14px;
    color: var(--text-light);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
@media (max-width: 720px) {
    .admin-nav-inner { padding: 0 6px; }
    .admin-tab { padding: 6px 8px; font-size: 13px; }
}
.admin-tab:hover {
    color: var(--text-dark);
    background: var(--bg-soft);
}
.admin-tab-active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.admin-card {
    max-width: 1100px;
}

.admin-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin: 16px 0 28px;
}
.admin-stat {
    display: block;
    padding: 14px;
    border-radius: 10px;
    background: var(--surface-card);
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-dark);
    transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.admin-stat:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-card);
    border-color: var(--border-soft-hover);
}
.admin-stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    margin-bottom: 4px;
}
.admin-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-dark);
}
.admin-stat-warn .admin-stat-value {
    color: var(--warn-text);
}
.admin-stat-warn {
    background: var(--warn-bg);
    border-color: var(--warn-border);
}
.admin-stat-good {
    background: var(--bg-success);
    border-color: var(--success-color);
}
.admin-stat-good .admin-stat-value {
    color: var(--success-color);
}
.admin-stat-audit {
    background: var(--admin-stat-audit-bg);
    border-color: var(--admin-stat-audit-border);
}
.admin-stat-audit .admin-stat-value {
    color: var(--admin-stat-audit-border);
}
.admin-stat-expiring {
    background: var(--admin-stat-expiring-bg);
    border-color: var(--admin-stat-expiring-border);
}
.admin-stat-expiring .admin-stat-value {
    color: var(--admin-stat-expiring-text);
}

.admin-section-h {
    font-size: 18px;
    margin: 24px 0 10px;
    color: var(--text-dark);
}
.admin-empty {
    color: var(--text-light);
    font-style: italic;
    padding: 16px 0;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.admin-table th,
.admin-table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}
.admin-table th {
    background: var(--bg-soft);
    color: var(--text-dark);
    font-weight: 600;
    position: sticky;
    top: 0;
}
.admin-th-sort {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.admin-th-sort::after {
    content: ' \25B8';
    font-size: 10px;
    opacity: 0.3;
}
.admin-th-sort:hover {
    color: var(--primary-color);
}
.admin-th-sort-asc::after {
    content: ' \25B2' attr(data-sort-rank);
    opacity: 1;
    color: var(--primary-color);
}
.admin-th-sort-desc::after {
    content: ' \25BC' attr(data-sort-rank);
    opacity: 1;
    color: var(--primary-color);
}
.admin-table tr:hover td {
    background: var(--bg-soft);
}
.admin-table code {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 12px;
}
.admin-note-cell {
    color: var(--text-light);
    max-width: 320px;
}
.admin-foot-link {
    margin-top: 12px;
    text-align: right;
}
.admin-foot-link a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}
.admin-foot-link a:hover { text-decoration: underline; }

/* Settings page — fieldset + checkbox-row layout */
.admin-fieldset {
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    padding: 14px 16px 8px;
    margin: 12px 0 16px;
    background: var(--bg-soft);
}
.admin-fieldset legend {
    padding: 0 4px;
    margin-left: -4px;
    font-weight: 600;
    color: var(--text-dark);
}
.admin-panel {
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    padding: 14px 16px 12px;
    margin: 12px 0 16px;
    background: var(--bg-soft);
}
.admin-panel-heading {
    margin: 0 0 6px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-dark);
}
.admin-fieldset-blurb {
    font-size: 13px;
    color: var(--text-light);
    margin: 0 0 12px;
}
.admin-checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    border-top: 1px solid var(--border-soft);
    font-size: 14px;
    color: var(--text-dark);
    cursor: pointer;
}
.admin-checkbox-row:first-of-type { border-top: 0; }
.admin-checkbox-row input[type="checkbox"] {
    margin-top: 3px;
    flex: 0 0 auto;
}
.admin-checkbox-row strong { color: var(--text-dark); }
.admin-form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 8px;
}

/* Filter strip on list pages */
.admin-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    margin: 12px 0 16px;
    padding: 12px;
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
}
.admin-filter-field {
    display: flex;
    flex-direction: column;
    min-width: 140px;
}
.admin-filter-field label {
    font-size: 12px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}
.admin-filter-field select,
.admin-filter-field input {
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-dark);
    font-size: 14px;
}
.admin-filter-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
    align-items: center;
}
.admin-filter-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-light);
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
    cursor: pointer;
}
.admin-filter-checkbox input {
    width: auto;
    padding: 0;
    border: 0;
    margin: 0;
}

/* Row-action button cluster (in table cells) */
.admin-row-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.admin-row-actions .btn {
    padding: 4px 10px;
    font-size: 12px;
    min-width: 0;
}

/* Detail page sections */
.admin-detail-section {
    margin-top: 18px;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--surface-card);
}
.admin-detail-section h3 {
    margin: 0 0 10px;
    font-size: 16px;
    color: var(--text-dark);
}
.admin-detail-grid {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 14px;
    font-size: 14px;
}
.admin-detail-grid dt {
    color: var(--text-light);
    font-weight: 600;
    /* Top-align rather than vertically centering — when a dd contains
       a wrapped .admin-help paragraph the cell is much taller than the
       dt label, and centering pushes the label below the buttons row.
       align-self: start keeps the label level with the dd's top row. */
    align-self: start;
    padding-top: 4px;
}
.admin-detail-grid dd {
    margin: 0;
    color: var(--text-dark);
    word-break: break-word;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
/* Defeat the global `select { width:100% }`, `input { width:100% }`, and
   `.btn { width:100% }` so the flex row stays inline instead of each
   element stretching to fill the dd cell. */
.admin-detail-grid dd select,
.admin-detail-grid dd input[type="text"],
.admin-detail-grid dd input[type="email"],
.admin-detail-grid dd input[type="tel"],
.admin-detail-grid dd input[type="number"] {
    width: auto;
    padding: 6px 8px;
    font-size: 14px;
}
.admin-detail-grid dd .btn,
.admin-detail-grid dd button {
    width: auto;
}
/* Help paragraphs and inline-help notes occupy their own row so they
   don't compete with buttons for horizontal space. */
.admin-detail-grid dd > p,
.admin-detail-grid dd > .admin-help {
    flex-basis: 100%;
    margin: 4px 0 0;
}

/* Side-by-side comparison (used by subscription detail to show DB vs Stripe). */
.admin-compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
@media (max-width: 720px) {
    .admin-compare-grid { grid-template-columns: 1fr; }
}

/* Status / role badges in admin lists */
.admin-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--neutral-bg);
    color: var(--neutral-text);
}
.admin-badge-active    { background: var(--bg-success); color: var(--success-color); }
.admin-badge-pending   { background: var(--warn-bg);    color: var(--warn-text);     }
.admin-badge-suspended { background: var(--danger-soft-bg); color: var(--danger-soft-text); }
.admin-badge-admin     { background: var(--admin-badge-bg); color: var(--admin-badge-text); }
.admin-badge-override  { background: var(--primary-glow); color: var(--primary-color); }
.admin-badge-canceled  { background: var(--danger-soft-bg); color: var(--danger-soft-text); }

/* Admin confirmation + message modal layout — sticky title strip + a
   scrollable body, so long content doesn't carry the title (and close-X)
   off-screen. Per 2026-05-15 walkthrough. */
.admin-action-modal .modal-card {
    /* .modal-card already has display:flex / flex-direction:column /
       max-height:90vh / overflow:hidden — body scrolls inside. */
    padding: 0;
}
.admin-modal-header {
    flex-shrink: 0;
    padding: 22px 56px 12px 30px;   /* right pad reserves space for .card-close */
    border-bottom: 1px solid var(--border-color);
    background: var(--surface);
    border-radius: 12px 12px 0 0;
}
.admin-modal-header h2 {
    margin: 0;
    font-size: 19px;
    color: var(--text-dark);
}
.admin-modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 14px 30px 24px;
}

/* Confirmation modal body */
.admin-action-message {
    margin: 8px 0 14px;
    color: var(--text-dark);
}
.admin-action-note-wrap {
    margin: 0 0 14px;
}
.admin-action-note-wrap label {
    display: block;
    font-size: 13px;
    color: var(--text-dark);
    font-weight: 600;
    margin-bottom: 4px;
}
.admin-action-note-wrap textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-dark);
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
}
.admin-action-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.admin-action-error {
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    background: var(--danger-soft-bg);
    color: var(--danger-soft-text);
    border: 1px solid var(--danger-soft-border);
    display: none;
}
.admin-action-error.show {
    display: block;
}
.admin-required {
    color: var(--danger-color);
}
.admin-message-subject {
    padding: 8px;
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    background: var(--bg-soft);
    color: var(--text-dark);
    font-style: italic;
}

/* Inline edit form on detail pages */
.admin-form {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 10px 14px;
    align-items: center;
    margin: 8px 0;
}
.admin-form label {
    color: var(--text-light);
    font-weight: 600;
    font-size: 13px;
}
.admin-form input[type="text"],
.admin-form input[type="email"],
.admin-form input[type="tel"],
.admin-form input[type="number"],
.admin-form select,
.admin-form textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-dark);
    font-size: 14px;
    font-family: inherit;
}
.admin-form .admin-form-row-actions {
    grid-column: 2;
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

/* JSON-pretty container for audit log diffs */
.admin-json {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 6px;
    padding: 8px 10px;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-dark);
    margin: 4px 0 0;
}

/* Pagination strip used by list pages */
.admin-pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
}
.admin-pagination a,
.admin-pagination span {
    padding: 4px 10px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 13px;
    color: var(--text-light);
    border: 1px solid var(--border-color);
    background: var(--surface);
}
.admin-pagination a:hover {
    color: var(--primary-color);
    border-color: var(--border-soft-hover);
}
.admin-pagination .admin-pagination-current {
    color: var(--primary-color);
    border-color: var(--primary-color);
    font-weight: 700;
}
.admin-pagination .admin-pagination-disabled {
    color: var(--text-on-color-faint);
    cursor: default;
}

/* Stacked inline metadata used inside compact admin-table cells —
   primary identity (email) + small secondary line (login / customer id). */
.admin-cell-stack {
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.3;
}
.admin-cell-stack .admin-cell-sub {
    font-size: 11px;
    color: var(--text-light);
    word-break: break-word;
}
.admin-badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2px;
}
.admin-help {
    font-size: 12px;
    color: var(--text-light);
    margin: 4px 0 0;
    line-height: 1.4;
}
.admin-help-strong {
    color: var(--text-dark);
}

/* Responsive table — at narrow widths, drop the table grid and render
   each row as a stacked card. Cells use data-label to print their column
   name as a prefix. Apply by adding class="admin-table-stack" to the
   <table> element along with admin-table. */
@media (max-width: 720px) {
    .admin-table-stack thead { display: none; }
    .admin-table-stack tr {
        display: block;
        margin: 0 0 10px;
        padding: 8px 10px;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        background: var(--surface-card);
    }
    .admin-table-stack tr:hover td { background: transparent; }
    .admin-table-stack td {
        display: block;
        padding: 4px 0;
        border-bottom: 1px dashed var(--border-color);
    }
    .admin-table-stack td:last-child { border-bottom: 0; }
    .admin-table-stack td::before {
        content: attr(data-label);
        display: block;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-light);
        margin-bottom: 2px;
    }
    .admin-table-stack td[data-label=""]::before { display: none; }
}

/* ============================================================
   Help system — public (/spv/help/) and admin (/admin/help/)
   All colors via existing vars; no scheme migration needed.
   ============================================================ */

/* --- Public help page --- */

.help-category {
    margin: 24px 0;
}

.help-cat-h2 {
    font-size: 1.2rem;
    color: var(--text-dark);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 6px;
    margin: 0 0 12px 0;
}

.help-topic {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 8px;
    background: var(--bg-soft);
}

.help-topic[open] {
    background: var(--bg-soft-hover);
    border-color: var(--primary-color);
}

.help-topic > summary {
    padding: 12px 14px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-dark);
    list-style: none;
}

.help-topic > summary::-webkit-details-marker { display: none; }

.help-topic > summary::before {
    content: '▸';
    display: inline-block;
    margin-right: 8px;
    color: var(--text-light);
    transition: transform 120ms ease;
}

.help-topic[open] > summary::before {
    transform: rotate(90deg);
}

.help-topic-body {
    padding: 0 16px 4px 16px;
    color: var(--text-dark);
    line-height: 1.55;
}

.help-topic-body :first-child { margin-top: 6px; }
.help-topic-body :last-child  { margin-bottom: 6px; }

.help-topic-body pre {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 10px;
    overflow-x: auto;
}

.help-topic-body code {
    background: var(--surface);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.92em;
}

.help-topic-body pre code {
    background: none;
    padding: 0;
}

.help-topic-permalink {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 16px 12px 16px;
    font-size: 0.85rem;
    color: var(--text-light);
    margin: 0;
}

.help-search {
    margin: 0 0 16px;
}
.help-search input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font: inherit;
    font-size: 15px;
    background: var(--surface);
    color: var(--text-dark);
}
.help-search input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.help-search-jump {
    text-decoration: none;
    font-size: 1rem;
    opacity: 0.5;
    transition: opacity 0.15s ease;
}
.help-search-jump:hover {
    opacity: 1;
}

.help-badge-admin {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--admin-badge-bg);
    color: var(--admin-badge-text);
    border-radius: 3px;
    vertical-align: middle;
}
.help-badge-buyers {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--buyers-badge-bg);
    color: var(--buyers-badge-text);
    border-radius: 3px;
    vertical-align: middle;
}

/* --- Admin help editor --- */

.admin-section-h2 {
    font-size: 1.1rem;
    color: var(--text-dark);
    margin: 20px 0 10px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-color);
}

.admin-dim {
    color: var(--text-light);
    font-size: 0.9em;
}

.form-row {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-row label {
    font-weight: 600;
    color: var(--text-dark);
}

.form-row input,
.form-row select,
.form-row textarea {
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font: inherit;
    width: 100%;
    box-sizing: border-box;
}

.form-row textarea {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.92rem;
    resize: vertical;
}

.form-help {
    font-size: 0.85rem;
    color: var(--text-light);
    margin: 2px 0 0 0;
}

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

.admin-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
    margin: 16px 0 0 0;
}

.admin-tabs .admin-tab {
    background: none;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    padding: 8px 14px;
    cursor: pointer;
    color: var(--text-light);
    font: inherit;
}

.admin-tabs .admin-tab.admin-tab-active {
    color: var(--primary-color);
    border-color: var(--border-color);
    background: var(--surface);
    margin-bottom: -1px;
}

.help-cat-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.help-cat-row {
    display: grid;
    grid-template-columns: auto 1fr 80px;
    align-items: center;
    gap: 12px;
    padding: 6px 8px;
    border-radius: 4px;
}

.help-cat-row:hover {
    background: var(--bg-soft-hover);
}

.help-cat-title { color: var(--text-dark); }

.help-cat-sort {
    padding: 4px 6px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    font: inherit;
    text-align: center;
}

.help-preview-pane {
    border: 1px solid var(--border-color);
    border-top: none;
    background: var(--surface);
    padding: 12px 14px;
    min-height: 200px;
    margin-bottom: 12px;
}

.help-preview-warn {
    background: var(--warn-bg);
    border: 1px solid var(--warn-border);
    color: var(--warn-text);
    border-radius: 4px;
    padding: 10px 12px;
    margin: 0 0 12px 0;
    font-size: 0.9rem;
}

.help-preview-warn ul {
    margin: 6px 0 6px 22px;
    padding: 0;
}

.help-preview-body {
    color: var(--text-dark);
    line-height: 1.55;
}

@media (max-width: 600px) {
    .help-cat-row {
        grid-template-columns: auto 1fr;
    }
    .help-cat-sort {
        grid-column: 2 / -1;
        justify-self: start;
        width: 80px;
    }
}

/* ===== Welcome / marketing landing (/spv/welcome) ===================== */
/* Layout-only additions; all colors via existing scheme vars (no new
   vars, so no per-scheme edit). Hero sits on the brand gradient with
   --text-on-color (white in every scheme); content bands sit on light
   surfaces so --text-dark stays readable. */
.welcome { max-width: 960px; margin: 0 auto; padding: 0 16px 48px; }

.welcome-hero {
    text-align: center;
    padding: 56px 24px 48px;
    background: var(--bg-gradient);
    border-radius: 18px;
    margin-top: 16px;
    box-shadow: var(--shadow-card);
}
.welcome-hero-logo { width: 72px; height: 72px; margin-bottom: 16px; }
.welcome-hero h1 {
    font-size: clamp(1.6rem, 4.5vw, 2.6rem);
    line-height: 1.15;
    margin: 0 auto 16px;
    max-width: 16em;
    color: var(--text-on-color);
}
.welcome-hero-sub {
    font-size: clamp(1rem, 2.2vw, 1.2rem);
    color: var(--text-on-color-muted);
    max-width: 32em;
    margin: 0 auto 28px;
    line-height: 1.5;
}
.welcome-cta-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
/* Hero CTAs override the full-width .btn base and pop on the gradient. */
.welcome-btn-primary, .welcome-btn-ghost { width: auto; padding: 14px 28px; }
.welcome-btn-primary { background: var(--surface); color: var(--primary-color); }
.welcome-btn-primary:hover { box-shadow: var(--shadow-card-hover); }
.welcome-btn-ghost { background: transparent; color: var(--text-on-color); border: 1px solid var(--text-on-color-faint); }
.welcome-btn-ghost:hover { border-color: var(--text-on-color); }

.welcome-band {
    background: var(--surface);
    border-radius: 16px;
    padding: 40px 24px;
    margin: 16px 0;
    box-shadow: var(--shadow-card);
}
.welcome-band-alt { background: var(--bg-soft); }
.welcome-band h2 {
    text-align: center;
    font-size: clamp(1.3rem, 3vw, 1.9rem);
    margin: 0 0 28px;
    color: var(--text-dark);
}

.welcome-why { max-width: 38em; margin: 0 auto; display: grid; gap: 16px; }
.welcome-why p { font-size: 1.05rem; line-height: 1.55; color: var(--text-dark); margin: 0; }

.welcome-features {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.welcome-feature {
    background: var(--surface-card);
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    padding: 22px;
    box-shadow: var(--shadow-card);
}
.welcome-feature h3 { margin: 0 0 8px; font-size: 1.1rem; color: var(--primary-color); }
.welcome-feature p { margin: 0; line-height: 1.5; color: var(--text-dark); }

.welcome-companion { max-width: 40em; margin: 0 auto; text-align: center; }
.welcome-companion p { line-height: 1.55; color: var(--text-dark); margin: 0; }

.welcome-form-wrap { max-width: 30em; margin: 0 auto; }
.welcome-form-intro { text-align: center; color: var(--text-light); margin: 0 0 20px; line-height: 1.5; }
.welcome-optional { color: var(--text-light); font-weight: normal; font-size: 0.85em; }
