@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Manrope:wght@400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f7f8fa;
  --bg2:       #ffffff;
  --bg3:       #f2f3f6;
  --bg4:       #eaecf0;
  --border:    #e2e5ea;
  --border2:   #cdd1d8;
  --text:      #1a1d23;
  --text2:     #4a5060;
  --text3:     #8a919e;
  --accent:    #1a6ef5;
  --accent2:   #1558d4;
  --green:     #0f9b6e;
  --green-bg:  #edf9f4;
  --red:       #d93636;
  --red-bg:    #fef2f2;
  --amber:     #b85c00;
  --amber-bg:  #fff8ed;
  --purple:    #6b52d6;
  --sidebar:   228px;
  --radius:    10px;
  --font:      'Manrope', sans-serif;
  --mono:      'IBM Plex Mono', monospace;
  --shadow:    0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
}

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
}
.sb-logo {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-mark {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; color: #fff;
  font-family: var(--mono); flex-shrink: 0; letter-spacing: -.5px;
}
.logo-text  { font-size: 12px; font-weight: 700; color: var(--text); line-height: 1.2; }
.logo-sub   { font-size: 9px; color: var(--text3); font-family: var(--mono); }

nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.nav-section { margin-bottom: 20px; }
.nav-label {
  font-size: 10px; font-weight: 700; color: var(--text3);
  letter-spacing: .07em; text-transform: uppercase;
  padding: 0 8px; margin-bottom: 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 7px;
  cursor: pointer; color: var(--text2);
  font-size: 13px; font-weight: 500;
  transition: background .12s, color .12s;
  position: relative; user-select: none;
  text-decoration: none;
}
.nav-item:hover  { background: var(--bg3); color: var(--text); }
.nav-item.active { background: #eff4ff; color: var(--accent); font-weight: 700; }
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 16px; background: var(--accent); border-radius: 0 2px 2px 0;
}
.nav-item svg { width: 15px; height: 15px; opacity: .55; flex-shrink: 0; }
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto; background: var(--accent); color: #fff;
  font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 8px;
  font-family: var(--mono);
}

.sb-footer { padding: 10px 8px; border-top: 1px solid var(--border); }
.lang-row  { display: flex; gap: 4px; margin-bottom: 6px; }
.lang-btn  {
  flex: 1; padding: 5px; font-size: 11px; font-weight: 700;
  border: 1px solid var(--border); border-radius: 6px;
  background: transparent; color: var(--text3); cursor: pointer; font-family: var(--font);
}
.lang-btn.active { background: var(--bg3); color: var(--text); border-color: var(--border2); }
.user-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px; border-radius: 7px; cursor: pointer;
}
.user-row:hover { background: var(--bg3); }
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--purple); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
}
.user-name { font-size: 12px; font-weight: 700; color: var(--text); }

/* ─── MAIN ─── */
.main {
  margin-left: var(--sidebar);
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}
.topbar {
  height: 52px; background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 12px;
  position: sticky; top: 0; z-index: 10;
  box-shadow: var(--shadow);
}
.topbar-title { font-size: 14px; font-weight: 700; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.status-dot   { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.status-lbl   { font-size: 11px; color: var(--green); font-weight: 700; }
.status-lbl.old { color: var(--amber); }
.topbar-date  { font-size: 11px; color: var(--text3); font-family: var(--mono); }

.content {
  padding: 24px;
  flex: 1;
  min-width: 0;
}

/* ─── CARDS ─── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 16px;
}
.card-head {
  padding: 10px 16px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  font-size: 11px; font-weight: 700; color: var(--text2);
  letter-spacing: .04em; text-transform: uppercase;
  display: flex; align-items: center; gap: 10px;
}
.card-body { padding: 16px; }
.section-title { font-size: 13px; font-weight: 700; margin-bottom: 12px; }

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; font-family: var(--font);
  transition: all .12s; text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-ghost {
  background: var(--bg2); color: var(--text2);
  border: 1px solid var(--border2);
}
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-danger { background: var(--red-bg); color: var(--red); border: 1px solid #fbc4c4; }

/* ─── FORMS ─── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 11px; font-weight: 700; color: var(--text3); letter-spacing: .05em; margin-bottom: 5px; }
.form-input {
  width: 100%;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 8px; padding: 10px 13px;
  color: var(--text); font-size: 13px; font-family: var(--font);
  outline: none; transition: border-color .15s;
}
.form-input:focus { border-color: var(--accent); background: var(--bg2); }
.form-input::placeholder { color: var(--text3); }
select.form-input { cursor: pointer; }

/* ─── TABLE ─── */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; padding: 8px 14px;
  color: var(--text3); font-weight: 700; font-size: 11px;
  letter-spacing: .04em; text-transform: uppercase;
  background: var(--bg3); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tbl td { padding: 9px 14px; border-bottom: 1px solid var(--border); color: var(--text2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: #f8f9ff; }
.tbl .sku { font-family: var(--mono); font-size: 12px; color: var(--text); }

.products-table-scroll {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.products-table {
  width: max-content;
  min-width: 100%;
}

/* ─── STATUS CHIPS ─── */
.chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 8px; border-radius: 12px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.chip-ok    { background: var(--green-bg); color: var(--green); }
.chip-miss  { background: var(--red-bg);   color: var(--red);   }
.chip-warn  { background: var(--amber-bg); color: var(--amber); }
.chip-multi { background: #f0eeff; color: var(--purple); cursor: pointer; }
.chip-arc   { background: var(--bg3); color: var(--text3); }

/* ─── PRICE COLORS ─── */
.price-good { color: var(--green); font-weight: 700; font-family: var(--mono); }
.price-bad  { color: var(--red);   font-weight: 700; font-family: var(--mono); }
.price-miss { color: var(--amber); font-weight: 600; }
.price-neu  { font-family: var(--mono); }

/* ─── BRAND TAG ─── */
.brand-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 4px; padding: 1px 6px;
  font-size: 11px; font-weight: 700; color: var(--text2); font-family: var(--mono);
}

.brand-tag-logo {
  min-width: 74px;
  min-height: 26px;
  padding: 3px 6px;
  background: #fff;
}

.brand-tag-logo__img {
  display: block;
  max-width: 72px;
  max-height: 18px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.hm-brand .brand-tag {
  max-width: 100%;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ─── PILLS ─── */
.pill {
  display: inline-block; padding: 3px 9px;
  border-radius: 12px; font-size: 11px; font-weight: 700;
  font-family: var(--mono);
}
.pill-green { background: var(--green-bg); color: var(--green); }
.pill-amber { background: var(--amber-bg); color: var(--amber); }
.pill-red   { background: var(--red-bg);   color: var(--red);   }
.pill-blue  { background: #eff4ff; color: var(--accent); }

.product-top-qty {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.product-top-status {
  display: inline-block;
  min-width: 42px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  line-height: 1.2;
}

.product-top-status--yes {
  background: var(--green-bg);
  border-color: #a7e8cf;
  color: var(--green);
}

.product-top-status--no {
  background: var(--bg3);
  border-color: var(--border2);
  color: var(--text3);
}

/* ─── UPLOAD ─── */
.upload-area {
  border: 2px dashed var(--border2);
  border-radius: var(--radius); padding: 32px 20px;
  text-align: center; cursor: pointer; transition: all .18s;
  background: var(--bg2);
}
.upload-area:hover  { border-color: var(--accent); background: #f5f8ff; }
.upload-area.active { border-color: var(--green); background: var(--green-bg); }
.ft-row { display: flex; gap: 5px; justify-content: center; margin-top: 10px; }
.ft {
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 4px; padding: 2px 7px;
  font-size: 10px; font-weight: 700; font-family: var(--mono); color: var(--text3);
}

/* ─── TOGGLE CHIPS ─── */
.toggle-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.toggle-chip {
  padding: 6px 14px; border-radius: 7px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border2); background: var(--bg3); color: var(--text3);
  cursor: pointer; transition: all .12s; user-select: none;
}
.toggle-chip.on { background: #eff4ff; border-color: var(--accent); color: var(--accent); }

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mode-card {
  display: block;
  cursor: pointer;
}

.mode-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-card__body {
  display: block;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 10px 12px;
  transition: border-color .12s, background .12s, box-shadow .12s;
}

.mode-card input:checked + .mode-card__body {
  background: #eff4ff;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(26, 110, 245, .08);
}

.mode-card__title {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 3px;
  line-height: 1.35;
}

.mode-card__sub {
  display: block;
  font-size: 10px;
  color: var(--text3);
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* ─── WIZARD STEPS ─── */
.step-block {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
}
.step-num { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.step-dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: #fff; font-weight: 700; flex-shrink: 0;
}
.step-dot.done { background: var(--green); }
.step-dot.gray { background: var(--border2); }
.step-label { font-size: 11px; font-weight: 700; color: var(--text3); letter-spacing: .05em; text-transform: uppercase; }
.col-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.col-lbl { font-size: 12px; color: var(--text2); width: 85px; flex-shrink: 0; }
.col-sel {
  flex: 1; background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 6px; color: var(--text); font-size: 12px;
  padding: 6px 9px; font-family: var(--font); cursor: pointer; outline: none;
}
.col-sel:focus { border-color: var(--accent); }

/* ─── FILE PREVIEW TABLE ─── */
.preview-table-wrap {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 7px; overflow: auto; margin-bottom: 12px;
  max-height: 140px;
}
.preview-table { width: 100%; border-collapse: collapse; font-size: 11px; font-family: var(--mono); }
.preview-table th { padding: 5px 10px; background: var(--bg4); color: var(--text3); font-weight: 700; border-bottom: 1px solid var(--border); white-space: nowrap; }
.preview-table td { padding: 4px 10px; border-bottom: 1px solid var(--border); color: var(--text2); white-space: nowrap; }
.preview-table tr:last-child td { border-bottom: none; }

/* ─── HM BAR ─── */
.hm-bar {
  background: #f0f4ff; border: 1px solid #c7d7fb;
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px;
}
.hm-title {
  font-size: 10px; font-weight: 700; color: var(--accent);
  letter-spacing: .07em; text-transform: uppercase; margin-bottom: 10px;
}
.hm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px,1fr)); gap: 7px; }
.hm-chip {
  background: #fff; border: 1px solid #c7d7fb;
  border-radius: 7px; padding: 7px 10px; text-align: center;
}
.hm-brand { font-size: 12px; font-weight: 700; color: var(--accent); font-family: var(--mono); }
.hm-sub   { font-size: 10px; color: var(--text3); margin-top: 2px; }

/* ─── GROUP HEADER ─── */
.group-header {
  font-size: 11px; font-weight: 700; color: var(--text3);
  letter-spacing: .05em; text-transform: uppercase;
  padding: 2px 0; margin: 16px 0 6px; border-bottom: 1px solid var(--border);
  padding-bottom: 5px;
}

/* ─── MODAL ─── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,20,30,.35); z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 14px; padding: 22px; width: 460px;
  max-height: 85vh; overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.modal-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.modal-sub   { font-size: 12px; color: var(--text3); margin-bottom: 16px; font-family: var(--mono); }
.match-opt {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 6px; cursor: pointer; transition: all .12s;
}
.match-opt:hover    { border-color: var(--accent); background: #f5f8ff; }
.match-opt.selected { border-color: var(--green); background: var(--green-bg); }
.match-brand { font-size: 12px; font-weight: 700; font-family: var(--mono); color: var(--text); }
.match-desc  { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* ─── HISTORY ─── */
.hist-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .1s; text-decoration: none; color: inherit;
}
.hist-item:last-child { border-bottom: none; }
.hist-item:hover { background: var(--bg3); }
.hist-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: #eff4ff; display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.hist-name { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.hist-info { font-size: 11px; color: var(--text3); font-family: var(--mono); }
.hist-rate { font-size: 14px; font-weight: 700; font-family: var(--mono); }

/* ─── FILE UPDATES ─── */
.fstat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.fstat {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow);
}
.fstat-label { font-size: 10px; font-weight: 700; color: var(--text3); letter-spacing: .05em; text-transform: uppercase; margin-bottom: 5px; }
.fstat-val   { font-size: 13px; font-weight: 700; font-family: var(--mono); color: var(--text); }
.fstat-sub   { font-size: 11px; color: var(--text3); margin-top: 3px; font-family: var(--mono); }

/* ─── LOGS ─── */
.log-user   { color: var(--accent); font-weight: 700; }
.log-action { color: var(--text); }
.log-time   { color: var(--text3); font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.log-ip     { color: var(--text3); font-family: var(--mono); font-size: 11px; }

/* ─── SETTINGS ─── */
.user-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.user-item:last-child { border-bottom: none; }

/* ─── ALERTS ─── */
.alert {
  padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px;
}
.alert-error   { background: var(--red-bg);   color: var(--red);   border: 1px solid #fbc4c4; }
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid #a7e8cf; }
.alert-info    { background: #eff4ff; color: var(--accent); border: 1px solid #c7d7fb; }

/* ─── UTILS ─── */
.flex  { display: flex; align-items: center; gap: 8px; }
.ml-a  { margin-left: auto; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.text-muted { color: var(--text3); }
.text-xs  { font-size: 11px; }
.text-sm  { font-size: 12px; }
.font-mono { font-family: var(--mono); }
.w-full  { width: 100%; }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ─── LOGIN PAGE ─── */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; flex: 1; background: var(--bg); }
.login-card {
  width: 380px; background: var(--bg2);
  border: 1px solid var(--border); border-radius: 16px;
  padding: 36px; box-shadow: var(--shadow-md);
}
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; justify-content: center; }
.login-title { font-size: 18px; font-weight: 700; text-align: center; margin-bottom: 4px; }
.login-sub   { font-size: 12px; color: var(--text3); text-align: center; margin-bottom: 24px; font-family: var(--mono); }
.btn-login   { width: 100%; padding: 11px; font-size: 14px; font-weight: 700; background: var(--accent); color: #fff; border: none; border-radius: 8px; cursor: pointer; font-family: var(--font); margin-top: 6px; }
.btn-login:hover { background: var(--accent2); }
.login-hint  { font-size: 11px; color: var(--text3); text-align: center; margin-top: 14px; font-family: var(--mono); }



/* ─── DIFF COLORS ─── */
.diff-green   { color: #0f9b6e; font-weight: 700; font-family: var(--mono); }
.diff-orange  { color: #b85c00; font-weight: 700; font-family: var(--mono); }
.diff-red     { color: #c0392b; font-weight: 700; font-family: var(--mono); }
.diff-neutral { color: var(--text3); font-family: var(--mono); }

/* diff cell backgrounds — subtle */
.diff-green  { background: transparent; }
td.bg-green  { background: #f0fdf8; }
td.bg-orange { background: #fff8ed; }
td.bg-red    { background: #fef5f5; }

.tbl thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg3);
    box-shadow: 0 1px 0 var(--border);
}

/* Keep both header rows sticky in the interactive matched table. */
#main-tbl thead tr:first-child th {
  top: 0;
  z-index: 7;
}

#main-tbl thead tr:nth-child(2) th {
  top: 34px;
  z-index: 8;
}

#main-tbl thead th[rowspan="2"] {
  top: 0;
  z-index: 9;
}

.supplier-opt:hover {
    background: var(--bg3);
}
.supplier-opt:last-child {
    border-bottom: none;
}