/* TurnoverOps — Stack B interfaces (shared design system)
 *
 * One stylesheet for all three role surfaces. A single system rather than three
 * is deliberate: the operator, the cleaner and the client are looking at the same
 * records, and a status that is "amber" on one screen must not be "orange" on
 * another. Tokens are named for meaning (--ok, --late) not for colour.
 *
 * Mobile-first. The cleaner uses a phone in a flat with one hand; the operator
 * uses a laptop. Base rules are the narrow layout, and the wider layout is added
 * with a min-width query, so the phone never downloads a desktop-first cascade it
 * has to undo.
 */

:root {
  color-scheme: light;

  --canvas: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f4f8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;

  --brand: #0f766e;
  --brand-strong: #115e59;
  --brand-soft: #ecfdf5;
  --focus: #2563eb;

  --ok-bg: #ecfdf5;      --ok-fg: #047857;
  --late-bg: #fffbeb;    --late-fg: #b45309;
  --bad-bg: #fef2f2;     --bad-fg: #b91c1c;
  --info-bg: #eff6ff;    --info-fg: #1d4ed8;
  --neutral-bg: #f1f5f9; --neutral-fg: #475569;

  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06);
  --tap: 44px; /* minimum touch target */
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 19px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }

a { color: var(--brand-strong); }

/* Visible focus for keyboard users on every interactive element. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Screen-reader-only text: labels that must exist for assistive tech but would
   be visual noise on a dense board. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }

main { padding: 16px; max-width: 1100px; margin: 0 auto; }
main.narrow { max-width: 640px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.card > header {
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}

.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

label { font-size: 13px; font-weight: 550; color: var(--ink-2); display: block; margin-bottom: 4px; }

input[type=text], input[type=email], input[type=date], input[type=datetime-local],
input[type=number], select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}
textarea { min-height: 88px; resize: vertical; }

button {
  min-height: var(--tap);
  padding: 10px 16px;
  font: inherit; font-weight: 600;
  color: #fff;
  background: var(--brand);
  border: 1px solid var(--brand-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--brand-strong); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.secondary {
  background: var(--surface); color: var(--ink-2); border-color: var(--line-strong);
}
button.secondary:hover:not(:disabled) { background: var(--surface-2); }
button.danger { background: #b91c1c; border-color: #991b1b; }
button.link {
  background: none; border: none; color: var(--brand-strong);
  text-decoration: underline; padding: 6px; min-height: 0; font-weight: 550;
}

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em;
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
  background: var(--neutral-bg); color: var(--neutral-fg);
}
.badge.ok      { background: var(--ok-bg);      color: var(--ok-fg); }
.badge.late    { background: var(--late-bg);    color: var(--late-fg); }
.badge.bad     { background: var(--bad-bg);     color: var(--bad-fg); }
.badge.info    { background: var(--info-bg);    color: var(--info-fg); }
.badge.brand   { background: var(--brand-soft); color: var(--brand-strong); }

.muted { color: var(--muted); font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all; }

/* Lists: one row per job/record. A grid on wide screens, stacked on phones. */
.list { list-style: none; margin: 0; padding: 0; }
.list > li {
  display: grid; gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.list > li:first-child { border-top: none; }
.list-head { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.list-title { font-weight: 600; }
.list-meta { color: var(--muted); font-size: 13px; }

.empty {
  padding: 24px 16px; text-align: center;
  color: var(--muted); font-size: 14px;
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
}

.notice {
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px;
  border: 1px solid var(--line);
}
.notice.error { background: var(--bad-bg); border-color: #fecaca; color: var(--bad-fg); }
.notice.ok    { background: var(--ok-bg);  border-color: #a7f3d0; color: var(--ok-fg); }
.notice.info  { background: var(--info-bg); border-color: #bfdbfe; color: var(--info-fg); }

/* Loading state: a real placeholder, so an empty board is never ambiguous
   between "no jobs" and "still fetching". */
.skeleton {
  height: 56px; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface-2) 25%, #e9eef5 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button {
  background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0;
  color: var(--muted); font-weight: 600; padding: 10px 12px; white-space: nowrap; min-height: var(--tap);
}
.tabs button[aria-selected="true"] { color: var(--brand-strong); border-bottom-color: var(--brand); }
.tabs button:hover:not([aria-selected="true"]) { color: var(--ink-2); }

.proof-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.proof-grid figure { margin: 0; }
.proof-grid img {
  width: 100%; aspect-ratio: 4/3; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2);
}
.proof-grid figcaption { font-size: 11px; color: var(--muted); margin-top: 3px; }

.split { display: grid; gap: 14px; }

@media (min-width: 760px) {
  main { padding: 24px; }
  h1 { font-size: 22px; }
  .split { grid-template-columns: 1fr 1fr; }
  .list > li { grid-template-columns: 1fr auto; align-items: center; }
  .list > li .list-body { min-width: 0; }
}

/* The cleaner's phone is the primary device: keep targets large and the primary
   action reachable with a thumb. */
@media (max-width: 759px) {
  .action-bar {
    position: sticky; bottom: 0; z-index: 15;
    display: grid; gap: 8px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--line);
    margin: 16px -16px -16px;
  }
  .action-bar button { width: 100%; }
}
