/* Control Center — a desk tool. Dense tables, small controls,
   light by default with a dark variant that follows the operating system. */

:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #14171c;
  --text-dim: #5b6472;
  --primary: #1f6feb;
  --danger: #d1392b;
  --ok: #1a7f4b;
  --warn: #9a6200;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218; --surface: #161a22; --border: #262c38;
    --text: #e8eaee; --text-dim: #9aa3b2; --warn: #e0a83a;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
}

code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.9em; }
a { color: var(--primary); }

/* --- Chrome -------------------------------------------------------------- */

.chrome {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}

.brand { font-weight: 700; cursor: pointer; }
.chrome-right { display: flex; align-items: center; gap: 12px; }

.root { max-width: 1100px; margin: 0 auto; padding: 24px; }

/* --- Login --------------------------------------------------------------- */

.login-wrap { min-height: 70vh; display: grid; place-items: center; }
.login {
  width: min(380px, 92vw); padding: 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 14px;
}
.login h1 { margin: 0; font-size: 22px; }
.login p { margin: -8px 0 8px; }

/* --- Layout blocks ------------------------------------------------------- */

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.page-head h1, .page-head h2 { margin: 0 0 4px; font-size: 24px; }
.back { display: inline-block; margin-bottom: 6px; font-size: 13px; text-decoration: none; }

.card {
  padding: 20px; margin-bottom: 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.card h3 { margin: 0 0 12px; font-size: 17px; }
.section { margin-top: 24px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 380px); gap: 20px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

.muted { color: var(--text-dim); }
.small { font-size: 13px; }
.note { padding: 10px 12px; background: rgba(31,111,235,0.08); border-radius: 8px; font-size: 14px; }
.warn { color: var(--warn); font-weight: 600; }

.empty { padding: 28px; text-align: center; color: var(--text-dim); }

/* --- Forms --------------------------------------------------------------- */

.form { display: flex; flex-direction: column; gap: 14px; max-width: 520px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-weight: 600; font-size: 14px; }
.field-hint { font-size: 12.5px; color: var(--text-dim); }

input, select, textarea {
  padding: 9px 11px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
input[type="color"] { padding: 2px; width: 46px; height: 36px; }
.inline-input { padding: 6px 9px; }
.color-row { display: flex; gap: 8px; align-items: center; }

.form-actions { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; }

.btn {
  padding: 8px 14px; font: inherit; font-weight: 600;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.btn:hover { border-color: var(--primary); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--danger { color: var(--danger); border-color: var(--danger); }

/* --- Tables -------------------------------------------------------------- */

.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 13px; color: var(--text-dim); font-weight: 600; }
.table tr:last-child td { border-bottom: none; }
.table--tight th, .table--tight td { padding: 6px 9px; font-size: 13.5px; }
.tick-col { width: 34px; }
.row-actions { display: flex; gap: 8px; white-space: nowrap; }
.scroll-x { overflow-x: auto; }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.search-input { flex: 1; max-width: 320px; }
.add-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bulk {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 12px;
  background: rgba(31,111,235,0.1); border-radius: var(--radius);
}

.editable { display: inline-block; min-width: 60px; padding: 2px 4px; border-radius: 5px; cursor: text; }
.editable:hover { background: rgba(127,127,127,0.14); }
.editable--empty { color: var(--text-dim); font-style: italic; }

.pill { padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(127,127,127,0.16); }
.pill--active { background: rgba(26,127,75,0.16); color: var(--ok); }
.pill--archived { background: rgba(154,98,0,0.16); color: var(--warn); }

.archived { margin-top: 20px; }
.archived summary { cursor: pointer; font-weight: 600; margin-bottom: 10px; }

/* --- Tabs ---------------------------------------------------------------- */

.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab {
  padding: 9px 14px; font: inherit; font-weight: 600;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-dim); cursor: pointer;
}
.tab--active { color: var(--text); border-bottom-color: var(--primary); }

/* --- Wizard extras ------------------------------------------------------- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 4px 10px; background: rgba(127,127,127,0.14); border-radius: 999px; font-size: 13px; }
.chip--warn { background: rgba(154,98,0,0.18); color: var(--warn); }
.schema-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; flex-wrap: wrap; }
.url-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.url-row code { padding: 5px 8px; background: rgba(127,127,127,0.12); border-radius: 6px; word-break: break-all; }

/* --- Toast --------------------------------------------------------------- */

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 50; max-width: min(560px, 92vw);
  padding: 11px 18px; border-radius: 10px;
  background: #22262e; color: #fff; box-shadow: 0 6px 24px rgba(0,0,0,0.28);
}
.toast--ok { background: var(--ok); }
.toast--error { background: var(--danger); }

/* --- Background work ----------------------------------------------------- */

.chrome-nav { display: flex; gap: 4px; margin-left: 18px; }
.navlink {
  padding: 5px 11px; border: 0; border-radius: 999px;
  background: transparent; color: var(--text-dim);
  font: inherit; font-size: 13.5px; cursor: pointer;
}
.navlink:hover { color: var(--text); background: rgba(127,127,127,0.12); }
.navlink--on { color: var(--text); background: rgba(127,127,127,0.16); font-weight: 600; }

/* The filter chips are buttons, so the base .chip style needs its borders and
   cursor reset rather than inheriting the browser's button chrome. */
button.chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid transparent; color: var(--text-dim);
  font: inherit; font-size: 13px; cursor: pointer;
}
button.chip:hover { color: var(--text); }
.chip--on { border-color: var(--primary); color: var(--text); font-weight: 600; }
/* Only ever set when something actually needs a person. */
.chip--alert { background: rgba(209,57,43,0.14); color: var(--danger); }
.chip-count { font-variant-numeric: tabular-nums; opacity: .7; font-weight: 400; }

.pill--queued    { background: rgba(127,127,127,0.16); color: var(--text-dim); }
.pill--running   { background: rgba(31,111,235,0.16); color: var(--primary); }
.pill--succeeded { background: rgba(26,127,75,0.16); color: var(--ok); }
.pill--failed    { background: rgba(154,98,0,0.18); color: var(--warn); }
.pill--dead      { background: rgba(209,57,43,0.16); color: var(--danger); }

.banner {
  padding: 11px 14px; margin: 14px 0;
  border: 1px solid var(--border); border-left: 3px solid var(--text-dim);
  border-radius: var(--radius); background: var(--surface); font-size: 14px;
}
.banner--warn { border-left-color: var(--danger); color: var(--danger); }

/* A long error message must scroll in its own box, never widen the page. */
.table-wrap { overflow-x: auto; margin-top: 14px; }
.table .num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* --- Photos ---------------------------------------------------------------
   A contact sheet. Tiles are sized so a 500-photo event scrolls as a grid
   rather than a list, and every tile carries its own state: the batch panel
   above is transient, but a photo that failed has to stay findable. */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.photo-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}
.photo-tile--failed { border-color: var(--danger); }

.photo-thumb {
  aspect-ratio: 4 / 3;
  background: var(--bg);
  display: grid;
  place-items: center;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Until a signed URL arrives the img has no src, which browsers render as a
   broken-image glyph. Hide it and let the tile background stand in. */
.photo-thumb img:not([src]) { visibility: hidden; }

.photo-meta { padding: 10px 12px; display: flex; flex-direction: column; gap: 7px; }
.photo-name {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.photo-meta .warn.small { font-size: 12px; margin: 0; }

/* A button that reads as a link. A real <a href> would be a route the router
   does not have, and an anchor with no href is not focusable. */
.linkish {
  background: none;
  border: 0;
  padding: 4px 0;
  color: var(--primary);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  align-self: flex-start;
}
.linkish:hover { text-decoration: underline; }

/* Who the matcher found in this photograph. A confirmed match is stated
   plainly; one still awaiting review is marked, because the difference is the
   difference between "delivered" and "not yet". */
.photo-faces { list-style: none; margin: 0; padding: 0; display: flex;
               flex-direction: column; gap: 3px; }
.photo-face { display: flex; justify-content: space-between; gap: 8px;
              font-size: 12px; }
.photo-face-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-face-score { color: var(--text-dim); flex: none; }
.photo-face-score.warn { color: var(--warn); }

.pill--uploading  { background: rgba(127,127,127,0.16); color: var(--text-dim); }
.pill--stored     { background: rgba(127,127,127,0.16); color: var(--text-dim); }
.pill--processing { background: rgba(31,111,235,0.16); color: var(--primary); }
.pill--ready      { background: rgba(26,127,75,0.16); color: var(--ok); }

/* The upload batch: one row per file, because "12 failed" is not actionable. */
.batch {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  margin-top: 18px;
  background: var(--surface);
}
.batch-list { max-height: 260px; overflow-y: auto; margin-top: 10px; }
.batch-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.batch-row:last-child { border-bottom: 0; }
.batch-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-state { color: var(--text-dim); white-space: nowrap; }
.batch-row[data-state="failed"] .batch-state { color: var(--danger); }
.batch-row[data-state="done"] .batch-state { color: var(--ok); }
.batch-row[data-state="duplicate"] .batch-state { color: var(--warn); }

/* The file input is driven by a styled label; it must stay reachable by
   keyboard and to assistive tech, so it is moved off-screen rather than
   hidden with display:none. */
#photo-input {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* --- Attendees ------------------------------------------------------------ */

.notice-card { border-left: 3px solid var(--warn); }

.chip--ok { background: rgba(26,127,75,0.16); color: var(--ok); }

.pill--not_invited { background: rgba(127,127,127,0.16); color: var(--text-dim); }
.pill--invited     { background: rgba(31,111,235,0.16); color: var(--primary); }
.pill--enrolled    { background: rgba(26,127,75,0.16); color: var(--ok); }
.pill--declined    { background: rgba(127,127,127,0.16); color: var(--text-dim); }
/* A withdrawal is not a failure, but it is a state somebody must be able to
   find at a glance when answering a request about their own data. */
.pill--withdrawn   { background: rgba(154,98,0,0.18); color: var(--warn); }

/* --- Review queue ---------------------------------------------------------
   One card per match, worst score first. The frame shows the crop the provider
   actually matched on: asking someone to pick a face out of a group shot and
   decide whether the score belongs to it is asking them to guess. */

.review-list { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }

.review-card {
  display: flex;
  gap: 16px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--surface);
}

.review-face {
  flex: none;
  width: 96px;
  height: 96px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
  position: relative;
}
.review-face img { display: block; max-width: none; }
.review-face img:not([src]) { visibility: hidden; }

.review-body { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.review-body .row-actions { margin-top: 2px; }

.pill--confirmed { background: rgba(26,127,75,0.16); color: var(--ok); }
.pill--review    { background: rgba(154,98,0,0.18); color: var(--warn); }
.pill--rejected  { background: rgba(127,127,127,0.16); color: var(--text-dim); }
.pill--withdrawn { background: rgba(209,57,43,0.16); color: var(--danger); }
