/* ============================================================
   Today area — the Today page (your day, reminders, top 3, the
   plan for a day or a week, tickets, figures, this time last
   year), the task rows and editor from task-ui.js, the Farming
   page and the quick task form. Classes are prefixed td-.
   Semantic tokens only, so a re-theme is a token swap.
   ============================================================ */

/* ── shared task bits (task-ui.js, used on Today and /op/*) ─────── */

.td-sub { border-style: dashed; }
.td-est { font-family: var(--font-mono); font-weight: 600; }
.td-kind { color: var(--text-muted); }
.td-contact { font-size: 13px; font-weight: 600; }
.td-on-ice { color: var(--danger-ink); }

.td-rating-hot  { color: var(--danger-ink);  background: var(--danger-tint);  border-color: var(--danger-line); }
.td-rating-warm { color: var(--warning-ink); background: var(--warning-tint); border-color: var(--warning-line); }
.td-rating-cold { color: var(--text-muted);  background: var(--canvas);       border-color: var(--line); }

.td-waiting-them { color: var(--text-muted); }
.td-waiting-me   { color: var(--accent-ink); border-color: var(--accent-line); }

.td-plan-pill { color: var(--text-muted); background: var(--surface); border-style: dashed; }
.td-plan-pill.is-today { color: var(--accent-ink); background: var(--accent-tint); border-color: var(--accent-line); border-style: solid; }
.td-kept-pill { color: var(--text-muted); border-style: dashed; }

.td-plan-btn.on { color: var(--accent-ink); background: var(--accent-tint); border-color: var(--accent-line); }

/* Who is on it: "Sipho, Jabu + 2", with a small person glyph. */
.td-people-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; font-weight: 600; color: var(--ink);
  white-space: nowrap;
}
.td-people-icon { position: relative; display: inline-block; width: 10px; height: 11px; flex-shrink: 0; color: var(--text-muted); }
.td-people-icon::before {
  content: ""; position: absolute; left: 2.5px; top: 0;
  width: 5px; height: 5px; border-radius: 50%; background: currentColor;
}
.td-people-icon::after {
  content: ""; position: absolute; left: 0; bottom: 0;
  width: 10px; height: 5px; border-radius: 5px 5px 1px 1px; background: currentColor;
}

.td-editor-kind, .td-editor-who {
  font-size: 13.5px;
  line-height: 1.55;
  padding: 10px 14px;
  margin-bottom: var(--space-md);
  border-radius: var(--radius-sm);
  background: var(--canvas);
  border: 1px solid var(--line);
  color: var(--text-muted);
}
.td-editor-kind strong, .td-editor-who strong { color: var(--ink); }
.td-editor-kind a { color: var(--accent-ink); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.td-pays-field { display: flex; flex-direction: column; justify-content: flex-end; }
.td-del { margin-right: auto; }

.td-lbl { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }

/* The plan buttons in the board drawer (board-ui.js). */
.td-bd-plan-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.td-bd-plan-btns .btn:disabled.on { opacity: 1; cursor: default; }
.td-show-field { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--canvas); border: 1px solid var(--line); }
.td-show-field .hint { margin-top: 2px; }

/* The people picker in the editor and the quick form. */
.td-people-group + .td-people-group { margin-top: 10px; }
.td-people-head { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.td-people-summary { font-size: 12.5px; color: var(--text-muted); margin-top: 8px; }
/* Someone on the job who cannot see its operation, or has left the lists. */
.td-person-warn { border-style: dashed; }
.td-person-warn:not(.on) .chip-hint { color: var(--danger-ink); }

.td-link { color: var(--accent-ink); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.td-link-btn {
  border: 0; background: transparent; padding: 0;
  font: inherit; font-weight: 600;
  color: var(--accent-ink);
  text-decoration: underline; text-underline-offset: 2px;
  cursor: pointer;
}
.td-link-btn:hover { color: var(--ink); }

.td-row.td-flash { background: var(--accent-tint); border-radius: var(--radius-sm); }

/* The plan menu: Today, Tomorrow, This week, Next week. */
.td-menu {
  position: absolute; z-index: 950;
  min-width: 230px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}
.td-menu-item {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-md);
  width: 100%; min-height: 44px;
  padding: 8px 12px;
  border: 0; border-radius: var(--radius-sm);
  background: transparent;
  text-align: left; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--ink);
}
.td-menu-item:hover, .td-menu-item:focus-visible { background: var(--canvas); outline: none; }
.td-menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--accent-strong); }
.td-menu-item.on { background: var(--accent-tint); color: var(--accent-ink); }
.td-menu-hint { font-size: 12px; font-weight: 500; color: var(--text-muted); white-space: nowrap; }
.td-menu-off { color: var(--danger-ink); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius-sm) var(--radius-sm); margin-top: 4px; }

/* ── Today: your day, from the week planner ─────────────────────── */

.td-yourday {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--space-md);
  padding: 12px 16px;
  margin-bottom: var(--space-lg);
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  transition: border-color var(--dur-fast) var(--ease);
}
.td-yourday[hidden] { display: none; }
.td-yourday:hover { border-color: var(--accent-line); }
.td-yd-label { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.td-yd-text { flex: 1; min-width: 0; font-size: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.td-yd-now, .td-yd-next { display: inline-flex; align-items: center; gap: 6px; }
.td-yd-next { color: var(--text-muted); }
.td-yd-next strong { color: var(--ink); }
.td-yd-swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--stone); flex-shrink: 0; }
.td-yd-sep { color: var(--text-muted); }
.td-yd-go { color: var(--accent-ink); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.td-yd-bar {
  position: relative; display: block;
  flex-basis: 100%; height: 8px;
  border-radius: var(--radius-full);
  background: var(--canvas);
  overflow: hidden;
}
.td-yd-bar[hidden] { display: none; }
.td-yd-seg { position: absolute; top: 0; bottom: 0; background: var(--stone-deep); border-right: 1px solid var(--surface); }
.td-yd-skipped { opacity: 0.3; }
.td-yd-mark { position: absolute; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: var(--ink); }

/* ── Today: reminders ───────────────────────────────────────────── */

.td-reminders { display: flex; flex-direction: column; gap: var(--space-sm); margin-bottom: var(--space-lg); }
.td-reminders[hidden] { display: none; }
.td-reminder {
  display: flex; align-items: center; gap: var(--space-md);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--warning-tint);
  border: 1px solid var(--warning-line);
}
.td-rem-when { flex-shrink: 0; min-width: 84px; font-weight: 700; font-size: 14px; color: var(--warning-ink); display: flex; flex-direction: column; }
.td-rem-date { font-size: 12px; font-weight: 500; }
.td-rem-body { flex: 1; min-width: 0; }
.td-rem-title { font-weight: 700; font-size: 14.5px; line-height: 1.35; }
.td-rem-detail { font-size: 13px; color: var(--text-muted); margin-top: 2px; line-height: 1.5; }
.td-rem-actions { display: flex; gap: 6px; flex-wrap: wrap; flex-shrink: 0; }
.td-rem-actions .btn { min-height: 40px; }

/* ── Today: top 3 cards ──────────────────────────────────────────── */

.td-card-bits { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 2px 0 var(--space-sm); }
.td-card-foot { flex-wrap: wrap; }
.td-card-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }

/* ── Today: the plan ─────────────────────────────────────────────── */

.td-plan-head { margin-bottom: var(--space-md); align-items: center; }
.td-plan-date { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; margin-top: 4px; }

.td-switch {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--canvas);
  border: 1px solid var(--line);
}
.td-switch-btn {
  min-height: 44px;
  min-width: 88px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.td-switch-btn:hover { color: var(--ink); }
.td-switch-btn.on { background: var(--ink); color: var(--ink-contrast); }

.td-plan-sum:empty { display: none; }
.td-plan-sum {
  padding: 12px 14px;
  margin-bottom: var(--space-md);
  border-radius: var(--radius-sm);
  background: var(--canvas);
  border: 1px solid var(--line);
}
.td-sum-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 15px; }
.td-sum-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.td-sum-sep { color: var(--text-muted); }
.td-sum-total { font-weight: 800; white-space: nowrap; }
.td-plan-hint { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }
.td-plan-hint:first-child { margin-top: 0; }

.td-group + .td-group { margin-top: var(--space-md); }
.td-group-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.td-group-name { flex: 1; min-width: 0; }
.td-group-hours { font-family: var(--font-mono); font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--text-muted); }

/* The week: a section per day, today marked, days gone by quieter. */
.td-day.is-today .td-group-head { color: var(--accent-ink); border-bottom-color: var(--accent-line); }
.td-day.is-past .td-group-head { color: var(--text-muted); }
.td-day.is-anytime .td-group-head { border-bottom-style: dashed; }
.td-bullet-op { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; color: var(--ink); }

.td-bullets { list-style: none; margin: 0; padding: 0; }
.td-bullet {
  display: flex; align-items: flex-start; gap: var(--space-sm);
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
}
.td-bullet:last-child { border-bottom: 0; }

/* The tick is a 44px target with a 22px box inside it. */
.td-tick {
  width: 44px; height: 44px; flex-shrink: 0;
  display: grid; place-items: center;
  border: 0; background: transparent; padding: 0;
  cursor: pointer;
}
.td-tick:disabled { cursor: default; opacity: 0.5; }
.td-tick-box {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 1.5px solid var(--input-line);
  background: var(--surface);
  position: relative;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.td-tick:hover:not(:disabled) .td-tick-box { border-color: var(--accent-strong); }
.td-tick.done .td-tick-box { background: var(--accent); border-color: var(--accent-strong); }
.td-tick.done .td-tick-box::after {
  content: "";
  position: absolute; left: 7px; top: 3px;
  width: 5px; height: 10px;
  border: solid var(--accent-contrast); border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.td-bullet-body { flex: 1; min-width: 0; padding: 10px 0 8px; }
.td-bullet-title {
  display: block; width: 100%;
  border: 0; background: transparent; padding: 0;
  text-align: left; cursor: pointer;
  font-size: 15px; font-weight: 600; line-height: 1.35;
  color: var(--ink);
}
.td-bullet-title:hover { color: var(--accent-ink); }
.td-bullet.done .td-bullet-title { color: var(--text-muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.td-bullet-meta { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; }
.td-bullet-meta .pill { padding: 1px 8px; font-size: 11px; }
.td-no-est { font-style: italic; }
.td-bullet-btns { display: flex; gap: 6px; flex-shrink: 0; margin-top: 6px; }
.td-bullet-btns .btn { min-height: 36px; }

.td-plan-empty { text-align: center; padding: var(--space-lg) var(--space-md); }
.td-plan-empty-title { font-weight: 700; font-size: 16px; }
.td-plan-empty-body { font-size: 13.5px; color: var(--text-muted); margin: 6px auto 0; max-width: 52ch; line-height: 1.55; }
.td-suggest-list { list-style: none; padding: 0; margin: var(--space-md) auto 0; max-width: 460px; text-align: left; }
.td-suggest-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-top: 1px solid var(--line);
  font-size: 14px;
}
.td-suggest-list li:first-child { border-top: 0; }
.td-suggest-list .muted { white-space: nowrap; }
.td-suggest { margin-top: var(--space-md); min-height: 44px; }

/* ── Today: tickets ─────────────────────────────────────────────── */

.td-ticket-counts { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-top: 8px; }
.td-count { white-space: nowrap; }
.td-count-num { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.td-count-lbl { font-size: 15px; color: var(--text-muted); font-weight: 500; }
.td-count-sep { color: var(--text-muted); font-size: 20px; }

.td-ticket-chase {
  font-size: 13.5px;
  padding: 10px 14px;
  margin: calc(-1 * var(--space-sm)) 0 var(--space-md);
  border-radius: var(--radius-sm);
  background: var(--warning-tint);
  color: var(--warning-ink);
  border: 1px solid var(--warning-line);
}
.td-ticket-chase a { font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

/* Stubs coloured by stage: out with the driver (dashed), back, handed in. */
.stub.td-stub-with_driver { background: transparent; border: 1.5px dashed var(--text-muted); }
.stub.td-stub-returned    { background: var(--warning); }
.stub.td-stub-handed_in   { background: var(--accent); }
.td-stubs-empty { padding: 8px 0; width: 100%; }
.td-stubs-empty a { color: var(--accent-ink); font-weight: 600; text-decoration: underline; }

.td-stub-legend { display: flex; flex-wrap: wrap; gap: 6px var(--space-md); font-size: 12.5px; color: var(--text-muted); margin: calc(-1 * var(--space-sm)) 0 var(--space-lg); }
.td-legend-key { display: inline-flex; align-items: center; gap: 6px; }
.td-legend-swatch { width: 10px; height: 14px; border-radius: 3px; display: inline-block; }
.td-legend-swatch.td-stub-with_driver { border: 1.5px dashed var(--text-muted); }
.td-legend-swatch.td-stub-returned    { background: var(--warning); }
.td-legend-swatch.td-stub-handed_in   { background: var(--accent); }

/* ── Today: figures, the open list and last year ────────────────── */

.td-stat-note { font-size: 12.5px; color: var(--text-muted); margin-top: 6px; line-height: 1.45; }
.td-stat-note:empty { display: none; }

.td-kept {
  font-size: 13px;
  color: var(--text-muted);
  padding: 8px 12px;
  margin-bottom: var(--space-md);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line-strong);
}
.td-kept[hidden] { display: none; }

.td-last-year { margin-bottom: var(--space-2xl); }
.td-ly-head { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px; }
.td-ly-list { list-style: none; margin: 0 0 var(--space-md); padding: 0; }
.td-ly-list:last-child { margin-bottom: 0; }
.td-ly-row { padding: 10px 0; border-top: 1px solid var(--line); }
.td-ly-row:first-child { border-top: 0; }
.td-ly-title { font-weight: 600; font-size: 14.5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.td-ly-meta { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── Farming page ───────────────────────────────────────────────── */

.td-tabs {
  display: flex; gap: 4px;
  overflow-x: auto;
  margin-bottom: var(--space-lg);
  border-bottom: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.td-tabs::-webkit-scrollbar { display: none; }
.td-tab {
  display: inline-flex; align-items: center;
  min-height: 44px;
  padding: 0 18px;
  font-weight: 600; font-size: 14.5px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.td-tab:hover { color: var(--ink); }
.td-tab.on { color: var(--ink); border-bottom-color: var(--accent); }

.td-stat-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; line-height: 1.45; }

.td-farm-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: var(--space-lg); align-items: start; }
.td-farm-grid > .panel { margin-bottom: 0; }
.td-farm-grid { margin-bottom: var(--space-lg); }
.td-status-filter { width: auto; min-width: 140px; }
.td-panel-note { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.td-log-foot { border-top: 1px solid var(--line); margin-top: var(--space-md); padding-top: var(--space-md); font-size: 13.5px; }
.td-log-empty { padding: var(--space-lg) var(--space-sm); line-height: 1.8; }

/* ── Quick task form ────────────────────────────────────────────── */

.td-task-form .input { min-height: 44px; }
.td-check-big { min-height: 44px; font-size: 15px; font-weight: 600; }
.td-check-big input { width: 22px; height: 22px; }

/* ── Weekly report: field work ──────────────────────────────────── */

.td-report-charts { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-lg); margin-bottom: var(--space-lg); }
.td-report-charts[hidden] { display: none; }
.td-total-row td { background: var(--canvas); }

/* ── narrow screens ─────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .td-farm-grid { grid-template-columns: 1fr; }
  .td-report-charts { grid-template-columns: 1fr; }
  .td-farm-grid > .panel { margin-bottom: 0; }
}

@media (max-width: 720px) {
  .td-plan-head { flex-direction: column; align-items: stretch; }
  /* Four choices: two by two on a phone, each a full-size target. */
  .td-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
  .td-switch-btn { min-width: 0; }
}

@media (max-width: 560px) {
  .td-sum-line { font-size: 14px; }
  .td-count-num { font-size: 26px; }
  .td-card-actions { margin-left: 0; width: 100%; }
  .td-card-actions .btn { flex: 1; min-height: 44px; }
  .td-status-filter { width: 100%; }
  .td-tab { padding: 0 14px; }
  .td-yd-label { flex-basis: 100%; }
  .td-yd-text { flex-basis: 100%; font-size: 13.5px; }
  .td-yd-sep { display: none; }
  .td-yd-now, .td-yd-next { flex-basis: 100%; }
  .td-reminder { flex-wrap: wrap; gap: 6px var(--space-md); }
  .td-rem-when { min-width: 0; flex-basis: 100%; flex-direction: row; gap: 8px; align-items: baseline; }
  .td-rem-body { flex-basis: 100%; }
  .td-rem-actions { width: 100%; }
  .td-rem-actions .btn { flex: 1; min-height: 44px; }
  .td-bullet { flex-wrap: wrap; }
  .td-bullet-body { flex-basis: calc(100% - 52px); }
  .td-bullet-btns { width: 100%; padding-left: 52px; margin-top: 0; margin-bottom: 8px; }
  .td-bullet-btns .btn { min-height: 40px; }
  /* The side column of a task row stacks under the text on a phone. */
  .td-row { flex-wrap: wrap; }
  .td-row .task-body { flex-basis: calc(100% - 40px); }
  .td-row .task-side { flex-direction: row; flex-wrap: wrap; align-items: center; width: 100%; padding-left: 36px; }
  .td-row .task-side .btn { min-height: 40px; }
  .td-menu { min-width: 0; width: calc(100vw - 16px); max-width: 320px; }
}
