*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #f5f5f5;
  color: #222;
  min-height: 100vh;
}

header {
  background: #1a1a2e;
  color: #fff;
  padding: 1rem 2rem;
}

header h1 { font-size: 1.25rem; font-weight: 600; }
header p  { font-size: 0.8rem; color: #aaa; margin-top: 0.2rem; }

main { max-width: 1200px; margin: 2rem auto; padding: 0 1rem; }

.card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card h2 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e5e7eb;
  margin-bottom: 1.5rem;
}
.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: #4f46e5; }
.tab-active { color: #4f46e5; border-bottom-color: #4f46e5; }

.tab-panel { /* nothing needed — visibility handled inline */ }

.hint    { color: #aaa; font-weight: 400; }
.footnote { margin-top: 0.75rem; font-size: 0.78rem; color: #888; }

.form-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field label { font-size: 0.8rem; color: #555; font-weight: 500; }
.field input[type="text"],
.field input[type="file"] {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0.45rem 0.6rem;
  font-size: 0.9rem;
  outline: none;
}
.field input[type="text"]:focus { border-color: #4f46e5; }
.field input[type="file"] { padding: 0.35rem 0.4rem; cursor: pointer; }

button[type="submit"] {
  background: #4f46e5;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.5rem 1.2rem;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-width: 6.5rem;
  transition: background 0.15s ease, transform 0.06s ease, box-shadow 0.15s ease;
}
button[type="submit"]:hover:not(:disabled) {
  background: #4338ca;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
}
button[type="submit"]:active:not(:disabled) { transform: translateY(1px); }
button[type="submit"]:disabled { background: #a5b4fc; cursor: not-allowed; }
button[type="submit"].is-loading { background: #6366f1; cursor: wait; }

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

#msg { font-size: 0.85rem; color: #dc2626; margin-top: 0.5rem; min-height: 1.2em; }

#unredact-msg { font-size: 0.85rem; margin-top: 0.5rem; min-height: 1.2em; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; white-space: nowrap; }
th { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 2px solid #e5e7eb; color: #555; font-weight: 600; }
td { padding: 0.45rem 0.6rem; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-queued     { background: #fef9c3; color: #92400e; }
.badge-processing { background: #dbeafe; color: #1e40af; }
.badge-done       { background: #d1fae5; color: #065f46; }
.badge-failed     { background: #fee2e2; color: #991b1b; }

.dl-link {
  display: inline-block;
  margin-right: 0.4rem;
  padding: 0.2rem 0.55rem;
  background: #f3f4f6;
  border-radius: 4px;
  color: #4f46e5;
  text-decoration: none;
  font-size: 0.78rem;
}
.dl-link:hover { background: #e0e7ff; }

.empty { color: #aaa; font-size: 0.85rem; padding: 1rem 0.75rem; }

.mono { font-family: monospace; font-size: 0.78rem; color: #666; }

.radio-group {
  display: flex;
  gap: 1.5rem;
  margin: 0.75rem 0 0.5rem;
}
.radio-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: #444;
  cursor: pointer;
}

.msg-ok    { color: #065f46; }
.msg-warn  { color: #d97706; }
.msg-error { color: #dc2626; }

/* ── Excel header-row picker ── */
#header-config {
  margin-top: 1.25rem;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
}
.hc-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.45rem 0.75rem;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}
.hc-title  { font-size: 0.82rem; font-weight: 500; color: #374151; }
.hc-loading { font-size: 0.78rem; color: #9ca3af; }

.sheet-tabs {
  display: flex;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
  padding: 0 0.5rem;
}
.sheet-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  color: #6b7280;
  cursor: pointer;
}
.sheet-tab:hover { color: #4f46e5; }
.sheet-tab-active { color: #4f46e5; border-bottom-color: #4f46e5; }

.preview-scroll { overflow-x: auto; max-height: 220px; overflow-y: auto; }
.preview-table  { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.preview-row    { cursor: pointer; }
.preview-row:hover              { background: #f0f0ff; }
.preview-row-header             { background: #eef2ff; }
.preview-row-header:hover       { background: #e0e7ff; }
.preview-rownum {
  padding: 0.28rem 0.5rem;
  color: #9ca3af;
  font-family: monospace;
  font-size: 0.72rem;
  text-align: right;
  border-right: 1px solid #f0f0f0;
  width: 2rem;
  user-select: none;
  white-space: nowrap;
}
.preview-cell {
  padding: 0.28rem 0.5rem;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-right: 1px solid #f3f4f6;
}
.preview-badge-cell { padding: 0 0.4rem; width: 4rem; }
.preview-badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: #4f46e5;
  background: #e0e7ff;
  border-radius: 999px;
}
.preview-hint  { font-size: 0.75rem; color: #9ca3af; padding: 0.4rem 0.75rem; border-top: 1px solid #f3f4f6; }
.preview-empty { font-size: 0.82rem; color: #9ca3af; padding: 0.75rem; }
.preview-error { font-size: 0.82rem; color: #dc2626; padding: 0.75rem; }

/* ── Toast notifications ── */
#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1000;
  pointer-events: none;
  max-width: calc(100vw - 2rem);
}
.toast {
  pointer-events: auto;
  min-width: 240px;
  max-width: 380px;
  padding: 0.7rem 0.85rem;
  border-radius: 6px;
  background: #fff;
  border-left: 4px solid #6b7280;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
  font-size: 0.85rem;
  color: #1f2937;
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  animation: toast-in 0.25s cubic-bezier(0.21, 1.02, 0.73, 1);
}
.toast-out { animation: toast-out 0.2s ease-in forwards; }
.toast-success { border-left-color: #10b981; }
.toast-error   { border-left-color: #ef4444; }
.toast-warn    { border-left-color: #f59e0b; }
.toast-info    { border-left-color: #3b82f6; }

.toast-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.72rem;
  color: #fff;
  margin-top: 0.05rem;
}
.toast-success .toast-icon { background: #10b981; }
.toast-error   .toast-icon { background: #ef4444; }
.toast-warn    .toast-icon { background: #f59e0b; }
.toast-info    .toast-icon { background: #3b82f6; }

.toast-body { flex: 1; line-height: 1.35; word-break: break-word; }
.toast-close {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  padding: 0 0 0 0.25rem;
  font-size: 1.1rem;
  line-height: 1;
  align-self: flex-start;
}
.toast-close:hover { color: #4b5563; }

@keyframes toast-in {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes toast-out {
  to { transform: translateX(110%); opacity: 0; }
}

/* ── Help sections ── */
.help-section { padding: 1.25rem 0; border-bottom: 1px solid #f0f0f0; }
.help-section:last-child { border-bottom: none; }
.help-section h2 { font-size: 1rem; font-weight: 600; margin-bottom: 0.9rem; color: #1a1a2e; }
.help-section h3 { font-size: 0.88rem; font-weight: 600; color: #374151; margin: 1.1rem 0 0.45rem; }
.help-section p  { font-size: 0.88rem; color: #444; line-height: 1.6; margin-bottom: 0.6rem; }
.help-section ul, .help-section ol { font-size: 0.88rem; color: #444; line-height: 1.6; padding-left: 1.4rem; margin-bottom: 0.6rem; }
.help-section li { margin-bottom: 0.25rem; }

.steps { list-style: none; padding-left: 0; counter-reset: step; }
.steps li { counter-increment: step; display: flex; gap: 0.85rem; align-items: flex-start; margin-bottom: 0.75rem; }
.steps li::before {
  content: counter(step);
  flex-shrink: 0;
  width: 1.6rem; height: 1.6rem;
  background: #4f46e5; color: #fff;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700;
  margin-top: 0.05rem;
}
.steps li p { margin: 0; }

.pii-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.6rem; margin-top: 0.5rem; }
.pii-chip { display: flex; align-items: center; gap: 0.5rem; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px; padding: 0.45rem 0.7rem; font-size: 0.8rem; }
.pii-chip-icon { font-size: 1rem; flex-shrink: 0; }
.pii-chip-label { color: #374151; font-weight: 500; }
.pii-chip-desc  { color: #6b7280; font-size: 0.72rem; }

.callout { background: #eff6ff; border-left: 3px solid #3b82f6; border-radius: 0 6px 6px 0; padding: 0.65rem 0.9rem; font-size: 0.84rem; color: #1e3a8a; margin: 0.75rem 0; line-height: 1.5; }
.callout-warn { background: #fffbeb; border-left-color: #f59e0b; color: #78350f; }

.example-pill { display: inline-block; background: #e0e7ff; color: #3730a3; border-radius: 4px; padding: 0.15rem 0.5rem; font-family: monospace; font-size: 0.78rem; margin: 0.1rem 0.15rem; }

table.help-table { font-size: 0.82rem; white-space: normal; }
table.help-table th { color: #374151; background: #f9fafb; font-size: 0.78rem; }
table.help-table td { vertical-align: top; color: #444; }
table.help-table td:first-child { font-weight: 600; white-space: nowrap; color: #1a1a2e; }
