:root {
  --paper: #f4f1ea;
  --ink: #17251d;
  --green: #254f39;
  --acid: #d7ff45;
  --line: #c9c7bf;
  --white: #fffdf8;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }
button { cursor: pointer; }

.shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }

.topbar {
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; font-size: 13px; font-weight: 850; letter-spacing: .12em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; background: var(--green); color: var(--acid); font-family: Georgia, serif; font-style: italic; font-size: 22px; border-radius: 50%; }
.privacy { display: flex; align-items: center; gap: 9px; color: #58645d; font-size: 12px; }
.privacy i { width: 8px; height: 8px; border-radius: 50%; background: #73a943; box-shadow: 0 0 0 4px #deead4; }

.hero { padding: 70px 0 54px; display: grid; grid-template-columns: 1.35fr .65fr; align-items: end; gap: 50px; }
.eyebrow { grid-column: 1 / -1; margin: 0 0 -28px; color: #6b766f; font-size: 11px; font-weight: 800; letter-spacing: .2em; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(52px, 7vw, 90px); line-height: .89; letter-spacing: -.055em; font-weight: 500; }
h1 em { color: var(--green); font-weight: 500; }
.intro { max-width: 440px; margin: 0 0 4px; color: #56615a; font-size: 17px; line-height: 1.65; }

.workspace { display: grid; grid-template-columns: .85fr 1.15fr; min-height: 510px; box-shadow: 0 24px 70px rgba(35, 48, 40, .12); }
.upload-panel, .result-panel { padding: clamp(28px, 4vw, 52px); }
.upload-panel { background: var(--white); }
.result-panel { display: flex; flex-direction: column; background: var(--green); color: white; }
.step { display: inline-grid; place-items: center; width: 32px; height: 24px; border-radius: 99px; background: var(--acid); color: var(--ink); font-size: 10px; font-weight: 900; letter-spacing: .08em; }
.step.dark { background: rgba(215,255,69,.16); color: var(--acid); }
h2 { margin: 18px 0 6px; font-family: Georgia, serif; font-size: 29px; font-weight: 500; }
.upload-panel > p { margin: 0; color: #778079; font-size: 13px; }

.dropzone { min-height: 232px; margin-top: 32px; border: 1.5px dashed #aeb3ad; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; transition: .2s ease; cursor: pointer; outline: none; }
.dropzone:hover, .dropzone.dragging, .dropzone:focus-within { border-color: var(--green); background: #f2f7ed; transform: translateY(-2px); }
.dropzone input { position: absolute; opacity: 0; pointer-events: none; }
.upload-icon { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 8px; border-radius: 50%; background: var(--acid); color: var(--green); font-size: 24px; }
.dropzone strong { font-size: 15px; }
.dropzone span:last-child { color: #7d857f; font-size: 12px; }
.dropzone u { color: var(--green); font-weight: 700; text-underline-offset: 3px; }
.local-note { margin-top: 14px !important; text-align: center; font-size: 11px !important; }

.result-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 25px; border-bottom: 1px solid rgba(255,255,255,.18); }
.result-head h2 { margin-bottom: 0; }
.database-status { margin: 7px 0 0; color: rgba(255,255,255,.52); font-size: 10px; }
.database-status.ready { color: #bcd894; }
.database-status.failed { color: #f4b9ad; }
.result-summary { margin: 5px 0 0; color: rgba(255,255,255,.72); font-size: 9px; }
.count { display: grid; place-items: center; min-width: 42px; height: 42px; padding: 0 11px; border: 1px solid rgba(255,255,255,.25); border-radius: 50%; font-family: Georgia, serif; font-size: 18px; }
.empty-state, .loading-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: rgba(255,255,255,.48); }
.empty-state p, .loading-state p { margin: 14px 0 0; font-size: 12px; }
.spinner { width: 34px; height: 34px; border: 2px solid rgba(255,255,255,.2); border-top-color: var(--acid); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.result-tabs { margin: 18px -4px 0; }
.tab-list { display: flex; gap: 7px; padding: 0 4px 10px; overflow-x: auto; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.25) transparent; }
.result-tab { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; min-height: 34px; padding: 7px 9px 7px 11px; border: 1px solid rgba(255,255,255,.17); border-radius: 99px; background: rgba(255,255,255,.06); color: rgba(255,255,255,.7); font-size: 9px; font-weight: 800; transition: .18s ease; }
.result-tab:hover { border-color: rgba(215,255,69,.65); color: white; }
.result-tab[aria-selected="true"] { border-color: var(--acid); background: var(--acid); color: var(--ink); }
.result-tab:focus-visible { outline: 2px solid white; outline-offset: 2px; }
.tab-count { display: grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: rgba(255,255,255,.14); font-size: 8px; }
.result-tab[aria-selected="true"] .tab-count { background: rgba(23,37,29,.12); }
.results { flex: 1; min-height: 210px; max-height: 570px; overflow-y: auto; padding: 8px 4px 6px 0; scrollbar-color: rgba(255,255,255,.35) transparent; }
.tab-empty { min-height: 210px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 28px; text-align: center; color: rgba(255,255,255,.5); }
.tab-empty strong { color: white; font-family: Georgia, serif; font-size: 18px; font-weight: 500; }
.tab-empty span { max-width: 300px; font-size: 11px; line-height: 1.5; }
.result-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 14px; padding: 18px 0; border-bottom: 1px solid rgba(255,255,255,.13); }
.match-status { display: block; width: max-content; margin-bottom: 8px; padding: 4px 7px; border-radius: 2px; font-size: 8px; font-weight: 900; letter-spacing: .1em; }
.match-status.found { background: var(--acid); color: var(--ink); }
.match-status.missing { background: #f0b3a8; color: #39201c; }
.match-status.unknown { background: rgba(255,255,255,.15); color: white; }
.match-status.exact { background: var(--acid); color: var(--ink); }
.match-status.difference { background: #ffd078; color: #3e2a09; }
.match-status.frame-not-found, .match-status.no-frame { background: #f0a59a; color: #3b1712; }
.match-status.battery-missing, .match-status.price-missing { background: rgba(255,255,255,.16); color: white; }
.serial { color: var(--acid); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: clamp(16px, 2vw, 21px); letter-spacing: .05em; overflow-wrap: anywhere; }
.source { display: block; margin-top: 5px; color: rgba(255,255,255,.52); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.match-details { display: flex; flex-direction: column; gap: 3px; margin-top: 12px; padding: 11px 12px; border-left: 2px solid var(--acid); background: rgba(255,255,255,.07); font-size: 11px; line-height: 1.35; }
.match-details strong { color: white; }
.match-details span { color: rgba(255,255,255,.8); }
.match-details small { color: rgba(255,255,255,.48); font-size: 9px; }
.product-pair { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 14px; margin-top: 15px; padding: 12px; background: rgba(255,255,255,.06); }
.pair-label { grid-column: 1 / -1; color: var(--acid); font-size: 8px; font-weight: 900; letter-spacing: .12em; }
.pair-label.battery-label { margin-top: 8px; }
.pair-name { color: rgba(255,255,255,.76); font-size: 10px; line-height: 1.4; }
.pair-price { color: white; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; white-space: nowrap; }
.reused-note { grid-column: 1 / -1; margin-top: 3px; color: #ffd078; font-size: 9px; }
.price-comparison { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 7px 14px; margin-top: 12px; padding: 13px 0; border-top: 1px solid rgba(255,255,255,.13); border-bottom: 1px solid rgba(255,255,255,.13); }
.comparison-label { color: rgba(255,255,255,.52); font-size: 8px; font-weight: 800; letter-spacing: .08em; }
.comparison-value { color: white; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; text-align: right; }
.difference-value.exact { color: var(--acid); }
.difference-value.difference { color: #ffd078; }
.difference-value.frame-not-found, .difference-value.no-frame, .difference-value.battery-missing, .difference-value.price-missing { color: rgba(255,255,255,.45); }
.copy-one { border: 0; background: transparent; color: white; font-size: 11px; text-decoration: underline; text-underline-offset: 3px; }
.file-error { display: flex; flex-direction: column; gap: 5px; margin: 10px 0; padding: 14px; background: rgba(255,255,255,.08); color: #f4c8bf; font-size: 11px; line-height: 1.4; }
.file-error strong { font-size: 10px; letter-spacing: .08em; }
.file-error span { color: rgba(255,255,255,.65); }
.file-error.no-frame { border-left: 3px solid #f0b3a8; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-top: 20px; }
.actions button { min-height: 46px; border: 1px solid var(--acid); font-weight: 800; font-size: 12px; }
.primary { background: var(--acid); color: var(--ink); }
.secondary { background: transparent; color: white; }
.actions button:hover { transform: translateY(-1px); }
.actions button:disabled { cursor: wait; opacity: .65; transform: none; }
#copy-all[hidden] + #download-excel { grid-column: 1 / -1; }

.explain { display: grid; grid-template-columns: 80px 1fr; gap: 24px; align-items: start; max-width: 730px; padding: 44px 0 70px; color: #5f6a63; font-size: 13px; line-height: 1.65; }
.explain p { margin: 0; }
.explain strong { color: var(--ink); }
.rule { height: 1px; margin-top: 10px; background: var(--green); }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); padding: 12px 18px; background: #101913; color: white; border-radius: 4px; font-size: 12px; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .shell { width: min(100% - 24px, 600px); }
  .topbar { min-height: 68px; }
  .privacy { font-size: 0; }
  .hero { padding: 48px 0 38px; grid-template-columns: 1fr; gap: 30px; }
  .eyebrow { margin-bottom: -12px; }
  .workspace { grid-template-columns: 1fr; }
  .upload-panel, .result-panel { padding: 28px 22px; }
  .result-panel { min-height: 430px; }
  .result-tabs { margin-right: -22px; }
  .explain { grid-template-columns: 45px 1fr; padding-bottom: 45px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
