:root {
  --blue: #1565c0;
  --blue-dark: #0d47a1;
  --bg: #f4f7fb;
  --text: #1a1a1a;
  --muted: #5e6b7a;
  --border: #dbe3ef;
  --ok: #0f8b46;
  --warn: #c27000;
}

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

/* ── Top bar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 48px;
  background: linear-gradient(160deg, #1a56db 0%, var(--blue) 100%);
  color: #fff;
}
.brand {
  font-weight: 700;
  letter-spacing: 0.2px;
  font-size: 15px;
  color: #fff;
  text-decoration: none;
}
.nav { display: flex; gap: 4px; align-items: center; }
.nav-link {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  transition: background 0.15s;
}
.nav-link:hover { background: rgba(255,255,255,0.15); color: #fff; }
.nav-link.active { background: rgba(255,255,255,0.22); color: #fff; }
.nav-gear { font-size: 18px; padding: 4px 10px; }

/* ── Page ── */
.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px;
}

/* ── Flash ── */
.flash-wrap { margin-bottom: 12px; }
.flash { padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 6px; }
.flash-success { background: #e8f6ee; color: #145a32; border: 1px solid #b7e2c4; }
.flash-warning { background: #fff4df; color: #7a4a00; border: 1px solid #f0d3a4; }
.flash-error { background: #fde8e8; color: #7f1d1d; border: 1px solid #f5b9b9; }

/* ── Hero action ── */
.hero-action {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

/* ── Cards ── */
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}
.card h3 { margin: 0 0 6px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; }
.metric { margin: 0; font-size: 26px; font-weight: 700; }
.card.warn .metric { color: var(--warn); }

/* ── Panel ── */
.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.panel-head h2 { margin: 0; font-size: 17px; }
.hint { color: var(--muted); font-size: 12px; }
.user-meta { display: flex; align-items: center; gap: 10px; }

/* ── Buttons ── */
.btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.3;
}
.btn:hover { background: #f0f3f8; }
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-dark); }
.btn-lg { padding: 12px 24px; font-size: 15px; font-weight: 600; border-radius: 10px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { background: var(--red, #c00); color: #fff; border-color: var(--red, #c00); }
.btn-danger:hover { background: #a00; border-color: #a00; }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}
.tab {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  padding: 8px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}
th, td {
  border-bottom: 1px solid #edf1f7;
  padding: 8px;
  font-size: 13px;
  vertical-align: top;
}
th { text-align: left; color: var(--muted); font-weight: 600; }
td a { color: var(--blue-dark); text-decoration: none; font-weight: 600; }

tr.row-link { cursor: pointer; transition: background 0.1s; }
tr.row-link:hover { background: #f0f4fa; }
tr.row-link td { color: var(--text); }

/* ── Pills ── */
.pill {
  display: inline-block;
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #eef2f8;
}
.pill.ok { background: #dff5e7; color: var(--ok); }
.pill.warn { background: #fff0db; color: var(--warn); }

/* ── Audit tier pills (v2 scoring) ── */
/* grey → amber → yellow → light green → strong green */
.pill.tier-1 { background: #eceff3; color: #5a6676; }      /* undocumented    */
.pill.tier-2 { background: #ffe5c4; color: #8a4a00; }      /* documented      */
.pill.tier-3 { background: #fff4b8; color: #6b5800; }      /* corroborated    */
.pill.tier-4 { background: #d5f0c8; color: #3a6b1f; }      /* strong          */
.pill.tier-5 { background: #b7e4a1; color: #1f5a0c; font-weight: 600; } /* fully reconciled */
.pill.decision-new { background: #dff5e7; color: #0d6b36; }
.pill.decision-possible_update { background: #e8efff; color: #204ea8; }
.pill.decision-possible_duplicate,
.pill.decision-duplicate_in_file,
.pill.decision-conflict_in_file { background: #fff0db; color: #8a5200; }
.pill.decision-exact_duplicate { background: #eef2f8; color: #4f5f75; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.diff-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 4px;
}
.diff-list li { font-size: 12px; }

/* ── Forms ── */
.filters {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
}
.filter-grow {
  flex: 1;
  min-width: 160px;
}
label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
input, select, textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding-bottom: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.form-grid .full { grid-column: 1 / -1; }

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  margin-bottom: 10px;
}

/* ── Evidence ── */
.evidence-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.evidence-list li { border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.evidence-head { display: flex; justify-content: space-between; margin-bottom: 6px; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .topbar { padding: 0 10px; }
  .nav-link { font-size: 12px; padding: 6px 8px; }
  .nav-gear { font-size: 16px; padding: 4px 8px; }
  .cards { grid-template-columns: 1fr; }
  .form-grid, .kv-grid { grid-template-columns: 1fr; }
  .panel-head h2 { font-size: 16px; }
  .tabs { gap: 0; }
  .tab { font-size: 12px; padding: 8px 10px; }
  table { min-width: 0; }
  thead { display: none; }
  tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 6px;
    background: #fff;
  }
  tbody td {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px dashed #edf1f7;
    padding: 7px 4px;
  }
  tbody td:last-child { border-bottom: 0; }
  tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 600;
    min-width: 110px;
  }
}
