/* Board Watch — single stylesheet, no framework. Minimal, clean, dense tables. */

:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1e2430;
  --muted: #6b7280;
  --line: #e3e4e8;
  --accent: #1f5fbf;
  --accent-soft: #e8f0fc;
  --ok: #1a7f4b;
  --warn: #b45309;
  --bad: #b91c1c;
  --mark: #fde68a;
}

* { box-sizing: border-box; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

h1 { font-size: 1.4rem; margin: 1rem 0 0.75rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.5rem; }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.error { color: var(--bad); }
.empty-state { color: var(--muted); padding: 2rem 0; }
.breadcrumb { margin: 0.75rem 0 0; font-size: 0.85rem; }

/* --- Top bar --------------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0.6rem 1.25rem;
}
.topbar .brand a { font-weight: 700; color: var(--text); }
.topbar nav { display: flex; gap: 1rem; flex: 1; }
.topbar nav a { color: var(--muted); padding: 0.2rem 0.1rem; }
.topbar nav a.active { color: var(--text); font-weight: 600; border-bottom: 2px solid var(--accent); }
.userbox { display: flex; gap: 0.75rem; align-items: center; font-size: 0.85rem; }

/* --- Flash messages ---------------------------------------------------------- */
.flashes { margin: 0.75rem 0; }
.flash { padding: 0.5rem 0.75rem; border-radius: 6px; margin-bottom: 0.4rem; font-size: 0.9rem; }
.flash-ok { background: #e7f6ee; color: var(--ok); border: 1px solid #bfe6d0; }
.flash-error, .flash-message { background: #fdecec; color: var(--bad); border: 1px solid #f5c6c6; }

/* --- Auth cards ---------------------------------------------------------------- */
.authcard {
  max-width: 380px; margin: 3rem auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 1.5rem;
}
.authcard label { display: block; margin: 0.75rem 0 0; font-size: 0.85rem; color: var(--muted); }
.authcard input {
  display: block; width: 100%; margin-top: 0.25rem; padding: 0.5rem;
  border: 1px solid var(--line); border-radius: 6px; font-size: 0.95rem;
}
.authcard button { margin-top: 1rem; width: 100%; }

/* --- Forms / filter bar ----------------------------------------------------------- */
button, .button {
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 0.45rem 0.9rem; font-size: 0.9rem; cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button.linkish {
  background: none; color: var(--accent); padding: 0 0.15rem; font-size: 0.8rem;
}
button.linkish:hover { text-decoration: underline; }

.filterbar {
  display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; align-items: end;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 0.75rem 1rem; margin-bottom: 1rem; font-size: 0.85rem;
}
.filterbar label { display: flex; flex-direction: column; gap: 0.2rem; color: var(--muted); }
.filterbar label.inline { flex-direction: row; align-items: center; gap: 0.4rem; }
.filterbar label.inline input { min-width: 0; }
.filterbar input, .filterbar select {
  padding: 0.3rem 0.4rem; border: 1px solid var(--line); border-radius: 5px;
  font-size: 0.88rem; background: #fff; min-width: 7rem;
}
.filterbar .searchbox { min-width: 22rem; }

/* --- Tables ------------------------------------------------------------------- */
.datatable {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  font-size: 0.9rem;
}
.datatable th, .datatable td {
  text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.datatable thead th {
  background: #fafafa; font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted);
}
.datatable tbody tr:hover { background: #fbfcfe; }

/* --- Badges ---------------------------------------------------------------------- */
.badge {
  display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px;
  font-size: 0.74rem; font-weight: 600; white-space: nowrap;
  background: #eef0f3; color: var(--muted);
}
.badge.status-new { background: var(--accent-soft); color: var(--accent); }
.badge.status-lead { background: #e7f6ee; color: var(--ok); }
.badge.status-reviewed { background: #eef0f3; color: var(--muted); }
.badge.status-dismissed { background: #f3f4f6; color: #9ca3af; }
.badge.status-superseded { background: #f5f3ff; color: #6d28d9; }
/* corpus, not queue — reads quieter than dismissed, which was a human call */
.badge.status-archived { background: #f3f4f6; color: #9ca3af; }
.badge.status-ok { background: #e7f6ee; color: var(--ok); }
.badge.status-failing, .badge.status-failed,
.badge.status-fetch_failed, .badge.status-extract_failed,
.badge.status-classify_failed, .badge.status-failed_permanent {
  background: #fdecec; color: var(--bad);
}
.badge.status-not_attempted { background: #fff7ed; color: var(--warn); }
.badge.status-confirmed_no_online_docs { background: #f3f4f6; color: #6b7280; }
.badge.status-needs_ocr, .badge.status-awaiting,
.badge.status-needs_review { background: #fff7ed; color: var(--warn); }
.badge.source-gone { background: #fdecec; color: var(--bad); }
.badge.platform-boarddocs { background: var(--accent-soft); color: var(--accent); }
.badge.platform-simbli { background: #ecfdf5; color: #047857; }
.badge.platform-custom { background: #f5f3ff; color: #6d28d9; }
.badge.platform-unknown { background: #f3f4f6; color: #9ca3af; }
.badge[class*="cat-"] { background: var(--accent-soft); color: var(--accent); }
.badge.cat-international { background: #fef3c7; color: #92400e; }
.badge.cat-vendor_contract { background: #fdecec; color: var(--bad); }
/* Inline category editor: a badge-shaped select that saves on change. */
.cat-select {
  border: 1px solid transparent; border-radius: 10px; padding: 2px 6px;
  font-size: 0.78rem; cursor: pointer; -webkit-appearance: none; appearance: none;
  background: var(--accent-soft); color: var(--accent); max-width: 11rem;
}
.cat-select:hover { border-color: var(--line); }
.cat-select.cat-international { background: #fef3c7; color: #92400e; }
.cat-select.cat-vendor_contract { background: #fdecec; color: var(--bad); }
.badge[class*="doctype-"] { background: #eef0f3; color: var(--muted); }

/* --- Flags view --------------------------------------------------------------------- */
.bulkbar {
  display: flex; gap: 0.75rem; align-items: center;
  margin-bottom: 0.5rem; font-size: 0.85rem;
}
.bulkbar select { padding: 0.3rem 0.4rem; border: 1px solid var(--line); border-radius: 5px; }
.flags-table .flag-body { max-width: 34rem; }
.flags-table .summary { margin-bottom: 0.2rem; }
.snippet {
  margin: 0.35rem 0; padding: 0.5rem 0.7rem; border-left: 3px solid var(--line);
  background: #fafafa; font-size: 0.85rem; white-space: pre-wrap; word-break: break-word;
}
.noteform textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 5px;
  font: inherit; font-size: 0.85rem; padding: 0.35rem; margin: 0.3rem 0;
}
.statuscell .transitions { display: flex; flex-wrap: wrap; gap: 0.1rem; margin-top: 0.3rem; }
.statuscell form { display: inline; }
details > summary { cursor: pointer; }

/* --- Search results -------------------------------------------------------------------- */
.search-results { padding-left: 1.5rem; }
.search-hit { margin-bottom: 1rem; }
.hit-meta { font-size: 0.85rem; margin-bottom: 0.15rem; }
.headline {
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  padding: 0.5rem 0.7rem; font-size: 0.9rem; word-break: break-word;
}
mark { background: var(--mark); padding: 0 0.1rem; border-radius: 2px; }

/* --- District stats --------------------------------------------------------------------- */
.statgrid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem; margin: 1rem 0;
}
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 0.6rem 0.8rem;
}
.stat-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.stat-value { margin-top: 0.2rem; font-size: 0.95rem; }

/* --- Coverage ------------------------------------------------------------------------------ */
.stuck-panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 0.75rem 1rem 1rem; margin: 1rem 0 1.5rem;
}
.stuck-counts { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.stuck-count {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.3rem 0.6rem; border: 1px solid var(--line); border-radius: 6px;
  color: var(--text);
}
.stuck-count.active { border-color: var(--accent); background: var(--accent-soft); }
.stuck-count:hover { text-decoration: none; border-color: var(--accent); }
tr.coverage-failing td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
tr.coverage-not_attempted td:first-child { box-shadow: inset 3px 0 0 var(--warn); }

/* --- Pagination -------------------------------------------------------------------------------- */
.pagination {
  display: flex; gap: 1rem; align-items: center; justify-content: center;
  margin: 1rem 0; font-size: 0.9rem;
}

.doc-links { display: flex; flex-direction: column; gap: 0.15rem; }

/* --- Coverage choropleth map -------------------------------------------------- */
.coverage-map {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem 1.25rem 1.25rem;
  margin-bottom: 1.5rem;
}
.coverage-map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}
.coverage-map-legend .legend-item { display: inline-flex; align-items: center; gap: 0.4rem; }
.coverage-map-legend .legend-swatch {
  width: 14px; height: 14px; border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.12);
}
.coverage-map-legend b { font-variant-numeric: tabular-nums; }
.ny-map {
  display: block;
  width: 100%;
  height: auto;
  max-height: 70vh;
}
.ny-map path {
  stroke: #ffffff;
  stroke-width: 0.5;
  stroke-linejoin: round;
  transition: fill 0.1s ease;
}
.ny-map path:hover { stroke: var(--text); stroke-width: 1.2; }

/* --- Competitor watch chips --------------------------------------------------- */
.competitor-watch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.competitor-watch .cw-label {
  font-weight: 600;
  color: var(--muted);
  margin-right: 0.25rem;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.cw-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
}
.cw-chip b { font-variant-numeric: tabular-nums; color: var(--accent); }
.cw-chip:hover { border-color: var(--accent); }
.cw-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.cw-chip.active b { color: #fff; }
.cw-clear { font-size: 0.9rem; color: var(--muted); }

/* --- Sortable table headers --------------------------------------------------- */
.flags-table thead th a {
  color: var(--text);
  display: inline-block;
  white-space: nowrap;
}
.flags-table thead th a:hover { color: var(--accent); }
.flags-table thead th.sorted a { color: var(--accent); font-weight: 700; }

/* --- Export CSV link ---------------------------------------------------------- */
.export-csv {
  margin-left: auto;
  align-self: center;
  font-size: 0.95rem;
  white-space: nowrap;
}
