/* Spectrum Surveys — phone first.
 *
 * Everything is sized for a thumb on a bright driveway: 16px minimum on inputs (any
 * smaller and iOS zooms the page on focus), 44px minimum tap targets, and high contrast
 * rather than subtle greys. Desktop gets the same layout in a centred column — Charlie
 * and Mitch use this occasionally, Tony uses it every day, so the phone wins.
 */

:root {
  --navy:   #1F233C;
  --navy-2: #2A3050;
  --cyan:   #3AC3E9;
  --ink:    #1a1d28;
  --muted:  #5d6478;
  --line:   #dfe3ec;
  --bg:     #f4f6fa;
  --card:   #ffffff;
  --ok:     #158b52;
  --warn:   #a86a00;
  --bad:    #b3261e;
  --radius: 12px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  /* Respect the notch and the home indicator when installed to the home screen. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

h1 { font-size: 1.35rem; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
h3 { font-size: .95rem; margin: 1.2rem 0 .5rem; }
a  { color: #12657f; }

.muted { color: var(--muted); font-size: .875rem; }
.bad   { color: var(--bad); }
.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;
}

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

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; padding: .6rem .9rem;
  background: var(--navy); color: #fff;
}
.topbar .brand { display: flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; font-weight: 600; }
.topbar nav { display: flex; gap: .35rem; }
.topbar nav a {
  color: #cdd3e4; text-decoration: none; padding: .5rem .7rem;
  border-radius: 8px; font-size: .9rem; min-height: 44px; display: flex; align-items: center;
}
.topbar nav a.on { background: var(--navy-2); color: #fff; }

.wrap { max-width: 720px; margin: 0 auto; padding: .9rem .9rem 4rem; }

/* ---------------------------------------------------------------- pieces */

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem; margin: 0 0 .9rem;
}

.banner { padding: .7rem .8rem; border-radius: var(--radius); margin: 0 0 .8rem; font-size: .92rem; }
.banner.ok   { background: #e7f5ee; border: 1px solid #b9e0cc; color: #0d5c37; }
.banner.warn { background: #fdf3e0; border: 1px solid #eccf9a; color: #7a4d00; }
.banner.bad  { background: #fdeceb; border: 1px solid #f0bdb9; color: #8c1d16; }

.pill { display: inline-block; padding: .1rem .45rem; border-radius: 999px; font-size: .75rem; }
.pill.ok { background: #e7f5ee; color: #0d5c37; }
.pill.warn { background: #fdf3e0; color: #7a4d00; }
.pill.bad { background: #fdeceb; color: #8c1d16; }
.pill.muted { background: #eef0f6; color: var(--muted); }

.empty { color: var(--muted); padding: 1rem 0; }
.hint  { color: var(--muted); font-size: .85rem; margin: .35rem 0 1rem; }

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

.field { display: block; margin: 0 0 .75rem; }
.field > span { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .2rem; }

input[type=text], input[type=tel], input[type=email], input[type=password],
input[type=search], input[type=number], input[type=date], input:not([type]),
textarea, select {
  width: 100%; padding: .7rem .65rem;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink);
  /* 16px exactly: anything smaller and iOS Safari zooms the whole page on focus,
     which on a customer's driveway is genuinely infuriating. */
  font-size: 16px; font-family: inherit;
  min-height: 44px;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--cyan); outline-offset: 1px; border-color: var(--cyan); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: .6rem 1rem;
  border: 1px solid var(--navy); border-radius: 10px;
  background: #fff; color: var(--navy); font-size: .95rem; font-weight: 600;
  text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--navy); color: #fff; }
.btn.ghost   { border-color: var(--line); color: var(--navy); font-weight: 500; }
.btn.wide    { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.linkbtn { background: none; border: 0; color: #12657f; font: inherit; font-size: .85rem; cursor: pointer; padding: .4rem; min-height: 44px; }
.linkbtn.bad { color: var(--bad); }

.check { display: inline-flex; align-items: center; gap: .35rem; margin: 0 .6rem .35rem 0; font-size: .9rem; }
.check input { width: auto; min-height: 0; }
.chiprow { display: flex; flex-wrap: wrap; }

.inlineform { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.inlineform input { width: auto; flex: 1 1 8rem; }
.stack { display: block; }

/* ---------------------------------------------------------------- search */

.searchbar { display: flex; gap: .5rem; margin: 0 0 .2rem; }
.searchbar input { flex: 1; }

.listhead { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 1.1rem 0 .4rem; }

.clist { display: flex; flex-direction: column; gap: .4rem; }
.crow {
  display: flex; align-items: center; gap: .6rem;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .7rem .8rem; text-decoration: none; color: var(--ink);
  min-height: 60px;                     /* comfortably tappable with cold hands */
}
.crow:active { background: #eef2fa; }
.crow-main { flex: 1; min-width: 0; }
.crow-name { display: block; font-weight: 600; }
.crow-sub  { display: block; font-size: .84rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crow-note { font-size: .75rem; color: var(--muted); white-space: nowrap; }
.crow-go   { color: var(--muted); font-size: 1.3rem; }

/* ---------------------------------------------------------------- customer */

.chead { margin: 0 0 .9rem; }
.csub  { margin: 0 0 .5rem; color: var(--muted); }
.stages { display: flex; flex-wrap: wrap; gap: .3rem; margin: .3rem 0 .6rem; }
.stage  { background: #eef2fa; border: 1px solid var(--line); border-radius: 999px; padding: .15rem .6rem; font-size: .78rem; }
.quickrow { display: flex; flex-wrap: wrap; gap: .4rem; }

.sticky-save {
  position: sticky; bottom: 0; z-index: 15;
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  background: var(--bg); border-top: 1px solid var(--line);
  padding: .6rem 0; margin-top: .4rem;
}
.savestate { font-size: .8rem; color: var(--muted); }
.savestate.ok  { color: var(--ok); }
.savestate.bad { color: var(--bad); }

/* ---------------------------------------------------------------- photos */

.uploads { list-style: none; margin: .8rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.upl { display: flex; align-items: center; gap: .6rem; padding: .4rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.upl-thumb { width: 44px; height: 44px; border-radius: 8px; overflow: hidden; background: #eef0f6; flex: none; }
.upl-thumb img { width: 100%; height: 100%; object-fit: cover; }
.upl-meta { flex: 1; min-width: 0; }
.upl-name { display: block; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upl-state { display: block; font-size: .78rem; color: var(--muted); }
.upl.going .upl-state { color: #12657f; }
.upl.done  .upl-state { color: var(--ok); }
.upl.wait  .upl-state { color: var(--warn); }
.upl.bad   .upl-state { color: var(--bad); }

.gallery { list-style: none; margin: .9rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; }
.gallery li { position: relative; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; }
.gmeta { display: block; font-size: .7rem; color: var(--muted); margin-top: .2rem; }
.ginline { margin: 0; }

/* ---------------------------------------------------------------- notes */

.notes { list-style: none; margin: 1rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.notes li { border-left: 3px solid var(--line); padding-left: .7rem; }
.notes p  { margin: 0 0 .2rem; }
.nmeta    { font-size: .78rem; color: var(--muted); }

/* ---------------------------------------------------------------- admin */

.grid { width: 100%; border-collapse: collapse; font-size: .88rem; display: block; overflow-x: auto; }
.grid th, .grid td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.capform { display: flex; flex-wrap: wrap; gap: .2rem; align-items: center; }

.mini-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%; font-size: .7rem; font-weight: 700;
  margin-right: .3rem; vertical-align: middle;
}
.mini-avatar.none { background: #eef0f6; color: var(--muted); }

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

.loginwrap { max-width: 340px; margin: 0 auto; padding: 3rem 1.2rem; text-align: center; }
.loginlogo { width: 150px; height: auto; margin-bottom: 1rem; filter: invert(1) brightness(.25); }
.loginform { text-align: left; margin-top: 1.2rem; }
.loginnote { font-size: .78rem; color: var(--muted); margin-top: 1.6rem; }

/* ---------------------------------------------------------------- dark */
/* The phone is often in dark mode and this app gets used at dusk in December. */
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e9ecf4; --muted: #9aa3ba; --line: #333a52;
    --bg: #14172a; --card: #1c2038; --navy-2: #2a3050;
  }
  .btn { background: var(--card); color: #dfe4f2; border-color: #3a4160; }
  /* .btn.ghost sets color:var(--navy) for light mode. --navy stays dark in the dark
     palette (it is the brand colour, not a text colour), so without this the ghost
     buttons were dark navy on a dark card — legible as empty boxes and nothing else. */
  .btn.ghost { color: #dfe4f2; border-color: #3a4160; }
  .btn.primary { background: var(--cyan); color: #10131f; border-color: var(--cyan); }
  input[type=text], input[type=tel], input[type=email], input[type=password],
  input[type=search], input[type=number], input[type=date], input:not([type]),
  textarea, select { background: #121524; color: var(--ink); border-color: #3a4160; }
  .stage, .upl-thumb, .mini-avatar.none { background: #262b45; }
  .crow:active { background: #232842; }
  .banner.ok   { background: #10301f; border-color: #1d5c39; color: #8fe0b4; }
  .banner.warn { background: #33280f; border-color: #6b5316; color: #e9c67a; }
  .banner.bad  { background: #331715; border-color: #6d2723; color: #f0a49e; }
  .loginlogo { filter: none; }
  a, .linkbtn { color: var(--cyan); }
}
