:root {
  /* Aligned with the sibling store-uploader app's palette (see its
     public/css/style.css) so the two read as the same product family
     from the shared portal homepage, without changing either app's
     markup/layout. Variable names kept as-is here to avoid touching
     every rule below -- only the values changed. */
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #dde1e6;
  --text: #1c2430;
  --text-muted: #5b6572;
  --primary: #1f5fbf;
  --primary-dark: #164a97;
  --danger: #c0362c;
  --danger-bg: #fdecea;
  --success: #1e7e46;
  --success-bg: #e8f6ee;
  --changed-bg: #fff7e0;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--primary); }

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.auth-card h1 {
  font-size: 20px;
  margin: 0 0 4px;
}

.auth-card p.subtitle {
  color: var(--text-muted);
  margin: 0 0 24px;
  font-size: 13px;
}

label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin: 14px 0 6px;
}

input[type="text"], input[type="email"], input[type="password"], input[type="number"], select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

button {
  cursor: pointer;
  font-size: 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 9px 16px;
  color: var(--text);
}

button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
button.primary:hover { background: var(--primary-dark); }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }

button.danger { color: var(--danger); border-color: var(--danger); background: #fff; }
button.link { border: none; background: none; color: var(--primary); padding: 0; }

.full-width { width: 100%; }

.error-banner {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fca5a1;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
  margin-top: 14px;
  display: none;
}
.error-banner.visible { display: block; }

.success-banner {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid #a6e5cf;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
  margin-top: 14px;
  display: none;
}
.success-banner.visible { display: block; }

/* --- App shell --- */
.app-header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.app-header .brand { font-weight: 700; font-size: 15px; }
.app-header .user-info { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-muted); }
.home-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.home-link:hover { background: var(--bg); color: var(--primary); }
/* Auth pages (login/register/reset/etc.) have no app-header of their own
   to hold the home-link -- pin it to the corner instead, so the "back to
   portal home" affordance stays available everywhere, not just once
   already logged in. */
.home-link-corner { position: fixed; top: 16px; left: 16px; background: var(--card-bg); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.auth-logo { display: block; width: 220px; max-width: 80%; height: auto; margin: 0 auto 24px; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 12px 6px;
  color: var(--text-muted);
  font-weight: 600;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.panel h2 { margin-top: 0; font-size: 16px; }
.panel h3 { font-size: 14px; margin: 0 0 8px; }

.hidden { display: none !important; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.dragover { border-color: var(--primary); background: #eaf1fb; color: var(--primary); }
.dropzone strong { color: var(--text); }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.toolbar .spacer { flex: 1; }
.small-text { font-size: 12px; color: var(--text-muted); }

.table-wrap {
  overflow: auto;
  max-height: 480px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
table.preview {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}
table.preview th, table.preview td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid #eef0f3;
  padding: 6px 8px;
  white-space: nowrap;
  text-align: left;
}
table.preview thead th {
  position: sticky;
  top: 0;
  background: #f8f9fb;
  z-index: 1;
}
table.preview td[contenteditable="true"] {
  cursor: text;
}
table.preview td[contenteditable="true"]:focus {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
table.preview td.changed { background: var(--changed-bg); }
table.preview td.row-index-cell { color: var(--text-muted); background: #fafafa; }
table.preview th .col-type { font-weight: 400; color: var(--text-muted); font-size: 11px; display: block; }

.pagination { display: flex; align-items: center; gap: 8px; margin-top: 10px; }

.mapping-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px 12px;
  max-height: 160px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
}
.checkbox-grid label {
  font-weight: 400;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.results-summary {
  display: flex;
  gap: 24px;
  margin-bottom: 12px;
}
.results-summary .stat { font-size: 22px; font-weight: 700; }
.results-summary .stat.ok { color: var(--success); }
.results-summary .stat.fail { color: var(--danger); }
.results-summary .label { font-size: 12px; color: var(--text-muted); }

.history-table, .settings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.history-table th, .history-table td, .settings-table th, .settings-table td {
  border-bottom: 1px solid var(--border);
  padding: 8px;
  text-align: left;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge.admin { background: #e8f0fc; color: var(--primary); }

.metric-block {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  margin-top: 14px;
  background: #fbfbfc;
}
.field-form {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  margin-top: 10px;
  background: #fff;
}

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid #d0d5dd;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
