/* =========================================================
   Shoptify.co — Design System
   Plain CSS ไม่พึ่ง framework ภายนอก
   ========================================================= */

/* ---------- Design Tokens ---------- */
:root {
    /* Colors */
    --primary:        #6366f1;
    --primary-dark:   #4f46e5;
    --primary-light:  #e0e7ff;
    --success:        #10b981;
    --success-dark:   #059669;
    --success-light:  #d1fae5;
    --warning:        #f59e0b;
    --warning-light:  #fef3c7;
    --danger:         #ef4444;
    --danger-light:   #fee2e2;
    --info:           #3b82f6;
    --info-light:     #dbeafe;
    --purple:         #8b5cf6;
    --purple-light:   #ede9fe;
    --pink:           #ec4899;
    --pink-light:     #fce7f3;

    /* Neutrals */
    --bg:             #f1f5f9;
    --surface:        #ffffff;
    --border:         #e2e8f0;
    --text:           #1e293b;
    --text-muted:     #64748b;
    --text-light:     #94a3b8;

    /* Layout */
    --sidebar-w:      260px;
    --radius:         12px;
    --radius-sm:      8px;
    --shadow:         0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-lg:      0 10px 25px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.04);

    /* Typography */
    --font:           'Segoe UI', system-ui, -apple-system, 'Sarabun', 'Thonburi', sans-serif;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 15px;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: inherit; }
code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: .9em; }

/* ---------- Helpers ---------- */
.text-primary { color: var(--primary); }
.muted { color: var(--text-muted); }
.small { font-size: .85em; }
.mt { margin-top: 1.5rem; }
.mt-xs { margin-top: .5rem; }

/* =========================================================
   Auth (login page)
   ========================================================= */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    padding: 1.5rem;
}
.auth-wrapper { width: 100%; max-width: 400px; }
.auth-card {
    background: var(--surface);
    border-radius: 20px;
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-lg);
}
.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo-mark {
    display: inline-flex;
    width: 56px; height: 56px;
    background: var(--primary);
    color: #fff;
    border-radius: 16px;
    font-size: 1.8rem;
    font-weight: 700;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}
.auth-logo h1 { font-size: 1.5rem; margin-bottom: .25rem; }
.auth-logo p { color: var(--text-muted); font-size: .9rem; }
.auth-hint {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: .85rem;
}
.auth-hint code { font-size: .9em; }

/* =========================================================
   App Shell (sidebar + main)
   ========================================================= */
.app-shell { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 100;
    transition: transform .25s ease;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 1.25rem;
    font-weight: 700;
}
.brand-mark {
    display: inline-flex;
    width: 36px; height: 36px;
    background: var(--primary);
    color: #fff;
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem; }
.sidebar-nav ul { list-style: none; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .7rem .9rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 2px;
    transition: all .15s ease;
}
.sidebar-nav a:hover {
    background: var(--bg);
    color: var(--text);
    text-decoration: none;
}
.sidebar-nav a.is-active {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
}
.nav-icon { width: 22px; text-align: center; font-size: 1.05rem; }
.sidebar-footer { padding: .75rem; border-top: 1px solid var(--border); }
.nav-link-danger {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .7rem .9rem;
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-weight: 500;
}
.nav-link-danger:hover { background: var(--danger-light); text-decoration: none; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
}
.sidebar-overlay.show { display: block; }

/* ---------- Main ---------- */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .85rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-title { font-size: 1.15rem; font-weight: 600; flex: 1; }
.icon-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--text-muted);
    padding: .25rem .5rem;
    border-radius: 6px;
}
.icon-btn:hover { background: var(--bg); }
.sidebar-toggle { display: none; }
.topbar-user { display: flex; align-items: center; gap: .65rem; }
.user-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    overflow: hidden;
    flex-shrink: 0;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-weight: 600; font-size: .9rem; }
.user-level { font-size: .75rem; color: var(--text-muted); }

.content {
    flex: 1;
    padding: 1.5rem;
    max-width: 1100px;
    width: 100%;
}

/* =========================================================
   Components
   ========================================================= */

/* Alerts */
.alert {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .85rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: .92rem;
}
.alert-icon {
    display: inline-flex;
    width: 22px; height: 22px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: .8rem;
    flex-shrink: 0;
}
.alert-success { background: var(--success-light); color: var(--success-dark); }
.alert-success .alert-icon { background: var(--success); color: #fff; }
.alert-error { background: var(--danger-light); color: var(--danger); }
.alert-error .alert-icon { background: var(--danger); color: #fff; }
.alert-warning { background: var(--warning-light); color: #92400e; }
.alert-warning .alert-icon { background: var(--warning); color: #fff; }
.alert-info { background: var(--info-light); color: #1e40af; }
.alert-info .alert-icon { background: var(--info); color: #fff; }

/* Page head */
.page-head { margin-bottom: 1.5rem; }
.page-head h2 { font-size: 1.5rem; }

/* Card grid (stat cards) */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    color: var(--text);
    transition: transform .15s ease, box-shadow .15s ease;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    text-decoration: none;
}
.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.stat-value { font-size: 1.25rem; font-weight: 700; }
.stat-label { font-size: .85rem; color: var(--text-muted); }

/* color variants for stat icons */
.stat-primary .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-success .stat-icon { background: var(--success-light); color: var(--success); }
.stat-info .stat-icon    { background: var(--info-light); color: var(--info); }
.stat-warning .stat-icon { background: var(--warning-light); color: var(--warning); }
.stat-purple .stat-icon  { background: var(--purple-light); color: var(--purple); }
.stat-pink .stat-icon    { background: var(--pink-light); color: var(--pink); }

/* Section */
.section { margin-top: 2rem; }
.section-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--border);
}

/* Quick actions */
.quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}
.quick-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    text-align: center;
    color: var(--text);
    transition: all .15s ease;
}
.quick-card:hover {
    border-color: var(--primary);
    color: var(--primary);
    text-decoration: none;
    transform: translateY(-2px);
}
.quick-icon { font-size: 1.8rem; }

/* Info grid */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}
.info-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}
.info-label { font-size: .78rem; color: var(--text-muted); }
.info-value { font-weight: 600; }

/* Badges */
.badge {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-success { background: var(--success-light); color: var(--success-dark); }
.badge-info    { background: var(--info-light); color: #1e40af; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-muted   { background: #f1f5f9; color: var(--text-muted); }

/* Balance hero */
.balance-hero {
    border-radius: var(--radius);
    padding: 2rem;
    color: #fff;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}
.balance-success { background: linear-gradient(135deg, var(--success) 0%, var(--success-dark) 100%); }
.balance-info    { background: linear-gradient(135deg, var(--info) 0%, #1d4ed8 100%); }
.balance-label { opacity: .9; font-size: .9rem; margin-bottom: .25rem; }
.balance-amount { font-size: 2.25rem; font-weight: 700; line-height: 1.2; }
.balance-actions { margin-top: 1rem; display: flex; gap: .5rem; }
.btn-sm { padding: .35rem .85rem; font-size: .82rem; border-radius: var(--radius-sm); }
.btn-light { background: rgba(255,255,255,.25); color: #fff; border: 1px solid rgba(255,255,255,.4); }
.btn-light:hover { background: rgba(255,255,255,.35); text-decoration: none; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .65rem 1.25rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: .92rem;
    transition: all .15s ease;
    cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; text-decoration: none; color: #fff; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); text-decoration: none; }
.btn-block { width: 100%; }

/* Forms */
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    min-width: 0;
    overflow: hidden; /* prevent long URLs/words from breaking the layout */
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.form-group { margin-bottom: 1rem; display: flex; flex-direction: column; gap: .35rem; }
.form-group label { font-weight: 500; font-size: .88rem; }
.form-group input,
.form-group select,
.form-group textarea {
    padding: .65rem .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.form-group input:disabled { background: #f8fafc; color: var(--text-muted); }
.form-actions { display: flex; gap: .65rem; margin-top: .5rem; }
.import-preview-img {
    width: 140px;
    height: 140px;
    object-fit: cover;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin: .25rem 0 1rem;
    background: #f8fafc;
}
.columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Quick amount buttons */
.quick-amounts { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.quick-amounts button {
    flex: 1;
    min-width: 60px;
    padding: .5rem;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius-sm);
    font-weight: 500;
    color: var(--text-muted);
    transition: all .15s ease;
}
.quick-amounts button:hover { border-color: var(--primary); color: var(--primary); }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}
.empty-icon { font-size: 2.5rem; margin-bottom: .5rem; }

/* Input group */
.input-group { display: flex; gap: .5rem; }
.input-group input { flex: 1; padding: .65rem .85rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.ref-row { margin-bottom: 1rem; }
.ref-row > label { display: block; font-weight: 500; font-size: .88rem; margin-bottom: .35rem; }

/* Stats row (3 columns) */
.stats-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
}
.stat-num { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.stat-box-warning .stat-num { color: var(--warning); }
.stat-cap { font-size: .82rem; color: var(--text-muted); margin-top: .25rem; }

/* Level card */
.level-card {
    background: linear-gradient(135deg, var(--purple) 0%, var(--primary) 100%);
    color: #fff;
    border-radius: var(--radius);
    padding: 1.75rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
.level-badge {
    width: 80px; height: 80px;
    background: rgba(255,255,255,.2);
    border: 2px solid rgba(255,255,255,.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 700;
    flex-shrink: 0;
}
.level-info { flex: 1; }
.level-info h2 { margin-bottom: .35rem; }
.level-info .muted { color: rgba(255,255,255,.85); }
.progress {
    height: 10px;
    background: rgba(255,255,255,.25);
    border-radius: 999px;
    overflow: hidden;
    margin: .65rem 0 .35rem;
}
.progress-bar {
    height: 100%;
    background: #fff;
    border-radius: 999px;
    transition: width .4s ease;
}

/* Mission list */
.mission-list { display: flex; flex-direction: column; gap: .65rem; }
.mission-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .85rem 1rem;
}
.mission-icon { font-size: 1.5rem; width: 32px; text-align: center; }
.mission-body { flex: 1; }
.mission-title { font-weight: 500; }

/* Profile header */
.profile-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.profile-avatar {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 700;
    overflow: hidden;
    flex-shrink: 0;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Placeholder page */
.placeholder-page {
    text-align: center;
    padding: 3rem 1.5rem;
}
.placeholder-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: .8;
}
.placeholder-title { font-size: 1.75rem; margin-bottom: .5rem; }
.placeholder-subtitle { font-size: 1.1rem; margin-bottom: .5rem; }
.placeholder-desc { max-width: 480px; margin: 0 auto 1.5rem; }
.placeholder-badge { margin-bottom: 1.5rem; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .main { margin-left: 0; }
    .content { padding: 1rem; }
    .columns, .form-row { grid-template-columns: 1fr; }
    .stats-3 { grid-template-columns: 1fr; }
    .balance-amount { font-size: 1.75rem; }
    .level-card { flex-direction: column; text-align: center; }
    .user-meta { display: none; }
    .table-wrap { overflow-x: auto; }
    .table { min-width: 480px; }
    .filter-bar { overflow-x: auto; flex-wrap: nowrap; }
    .chip { white-space: nowrap; }
}

/* =========================================================
   Reward-specific components
   ========================================================= */

/* Text colors */
.text-success { color: var(--success-dark); }
.text-danger  { color: var(--danger); }
.text-right   { text-align: right; }

/* Section head (title + action) */
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--border);
}
.section-head .section-title { margin: 0; padding: 0; border: none; }

/* Page head with action */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.page-head h2 { font-size: 1.5rem; }

/* Button variants */
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: var(--success-dark); text-decoration: none; color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Daily login card */
.daily-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.daily-info { display: flex; align-items: center; gap: 1rem; }
.daily-info .mission-icon { font-size: 2rem; }

/* Table */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
}
.table th {
    background: #f8fafc;
    text-align: left;
    padding: .85rem 1rem;
    font-weight: 600;
    color: var(--text-muted);
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    border-bottom: 1px solid var(--border);
}
.table td {
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }

/* Filter chips */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin: 1.5rem 0;
}
.chip {
    display: inline-block;
    padding: .4rem .9rem;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: .85rem;
    font-weight: 500;
    transition: all .15s ease;
}
.chip:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.chip.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}
.page-link {
    padding: .5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    background: var(--surface);
    transition: all .15s ease;
}
.page-link:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.page-info { color: var(--text-muted); font-size: .9rem; }

/* =========================================================
   Coupon-specific components
   ========================================================= */

/* Stat box success variant */
.stat-box-success .stat-num { color: var(--success-dark); }

/* Coupon grid */
.coupon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

/* Coupon card (ticket style) */
.coupon-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    align-items: stretch;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform .15s ease, box-shadow .15s ease;
}
.coupon-card:hover:not(.is-expired) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.coupon-card.is-expired {
    opacity: .6;
    background: #f8fafc;
}

/* coupon body */
.coupon-body {
    flex: 1;
    padding: 1.1rem 1.25rem;
    position: relative;
}
.coupon-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
    margin-bottom: .15rem;
}
.coupon-card.is-expired .coupon-value { color: var(--text-muted); }

.coupon-title {
    font-weight: 600;
    margin-bottom: .35rem;
    color: var(--text);
}
.coupon-code {
    font-size: .82rem;
    color: var(--text-muted);
    margin-bottom: .35rem;
}
.coupon-code strong { color: var(--text); }
.coupon-meta {
    font-size: .76rem;
    color: var(--text-light);
    line-height: 1.5;
}

/* divider with notch (ticket effect) */
.coupon-body::after {
    content: '';
    position: absolute;
    right: 0; top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 70%;
    border-left: 2px dashed var(--border);
}

/* coupon actions */
.coupon-actions {
    display: flex;
    align-items: center;
    padding: 0 1rem;
    flex-shrink: 0;
}
.coupon-redeem-form { display: flex; }

/* =========================================================
   Affiliate-specific components
   ========================================================= */

/* Link list */
.link-list { display: flex; flex-direction: column; gap: 1rem; }

/* Link card */
.link-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    box-shadow: var(--shadow);
}
.link-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .75rem;
    flex-wrap: wrap;
}
.link-card-head .link-title {
    font-weight: 600;
    font-size: 1.05rem;
    margin-right: .5rem;
}
.link-type {
    font-size: .82rem;
    color: var(--primary);
    background: var(--primary-light);
    padding: .2rem .6rem;
    border-radius: 999px;
    white-space: nowrap;
}

/* URL row (copyable) */
.link-url-row {
    display: flex;
    gap: .5rem;
    margin-bottom: .5rem;
}
.link-url-row input {
    flex: 1;
    padding: .55rem .85rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: #f8fafc;
    font-family: monospace;
    font-size: .88rem;
    color: var(--text-muted);
}
.link-meta {
    font-size: .8rem;
    color: var(--text-light);
}

/* =========================================================
   MUANG Commerce Theme Override
   Inspired by the provided ecosystem design reference.
   ========================================================= */
:root {
    --purple-950: #160B29;
    --purple-900: #241143;
    --purple-800: #33176A;
    --purple-700: #4A1F91;
    --purple-600: #6B2FC4;
    --purple-500: #8B4CE0;
    --purple-400: #AD7BEA;
    --purple-200: #DCC9F7;
    --lavender-50: #F8F4FF;
    --lavender-100: #F1E9FF;
    --gold-600: #C97B25;
    --gold-500: #E89A3C;
    --gold-400: #F3B45E;
    --gold-100: #FCEBD2;
    --ink: #1D1330;
    --ink-soft: #5B4E75;
    --line: #E7DBFA;

    --primary: var(--purple-600);
    --primary-dark: var(--purple-800);
    --primary-light: var(--lavender-100);
    --warning: var(--gold-500);
    --warning-light: var(--gold-100);
    --success: #10A66A;
    --success-dark: #087F52;
    --success-light: #DDF8EA;
    --info: var(--purple-500);
    --info-light: #EFE5FF;
    --purple: var(--purple-600);
    --purple-light: var(--lavender-100);
    --pink: #C24B8F;
    --pink-light: #FFE7F4;

    --bg: var(--lavender-50);
    --surface: #FFFFFF;
    --border: var(--line);
    --text: var(--ink);
    --text-muted: var(--ink-soft);
    --text-light: #8D80A8;
    --radius: 18px;
    --radius-sm: 12px;
    --shadow: 0 12px 30px -18px rgba(74,31,145,.30);
    --shadow-lg: 0 22px 48px -24px rgba(36,17,67,.42);
    --font: 'IBM Plex Sans Thai', 'Kanit', system-ui, -apple-system, sans-serif;
    --display: 'Kanit', 'IBM Plex Sans Thai', sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

body {
    background:
        radial-gradient(ellipse at 16% -10%, rgba(139,76,224,.17), transparent 42%),
        radial-gradient(ellipse at 86% 0%, rgba(232,154,60,.13), transparent 38%),
        var(--lavender-50);
    color: var(--ink);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3,
.topbar-title,
.sidebar-brand,
.page-head h2,
.section-title,
.stat-value,
.stat-num,
.balance-amount,
.coupon-value,
.auth-logo h1 {
    font-family: var(--display);
    letter-spacing: 0;
}

a { color: var(--purple-700); }
a:hover { color: var(--purple-600); }

/* Auth */
.auth-body {
    background:
        radial-gradient(ellipse at 22% 12%, rgba(243,180,94,.22), transparent 36%),
        radial-gradient(ellipse at 80% 5%, rgba(173,123,234,.28), transparent 40%),
        linear-gradient(160deg, var(--purple-950) 0%, var(--purple-800) 56%, var(--purple-600) 100%);
}
.auth-wrapper { max-width: 430px; }
.auth-card {
    border: 1px solid rgba(255,255,255,.55);
    border-radius: 24px;
    padding: 2.25rem;
    box-shadow: 0 28px 70px -28px rgba(22,11,41,.72);
}
.auth-logo-mark,
.brand-mark {
    background: linear-gradient(145deg, var(--purple-500), var(--purple-800));
    color: #fff;
    box-shadow: 0 14px 28px -14px rgba(74,31,145,.58);
}
.auth-logo h1,
.brand-name {
    color: var(--purple-950);
}
.text-primary { color: var(--gold-600); }
.auth-hint {
    background: var(--lavender-50);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 1rem;
}

/* App shell */
.app-shell { background: transparent; }
.sidebar {
    background: rgba(255,255,255,.92);
    border-right: 1px solid rgba(231,219,250,.9);
    box-shadow: 18px 0 44px -36px rgba(36,17,67,.44);
    backdrop-filter: blur(14px);
}
.sidebar-brand {
    border-bottom: 1px solid var(--line);
    padding: 1.1rem 1.35rem;
}
.brand-mark {
    border-radius: 13px;
    font-family: var(--display);
}
.sidebar-nav { padding: 1rem .8rem; }
.sidebar-nav a,
.nav-link-danger {
    border-radius: 14px;
    color: var(--ink-soft);
    font-family: var(--display);
    font-size: .94rem;
    font-weight: 500;
}
.sidebar-nav a:hover {
    background: var(--lavender-100);
    color: var(--purple-800);
}
.sidebar-nav a.is-active {
    background: linear-gradient(135deg, var(--purple-600), var(--purple-800));
    color: #fff;
    box-shadow: 0 16px 30px -18px rgba(74,31,145,.72);
}
.nav-link-danger {
    color: #B93855;
    background: #FFF5F7;
}
.nav-link-danger:hover { background: #FFE7ED; }

.main { min-height: 100vh; }
.topbar {
    background: rgba(248,244,255,.86);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
    padding: .95rem 1.5rem;
}
.topbar-title {
    color: var(--purple-950);
    font-size: 1.22rem;
    font-weight: 700;
}
.icon-btn {
    border-radius: 12px;
    color: var(--purple-800);
}
.icon-btn:hover { background: var(--lavender-100); }
.user-avatar {
    background: linear-gradient(145deg, var(--gold-400), var(--purple-500));
    color: #fff;
    box-shadow: 0 12px 26px -16px rgba(36,17,67,.55);
}
.content {
    max-width: 1180px;
    padding: 1.8rem;
}

/* Cards and sections */
.page-head {
    background: rgba(255,255,255,.66);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 1.2rem 1.35rem;
    box-shadow: var(--shadow);
}
.page-head h2 { color: var(--purple-950); }
.section-title,
.section-head {
    border-color: var(--line);
}
.section-title { color: var(--purple-900); }
.stat-card,
.quick-card,
.info-item,
.form-card,
.stat-box,
.mission-item,
.daily-card,
.table-wrap,
.coupon-card,
.link-card,
.profile-header {
    border-color: rgba(231,219,250,.95);
    border-radius: 18px;
    box-shadow: var(--shadow);
}
.stat-card,
.quick-card,
.stat-box,
.form-card,
.table-wrap,
.coupon-card,
.link-card,
.profile-header {
    background: rgba(255,255,255,.94);
}
.stat-card:hover,
.quick-card:hover,
.coupon-card:hover:not(.is-expired),
.link-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}
.stat-value,
.stat-num,
.coupon-value { color: var(--purple-800); }
.stat-label,
.info-label,
.stat-cap,
.link-meta { color: var(--ink-soft); }
.stat-icon,
.quick-icon {
    border-radius: 15px;
}
.stat-primary .stat-icon,
.stat-purple .stat-icon,
.stat-info .stat-icon {
    background: var(--lavender-100);
    color: var(--purple-700);
}
.stat-warning .stat-icon {
    background: var(--gold-100);
    color: var(--gold-600);
}

/* Buttons and forms */
.btn {
    border-radius: 999px;
    font-family: var(--display);
    letter-spacing: 0;
}
.btn-primary,
.chip.is-active {
    background: linear-gradient(135deg, var(--purple-600), var(--purple-800));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 14px 28px -17px rgba(74,31,145,.70);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--purple-500), var(--purple-800));
    color: #fff;
}
.btn-success {
    background: linear-gradient(135deg, var(--gold-400), var(--gold-600));
    color: #3A2205;
}
.btn-outline,
.page-link,
.chip {
    background: #fff;
    border-color: var(--line);
    color: var(--purple-700);
}
.btn-outline:hover,
.page-link:hover,
.chip:hover {
    border-color: var(--purple-400);
    color: var(--purple-800);
}
.form-group input,
.form-group select,
.form-group textarea,
.input-group input,
.link-url-row input {
    border-color: var(--line);
    border-radius: 14px;
    background: #fff;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.input-group input:focus {
    border-color: var(--purple-500);
    box-shadow: 0 0 0 4px rgba(139,76,224,.14);
}

/* Tables, badges, alerts */
.table th {
    background: var(--lavender-50);
    color: var(--purple-800);
    font-family: var(--mono);
    letter-spacing: .04em;
}
.table tbody tr:hover { background: rgba(248,244,255,.76); }
.badge { font-family: var(--display); }
.badge-info { background: var(--lavender-100); color: var(--purple-700); }
.badge-warning { background: var(--gold-100); color: var(--gold-600); }
.badge-success { background: var(--success-light); color: var(--success-dark); }
.badge-muted { background: #F4F0FA; color: var(--ink-soft); }
.alert {
    border: 1px solid transparent;
    border-radius: 16px;
}
.alert-info { background: var(--lavender-100); color: var(--purple-800); border-color: var(--line); }
.alert-warning { background: var(--gold-100); color: #7A4A12; border-color: #F8D8A2; }

/* Hero-like finance panels */
.balance-hero,
.level-card {
    border-radius: 22px;
    background:
        radial-gradient(ellipse at 82% 12%, rgba(243,180,94,.24), transparent 38%),
        linear-gradient(135deg, var(--purple-700), var(--purple-950));
    box-shadow: var(--shadow-lg);
}
.balance-success {
    background:
        radial-gradient(ellipse at 82% 12%, rgba(243,180,94,.22), transparent 38%),
        linear-gradient(135deg, #0E8D62, var(--purple-800));
}
.balance-info {
    background:
        radial-gradient(ellipse at 82% 12%, rgba(243,180,94,.22), transparent 38%),
        linear-gradient(135deg, var(--purple-500), var(--purple-900));
}
.level-badge {
    border-color: rgba(243,180,94,.55);
    background: rgba(252,235,210,.18);
}
.progress-bar { background: linear-gradient(90deg, var(--gold-400), #fff); }

/* Public store pages */
.public-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: 76px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    background: rgba(248,244,255,.88);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}
.public-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--purple-950);
    font-family: var(--display);
    font-size: 1.25rem;
    font-weight: 700;
}
.public-brand:hover { text-decoration: none; }
.public-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}
.public-nav > a:not(.btn) {
    color: var(--ink-soft);
    font-family: var(--display);
    font-weight: 500;
}
.public-content {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 2rem 0 3rem;
}
.public-footer {
    border-top: 1px solid var(--line);
    color: var(--ink-soft);
    padding: 1.5rem;
    text-align: center;
}

/* Product/store surfaces */
.store-card,
.product-card,
[class*="store-"] .card {
    border-color: var(--line);
    border-radius: 18px;
}
.public-head {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    background:
        radial-gradient(ellipse at 82% 18%, rgba(243,180,94,.22), transparent 38%),
        linear-gradient(135deg, #fff, var(--lavender-100));
    box-shadow: var(--shadow);
}
.public-head h1 {
    color: var(--purple-950);
    font-family: var(--display);
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    line-height: 1.12;
    margin-bottom: .35rem;
}
.store-grid,
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}
.store-card,
.product-card,
.review-card {
    display: block;
    overflow: hidden;
    background: rgba(255,255,255,.94);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
    color: var(--ink);
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.store-card:hover,
.product-card:hover {
    border-color: var(--purple-400);
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
    text-decoration: none;
}
.store-card-banner,
.product-img {
    position: relative;
    min-height: 150px;
    background:
        radial-gradient(ellipse at 72% 8%, rgba(243,180,94,.38), transparent 36%),
        linear-gradient(145deg, var(--purple-600), var(--purple-950));
}
.store-card-banner img,
.product-img img {
    width: 100%;
    height: 170px;
    object-fit: cover;
}
.store-banner-ph,
.product-img-ph {
    min-height: 170px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 2.5rem;
}
.store-card-body,
.product-info {
    padding: 1rem 1.1rem 1.15rem;
}
.store-card-name,
.product-name {
    color: var(--purple-950);
    font-family: var(--display);
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.35;
}
.store-card-rating,
.store-meta,
.product-sold {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .35rem;
    margin-top: .35rem;
    color: var(--ink-soft);
    font-size: .88rem;
}
.store-card-desc { margin-top: .45rem; }
.star-filled,
.stars-display .star-filled {
    color: var(--gold-500);
}
.store-verified,
.store-verified-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--gold-400), var(--gold-600));
    color: #3A2205;
    font-family: var(--display);
    font-size: .8rem;
    font-weight: 800;
    box-shadow: 0 10px 22px -14px rgba(201,123,37,.7);
}
.store-verified {
    position: absolute;
    right: 12px;
    top: 12px;
}
.store-verified-inline {
    vertical-align: middle;
    margin-left: .35rem;
}
.store-header {
    display: flex;
    gap: 1.25rem;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 1.35rem;
    background:
        radial-gradient(ellipse at 86% 8%, rgba(243,180,94,.18), transparent 36%),
        linear-gradient(135deg, #fff, var(--lavender-100));
    box-shadow: var(--shadow);
}
.store-logo {
    width: 92px;
    height: 92px;
    border-radius: 24px;
    overflow: hidden;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, var(--purple-500), var(--purple-900));
    color: #fff;
    font-size: 2.1rem;
    box-shadow: var(--shadow-lg);
}
.store-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.store-info h1 {
    color: var(--purple-950);
    font-family: var(--display);
    line-height: 1.16;
    margin-bottom: .35rem;
}
.product-price {
    display: flex;
    align-items: baseline;
    gap: .45rem;
    margin-top: .55rem;
}
.price-now {
    color: var(--purple-700);
    font-family: var(--mono);
    font-size: 1.05rem;
    font-weight: 700;
}
.price-was {
    color: var(--text-light);
    font-size: .85rem;
    text-decoration: line-through;
}
.product-sale-badge,
.product-oos-badge {
    position: absolute;
    left: 12px;
    top: 12px;
    border-radius: 999px;
    padding: .32rem .7rem;
    font-family: var(--display);
    font-size: .78rem;
    font-weight: 700;
}
.product-sale-badge {
    background: var(--gold-100);
    color: var(--gold-600);
}
.product-oos-badge {
    background: rgba(22,11,41,.78);
    color: #fff;
}
.review-list {
    display: grid;
    gap: .85rem;
}
.review-card {
    padding: 1rem;
}
.review-head {
    display: flex;
    align-items: center;
    gap: .75rem;
}
.review-author {
    color: var(--purple-950);
    font-family: var(--display);
    font-weight: 700;
}
.review-text {
    margin-top: .85rem;
    color: var(--ink-soft);
}

/* Ecosystem landing page */
.ecosystem-body { background: var(--lavender-50); }
.ecosystem-wrap { max-width: 1220px; margin: 0 auto; padding: 0 24px; }
.ecosystem-header {
    position: sticky;
    top: 0;
    z-index: 70;
    background: rgba(248,244,255,.9);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}
.ecosystem-topline {
    min-height: 34px;
    padding: 0 24px;
    background: var(--purple-950);
    color: var(--purple-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    font-size: .82rem;
}
.ecosystem-topline strong { color: var(--gold-400); }
.ecosystem-nav {
    max-width: 1220px;
    min-height: 76px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 24px;
}
.ecosystem-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    color: var(--purple-950);
    font-family: var(--display);
    font-size: 1.28rem;
    font-weight: 800;
}
.ecosystem-logo small {
    display: block;
    color: var(--ink-soft);
    font-family: var(--mono);
    font-size: .56rem;
    letter-spacing: .14em;
    text-transform: uppercase;
}
.ecosystem-logo:hover { text-decoration: none; }
.ecosystem-search {
    flex: 1;
    max-width: 560px;
    display: flex;
    align-items: center;
    gap: 0;
    background: #fff;
    border: 1.5px solid var(--line);
    border-radius: 999px;
    padding: 6px 6px 6px 18px;
}
.ecosystem-search select,
.ecosystem-search input {
    border: 0;
    background: transparent;
}
.ecosystem-search select {
    color: var(--ink-soft);
    font-size: .85rem;
    padding-right: 10px;
    border-right: 1px solid var(--line);
}
.ecosystem-search input {
    flex: 1;
    min-width: 80px;
    padding: 0 12px;
}
.ecosystem-search input:focus { outline: 0; }
.ecosystem-search button {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: var(--purple-700);
    color: #fff;
}
.ecosystem-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
}
.ecosystem-actions a:not(.btn) {
    color: var(--ink-soft);
    font-family: var(--display);
    font-weight: 500;
}
.ecosystem-cats {
    max-width: 1220px;
    height: 46px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 28px;
    overflow-x: auto;
    border-top: 1px solid var(--line);
}
.ecosystem-cats a {
    flex: 0 0 auto;
    color: var(--ink-soft);
    font-family: var(--display);
    font-size: .9rem;
}
.ecosystem-hero {
    position: relative;
    overflow: hidden;
    padding: 64px 0 40px;
}
.ecosystem-hero::before {
    content: "";
    position: absolute;
    inset: -20% -10% auto -10%;
    height: 620px;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(139,76,224,.20), transparent 60%),
        radial-gradient(ellipse at 80% 10%, rgba(232,154,60,.16), transparent 55%);
    pointer-events: none;
}
.hero-grid {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    gap: 56px;
    align-items: center;
}
.eyebrow {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--purple-600);
    font-family: var(--mono);
    font-size: .76rem;
    letter-spacing: .12em;
    text-transform: uppercase;
}
.eyebrow::before {
    content: "";
    width: 18px;
    height: 2px;
    background: var(--gold-500);
}
.ecosystem-hero h1 {
    color: var(--purple-950);
    font-family: var(--display);
    font-size: clamp(2.2rem, 5vw, 3.55rem);
    line-height: 1.12;
    margin: 16px 0 18px;
}

/* =========================================================
   OwnerOS Phase 2
   ========================================================= */
.page-actions {
    display: flex;
    justify-content: flex-end;
    gap: .65rem;
    margin: 0 0 1rem;
}

.table-actions {
    display: grid;
    grid-template-columns: auto minmax(160px, 1fr) auto;
    gap: .45rem;
    align-items: center;
    min-width: 310px;
}
.table-actions input {
    min-width: 0;
    padding: .42rem .6rem;
    border: 1px dashed var(--line);
    border-radius: 999px;
    color: var(--ink-soft);
    background: var(--lavender-50);
    font-family: var(--mono);
    font-size: .78rem;
}

.inline-form {
    display: flex;
    align-items: center;
    gap: .45rem;
    flex-wrap: wrap;
}
.inline-form select,
.inline-form input {
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: .35rem .65rem;
    background: #fff;
    color: var(--ink);
    font-size: .84rem;
}
.inline-form input {
    width: 132px;
}
.finder-filter {
    margin-top: 1rem;
}
.compact-head {
    margin-bottom: 1rem;
    padding: 0;
    background: transparent;
    border: 0;
}
.compact-head h2 {
    margin-bottom: .2rem;
}
.finder-table {
    min-width: 1180px;
}
.link-preview-table {
    min-width: 1120px;
}
.link-preview-table td:last-child {
    min-width: 260px;
}
.table-main-input,
.table-mini-input {
    width: 100%;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    padding: .42rem .58rem;
}
.table-main-input {
    min-width: 260px;
    font-weight: 700;
}
.table-mini-input {
    max-width: 180px;
    font-size: .86rem;
}
.rating-input {
    width: 64px;
}
.finder-thumb {
    width: 58px;
    height: 58px;
    border-radius: 12px;
    object-fit: cover;
    background: var(--lavender-50);
    border: 1px solid var(--line);
}
.text-warning {
    color: var(--gold-600);
}

/* Full-width work area for owner dashboard pages */
.content {
    max-width: none;
    width: 100%;
    padding: clamp(1rem, 2vw, 2rem);
}
.content > .form-card,
.content > .table-wrap,
.content > .section,
.content > .page-head,
.content > .card-grid,
.content > .balance-hero,
.content > .page-actions {
    width: 100%;
}
.content > .section .table-wrap,
.content > .section .link-list {
    width: 100%;
}

/* Collapsible owner sidebar */
:root {
    --sidebar-collapsed-w: 86px;
}
.sidebar,
.main {
    transition: width .2s ease, margin-left .2s ease, transform .25s ease;
}
.sidebar-collapse-btn {
    margin-left: auto;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--purple-800);
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}
.sidebar-collapse-btn:hover {
    background: var(--lavender-100);
}
.sidebar-collapse-top {
    display: inline-flex;
}
body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-w);
}
body.sidebar-collapsed .main {
    margin-left: var(--sidebar-collapsed-w);
}
body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding-left: .75rem;
    padding-right: .75rem;
}
body.sidebar-collapsed .brand-name,
body.sidebar-collapsed .nav-label {
    display: none;
}
body.sidebar-collapsed .sidebar-collapse-btn {
    position: absolute;
    right: -16px;
    top: 18px;
    box-shadow: var(--shadow);
}
body.sidebar-collapsed .sidebar-nav {
    padding-left: .65rem;
    padding-right: .65rem;
}
body.sidebar-collapsed .sidebar-nav a,
body.sidebar-collapsed .nav-link-danger {
    justify-content: center;
    gap: 0;
    padding-left: .7rem;
    padding-right: .7rem;
    position: relative;
}
body.sidebar-collapsed .nav-icon {
    width: 26px;
}
body.sidebar-collapsed .sidebar-nav a:hover::after,
body.sidebar-collapsed .nav-link-danger:hover::after {
    content: attr(aria-label);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    white-space: nowrap;
    z-index: 200;
    padding: .45rem .7rem;
    border-radius: 10px;
    background: var(--purple-950);
    color: #fff;
    box-shadow: var(--shadow-lg);
    font-size: .82rem;
}

@media (max-width: 768px) {
    .sidebar-collapse-btn,
    .sidebar-collapse-top {
        display: none;
    }
    body.sidebar-collapsed .sidebar {
        width: var(--sidebar-w);
    }
    body.sidebar-collapsed .main {
        margin-left: 0;
    }
    body.sidebar-collapsed .brand-name,
    body.sidebar-collapsed .nav-label {
        display: inline;
    }
}

.public-lead-body {
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 16% -10%, rgba(139,76,224,.20), transparent 42%),
        radial-gradient(ellipse at 86% 0%, rgba(232,154,60,.16), transparent 38%),
        var(--lavender-50);
}
.public-lead-page {
    width: min(960px, calc(100% - 32px));
    margin: 0 auto;
    padding: 2rem 0 3rem;
}
.lead-product {
    display: grid;
    grid-template-columns: minmax(240px, 380px) 1fr;
    gap: 1.4rem;
    align-items: stretch;
    margin-bottom: 1.4rem;
}
.lead-product-media,
.lead-product-info {
    border: 1px solid var(--line);
    border-radius: 24px;
    background: rgba(255,255,255,.94);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.lead-product-media {
    min-height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse at 72% 8%, rgba(243,180,94,.32), transparent 36%),
        linear-gradient(145deg, var(--purple-600), var(--purple-950));
}
.lead-product-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.lead-product-info {
    padding: 1.5rem;
}
.lead-product-info h1 {
    margin: .8rem 0 .65rem;
    color: var(--purple-950);
    font-family: var(--display);
    font-size: clamp(1.8rem, 5vw, 3rem);
    line-height: 1.12;
}
.lead-product-info p {
    color: var(--ink-soft);
    margin-bottom: 1rem;
}
.lead-price {
    color: var(--purple-800);
    font-family: var(--mono);
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: .35rem;
}
.lead-form {
    max-width: none;
}

/* Affiliate bridge landing */
.deal-body {
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 20% -10%, rgba(139,76,224,.22), transparent 42%),
        radial-gradient(ellipse at 82% 0%, rgba(243,180,94,.20), transparent 40%),
        var(--lavender-50);
}
.deal-page {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 2rem 0 3rem;
}
.deal-hero {
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    gap: 1.5rem;
    align-items: stretch;
    min-height: 520px;
}
.deal-copy,
.deal-media,
.deal-panel {
    border: 1px solid var(--line);
    border-radius: 26px;
    background: rgba(255,255,255,.94);
    box-shadow: var(--shadow);
}
.deal-copy {
    padding: clamp(1.4rem, 4vw, 3rem);
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.deal-copy h1 {
    margin: 1rem 0 .8rem;
    color: var(--purple-950);
    font-family: var(--display);
    font-size: clamp(2rem, 5vw, 4rem);
    line-height: 1.08;
}
.deal-copy p {
    color: var(--ink-soft);
    font-size: 1.06rem;
    max-width: 620px;
}
.deal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-top: 1.4rem;
}
.deal-disclaimer {
    margin-top: 1.25rem;
    color: var(--text-light);
    font-size: .82rem;
    line-height: 1.55;
}
.deal-media {
    overflow: hidden;
    min-height: 360px;
    background:
        radial-gradient(ellipse at 72% 12%, rgba(243,180,94,.38), transparent 38%),
        linear-gradient(145deg, var(--purple-600), var(--purple-950));
}
.deal-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.deal-media-ph {
    height: 100%;
    min-height: 360px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,.9);
    font-family: var(--display);
    font-size: clamp(3rem, 10vw, 7rem);
    font-weight: 800;
}
.deal-section {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 1rem;
    margin-top: 1rem;
}
.deal-panel {
    padding: 1.35rem;
}
.deal-panel h2 {
    color: var(--purple-950);
    font-family: var(--display);
    margin-bottom: .75rem;
}
.deal-bullets {
    display: grid;
    gap: .65rem;
    list-style: none;
}
.deal-bullets li {
    position: relative;
    padding-left: 1.7rem;
    color: var(--ink-soft);
}
.deal-bullets li::before {
    content: "✓";
    position: absolute;
    left: 0;
    top: 0;
    width: 1.15rem;
    height: 1.15rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--success-light);
    color: var(--success-dark);
    font-size: .75rem;
    font-weight: 800;
}
.deal-cta-panel {
    align-self: start;
}

@media (max-width: 768px) {
    .page-actions {
        justify-content: stretch;
    }
    .page-actions .btn {
        width: 100%;
    }
    .lead-product {
        grid-template-columns: 1fr;
    }
    .lead-product-media {
        min-height: 240px;
    }
    .table-actions {
        grid-template-columns: 1fr;
        min-width: 220px;
    }
    .inline-form {
        align-items: stretch;
        flex-direction: column;
    }
    .inline-form input,
    .inline-form select,
    .inline-form .btn {
        width: 100%;
    }
    .deal-hero,
    .deal-section {
        grid-template-columns: 1fr;
        min-height: 0;
    }
    .deal-media {
        min-height: 260px;
        order: -1;
    }
    .deal-actions .btn {
        width: 100%;
    }
}
.lead {
    max-width: 560px;
    color: var(--ink-soft);
    font-size: 1.05rem;
}
.hero-cta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 28px 0 36px;
}
.stat-row {
    display: flex;
    gap: 0;
    border-top: 1px solid var(--line);
    padding-top: 22px;
}
.stat { flex: 1; padding-right: 18px; }
.stat b {
    display: block;
    color: var(--purple-800);
    font-family: var(--mono);
    font-size: 1.4rem;
}
.stat span { color: var(--ink-soft); font-size: .85rem; }
.phone-stage {
    position: relative;
    display: flex;
    justify-content: center;
}
.phone {
    position: relative;
    z-index: 2;
    width: 290px;
    height: 560px;
    padding: 12px;
    border-radius: 38px;
    background: var(--purple-950);
    box-shadow: var(--shadow-lg);
}
.phone .screen {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 28px;
    background: linear-gradient(165deg, var(--purple-700), var(--purple-950) 70%);
}
.phone .live-tag,
.live-card .badge {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #E23B4E;
    color: #fff;
    font-family: var(--mono);
    font-size: .68rem;
    font-weight: 700;
    border-radius: 999px;
}
.phone .live-tag { position: absolute; top: 16px; left: 16px; padding: 5px 10px; }
.phone .live-tag i,
.live-card .badge i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
}
.phone .viewers {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(0,0,0,.35);
    color: #fff;
    font-family: var(--mono);
    font-size: .68rem;
    padding: 5px 10px;
    border-radius: 999px;
}
.phone .host {
    position: absolute;
    bottom: 150px;
    left: 16px;
    right: 16px;
    color: #fff;
}
.phone .host .name { font-family: var(--display); font-weight: 700; }
.phone .host .cap { color: var(--purple-200); font-size: .8rem; margin-top: 4px; }
.phone .product-sheet {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    border-radius: 22px 22px 0 0;
    padding: 16px 18px 20px;
}
.phone .prow { display: flex; align-items: center; gap: 12px; }
.phone .thumb {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--gold-400), var(--purple-500));
}
.phone .pname { color: var(--ink); font-size: .8rem; font-weight: 700; }
.phone .price-line { display: flex; align-items: baseline; gap: 6px; margin-top: 3px; }
.phone .price-line b { color: var(--purple-700); font-family: var(--mono); }
.phone .price-line s { color: #B4A9C6; font-size: .72rem; }
.cashback-chip {
    margin-left: auto;
    background: var(--gold-100);
    color: var(--gold-600);
    border-radius: 999px;
    padding: 5px 9px;
    font-family: var(--mono);
    font-size: .68rem;
    font-weight: 700;
}
.float-card {
    position: absolute;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border-radius: 16px;
    padding: 12px 16px;
    box-shadow: var(--shadow-lg);
}
.float-card .ico {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gold-100);
}
.float-card b { display: block; font-family: var(--mono); }
.float-card span { color: var(--ink-soft); font-size: .72rem; }
.float-1 { top: 8%; left: -8%; }
.float-2 { right: -10%; bottom: 6%; }
.catgrid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 14px;
}
.catcard {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px 8px;
    color: var(--ink);
}
.catcard:hover { border-color: var(--purple-400); text-decoration: none; transform: translateY(-3px); box-shadow: var(--shadow); }
.catcard .em {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--lavender-100);
    font-size: 1.35rem;
}
.catcard span { font-family: var(--display); font-size: .85rem; font-weight: 600; }
.sec-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 30px;
}
.sec-head h2 { color: var(--purple-950); font-size: 1.9rem; margin-top: 8px; }
.sec-head p { max-width: 520px; color: var(--ink-soft); }
.see-all { color: var(--purple-700); font-family: var(--display); font-weight: 600; }
.live-band {
    overflow: hidden;
    color: #fff;
    border-radius: 24px;
    background: linear-gradient(120deg, var(--purple-950), var(--purple-800) 60%, var(--purple-700));
}
.live-band .inner { padding: 36px; }
.live-band .sec-head h2 { color: #fff; }
.live-band .sec-head p { color: var(--purple-200); }
.live-band .see-all { color: var(--gold-400); }
.scroller { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 6px; }
.live-card {
    flex: 0 0 220px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 18px;
    background: rgba(255,255,255,.06);
}
.live-card .thumb {
    position: relative;
    height: 130px;
    display: flex;
    align-items: flex-end;
    padding: 10px;
    background: linear-gradient(140deg, var(--purple-500), var(--gold-500));
}
.live-card .badge { position: absolute; top: 10px; left: 10px; padding: 4px 8px; }
.live-card .viewers { position: absolute; top: 10px; right: 10px; color: #fff; background: rgba(0,0,0,.38); padding: 4px 8px; border-radius: 999px; font-size: .7rem; }
.live-card .host { color: #fff; background: rgba(0,0,0,.32); padding: 5px 9px; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.live-card .info { padding: 12px 14px 16px; }
.live-card .info .p { font-size: .84rem; font-weight: 600; margin-bottom: 6px; }
.live-card .info .price { color: var(--gold-400); font-family: var(--mono); font-weight: 700; }
.prodgrid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
}
.pcard {
    overflow: hidden;
    position: relative;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    color: var(--ink);
    transition: .2s ease;
}
.pcard:hover { border-color: transparent; box-shadow: var(--shadow-lg); transform: translateY(-4px); text-decoration: none; }
.pcard .pthumb {
    aspect-ratio: 1 / 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(150deg, var(--purple-400), var(--gold-400));
    font-size: 2.2rem;
}
.pcard .disc {
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--purple-950);
    color: var(--gold-400);
    border-radius: 8px;
    padding: 4px 8px;
    font-family: var(--mono);
    font-size: .68rem;
    font-weight: 700;
}
.pcard .cb {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 10px;
    background: rgba(232,154,60,.94);
    color: #3A2205;
    text-align: center;
    border-radius: 999px;
    padding: 5px 0;
    font-family: var(--mono);
    font-size: .68rem;
    font-weight: 700;
}
.pcard .body { padding: 13px 14px 16px; }
.pcard .name {
    height: 42px;
    overflow: hidden;
    color: var(--ink);
    font-size: .88rem;
    font-weight: 600;
    line-height: 1.45;
}
.pcard .price { display: flex; align-items: baseline; gap: 6px; margin-top: 8px; }
.pcard .price b { color: var(--purple-700); font-family: var(--mono); font-size: 1rem; }
.pcard .price s { color: #B4A9C6; font-size: .75rem; }
.pcard .meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; color: var(--ink-soft); font-size: .74rem; }
.pcard .stars { color: var(--gold-500); }
.community-layout {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 20px;
}
.thread {
    display: flex;
    gap: 14px;
    padding: 18px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    margin-bottom: 12px;
}
.thread .avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(140deg, var(--purple-500), var(--purple-800));
    color: #fff;
    font-family: var(--display);
    font-weight: 700;
}
.thread .tag {
    display: inline-block;
    background: var(--lavender-100);
    color: var(--purple-700);
    border-radius: 999px;
    padding: 3px 9px;
    font-family: var(--mono);
    font-size: .68rem;
    font-weight: 700;
    margin-bottom: 6px;
}
.thread .tag.hot { background: #FDE7E7; color: #C23B3B; }
.thread h4 { color: var(--ink); font-size: 1rem; margin-bottom: 5px; }
.thread .snip { color: var(--ink-soft); font-size: .86rem; margin-bottom: 8px; }
.thread .stats { color: var(--ink-soft); font-size: .78rem; }
.side-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 20px;
    margin-bottom: 16px;
}
.side-card h4 { color: var(--purple-950); font-family: var(--display); margin-bottom: 14px; }
.aff-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.aff-row:last-child { border-bottom: 0; }
.aff-row .rank { color: var(--purple-400); font-family: var(--mono); font-weight: 700; }
.thumb-sm { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, var(--gold-400), var(--purple-400)); }
.aff-row .txt b { display: block; font-size: .86rem; }
.aff-row .txt span { color: var(--gold-600); font-family: var(--mono); font-size: .76rem; }
.flow-sec {
    position: relative;
    overflow: hidden;
    background: var(--purple-950);
    border-radius: 32px;
}
.flow-sec::before { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 0%, rgba(139,76,224,.35), transparent 60%); }
.flow-inner { position: relative; color: #fff; padding: 56px 28px; }
.flow-inner .sec-head h2 { color: #fff; }
.flow-inner .sec-head p { color: var(--purple-200); }
.flow-inner .eyebrow { color: var(--gold-400); }
.flowmap { max-width: 920px; margin: 34px auto 0; display: flex; flex-direction: column; align-items: center; }
.fnode {
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 16px;
    padding: 14px 20px;
    text-align: center;
    font-family: var(--display);
    font-weight: 600;
}
.fnode.top { background: linear-gradient(135deg, var(--purple-500), var(--purple-800)); border: 0; }
.fnode.mid { border-color: var(--gold-500); }
.fnode.core { background: linear-gradient(135deg, var(--gold-500), var(--gold-600)); color: #3A2205; border: 0; }
.fnode small { display: block; color: var(--purple-200); font-family: var(--mono); font-size: .62rem; margin-top: 3px; }
.fnode.core small { color: #7A4E13; }
.flow-vline { width: 2px; height: 26px; background: linear-gradient(var(--purple-400), transparent); }
.flow-branch3 { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.flow-col { display: flex; justify-content: center; }
.ecosystem-footer {
    margin-top: 64px;
    background: var(--purple-950);
    color: var(--purple-200);
}
.ecosystem-footer .foot-bottom {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding-top: 22px;
    padding-bottom: 22px;
    color: #BDADE0;
}

@media (max-width: 1080px) {
    .prodgrid { grid-template-columns: repeat(3, 1fr); }
    .catgrid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 860px) {
    .ecosystem-search { display: none; }
    .ecosystem-nav { flex-wrap: wrap; height: auto; padding-top: 12px; padding-bottom: 12px; }
    .hero-grid { grid-template-columns: 1fr; }
    .phone-stage { order: -1; margin-bottom: 18px; }
    .community-layout { grid-template-columns: 1fr; }
    .flow-branch3 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
    .ecosystem-topline { align-items: flex-start; flex-direction: column; padding-top: 8px; padding-bottom: 8px; }
    .ecosystem-actions { width: 100%; overflow-x: auto; }
    .ecosystem-cats { gap: 18px; }
    .prodgrid { grid-template-columns: repeat(2, 1fr); }
    .catgrid { grid-template-columns: repeat(3, 1fr); }
    .phone { width: 250px; height: 500px; }
    .float-card { display: none; }
}

@media (max-width: 768px) {
    .content { padding: 1rem; }
    .topbar { padding: .8rem 1rem; }
    .page-head { padding: 1rem; align-items: flex-start; }
    .public-topbar {
        min-height: auto;
        padding: 14px 16px;
        align-items: flex-start;
        flex-direction: column;
    }
    .public-nav {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 2px;
    }
    .auth-card { padding: 1.6rem; }
    .store-header {
        align-items: flex-start;
        flex-direction: column;
    }
    .store-logo {
        width: 76px;
        height: 76px;
        border-radius: 20px;
    }
}

/* Product editor (add / edit) */
.product-editor {
    box-shadow: 0 1px 3px rgba(20, 16, 40, .05);
    max-width: 100%;
    width: 100%;
}
.editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 1.25rem;
    align-items: start;
    min-width: 0;
}
.editor-main { display: grid; gap: 1.25rem; min-width: 0; }
.editor-side {
    display: grid;
    gap: 1.25rem;
    min-width: 0;
    /* Sticky on desktop: sidebar follows page scroll, no inner scrollbar.
       On mobile (<=960px) it is reset to static in the responsive block. */
    position: sticky;
    top: 5.5rem; /* sit just below the sticky topbar (~76px) with breathing room */
    align-self: start;
}
.form-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.35rem;
}
.form-section + .form-section { margin: 0; }
.form-section-title {
    font-family: var(--display);
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--purple-900);
    margin-bottom: .25rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.form-section-hint { font-size: .82rem; color: var(--text-muted); margin: 0 0 1rem; }
.field-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}
/* Legacy image-preview classes kept for backward compat — see "Image uploader" below */
.img-preview-main {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: #f8fafc;
}
.img-thumb-none {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border);
    color: #cbd0dd;
    font-size: 1.4rem;
    background: #fafbff;
}
.market-place-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: .85rem;
}
.market-place-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .85rem;
    padding: .9rem 0;
    border-bottom: 1px dashed var(--border);
}
.market-place-row:last-child { border-bottom: none; }
.market-place-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .55rem;
    font-weight: 600;
    font-size: .9rem;
    color: var(--text);
}
.market-place-logo {
    width: 1.35rem;
    height: 1.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    font-weight: 700;
    border-radius: 6px;
    color: #fff;
}
@media (max-width: 960px) {
    .editor-layout { grid-template-columns: 1fr; }
    .editor-side { position: static; }
    .field-3 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .market-place-row { grid-template-columns: 1fr; }
}

/* =========================================================
   Product Editor v2 — Modern card sections
   ========================================================= */

/* ---------- Tabs ---------- */
.product-tabs {
    display: flex;
    gap: .35rem;
    margin-bottom: 1.4rem;
    padding: .35rem;
    background: rgba(255,255,255,.7);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: var(--shadow);
    width: fit-content;
    max-width: 100%;
    overflow-x: auto;
}
.tab-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem 1.25rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--ink-soft);
    font-family: var(--display);
    font-size: .92rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s ease, color .15s ease;
}
.tab-btn:hover { color: var(--purple-800); }
.tab-btn.is-active {
    background: linear-gradient(135deg, var(--purple-600), var(--purple-800));
    color: #fff;
    box-shadow: 0 12px 24px -16px rgba(74,31,145,.7);
}
.tab-btn .count {
    background: rgba(255,255,255,.25);
    padding: .1rem .5rem;
    border-radius: 999px;
    font-size: .78rem;
}
.tab-btn:not(.is-active) .count {
    background: var(--lavender-100);
    color: var(--purple-700);
}
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* ---------- Editor section cards ---------- */
.editor-section {
    background: rgba(255,255,255,.96);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 1.4rem 1.5rem;
    box-shadow: var(--shadow);
    min-width: 0;
}
.editor-section + .editor-section { margin-top: 1rem; }
.es-head {
    display: flex;
    align-items: center;
    gap: .85rem;
    margin-bottom: 1.15rem;
    padding-bottom: 1rem;
    border-bottom: 1px dashed var(--line);
    min-width: 0;
}
.es-head > div { min-width: 0; }
.es-title {
    overflow-wrap: anywhere;
    word-break: break-word;
}
.es-step {
    width: 38px; height: 38px;
    flex: 0 0 auto;
    display: grid; place-items: center;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--lavender-100), #fff);
    border: 1px solid var(--line);
    color: var(--purple-700);
    font-family: var(--display);
    font-size: 1.15rem;
    font-weight: 700;
}
.es-icon { font-size: 1.25rem; line-height: 1; }
.es-title {
    font-family: var(--display);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--purple-950);
    margin: 0;
}
.es-hint {
    font-size: .82rem;
    color: var(--text-muted);
    margin: .15rem 0 0;
}
.editor-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    min-width: 0;
}
.editor-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    min-width: 0;
}
.editor-grid-3 > .form-group,
.editor-grid-2 > .form-group { min-width: 0; }
.editor-section .form-group label {
    font-family: var(--display);
    font-size: .84rem;
    color: var(--purple-900);
}
.editor-section .form-group input::placeholder,
.editor-section .form-group textarea::placeholder { color: #b6accb; }
/* Constrain inputs so long URLs / text never push columns to overflow */
.editor-section .form-group input,
.editor-section .form-group textarea,
.editor-section .form-group select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}
.editor-section .form-group input[type="url"],
.editor-section .form-group textarea { overflow-wrap: anywhere; }

/* ---------- Marketplace rows (redesigned) ---------- */
.market-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: .85rem;
    min-width: 0;
}
.market-row {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: .9rem 1rem;
    background: rgba(248,244,255,.5);
    transition: border-color .15s ease, background .15s ease;
    min-width: 0;
}
.market-row:hover { border-color: var(--purple-400); background: #fff; }
.market-head {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: .7rem;
    font-family: var(--display);
    font-weight: 600;
    font-size: .92rem;
    color: var(--ink);
    min-width: 0;
}
.market-logo {
    width: 30px; height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    color: #fff;
    font-size: .95rem;
    font-weight: 800;
    box-shadow: 0 6px 14px -8px rgba(0,0,0,.3);
}
.market-row .form-group { margin-bottom: .55rem; }
.market-row .form-group:last-child { margin-bottom: 0; }

/* ---------- Image uploader ---------- */
/* Main image preview (square, full width of sidebar) */
.img-main-preview {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: #f8fafc;
    margin: 0 0 .75rem;
}
/* Placeholder shown when main image has no URL */
.img-main-fill {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--purple-400);
    color: var(--purple-400);
    font-size: 2rem;
    background: var(--lavender-50);
    margin: 0 0 .75rem;
}
/* Thumbnail grid (2x2 on sidebar, responsive) */
.img-thumbs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .6rem;
}
.img-thumbs > .img-thumb {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    min-width: 0;
}
/* thumbnail media slot: shows either the <img> or the fill placeholder */
.img-thumb-media {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    overflow: hidden;
    background: var(--lavender-50);
    border: 1px solid var(--line);
}
.img-thumb-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.img-thumb-media .img-thumb-fill {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    margin: 0;
    border: 1px dashed var(--purple-400);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--purple-400);
    font-size: 1.3rem;
    background: var(--lavender-50);
}
.img-thumb input {
    width: 100%;
    min-width: 0;
    font-size: .76rem;
    padding: .4rem .5rem;
    border-radius: 8px;
}

/* ---------- Switch (toggle) ---------- */
.switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: .65rem;
    cursor: pointer;
    user-select: none;
    font-family: var(--display);
    font-size: .9rem;
    font-weight: 500;
    color: var(--ink);
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
    width: 44px; height: 24px;
    background: #d4cbe6;
    border-radius: 999px;
    position: relative;
    transition: background .2s ease;
    flex-shrink: 0;
}
.switch-track::after {
    content: "";
    position: absolute;
    top: 3px; left: 3px;
    width: 18px; height: 18px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,.25);
    transition: transform .2s ease;
}
.switch input:checked + .switch-track {
    background: linear-gradient(135deg, var(--purple-600), var(--purple-800));
}
.switch input:checked + .switch-track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px rgba(139,76,224,.25); }
.switch-row {
    display: flex;
    flex-direction: column;
    gap: .85rem;
    padding-top: .5rem;
}
.check-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .75rem .9rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(248,244,255,.5);
}

/* ---------- Editor submit bar ---------- */
.editor-submit {
    display: flex;
    gap: .65rem;
    margin-top: 1.2rem;
}
.editor-submit .btn { flex: 1; }

/* ---------- Product list (pl- = product-list) ---------- */
.pl-toolbar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}
.pl-search {
    position: relative;
    display: flex;
    align-items: center;
}
.pl-search::before {
    content: "🔍";
    position: absolute;
    left: 1rem;
    font-size: .9rem;
    opacity: .6;
}
.pl-search input {
    width: 100%;
    padding: .7rem 1rem .7rem 2.6rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    font-size: .92rem;
}
.pl-search input:focus {
    outline: 0;
    border-color: var(--purple-500);
    box-shadow: 0 0 0 4px rgba(139,76,224,.14);
}
.pl-filters {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    margin-bottom: 1.25rem;
}
.filter-chip {
    padding: .4rem .9rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--ink-soft);
    font-family: var(--display);
    font-size: .82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s ease;
}
.filter-chip:hover { border-color: var(--purple-400); color: var(--purple-800); }
.filter-chip.is-active {
    background: linear-gradient(135deg, var(--purple-600), var(--purple-800));
    border-color: transparent;
    color: #fff;
}
.pl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 1rem;
}
.pl-card {
    background: rgba(255,255,255,.96);
    border: 1px solid var(--line);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform .15s ease, box-shadow .15s ease;
    display: flex;
    flex-direction: column;
}
.pl-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.pl-thumb {
    position: relative;
    aspect-ratio: 16 / 10;
    background: linear-gradient(135deg, var(--lavender-100), #fff);
    overflow: hidden;
}
.pl-thumb img {
    width: 100%; height: 100%;
    object-fit: cover;
}
.pl-thumb-ph {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%;
    color: var(--purple-400);
    font-size: 2.2rem;
}
.pl-badges {
    position: absolute;
    top: .6rem; left: .6rem;
    display: flex; gap: .35rem; flex-wrap: wrap;
}
.pl-badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .2rem .55rem;
    border-radius: 999px;
    font-family: var(--display);
    font-size: .72rem;
    font-weight: 700;
    backdrop-filter: blur(4px);
}
.pl-badge.sponsored { background: var(--gold-500); color: #3A2205; }
.pl-badge.market {
    color: #fff;
    box-shadow: 0 4px 10px -4px rgba(0,0,0,.3);
}
.pl-badge.inactive { background: rgba(22,11,41,.7); color: #fff; }
.pl-body { padding: .9rem 1rem 1rem; display: flex; flex-direction: column; flex: 1; }
.pl-name {
    font-family: var(--display);
    font-size: .95rem;
    font-weight: 600;
    color: var(--purple-950);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.55rem;
}
.pl-cat { font-size: .78rem; color: var(--ink-soft); margin-top: .2rem; }
.pl-price {
    display: flex;
    align-items: baseline;
    gap: .4rem;
    margin-top: .5rem;
}
.pl-price .now { font-family: var(--mono); font-weight: 700; color: var(--purple-700); font-size: 1.05rem; }
.pl-price .was { font-size: .8rem; color: var(--text-light); text-decoration: line-through; }
.pl-stats {
    display: flex;
    gap: .85rem;
    margin-top: .65rem;
    padding-top: .65rem;
    border-top: 1px dashed var(--line);
    font-size: .76rem;
    color: var(--ink-soft);
    flex-wrap: wrap;
}
.pl-stat { display: inline-flex; align-items: center; gap: .25rem; }
.pl-rating { color: var(--gold-600); font-weight: 600; }
.pl-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-top: .85rem;
    padding-top: .75rem;
    border-top: 1px solid var(--line);
}
.pl-actions { display: flex; gap: .35rem; flex-wrap: wrap; }
.pl-actions .btn { padding: .35rem .65rem; font-size: .78rem; }
.pl-url { position: absolute; left: -9999px; }
.pl-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.pl-empty .ico { font-size: 3rem; opacity: .4; margin-bottom: .5rem; }

/* status switch variant on list card */
.switch.sm .switch-track { width: 38px; height: 22px; }
.switch.sm .switch-track::after { width: 16px; height: 16px; }
.switch.sm input:checked + .switch-track::after { transform: translateX(16px); }

/* ---------- Responsive editor + list ---------- */
/* Wide desktop: sidebar narrower so main column has room */
@media (max-width: 1180px) {
    .editor-layout { grid-template-columns: minmax(0, 1fr) 300px; }
}
/* Tablet / small laptop: stack to single column, sidebar goes below */
@media (max-width: 960px) {
    .editor-layout { grid-template-columns: 1fr; }
    .editor-side { position: static; }
    .editor-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
    .pl-toolbar { grid-template-columns: 1fr; }
}
/* Mobile: everything single column */
@media (max-width: 560px) {
    .editor-grid-3,
    .editor-grid-2 { grid-template-columns: 1fr; }
    .market-list { grid-template-columns: 1fr; }
    .editor-section { padding: 1.1rem 1.15rem; }
    .product-tabs { width: 100%; }
    .es-head { gap: .6rem; }
    .es-step { width: 32px; height: 32px; font-size: 1rem; }
    .es-title { font-size: 1rem; }
    .editor-grid-3 { gap: .75rem; }
    /* image thumbs: stay 2 columns on mobile (sidebar already stacked) */
    .img-thumbs { grid-template-columns: repeat(2, 1fr); }
    .form-card { padding: 1rem; }
    .product-editor { padding: .85rem; }
}
/* Very small phones: keep usable */
@media (max-width: 380px) {
    .editor-section { padding: .9rem .9rem; border-radius: 16px; }
    .es-head { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
    .switch-track, .switch-track::after, .pl-card, .market-row, .tab-btn { transition: none !important; }
}
