:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #d8dce1;
  --text: #1f2430;
  --muted: #6b7280;
  --brand: #2f6f4f;
  --brand-dark: #24563d;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --ok-bg: #eaf6ee;
  --warn-bg: #fff6e5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

header.topbar h1 {
  font-size: 1.05rem;
  margin: 0;
}

main {
  max-width: 960px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.login-wrap {
  max-width: 360px;
  margin: 4rem auto;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
  margin-top: 0.9rem;
}

input[type="text"],
input[type="password"],
input[type="file"] {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--brand);
  color: white;
}

button:hover {
  background: var(--brand-dark);
}

button:disabled {
  background: #a9b0ba;
  cursor: not-allowed;
}

button.secondary {
  background: transparent;
  color: var(--brand-dark);
  border: 1px solid var(--border);
}

.error-banner {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #f3c6c3;
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  margin: 0.75rem 0;
  font-size: 0.9rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.summary-tile {
  border-radius: 6px;
  padding: 0.75rem;
  text-align: center;
}

.summary-tile .count {
  font-size: 1.5rem;
  font-weight: 700;
  display: block;
}

.summary-tile .label {
  font-size: 0.78rem;
  color: var(--muted);
}

.summary-tile.ok { background: var(--ok-bg); }
.summary-tile.warn { background: var(--warn-bg); }
.summary-tile.danger { background: var(--danger-bg); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

th, td {
  border-bottom: 1px solid var(--border);
  padding: 0.4rem 0.5rem;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

tr.rejected td { background: var(--danger-bg); }
tr.warn-row td { background: var(--warn-bg); }

.table-scroll {
  overflow-x: auto;
}

/* The rejected-row fix-up table (public/assets/import.js) has ~12 columns
   including several inline inputs/selects. Without this, the browser
   shrinks the table to the container width and wraps long cell text (the
   Reasons column especially) into many lines, ballooning row height --
   ".table-scroll" exists specifically so a wide table can scroll
   horizontally instead. `.reasons-cell` opts back into wrapping, but
   capped to a sane width, so one long reason doesn't stretch the table
   sideways forever. */
#rejected-section td {
  white-space: nowrap;
}

#rejected-section td.reasons-cell {
  white-space: normal;
  /* table-layout:auto sizes a column from the *largest declared width* of
     any cell in it -- an explicit width (not max-width) is what actually
     reserves the space reliably; without it the auto algorithm gives a
     wrapping column only its longest-unbreakable-word width and hands the
     rest to the nowrap columns instead. */
  width: 240px;
}

/* table-layout:auto's column-width algorithm turned out unreliable for
   this ~12-column fix-up table (it wasn't honoring the reasons-cell's
   declared width -- see the colgroup in import.html). `table-layout:
   fixed` makes every column width come solely from its <col>, but a fixed
   table with `width: auto` still just fills/redistributes within its
   containing block (a plain block-level table doesn't grow to its
   content) -- it does NOT size itself to the colgroup sum the way
   `width: auto` might suggest. Setting an explicit width equal to that sum
   (must match the colgroup total in import.html) is what actually makes
   the table wider than `.table-scroll`'s container so it scrolls
   horizontally instead of squeezing every column (and wrapping the
   reasons text into a towering column) to fit. */
#rejected-section table {
  table-layout: fixed;
  width: 1400px;
}

.tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  text-transform: uppercase;
}

.tag.create { background: var(--ok-bg); color: var(--brand-dark); }
.tag.update { background: #e6effa; color: #1e4f8f; }
.tag.reactivate { background: var(--warn-bg); color: #8a5a00; }

.muted { color: var(--muted); font-size: 0.85rem; }

.actions-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1rem;
}

.hidden { display: none !important; }

progress {
  width: 100%;
  height: 0.6rem;
  margin-top: 0.9rem;
  accent-color: var(--brand);
}

/* Inline edit controls inside a table cell (rejected-row fix-up UI). Width
   comes from the fixed column (see colgroup in import.html), not a
   min-width here -- table-layout:fixed already reserves the space. */
td select,
td input[type="text"],
td input[type="number"] {
  width: 100%;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 0.82rem;
  background: white;
}

td input.invalid,
td select.invalid {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.suggest-chip {
  margin-top: 0.3rem;
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  white-space: normal;
}

.suggest-chip .apply-btn {
  padding: 0.1rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 999px;
  background: var(--ok-bg);
  color: var(--brand-dark);
  border: 1px solid #bfe0cc;
  cursor: pointer;
}

.suggest-chip .apply-btn:hover {
  background: #d9f0e1;
}

.suggest-chip.fuzzy .apply-btn {
  background: var(--warn-bg);
  color: #8a5a00;
  border-color: #f0dba8;
}

button.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
}

tr.row-fixed td {
  background: var(--ok-bg);
  transition: background 0.4s ease;
}

.row-status {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.2rem;
}
