/* ============================================================
   FreshLink Market — Design System
   Bold marketplace aesthetic (Instacart/DoorDash inspired)
   ============================================================ */

:root {
    /* Brand */
    --brand-50:  #ecfdf3;
    --brand-100: #d1fadf;
    --brand-200: #a6f4c5;
    --brand-300: #6ce9a6;
    --brand-400: #32d583;
    --brand-500: #12b76a;
    --brand-600: #039855;
    --brand-700: #027a48;
    --brand-800: #05603a;
    --brand-900: #054f31;

    /* Accent (warm) */
    --accent-500: #f04438;
    --accent-600: #d92d20;
    --warm-500:   #f79009;
    --warm-600:   #dc6803;

    /* Neutrals (light) */
    --bg:          #f8fafb;
    --surface:     #ffffff;
    --surface-2:   #f1f4f6;
    --ink:         #0f1c14;
    --ink-2:       #1f2d24;
    --muted:       #5b6b62;
    --muted-2:     #8a9991;
    --line:        #e3e8e5;
    --line-strong: #cdd6d0;
    --overlay:     rgba(15, 28, 20, 0.55);

    /* Semantic */
    --primary:        var(--brand-600);
    --primary-hover:  var(--brand-700);
    --primary-soft:   var(--brand-50);
    --danger:         var(--accent-600);
    --danger-soft:    #fef3f2;
    --warn:           var(--warm-600);
    --warn-soft:      #fffaeb;
    --success:        var(--brand-600);
    --success-soft:   var(--brand-50);
    --info:           #1570ef;
    --info-soft:      #eff8ff;

    /* Spacing scale (4px base) */
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 20px;
    --s-6: 24px;
    --s-7: 32px;
    --s-8: 40px;
    --s-9: 56px;
    --s-10: 72px;

    /* Radius */
    --r-1: 6px;
    --r-2: 10px;
    --r-3: 14px;
    --r-4: 20px;
    --r-full: 999px;

    /* Type */
    --font-sans: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    --font-display: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

    --fs-12: 12px;
    --fs-13: 13px;
    --fs-14: 14px;
    --fs-15: 15px;
    --fs-16: 16px;
    --fs-18: 18px;
    --fs-20: 20px;
    --fs-24: 24px;
    --fs-30: 30px;
    --fs-36: 36px;
    --fs-44: 44px;
    --fs-56: 56px;

    /* Elevation */
    --shadow-1: 0 1px 2px rgba(15, 28, 20, 0.05), 0 1px 3px rgba(15, 28, 20, 0.06);
    --shadow-2: 0 4px 8px -2px rgba(15, 28, 20, 0.08), 0 2px 4px -2px rgba(15, 28, 20, 0.05);
    --shadow-3: 0 12px 24px -8px rgba(15, 28, 20, 0.12), 0 4px 8px -4px rgba(15, 28, 20, 0.06);
    --shadow-4: 0 24px 48px -12px rgba(15, 28, 20, 0.18);
    --shadow-pop: 0 0 0 4px var(--brand-100);

    /* Motion */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --fast: 120ms;
    --med: 200ms;
    --slow: 320ms;

    /* Layout */
    --container: 1240px;
    --header-h: 64px;
    --rail-w: 280px;
}

html[data-theme="dark"] {
    --bg:          #0c1310;
    --surface:     #131c17;
    --surface-2:   #1b2620;
    --ink:         #ecf3ee;
    --ink-2:       #c8d2cc;
    --muted:       #95a39b;
    --muted-2:     #6e7c74;
    --line:        #25322b;
    --line-strong: #344137;
    --overlay:     rgba(0, 0, 0, 0.65);

    --primary:       var(--brand-400);
    --primary-hover: var(--brand-300);
    --primary-soft:  #0d2d1d;
    --success-soft:  #0d2d1d;
    --danger-soft:   #2c1311;
    --warn-soft:     #2a1d05;
    --info-soft:     #0a1f33;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 4px 8px -2px rgba(0, 0, 0, 0.5);
    --shadow-3: 0 12px 24px -8px rgba(0, 0, 0, 0.55);
    --shadow-4: 0 24px 48px -12px rgba(0, 0, 0, 0.6);
}

@media (prefers-color-scheme: dark) {
    html:not([data-theme]) {
        color-scheme: dark;
        --bg:          #0c1310;
        --surface:     #131c17;
        --surface-2:   #1b2620;
        --ink:         #ecf3ee;
        --ink-2:       #c8d2cc;
        --muted:       #95a39b;
        --muted-2:     #6e7c74;
        --line:        #25322b;
        --line-strong: #344137;
        --primary:       var(--brand-400);
        --primary-hover: var(--brand-300);
        --primary-soft:  #0d2d1d;
        --success-soft:  #0d2d1d;
        --danger-soft:   #2c1311;
        --warn-soft:     #2a1d05;
        --info-soft:     #0a1f33;
    }
}

/* ============================================================
   Reset + base
   ============================================================ */

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

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: var(--fs-15);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--r-1);
}

h1, h2, h3, h4 { color: var(--ink); margin: 0 0 var(--s-3); letter-spacing: -0.02em; font-weight: 700; }
h1 { font-size: var(--fs-36); line-height: 1.1; letter-spacing: -0.03em; }
h2 { font-size: var(--fs-24); line-height: 1.2; }
h3 { font-size: var(--fs-18); line-height: 1.3; }
p  { margin: 0 0 var(--s-3); color: var(--ink-2); }

::selection { background: var(--brand-200); color: var(--brand-900); }

/* ============================================================
   Header
   ============================================================ */

.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(160%) blur(10px);
    -webkit-backdrop-filter: saturate(160%) blur(10px);
    border-bottom: 1px solid var(--line);
}

.site-header__inner {
    align-items: center;
    display: flex;
    gap: var(--s-4);
    height: var(--header-h);
    margin: 0 auto;
    max-width: var(--container);
    padding: 0 var(--s-6);
}

.brand {
    align-items: center;
    color: var(--ink);
    display: inline-flex;
    font-size: var(--fs-18);
    font-weight: 800;
    gap: var(--s-2);
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.brand__mark {
    align-items: center;
    background: var(--primary);
    border-radius: var(--r-2);
    color: #fff;
    display: inline-flex;
    height: 32px;
    justify-content: center;
    width: 32px;
}

.header-search {
    flex: 1;
    max-width: 520px;
    position: relative;
}

.header-search input {
    background: var(--surface-2);
    border: 1px solid transparent;
    height: 40px;
    padding-left: 40px;
}

.header-search input:focus {
    background: var(--surface);
    border-color: var(--primary);
}

.header-search__icon {
    color: var(--muted);
    left: var(--s-3);
    pointer-events: none;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

.nav {
    align-items: center;
    display: flex;
    gap: var(--s-2);
    margin-left: auto;
}

.nav__link {
    border-radius: var(--r-2);
    color: var(--ink-2);
    font-weight: 600;
    font-size: var(--fs-14);
    padding: var(--s-2) var(--s-3);
    transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}

.nav__link:hover { background: var(--surface-2); color: var(--ink); }

.icon-btn {
    align-items: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--r-full);
    color: var(--ink-2);
    cursor: pointer;
    display: inline-flex;
    height: 40px;
    justify-content: center;
    min-height: 40px;
    padding: 0;
    position: relative;
    transition: background var(--fast) var(--ease);
    width: 40px;
}

.icon-btn:hover { background: var(--surface-2); }

.icon-btn__badge {
    align-items: center;
    background: var(--accent-600);
    border: 2px solid var(--surface);
    border-radius: var(--r-full);
    color: #fff;
    display: inline-flex;
    font-size: 10px;
    font-weight: 800;
    height: 18px;
    justify-content: center;
    line-height: 1;
    min-width: 18px;
    padding: 0 4px;
    position: absolute;
    right: -2px;
    top: -2px;
}

.user-chip {
    align-items: center;
    background: var(--surface-2);
    border-radius: var(--r-full);
    color: var(--ink);
    display: inline-flex;
    font-size: var(--fs-13);
    font-weight: 700;
    gap: var(--s-2);
    height: 36px;
    padding: 0 var(--s-3) 0 var(--s-1);
}

.user-chip__avatar {
    align-items: center;
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
    border-radius: var(--r-full);
    color: #fff;
    display: inline-flex;
    font-size: var(--fs-12);
    font-weight: 800;
    height: 28px;
    justify-content: center;
    width: 28px;
}

.nav-form { margin: 0; display: inline-flex; }

.nav-form .btn-ghost { height: 36px; min-height: 36px; padding: 0 var(--s-3); font-size: var(--fs-13); }

.menu-toggle { display: none; }

@media (max-width: 880px) {
    .site-header__inner { gap: var(--s-2); padding: 0 var(--s-4); }
    .header-search { display: none; }
    .nav__link:not(.always) { display: none; }
    .menu-toggle { display: inline-flex; }
}

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

.page {
    margin: 0 auto;
    max-width: var(--container);
    padding: var(--s-7) var(--s-6);
}

.page--narrow { max-width: 880px; }
.page--wide   { max-width: 1440px; }

@media (max-width: 720px) {
    .page { padding: var(--s-5) var(--s-4); }
}

.stack > * + * { margin-top: var(--s-4); }
.stack-lg > * + * { margin-top: var(--s-6); }

.row {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-3);
}

.row--between { justify-content: space-between; }

.grid-2, .grid-3, .grid-4 {
    display: grid;
    gap: var(--s-5);
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 1000px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ============================================================
   Toasts (flash messages)
   ============================================================ */

.toast-stack {
    bottom: var(--s-5);
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    left: 50%;
    max-width: 480px;
    pointer-events: none;
    position: fixed;
    transform: translateX(-50%);
    width: calc(100% - var(--s-7));
    z-index: 70;
}

.toast {
    align-items: flex-start;
    animation: toast-in 280ms var(--ease) both;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid var(--muted-2);
    border-radius: var(--r-2);
    box-shadow: var(--shadow-3);
    display: flex;
    font-size: var(--fs-14);
    font-weight: 600;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    pointer-events: auto;
}

.toast.success { border-left-color: var(--success); background: var(--success-soft); color: var(--brand-900); }
.toast.error   { border-left-color: var(--danger);  background: var(--danger-soft);  color: #7a271a; }
.toast.warning { border-left-color: var(--warn);    background: var(--warn-soft);   color: #7a2e0e; }
.toast.info    { border-left-color: var(--info);    background: var(--info-soft);   color: #194185; }

html[data-theme="dark"] .toast.success { color: var(--brand-200); }
html[data-theme="dark"] .toast.error   { color: #fda29b; }
html[data-theme="dark"] .toast.warning { color: #fec84b; }
html[data-theme="dark"] .toast.info    { color: #84caff; }

@keyframes toast-in {
    from { transform: translateY(16px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

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

.btn,
button.btn {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-2);
    color: var(--ink);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-size: var(--fs-14);
    font-weight: 700;
    gap: var(--s-2);
    justify-content: center;
    line-height: 1;
    min-height: 44px;
    padding: 0 var(--s-5);
    text-decoration: none;
    transition: transform var(--fast) var(--ease),
                background var(--fast) var(--ease),
                border-color var(--fast) var(--ease),
                box-shadow var(--fast) var(--ease);
    white-space: nowrap;
}

.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { cursor: not-allowed; opacity: 0.55; transform: none; }

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 1px 2px rgba(5, 80, 50, 0.2);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary:focus-visible { box-shadow: var(--shadow-pop); }

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: var(--accent-600); }

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--ink-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn-sm  { min-height: 36px; padding: 0 var(--s-3); font-size: var(--fs-13); }
.btn-lg  { min-height: 52px; padding: 0 var(--s-6); font-size: var(--fs-16); }
.btn-block { display: flex; width: 100%; }

/* legacy compatibility (older views may still use these) */
.button { /* alias */
    align-items: center; background: var(--surface); border: 1px solid var(--line-strong);
    border-radius: var(--r-2); color: var(--ink); cursor: pointer; display: inline-flex;
    font: inherit; font-weight: 700; justify-content: center; min-height: 44px;
    padding: 0 var(--s-5); text-decoration: none;
}
.button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.button.block { display: flex; width: 100%; }

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

input, select, textarea {
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-2);
    color: var(--ink);
    font: inherit;
    font-size: var(--fs-15);
    min-height: 44px;
    padding: 10px 14px;
    transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
    width: 100%;
}

input::placeholder, textarea::placeholder { color: var(--muted-2); }

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
    outline: none;
}

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

input[type="file"] {
    background: var(--surface-2);
    cursor: pointer;
    padding: var(--s-2);
}

input[type="checkbox"], input[type="radio"] {
    accent-color: var(--primary);
    height: 18px;
    min-height: 18px;
    width: 18px;
}

label.field {
    color: var(--ink);
    display: grid;
    font-size: var(--fs-13);
    font-weight: 700;
    gap: var(--s-2);
}

label.field .hint {
    color: var(--muted);
    font-size: var(--fs-12);
    font-weight: 500;
}

.field-row { display: grid; gap: var(--s-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 600px) { .field-row { grid-template-columns: 1fr; } }

.check-row { display: flex; flex-wrap: wrap; gap: var(--s-4); }
.check-row label {
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-full);
    cursor: pointer;
    display: inline-flex;
    font-size: var(--fs-13);
    font-weight: 700;
    gap: var(--s-2);
    padding: var(--s-2) var(--s-3);
}
.check-row label:has(input:checked) { background: var(--primary-soft); border-color: var(--primary); color: var(--brand-900); }
html[data-theme="dark"] .check-row label:has(input:checked) { color: var(--brand-200); }

.hp-field {
    height: 1px; left: -9999px; opacity: 0; position: absolute; width: 1px;
}

.challenge-number {
    background: var(--primary-soft);
    border: 1px dashed var(--primary);
    border-radius: var(--r-2);
    color: var(--brand-800);
    display: inline-block;
    font-family: var(--font-mono);
    font-size: var(--fs-20);
    font-weight: 800;
    letter-spacing: 0.04em;
    margin-bottom: var(--s-2);
    padding: var(--s-2) var(--s-4);
}

html[data-theme="dark"] .challenge-number { color: var(--brand-200); }

/* Password strength meter */
.pw-meter {
    background: var(--surface-2);
    border-radius: var(--r-full);
    height: 6px;
    overflow: hidden;
}
.pw-meter__bar {
    background: var(--accent-600);
    height: 100%;
    transition: width var(--med) var(--ease), background var(--med) var(--ease);
    width: 0;
}
.pw-meter[data-score="1"] .pw-meter__bar { width: 20%; background: var(--accent-600); }
.pw-meter[data-score="2"] .pw-meter__bar { width: 40%; background: var(--warm-500); }
.pw-meter[data-score="3"] .pw-meter__bar { width: 60%; background: var(--warm-500); }
.pw-meter[data-score="4"] .pw-meter__bar { width: 80%; background: var(--brand-400); }
.pw-meter[data-score="5"] .pw-meter__bar { width: 100%; background: var(--brand-600); }

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

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-3);
    box-shadow: var(--shadow-1);
    overflow: hidden;
}

.card--padded { padding: var(--s-6); }
.card--flush  { padding: 0; }

.section-title {
    align-items: baseline;
    display: flex;
    gap: var(--s-3);
    justify-content: space-between;
    margin-bottom: var(--s-4);
}
.section-title h2 { margin: 0; }
.section-title .meta { color: var(--muted); font-size: var(--fs-13); font-weight: 600; }

.eyebrow {
    color: var(--primary);
    font-size: var(--fs-12);
    font-weight: 800;
    letter-spacing: 0.08em;
    margin: 0 0 var(--s-2);
    text-transform: uppercase;
}

/* ============================================================
   Hero (marketplace)
   ============================================================ */

.hero {
    background: linear-gradient(135deg, var(--brand-50) 0%, #fffbf0 100%);
    border: 1px solid var(--line);
    border-radius: var(--r-4);
    overflow: hidden;
    padding: var(--s-9) var(--s-7);
    position: relative;
}

html[data-theme="dark"] .hero {
    background: linear-gradient(135deg, #0d2d1d 0%, #2a1d05 100%);
}

.hero::after {
    background: radial-gradient(circle at 100% 0%, rgba(18, 183, 106, 0.18), transparent 60%);
    content: "";
    inset: 0;
    pointer-events: none;
    position: absolute;
}

.hero__inner { max-width: 720px; position: relative; }
.hero h1 { font-size: clamp(var(--fs-30), 4.5vw, var(--fs-56)); margin-bottom: var(--s-3); }
.hero p  { color: var(--ink-2); font-size: var(--fs-18); margin-bottom: var(--s-5); max-width: 560px; }

.hero__cta { display: flex; flex-wrap: wrap; gap: var(--s-3); }

/* Category chip rail */
.chip-rail {
    display: flex;
    flex-wrap: nowrap;
    gap: var(--s-2);
    margin: var(--s-6) 0;
    overflow-x: auto;
    padding-bottom: var(--s-2);
    scrollbar-width: none;
}
.chip-rail::-webkit-scrollbar { display: none; }

.chip {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-full);
    color: var(--ink-2);
    cursor: pointer;
    display: inline-flex;
    font-size: var(--fs-13);
    font-weight: 700;
    gap: var(--s-2);
    padding: var(--s-2) var(--s-4);
    transition: all var(--fast) var(--ease);
    white-space: nowrap;
}
.chip:hover { border-color: var(--primary); color: var(--ink); }
.chip.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ============================================================
   Listing grid + cards
   ============================================================ */

.market-shell {
    display: grid;
    gap: var(--s-6);
    grid-template-columns: var(--rail-w) 1fr;
}

@media (max-width: 1000px) { .market-shell { grid-template-columns: 1fr; } }

.filter-rail {
    align-self: start;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-3);
    padding: var(--s-5);
    position: sticky;
    top: calc(var(--header-h) + var(--s-4));
}

.filter-rail h3 { font-size: var(--fs-14); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: var(--s-3); }
.filter-rail .field + .field { margin-top: var(--s-4); }
.filter-rail__actions { display: flex; gap: var(--s-2); margin-top: var(--s-5); }

@media (max-width: 1000px) { .filter-rail { position: static; } }

.listing-toolbar {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-3);
    justify-content: space-between;
    margin-bottom: var(--s-4);
}
.listing-toolbar h2 { margin: 0; font-size: var(--fs-20); }
.listing-toolbar .count { color: var(--muted); font-size: var(--fs-13); font-weight: 600; }

.listing-grid {
    display: grid;
    gap: var(--s-5);
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.listing-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    transition: transform var(--med) var(--ease), box-shadow var(--med) var(--ease), border-color var(--fast) var(--ease);
}

.listing-card:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-3);
    transform: translateY(-2px);
}

.listing-card__media {
    aspect-ratio: 4 / 3;
    background: var(--surface-2);
    overflow: hidden;
    position: relative;
}

.listing-card__media img {
    height: 100%;
    object-fit: cover;
    transition: transform var(--slow) var(--ease);
    width: 100%;
}

.listing-card:hover .listing-card__media img { transform: scale(1.04); }

.listing-card__badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-1);
    left: var(--s-3);
    position: absolute;
    top: var(--s-3);
}

.badge {
    align-items: center;
    background: var(--surface);
    border-radius: var(--r-full);
    color: var(--ink);
    display: inline-flex;
    font-size: 11px;
    font-weight: 800;
    gap: 4px;
    letter-spacing: 0.03em;
    padding: 4px 10px;
    text-transform: uppercase;
    box-shadow: var(--shadow-1);
}

.badge--organic { background: var(--brand-600); color: #fff; }
.badge--rush    { background: var(--accent-600); color: #fff; }
.badge--low     { background: var(--warm-500); color: #fff; }
.badge--new     { background: var(--info); color: #fff; }
.badge--soldout { background: var(--muted); color: #fff; }

.listing-card__body { display: flex; flex-direction: column; flex: 1; gap: var(--s-2); padding: var(--s-4) var(--s-5) var(--s-5); }

.listing-card__title { align-items: baseline; display: flex; gap: var(--s-3); justify-content: space-between; }
.listing-card__title h3 { font-size: var(--fs-16); margin: 0; }
.listing-card__price { color: var(--ink); font-size: var(--fs-16); font-weight: 800; white-space: nowrap; }
.listing-card__price small { color: var(--muted); font-size: var(--fs-12); font-weight: 600; }

.listing-card__meta { color: var(--muted); font-size: var(--fs-13); }

.listing-card__rating {
    align-items: center;
    color: var(--ink-2);
    display: inline-flex;
    font-size: var(--fs-13);
    font-weight: 700;
    gap: 4px;
}
.listing-card__rating .star { color: var(--warm-500); }

.listing-card__actions { display: flex; gap: var(--s-2); margin-top: auto; padding-top: var(--s-3); }
.listing-card__actions .btn { flex: 1; }

/* Skeleton */
.skeleton {
    background: linear-gradient(90deg, var(--surface-2) 0%, var(--line) 50%, var(--surface-2) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s linear infinite;
    border-radius: var(--r-2);
}
@keyframes shimmer {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}

/* ============================================================
   Detail page
   ============================================================ */

.detail {
    display: grid;
    gap: var(--s-7);
    grid-template-columns: 1.05fr 0.95fr;
}

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

.detail__media {
    aspect-ratio: 1 / 1;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-3);
    overflow: hidden;
}
.detail__media img { height: 100%; object-fit: cover; width: 100%; }

.detail__price {
    align-items: baseline;
    display: flex;
    gap: var(--s-3);
    margin: var(--s-4) 0;
}
.detail__price strong { color: var(--ink); font-size: var(--fs-36); font-weight: 800; letter-spacing: -0.02em; }
.detail__price span { color: var(--muted); font-size: var(--fs-14); }

.qty-stepper {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-full);
    display: inline-flex;
    overflow: hidden;
}
.qty-stepper button {
    background: transparent;
    border: 0;
    color: var(--ink);
    cursor: pointer;
    font-size: var(--fs-18);
    font-weight: 700;
    height: 40px;
    min-height: 40px;
    width: 40px;
}
.qty-stepper input {
    border: 0;
    background: transparent;
    height: 40px;
    min-height: 40px;
    text-align: center;
    width: 64px;
    padding: 0;
    font-weight: 700;
}
.qty-stepper input:focus { box-shadow: none; }

.tag-row { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-5); }
.tag {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-full);
    color: var(--ink-2);
    font-size: var(--fs-12);
    font-weight: 700;
    padding: 4px 10px;
}

.spec-grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.spec dt { color: var(--muted); font-size: var(--fs-12); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px; }
.spec dd { color: var(--ink); font-size: var(--fs-14); font-weight: 600; margin: 0; }

.sticky-cta {
    display: none;
}

@media (max-width: 720px) {
    .sticky-cta {
        align-items: center;
        background: var(--surface);
        border-top: 1px solid var(--line);
        bottom: 0;
        box-shadow: var(--shadow-3);
        display: flex;
        gap: var(--s-3);
        left: 0;
        padding: var(--s-3) var(--s-4) calc(var(--s-3) + env(safe-area-inset-bottom));
        position: fixed;
        right: 0;
        z-index: 30;
    }
    .sticky-cta .btn { flex: 1; }
    body.has-sticky-cta { padding-bottom: 92px; }
}

/* ============================================================
   Dashboards
   ============================================================ */

.dash {
    display: grid;
    gap: var(--s-6);
    grid-template-columns: 240px 1fr;
}

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

.dash-nav {
    align-self: start;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-3);
    padding: var(--s-3);
    position: sticky;
    top: calc(var(--header-h) + var(--s-4));
}

.dash-nav a {
    align-items: center;
    border-radius: var(--r-2);
    color: var(--ink-2);
    display: flex;
    font-size: var(--fs-14);
    font-weight: 600;
    gap: var(--s-2);
    padding: var(--s-3);
}
.dash-nav a:hover { background: var(--surface-2); color: var(--ink); }
.dash-nav a.is-active { background: var(--primary-soft); color: var(--primary); }
html[data-theme="dark"] .dash-nav a.is-active { color: var(--brand-200); }

@media (max-width: 1000px) { .dash-nav { position: static; display: flex; flex-wrap: wrap; gap: var(--s-1); } }

.metric-grid {
    display: grid;
    gap: var(--s-4);
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-bottom: var(--s-6);
}

.metric {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-3);
    padding: var(--s-5);
}
.metric .label { color: var(--muted); font-size: var(--fs-12); font-weight: 700; letter-spacing: 0.05em; margin-bottom: var(--s-2); text-transform: uppercase; }
.metric .value { color: var(--ink); font-size: var(--fs-30); font-weight: 800; letter-spacing: -0.02em; }
.metric .delta { color: var(--success); font-size: var(--fs-12); font-weight: 700; margin-top: var(--s-1); }
.metric .delta.down { color: var(--danger); }

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

.table-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-3);
    overflow: hidden;
}
.table-card__head {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    padding: var(--s-4) var(--s-5);
}
.table-card__head h2 { margin: 0; font-size: var(--fs-16); }
.table-scroll { overflow-x: auto; }

table {
    border-collapse: collapse;
    min-width: 720px;
    width: 100%;
}

th, td {
    border-bottom: 1px solid var(--line);
    font-size: var(--fs-14);
    padding: var(--s-3) var(--s-4);
    text-align: left;
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }

th {
    background: var(--surface-2);
    color: var(--muted);
    font-size: var(--fs-12);
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.pill {
    align-items: center;
    border-radius: var(--r-full);
    display: inline-flex;
    font-size: var(--fs-12);
    font-weight: 700;
    gap: 4px;
    padding: 4px 10px;
    text-transform: capitalize;
}
.pill::before { background: currentColor; border-radius: var(--r-full); content: ""; height: 6px; width: 6px; }

.pill-pending,   .pill-pending_verification, .pill-submitted, .pill-draft, .pill-open, .pill-not_started, .pill-unpaid { background: var(--surface-2); color: var(--muted); }
.pill-confirmed, .pill-active, .pill-verified, .pill-paid, .pill-completed, .pill-delivered, .pill-received, .pill-approved, .pill-signed { background: var(--success-soft); color: var(--success); }
.pill-ready, .pill-reviewing, .pill-authorized, .pill-assigned, .pill-in_transit, .pill-picked_up, .pill-sent { background: var(--info-soft); color: var(--info); }
.pill-paused, .pill-sold_out, .pill-rush_delivery, .pill-expired { background: var(--warn-soft); color: var(--warn); }
.pill-cancelled, .pill-rejected, .pill-suspended, .pill-failed, .pill-refunded { background: var(--danger-soft); color: var(--danger); }

.inline-form {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
}
.inline-form input, .inline-form select {
    min-height: 36px;
    padding: 6px 10px;
    width: auto;
}
.inline-form .btn { min-height: 36px; padding: 0 var(--s-3); font-size: var(--fs-13); }

.ops-cell { min-width: 380px; }
.ops-cell .inline-form + .inline-form { margin-top: var(--s-2); }

.small-link {
    color: var(--primary);
    font-size: var(--fs-13);
    font-weight: 700;
    text-decoration: none;
}
.small-link:hover { text-decoration: underline; }

/* ============================================================
   Empty / notice
   ============================================================ */

.notice {
    background: var(--warn-soft);
    border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
    border-radius: var(--r-2);
    color: var(--warn);
    font-size: var(--fs-14);
    padding: var(--s-3) var(--s-4);
}

.empty-state {
    background: var(--surface);
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-3);
    padding: var(--s-9) var(--s-5);
    text-align: center;
}
.empty-state h2 { margin-bottom: var(--s-2); }
.empty-state p { color: var(--muted); margin-bottom: var(--s-5); }

/* ============================================================
   Auth split
   ============================================================ */

.auth-split {
    display: grid;
    gap: var(--s-7);
    grid-template-columns: 1fr 1fr;
}

@media (max-width: 880px) { .auth-split { grid-template-columns: 1fr; } }

.auth-split__pitch {
    background: linear-gradient(135deg, var(--brand-700), var(--brand-900));
    border-radius: var(--r-4);
    color: #fff;
    padding: var(--s-9) var(--s-7);
}
.auth-split__pitch h1 { color: #fff; font-size: var(--fs-44); }
.auth-split__pitch p  { color: rgba(255,255,255,0.85); font-size: var(--fs-16); }

.auth-split__form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-4); padding: var(--s-7); }

/* ============================================================
   Confirmation page
   ============================================================ */

.success-mark {
    align-items: center;
    background: var(--brand-100);
    border-radius: var(--r-full);
    color: var(--brand-700);
    display: inline-flex;
    height: 72px;
    justify-content: center;
    margin-bottom: var(--s-4);
    width: 72px;
}
html[data-theme="dark"] .success-mark { background: #0d2d1d; color: var(--brand-300); }

.invoice-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-3);
    box-shadow: var(--shadow-2);
    overflow: hidden;
}
.invoice-card__head {
    background: linear-gradient(135deg, var(--brand-700), var(--brand-900));
    color: #fff;
    padding: var(--s-5) var(--s-6);
}
.invoice-card__head h2 { color: #fff; margin: 0; }
.invoice-card__body { padding: var(--s-5) var(--s-6); }

.summary-list { display: grid; gap: var(--s-3); }
.summary-list > div { display: flex; justify-content: space-between; gap: var(--s-3); }
.summary-list dt { color: var(--muted); font-size: var(--fs-13); font-weight: 600; }
.summary-list dd { color: var(--ink); font-size: var(--fs-14); font-weight: 700; margin: 0; text-align: right; }

/* ============================================================
   Cart drawer
   ============================================================ */

.drawer-backdrop {
    background: var(--overlay);
    inset: 0;
    opacity: 0;
    pointer-events: none;
    position: fixed;
    transition: opacity var(--med) var(--ease);
    z-index: 50;
}
.drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }

.drawer {
    background: var(--surface);
    bottom: 0;
    display: flex;
    flex-direction: column;
    max-width: 440px;
    position: fixed;
    right: 0;
    top: 0;
    transform: translateX(100%);
    transition: transform var(--med) var(--ease);
    width: 100%;
    z-index: 60;
}
.drawer.is-open { transform: translateX(0); }
.drawer__head { align-items: center; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; padding: var(--s-4) var(--s-5); }
.drawer__head h2 { margin: 0; }
.drawer__body { flex: 1; overflow-y: auto; padding: var(--s-5); }
.drawer__foot { border-top: 1px solid var(--line); padding: var(--s-4) var(--s-5); }

.cart-line { align-items: center; display: grid; gap: var(--s-3); grid-template-columns: 56px 1fr auto; padding: var(--s-3) 0; }
.cart-line + .cart-line { border-top: 1px solid var(--line); }
.cart-line__img { aspect-ratio: 1/1; background: var(--surface-2); border-radius: var(--r-2); overflow: hidden; }
.cart-line__img img { height: 100%; object-fit: cover; width: 100%; }
.cart-line__title { font-size: var(--fs-14); font-weight: 700; }
.cart-line__meta { color: var(--muted); font-size: var(--fs-12); }
.cart-line__price { font-weight: 800; }

/* ============================================================
   Utility
   ============================================================ */

.mt-0 { margin-top: 0 !important; }
.mt-3 { margin-top: var(--s-3); }
.mt-4 { margin-top: var(--s-4); }
.mt-5 { margin-top: var(--s-5); }
.mt-6 { margin-top: var(--s-6); }
.mt-7 { margin-top: var(--s-7); }
.mb-0 { margin-bottom: 0 !important; }
.text-muted { color: var(--muted); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: var(--fs-13); }
.text-lg { font-size: var(--fs-18); }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
