:root {
  --lake: #0d2137;
  --deep: #081729;
  --panel: #14304e;
  --line: #2b4c70;
  --ink: #eef4fa;
  --muted: #9fb6cc;
  --buoy: #ffc93c;
  --buoy-ink: #1c1602;
  --ok: #62d49c;
  --warn: #ff9f6b;
  --r: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--lake); color: var(--ink); }
body {
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--buoy); outline-offset: 2px; }
h1, h2 { margin: 0; }
.h2, h2 { display: block; font-size: 15px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
.opt { font-weight: 400; }

input:not([type]), input[type=text], input[type=password], input[type=search], textarea {
  width: 100%; padding: 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--deep); font-size: 17px;
}
textarea { resize: vertical; min-height: 64px; }

.btn-main {
  display: block; width: 100%; min-height: 58px; border: 0; border-radius: var(--r);
  background: var(--buoy); color: var(--buoy-ink); font-size: 19px; font-weight: 700;
}
.btn-main:disabled { background: var(--panel); color: var(--muted); }
.btn-quiet {
  border: 1px solid var(--line); background: transparent; border-radius: 999px;
  padding: 10px 16px; min-height: 44px; font-weight: 600;
}
.err { color: var(--warn); min-height: 1.4em; }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 14px; }
.login-card h1 { font-size: 26px; margin-bottom: 8px; }
.show-pw { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 15px; min-height: 44px; }
.show-pw input { width: 22px; height: 22px; accent-color: var(--buoy); }

/* capture */
.capture {
  max-width: 560px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 18px calc(env(safe-area-inset-bottom, 0px) + 110px);
}
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0 18px; }
.brand { font-weight: 800; letter-spacing: .01em; }
.outbox {
  border: 0; border-radius: 999px; padding: 8px 14px; min-height: 36px; font-size: 14px; font-weight: 600;
  background: var(--panel); color: var(--muted);
}
.outbox[data-state=ok]::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 8px; vertical-align: 1px; }
.outbox[data-state=busy] { color: var(--ink); }
.outbox[data-state=wait] { color: var(--buoy-ink); background: var(--buoy); }

.job {
  padding: 18px 18px 20px; border-radius: 20px; margin-bottom: 26px;
  background: linear-gradient(180deg, var(--panel), #102843);
  border-bottom: 3px solid #3e7cc0;
}
.how { margin: 0 0 6px; font-size: 14px; color: var(--muted); }
.cust-name { font-size: 30px; line-height: 1.1; font-weight: 800; letter-spacing: -.01em; overflow-wrap: anywhere; }
.cust-name:empty { display: none; }
.cust-addr { margin: 6px 0 14px; color: var(--muted); }
.cust-addr:empty { margin: 8px 0 0; }
.cust-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.addr-fix { display: grid; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.addr-fix label { font-size: 15px; color: var(--buoy); }

.block { margin-bottom: 26px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.grid:empty { display: none; }
.tile { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--panel); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .x {
  position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border-radius: 50%;
  border: 0; background: rgba(8, 23, 41, .8); color: var(--ink); font-size: 18px; line-height: 1;
}
.tile.wait::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--buoy); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.add-photos {
  position: relative; display: grid; place-items: center; min-height: 96px; border-radius: var(--r);
  border: 2px dashed var(--line); font-weight: 700; font-size: 19px;
}
.add-photos input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.add-photos:focus-within { outline: 3px solid var(--buoy); outline-offset: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: transparent; border-radius: 999px;
  padding: 10px 15px; min-height: 44px; font-size: 16px;
}
.chip[aria-pressed=true] { background: var(--ink); color: var(--lake); border-color: var(--ink); font-weight: 700; }
.chip[aria-pressed=true]::before { content: "\2713"; margin-right: 6px; font-weight: 800; }

/* work done, grouped by what was worked on */
.groups { display: grid; gap: 0; border-top: 1px solid var(--line); }
.group { display: grid; grid-template-columns: 72px 1fr; gap: 12px; align-items: start; padding: 14px 0; border-bottom: 1px solid var(--line); }
.group-head { display: grid; justify-items: center; gap: 4px; font-size: 14px; font-weight: 700; color: var(--muted); text-align: center; }
.group-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--panel); color: var(--muted); }
.group-icon svg { width: 28px; height: 28px; }
.group.on .group-head { color: var(--ink); }
.group.on .group-icon { background: var(--buoy); color: var(--buoy-ink); }
.with-hint .opt { font-size: 14px; color: var(--ok); }

.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 18px calc(env(safe-area-inset-bottom, 0px) + 12px);
  background: linear-gradient(180deg, rgba(13, 33, 55, 0), var(--lake) 30%);
}
.savebar .btn-main { max-width: 524px; margin: 0 auto; }

/* customer sheet */
.sheet { position: fixed; inset: 0; background: rgba(4, 12, 22, .6); display: flex; align-items: flex-end; z-index: 10; }
.sheet-panel {
  width: 100%; max-width: 560px; margin: 0 auto; height: 88dvh; background: var(--lake);
  border-radius: 20px 20px 0 0; padding: 16px 18px calc(env(safe-area-inset-bottom, 0px) + 16px);
  display: flex; flex-direction: column; gap: 12px;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { margin: 0; color: var(--ink); font-size: 20px; }
.results { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.results button {
  width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; padding: 14px 4px; display: grid; gap: 2px;
}
.results b { font-size: 18px; }
.results small { color: var(--muted); font-size: 14px; }
.results .empty { color: var(--muted); padding: 14px 4px; }
.new-cust { align-self: flex-start; }
.new-form { display: grid; gap: 8px; }
.new-form label { font-size: 15px; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 96px); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--lake); font-weight: 600; padding: 12px 18px; border-radius: 12px;
  max-width: calc(100% - 36px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
  .tile.wait::after { animation: none; }
}
