:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e1ef;
  --soft: #f4f7fb;
  --panel: #ffffff;
  --blue: #1769e0;
  --blue-dark: #1153b5;
  --blue-soft: #eaf2ff;
  --green: #1f7a55;
  --green-soft: #e9f8f0;
  --amber: #9a6700;
  --amber-soft: #fff5cc;
  --red: #bd2c3a;
  --red-soft: #fff0f2;
  --cyan: #047a8a;
  --cyan-soft: #e8fbff;
  --violet: #6941c6;
  --violet-soft: #f3edff;
  --shadow: 0 20px 60px rgba(18, 34, 66, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--soft);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.site-header {
  min-height: 76px;
  padding: 14px max(20px, calc((100vw - 1380px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 12px; font-size: 14px; }
.brand-mark {
  width: 48px;
  height: 38px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--blue);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
}
.header-actions, .actions, .toolbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.button, .collapse-button, .page-tab {
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #c9d7ef;
  border-radius: 8px;
  color: var(--blue);
  background: #fff;
  font-size: 12px;
  font-weight: 850;
}
.button:hover, .collapse-button:hover, .page-tab:hover { background: var(--blue-soft); }
.button-primary { color: #fff; background: var(--blue); border-color: var(--blue); }
.button-primary:hover { background: var(--blue-dark); }
.button-quiet { color: var(--muted); border-color: var(--line); }
.collapse-button { min-height: 34px; color: var(--muted); }

main {
  width: min(1380px, calc(100% - 40px));
  margin: auto;
  padding: 46px 0 72px;
}
.page-intro {
  margin-bottom: 28px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: end;
  gap: 28px;
}
h1 {
  max-width: 760px;
  margin: 0 0 12px;
  font-size: clamp(34px, 4vw, 54px);
  line-height: 1.02;
  letter-spacing: -.045em;
}
.page-intro p, .panel-head p, #result-note, #correction-note, #hold-result-note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}
.page-intro p { max-width: 760px; }
.page-tabs {
  padding: 6px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.page-tab {
  min-height: 46px;
  color: var(--muted);
  border-color: transparent;
}
.page-tab.is-active {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}
.page-view { display: block; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(340px, .92fr);
  gap: 18px;
  align-items: start;
}
.panel {
  padding: 26px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.panel.is-collapsed > :not(.panel-head):not(.toolbar) { display: none !important; }
.panel.is-collapsed .panel-head, .panel.is-collapsed .toolbar { margin-bottom: 0; }
.panel-head {
  margin-bottom: 22px;
  display: flex;
  align-items: flex-start;
  gap: 13px;
}
.panel-head .collapse-button { margin-left: auto; }
.panel-head > span {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 900;
}
h2 { margin: 0 0 4px; font-size: 20px; letter-spacing: -.02em; }
.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
}
.field { display: flex; flex-direction: column; gap: 7px; }
.field.wide { grid-column: 1 / -1; }
.field span, .checkbox { color: #344054; font-size: 11px; font-weight: 850; }
.field input, .field select, .field textarea {
  width: 100%;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d2dbe9;
  border-radius: 8px;
  outline: 0;
}
.field input, .field select { height: 44px; padding: 0 12px; }
.field textarea {
  min-height: 260px;
  max-height: 460px;
  padding: 13px 12px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre;
  overflow: auto;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: #77a7ff;
  box-shadow: 0 0 0 3px rgba(23, 105, 224, .1);
}
.actions { margin-top: 18px; }
.status { min-height: 20px; color: var(--muted); font-size: 12px; }
.status.error { color: var(--red); }
.status.success { color: var(--green); }
.warning-text { color: var(--amber); }

.baseline-stats {
  margin: 18px 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.baseline-stats article, .stat-card {
  padding: 12px;
  background: #f8faff;
  border: 1px solid #e2e9f5;
  border-radius: 10px;
}
.baseline-stats span, .stat-card span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}
.baseline-stats strong { font-size: 22px; line-height: 1; }
.duplicate-panel {
  margin: 0 0 18px;
  padding: 12px;
  color: var(--amber);
  background: var(--amber-soft);
  border: 1px solid #f3d27a;
  border-radius: 10px;
}
.duplicate-panel-title { margin-bottom: 8px; font-size: 12px; font-weight: 900; }
.duplicate-list { display: grid; gap: 8px; }
.duplicate-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 10px;
  background: #fffaf0;
  border: 1px solid #f5d98b;
  border-radius: 8px;
}
.duplicate-code { min-width: 132px; color: #7a4b00; font-size: 12px; }
.duplicate-meta { color: #7a4b00; font-size: 12px; line-height: 1.5; }

.drop-zone {
  min-height: 176px;
  padding: 24px;
  display: grid;
  place-items: center;
  gap: 8px;
  text-align: center;
  color: var(--blue);
  background: #fbfdff;
  border: 1px dashed #99b9ff;
  border-radius: 12px;
  cursor: pointer;
}
.drop-zone.is-dragging { background: var(--blue-soft); border-color: var(--blue); }
.drop-zone input { position: absolute; opacity: 0; pointer-events: none; }
.drop-zone strong { font-size: 15px; }
.drop-zone small { color: var(--muted); font-size: 12px; }
.csv-fields { margin-top: 18px; align-items: end; }
.compare-button { height: 44px; }

.summary-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.hold-summary-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stat-card { padding: 18px; background: #fff; }
.stat-card strong { font-size: 30px; line-height: 1; }
.stat-card.warning { background: var(--amber-soft); border-color: #f3d27a; }
.stat-card.muted { background: #f8faff; }

.results-panel, .correction-panel { margin-top: 18px; }
.toolbar {
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.checkbox { display: inline-flex; align-items: center; gap: 8px; }
.checkbox input { width: 16px; height: 16px; }
.table-shell {
  position: relative;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.baseline-shell { max-height: 520px; }
table { width: 100%; min-width: 980px; border-collapse: collapse; font-size: 12px; }
.baseline-table { min-width: 620px; }
.hold-baseline-table { min-width: 760px; }
.hold-result-table { min-width: 1040px; }
th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px 10px;
  color: #344054;
  background: #eef4ff;
  border-bottom: 1px solid #ccd9f0;
  text-align: left;
  white-space: nowrap;
}
td {
  padding: 11px 10px;
  border-bottom: 1px solid #e8ecf2;
  vertical-align: top;
  white-space: pre-wrap;
  word-break: break-word;
}
tr.is-mismatch { background: var(--amber-soft); }
tr.is-missing { background: var(--red-soft); }
tr.is-duplicate { background: #fff8de; }
tr.is-other { background: var(--violet-soft); }
.terminal-chip {
  display: inline-flex;
  min-width: 58px;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--cyan);
  background: var(--cyan-soft);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}
.duplicate-badge, .badge {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}
.duplicate-badge { margin-left: 8px; color: var(--amber); background: #ffeab0; }
.badge.ok { color: var(--green); background: var(--green-soft); }
.badge.diff { color: var(--amber); background: #ffeab0; }
.badge.missing { color: var(--red); background: #ffdfe4; }
.badge.other { color: var(--violet); background: var(--violet-soft); }
.empty { padding: 42px; text-align: center; color: var(--muted); }

.correction-actions { align-items: flex-end; }
.correction-filter { width: 180px; flex: 0 0 180px; }
.correction-layout {
  display: grid;
  grid-template-columns: minmax(260px, .55fr) minmax(0, 1.45fr);
  gap: 16px;
  align-items: start;
}
.copy-field textarea { min-height: 360px; max-height: 620px; background: #fbfdff; }
.reference-label { margin: 0 0 7px; color: var(--muted); font-size: 11px; font-weight: 850; }
.correction-shell { max-height: 620px; }
.correction-table { min-width: 760px; }
#correction-status { margin: -8px 0 14px; }
[hidden] { display: none !important; }

@media (max-width: 1100px) {
  .hold-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .page-intro, .workspace, .summary-grid, .correction-layout { grid-template-columns: 1fr; }
  .page-tabs { width: 100%; }
}
@media (max-width: 720px) {
  main { width: calc(100% - 28px); padding-top: 32px; }
  .site-header { align-items: flex-start; flex-direction: column; }
  .field-grid, .baseline-stats, .hold-summary-grid { grid-template-columns: 1fr; }
  .field.wide { grid-column: auto; }
  .toolbar, .panel-head { align-items: flex-start; flex-direction: column; }
  .toolbar-actions { align-items: stretch; flex-direction: column; width: 100%; }
  .toolbar-actions .button, .toolbar-actions .collapse-button, .panel-head .collapse-button, .correction-filter { width: 100%; }
  .panel-head .collapse-button { margin-left: 0; }
  .correction-filter { flex-basis: auto; }
}
