/* Sparrow Office — contractor app
   Brand: black and white; colour only for status. Tokens from the Sparrow design system. */

:root {
  --surface: #ffffff;
  --surface-soft: #f4f4f4;
  --line: #e3e3e3;
  --ink: #0a0a0a;
  --ink-muted: #6b6b6b;
  --fill: #0a0a0a;
  --on-fill: #ffffff;
  --ok: #1f7a3a;
  --warn: #9a6700;
  --bad: #b3261e;

  --font-display: "Bricolage Grotesque", "Helvetica Neue", Arial, sans-serif;
  --font-body: Geist, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, Menlo, Consolas, monospace;

  --r-sm: 8px;
  --r-lg: 14px;
  --r-full: 999px;
  --nav-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface: #0b0b0b;
    --surface-soft: #161616;
    --line: #2a2a2a;
    --ink: #f2f2f2;
    --ink-muted: #9a9a9a;
    --fill: #f2f2f2;
    --on-fill: #0b0b0b;
    --ok: #6fd38e;
    --warn: #e8b64a;
    --bad: #ff8a80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--surface);
  color: var(--ink);
  font: 400 15px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

/* ---------- Type ---------- */
.wordmark { font: 800 24px/1 var(--font-display); letter-spacing: -0.02em; }
.label, .tagline {
  font: 400 11px/1.4 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.tagline { letter-spacing: 0.14em; }
h1, h2, h3 { font-family: var(--font-display); margin: 0; }
h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; }
h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; }
h3 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
.muted { color: var(--ink-muted); }
.small { font-size: 13px; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-rows: auto 1fr; grid-template-columns: minmax(0, 1fr); min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex-shrink: 0; }
.topbar .select { min-width: 0; flex: 0 1 auto; max-width: 320px; text-overflow: ellipsis; }
@media (max-width: 480px) {
  .topbar { gap: 8px; }
  .topbar .brand .tagline { display: none; }
}
.brand .tagline { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }

.shell { display: grid; grid-template-columns: minmax(0, 1fr); }
.sidenav { display: none; }
main { padding: 20px 16px calc(var(--nav-h) + 32px); max-width: 860px; width: 100%; margin: 0 auto; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
}
.navbtn {
  flex: 1; border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--ink-muted); font: 500 12px/1 var(--font-body); position: relative;
}
.navbtn svg { width: 22px; height: 22px; }
.navbtn[aria-current="page"] { color: var(--ink); font-weight: 600; }
.navbtn .dot {
  position: absolute; top: 10px; left: calc(50% + 8px);
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--r-full);
  background: var(--fill); color: var(--on-fill); font: 600 10px/16px var(--font-body); text-align: center;
}

@media (min-width: 900px) {
  .shell { grid-template-columns: 220px minmax(0, 1fr); }
  .sidenav {
    display: flex; flex-direction: column; gap: 4px;
    padding: 20px 12px; border-right: 1px solid var(--line);
    position: sticky; top: 61px; height: calc(100vh - 61px);
  }
  .sidenav .navbtn {
    flex: none; flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 10px 12px; border-radius: var(--r-sm); font-size: 15px;
  }
  .sidenav .navbtn[aria-current="page"] { background: var(--surface-soft); }
  .sidenav .navbtn .dot { position: static; margin-left: auto; }
  .bottomnav { display: none; }
  main { padding: 32px 32px 48px; }
}

/* ---------- Page header ---------- */
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.pagehead .label { display: block; margin-bottom: 6px; }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: var(--r-full);
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  font-weight: 600; font-size: 14px; white-space: nowrap;
}
.btn:hover { background: var(--surface-soft); }
.btn.primary { background: var(--fill); color: var(--on-fill); border-color: var(--fill); }
.btn.primary:hover { opacity: 0.88; }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: none; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn svg { width: 16px; height: 16px; }
.iconbtn {
  width: 40px; height: 40px; border-radius: var(--r-full); border: 1px solid var(--line);
  background: var(--surface); display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.iconbtn svg { width: 18px; height: 18px; }

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

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field input, .field select, .field textarea, .select {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-soft);
}
.field textarea { min-height: 88px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--ink); outline-offset: -1px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.select { min-height: 36px; padding: 6px 10px; width: auto; border-radius: var(--r-full); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-full);
  padding: 6px 14px; font-size: 13px; font-weight: 500; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--fill); color: var(--on-fill); border-color: var(--fill); }

/* ---------- Cards and lists ---------- */
.card { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.list { display: flex; flex-direction: column; gap: 12px; }
.daygroup { margin-bottom: 24px; }
.daygroup > .label { display: block; margin-bottom: 10px; }

.booking { padding: 16px; display: grid; gap: 10px; }
.booking .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.booking .time { font: 700 18px/1.2 var(--font-display); letter-spacing: -0.01em; }
.booking .meta { display: grid; gap: 4px; font-size: 14px; }
.booking .meta a { text-decoration: none; }
.booking .meta a:hover { text-decoration: underline; }
.answers { background: var(--surface-soft); border-radius: var(--r-sm); padding: 10px 12px; font-size: 13px; }
.answers dt { color: var(--ink-muted); }
.answers dd { margin: 0 0 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.status { font: 500 11px/1 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; white-space: nowrap; }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.status.bad { color: var(--bad); }
.status.quiet { color: var(--ink-muted); }
.newtag {
  display: inline-block; padding: 3px 8px; border-radius: var(--r-full);
  background: var(--fill); color: var(--on-fill); font: 600 10px/1.2 var(--font-mono); letter-spacing: 0.1em;
}

.task { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; padding: 14px 16px; }
.task + .task { border-top: 1px solid var(--line); }
.check {
  width: 24px; height: 24px; border-radius: var(--r-full); border: 1.5px solid var(--ink-muted);
  background: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; margin-top: 1px;
}
.check svg { width: 14px; height: 14px; opacity: 0; }
.check[aria-checked="true"] { background: var(--fill); border-color: var(--fill); color: var(--on-fill); }
.check[aria-checked="true"] svg { opacity: 1; }
.task.done .title { text-decoration: line-through; color: var(--ink-muted); }
.task .title { font-weight: 500; }
.task .sub { font-size: 13px; color: var(--ink-muted); display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.task .sub .overdue { color: var(--bad); }
.pri-high { color: var(--warn); font-weight: 600; }

.project { padding: 16px; display: grid; gap: 8px; cursor: pointer; text-align: left; border: 1px solid var(--line); background: var(--surface); width: 100%; }
.project:hover { background: var(--surface-soft); }
.project .top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.crewline { display: flex; gap: 6px; flex-wrap: wrap; }
.avatar {
  width: 28px; height: 28px; border-radius: var(--r-full); background: var(--surface-soft); border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; font: 600 11px/1 var(--font-body);
}
.person { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 14px 16px; }
.person + .person { border-top: 1px solid var(--line); }
.person .avatar { width: 40px; height: 40px; font-size: 13px; }

.empty { padding: 32px 16px; text-align: center; color: var(--ink-muted); border: 1px dashed var(--line); border-radius: var(--r-lg); }
.empty h3 { color: var(--ink); margin-bottom: 4px; }

.banner { padding: 10px 16px; background: var(--surface-soft); border-bottom: 1px solid var(--line); font-size: 13px; text-align: center; }

/* ---------- Sheet (modal) ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}
.sheet .sheethead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; }
.sheet .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.sheet section { margin-top: 24px; }
.sheet section > .label { display: block; margin-bottom: 10px; }
@media (min-width: 600px) {
  .scrim { align-items: center; padding: 24px; }
  .sheet { border-radius: var(--r-lg); padding: 24px; }
}

/* ---------- Sign-in ---------- */
.signin { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px 16px; max-width: 420px; margin: 0 auto; }
.signin .brand { margin-bottom: 40px; }
.signin h1 { margin-bottom: 8px; }
.signin p { margin: 0 0 24px; color: var(--ink-muted); }
.signin .btn.primary { width: 100%; min-height: 48px; }
.msg { font-size: 14px; margin-top: 12px; }
.msg.err { color: var(--bad); }
.msg.ok { color: var(--ok); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px); z-index: 50;
  background: var(--fill); color: var(--on-fill); padding: 10px 16px; border-radius: var(--r-full); font-size: 14px; font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
@media (min-width: 900px) { .toast { bottom: 24px; } }

.loading { padding: 40px 0; text-align: center; color: var(--ink-muted); }
