:root {
  --teal: #004f49;
  --teal-2: #08756d;
  --ink: #17211f;
  --muted: #66736f;
  --line: #d9e1de;
  --paper: #ffffff;
  --soft: #f3f7f5;
  --warn: #a15c00;
  --warn-bg: #fff4dc;
  --ok: #11653d;
  --ok-bg: #e7f5ed;
  --bad: #9b1c1c;
  --bad-bg: #fde7e7;
  --shadow: 0 10px 28px rgba(25, 40, 36, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: #eef3f1;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(18px, 4vw, 48px);
  color: #fff;
  background: var(--teal);
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  font-weight: 700;
  letter-spacing: 0;
}

.topnav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.topnav a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 7px 11px;
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
}

.topnav a[aria-current="page"],
.topnav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.eyebrow {
  margin: 0 0 4px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.eyebrow.dark {
  color: var(--muted);
}

main {
  width: min(1360px, calc(100% - 32px));
  margin: 0 auto;
}

.import-band {
  margin: 24px 0;
  padding: 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.dashboard {
  width: min(1500px, calc(100% - 32px));
}

.stats-band,
.filters-band,
.property-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stats-band,
.filters-band {
  margin: 24px 0 16px;
  padding: 18px;
}

.filters-band {
  margin-top: 0;
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(150px, 210px) minmax(220px, 1.2fr) minmax(180px, 240px);
  gap: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
  padding-bottom: 48px;
}

.property-panel {
  min-width: 0;
  padding: 18px;
}

.import-grid {
  display: grid;
  grid-template-columns: minmax(190px, 260px) minmax(280px, 1fr) auto;
  gap: 16px;
  align-items: end;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field span,
.mini-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

input:focus,
select:focus,
button:focus {
  outline: 3px solid rgba(8, 117, 109, 0.22);
  outline-offset: 2px;
}

.drop-zone {
  min-height: 86px;
  display: grid;
  place-items: center;
  padding: 16px;
  color: var(--teal);
  background: var(--soft);
  border: 2px dashed #9dbab4;
  border-radius: 8px;
  cursor: pointer;
}

.drop-zone strong,
.drop-zone span {
  display: block;
  text-align: center;
}

.drop-zone.is-active {
  background: #e4f1ee;
  border-color: var(--teal-2);
}

.sheet-add {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.sheet-add .field {
  flex: 1;
}

#masterRows {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  padding: 10px;
  border: 1px solid #cbd5d1;
  border-radius: 8px;
  resize: vertical;
  box-sizing: border-box;
}

.auto-sync-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: auto;
  font-size: 0.9rem;
  color: var(--teal);
  white-space: nowrap;
}

.bulk-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

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

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.button.primary {
  color: #fff;
  background: var(--teal);
}

.button.secondary {
  color: var(--teal);
  background: #fff;
  border-color: #9dbab4;
}

.button.danger {
  color: var(--bad);
  background: var(--bad-bg);
}

.work-area {
  padding-bottom: 48px;
}

.section-head,
.file-head,
.file-controls,
.status-row,
.mapping-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.section-head {
  margin: 10px 0 16px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.muted {
  color: var(--muted);
}

.file-list {
  display: grid;
  gap: 16px;
}

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

.file-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.file-title {
  min-width: 0;
}

.file-title strong {
  display: block;
  overflow-wrap: anywhere;
}

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

.file-body {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.file-controls {
  align-items: end;
  flex-wrap: wrap;
}

.control-grid {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(190px, 260px) minmax(190px, 240px);
  gap: 12px;
}

.file-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}

.preview-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.preview-summary strong,
.preview-summary span {
  display: block;
}

.preview-summary strong {
  font-size: 0.98rem;
}

.metric {
  padding: 10px 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  font-size: 1.1rem;
}

.status-row {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.status.idle {
  color: var(--muted);
  background: var(--soft);
}

.status.busy {
  color: var(--teal);
  background: #e4f1ee;
}

.status.ok {
  color: var(--ok);
  background: var(--ok-bg);
}

.status.todo {
  color: var(--muted);
  background: var(--soft);
}

.status.in_progress {
  color: var(--warn);
  background: var(--warn-bg);
}

.status.done {
  color: var(--ok);
  background: var(--ok-bg);
}

.status.na {
  color: #4c5966;
  background: #eef1f4;
}

.status.warn {
  color: var(--warn);
  background: var(--warn-bg);
}

.status.bad {
  color: var(--bad);
  background: var(--bad-bg);
}

.message {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.message.bad {
  color: var(--bad);
}

.mapping-head h3,
.sample h3 {
  margin: 0;
  font-size: 1rem;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  background: var(--soft);
  font-size: 0.78rem;
  font-weight: 800;
}

tr:last-child td {
  border-bottom: 0;
}

.property-table table {
  min-width: 1020px;
}

.property-row {
  cursor: pointer;
}

.property-row:hover td,
.property-row.is-selected td {
  background: #f5faf8;
}

.property-row.is-selected td:first-child {
  border-left: 4px solid var(--teal);
}

.property-row td strong,
.property-row td span {
  display: block;
}

.property-row td span {
  color: var(--muted);
  font-size: 0.84rem;
}

.progress-cell {
  display: grid;
  gap: 5px;
  min-width: 140px;
}

.progress-cell > span {
  color: var(--muted);
  font-size: 0.82rem;
}

.progress-bar {
  width: 100%;
  height: 9px;
  overflow: hidden;
  background: #dde8e5;
  border-radius: 999px;
}

.progress-bar span {
  display: block;
  height: 100%;
  background: var(--teal-2);
  border-radius: inherit;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.checklist-subrow td {
  padding: 0;
  background: #fbfdfc;
}

.inline-checklist-shell {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-left: 4px solid var(--teal);
}

.inline-checklist-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.inline-checklist-head strong {
  overflow-wrap: anywhere;
}

.inline-checklist-scroll {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.task-matrix {
  width: max-content;
  min-width: 100%;
  table-layout: fixed;
}

.task-matrix th,
.task-matrix td {
  width: 150px;
  min-width: 150px;
  max-width: 150px;
  text-align: center;
}

.task-matrix th {
  height: 58px;
  vertical-align: bottom;
  overflow-wrap: anywhere;
}

.task-checkbox {
  display: grid;
  justify-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.task-checkbox input {
  width: 22px;
  min-height: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--teal);
}

/* Assessment booked is a board column rather than a checklist matrix cell, so
   it reads horizontally and left-aligned like the other property columns. */
.board-task {
  grid-auto-flow: column;
  justify-items: start;
  justify-content: start;
  align-items: center;
  gap: 8px;
  min-width: 118px;
}

.property-row .board-task span {
  display: inline;
  font-size: 0.82rem;
}

tr.is-unmapped td:first-child {
  border-left: 4px solid var(--warn);
}

.sample-values {
  max-width: 420px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.empty-state {
  display: grid;
  gap: 4px;
  padding: 32px 18px;
  color: var(--muted);
  text-align: center;
  background: var(--paper);
  border: 1px dashed #b8c7c3;
  border-radius: 8px;
}

.empty-state strong {
  color: var(--ink);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .import-grid,
  .control-grid,
  .metrics,
  .filter-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .bulk-actions,
  .file-actions,
  .file-controls,
  .section-head,
  .file-head,
  .topbar,
  .inline-checklist-head,
  .pager {
    align-items: stretch;
    flex-direction: column;
  }

  .button {
    width: 100%;
  }
}
