/* ============= RESET + BASE ============= */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --bg-0: #0a0f1a;
    --bg-1: #0f172a;
    --bg-2: #1e293b;
    --bg-3: #334155;
    --line: #334155;
    --text: #e2e8f0;
    --text-2: #94a3b8;
    --text-3: #64748b;
    --accent: #38bdf8;
    --accent-2: #2563eb;
    --green: #22c55e;
    --yellow: #eab308;
    --red: #ef4444;
    --purple: #a855f7;
}
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-0); color: var(--text); min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; cursor: pointer; }
.hidden { display: none !important; }
.flex { display: flex; gap: 12px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.flex-col { display: flex; flex-direction: column; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
@media (max-width: 768px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.spacer { flex: 1; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--text-2); }
.text-small { font-size: 13px; }
.text-tiny { font-size: 12px; color: var(--text-3); }
.text-center { text-align: center; }

/* ============= FORMS ============= */
label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
input, select, textarea {
    width: 100%; padding: 10px 14px; border: 1px solid #475569;
    border-radius: 8px; background: var(--bg-1); color: var(--text);
    font-size: 14px; margin-bottom: 12px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 80px; resize: vertical; }

button, .btn-primary, .btn-secondary, .btn-ghost, .btn-danger, .btn-success {
    padding: 10px 18px; border: none; border-radius: 8px;
    font-weight: 600; cursor: pointer; font-size: 14px;
    font-family: inherit; transition: all 0.15s; display: inline-flex;
    align-items: center; justify-content: center; gap: 6px;
}
button, .btn-primary { background: var(--accent); color: var(--bg-1); }
button:hover, .btn-primary:hover { background: #7dd3fc; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--bg-3); color: var(--text); }
.btn-secondary:hover { background: #475569; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--bg-2); }
.btn-danger { background: var(--red); color: white; }
.btn-success { background: var(--green); color: var(--bg-1); }
.btn-small { padding: 6px 12px; font-size: 12px; }
.btn-large { padding: 14px 28px; font-size: 16px; }

/* ============= PUBLIC LAYOUT ============= */
.public-nav {
    display: flex; justify-content: space-between; align-items: center;
    padding: 18px 40px; border-bottom: 1px solid var(--line);
    background: rgba(15, 23, 42, 0.85); backdrop-filter: blur(8px);
    position: sticky; top: 0; z-index: 50;
}
.public-nav-links { display: flex; align-items: center; gap: 16px; }
.public-nav-links a:not(.btn-primary):not(.btn-ghost) {
    color: var(--text-2); font-size: 14px;
}
.public-nav-links a:not(.btn-primary):not(.btn-ghost):hover { color: var(--text); }
.brand { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.brand-accent { color: var(--accent); }
.public-footer {
    padding: 32px 40px; border-top: 1px solid var(--line);
    text-align: center; color: var(--text-3); font-size: 13px;
}
.footer-links {
    display: flex; justify-content: center; gap: 24px;
    flex-wrap: wrap; margin-bottom: 16px;
}
.footer-links a { color: var(--text-2); font-size: 13px; }
.footer-links a:hover { color: var(--accent); }
.footer-copy { color: var(--text-3); font-size: 12px; }

.sidebar-legal {
    display: flex; gap: 12px; padding: 12px 8px 4px;
    flex-wrap: wrap; font-size: 11px;
}
.sidebar-legal a { color: var(--text-3); }
.sidebar-legal a:hover { color: var(--accent); }

/* Landing hero */
.hero {
    padding: 80px 40px 60px; text-align: center;
    background: radial-gradient(ellipse at top, rgba(56,189,248,0.10) 0%, transparent 60%);
}
.hero h1 {
    font-size: 52px; line-height: 1.1; max-width: 800px; margin: 0 auto 20px;
    letter-spacing: -0.02em;
}
.hero .lede {
    font-size: 19px; color: var(--text-2); max-width: 640px; margin: 0 auto 32px;
    line-height: 1.5;
}
.hero-cta { display: flex; justify-content: center; gap: 12px; }
@media (max-width: 640px) { .hero h1 { font-size: 34px; } }

.section { padding: 60px 40px; max-width: 1200px; margin: 0 auto; }
.section h2 {
    font-size: 32px; text-align: center; margin-bottom: 12px;
    letter-spacing: -0.01em;
}
.section .section-sub {
    color: var(--text-2); text-align: center; max-width: 600px;
    margin: 0 auto 40px; font-size: 16px;
}
.feature-card {
    background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
    padding: 28px; transition: border-color 0.2s;
}
.feature-card:hover { border-color: var(--accent); }
.feature-card .feature-icon { font-size: 28px; margin-bottom: 12px; }
.feature-card h3 { font-size: 17px; margin-bottom: 8px; }
.feature-card p { color: var(--text-2); font-size: 14px; line-height: 1.5; }

/* Workflow steps on landing page */
.workflow-step {
    background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
    padding: 24px; text-align: center; position: relative;
}
.workflow-num {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--accent); color: var(--bg-1);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 17px; margin-bottom: 8px;
}

/* Quick Start panel on dashboard for new users */
.quickstart-panel {
    background: linear-gradient(135deg, rgba(56,189,248,0.08), rgba(168,85,247,0.05));
    border-color: var(--accent);
}
.quickstart-step {
    padding: 16px;
    background: var(--bg-1);
    border-radius: 10px;
}
.quickstart-step h3 {
    font-size: 15px;
    margin: 8px 0;
}
.quickstart-step .workflow-num {
    width: 28px; height: 28px; font-size: 14px; margin-bottom: 6px;
}

/* Email notification toggle rows in Account */
.notif-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: var(--bg-1);
    border-radius: 8px;
    margin: 0;
    cursor: pointer;
    transition: background 0.1s;
}
.notif-row:hover { background: rgba(56, 189, 248, 0.05); }
.notif-row input[type="checkbox"] {
    width: auto;
    margin: 4px 0 0 0;
    flex-shrink: 0;
}
.notif-row > div { flex: 1; }

/* Pricing on public page */
.pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; max-width: 1100px; margin: 0 auto; }
.plan-card {
    background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
    padding: 28px; position: relative;
}
.plan-card.featured { border-color: var(--accent); }
.plan-card.featured::before {
    content: "Most popular"; position: absolute; top: -10px; left: 50%;
    transform: translateX(-50%); background: var(--accent);
    color: var(--bg-1); padding: 4px 12px; border-radius: 999px;
    font-size: 11px; font-weight: 700; text-transform: uppercase;
}
.plan-card h3 { color: var(--accent); margin-bottom: 4px; font-size: 19px; }
.plan-card .plan-price { font-size: 38px; font-weight: 700; margin: 12px 0; }
.plan-card .plan-price small { font-size: 14px; color: var(--text-2); font-weight: 400; }
.plan-features { list-style: none; padding: 0; margin: 20px 0; }
.plan-features li { padding: 6px 0; color: var(--text-2); font-size: 14px; }
.plan-features li::before { content: "✓"; color: var(--green); margin-right: 8px; font-weight: 700; }

/* Auth card */
.auth-wrap { min-height: 70vh; display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.auth-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; padding: 40px; max-width: 440px; width: 100%; }

/* ============= APP LAYOUT (sidebar + main) ============= */
#appLayout { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px; background: var(--bg-1); border-right: 1px solid var(--line);
    padding: 20px 16px; display: flex; flex-direction: column;
    position: fixed; left: 0; top: 0; bottom: 0; overflow-y: auto;
}
.sidebar .brand { padding: 6px 8px; margin-bottom: 24px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar-nav a {
    display: flex; align-items: center; padding: 10px 12px;
    border-radius: 8px; color: var(--text-2); font-size: 14px;
    font-weight: 500;
}
.sidebar-nav a:hover { background: var(--bg-2); color: var(--text); }
.sidebar-nav a.active { background: rgba(56,189,248,.1); color: var(--accent); }
.sidebar-nav a .icon { display: inline-block; width: 28px; font-size: 16px; }
.sidebar-nav a.nav-action {
    background: var(--accent); color: var(--bg-1); margin-top: 8px;
    justify-content: flex-start;
}
.sidebar-nav a.nav-action:hover { background: #7dd3fc; }
.sidebar-divider { height: 1px; background: var(--line); margin: 16px 0; }
.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }
#appMain {
    flex: 1; padding: 28px 40px; margin-left: 240px;
    max-width: calc(100vw - 240px);
}
/* ============= MOBILE (<= 768px) ============= */
@media (max-width: 768px) {
    /* Public nav: stack links below logo, reduce padding */
    .public-nav {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 12px 16px;
    }
    .public-nav-links {
        width: 100%;
        flex-wrap: wrap;
        gap: 10px 16px;
        font-size: 13px;
    }
    .brand { font-size: 16px; }

    /* Public main wrap */
    .public-main, #publicMain { padding: 0 16px; }

    /* Hero on mobile */
    .hero {
        padding: 48px 16px 32px;
    }
    .hero h1 { font-size: 32px; line-height: 1.15; }
    .hero p { font-size: 16px; }

    /* App layout: sidebar moves above content instead of fixed side */
    #appLayout { flex-direction: column; }
    .sidebar {
        position: relative; width: 100%; height: auto;
        padding: 12px 16px;
        flex-direction: column;
        border-right: none;
        border-bottom: 1px solid var(--line);
    }
    .sidebar .brand { margin-bottom: 8px; }
    .sidebar-nav {
        flex-direction: row; flex-wrap: wrap; gap: 4px;
    }
    .sidebar-nav a {
        padding: 8px 10px; font-size: 13px;
        flex: 0 0 auto;
    }
    .sidebar-nav a .icon { width: 20px; font-size: 14px; }
    .sidebar-divider { display: none; }
    .sidebar-footer {
        margin-top: 12px; padding-top: 12px; width: 100%;
        font-size: 12px;
    }
    .sidebar-legal { font-size: 10px; gap: 8px; padding: 8px 0 0; }
    #appMain {
        margin-left: 0;
        padding: 20px 16px;
        max-width: 100vw;
    }

    /* Page headers stack vertically */
    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .page-header h1 { font-size: 22px; }

    /* Stat cards stack */
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; }

    /* Tables scroll horizontally */
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    table { font-size: 13px; }
    table th, table td { padding: 8px 6px; }

    /* Modals fit screen */
    .modal-card {
        max-width: 95vw !important;
        margin: 16px;
        padding: 16px !important;
    }

    /* Public footer */
    .public-footer { padding: 24px 16px; }
    .footer-links { gap: 12px; font-size: 12px; }

    /* Buttons */
    .btn-large { padding: 12px 20px; font-size: 14px; }
    .btn-primary, .btn-secondary, .btn-ghost { padding: 10px 16px; font-size: 14px; }

    /* Forms */
    .form-input { font-size: 16px; padding: 10px 12px; }  /* 16px prevents iOS zoom on focus */
    .form-label { font-size: 13px; }
}

/* ============= TINY MOBILE (<= 380px) ============= */
@media (max-width: 380px) {
    .public-nav { padding: 10px 12px; }
    .public-nav-links { gap: 6px 12px; font-size: 12px; }
    .hero h1 { font-size: 26px; }
    .hero { padding: 32px 12px 24px; }
    #appMain { padding: 16px 12px; }
}

.page-header {
    display: flex; justify-content: space-between; align-items: flex-end;
    margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-size: 28px; letter-spacing: -0.01em; }
.page-header .subtitle { color: var(--text-2); font-size: 14px; margin-top: 4px; }

/* ============= PANELS / CARDS ============= */
.panel {
    background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
    padding: 24px; margin-bottom: 20px;
}
.panel h2 { color: var(--accent); font-size: 17px; margin-bottom: 16px; }

.stat-card {
    background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px;
    padding: 18px;
}
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--accent); line-height: 1.1; }
.stat-card .stat-label { font-size: 12px; color: var(--text-2); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .stat-sub { font-size: 12px; color: var(--text-3); margin-top: 6px; }

.user-pill {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    background: var(--bg-2); border-radius: 10px; font-size: 13px;
}
.user-pill .user-email { color: var(--text); font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.plan-badge {
    padding: 2px 10px; border-radius: 999px; font-weight: 600; font-size: 11px;
    text-transform: uppercase; letter-spacing: 0.05em;
}
.plan-free { background: rgba(148,163,184,.15); color: var(--text-2); }
.plan-starter { background: rgba(56,189,248,.15); color: var(--accent); }
.plan-pro { background: rgba(168,85,247,.15); color: var(--purple); }
.plan-agency { background: rgba(234,179,8,.15); color: var(--yellow); }

.badge {
    display: inline-block; padding: 3px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
}
.badge-blue { background: rgba(56,189,248,.15); color: var(--accent); }
.badge-green { background: rgba(34,197,94,.15); color: var(--green); }
.badge-red { background: rgba(239,68,68,.15); color: var(--red); }
.badge-yellow { background: rgba(234,179,8,.15); color: var(--yellow); }
.badge-purple { background: rgba(168,85,247,.15); color: var(--purple); }
.badge-gray { background: rgba(148,163,184,.15); color: var(--text-2); }

/* ============= TABLES ============= */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--text-2); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: rgba(56,189,248,.04); }
.table-wrap { background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.table-wrap table { font-size: 14px; }
.table-wrap th { padding: 14px 16px; background: var(--bg-1); }
.table-wrap td { padding: 14px 16px; }

.empty-state {
    text-align: center; padding: 60px 20px; color: var(--text-2);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.6; }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; color: var(--text); }
.empty-state p { margin-bottom: 24px; }

/* ============= WIZARD (4-step) ============= */
.progress-steps { display: flex; gap: 8px; margin-bottom: 24px; }
.step {
    flex: 1; padding: 12px; text-align: center;
    background: var(--bg-2); border: 1px solid var(--line);
    border-radius: 8px; font-size: 13px; color: var(--text-2);
    cursor: pointer; transition: all 0.15s;
}
.step.active { border-color: var(--accent); color: var(--accent); background: rgba(56,189,248,.05); }
.step.done { border-color: var(--green); color: var(--green); }
.step.disabled { opacity: 0.5; cursor: not-allowed; }

.file-drop {
    border: 2px dashed #475569; border-radius: 12px; padding: 40px;
    text-align: center; cursor: pointer; transition: border-color 0.2s;
}
.file-drop:hover { border-color: var(--accent); }
.file-drop.dragover { border-color: var(--accent); background: rgba(56, 189, 248, 0.05); }

.supplier-tag {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 16px; background: var(--bg-1); border: 1px solid var(--line);
    border-radius: 8px; margin-right: 8px; margin-bottom: 8px;
}
.supplier-tag .remove { cursor: pointer; color: var(--red); font-size: 18px; }

.mapping-row {
    display: grid; grid-template-columns: 1fr auto 1fr;
    gap: 12px; align-items: center;
    padding: 8px 0; border-bottom: 1px solid var(--line);
}
.mapping-row:last-child { border-bottom: none; }
.arrow { color: var(--accent); font-size: 18px; }

.field-category {
    margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--bg-3);
}
.field-category-title {
    font-size: 11px; font-weight: 700; color: var(--text-3);
    text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px;
}

.custom-field-row {
    display: grid; grid-template-columns: 1fr auto 1fr auto;
    gap: 12px; align-items: center; padding: 8px 0;
}

.transform-card {
    background: var(--bg-1); border: 1px solid var(--line); border-radius: 8px;
    padding: 16px; margin-bottom: 12px;
}

.quality-bar { height: 8px; background: var(--bg-3); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.quality-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }

.format-select { font-size: 15px; padding: 12px; border-width: 2px; }

/* ============= MODAL + TOAST ============= */
.modal-bg {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    display: none; align-items: center; justify-content: center; z-index: 100;
    padding: 20px;
}
.modal-bg.show { display: flex; }
.modal {
    background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px;
    padding: 32px; max-width: 900px; width: 100%; max-height: 90vh; overflow-y: auto;
}
.toast {
    position: fixed; bottom: 24px; right: 24px;
    background: var(--bg-2); border: 1px solid var(--line); padding: 14px 20px;
    border-radius: 8px; max-width: 360px; box-shadow: 0 10px 25px rgba(0,0,0,.4);
    opacity: 0; transform: translateY(20px); transition: all .25s;
    z-index: 1000;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: var(--red); }
.toast.success { border-color: var(--green); }

/* status pill colors */
.status-draft { background: rgba(148,163,184,.15); color: var(--text-2); }
.status-ready { background: rgba(56,189,248,.15); color: var(--accent); }
.status-exported { background: rgba(34,197,94,.15); color: var(--green); }
.status-archived { background: rgba(148,163,184,.1); color: var(--text-3); }
