@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

/* ─── Tokens ──────────────────────────────────────────────── */
:root {
  --font-ui:   'DM Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Fira Code', monospace;

  --bg:        #f0f2f7;
  --surface:   #ffffff;
  --surface2:  #f7f8fc;
  --surface3:  #eef0f7;
  --border:    #dde1ed;
  --border2:   #c8cede;

  --text:      #111827;
  --text2:     #4b5563;
  --text3:     #9ca3af;

  --accent:    #3b5bdb;
  --accent-h:  #2f4ac4;
  --accent-bg: #eef1fb;

  --good:      #15803d;
  --good-bg:   #dcfce7;
  --warn:      #b45309;
  --warn-bg:   #fef3c7;
  --bad:       #b91c1c;
  --bad-bg:    #fee2e2;

  --tag-match-bg:   #dcfce7; --tag-match-tx:   #14532d;
  --tag-diff-bg:    #fee2e2; --tag-diff-tx:    #7f1d1d;
  --tag-miss-bg:    #fef3c7; --tag-miss-tx:    #78350f;
  --tag-ign-bg:     #f3f4f6; --tag-ign-tx:     #374151;

  --radius:    10px;
  --radius-sm: 6px;
  --shadow:    0 1px 4px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --shadow-md: 0 2px 8px rgba(0,0,0,.08), 0 8px 32px rgba(0,0,0,.08);
}

body.theme-dark {
  --bg:        #0d1117;
  --surface:   #161b22;
  --surface2:  #1c2128;
  --surface3:  #21262d;
  --border:    #30363d;
  --border2:   #3d444d;

  --text:      #e6edf3;
  --text2:     #848d97;
  --text3:     #484f58;

  --accent:    #6e8efb;
  --accent-h:  #8ba3fc;
  --accent-bg: #1c2240;

  --good:      #3fb950;
  --good-bg:   #0d2619;
  --warn:      #d29922;
  --warn-bg:   #2d2005;
  --bad:       #f85149;
  --bad-bg:    #2d0f0f;

  --tag-match-bg:   #0d2619; --tag-match-tx:   #3fb950;
  --tag-diff-bg:    #2d0f0f; --tag-diff-tx:    #f85149;
  --tag-miss-bg:    #2d2005; --tag-miss-tx:    #d29922;
  --tag-ign-bg:     #21262d; --tag-ign-tx:     #848d97;

  --shadow:    0 1px 4px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.3);
  --shadow-md: 0 2px 8px rgba(0,0,0,.4), 0 8px 32px rgba(0,0,0,.3);
}

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

body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  transition: background .2s, color .2s;
}

.wrap { max-width: 1440px; margin: 0 auto; padding: 0 24px 48px; }

/* Topbar */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 0 16px;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.brandBlock { display: flex; flex-direction: column; gap: 6px; }
.topnav { display: flex; gap: 4px; margin-bottom: 4px; }
.navLink {
  font-size: 12px; font-weight: 500;
  padding: 4px 10px; border-radius: 20px;
  color: var(--text2); text-decoration: none;
  transition: background .15s, color .15s; letter-spacing: .01em;
}
.navLink:hover { background: var(--surface3); color: var(--text); }
.navLink.active { background: var(--accent); color: #fff; }

h1 { font-size: 22px; font-weight: 600; letter-spacing: -.02em; color: var(--text); line-height: 1.2; }
.sub { font-size: 13px; color: var(--text2); max-width: 640px; line-height: 1.5; }
.versionBadge {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  padding: 2px 8px; border-radius: 20px;
  background: var(--surface3); color: var(--text3); border: 1px solid var(--border);
  letter-spacing: .04em; align-self: flex-start;
}

.themeToggle {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 14px; border: 1px solid var(--border); border-radius: 20px;
  background: var(--surface); color: var(--text2);
  font-size: 13px; font-family: var(--font-ui);
  cursor: pointer; white-space: nowrap;
  transition: border-color .15s, background .15s, color .15s;
  flex-shrink: 0; margin-top: 4px;
}
.themeToggle:hover { border-color: var(--border2); color: var(--text); background: var(--surface2); }
.themeIcon { font-size: 14px; }

/* Panel */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  margin-bottom: 12px; box-shadow: var(--shadow);
}

/* Grid */
.grid { display: grid; gap: 16px; }
.grid2 { grid-template-columns: 1fr 1fr; }
.helperGrid { grid-template-columns: 1fr 1fr; }
.helperGrid3 { grid-template-columns: 1fr 2fr; }

/* Filebox */
.filebox { display: flex; flex-direction: column; gap: 10px; }
.sideTitle { display: flex; align-items: baseline; gap: 10px; }
.sideTitle h2 { font-size: 16px; font-weight: 600; color: var(--text); }
.sideHint { font-size: 11px; color: var(--text3); font-family: var(--font-mono); }

/* Labels & inputs */
label {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--text2); margin-bottom: 4px;
  letter-spacing: .02em; text-transform: uppercase;
}
input[type="text"], input[type="file"], select, textarea {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface2); color: var(--text);
  font-family: var(--font-ui); font-size: 13px;
  outline: none; transition: border-color .15s, box-shadow .15s; appearance: none;
}
input[type="text"]:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,91,219,.15);
}
body.theme-dark input[type="text"]:focus,
body.theme-dark select:focus,
body.theme-dark textarea:focus {
  box-shadow: 0 0 0 3px rgba(110,142,251,.15);
}
input[type="file"] { padding: 7px 11px; cursor: pointer; font-size: 13px; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239ca3af' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: 30px; cursor: pointer;
}
textarea {
  resize: vertical; min-height: 90px;
  font-family: var(--font-mono); font-size: 12px; line-height: 1.5;
}
textarea.outputArea { color: var(--accent); font-size: 11px; min-height: 64px; }
textarea.jsonPasteArea { min-height: 120px; }
textarea.compactArea { min-height: 72px; }
textarea.bulkMappingsArea { min-height: 100px; }
input[readonly] { color: var(--text2); cursor: default; }

/* Source tabs */
.sourceTabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px; margin-bottom: 10px;
}
.tabBtn {
  padding: 5px 14px; font-size: 12px; font-weight: 500;
  font-family: var(--font-ui); border: none;
  border-bottom: 2px solid transparent; background: none;
  color: var(--text2); cursor: pointer;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color .15s, border-color .15s, background .15s;
  margin-bottom: -2px;
}
.tabBtn:hover { color: var(--text); background: var(--surface3); }
.tabBtn.active { color: var(--accent); border-bottom-color: var(--accent); }
.sourcePanel { display: none; }
.sourcePanel.active { display: flex; flex-direction: column; gap: 10px; }

/* Buttons */
button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: none; border-radius: var(--radius-sm);
  font-family: var(--font-ui); font-size: 13px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background .15s, color .15s, opacity .15s, box-shadow .15s, transform .08s;
}
button:active { transform: translateY(1px); }
button:not(.secondary):not(.ghost):not(.themeToggle):not(.tabBtn):not(.modeSwitchBtn):not(.pill):not(.copyFieldBtn) {
  background: var(--accent); color: #fff;
  box-shadow: 0 1px 4px rgba(59,91,219,.3);
}
button:not(.secondary):not(.ghost):not(.themeToggle):not(.tabBtn):not(.modeSwitchBtn):not(.pill):not(.copyFieldBtn):hover {
  background: var(--accent-h); box-shadow: 0 2px 8px rgba(59,91,219,.35);
}
button.secondary {
  background: var(--surface3); color: var(--text);
  border: 1px solid var(--border);
}
button.secondary:hover { background: var(--surface2); border-color: var(--border2); }
button.ghost {
  background: transparent; color: var(--text2);
  border: 1px solid var(--border);
}
button.ghost:hover { background: var(--surface3); color: var(--text); }
button.detailBtn {
  padding: 4px 10px; font-size: 11px;
  background: var(--accent-bg); color: var(--accent);
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
}
button.detailBtn:hover { background: var(--accent); color: #fff; }

/* Mode switch */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.toolbarSplit { justify-content: space-between; }
.modeSwitch {
  display: flex; background: var(--surface3);
  border: 1px solid var(--border); border-radius: 8px; padding: 3px; gap: 2px;
}
.modeSwitchBtn {
  padding: 5px 16px; border-radius: 6px; border: none;
  background: none; color: var(--text2); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background .15s, color .15s, box-shadow .15s;
}
.modeSwitchBtn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Toggle switch */
.switchRow { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 500; color: var(--text2); }
.switch { position: relative; display: inline-block; width: 38px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0;
  background: var(--surface3); border: 1px solid var(--border2);
  border-radius: 22px; cursor: pointer;
  transition: background .2s, border-color .2s;
}
.slider::before {
  content: ''; position: absolute;
  width: 16px; height: 16px; left: 2px; top: 2px;
  background: var(--text3); border-radius: 50%;
  transition: transform .2s, background .2s;
}
input:checked + .slider { background: var(--accent); border-color: var(--accent); }
input:checked + .slider::before { transform: translateX(16px); background: #fff; }

/* Help */
.help { font-size: 12px; color: var(--text2); line-height: 1.5; }
.help.bad  { color: var(--bad); }
.help.warn { color: var(--warn); }
.help.muted { color: var(--text3); }
.smallGap { margin-top: 8px; }

/* Button row */
.btnRow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btnRow.smallGap { gap: 6px; }

/* Copy field */
.copyFieldWrap { position: relative; }
.copyFieldBtn {
  position: absolute; top: 6px; right: 6px;
  padding: 4px 7px; font-size: 12px;
  background: var(--surface3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; color: var(--text2);
  transition: background .15s, color .15s;
}
.copyFieldBtn:hover { background: var(--surface2); color: var(--text); }
.hasCopyIcon { padding-right: 42px; }

/* Status bar */
.statusbar {
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; margin-top: 12px;
  border: 1px solid transparent;
  transition: background .2s, color .2s, border-color .2s;
}
.statusbar.good  { background: var(--good-bg); color: var(--good); border-color: var(--good); }
.statusbar.bad   { background: var(--bad-bg);  color: var(--bad);  border-color: var(--bad);  }
.statusbar.warn  { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.statusbar.muted { background: var(--surface2); color: var(--text3); border-color: var(--border); }

/* Summary cards */
.cards { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px;
  min-width: 100px; flex: 1 1 90px;
}
.card .muted { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.card .num { font-size: 22px; font-weight: 600; font-family: var(--font-mono); letter-spacing: -.02em; color: var(--text); }
.card .headline-value { font-size: 15px; font-weight: 600; color: var(--text); }
.card .num.good { color: var(--good); }
.card .num.bad  { color: var(--bad); }
.card .num.warn { color: var(--warn); }
.card .headline-value.good { color: var(--good); }
.card .headline-value.warn { color: var(--warn); }

/* Docbar */
.docbar {
  display: flex; flex-wrap: wrap; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border); margin-bottom: 14px;
}
.helperDocbar { border-top: 1px solid var(--border); border-bottom: none; padding: 12px 0 0; margin: 12px 0 0; }
.docname { display: flex; flex-direction: column; gap: 2px; }
.doclabel { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; color: var(--text3); }
.docvalue { font-size: 15px; font-weight: 600; color: var(--text); }
.helperDocValue { font-family: var(--font-mono); font-size: 13px; color: var(--accent); }
.helperStatusValue { font-size: 13px; font-weight: 500; color: var(--text); }
.compareTopPanel .docbar { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

/* Filter pills */
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.pill {
  padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 500;
  cursor: pointer; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text2);
  transition: background .15s, color .15s, border-color .15s; user-select: none;
}
.pill:hover { background: var(--surface3); color: var(--text); border-color: var(--border2); }
.pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Chips */
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  padding: 4px 10px; border-radius: 20px; font-size: 11px;
  background: var(--accent-bg); color: var(--accent);
  border: 1px solid rgba(59,91,219,.2);
}
body.theme-dark .chip { border-color: rgba(110,142,251,.2); }

/* Table */
.result { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 8px 12px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text3);
  background: var(--surface2); border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
}
td { padding: 7px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }
tr.selected td { background: var(--accent-bg); }
tr.bulkSummaryRow { cursor: pointer; }
td.muted { color: var(--text3); font-style: italic; }
tr td[colspan] { text-align: center; padding: 24px; color: var(--text3); font-style: italic; font-size: 13px; }

/* Code */
.code { font-family: var(--font-mono); font-size: 11px; word-break: break-all; color: var(--text); line-height: 1.5; }
.codeInline {
  font-family: var(--font-mono); font-size: 11px;
  background: var(--surface3); border: 1px solid var(--border);
  border-radius: 3px; padding: 1px 5px; color: var(--text);
}

/* Tags */
.tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.tag.match   { background: var(--tag-match-bg); color: var(--tag-match-tx); }
.tag.diff    { background: var(--tag-diff-bg);  color: var(--tag-diff-tx);  }
.tag.missing { background: var(--tag-miss-bg);  color: var(--tag-miss-tx);  }
.tag.ignored { background: var(--tag-ign-bg);   color: var(--tag-ign-tx);   }

/* Compare layout */
.compareModeHelp { margin: 6px 0 0; }
.compareModeTopOnly .toolbar { padding: 0; }
.compareTopPanel { display: flex; flex-direction: column; gap: 10px; }

h2 { font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: -.01em; }

.stepLabel {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; margin-right: 8px; flex-shrink: 0;
}

/* Utility */
.hidden { display: none !important; }
.good { color: var(--good); }
.bad  { color: var(--bad); }
.warn { color: var(--warn); }
.muted { color: var(--text3); }
strong { font-weight: 600; }
.flatSourceField { display: flex; flex-direction: column; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* Responsive */
@media (max-width: 800px) {
  .grid2 { grid-template-columns: 1fr; }
  .helperGrid { grid-template-columns: 1fr; }
  .helperGrid3 { grid-template-columns: 1fr; }
  .wrap { padding: 0 14px 32px; }
  .topbar { flex-direction: column; gap: 12px; }
  .cards { gap: 8px; }
  .card { flex: 1 1 80px; padding: 10px 12px; }
}
