/* GCP Check: a field instrument screen. Sunlight-readable contrast, survey-panel black/white, one deep green accent,
   status in three fixed colours (OK / Check / Recheck). Phone first: bottom tab bar; side rail from 900px. */
:root {
  --bg: #f2f5f3;
  --surface: #ffffff;
  --surface-2: #e9eeeb;
  --ink: #0f1a17;
  --muted: #56655f;
  --line: #d5ddd9;
  --accent: #0b5e52;
  --accent-ink: #ffffff;
  --accent-soft: #dcefe9;
  --ok: #1d7a45;
  --ok-soft: #dff3e6;
  --check: #9a6200;
  --check-soft: #fbefd5;
  --recheck: #b8281e;
  --recheck-soft: #fbe2df;
  --panel: #0f1a17;
  --shadow: 0 1px 2px rgba(15, 26, 23, .06), 0 6px 18px rgba(15, 26, 23, .06);
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --r: 12px;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1311; --surface: #141e1b; --surface-2: #1b2723; --ink: #e6efeb; --muted: #93a49e; --line: #26342f;
    --accent: #3fbfa6; --accent-ink: #062520; --accent-soft: #143a33;
    --ok: #4cc47e; --ok-soft: #133524; --check: #f0b54a; --check-soft: #3a2c10; --recheck: #ff7a6e; --recheck-soft: #3e1714;
    --panel: #e6efeb; --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1311; --surface: #141e1b; --surface-2: #1b2723; --ink: #e6efeb; --muted: #93a49e; --line: #26342f;
  --accent: #3fbfa6; --accent-ink: #062520; --accent-soft: #143a33;
  --ok: #4cc47e; --ok-soft: #133524; --check: #f0b54a; --check-soft: #3a2c10; --recheck: #ff7a6e; --recheck-soft: #3e1714;
  --panel: #e6efeb; --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; font-weight: 600; }
h3 { font-size: .95rem; font-weight: 600; }
.eyebrow { font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- boot / login ---------- */
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 8px; color: var(--muted); }
.login {
  min-height: 100vh; display: grid; place-items: center;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left));
}
.login-card { width: min(400px, 100%); display: grid; gap: 20px; }
.login-brand { display: flex; align-items: center; gap: 14px; }
.login-brand img { width: 56px; height: 56px; border-radius: 14px; }
.login-foot { display: flex; justify-content: center; }
.login-foot img { height: 34px; width: auto; opacity: .85; }

/* ---------- shell ---------- */
.shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line);
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
}
.topbar-in { display: flex; align-items: center; gap: 12px; height: 56px; max-width: 1180px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.brand b { font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.topbar .grow { flex: 1; }
.sync {
  display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; background: var(--surface); cursor: pointer;
}
.sync i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.sync.off i { background: var(--check); }
.sync.wait i { background: var(--check); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.who { font-size: .85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }

.main {
  padding: 20px max(16px, env(safe-area-inset-right, 0px)) calc(var(--nav-h) + 28px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.page { max-width: 1180px; margin: 0 auto; display: grid; gap: 18px; min-width: 0; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
.tabs a {
  height: var(--nav-h); display: grid; place-content: center; justify-items: center; gap: 2px; text-decoration: none;
  color: var(--muted); font-size: .75rem; font-weight: 500;
}
.tabs a svg { width: 24px; height: 24px; }
.tabs a.on { color: var(--accent); }
.tabs a.on svg { stroke-width: 2.4; }

@media (min-width: 900px) {
  .shell { grid-template-columns: 220px 1fr; grid-template-rows: auto 1fr; }
  .topbar { grid-column: 1 / -1; }
  .tabs {
    position: sticky; top: 57px; align-self: start; height: calc(100vh - 57px); grid-auto-flow: row; grid-auto-rows: 48px;
    grid-auto-columns: auto; align-content: start; gap: 4px; border-top: 0; border-right: 1px solid var(--line); padding: 16px 12px;
  }
  .tabs a { height: 48px; display: flex; justify-content: flex-start; gap: 12px; padding: 0 14px; border-radius: 10px; font-size: .92rem; }
  .tabs a.on { background: var(--accent-soft); }
  .main { padding-bottom: 40px; }
}

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--recheck); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .88rem; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.field { display: grid; gap: 6px; min-width: 0; }
.field label { font-size: .85rem; font-weight: 600; }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
textarea.input { min-height: 70px; resize: vertical; }
.form { display: grid; gap: 14px; }
.error { color: var(--recheck); font-size: .9rem; }

.seg { display: inline-grid; grid-auto-flow: column; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button {
  border: 0; background: transparent; border-radius: 8px; min-height: 38px; padding: 0 14px; font-weight: 600; color: var(--muted);
  cursor: pointer; white-space: nowrap;
}
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0; }
.card.flat { box-shadow: none; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* ---------- import ---------- */
.import-grid { display: grid; gap: 16px; }
@media (min-width: 760px) { .import-grid { grid-template-columns: 1fr 1fr; align-items: start; } }
.drop {
  display: grid; place-items: center; text-align: center; gap: 10px; padding: 34px 18px; border-radius: var(--r);
  border: 2px dashed color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--surface); cursor: pointer;
}
.drop.over { background: var(--accent-soft); border-color: var(--accent); }
.drop .target { width: 64px; height: 64px; }
.drop strong { font-size: 1.1rem; }

/* ---------- report ---------- */
.rep-head { display: grid; gap: 6px; }
.rep-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .88rem; color: var(--muted); }
.rep-meta span { display: inline-flex; gap: 5px; align-items: center; }

.verdict {
  display: grid; gap: 14px; padding: 18px; border-radius: var(--r); background: var(--panel); color: var(--bg);
}
.verdict .big { font-size: 1.35rem; font-weight: 700; line-height: 1.25; }
.verdict .sub { opacity: .8; font-size: .92rem; }
.tally { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tally button {
  border: 0; border-radius: 10px; padding: 10px 12px; text-align: left; cursor: pointer; display: grid; gap: 0;
  background: color-mix(in srgb, var(--bg) 8%, transparent); color: inherit;
}
.tally button.on { outline: 2px solid currentColor; }
.tally b { font: 600 1.7rem/1.1 var(--mono); }
.tally span { font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; opacity: .85; }
.tally .t-ok b { color: var(--ok); } .tally .t-check b { color: var(--check); } .tally .t-recheck b { color: var(--recheck); }
.bar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: color-mix(in srgb, var(--bg) 15%, transparent); }
.bar i { display: block; height: 100%; }
.bar .b-ok { background: var(--ok); } .bar .b-check { background: var(--check); } .bar .b-recheck { background: var(--recheck); }

.notes { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.notes li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: var(--check-soft); font-size: .92rem; }
.notes li svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--check); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .78rem;
  font-weight: 700; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.lv0 { color: var(--ok); background: var(--ok-soft); }
.lv1 { color: var(--check); background: var(--check-soft); }
.lv2 { color: var(--recheck); background: var(--recheck-soft); }

.points { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); }
.pt { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: grid; min-width: 0; }
.pt.l1 { border-left: 5px solid var(--check); }
.pt.l2 { border-left: 5px solid var(--recheck); }
.pt.l0 { border-left: 5px solid var(--ok); }
.pt-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 12px 14px 6px; }
.pt-name { font: 600 1.15rem/1.2 var(--mono); word-break: break-all; }
.pt-sub { font-size: .8rem; color: var(--muted); }
.pt-coords { padding: 0 14px 8px; font: .8rem/1.4 var(--mono); color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 12px; }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.chip { background: var(--surface); padding: 7px 10px; display: grid; min-width: 0; }
.chip:last-child:nth-child(3n + 2) { grid-column: span 2; }
.chip:last-child:nth-child(3n + 1) { grid-column: span 3; }
.chip span { font-size: .68rem; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip b { font: 600 .98rem/1.3 var(--mono); }
.chip.g1 { background: var(--check-soft); } .chip.g1 b { color: var(--check); }
.chip.g2 { background: var(--recheck-soft); } .chip.g2 b { color: var(--recheck); }
.chip.na b { color: var(--muted); font-weight: 400; }
.issues { margin: 0; padding: 10px 14px 12px 32px; display: grid; gap: 4px; font-size: .88rem; border-top: 1px solid var(--line); }
.issues li.l2 { color: var(--recheck); } .issues li.l1 { color: var(--check); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; }
td.num, th.num { text-align: right; }
td.g1 { background: var(--check-soft); color: var(--check); font-weight: 600; }
td.g2 { background: var(--recheck-soft); color: var(--recheck); font-weight: 600; }
tr:last-child td { border-bottom: 0; }

.plan { width: 100%; height: auto; display: block; }
.plan text { font: 11px var(--mono); fill: var(--ink); }
.plan .grid { stroke: var(--line); stroke-width: 1; }
.plan .base { fill: none; stroke: var(--muted); stroke-width: 2; }

.grid-gap { display: grid; gap: 12px; }
details.card summary { cursor: pointer; }

/* ---------- history ---------- */
.filters { display: grid; gap: 10px; }
@media (min-width: 700px) { .filters { grid-template-columns: 1fr auto; align-items: center; } }
.projects { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.projects button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; white-space: nowrap;
  cursor: pointer; font-size: .86rem;
}
.projects button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.list { display: grid; gap: 10px; }
.row {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 14px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); text-decoration: none; color: var(--ink); min-width: 0;
}
.row:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.row .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.row .m { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .82rem; color: var(--muted); }
.row .bar { grid-column: 1 / -1; background: var(--surface-2); height: 6px; }
.row.pending { border-style: dashed; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); display: grid; gap: 10px; justify-items: center; }

/* ---------- settings ---------- */
.limits { display: grid; gap: 0; }
.limit { display: grid; grid-template-columns: 1fr 86px 86px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.limit:last-child { border-bottom: 0; }
.limit .input { min-height: 40px; padding: 6px 8px; text-align: right; font-family: var(--mono); }
.limit small { display: block; color: var(--muted); font-size: .78rem; }
.limit-head { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-bottom: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: .92rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.users .row { grid-template-columns: 1fr auto; align-items: center; }

/* ---------- toast & sheet ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px));
  background: var(--panel); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: .92rem;
  max-width: calc(100vw - 32px); box-shadow: var(--shadow);
}
.sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .45); display: grid; align-items: end; justify-items: center; }
.sheet {
  width: min(520px, 100%); background: var(--surface); border-radius: 16px 16px 0 0; display: grid; gap: 14px;
  padding: 20px max(16px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  max-height: 90vh; overflow: auto;
}
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: 16px; } }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
