:root {
  --text: #1f2933;
  --muted: #64717d;
  --background: #f5f6f7;
  --surface: #ffffff;
  --border: #d8dde2;
  --primary: #176b4d;
  --primary-light: #e8f3ed;
  --warning: #9a571e;
  --warning-light: #fff2df;
  --danger: #9b302c;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--background);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--background); }
button, input { font: inherit; }
button { color: inherit; }
.page-shell { width: min(1000px, calc(100% - 32px)); margin: 0 auto; }

.site-header { padding: 20px 0; border-bottom: 1px solid var(--border); }
.brand { color: var(--text); font-size: 1.1rem; font-weight: 700; text-decoration: none; }
.page-heading { padding: 38px 0 22px; }
.page-heading h1 { margin: 0; font-size: 1.8rem; }
.page-heading p { margin: 7px 0 0; color: var(--muted); }

.compare-panel { padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.panel-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 20px; }
.panel-heading h2 { margin: 0; font-size: 1.15rem; }
.file-limit { color: var(--muted); font-size: .8rem; }
.file-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.file-field { display: grid; gap: 8px; padding: 12px; font-size: .88rem; font-weight: 650; border: 1px dashed var(--border); border-radius: 6px; transition: border-color .15s, background .15s; }
.file-field.is-dragging { border-color: var(--primary); background: var(--primary-light); }
.file-field.has-file { border-style: solid; border-color: var(--primary); }
.file-field input { width: 100%; padding: 10px; color: var(--muted); background: var(--background); border: 1px solid var(--border); border-radius: 6px; }
.file-field input::file-selector-button { margin-right: 10px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text); cursor: pointer; }
.file-field small { min-height: 1.2em; color: var(--muted); font-weight: 400; overflow-wrap: anywhere; }
.file-field.has-file small { color: var(--primary); }

.compare-button { margin-top: 20px; padding: 10px 16px; border: 0; border-radius: 6px; background: var(--primary); color: white; font-weight: 650; cursor: pointer; }
.compare-button:hover { background: #12573e; }
.compare-button:disabled { opacity: .65; cursor: wait; }

#result-region { scroll-margin-top: 18px; }
.results { margin-top: 24px; }
.result-header { padding: 20px; color: white; background: #34433d; border-radius: 8px 8px 0 0; }
.result-header.is-identical { background: var(--primary); }
.result-header h2 { margin: 0; font-size: 1.3rem; }
.result-header p { margin: 7px 0 0; color: rgba(255, 255, 255, .78); font-size: .85rem; overflow-wrap: anywhere; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface); border: 1px solid var(--border); border-top: 0; }
.stats div { padding: 16px 20px; border-right: 1px solid var(--border); }
.stats div:last-child { border-right: 0; }
.stats span, .stats small { display: block; }
.stats span { font-size: 1.5rem; font-weight: 650; }
.stats small { margin-top: 2px; color: var(--muted); font-size: .72rem; }

.sheet-strip { display: flex; gap: 8px; overflow-x: auto; padding: 18px 0 12px; }
.sheet-chip { padding: 8px 11px; white-space: nowrap; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.sheet-chip span, .sheet-chip small { display: block; }
.sheet-chip span { font-weight: 650; }
.sheet-chip small { margin-top: 2px; color: var(--muted); }
.sheet-chip.changed { border-left: 3px solid var(--warning); }
.sheet-chip.added { border-left: 3px solid var(--primary); }
.sheet-chip.removed { border-left: 3px solid var(--danger); }
.sheet-chip.active { color: white; background: var(--text); border-color: var(--text); }
.sheet-chip.active small { color: #ccd2d0; }
.row-recap { margin: 8px 0 22px; }
.row-recap h3, .detail-title { margin: 0 0 10px; font-size: 1rem; }
.result-tools { display: flex; align-items: center; gap: 12px; margin: 6px 0 10px; }
.search-control { flex: 1; }
.search-control input { width: 100%; padding: 9px 11px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
.search-control input:focus { outline: 2px solid rgba(23, 107, 77, .2); border-color: var(--primary); }
.clear-filter { padding: 0; color: var(--primary); background: transparent; border: 0; cursor: pointer; text-decoration: underline; }
.result-tools > span { color: var(--muted); font-size: .78rem; white-space: nowrap; }

.diff-table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 7px; }
.diff-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.diff-table th { color: var(--muted); background: #eef0f2; font-size: .72rem; text-align: left; }
.diff-table th, .diff-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.diff-table tbody tr + tr td { border-top: 2px solid var(--border); }
.diff-table code { color: #14543f; white-space: nowrap; }
.row-number-list { line-height: 1.8; overflow-wrap: anywhere; }
.cell-value { min-width: 140px; max-width: 320px; overflow-wrap: anywhere; white-space: pre-wrap; }
.change-tag { display: inline-block; padding: 3px 7px; color: var(--warning); background: var(--warning-light); border-radius: 10px; white-space: nowrap; font-size: .7rem; }

.message { margin-top: 18px; padding: 13px 15px; border-radius: 6px; }
.message p { margin: 4px 0 0; }
.error-message { color: var(--danger); background: #f9e7e5; border: 1px solid #e4b7b3; }
.warning-message { color: #76501e; background: var(--warning-light); border: 1px solid #e8c995; }
.identical-note { padding: 18px; color: var(--primary); background: var(--primary-light); text-align: center; border-radius: 0 0 7px 7px; }
.empty-filter { padding: 24px; color: var(--muted); text-align: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 640px) {
  .page-shell { width: min(100% - 20px, 1000px); }
  .page-heading { padding-top: 28px; }
  .compare-panel { padding: 18px; }
  .panel-heading { display: block; }
  .file-limit { display: block; margin-top: 5px; }
  .file-grid { grid-template-columns: 1fr; }
  .compare-button { width: 100%; }
  .stats div { padding: 13px 10px; }
  .stats span { font-size: 1.25rem; }
  .result-tools { flex-wrap: wrap; }
  .search-control { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
