/* COSDAV back office.
   A tool, not a brochure: the visual language is the paper work-order this
   replaces — ruled hairlines, file-tab status edges, tabular figures. */

:root {
  --ink: #10302e;
  --paper: #f7f5f1;
  --surface: #ffffff;
  --teal: #0b7a75;
  --teal-deep: #075a56;
  --amber: #b4680e;
  --amber-soft: #fdf3e6;
  /* Task state. Kept separate from --teal: teal means "you can act on this",
     green and red mean "this is how the task ended". */
  --ok: #1a7f4b;
  --ok-soft: #ebf7f0;
  --bad: #b3261e;
  --bad-soft: #fdeceb;
  --rule: #e4e0da;
  --muted: #6b6b6b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 48, 46, 0.06), 0 8px 24px rgba(16, 48, 46, 0.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

/* An author `display` rule outranks the UA stylesheet's [hidden] { display:none },
   so .gate/.field-error would stay on screen while marked hidden. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

/* Micro-labels: the utility voice of the interface. */
.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.num { font-variant-numeric: tabular-nums; }

/* --- chrome ---------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}
.topbar-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.mark {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  margin: 0;
}
.mark span { color: var(--teal); font-weight: 500; }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tabs a {
  padding: 7px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}
.tabs a[aria-current="page"] { background: var(--paper); color: var(--ink); }
.tabs a:hover { color: var(--ink); }

.wrap { max-width: 980px; margin: 0 auto; padding: 24px 20px 64px; }

.page-head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-head h1 { font-size: 26px; margin: 2px 0 0; letter-spacing: -0.02em; }
.page-head .spacer { margin-left: auto; }

/* --- buttons -------------------------------------------------------------- */

.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  padding: 9px 15px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.btn:hover { border-color: #cfc9c0; background: #fdfcfa; }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-deep); border-color: var(--teal-deep); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn-quiet:hover { background: rgba(16, 48, 46, 0.05); color: var(--ink); }
.btn-danger { color: #a3261b; }
.btn-danger:hover { background: #fdf1f0; border-color: #f0cdc9; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* --- the ledger: one block per task, coloured by its answer ---------------- */

.ledger { display: flex; gap: 2px; align-items: center; }
.ledger .blk {
  width: 7px;
  height: 16px;
  border-radius: 2px;
  background: var(--rule);
  transition: background 180ms ease;
}
.ledger .blk.done { background: var(--ok); }
.ledger .blk.failed { background: var(--bad); }
.ledger-label { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* Dot tally: green count of finished tasks, red count of ones that failed. */
.tally { display: flex; align-items: center; gap: 12px; font-size: 12px; }
.tally-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.tally-item::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.tally-item.ok { color: var(--ok); }
.tally-item.bad { color: var(--bad); }
/* A zero goes quiet rather than shouting a red 0 at a cleaning with no problems. */
.tally-item.is-zero { color: #a8a29a; font-weight: 500; }
.tally-total { color: var(--muted); }

/* --- cleaning rows -------------------------------------------------------- */

.rows { display: flex; flex-direction: column; gap: 10px; }

.row {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 14px 16px 14px 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 20px;
  align-items: center;
  box-shadow: 0 1px 1px rgba(16, 48, 46, 0.03);
}
/* File-tab edge carries the status without spending a pill on it. */
.row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 3px;
  background: var(--rule);
}
.row.is-completed::before { background: var(--teal); }

.row-when { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
  margin-top: 5px;
  font-size: 13px;
  color: var(--muted);
}
.row-meta .sep { color: var(--rule); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.row-ledger { display: flex; align-items: center; gap: 10px; margin-top: 8px; }

.state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.state::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.state.completed { color: var(--teal); }

/* --- checklist template list ---------------------------------------------- */

.tasks { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.task {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 14px 16px;
  border-bottom: 1px solid var(--rule);
}
.task:last-child { border-bottom: 0; }
.task-ord {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
  min-width: 22px;
}
.task-name { font-weight: 600; font-size: 15px; }
.task-desc { font-size: 13px; color: var(--muted); margin-top: 3px; }
.task-actions { display: flex; gap: 4px; }

/* --- empty + feedback ----------------------------------------------------- */

.empty {
  background: var(--surface);
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
}
.empty strong { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

.notice {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--amber-soft);
  border: 1px solid #eccfa4;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 14px;
}
.notice strong { display: block; }
.notice .btn { margin-left: auto; background: var(--surface); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 200;
  box-shadow: var(--shadow);
}
.toast.error { background: #a3261b; }

/* --- login ---------------------------------------------------------------- */

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
}
.gate-card h1 { font-size: 20px; margin: 6px 0 6px; letter-spacing: -0.02em; }
.gate-card p { color: var(--muted); font-size: 14px; margin: 0 0 20px; }

/* --- forms ---------------------------------------------------------------- */

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field input, .field select, .field textarea {
  font: inherit;
  font-size: 15px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}
.field textarea { min-height: 76px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--teal);
  outline: none;
  box-shadow: 0 0 0 3px rgba(11, 122, 117, 0.12);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field-error { font-size: 13px; color: #a3261b; margin: -6px 0 12px; }

/* The computed readout: the form doing arithmetic for you. */
.readout {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 4px 0 16px;
}
.readout div { font-size: 13px; color: var(--muted); }
.readout strong { display: block; font-size: 17px; color: var(--ink); font-variant-numeric: tabular-nums; }

/* --- lightbox ------------------------------------------------------------- */

.lb {
  position: fixed;
  inset: 0;
  background: rgba(16, 48, 46, 0.4);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 100;
  overflow-y: auto;
}
.lb + .lb { z-index: 120; background: rgba(16, 48, 46, 0.32); }
.lb-card {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow);
  margin: auto;
  animation: pop 140ms ease-out;
}
.lb-wide { max-width: 780px; }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .lb-card { animation: none; }
  .ledger .blk { transition: none; }
}
.lb-head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  gap: 12px;
}
.lb-head h2 { margin: 0; font-size: 17px; letter-spacing: -0.01em; }
.lb-head .btn { margin-left: auto; }
.lb-body { padding: 20px; }
.lb-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--rule);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* --- admin checklist answers --------------------------------------------- */

/* Ruled paper: the form this screen replaces. */
.answers { max-height: min(62vh, 560px); overflow-y: auto; }
/* Task on the left, its status control on the right: the row reads as a list
   with a dropdown per line rather than a stack of blocks. */
.answer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 20px;
  align-items: start;
  padding: 14px 20px;
  border-bottom: 1px solid var(--rule);
}
.answer:last-child { border-bottom: 0; }
/* Green done, red not done, plain white still pending. The inset bar carries
   the state at the edge of the row so it reads down the list. */
.answer.done { background: var(--ok-soft); box-shadow: inset 3px 0 0 var(--ok); }
.answer.failed { background: var(--bad-soft); box-shadow: inset 3px 0 0 var(--bad); }
.answer.done select { border-color: #a9d6bd; color: var(--ok); font-weight: 600; }
.answer.failed select { border-color: #eebdb9; color: var(--bad); font-weight: 600; }
.answer-name { font-weight: 600; font-size: 15px; }
.answer-desc { font-size: 13px; color: var(--muted); margin: 3px 0 0; }
.answer-control {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.answer select {
  font: inherit;
  font-size: 14px;
  padding: 7px 10px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  /* Fixed width so every dropdown in the list lines up. */
  width: 132px;
}
.answer-reason {
  font-size: 13px;
  color: var(--bad);
  background: #fff;
  border: 1px solid #eebdb9;
  border-radius: 6px;
  padding: 6px 9px;
  margin-top: 8px;
}
.saved {
  font-size: 12px;
  color: var(--teal);
  opacity: 0;
  transition: opacity 160ms;
  white-space: nowrap;
}

/* Narrow screens: the control drops under the task rather than squeezing it. */
@media (max-width: 560px) {
  .answer { grid-template-columns: 1fr; }
  .answer-control { align-items: flex-start; }
  .answer select { width: 100%; }
}
.saved.on { opacity: 1; }

/* --- share ---------------------------------------------------------------- */

.share-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  word-break: break-all;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

@media (max-width: 700px) {
  .row { grid-template-columns: 1fr; }
  .row-actions { justify-content: flex-start; }
  .field-row { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 22px; }
}
