:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #172033;
  --muted: #637083;
  --line: #d9dee7;
  --accent: #2563eb;
  --danger: #b42318;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
h1 { margin: 0; font-size: 28px; }
h2 { margin-top: 32px; font-size: 20px; }
input, select, textarea, button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
}
textarea { min-height: 120px; resize: vertical; }
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 10px 14px;
  cursor: pointer;
}
button.secondary, .button.secondary { background: #fff; color: var(--text); border-color: var(--line); }
button.danger { background: var(--danger); border-color: var(--danger); }
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 60px;
  padding: 0 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--text); }
.topbar nav { display: flex; gap: 16px; flex: 1; }
.link-button { background: transparent; color: var(--accent); border: 0; padding: 0; }
.container { max-width: 1180px; margin: 0 auto; padding: 32px 24px; }
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.page-head p { margin: 6px 0 0; color: var(--muted); }
.toolbar, .form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
}
.toolbar input:first-child { grid-column: span 2; }
.form-grid label, fieldset { display: grid; gap: 6px; color: var(--muted); }
.form-grid .wide { grid-column: 1 / -1; }
.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
legend { color: var(--text); padding: 0 4px; }
.check { display: flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 8px; color: var(--text); }
.check input { width: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th { color: var(--muted); font-size: 13px; font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.actions { text-align: right; white-space: nowrap; }
.actions-row { display: flex; gap: 10px; }
.bulk-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.bulk-actions select { width: min(260px, 100%); }
.select-col { width: 44px; text-align: center; }
.select-col input { width: auto; }
.columns-panel { padding: 12px 16px; }
.columns-panel summary { cursor: pointer; font-weight: 600; }
.columns-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
}
.chip {
  display: inline-flex;
  margin: 2px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #29336f;
  font-size: 12px;
}
.color-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}
.empty { color: var(--muted); text-align: center; padding: 28px; }
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 18px;
  padding: 16px;
}
.panel h2 { margin: 0 0 12px; }
.muted { color: var(--muted); }
.mapping-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.mapping-grid label { display: grid; gap: 6px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
.merge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.merge-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.merge-option input { width: auto; margin-top: 4px; }
.merge-option strong,
.merge-option span { display: block; }
.merge-detail { margin-top: 10px; color: var(--muted); }
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-box {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
}
.login-box p { color: var(--muted); }
.stack { display: grid; gap: 14px; }
.alert {
  background: #fef3f2;
  color: var(--danger);
  border: 1px solid #fecdca;
  border-radius: 6px;
  padding: 10px 12px;
  margin: 14px 0;
}

@media (max-width: 760px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 14px 18px; gap: 12px; }
  .topbar nav { flex-wrap: wrap; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .toolbar, .form-grid, .compact, .mapping-grid { grid-template-columns: 1fr; }
  .toolbar input:first-child { grid-column: auto; }
  .bulk-actions { align-items: stretch; flex-direction: column; }
  .bulk-actions select, .bulk-actions button { width: 100%; }
  table { display: block; overflow-x: auto; }
}
