/*
Theme Name: MARGN.PLUS
Theme URI: https://margn.plus
Author: MARGN.PLUS
Author URI: https://margn.plus
Description: Analytics dashboard theme for Whatnot resellers
Version: 1.28.63
Requires at least: 6.0
Tested up to: 6.5
Requires PHP: 8.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: margn-plus
*/

/* ── Account page tabs (v1.28.18) ───────────────────────────────────────
 * 5-tab nav (Profile / Plan & Billing / Data / Support / Danger Zone).
 * Different class namespace than the dashboard's .tab-btn so the dashboard's
 * switchTab() can't accidentally sweep these into a chart re-render.
 */
.account-tab-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary, #b0a4c0);
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.6rem 0.9rem;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
    margin-bottom: -1px; /* sits ON the parent's bottom border so active state highlights cleanly */
}
.account-tab-btn:hover {
    color: var(--text-primary, #fff);
    background: rgba(124, 58, 237, 0.06);
}
.account-tab-btn.active {
    color: var(--accent-purple, #7c3aed);
    border-bottom-color: var(--accent-purple, #7c3aed);
}
.account-tab-btn:focus-visible {
    outline: 2px solid var(--accent-purple, #7c3aed);
    outline-offset: 2px;
    border-radius: var(--radius-sm, 6px) var(--radius-sm, 6px) 0 0;
}

.account-tab-panel {
    display: block;
}
/* The PHP renders inactive panels with the hidden attr, but defend in CSS
 * too in case someone toggles only the .active class. */
.account-tab-panel:not(.active) {
    display: none;
}

@media (max-width: 600px) {
    .account-tabs-nav {
        gap: 0.25rem !important;
        overflow-x: auto;
        scrollbar-width: thin;
    }
    .account-tab-btn {
        padding: 0.5rem 0.6rem;
        font-size: 0.85rem;
        white-space: nowrap;
    }
}

/* ── BETA mark (v1.28.8) ────────────────────────────────────────────────
 * Thin, all-caps, slightly raised + faded "Beta" suffix that rides
 * alongside the wordmark. Inherits the parent's color so it works on
 * both the gradient login/register hero and the plain header/footer.
 */
.beta-mark {
    font-weight: 200;
    font-size: 0.55em;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-left: 0.45em;
    opacity: 0.7;
    vertical-align: 0.25em;
    -webkit-background-clip: initial;
    background-clip: initial;
    -webkit-text-fill-color: currentColor;
    color: currentColor;
}

/* ── Founding Member badge (v1.28.26) ───────────────────────────────────
 * Tiny ✨ next to "Account" in the nav for users with the
 * _margn_founding_member flag. Subtle gold; scales with surrounding font;
 * tooltip on hover. Costs nothing to render but signals appreciation
 * everywhere they navigate.
 */
.founder-badge {
    color: var(--accent-yellow, #ffd166);
    margin-left: 0.25em;
    font-size: 0.95em;
    text-shadow: 0 0 6px rgba(255, 209, 102, 0.45);
    cursor: help;
}

/* ==========================================================================
   Accessibility utilities
   ========================================================================== */

/* WordPress-standard visually-hidden pattern. Keeps content in the
 * accessibility tree for screen readers while removing it from the
 * visual + tap-target layout. */
.screen-reader-text {
    position: absolute !important;
    clip: rect(1px, 1px, 1px, 1px);
    width: 1px;
    height: 1px;
    overflow: hidden;
    word-wrap: normal !important;
}
.screen-reader-text:focus {
    clip: auto !important;
    clip-path: none;
    display: block;
    width: auto;
    height: auto;
    z-index: 100000;
}

/* Skip-to-content link: invisible off-screen, revealed when it receives
 * keyboard focus. Lets users bypass the nav on Tab. */
.skip-link {
    left: -9999px;
    position: absolute;
    top: auto;
}
.skip-link:focus {
    background: #fff;
    color: #0f0f1a;
    clip: auto;
    clip-path: none;
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    height: auto;
    left: 1rem;
    line-height: 1;
    padding: 0.75rem 1rem;
    text-decoration: none;
    top: 1rem;
    width: auto;
    z-index: 100000;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

#main:focus { outline: none; }

/* ==========================================================================
   CSS Variables
   ========================================================================== */

:root {
    --bg-primary: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-card-alt: #16213e;
    --accent-purple: #9f5de6;
    --accent-teal: #06d6a0;
    --accent-pink: #f472b6;
    --accent-rose: #fb7185;
    --accent-yellow: #ffd166;
    --accent-blue: #60a5fa;
    --accent-orange: #f78c6b;
    --accent-lavender: #c4b5fd;
    --text-primary: #f0e8f8;
    --text-secondary: #c4b5d0;   /* bumped from #b0a4c0 for AA contrast on dark bg (~7.4:1) */
    --text-muted: #9aa0b3;       /* bumped from #6b7280 \u2014 old was 4.1:1 and failed AA for body text */
    --border: #3d2d54;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
    --transition: 0.2s ease;
    --nav-height: 64px;
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */

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

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

body,
html {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-family);
    /* v1.28.5: body baseline bumped 16 \u2192 17px. Small bump, big
     * legibility win for secondary text without pushing layouts around.
     * Chart tooltips, Tune-Up detail, etc. all inherit from here. */
    font-size: 17px;
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.margn-dark-theme {
    background-color: var(--bg-primary);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: var(--accent-purple);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--accent-lavender);
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
}

/* v1.28.5: headings upsized. h3 \u2014 the card-title workhorse \u2014
 * bumped to 2rem so cards feel like first-class surfaces, not footnotes.
 * .stat-card .stat-value is deliberately untouched downstream. */
h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 2rem; }
h4 { font-size: 1.25rem; }

p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

/* ==========================================================================
   Layout
   ========================================================================== */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    width: 100%;
}

.site-content {
    padding-top: calc(var(--nav-height) + 2rem);
    padding-bottom: 3rem;
    min-height: calc(100vh - 200px);
}

/* ==========================================================================
   Navigation / Header Bar
   ========================================================================== */

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(15, 15, 26, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    height: var(--nav-height);
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

.site-brand {
    font-size: 1.25rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-teal));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.site-brand a {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-teal));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.site-nav a {
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    transition: all var(--transition);
}

.site-nav a:hover,
.site-nav a.active {
    color: var(--text-primary);
    background: rgba(159, 93, 230, 0.1);
}
.site-nav a.nav-upgrade-cta {
    color: var(--accent-pink);
    background: rgba(244, 114, 182, 0.12);
    border: 1px solid rgba(244, 114, 182, 0.35);
}
.site-nav a.nav-upgrade-cta:hover {
    color: #fff;
    background: rgba(244, 114, 182, 0.22);
}

.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
}

.hamburger span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all var(--transition);
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* ==========================================================================
   Cards
   ========================================================================== */

.margn-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: all var(--transition);
}

.margn-card:hover {
    border-color: var(--accent-purple);
    box-shadow: 0 0 20px rgba(159, 93, 230, 0.08);
}

.margn-card h3 {
    /* v1.28.5: matches the global 2rem h3 \u2014 card titles now read as
     * proper section headers instead of footnotes. */
    margin-bottom: 0.75rem;
    font-size: 2rem;
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.15;
}

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

.stat-card .stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.stat-card .stat-value {
    font-family: 'Fraunces', 'Playfair Display', Georgia, serif;
    /* Scaled down + responsive (v1.23.0) — 12 cards in a 4-column grid
     * squeezes each card narrower; long currency values ($113,425.58)
     * were wrapping. clamp() keeps the display type as large as it can be
     * without breaking onto two lines. */
    font-size: clamp(1.5rem, 2.2vw, 1.85rem);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    /* Ellipsize if the number still overflows (defensive). */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Editorial display type on every logged-in page (v1.22.0). Fraunces on
 * h1/h2 across account, upload, pricing, support, terms, privacy — keeps
 * the same display voice the homepage + dashboard use. Inter still handles
 * body copy, form UI, and navigation. */
body.page-account .site-content h1,
body.page-account .site-content h2,
body.page-upload  .site-content h1,
body.page-upload  .site-content h2,
body.page-pricing .site-content h1,
body.page-pricing .site-content h2,
body.page-support .site-content h1,
body.page-support .site-content h2,
body.page-terms   .site-content h1,
body.page-terms   .site-content h2,
body.page-privacy .site-content h1,
body.page-privacy .site-content h2,
body[class*="parent-pageid"] .site-content h1,
body[class*="parent-pageid"] .site-content h2 {
    font-family: 'Fraunces', 'Playfair Display', Georgia, serif;
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.15;
}

.stat-card .stat-change {
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.stat-card .stat-change.positive {
    color: var(--accent-teal);
}

.stat-card .stat-change.negative {
    color: var(--accent-rose);
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    position: relative;
}

.chart-card h3 {
    margin-bottom: 0.75rem;
    font-size: 2rem;
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.15;
}

.chart-card canvas {
    width: 100% !important;
    max-height: 350px;
}

/* ==========================================================================
   Grid Utilities
   ========================================================================== */

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

/* ==========================================================================
   Hero Stats
   ========================================================================== */

.hero-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

/* Fixed 4-column grid (v1.23.0) — enforces a clean 3×4 layout with 12 stat
 * cards. Steps down to 3 / 2 / 1 column on narrower screens so the grid
 * stays readable without any single card getting absurdly tiny. */
.hero-stats.hero-stats--grid4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
@media (max-width: 1100px) {
    .hero-stats.hero-stats--grid4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .hero-stats.hero-stats--grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 440px) {
    .hero-stats.hero-stats--grid4 { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Tab Navigation
   ========================================================================== */

.tab-nav {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.tab-nav::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    padding: 0.75rem 1.25rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-family);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    /* Works for both <button> (legacy) and <a> (v1.22.0 section-page nav). */
    text-decoration: none;
    display: inline-block;
}

.tab-btn:hover {
    color: var(--text-secondary);
}

.tab-btn.active,
.tab-btn[aria-current="page"] {
    color: var(--accent-purple);
    border-bottom-color: var(--accent-purple);
}

/* Legacy: pre-v1.22.0 monolith used .tab-panel to hide inactive tab content.
 * Kept for any older cached JS that still injects these divs — new
 * section pages don't wrap content in a .tab-panel. */
.tab-panel {
    display: none;
}
.tab-panel.active {
    display: block;
}

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

/* ==========================================================================
   Data Tables
   ========================================================================== */

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table thead th {
    text-align: left;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(61, 45, 84, 0.3);
    color: var(--text-secondary);
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: rgba(159, 93, 230, 0.04);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
}

/* ==========================================================================
   Fun Fact Cards
   ========================================================================== */

.fun-fact {
    background: linear-gradient(135deg, var(--bg-card), var(--bg-card-alt));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.fun-fact .fun-fact-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.fun-fact .fun-fact-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.fun-fact .fun-fact-text strong {
    color: var(--text-primary);
}

/* ==========================================================================
   Modal
   ========================================================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

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

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 600px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.margn-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.margn-btn:hover {
    border-color: var(--accent-purple);
    color: var(--text-primary);
}

.margn-btn-primary {
    background: linear-gradient(135deg, var(--accent-purple), #7c3aed);
    border: none;
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}

.margn-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(159, 93, 230, 0.4);
    color: #fff;
}

.margn-btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}

.margn-btn-secondary:hover {
    border-color: var(--accent-purple);
    color: var(--text-primary);
}

/* ==========================================================================
   Forms
   ========================================================================== */

.margn-form label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Checkbox labels (ToS consent, opt-ins) are legal prose — keep them in
 * sentence case and normal weight so the paragraph reads naturally. The
 * uppercase + 600 weight above was making the whole consent block shouty. */
.margn-form label:has(input[type="checkbox"]),
.margn-form label:has(input[type="radio"]) {
    text-transform: none;
    letter-spacing: normal;
    font-weight: normal;
}

.margn-form input[type="text"],
.margn-form input[type="email"],
.margn-form input[type="password"],
.margn-form input[type="number"],
.margn-form input[type="url"],
.margn-form input[type="search"],
.margn-form select,
.margn-form textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.875rem;
    transition: border-color var(--transition);
    outline: none;
}

.margn-form input:focus,
.margn-form select:focus,
.margn-form textarea:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(159, 93, 230, 0.15);
}

.margn-form input::placeholder,
.margn-form textarea::placeholder {
    color: var(--text-muted);
}

.margn-form .form-group {
    margin-bottom: 1.25rem;
}

.margn-form textarea {
    resize: vertical;
    min-height: 100px;
}

/* ==========================================================================
   Alerts / Error Messages
   ========================================================================== */

.margn-alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.margn-alert-error {
    background: rgba(251, 113, 133, 0.1);
    border: 1px solid rgba(251, 113, 133, 0.3);
    color: var(--accent-rose);
}

.margn-alert-success {
    background: rgba(6, 214, 160, 0.1);
    border: 1px solid rgba(6, 214, 160, 0.3);
    color: var(--accent-teal);
}

.margn-alert-warning {
    background: rgba(255, 209, 102, 0.1);
    border: 1px solid rgba(255, 209, 102, 0.3);
    color: var(--accent-yellow);
}

.margn-alert-info {
    background: rgba(96, 165, 250, 0.1);
    border: 1px solid rgba(96, 165, 250, 0.3);
    color: var(--accent-blue);
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    background: var(--bg-card);
    border: 1px solid var(--accent-purple);
    color: var(--text-primary);
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    z-index: 3000;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.3s ease;
    white-space: nowrap;
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ==========================================================================
   Download Toast
   ========================================================================== */

.download-toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg-card);
    border: 1px solid var(--accent-teal);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    z-index: 3000;
    box-shadow: var(--shadow-lg);
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.download-toast.show {
    transform: translateX(0);
    opacity: 1;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 2rem 0;
    margin-top: 3rem;
}

.site-footer .container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.footer-brand {
    font-weight: 800;
    font-size: 1rem;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-teal));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
}

.footer-links a {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    transition: color var(--transition);
}

.footer-links a:hover {
    color: var(--text-secondary);
}

.footer-copy {
    font-size: 0.75rem;
    color: var(--text-muted);
    width: 100%;
    text-align: center;
    margin-top: 1rem;
}

/* ==========================================================================
   Upload Dropzone
   ========================================================================== */

.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: rgba(26, 26, 46, 0.5);
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--accent-purple);
    background: rgba(159, 93, 230, 0.05);
}

.dropzone .dropzone-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.dropzone .dropzone-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.dropzone .dropzone-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ==========================================================================
   Pricing Cards
   ========================================================================== */

.pricing-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.pricing-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    transition: all var(--transition);
}

.pricing-card.featured {
    border-color: var(--accent-purple);
    box-shadow: 0 0 30px rgba(159, 93, 230, 0.15), 0 0 60px rgba(159, 93, 230, 0.05);
    transform: scale(1.03);
    position: relative;
}

.pricing-card .pricing-tier {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.pricing-card .pricing-price {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.pricing-card .pricing-price span {
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-muted);
}

.pricing-card .pricing-features {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0;
    text-align: left;
}

.pricing-card .pricing-features li {
    padding: 0.5rem 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pricing-card .pricing-features li::before {
    content: "\2713";
    color: var(--accent-teal);
    font-weight: 700;
    flex-shrink: 0;
}

/* ==========================================================================
   Account Page
   ========================================================================== */

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

.billing-card h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-weight: 600;
}

.billing-info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(61, 45, 84, 0.3);
    font-size: 0.875rem;
}

.billing-info-row:last-child {
    border-bottom: none;
}

.billing-info-row .label {
    color: var(--text-muted);
}

.billing-info-row .value {
    color: var(--text-primary);
    font-weight: 600;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.invoice-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.invoice-table td {
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(61, 45, 84, 0.3);
}

.invoice-table .status-paid {
    color: var(--accent-teal);
    font-weight: 600;
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-state .empty-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    opacity: 0.4;
}

.empty-state h3 {
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.empty-state p {
    color: var(--text-muted);
    max-width: 400px;
    margin: 0 auto 1.5rem;
}

/* ==========================================================================
   Pro Badge
   ========================================================================== */

.pro-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    background: linear-gradient(135deg, var(--accent-purple), #7c3aed);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 999px;
    vertical-align: middle;
}

/* ==========================================================================
   Map Container
   ========================================================================== */

.map-container {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    overflow: hidden;
}

.map-container svg {
    width: 100%;
    height: auto;
    display: block;
}

.map-container svg path {
    stroke: var(--border);
    stroke-width: 0.5;
    transition: all var(--transition);
    cursor: pointer;
}

.map-container svg path:hover {
    stroke: var(--accent-purple);
    stroke-width: 1;
}

.map-tooltip {
    position: absolute;
    background: var(--bg-card-alt);
    border: 1px solid var(--accent-purple);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.875rem;
    font-size: 0.8rem;
    color: var(--text-primary);
    pointer-events: none;
    z-index: 100;
    white-space: nowrap;
    box-shadow: var(--shadow);
    display: none;
}

.map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.map-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.map-legend .legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.territory-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.75rem;
    background: rgba(159, 93, 230, 0.1);
    border: 1px solid rgba(159, 93, 230, 0.2);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-lavender);
}

/* ==========================================================================
   Word Cloud
   ========================================================================== */

.word-cloud-wrapper {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem;
    min-height: 200px;
}

.word-cloud-wrapper .word {
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    transition: all var(--transition);
    cursor: default;
}

.word-cloud-wrapper .word:hover {
    transform: scale(1.1);
}

/* ==========================================================================
   Chart Action Buttons
   ========================================================================== */

.chart-actions {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.375rem;
}

.chart-actions button {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.8rem;
}

.chart-actions button:hover {
    color: var(--text-primary);
    border-color: var(--accent-purple);
    background: rgba(159, 93, 230, 0.1);
}

/* ==========================================================================
   Margin Bar
   ========================================================================== */

.margin-bar {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.margin-bar .bar {
    width: 60px;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
}

.margin-bar .bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* ==========================================================================
   Qty Badge
   ========================================================================== */

.qty-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.15rem 0.5rem;
    background: rgba(159, 93, 230, 0.15);
    color: var(--accent-lavender);
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 999px;
    min-width: 24px;
}

/* ==========================================================================
   Counter Animation
   ========================================================================== */

.counter {
    display: inline-block;
}

.counter.counting {
    transition: none;
}

/* ==========================================================================
   Scrollbar Styling
   ========================================================================== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-purple);
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--bg-primary);
}

/* ==========================================================================
   Responsive — 768px
   ========================================================================== */

@media (max-width: 768px) {
    :root {
        --nav-height: 56px;
    }

    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }

    .hamburger {
        display: flex;
    }

    .site-nav {
        position: fixed;
        top: var(--nav-height);
        left: 0;
        right: 0;
        background: rgba(15, 15, 26, 0.98);
        backdrop-filter: blur(12px);
        flex-direction: column;
        padding: 1rem;
        border-bottom: 1px solid var(--border);
        transform: translateY(-100%);
        opacity: 0;
        pointer-events: none;
        transition: all 0.3s ease;
    }

    .site-nav.open {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .site-nav a {
        padding: 0.75rem 1rem;
        width: 100%;
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .hero-stats {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .pricing-card.featured {
        transform: none;
    }

    .site-footer .container {
        flex-direction: column;
        text-align: center;
    }

    .footer-links {
        justify-content: center;
    }

    .container {
        padding: 0 1rem;
    }

    .margn-card {
        padding: 1.25rem;
    }

    .modal-content {
        padding: 1.5rem;
    }
}

/* ==========================================================================
   Responsive — 480px
   ========================================================================== */

@media (max-width: 480px) {
    h1 { font-size: 1.25rem; }

    .hero-stats {
        grid-template-columns: 1fr;
    }

    .stat-card .stat-value {
        font-size: 1.4rem;
    }

    .tab-btn {
        padding: 0.625rem 0.875rem;
        font-size: 0.8rem;
    }

    .dropzone {
        padding: 2rem 1rem;
    }

    .margn-btn-primary {
        width: 100%;
    }
}

/* ==========================================================================
   Print Media
   ========================================================================== */

@media print {
    *,
    *::before,
    *::after {
        background: #fff !important;
        color: #000 !important;
        box-shadow: none !important;
        text-shadow: none !important;
        border-color: #ccc !important;
    }

    body {
        font-size: 12pt;
        line-height: 1.4;
    }

    .site-header,
    .site-footer,
    .hamburger,
    .tab-nav,
    .margn-btn,
    .margn-btn-primary,
    .margn-btn-secondary,
    .chart-actions,
    .toast,
    .download-toast,
    .modal-overlay {
        display: none !important;
    }

    .site-content {
        padding-top: 0;
    }

    .container {
        max-width: 100%;
        padding: 0;
    }

    .margn-card,
    .stat-card,
    .chart-card {
        break-inside: avoid;
        border: 1px solid #ccc;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
    }
}

/* ==========================================================================
   Category Theme Overrides — applied sitewide via body[data-theme="..."]
   Set server-side from the user's detected primary category (margn_set_body_theme
   in functions.php). Same palette as the homepage preview pills, so the
   dashboard/account/upload pages pick up the user's niche automatically.
   ========================================================================== */

body[data-theme="mens-fashion"] {
    --accent-purple: #3b4cca;
    --accent-pink:   #64748b;
    --accent-teal:   #06b6d4;
    --accent-yellow: #d97706;
}
body[data-theme="sneakers-streetwear"] {
    --accent-purple: #ea580c;
    --accent-pink:   #f97316;
    --accent-teal:   #84cc16;
    --accent-yellow: #fde047;
}
body[data-theme="luxury-designer"] {
    --accent-purple: #92400e;
    --accent-pink:   #d97706;
    --accent-teal:   #a8a29e;
    --accent-yellow: #fbbf24;
}
body[data-theme="beauty"] {
    --accent-purple: #ec4899;
    --accent-pink:   #fb7185;
    --accent-teal:   #fda4af;
    --accent-yellow: #fde68a;
}
body[data-theme="sports-cards"] {
    --accent-purple: #1d4ed8;
    --accent-pink:   #dc2626;
    --accent-teal:   #f1f5f9;
    --accent-yellow: #2563eb;
}
body[data-theme="trading-cards"] {
    --accent-purple: #1f2937;
    --accent-pink:   #eab308;
    --accent-teal:   #0284c7;
    --accent-yellow: #fde047;
}
body[data-theme="funko-collectibles"] {
    --accent-purple: #a855f7;
    --accent-pink:   #ec4899;
    --accent-teal:   #22d3ee;
    --accent-yellow: #facc15;
}
body[data-theme="comics"] {
    --accent-purple: #dc2626;
    --accent-pink:   #fbbf24;
    --accent-teal:   #3b82f6;
    --accent-yellow: #fde047;
}
body[data-theme="toys-hobbies"] {
    --accent-purple: #8b5cf6;
    --accent-pink:   #f97316;
    --accent-teal:   #10b981;
    --accent-yellow: #fde047;
}
body[data-theme="coins-currency"] {
    --accent-purple: #a16207;
    --accent-pink:   #ca8a04;
    --accent-teal:   #65a30d;
    --accent-yellow: #fbbf24;
}
body[data-theme="vintage"] {
    --accent-purple: #9a3412;
    --accent-pink:   #c2410c;
    --accent-teal:   #a16207;
    --accent-yellow: #fef3c7;
}

/* Smooth-swap transition when theme flips (e.g. admin override preview). */
body, .blob-bg .blob {
    transition: background-color 0.4s ease;
}
@media (prefers-reduced-motion: reduce) {
    body, .blob-bg .blob { transition: none; }
}
