:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #64748b;
  --line: #d8dee8;
  --primary: #155eef;
  --primary-dark: #0f47b8;
  --danger: #b42318;
  --warning: #a15c07;
  --success: #067647;
  --soft-blue: #eef4ff;
  --shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

h1, h2, p { margin: 0; }

h1 {
  font-size: 30px;
  line-height: 1.2;
  font-weight: 800;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
  font-weight: 750;
}

p { color: var(--muted); margin-top: 6px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.upload-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) minmax(180px, 0.7fr);
  gap: 16px;
  padding: 18px;
  margin-bottom: 18px;
}

.mapping-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.field-group.compact { min-width: 180px; }

label {
  color: #344054;
  font-weight: 700;
  font-size: 13px;
}

input[type="file"], input[type="text"], select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
}

input[type="file"] { padding: 7px 10px; }

select:disabled, button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.mapping-list {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.mapping-row {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) 92px;
  align-items: center;
  gap: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  background: #f1f5f9;
  color: #475569;
  white-space: nowrap;
}

.badge.good { background: #ecfdf3; color: var(--success); }
.badge.warn { background: #fff7ed; color: var(--warning); }
.badge.bad { background: #fef3f2; color: var(--danger); }

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 18px;
}

.button {
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 40px;
  padding: 9px 14px;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.button.primary {
  background: var(--primary);
  color: white;
}

.button.primary:hover:not(:disabled) { background: var(--primary-dark); }

.button.secondary {
  background: white;
  border-color: #cbd5e1;
  color: #344054;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  box-shadow: var(--shadow);
}

.kpi-card span {
  display: block;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 8px;
}

.kpi-card strong {
  display: block;
  font-size: 26px;
  line-height: 1;
}

.preview-panel { overflow: hidden; }
.table-wrap {
  width: 100%;
  overflow: auto;
  max-height: 62vh;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1040px;
}

th, td {
  border-bottom: 1px solid #e5e7eb;
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr:hover { background: var(--soft-blue); }

.empty-state {
  color: var(--muted);
  padding: 24px;
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.message {
  border-radius: 8px;
  padding: 10px 12px;
  border: 1px solid;
  background: white;
  font-weight: 700;
}

.message.error {
  color: var(--danger);
  border-color: #fecdca;
  background: #fffbfa;
}

.message.warning {
  color: var(--warning);
  border-color: #fedf89;
  background: #fffcf5;
}

.message.success {
  color: var(--success);
  border-color: #abefc6;
  background: #f6fef9;
}

@media (max-width: 980px) {
  .upload-grid, .mapping-grid, .kpi-grid { grid-template-columns: 1fr; }
  .topbar, .panel-header { flex-direction: column; }
  .field-group.compact { width: 100%; }
  .mapping-row { grid-template-columns: 1fr; }
  .actions { justify-content: stretch; flex-direction: column; }
  .button { width: 100%; }
}

.confirm-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 2px;
  color: #344054;
  font-weight: 700;
}

.confirm-row input {
  width: 16px;
  height: 16px;
}
