/* ============================================================
   App-Base theme — v1
   Calm, minimal, focused. See THEME.md for the philosophy.
   Every page links this file (base/theme.css) and adds only
   page-specific rules in its own <style>. Additive changes are fine
   within v1; a meaningful change to an existing look is a new
   version: snapshot this file as theme-v1.css first.
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  --bg: #fafaf8;        /* warm off-white page background */
  --ink: #1c1917;       /* primary text */
  --soft: #57534e;      /* secondary text */
  --muted: #a8a29e;     /* labels, captions, de-emphasized */
  --hairline: #e7e5e4;  /* row dividers */
  --track: #eeedeb;     /* empty progress track */

  /* Status accents — desaturated, used ONLY where color carries meaning */
  --red: #c4574e;       /* behind pace */
  --amber: #c98a2d;     /* at risk */
  --green: #5f9464;     /* on track */
  --today: #d6c451;     /* elapsed time */
  --gold: #b8922e;      /* a reward goal — the one colour beyond status, only where a number IS the reward */
  --gold-light: #e8cf7a;
}

/* ---------- Base ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; }
/* `hidden` wins over any display rule a class sets (e.g. a flex pill group) */
[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.6;
}

/* ---------- Layout: single calm column ---------- */
.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 96px 32px 128px;
}

section { margin-bottom: 112px; }
section:last-child { margin-bottom: 0; }

/* ---------- Top nav ---------- */
.nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 28px;
  margin-bottom: 72px;
  font-size: .85rem;
}
/* Links outgrow the 640px column from six on (auth.js trims the nav to
   the role's pages, but the admin sees them all): borrow the column
   margins on wide screens, wrap on narrow. Each link costs ~105px with
   the system font — MEASURE (harness, device-metrics override), never
   eyeball. The tiers below were measured at 7, 8, 9, 10, 11 and 12
   links: 733 / 874 / 969 / 1077 / 1167 / 1254px. A thirteenth link needs
   a new nav shape, not another tier. */
@media (min-width: 720px) {
  .nav { margin-left: -64px; margin-right: -64px; }
}
@media (min-width: 800px) {
  .nav { margin-left: -96px; margin-right: -96px; }
}
@media (min-width: 960px) {
  .nav { margin-left: -160px; margin-right: -160px; }
}
@media (min-width: 1040px) {
  .nav { margin-left: -200px; margin-right: -200px; }
}
@media (min-width: 1160px) {
  .nav { margin-left: -260px; margin-right: -260px; }
}
@media (min-width: 1280px) {
  .nav { margin-left: -320px; margin-right: -320px; }
}
@media (min-width: 1360px) {
  .nav { margin-left: -350px; margin-right: -350px; }
}
.nav a {
  color: var(--muted);
  text-decoration: none;
  transition: color .15s ease;
}
.nav a:hover { color: var(--ink); }
.nav a.active { color: var(--ink); font-weight: 500; }
/* A gentle dot on a nav link while something waits there (a queue,
   unread items). Positioned outside the text so the nav's measured
   width never changes; a slow soft halo, frozen for reduced motion.
   Set `title` on the link to say what waits. */
.nav a { position: relative; }
.nav-dot {
  position: absolute;
  top: 2px;
  right: -10px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
  animation: nav-dot-breathe 3.6s ease-in-out infinite;
}
@keyframes nav-dot-breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201, 138, 45, 0); }
  50%      { box-shadow: 0 0 0 4px rgba(201, 138, 45, .2); }
}
@media (prefers-reduced-motion: reduce) {
  .nav-dot { animation: none; }
}
/* Signed-in name + Sign out, appended by auth.js at the foot of the column
   (auth.js also removes the nav when the role can open a single page) */
.who {
  margin-top: 112px;
  text-align: center;
  font-size: .85rem;
  color: var(--muted);
}
.who a {
  color: var(--muted);
  text-decoration: none;
  transition: color .15s ease;
}
.who a:hover { color: var(--ink); }
/* "A new version is ready · Reload" — added by auth.js when a newer deployment is live */
.who-update { margin-bottom: 8px; }

/* ---------- Typography ---------- */
.page-title {
  font-size: 1.9rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 20px;
}

.page-subtitle {
  font-size: .9rem;
  color: var(--muted);
  text-align: center;
  margin-bottom: 20px;
}

.section-title {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  margin-bottom: 28px;
}

.note {
  font-size: .85rem;
  color: var(--muted);
}

/* ---------- Timeline (thin range with "now" dot) ---------- */
.timeline {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 380px;
  margin: 0 auto 88px;
}
.t-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .06em;
}
.t-track {
  position: relative;
  flex: 1;
  height: 2px;
  background: var(--track);
  border-radius: 1px;
}
.t-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--today);
  border-radius: 1px;
}
.t-now {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--ink);
}

/* ---------- Pills (filters / segmented choices) ---------- */
.pills {
  display: flex;
  flex-wrap: wrap;   /* a long context list outgrows the column */
  justify-content: center;
  gap: 8px;
  margin-bottom: 96px;
}
.pill {
  font-family: inherit;
  font-size: .9rem;
  font-weight: 500;
  padding: 8px 20px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--soft);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.pill:hover { color: var(--ink); }
.pill.active {
  background: var(--ink);
  color: var(--bg);
}

/* ---------- Goal progress bars (the hero element) ---------- */
.goals {
  display: flex;
  flex-direction: column;
  gap: 52px;
  margin-bottom: 128px;
}
.goal-row { display: block; }
.goal-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}
.goal-label {
  font-size: 1rem;
  font-weight: 500;
  color: var(--soft);
}
.goal-label small {
  font-size: .8rem;
  color: var(--muted);
  font-weight: 400;
  margin-left: 6px;
}
.goal-numbers {
  font-size: 1.35rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.goal-numbers .of {
  font-size: .95rem;
  font-weight: 400;
  color: var(--muted);
  margin-left: 2px;
}
.goal-track {
  height: 6px;
  background: var(--track);
  border-radius: 3px;
  overflow: hidden;
}
.goal-fill {
  height: 100%;
  border-radius: 3px;
}
.goal-row.red   .goal-fill { background: var(--red); }
.goal-row.red   .goal-numbers .value { color: var(--red); }
.goal-row.amber .goal-fill { background: var(--amber); }
.goal-row.amber .goal-numbers .value { color: var(--amber); }
.goal-row.green .goal-fill { background: var(--green); }
.goal-row.green .goal-numbers .value { color: var(--green); }

/* ---------- Tables (quiet supporting detail) ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .95rem;
  font-variant-numeric: tabular-nums;
}
th {
  font-size: .75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  text-align: right;
  padding: 0 0 12px;
}
th:first-child { text-align: left; }
td {
  padding: 14px 0;
  border-top: 1px solid var(--hairline);
  text-align: right;
  color: var(--soft);
}
td:first-child { text-align: left; }
th:not(:first-child), td:not(:first-child) { width: 90px; }

.row-title { font-weight: 500; color: var(--ink); }

/* Sub-table with a named header (e.g. per-person groups) */
.table-group { margin-bottom: 48px; }
.table-group:last-child { margin-bottom: 0; }
th.table-subhead {
  font-size: .95rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
}

/* ---------- Forms (quiet, underline-only inputs) ---------- */
.input {
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--hairline);
  padding: 2px 4px;
  transition: border-color .15s ease;
  font-variant-numeric: tabular-nums;
}
.input:focus {
  outline: none;
  border-bottom-color: var(--ink);
}
.input-num {
  width: 64px;
  text-align: right;
}
.input-text { text-align: left; }

/* Underline dropdown for roster-sized enums (~12+ options; 2–4 stay pills). */
.input-select {
  appearance: none;
  -webkit-appearance: none;
  width: 220px;
  padding-right: 24px;
  cursor: pointer;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23a8a29e' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 6px center;
}
.input-select:invalid { color: var(--muted); }

/* Big editable number for a page's hero figure */
.input-hero {
  font-size: 2.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  width: 120px;
  text-align: left;
  padding: 0 4px 2px;
}

/* Remove number-input spinners; keep it quiet */
.input::-webkit-outer-spin-button,
.input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit;
  font-size: .9rem;
  font-weight: 500;
  padding: 10px 28px;
  border: none;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  cursor: pointer;
  transition: opacity .15s ease;
}
.btn:hover { opacity: .85; }

.btn-quiet {
  font-family: inherit;
  font-size: .85rem;
  font-weight: 500;
  padding: 6px 0;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s ease;
}
.btn-quiet:hover { color: var(--ink); }

/* Quiet field label + spacing inside a form section. */
.field { margin-bottom: 44px; }
.field:last-child { margin-bottom: 0; }
.field-label {
  font-size: .8rem;
  color: var(--muted);
  margin-bottom: 14px;
}

/* Left-aligned wrapping pill group inside a form (single- or
   multi-select). */
.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* "+ Add …" row under a repeating table */
.add-row { margin-top: 12px; }

/* Centered submit area at the end of a form page */
.save-area {
  margin-top: 128px;
  text-align: center;
}
.save-area .note { margin-top: 16px; }
.save-area .note.error { color: var(--red); }

/* Validation marks — only ever set on Save / Submit, never while typing */
.input.missing { border-bottom-color: var(--red); }
.choices.missing .pill, .pills.missing .pill { color: var(--red); }

/* ---------- Type-ahead menu ---------- */
/* An underline input with a dropdown of matches under it (a long list the
   person searches by typing — a category, a client, a place). Wrap the
   input in .typeahead; the page fills .typeahead-menu with buttons and
   toggles .open. */
.typeahead { position: relative; }
.typeahead-menu {
  display: none;
  position: absolute;
  top: 100%; left: 0; right: 0;
  z-index: 10;
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  margin-top: 6px;
  max-height: 264px;
  overflow-y: auto;
}
.typeahead-menu.open { display: block; }
.typeahead-menu button {
  display: block;
  width: 100%;
  font: inherit;
  font-size: .95rem;
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--soft);
  cursor: pointer;
}
.typeahead-menu button:hover { color: var(--ink); background: var(--track); }
.typeahead-menu .typeahead-empty {
  font-size: .85rem;
  color: var(--muted);
  padding: 10px 14px;
}
/* A table of repeating input rows (amount + date, name + duration…):
   first cell soft, inputs sized by the page, a × cell at the right. */
.rows-table td:first-child { color: var(--soft); }
.rows-table th:not(:first-child), .rows-table td:not(:first-child) { width: auto; }
.rows-table td.remove-cell { width: 32px; text-align: right; }

/* Small inline remove control (×) */
.btn-remove {
  font-family: inherit;
  font-size: 1rem;
  line-height: 1;
  border: none;
  background: transparent;
  color: var(--hairline);
  cursor: pointer;
  padding: 4px 6px;
  transition: color .15s ease;
}
.btn-remove:hover { color: var(--red); }

/* ---------- Live-data status line ---------- */
/* Under the context pills on a live page: empty while all is well, red
   when the backend can't be reached. Collapses when empty. */
.status { text-align: center; margin: -64px 0 64px; min-height: 1.4em; }
.status.error { color: var(--red); }
.status:empty { display: none; }

/* ---------- Messages board (board.js, top of every page) ---------- */
/* The manager's important messages, under the page's header block and
   above its content (board.js picks the spot). Unseen messages read in ink with a dot; seen ones recede to
   soft and stay as reminders. Structure, not fills. */
.board { margin: 0 0 88px; }
.board .section-title { margin-bottom: 8px; }
.board-msg {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 0;
  border-top: 1px solid var(--hairline);
}
.board-body { min-width: 0; }
.board-text {
  white-space: pre-line;
  color: var(--soft);
}
.board-msg.unseen .board-text {
  color: var(--ink);
  font-weight: 500;
}
.board-msg.unseen .board-text::before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ink);
  margin-right: 10px;
  vertical-align: middle;
  position: relative;
  top: -1px;
}
.board-meta {
  font-size: .8rem;
  color: var(--muted);
  margin-top: 2px;
}
.board-side {
  flex: none;
  font-size: .85rem;
  color: var(--muted);
  white-space: nowrap;
}
.board-side .btn-quiet { padding: 0; }
.board-msg.unseen .btn-quiet { color: var(--soft); }
.board-note { margin-top: 12px; }
.board-note.error { color: var(--red); }
.board-note:empty { display: none; }

/* ---------- Item list (tap-to-open rows) ---------- */
/* A list of records the person taps to open (a client, a booking, an
   appointment): hairline rows, an ink title, a muted meta line, a quiet
   figure at the right. Each row is a <button class="item"> when it
   opens something, a <div class="item"> when it does not. */
.items { }
.item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  width: 100%;
  padding: 14px 0;
  border: none;
  border-top: 1px solid var(--hairline);
  background: transparent;
  font: inherit;
  text-align: left;
  color: inherit;
  line-height: 1.5;
}
button.item { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button.item:hover .item-title { color: var(--soft); }
.item-main { min-width: 0; }
.item-title { color: var(--ink); font-weight: 500; }
.item-meta { font-size: .85rem; color: var(--muted); margin-top: 2px; }
.item-side {
  flex: none;
  font-size: .9rem;
  color: var(--soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.items-empty { font-size: .9rem; color: var(--muted); }
