/* Property inspections — a field instrument, not a dashboard.
   Built to be read on a phone in direct sun, one-handed, with gloves on. */

:root {
  --ink: #16202b;
  --ink-soft: #33465a;
  --muted: #5a6b79;
  --paper: #e7ecf1;
  --surface: #ffffff;
  --surface-2: #f3f6f9;
  --rule: #c6d0d9;
  --rule-hard: #93a3b1;
  --fresh: #1f6b4a;
  --warn: #b26a00;
  --late: #a8321f;
  --late-wash: #fbedea;
  --accent: #2e4257;
  --accent-wash: #eaeef3;

  --step--1: 0.75rem;
  --step-0: 0.9375rem;
  --step-1: 1.0625rem;
  --step-2: 1.375rem;
  --step-3: 2rem;

  --gap: 0.75rem;
  --radius: 3px;
  --shadow: 0 1px 0 var(--rule), 0 6px 18px -14px rgba(22, 32, 43, 0.5);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: var(--step-0)/1.5 "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  padding-bottom: 6.5rem;
}

h1, h2, h3, .display {
  font-family: "Barlow Condensed", "IBM Plex Sans Condensed", sans-serif;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0;
}

.mono, .age-count, .stat-num, input[type="date"], .pill-code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

a { color: var(--accent); }

/* ------------------------------------------------------------ masthead */

.masthead {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--accent);
  color: #fff;
  border-bottom: 3px solid rgba(0, 0, 0, 0.25);
  transition: background 220ms ease;
}

.masthead-inner {
  max-width: 60rem;
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mark {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.04em;
  padding: 0.3rem 0.5rem;
  border: 2px solid rgba(255, 255, 255, 0.85);
  white-space: nowrap;
}

.masthead h1 {
  font-size: var(--step-1);
  line-height: 1.1;
  flex: 1;
  min-width: 0;
}

.masthead .sub {
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.6875rem;
  font-weight: 400;
  opacity: 0.8;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.masthead a { color: #fff; text-decoration: none; font-size: var(--step--1); }
.masthead a:hover { text-decoration: underline; }

/* ------------------------------------------------------------ shell */

.wrap {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card > header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--rule);
  background: var(--surface-2);
}

.card > header h2 { font-size: var(--step-2); }

.card > header .hint,
.eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.card-body { padding: 0.9rem; display: grid; gap: 0.75rem; }

/* ------------------------------------------------------------ form bits */

label.field { display: grid; gap: 0.25rem; }

label.field > span {
  font-size: 0.6875rem;
  font-family: "IBM Plex Mono", monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

input, select, textarea, button { font: inherit; color: inherit; }

input[type="text"], input[type="date"], select, textarea {
  width: 100%;
  padding: 0.55rem 0.6rem;
  background: var(--surface);
  border: 1px solid var(--rule-hard);
  border-radius: var(--radius);
  min-height: 2.75rem;
}

textarea { min-height: 4.5rem; resize: vertical; }

input:focus-visible, select:focus-visible, textarea:focus-visible,
button:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.grid-2 { display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 34rem) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--rule-hard);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-weight: 500;
  transition: background 120ms ease, transform 60ms ease;
}

.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { filter: brightness(1.12); background: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-danger { color: var(--late); border-color: var(--late); }
.btn-sm { min-height: 2.25rem; padding: 0.3rem 0.6rem; font-size: var(--step--1); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* ------------------------------------------------------------ checklist */

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 0.9rem;
  background: var(--accent-wash);
  border: 0;
  border-top: 1px solid var(--rule);
  cursor: pointer;
  text-align: left;
}

.section-head h3 { font-size: var(--step-1); }
.section-head .count { font-family: "IBM Plex Mono", monospace; font-size: var(--step--1); color: var(--muted); }

.check-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem 0.75rem;
  align-items: center;
  padding: 0.6rem 0.9rem;
  border-top: 1px solid var(--rule);
}

.check-row p { margin: 0; font-size: var(--step-0); }
.check-row .note-in { grid-column: 1 / -1; }
.check-row[data-status="fail"] { background: var(--late-wash); }

.tri { display: inline-flex; border: 1px solid var(--rule-hard); border-radius: var(--radius); overflow: hidden; }
.tri button {
  border: 0;
  background: var(--surface);
  padding: 0.45rem 0.55rem;
  min-width: 3rem;
  min-height: 2.5rem;
  cursor: pointer;
  font-size: var(--step--1);
  border-left: 1px solid var(--rule);
}
.tri button:first-child { border-left: 0; }
.tri button[aria-pressed="true"] { color: #fff; font-weight: 600; }
.tri button[data-v="pass"][aria-pressed="true"] { background: var(--fresh); }
.tri button[data-v="fail"][aria-pressed="true"] { background: var(--late); }
.tri button[data-v="na"][aria-pressed="true"] { background: var(--muted); }

/* ------------------------------------------------------------ photo items */

.items { display: grid; gap: 0.9rem; }

.item {
  border: 1px solid var(--rule);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.item[data-carried="1"] { border-left-color: var(--warn); }
.item header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.7rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--rule);
}
.item header .num {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  font-size: var(--step--1);
}
.item header .spacer { flex: 1; }
.item .thumb-wrap { background: #0d141c; display: grid; place-items: center; }
.item img.thumb { width: 100%; max-height: 60vh; object-fit: contain; display: block; }
.item .fields { padding: 0.7rem; display: grid; gap: 0.6rem; }

/* --------------------------------------------- the age meter (signature) */

.age {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.7rem;
  border-top: 1px dashed var(--rule);
  background: var(--surface-2);
}

.age-count {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1;
  color: var(--fresh);
}
.age-count sup { font-size: 0.6rem; letter-spacing: 0.1em; opacity: 0.75; }
.age[data-heat="warn"] .age-count { color: var(--warn); }
.age[data-heat="late"] .age-count { color: var(--late); }

.age-meter {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 1.4rem;
  overflow: hidden;
}
.age-meter i {
  display: block;
  flex: 1 1 2px;
  min-width: 2px;
  max-width: 7px;
  height: 40%;
  background: var(--rule-hard);
  border-radius: 1px;
}
.age-meter i.on { height: 100%; background: var(--fresh); }
.age[data-heat="warn"] .age-meter i.on { background: var(--warn); }
.age[data-heat="late"] .age-meter i.on { background: var(--late); }
.age-note { grid-column: 1 / -1; font-size: 0.6875rem; color: var(--muted); font-family: "IBM Plex Mono", monospace; }

/* ------------------------------------------------------------ carried list */

.carry { border-top: 1px solid var(--rule); padding: 0.7rem 0.9rem; display: grid; gap: 0.4rem; }
.carry:first-child { border-top: 0; }
.carry-top { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.carry-top strong { font-weight: 600; }
.carry-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.carry[data-state="resolved"] { background: #eef6f1; }
.carry[data-state="resolved"] .carry-top strong { text-decoration: line-through; color: var(--muted); }

.tag {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.625rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.15rem 0.35rem;
  border: 1px solid currentColor;
  border-radius: 2px;
  color: var(--muted);
  white-space: nowrap;
}
.tag.hot { color: var(--late); background: var(--late-wash); }
.tag.warm { color: var(--warn); }
.tag.cool { color: var(--fresh); }

/* ------------------------------------------------------------ action bar */

.actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  background: var(--surface);
  border-top: 2px solid var(--ink);
  padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom));
}
.actionbar-inner {
  max-width: 60rem;
  margin: 0 auto;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.actionbar .status { flex: 1; font-size: var(--step--1); color: var(--muted); min-width: 0; }
.actionbar .btn { flex: 0 0 auto; }
@media (max-width: 30rem) { .actionbar .status { display: none; } }

/* ------------------------------------------------------------ annotator */

dialog.editor {
  border: 0;
  padding: 0;
  width: min(100vw, 60rem);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  background: #0d141c;
  color: #fff;
}
dialog.editor::backdrop { background: rgba(13, 20, 28, 0.85); }
.editor-shell { display: grid; grid-template-rows: auto 1fr auto; height: 100%; }
.editor-canvas { display: grid; place-items: center; overflow: hidden; touch-action: none; }
.editor-canvas canvas { max-width: 100%; max-height: 100%; touch-action: none; cursor: crosshair; }
.editor-bar {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.6rem 0.8rem calc(0.6rem + env(safe-area-inset-bottom));
  background: #16202b;
  border-top: 1px solid #2c3c4c;
}
.editor-bar .btn { background: #22303f; border-color: #3a4b5d; color: #fff; }
.editor-bar .btn[aria-pressed="true"] { background: #fff; color: #16202b; border-color: #fff; }
.swatches { display: flex; gap: 0.3rem; margin-left: auto; }
.swatch { width: 2rem; height: 2rem; border-radius: 50%; border: 2px solid #fff6; cursor: pointer; }
.swatch[aria-pressed="true"] { border-color: #fff; box-shadow: 0 0 0 2px #16202b, 0 0 0 4px #fff; }

/* ------------------------------------------------------------ misc */

.empty {
  padding: 1.25rem 0.9rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--rule-hard);
  border-radius: var(--radius);
}
.empty strong { display: block; color: var(--ink); font-size: var(--step-1); }

.stats { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.stat-num { font-size: var(--step-3); line-height: 1; font-weight: 600; }
.stat span { display: block; font-size: 0.625rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 5.5rem;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--ink);
  color: #fff;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  max-width: min(92vw, 32rem);
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.7);
}
.toast[data-kind="error"] { background: var(--late); }
.toast[hidden] { display: none; }

table.reports { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
table.reports th {
  text-align: left;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.625rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--rule-hard);
  padding: 0.4rem 0.5rem;
}
table.reports td { border-bottom: 1px solid var(--rule); padding: 0.55rem 0.5rem; vertical-align: top; }
table.reports tr:hover td { background: var(--surface-2); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
