:root {
    --bg: #f4f7f5;
    --surface: #ffffff;
    --surface-soft: #f8faf9;
    --surface-dark: #0d1712;
    --text: #152019;
    --muted: #67736d;
    --muted-2: #8a958f;
    --line: #dfe7e2;
    --line-strong: #cfdad4;
    --primary: #117a55;
    --primary-strong: #0a6042;
    --primary-soft: #e8f5ef;
    --excel: #176b45;
    --danger: #b42318;
    --danger-soft: #fff1f0;
    --warning: #b54708;
    --warning-soft: #fff8eb;
    --shadow-sm: 0 1px 2px rgba(16, 38, 28, .05), 0 8px 24px rgba(16, 38, 28, .05);
    --shadow-md: 0 18px 50px rgba(16, 38, 28, .10);
    --shadow-lg: 0 30px 90px rgba(5, 25, 16, .20);
    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 22px;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 5% 0%, rgba(17, 122, 85, .055), transparent 26rem),
        var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
svg { display: block; }
.hidden { display: none !important; }

/* Login */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    overflow: hidden;
    position: relative;
    padding: 24px;
    background: linear-gradient(145deg, #07110c 0%, #10231a 58%, #0d1913 100%);
}
.login-glow { position: absolute; border-radius: 999px; filter: blur(10px); opacity: .6; pointer-events: none; }
.login-glow-one { width: 440px; height: 440px; top: -190px; right: -120px; background: radial-gradient(circle, rgba(47, 184, 126, .28), transparent 70%); }
.login-glow-two { width: 380px; height: 380px; bottom: -190px; left: -130px; background: radial-gradient(circle, rgba(89, 141, 255, .16), transparent 70%); }
.login-card {
    width: min(460px, 100%);
    position: relative;
    z-index: 1;
    padding: 34px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 26px;
    background: rgba(255, 255, 255, .96);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(20px);
}
.login-brand { display: flex; align-items: center; gap: 14px; }
.login-brand h1 { margin: 3px 0 0; font-size: 1.35rem; line-height: 1.2; letter-spacing: -.025em; }
.eyebrow { display: block; color: var(--primary); font-size: .7rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.brand-symbol {
    width: 50px;
    height: 50px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    color: #fff;
    border-radius: 16px;
    background: linear-gradient(145deg, #1a9a6d, #0a6243);
    box-shadow: 0 12px 28px rgba(17, 122, 85, .28), inset 0 1px rgba(255,255,255,.28);
}
.brand-symbol svg { width: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.brand-symbol.small { width: 38px; height: 38px; border-radius: 12px; box-shadow: 0 8px 18px rgba(17, 122, 85, .2); }
.brand-symbol.small svg { width: 21px; }
.login-copy { margin: 22px 0 26px; color: var(--muted); line-height: 1.55; }
.login-footer { margin: 22px 0 0; color: var(--muted-2); font-size: .8rem; text-align: center; }
.login-footer strong { color: var(--muted); }
.alert { padding: 12px 14px; margin: 0 0 18px; border-radius: 11px; font-size: .9rem; }
.alert.error { color: var(--danger); background: var(--danger-soft); border: 1px solid #ffd3cf; }

/* Inputs and buttons */
.field-label, .form-group label, .discount-copy label {
    display: block;
    margin: 0 0 8px;
    font-size: .84rem;
    font-weight: 750;
    color: #253129;
}
input[type="text"], input[type="password"], textarea, select {
    width: 100%;
    color: var(--text);
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: #fff;
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
input[type="text"], input[type="password"], select { height: 46px; padding: 0 13px; }
textarea { min-height: 130px; padding: 13px; resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { border-color: #3aa77e; box-shadow: 0 0 0 4px rgba(17, 122, 85, .11); }
input::placeholder, textarea::placeholder { color: #a0aaa5; }
.input-with-icon { position: relative; }
.input-with-icon svg { width: 18px; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); fill: none; stroke: #7f8b84; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.input-with-icon input { padding-left: 42px; }
.btn {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 11px;
    cursor: pointer;
    font-weight: 760;
    font-size: .88rem;
    text-decoration: none;
    white-space: nowrap;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { color: #fff; background: linear-gradient(145deg, #16885f, #0d6b49); box-shadow: 0 9px 20px rgba(17, 122, 85, .18); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 12px 26px rgba(17, 122, 85, .25); }
.btn-secondary { color: #126546; background: var(--primary-soft); border-color: #cde9dc; }
.btn-soft { color: #435048; background: #f1f4f2; border-color: #e1e7e3; }
.btn-danger-ghost { color: var(--danger); background: #fff; border-color: #f0c7c3; }
.btn-excel { color: #fff; background: linear-gradient(145deg, #1d7b50, #125f3e); box-shadow: 0 10px 24px rgba(23, 107, 69, .2); }
.btn-block { width: 100%; margin-top: 18px; min-height: 48px; }

/* Header */
.app-header {
    position: sticky;
    top: 0;
    z-index: 30;
    height: 64px;
    color: #fff;
    background: rgba(10, 22, 16, .96);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    backdrop-filter: blur(16px);
    box-shadow: 0 8px 30px rgba(7, 20, 13, .13);
}
.header-inner { width: min(1560px, calc(100% - 32px)); height: 100%; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.compact-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-copy { min-width: 0; }
.brand-copy h1 { margin: 0; font-size: 1rem; line-height: 1.1; letter-spacing: -.01em; white-space: nowrap; }
.brand-copy span { display: block; margin-top: 3px; color: #9fb1a7; font-size: .7rem; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-action {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    color: #dbe5df;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 11px;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s ease, transform .15s ease;
}
.icon-action:hover { background: rgba(255,255,255,.13); transform: translateY(-1px); }
.icon-action svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.connection-badge {
    height: 34px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0 11px;
    color: #c5d2cb;
    background: rgba(255,255,255,.055);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 999px;
    font-size: .73rem;
    font-weight: 720;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #7d8c84; box-shadow: 0 0 0 4px rgba(125,140,132,.12); }
.connection-badge.connected .status-dot { background: #43cf8d; box-shadow: 0 0 0 4px rgba(67,207,141,.12); }
.connection-badge.failed .status-dot { background: #ff746c; box-shadow: 0 0 0 4px rgba(255,116,108,.12); }
.connection-badge.testing .status-dot { background: #f5c04a; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* Workspace */
.workspace { width: min(1560px, calc(100% - 32px)); margin: 22px auto 34px; display: grid; gap: 18px; }
.panel { background: rgba(255,255,255,.97); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.panel-heading, .results-top { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.input-panel, .results-panel { padding: 22px; }
.heading-group, .summary-title { display: flex; align-items: center; gap: 13px; }
.heading-group h2, .summary-title h2, .results-top h2 { margin: 0; font-size: 1.05rem; letter-spacing: -.012em; }
.heading-group p, .summary-title p, .results-top p { margin: 4px 0 0; color: var(--muted); font-size: .82rem; }
.step-chip {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    color: var(--primary);
    background: var(--primary-soft);
    border: 1px solid #d3ebdf;
    border-radius: 12px;
    font-size: .72rem;
    font-weight: 850;
    letter-spacing: .04em;
}

/* Collapsible columns */
.accordion-panel { overflow: hidden; }
.accordion-panel > summary {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px 20px;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.accordion-panel > summary::-webkit-details-marker { display: none; }
.accordion-panel[open] > summary { border-bottom: 1px solid var(--line); }
.summary-right { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.summary-hint { font-size: .78rem; }
.chevron { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; background: var(--surface-soft); border: 1px solid var(--line); transition: transform .2s ease; }
.chevron svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.accordion-panel[open] .chevron { transform: rotate(180deg); }
.accordion-content { padding: 18px 20px 20px; }
.template-bar { display: flex; align-items: flex-end; gap: 10px; padding: 14px; margin-bottom: 14px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 14px; }
.template-field { min-width: 180px; }
.template-field.grow { flex: 1 1 240px; }
.mini-label { display: block; margin: 0 0 6px; color: var(--muted); font-size: .72rem; font-weight: 740; }
.template-button { height: 46px; }
.column-builder { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 9px; }
.column-item {
    min-height: 52px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 9px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    transition: border-color .15s ease, box-shadow .15s ease, opacity .15s ease, transform .15s ease;
}
.column-item:has(input:checked) { border-color: #b9ddcc; background: #fbfefc; }
.column-item.dragging { opacity: .45; transform: scale(.98); }
.column-item.drag-over { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(17,122,85,.1); }
.drag-handle { width: 24px; height: 28px; display: grid; place-items: center; flex: 0 0 auto; color: #a3ada8; cursor: grab; }
.drag-handle:active { cursor: grabbing; }
.drag-handle svg { width: 17px; fill: currentColor; }
.switch-row { min-width: 0; flex: 1; display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: .84rem; font-weight: 700; }
.switch-row > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.custom-checkbox { width: 19px; height: 19px; display: grid; place-items: center; flex: 0 0 auto; color: transparent; background: #fff; border: 1.5px solid #bdc9c2; border-radius: 6px; transition: all .16s ease; }
.custom-checkbox svg { width: 13px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.switch-row input:checked + .custom-checkbox { color: #fff; background: var(--primary); border-color: var(--primary); box-shadow: 0 5px 12px rgba(17,122,85,.18); }
.order-actions { display: flex; gap: 3px; }
.micro-btn { width: 28px; height: 28px; display: grid; place-items: center; padding: 0; color: #66736c; background: #f7f9f8; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.micro-btn:hover { color: var(--primary); border-color: #bddbce; background: var(--primary-soft); }
.micro-btn svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Product input */
.discount-bar {
    display: grid;
    grid-template-columns: auto minmax(210px, 1fr) 130px auto;
    align-items: center;
    gap: 14px;
    padding: 14px;
    margin: 18px 0;
    background: linear-gradient(100deg, #f3faf7, #f9fbfa);
    border: 1px solid #d7ebe1;
    border-radius: 16px;
}
.discount-icon { width: 42px; height: 42px; display: grid; place-items: center; color: #fff; background: linear-gradient(145deg, #1b9569, #0d6a49); border-radius: 12px; font-size: 1.05rem; font-weight: 850; box-shadow: 0 8px 18px rgba(17,122,85,.17); }
.discount-copy label { margin-bottom: 3px; }
.discount-copy span { color: var(--muted); font-size: .75rem; }
.percentage-input { position: relative; }
.percentage-input input { padding-right: 34px; text-align: right; font-weight: 800; }
.percentage-input span { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .82rem; font-weight: 750; }
.entry-grid { display: grid; grid-template-columns: minmax(320px, .82fr) minmax(420px, 1.18fr); gap: 14px; }
.entry-card { padding: 16px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 16px; }
.entry-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.entry-card-head h3 { margin: 0; font-size: .91rem; }
.entry-card-head p { margin: 3px 0 0; color: var(--muted); font-size: .72rem; }
.entry-icon { width: 36px; height: 36px; display: grid; place-items: center; color: var(--primary); background: #fff; border: 1px solid #dbe8e1; border-radius: 10px; }
.entry-icon svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.single-input-row { display: flex; gap: 9px; }
.single-input-row input { min-width: 0; }
.bulk-entry-card textarea { min-height: 132px; background: #fff; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .84rem; }
.bulk-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.bulk-footer span { color: var(--muted); font-size: .75rem; }
.progress-area { margin-top: 16px; padding: 12px 14px; background: #f7faf8; border: 1px solid var(--line); border-radius: 13px; }
.progress-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; color: var(--muted); font-size: .75rem; }
.progress-meta strong { color: var(--primary); }
.progress-track { height: 8px; overflow: hidden; background: #e2ebe6; border-radius: 999px; }
.progress-track > div { width: 0; height: 100%; background: linear-gradient(90deg, #1ca572, #0d7250); border-radius: inherit; transition: width .2s ease; }

/* Results */
.results-top { margin-bottom: 16px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; margin-bottom: 14px; }
.stat-card { min-height: 76px; display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-soft); }
.stat-icon { width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 12px; }
.stat-icon svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.stat-card span:not(.stat-icon) { display: block; color: var(--muted); font-size: .72rem; font-weight: 650; }
.stat-card strong { display: block; margin-top: 2px; font-size: 1.45rem; line-height: 1; letter-spacing: -.03em; }
.stat-total .stat-icon { color: #3f5d4e; background: #e9efec; }
.stat-found { border-color: #d5ebdf; background: #f6fcf9; }
.stat-found .stat-icon { color: var(--primary); background: var(--primary-soft); }
.stat-found strong { color: var(--primary-strong); }
.stat-missing { border-color: #f0ddd9; background: #fffafa; }
.stat-missing .stat-icon { color: var(--danger); background: var(--danger-soft); }
.stat-missing strong { color: var(--danger); }
.table-shell { position: relative; min-height: 190px; overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 16px; }
.empty-state { min-height: 230px; display: grid; place-items: center; align-content: center; text-align: center; padding: 28px; }
.empty-icon { width: 52px; height: 52px; display: grid; place-items: center; color: #7c8b83; background: #f1f5f3; border-radius: 16px; }
.empty-icon svg { width: 25px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.empty-state h3 { margin: 13px 0 5px; font-size: .95rem; }
.empty-state p { margin: 0; color: var(--muted); font-size: .78rem; }
.table-wrap { max-height: 64vh; overflow: auto; }
table { width: 100%; min-width: 1000px; border-collapse: separate; border-spacing: 0; }
th, td { border-bottom: 1px solid var(--line); border-right: 1px solid #edf1ef; text-align: left; vertical-align: top; }
th:last-child, td:last-child { border-right: 0; }
th {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 12px 11px;
    color: #f2f7f4;
    background: #10241a;
    font-size: .72rem;
    font-weight: 780;
    letter-spacing: .02em;
    white-space: nowrap;
    box-shadow: inset 0 -1px rgba(255,255,255,.04);
}
td { padding: 7px; background: #fff; font-size: .8rem; }
tbody tr:nth-child(even):not(.row-missing) td { background: #fbfcfb; }
tbody tr:hover td { background: #f5faf7; }
tbody tr.row-missing td { background: #fff8f7; }
tbody tr:last-child td { border-bottom: 0; }
.row-number-head, .row-number { width: 48px; min-width: 48px; text-align: center; }
.row-number { padding-top: 18px; color: #8a958f; font-size: .72rem; font-weight: 730; }
.row-action-head, .row-action { width: 48px; min-width: 48px; text-align: center; }
td input, td textarea { min-width: 125px; min-height: 36px; height: 36px; padding: 7px 8px; color: #29342e; background: transparent; border-color: transparent; border-radius: 8px; font-size: .78rem; }
td textarea { min-width: 210px; height: 54px; min-height: 54px; resize: vertical; line-height: 1.35; }
td input:focus, td textarea:focus { background: #fff; border-color: #55ae89; box-shadow: 0 0 0 3px rgba(17,122,85,.1); }
td[data-field="sku"] input, td[data-field="barcode"] input { min-width: 112px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
td[data-field="handle"] input { min-width: 145px; }
td[data-field="vendor"] input, td[data-field="product_type"] input { min-width: 140px; }
td[data-field="product_id"] input, td[data-field="variant_id"] input { min-width: 250px; font-size: .72rem; color: #66736c; }
td[data-field="discount"] input { min-width: 88px; max-width: 105px; text-align: center; font-weight: 800; color: var(--primary-strong); background: #f2faf6; border-color: #d7ebe1; }
.lookup-badge { display: inline-flex; align-items: center; gap: 6px; min-width: 86px; margin: 7px 3px; padding: 6px 9px; border-radius: 999px; font-size: .7rem; font-weight: 780; }
.lookup-badge.found { color: #0c6c49; background: #e8f6ef; }
.lookup-badge.missing { color: var(--danger); background: var(--danger-soft); }
.lookup-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.remove-row { width: 30px; height: 30px; display: grid; place-items: center; margin: 4px auto 0; color: #a74b43; background: #fff4f3; border: 1px solid #f2d5d2; border-radius: 9px; cursor: pointer; transition: color .15s ease, background .15s ease; }
.remove-row:hover { color: #fff; background: var(--danger); border-color: var(--danger); }
.remove-row svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(4, 14, 9, .68); backdrop-filter: blur(8px); }
.modal-card { width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: #fff; border: 1px solid rgba(255,255,255,.5); border-radius: 22px; box-shadow: var(--shadow-lg); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 23px 23px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 4px 0 0; font-size: 1.18rem; }
.modal-head p { margin: 5px 0 0; color: var(--muted); font-size: .78rem; }
.modal-close { width: 34px; height: 34px; display: grid; place-items: center; color: #64716a; background: #f4f6f5; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.modal-close svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.settings-form { padding: 20px 23px 23px; }
.form-group { margin-bottom: 16px; }
.form-group.compact-group { max-width: 220px; }
.field-hint { display: block; margin-top: 6px; color: var(--muted); font-size: .7rem; }
.connection-result { margin: 4px 0 16px; padding: 11px 12px; border-radius: 11px; font-size: .77rem; line-height: 1.4; }
.connection-result.success { color: #0c6948; background: #ebf8f1; border: 1px solid #cdebdc; }
.connection-result.error { color: var(--danger); background: var(--danger-soft); border: 1px solid #f2d2cf; }
.connection-result.testing { color: var(--warning); background: var(--warning-soft); border: 1px solid #f1e0ba; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }

/* Footer and toast */
.app-footer { padding: 0 20px 24px; color: #87928c; font-size: .72rem; text-align: center; }
.app-footer strong { color: #64716a; }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 120; max-width: min(430px, calc(100% - 36px)); padding: 13px 15px; color: #fff; background: #14251c; border: 1px solid rgba(255,255,255,.1); border-radius: 12px; box-shadow: var(--shadow-md); font-size: .82rem; line-height: 1.45; }
.toast.error { background: #8f251d; }

@media (max-width: 980px) {
    .entry-grid { grid-template-columns: 1fr; }
    .discount-bar { grid-template-columns: auto 1fr 120px; }
    .discount-bar .btn { grid-column: 2 / -1; justify-self: start; }
    .template-bar { flex-wrap: wrap; }
    .template-button { flex: 1 1 140px; }
}

@media (max-width: 720px) {
    .header-inner, .workspace { width: min(100% - 20px, 1560px); }
    .brand-copy span, .connection-text { display: none; }
    .connection-badge { width: 34px; justify-content: center; padding: 0; }
    .input-panel, .results-panel { padding: 16px; }
    .panel-heading, .results-top { align-items: flex-start; }
    .panel-heading { flex-direction: column; }
    .panel-heading > .btn { align-self: flex-end; margin-top: -45px; }
    .results-top { flex-direction: column; }
    .results-top .btn-excel { width: 100%; }
    .summary-hint { display: none; }
    .accordion-panel > summary { padding: 14px 15px; }
    .accordion-content { padding: 14px 15px 16px; }
    .template-bar { padding: 11px; }
    .template-field.grow { flex-basis: 100%; }
    .column-builder { grid-template-columns: 1fr; }
    .discount-bar { grid-template-columns: auto 1fr; }
    .percentage-input { grid-column: 1 / 2; }
    .discount-bar .btn { grid-column: 2 / 3; align-self: stretch; }
    .stats-grid { grid-template-columns: 1fr; }
    .stat-card { min-height: 66px; }
    .single-input-row { flex-direction: column; }
    .single-input-row .btn { width: 100%; }
    .bulk-footer { align-items: flex-end; }
    .bulk-footer .btn { min-width: 150px; }
    .modal-actions { flex-direction: column-reverse; }
    .modal-actions .btn { width: 100%; }
}

@media (max-width: 460px) {
    .login-card { padding: 26px 22px; border-radius: 22px; }
    .brand-copy h1 { font-size: .88rem; }
    .panel-heading > .btn { align-self: stretch; margin-top: 0; }
    .discount-bar { grid-template-columns: auto 1fr; gap: 10px; }
    .percentage-input, .discount-bar .btn { grid-column: 1 / -1; }
    .discount-bar .btn { width: 100%; }
    .bulk-footer { flex-direction: column; align-items: stretch; }
    .bulk-footer .btn { width: 100%; }
    .heading-group p, .summary-title p, .results-top p { max-width: 230px; }
}

/* =========================================================
   Premium v2.1 — bounded data grid, smart controls and polish
   ========================================================= */
html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
body {
    background:
        radial-gradient(circle at 8% -8%, rgba(21, 143, 98, .10), transparent 30rem),
        radial-gradient(circle at 95% 12%, rgba(38, 96, 75, .07), transparent 34rem),
        linear-gradient(180deg, #f5f8f6 0%, #eef3f0 100%);
}
.app-header {
    height: 60px;
    background: linear-gradient(100deg, rgba(8, 20, 14, .985), rgba(13, 37, 26, .97));
    box-shadow: 0 10px 34px rgba(7, 25, 15, .16);
}
.header-inner,
.workspace {
    width: min(1440px, calc(100% - 28px));
    max-width: 100%;
    min-width: 0;
}
.workspace { margin-top: 18px; gap: 16px; }
.panel,
.input-panel,
.results-panel,
.accordion-panel,
.table-shell,
.table-wrap,
.entry-grid,
.entry-card,
.smart-controls,
.smart-control { min-width: 0; max-width: 100%; }
.panel {
    position: relative;
    border-color: rgba(201, 216, 208, .88);
    background: linear-gradient(180deg, rgba(255,255,255,.995), rgba(252,254,253,.98));
    box-shadow: 0 2px 4px rgba(16, 38, 28, .035), 0 18px 48px rgba(16, 38, 28, .055);
}
.panel::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    box-shadow: inset 0 1px rgba(255,255,255,.9);
}
.input-panel,
.results-panel { padding: 20px; }
.step-chip {
    background: linear-gradient(145deg, #effaf5, #dff2e9);
    box-shadow: inset 0 1px #fff, 0 7px 16px rgba(17,122,85,.08);
}
.btn { box-shadow: inset 0 1px rgba(255,255,255,.28); }
.btn-control {
    color: #174c37;
    background: linear-gradient(180deg, #ffffff, #edf5f1);
    border-color: #cfe1d7;
    box-shadow: inset 0 1px #fff, 0 7px 16px rgba(31, 78, 56, .08);
}
.btn-control:hover:not(:disabled) {
    color: #0d6847;
    border-color: #9fcdb8;
    background: linear-gradient(180deg, #ffffff, #e7f5ee);
}
.button-spinner {
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255,255,255,.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: buttonSpin .7s linear infinite;
}
@keyframes buttonSpin { to { transform: rotate(360deg); } }

/* Smart control deck */
.smart-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 13px;
    margin: 17px 0;
}
.smart-control {
    position: relative;
    isolation: isolate;
    display: grid;
    grid-template-columns: 48px minmax(170px, 1fr) minmax(230px, auto);
    align-items: center;
    gap: 13px;
    min-height: 92px;
    padding: 14px;
    overflow: hidden;
    border: 1px solid #d7e5dd;
    border-radius: 18px;
    background: linear-gradient(145deg, rgba(255,255,255,.98), rgba(243,249,246,.97));
    box-shadow:
        inset 0 1px rgba(255,255,255,.98),
        inset 0 -1px rgba(190,210,199,.28),
        0 10px 28px rgba(20, 62, 42, .07);
}
.smart-control::before {
    content: "";
    position: absolute;
    z-index: -1;
    width: 210px;
    height: 210px;
    right: -110px;
    top: -140px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(30, 157, 106, .12), transparent 68%);
}
.duplicate-control-card::before { background: radial-gradient(circle, rgba(63, 103, 175, .10), transparent 68%); }
.control-orb {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    color: #fff;
    border-radius: 15px;
    box-shadow: inset 0 1px rgba(255,255,255,.35), 0 11px 22px rgba(15, 91, 60, .19);
}
.discount-orb { background: linear-gradient(145deg, #21a878, #0c704d); }
.discount-orb span { font-size: 1.08rem; font-weight: 900; }
.duplicate-orb { background: linear-gradient(145deg, #4979a9, #294f75); box-shadow: inset 0 1px rgba(255,255,255,.32), 0 11px 22px rgba(41,79,117,.18); }
.duplicate-orb svg { width: 25px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.control-copy { min-width: 0; }
.control-kicker {
    display: block;
    margin-bottom: 3px;
    color: #15805a;
    font-size: .63rem;
    font-weight: 850;
    letter-spacing: .11em;
    text-transform: uppercase;
}
.duplicate-control-card .control-kicker { color: #416a91; }
.control-copy label {
    display: block;
    margin: 0;
    color: #1a2a21;
    font-size: .9rem;
    font-weight: 820;
    letter-spacing: -.01em;
}
.control-copy p {
    margin: 5px 0 0;
    color: #6b7871;
    font-size: .72rem;
    line-height: 1.35;
}
.control-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    min-width: 0;
}
.premium-input { width: 100px; flex: 0 0 100px; }
.premium-input input {
    height: 44px;
    padding: 0 32px 0 12px;
    color: #0b6746;
    border-color: #b9d8ca;
    background: linear-gradient(180deg, #fff, #f3faf6);
    box-shadow: inset 0 2px 5px rgba(19, 80, 51, .055), 0 5px 14px rgba(20, 72, 47, .05);
    font-size: 1rem;
    text-align: center;
}
.duplicate-actions {
    min-width: 225px;
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
}
.duplicate-actions select {
    height: 44px;
    padding: 0 36px 0 12px;
    color: #27465f;
    border-color: #c9d9e6;
    background-color: #fff;
    font-size: .8rem;
    font-weight: 760;
}
.control-note {
    color: #7b8981;
    font-size: .64rem;
    line-height: 1.25;
    text-align: right;
}

/* Elevated entry cards */
.entry-card {
    background: linear-gradient(145deg, #fafcfb, #f3f7f5);
    box-shadow: inset 0 1px #fff, 0 9px 22px rgba(20, 55, 38, .045);
}
.entry-icon { box-shadow: inset 0 1px #fff, 0 7px 14px rgba(26, 78, 53, .055); }
.bulk-metrics { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; min-width: 0; }
.duplicate-detected {
    display: inline-flex;
    align-items: center;
    min-height: 23px;
    padding: 0 8px;
    color: #9b5c0b;
    background: #fff6e6;
    border: 1px solid #f0d9aa;
    border-radius: 999px;
    font-size: .67rem !important;
    font-weight: 760;
}

/* More prominent result counters */
.stats-grid { gap: 12px; }
.stat-card {
    min-height: 80px;
    position: relative;
    overflow: hidden;
    border-radius: 17px;
    box-shadow: inset 0 1px #fff, 0 8px 20px rgba(22, 58, 40, .045);
}
.stat-card::after {
    content: "";
    position: absolute;
    width: 90px;
    height: 90px;
    right: -38px;
    top: -50px;
    border-radius: 50%;
    background: rgba(72, 125, 96, .055);
}
.stat-card strong { font-size: 1.62rem; }
.stat-found { background: linear-gradient(145deg, #f9fdfa, #eff9f4); }
.stat-missing { background: linear-gradient(145deg, #fffdfd, #fff4f2); }

/* Root-level table containment: wide tables scroll inside the panel only */
.results-panel { overflow: hidden; }
.table-shell {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    isolation: isolate;
    border-color: #d8e2dc;
    box-shadow: inset 0 1px #fff, 0 10px 30px rgba(17, 48, 32, .055);
}
.table-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    max-height: min(62vh, 720px);
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    background: #fff;
    outline: none;
    -webkit-overflow-scrolling: touch;
    scrollbar-color: #94b4a4 #edf3f0;
    scrollbar-width: thin;
}
.table-wrap:focus-visible { box-shadow: inset 0 0 0 3px rgba(17,122,85,.12); }
.table-wrap::-webkit-scrollbar { width: 12px; height: 12px; }
.table-wrap::-webkit-scrollbar-track { background: #edf3f0; }
.table-wrap::-webkit-scrollbar-thumb { background: #9bb7a9; border: 3px solid #edf3f0; border-radius: 999px; }
.table-wrap::-webkit-scrollbar-thumb:hover { background: #6f9b84; }
#resultTable {
    width: var(--table-content-width, 1000px);
    min-width: 100%;
    max-width: none;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
}
#resultTable th,
#resultTable td {
    width: auto;
    max-width: none;
    overflow: hidden;
}
#resultTable th {
    height: 44px;
    padding: 0 11px;
    vertical-align: middle;
    color: #f4faf6;
    background: linear-gradient(180deg, #173428, #10251b);
    border-right-color: rgba(255,255,255,.07);
    box-shadow: inset 0 1px rgba(255,255,255,.045), inset 0 -1px rgba(0,0,0,.18);
}
#resultTable td { padding: 7px; }
#resultTable td input,
#resultTable td textarea {
    width: 100%;
    max-width: 100%;
    min-width: 0 !important;
    border: 1px solid transparent;
}
#resultTable td textarea { min-width: 0 !important; }
#resultTable td[data-field="product_id"] input,
#resultTable td[data-field="variant_id"] input { min-width: 0 !important; }
.row-number-head,
.row-number {
    position: sticky;
    left: 0;
}
.row-number-head { z-index: 13 !important; background: linear-gradient(180deg, #153026, #0d2118) !important; }
.row-number {
    z-index: 5;
    background: #f4f7f5 !important;
    box-shadow: 1px 0 #e2e9e5;
}
.sticky-data-head {
    position: sticky;
    left: 52px;
    z-index: 12 !important;
    box-shadow: 8px 0 16px -13px rgba(3, 20, 11, .9), inset 0 -1px rgba(0,0,0,.18) !important;
}
.sticky-data-cell {
    position: sticky;
    left: 52px;
    z-index: 4;
    background: #fff !important;
    box-shadow: 8px 0 16px -13px rgba(12, 38, 23, .42);
}
tbody tr:nth-child(even):not(.row-missing) .sticky-data-cell { background: #fbfcfb !important; }
tbody tr:hover .sticky-data-cell { background: #f5faf7 !important; }
tbody tr.row-missing .sticky-data-cell { background: #fff8f7 !important; }
.row-action-head,
.row-action {
    position: sticky;
    right: 0;
}
.row-action-head { z-index: 13 !important; background: linear-gradient(180deg, #153026, #0d2118) !important; }
.row-action {
    z-index: 5;
    background: #fff !important;
    box-shadow: -8px 0 16px -13px rgba(12, 38, 23, .42);
}
tbody tr:nth-child(even):not(.row-missing) .row-action { background: #fbfcfb !important; }
tbody tr:hover .row-action { background: #f5faf7 !important; }
tbody tr.row-missing .row-action { background: #fff8f7 !important; }
#resultTable td[data-field="discount"] input {
    min-width: 0;
    max-width: 100%;
    background: linear-gradient(180deg, #f5fcf8, #eaf7f0);
    box-shadow: inset 0 1px #fff;
}
.lookup-badge { min-width: 0; width: calc(100% - 6px); justify-content: center; }

@media (max-width: 1180px) {
    .smart-controls { grid-template-columns: 1fr; }
    .smart-control { grid-template-columns: 48px minmax(170px, 1fr) minmax(260px, auto); }
}

@media (max-width: 760px) {
    .header-inner, .workspace { width: min(100% - 18px, 1440px); }
    .smart-control {
        grid-template-columns: 44px minmax(0, 1fr);
        padding: 13px;
    }
    .control-orb { width: 44px; height: 44px; border-radius: 14px; }
    .control-actions {
        grid-column: 1 / -1;
        justify-content: stretch;
        padding-top: 2px;
    }
    .discount-actions .premium-input { flex: 1 1 110px; width: auto; }
    .discount-actions .btn { flex: 1 1 160px; }
    .duplicate-actions { min-width: 0; }
    .control-note { text-align: left; }
    .table-wrap { max-height: 66vh; }
}

@media (max-width: 480px) {
    .input-panel, .results-panel { padding: 14px; }
    .smart-controls { margin: 14px 0; gap: 10px; }
    .discount-actions { flex-direction: column; align-items: stretch; }
    .discount-actions .premium-input { width: 100%; flex-basis: auto; }
    .discount-actions .btn { width: 100%; }
    .bulk-metrics { align-items: flex-start; flex-direction: column; gap: 5px; }
}
