:root {
    --blue:       #00488d;
    --blue-mid:   #005fb8;
    --blue-light: #d6e3ff;
    --orange:     #fc6018;
    --ink:        #0d0f12;
    --ink-soft:   #424752;
    --surface:    #f9f9fc;
    --surface-2:  #f3f3f6;
    --surface-3:  #e8e8ea;
    --surface-4:  #e2e2e5;
    --border:     #c2c6d4;
    --white:      #ffffff;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: 'DM Sans', sans-serif; background: var(--surface); color: var(--ink); min-height: 100vh; display: flex; flex-direction: column; }

/* ── NAV ── */
nav {
    position: sticky; top: 0; z-index: 100;
    background: var(--surface-4);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 2rem; height: 56px;
    justify-content: space-between;
}
.nav-left { display: flex; align-items: center; gap: 2.5rem; }
.nav-brand { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 1.2rem; color: var(--blue); letter-spacing: -0.03em; text-decoration: none; }
.nav-links { display: flex; gap: 1.5rem; }
.nav-links a { font-family: 'Syne', sans-serif; font-size: .875rem; font-weight: 600; color: var(--ink-soft); text-decoration: none; padding-bottom: 2px; transition: color .15s; }
.nav-links a.active { color: var(--blue); border-bottom: 2px solid var(--blue); }
.nav-links a:hover { color: var(--blue); }

/* Hamburger */
.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: .4rem; border-radius: 4px; color: var(--ink); transition: background .15s; }
.nav-toggle:hover { background: var(--surface-3); }
.nav-toggle svg { display: block; }

/* Mobile drawer */
.nav-drawer {
    display: none;
    position: fixed; top: 56px; left: 0; right: 0;
    background: var(--surface-4);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    flex-direction: column; gap: .25rem;
    z-index: 99;
    box-shadow: 0 8px 24px rgba(0,0,0,.08);
}
.nav-drawer.open { display: flex; }
.nav-drawer a { font-family: 'Syne', sans-serif; font-size: .9rem; font-weight: 600; color: var(--ink-soft); text-decoration: none; padding: .65rem .75rem; border-radius: 6px; transition: background .15s, color .15s; }
.nav-drawer a:hover { background: var(--surface-3); color: var(--blue); }
.nav-drawer a.active { color: var(--blue); background: var(--surface-3); }

/* ── HERO ── */
.hero { background: var(--ink); color: var(--white); padding: 5rem 2rem 0; position: relative; overflow: hidden; }
.hero::before { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse 60% 50% at 70% -10%, rgba(0,95,184,.35) 0%, transparent 70%), radial-gradient(ellipse 40% 40% at 10% 110%, rgba(252,96,24,.15) 0%, transparent 60%); pointer-events: none; }
.hero::after { content: ''; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px); background-size: 40px 40px; pointer-events: none; }
.hero-inner { max-width: 1100px; margin: 0 auto; position: relative; z-index: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 4rem; align-items: center; }
.hero-badge { display: inline-flex; align-items: center; gap: .5rem; background: rgba(252,96,24,.15); border: 1px solid rgba(252,96,24,.3); color: #ff8f57; font-family: 'DM Mono', monospace; font-size: .65rem; font-weight: 500; letter-spacing: .15em; text-transform: uppercase; padding: .35rem .75rem; border-radius: 999px; margin-bottom: 1.5rem; }
.hero-badge span { width: 6px; height: 6px; border-radius: 50%; background: var(--orange); }
.hero h1 { font-family: 'Syne', sans-serif; font-size: clamp(2rem, 4vw, 3rem); font-weight: 800; line-height: 1.1; letter-spacing: -.04em; margin-bottom: 1.25rem; }
.hero h1 em { font-style: normal; background: linear-gradient(90deg, #60a5fa, #93c5fd); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.hero-desc { font-size: 1rem; line-height: 1.7; color: rgba(255,255,255,.65); margin-bottom: 2rem; max-width: 440px; }
.hero-pills { display: flex; flex-wrap: wrap; gap: .5rem; }
.hero-pill { display: flex; align-items: center; gap: .4rem; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); color: rgba(255,255,255,.8); font-family: 'DM Mono', monospace; font-size: .7rem; padding: .4rem .75rem; border-radius: 4px; }
.hero-pill svg { opacity: .6; }
.hero-cards { display: flex; flex-direction: column; gap: .75rem; }
.diff-card { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); border-radius: 8px; padding: 1.25rem 1.5rem; display: flex; gap: 1rem; align-items: flex-start; transition: background .2s, border-color .2s; animation: slideIn .5s ease both; }
.diff-card:nth-child(1) { animation-delay: .1s; }
.diff-card:nth-child(2) { animation-delay: .2s; }
.diff-card:nth-child(3) { animation-delay: .3s; }
.diff-card:hover { background: rgba(255,255,255,.09); border-color: rgba(255,255,255,.15); }
.diff-icon { width: 36px; height: 36px; flex-shrink: 0; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1rem; }
.diff-icon.blue  { background: rgba(0,95,184,.3); }
.diff-icon.orange { background: rgba(252,96,24,.2); }
.diff-icon.slate { background: rgba(255,255,255,.1); }
.diff-card h3 { font-family: 'Syne', sans-serif; font-size: .85rem; font-weight: 700; color: var(--white); margin-bottom: .25rem; }
.diff-card p { font-size: .78rem; line-height: 1.5; color: rgba(255,255,255,.5); }
.hero-wave { margin-top: 4rem; display: block; width: 100%; height: 48px; background: var(--surface); clip-path: ellipse(55% 100% at 50% 100%); }

/* ── WORKSPACE ── */
.workspace { max-width: 1100px; margin: 0 auto; padding: 3rem 2rem; flex: 1; display: flex; flex-direction: column; gap: 2rem; }
.section-label { font-family: 'DM Mono', monospace; font-size: .6rem; letter-spacing: .2em; text-transform: uppercase; color: var(--blue); font-weight: 500; margin-bottom: .35rem; }
.section-title { font-family: 'Syne', sans-serif; font-size: 1.5rem; font-weight: 800; letter-spacing: -.03em; }
.workspace-grid { display: grid; grid-template-columns: 1fr 340px; gap: 1.5rem; align-items: start; }

/* upload zone */
.upload-zone { background: var(--surface-2); border: 2px dashed var(--border); border-radius: 10px; padding: 3.5rem 2rem; text-align: center; cursor: pointer; transition: border-color .2s, background .2s; position: relative; overflow: hidden; }
.upload-zone:hover, .upload-zone.dragover { border-color: var(--blue); background: #eef4ff; }
.upload-zone.has-file { border-style: solid; border-color: var(--blue); background: #eef4ff; }
.upload-icon { width: 56px; height: 56px; background: var(--surface-4); border-radius: 10px; display: flex; align-items: center; justify-content: center; margin: 0 auto 1.25rem; transition: transform .2s; }
.upload-zone:hover .upload-icon { transform: scale(1.08); }
.upload-icon svg { color: var(--blue); }
.upload-title { font-family: 'Syne', sans-serif; font-size: 1rem; font-weight: 700; margin-bottom: .35rem; }
.upload-sub { font-family: 'DM Mono', monospace; font-size: .65rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }
#fileInput { display: none; }

/* file bar */
.file-bar { display: none; margin-top: 1.25rem; background: var(--white); border: 1px solid var(--border); border-radius: 6px; padding: .75rem 1rem; align-items: center; gap: .75rem; }
.file-bar.visible { display: flex; }
.file-bar-name { font-family: 'DM Mono', monospace; font-size: .78rem; color: var(--blue); font-weight: 500; flex: 1; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.file-bar-size { font-family: 'DM Mono', monospace; font-size: .72rem; color: var(--ink-soft); white-space: nowrap; }

/* buttons */
.btn-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.5rem; }
.btn-primary { display: inline-flex; align-items: center; gap: .5rem; background: linear-gradient(135deg, var(--blue), var(--blue-mid)); color: var(--white); font-family: 'Syne', sans-serif; font-size: .875rem; font-weight: 700; padding: .75rem 1.75rem; border-radius: 6px; border: none; cursor: pointer; transition: opacity .15s, transform .1s, box-shadow .2s; box-shadow: 0 4px 14px rgba(0,72,141,.25); }
.btn-primary:hover:not(:disabled) { opacity: .9; box-shadow: 0 6px 20px rgba(0,72,141,.35); }
.btn-primary:active:not(:disabled) { transform: scale(.97); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.btn-ghost { display: inline-flex; align-items: center; gap: .4rem; background: transparent; color: var(--ink-soft); font-family: 'DM Sans', sans-serif; font-size: .8rem; font-weight: 500; padding: .5rem .9rem; border-radius: 5px; border: 1px solid var(--border); cursor: pointer; transition: background .15s, color .15s; }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); }

/* HUD */
.hud-panel { background: var(--surface-4); border-radius: 10px; padding: 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; }
.hud-label { font-family: 'DM Mono', monospace; font-size: .6rem; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-soft); font-weight: 500; margin-bottom: .75rem; }
.hud-stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.hud-stat { background: var(--white); border: 1px solid rgba(194,198,212,.4); border-radius: 6px; padding: .85rem; }
.hud-stat-label { font-family: 'DM Mono', monospace; font-size: .55rem; letter-spacing: .15em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: .3rem; }
.hud-stat-val { font-family: 'Syne', sans-serif; font-size: 1.4rem; font-weight: 800; color: var(--ink); }
.hud-stat-val.blue { color: var(--blue); }
.status-row { display: flex; align-items: center; justify-content: space-between; font-size: .78rem; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2); animation: pulse 2s infinite; }
.status-dot.orange { background: var(--orange); box-shadow: 0 0 0 3px rgba(252,96,24,.2); }
.status-dot.blue { background: var(--blue); box-shadow: 0 0 0 3px rgba(0,72,141,.2); }
.insight-card { background: var(--ink); color: var(--white); border-radius: 8px; padding: 1.25rem; position: relative; overflow: hidden; }
.insight-card-label { font-family: 'DM Mono', monospace; font-size: .6rem; letter-spacing: .15em; text-transform: uppercase; color: rgba(255,255,255,.4); margin-bottom: .5rem; }
.insight-card p { font-size: .8rem; line-height: 1.6; color: rgba(255,255,255,.75); }
.insight-icon { position: absolute; bottom: -8px; right: -4px; font-size: 4rem; opacity: .07; color: var(--white); font-family: 'DM Mono', monospace; font-weight: 500; line-height: 1; }

/* loading */
#loading { display: none; text-align: center; padding: 2.5rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
#loading.visible { display: block; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; margin: 0 auto .75rem; }
.loading-text { font-family: 'DM Mono', monospace; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); }

/* error */
.error-bar { display: none; background: #fef2f2; border: 1px solid #fca5a5; border-radius: 6px; padding: .85rem 1.1rem; font-size: .82rem; color: #991b1b; align-items: center; gap: .6rem; }
.error-bar.visible { display: flex; }

/* results */
#results { display: none; }
#results.visible { display: block; }
.results-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem; margin-bottom: 1rem; }
.results-title { font-family: 'Syne', sans-serif; font-size: 1.1rem; font-weight: 800; letter-spacing: -.02em; display: flex; align-items: center; gap: .75rem; }
.live-badge { font-family: 'DM Mono', monospace; font-size: .6rem; letter-spacing: .12em; text-transform: uppercase; background: var(--orange); color: var(--white); padding: .25rem .6rem; border-radius: 4px; font-weight: 500; }
.export-btns { display: flex; gap: .5rem; flex-wrap: wrap; }
.btn-export { display: flex; align-items: center; gap: .5rem; background: var(--surface-3); border: 1px solid var(--border); color: var(--blue); font-family: 'Syne', sans-serif; font-size: .75rem; font-weight: 700; padding: .5rem 1rem; border-radius: 5px; cursor: pointer; transition: background .15s; }
.btn-export:hover { background: var(--surface-4); }
.btn-export-pdf { color: var(--orange); border-color: rgba(252,96,24,.3); background: rgba(252,96,24,.05); }
.btn-export-pdf:hover { background: rgba(252,96,24,.1); }

/* table */
.table-wrap { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap table { width: 100%; border-collapse: collapse; min-width: 560px; }
thead tr { background: var(--surface-4); }
thead th { padding: .9rem 1.25rem; font-family: 'DM Mono', monospace; font-size: .6rem; letter-spacing: .15em; text-transform: uppercase; color: var(--ink-soft); font-weight: 500; text-align: left; white-space: nowrap; }
tbody tr { border-top: 1px solid rgba(194,198,212,.3); transition: background .15s; }
tbody tr:nth-child(even) { background: var(--white); }
tbody tr:hover { background: #eef4ff; }
tbody td { padding: .85rem 1.25rem; font-size: .82rem; color: var(--ink); vertical-align: middle; }
td.num { font-family: 'DM Mono', monospace; font-size: .72rem; color: var(--ink-soft); }
td.qty { font-family: 'Syne', sans-serif; font-weight: 700; font-size: .9rem; }
td.mono { font-family: 'DM Mono', monospace; font-size: .72rem; color: var(--ink-soft); }
.cat-badge { display: inline-block; font-family: 'DM Mono', monospace; font-size: .6rem; letter-spacing: .08em; text-transform: uppercase; background: var(--surface-4); border: 1px solid var(--border); padding: .25rem .6rem; border-radius: 3px; white-space: nowrap; }

/* footer */
footer { background: var(--surface-3); border-top: 1px solid var(--border); padding: 1.75rem 2rem; display: flex; justify-content: space-between; align-items: center; margin-top: auto; flex-wrap: wrap; gap: 1rem; }
.footer-brand { font-family: 'Syne', sans-serif; font-size: .8rem; font-weight: 700; color: var(--ink-soft); }
.footer-copy { font-size: .72rem; color: var(--ink-soft); margin-top: .2rem; }
.footer-link { font-family: 'DM Mono', monospace; font-size: .6rem; letter-spacing: .15em; text-transform: uppercase; color: var(--ink-soft); text-decoration: none; transition: color .15s; }
.footer-link:hover { color: var(--blue); }

/* animations */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 3px rgba(34,197,94,.2); } 50% { box-shadow: 0 0 0 6px rgba(34,197,94,.05); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.fade-up { animation: fadeUp .4s ease both; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
    nav { padding: 0 1.25rem; }
    .nav-links { display: none; }
    .nav-toggle { display: flex; }

    .hero { padding: 3rem 1.25rem 0; }
    .hero-inner { grid-template-columns: 1fr; gap: 2rem; padding-bottom: 3rem; }
    .hero-cards { display: none; }
    .hero h1 { font-size: clamp(1.75rem, 7vw, 2.5rem); }
    .hero-wave { margin-top: 2rem; }

    .workspace { padding: 2rem 1.25rem; }
    .workspace-grid { grid-template-columns: 1fr; }
    .upload-zone { padding: 2.5rem 1.25rem; }

    .hud-panel { display: none; } /* hide HUD on mobile — not critical */

    .results-header { flex-direction: column; align-items: flex-start; }
    .export-btns { width: 100%; }
    .btn-export { flex: 1; justify-content: center; }

    .section-title { font-size: 1.2rem; }

    footer { flex-direction: column; align-items: flex-start; gap: .75rem; }
}

@media (max-width: 480px) {
    .btn-primary { width: 100%; justify-content: center; }
    .file-bar-size { display: none; }
}

@media (max-width: 768px) {
    #results .results-title { display: none; }
    #results .table-wrap    { display: none; }
    .export-btns { width: 100%; }
    .btn-export  { flex: 1; justify-content: center; }
}