/* SmartTrap dashboard styles, shared by every signed-in page.
   Same visual world as the website (assets/css/site.css): white and green,
   square corners, hairline dividers, no shadows, Inter Tight with mono labels.
   The dashboard is a working tool, so sizes are fixed rather than fluid and
   transitions stay short. Token values match site.css; change both together. */

:root {
  --color-bg:            #ffffff;
  --color-surface:       #f4f6f1;
  --color-line:          #dde2da;
  --color-rule:          #b9c3b6;
  --color-text:          #141a15;
  --color-muted:         #525c53;
  --color-faint:         #687169;   /* placeholders and disabled text; 5.1:1 on white, 4.6:1 on surface */
  --color-forest:        #1c261d;
  --color-primary:       #1a7a3c;
  --color-primary-hover: #14612f;
  --color-accent:        #2f7a1f;
  --color-accent-light:  #9fd07f;
  --color-warn:          #b45309;   /* a trap that missed its report; 5.0:1 on white */
  --color-error:         #b91c1c;

  /* One color per kind of data, used by swatches, chart lines, and heatmaps alike. */
  --data-beetles:  #f97316;
  --data-temp:     #dc2626;
  --data-humidity: #0284c7;
  --temp-ramp: linear-gradient(90deg, #0000dc, #00c8dc, #fadc00, #dc1414);

  /* Map symbol chips in the key sit on this, so white map strokes stay visible. */
  --color-map-chip: #3f4a35;

  --font-sans: 'Inter Tight', 'Helvetica Now Display', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;

  --header-h: 60px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  accent-color: var(--color-primary);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scrollbar-width: thin; scrollbar-color: var(--color-rule) transparent; }

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  caret-color: var(--color-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
}
/* Map pages fill the window and scroll inside their panels instead. */
body.app-fixed { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }

::selection { background: var(--color-accent-light); color: var(--color-forest); }

h1, h2, h3 { margin: 0; font-weight: 400; line-height: 1.15; letter-spacing: -0.02em; text-wrap: balance; }
p { margin: 0; }
a { color: var(--color-primary); text-underline-offset: 3px; }
a:hover { color: var(--color-primary-hover); }
button, input, select, textarea { font: inherit; letter-spacing: inherit; }

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

.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;
}

/* Small uppercase label that names a value or a group. */
.label {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-muted);
}
.num { font-variant-numeric: tabular-nums; }

/* Square color key for a kind of data. */
.swatch { display: inline-block; width: 9px; height: 9px; flex-shrink: 0; vertical-align: 1px; }
.swatch-beetles  { background: var(--data-beetles); }
.swatch-temp     { background: var(--temp-ramp); }
.swatch-humidity { background: var(--data-humidity); }

/* Estimated battery: an outline with 1-4 bars. The bar count carries the level;
   color backs it up, amber at two bars and red at one. Size it with width/height. */
.batt { display: inline-block; flex-shrink: 0; width: 26px; height: 13px; vertical-align: middle; overflow: visible; }
.batt-body { fill: none; stroke: var(--color-muted); stroke-width: 1.5; }
.batt-tip  { fill: var(--color-muted); }
.batt-slot { fill: #e7ebe4; }
.batt-bar  { fill: var(--color-primary); }
.batt.is-2 .batt-bar { fill: #d97706; }
.batt.is-1 .batt-bar { fill: var(--color-error); }

/* ── HEADER ─────────────────────────────────────────────── */
.app-header {
  flex-shrink: 0; display: flex; align-items: center; gap: 28px;
  height: var(--header-h); padding: 0 24px;
  background: var(--color-bg); border-bottom: 1px solid var(--color-line);
}
.wordmark {
  font-size: 20px; font-weight: 600; letter-spacing: -0.035em; line-height: 1;
  color: var(--color-text); text-decoration: none; white-space: nowrap;
}
.wordmark:hover { color: var(--color-text); }
.wordmark-tech { color: var(--color-accent); }

.app-nav { display: flex; align-items: center; gap: 24px; padding-left: 28px; border-left: 1px solid var(--color-line); height: 24px; }
.app-nav a { color: var(--color-muted); font-size: 15px; text-decoration: none; white-space: nowrap; transition: color 0.15s; }
.app-nav a:hover { color: var(--color-text); }
.app-nav a[aria-current="page"] { color: var(--color-text); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 6px; }

.app-header-end { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.app-status { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-muted); white-space: nowrap; }
/* Development-only link; the dashed edge marks it as not part of the product. */
.dev-link { border-style: dashed; }

/* ── BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border: 1px solid transparent; border-radius: 0;
  font-family: var(--font-mono); font-size: 12px; font-weight: 500; line-height: 1;
  letter-spacing: 0.08em; text-transform: uppercase; text-decoration: none; white-space: nowrap;
  cursor: pointer; transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 11px; }
.btn-lg { min-height: 52px; padding: 0 22px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); color: #fff; }
.btn-outline { background: var(--color-bg); color: var(--color-text); border-color: var(--color-rule); }
.btn-outline:hover { border-color: var(--color-text); color: var(--color-text); }
.btn-outline[aria-pressed="true"] { background: var(--color-text); border-color: var(--color-text); color: #fff; }
.btn-danger { background: var(--color-bg); color: var(--color-error); border-color: #e3b9b9; }
.btn-danger:hover { background: #fdf3f3; border-color: var(--color-error); color: var(--color-error); }
.btn:disabled, .btn[aria-disabled="true"] {
  background: var(--color-surface); border-color: var(--color-line); color: var(--color-faint); cursor: not-allowed;
}

/* Breadcrumb back to the map, in plain sentence case so it reads as navigation. */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; color: var(--color-muted); }
.crumbs a { color: var(--color-muted); text-decoration: underline; text-decoration-color: var(--color-rule); text-underline-offset: 4px; }
.crumbs a:hover { color: var(--color-text); text-decoration-color: currentColor; }
.crumbs [aria-current] { font-family: var(--font-mono); font-size: 13px; color: var(--color-text); }

/* ── STATUS ─────────────────────────────────────────────── */
/* A trap's reporting state. Quiet when it reported; amber when it missed. */
.status { display: inline-flex; align-items: center; gap: 7px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em; color: var(--color-muted); white-space: nowrap; }
/* Round markers, echoing the trap's pin on the map. */
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--color-primary); flex-shrink: 0; }
.status.is-missed { color: var(--color-warn); font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; }
/* Yellow like the pin; the text stays dark amber, since yellow text can't be read on white. */
.status.is-missed::before { background: #facc15; box-shadow: 0 0 0 1px #a16207; }
.status.is-none::before { background: var(--color-rule); }

.warn-note { font-size: 13px; color: var(--color-warn); }
.warn-note::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 8px; background: var(--color-warn); vertical-align: 1px; }

/* ── MAP PAGE LAYOUT ───────────────────────────────────── */
.map-layout { flex: 1; display: grid; grid-template-columns: 380px minmax(0, 1fr); min-height: 0; }
/* Three layers, from back to front: pale sage list, deeper sage overview, white cards. */
.sidebar { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; border-right: 1px solid var(--color-line); background: var(--color-surface); }
.map-area { position: relative; min-width: 0; min-height: 0; }
.map-area #map-view { position: absolute; inset: 0; }

/* ── SUMMARY ────────────────────────────────────────────── */
/* The orchard overview: a filled sage block, so it reads apart from the white trap cards. */
.summary { --summary-line: #c5d0c1; margin: 12px 12px 0; padding: 18px 18px 16px; background: #e7eee2; border: 1px solid var(--summary-line); }
.summary-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.summary-place { color: var(--color-text); }
.summary-rover { margin: -8px 0 16px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em; color: var(--color-muted); }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--summary-line, var(--color-line)); }
.stat { padding: 14px 0 12px; border-bottom: 1px solid var(--summary-line, var(--color-line)); }
.stat:nth-child(2n) { padding-left: 16px; border-left: 1px solid var(--summary-line, var(--color-line)); }
.stat:nth-last-child(-n + 2) { border-bottom: 0; padding-bottom: 2px; }
.stat-value { font-size: 26px; line-height: 1.1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-value small { margin-left: 3px; font-size: 14px; color: var(--color-muted); letter-spacing: 0; }
.stat .label { display: flex; align-items: center; gap: 7px; margin-top: 6px; }

/* ── TRAP LIST + CARDS ─────────────────────────────────── */
.list-head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; margin-top: 8px; padding: 12px 20px; background: var(--color-surface); border-bottom: 1px solid var(--color-line); }
.trap-list { display: flex; flex-direction: column; gap: 10px; padding: 12px 12px 20px; }

/* White cards with a heavier, darker edge, so each trap reads as its own object on the sage list. */
.trap-card {
  display: block; padding: 14px 16px 12px; background: var(--color-bg);
  border: 2px solid #a3ada1; color: inherit; text-decoration: none;
  transition: border-color 0.15s, background-color 0.15s;
}
.trap-card:hover, .trap-card.is-hot { border-color: var(--color-primary); background: #fafcf9; color: inherit; }
.trap-card-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.trap-id { font-family: var(--font-mono); font-size: 13px; font-weight: 500; color: var(--color-text); }
.trap-card-sub { margin-top: 2px; text-align: right; font-family: var(--font-mono); font-size: 11px; color: var(--color-muted); }
.trap-card-main { display: grid; grid-template-columns: 1.1fr 1fr 1fr; gap: 12px; align-items: end; margin-top: 12px; }
.reading-value { font-size: 20px; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.reading-value small { margin-left: 2px; font-size: 12px; color: var(--color-muted); letter-spacing: 0; }
.reading-lead .reading-value { font-size: 32px; }
.reading .label { display: flex; align-items: center; gap: 6px; margin-top: 7px; font-size: 10px; }
.trap-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--color-line); font-family: var(--font-mono); font-size: 11px; color: var(--color-muted); }
.trap-card-power { display: flex; align-items: center; gap: 10px; }
.trap-card-foot .open { flex-shrink: 0; color: var(--color-rule); transition: color 0.15s, transform 0.2s var(--ease-out); }
.trap-card:hover .open, .trap-card.is-hot .open, .trap-card:focus-visible .open { color: var(--color-primary); transform: translateX(2px); }
.trap-card .warn-note { margin-top: 10px; font-size: 12px; }

/* Placeholder cards while traps load. */
.trap-card.is-skeleton { pointer-events: none; }
.skeleton-bar { display: block; height: 10px; background: var(--color-surface); }
.skeleton-bar + .skeleton-bar { margin-top: 10px; }
@media (prefers-reduced-motion: no-preference) {
  .skeleton-bar { animation: skeleton 1.4s ease-in-out infinite; }
  @keyframes skeleton { 50% { opacity: 0.45; } }
}

.list-message { padding: 20px; color: var(--color-muted); font-size: 14px; }
.list-message a { font-weight: 500; }
.list-message.is-error { color: var(--color-error); }

/* ── FLOATING MAP PANELS ───────────────────────────────── */
.map-panel { position: absolute; z-index: 1000; background: var(--color-bg); border: 1px solid var(--color-rule); }

.map-notice {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1000;
  max-width: calc(100% - 120px); padding: 9px 14px; background: var(--color-bg); border: 1px solid var(--color-rule);
  font-size: 13px; color: var(--color-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.map-notice::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 9px; background: var(--color-warn); vertical-align: 1px; }

/* Heatmap switch with its scale directly beneath it. */
.heat-panel { left: 16px; bottom: 28px; width: 352px; padding: 14px 16px 16px; }
.heat-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.heat-readout { font-family: var(--font-mono); font-size: 12px; color: var(--color-text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.heat-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.heat-buttons .btn { min-height: 36px; padding: 0 8px; gap: 7px; font-size: 11px; }
.heat-buttons .btn + .btn { margin-left: -1px; }
.heat-buttons .btn[aria-pressed="true"] { position: relative; z-index: 1; }
.heat-hint { margin-top: 12px; font-size: 13px; color: var(--color-muted); }
.heat-scale { margin-top: 14px; }
.heat-title { font-size: 15px; font-weight: 500; letter-spacing: -0.01em; margin-bottom: 9px; }
.heat-bar { position: relative; height: 16px; }
.heat-bar canvas { display: block; width: 100%; height: 16px; }
/* Where the value under the cursor falls on the scale. */
.heat-marker {
  position: absolute; top: -5px; width: 3px; height: 26px; margin-left: -1.5px;
  background: var(--color-text); outline: 1px solid #fff; pointer-events: none;
}
.heat-ticks { display: flex; justify-content: space-between; margin-top: 7px; font-family: var(--font-mono); font-size: 12px; color: var(--color-muted); font-variant-numeric: tabular-nums; }

/* Map key: what each symbol on the map means. */
.key { right: 12px; bottom: 28px; min-width: 0; border: 0; background: transparent; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.key-body { padding: 12px 14px; background: var(--color-bg); border: 1px solid var(--color-rule); }
.key-body ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 9px; }
.key-body li { display: flex; align-items: center; gap: 10px; font-size: 14px; white-space: nowrap; }
.key-toggle { min-height: 32px; }
.key-chip { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 22px; flex-shrink: 0; background: var(--color-map-chip); }
.key-chip .pin { position: static; transform: none; width: 17px; height: 17px; border-width: 1.5px; font-size: 9px; }
.key-chip .rover-mark { position: static; width: 9px; height: 9px; margin: 0; transform: rotate(45deg); }
.key-route { width: 22px; height: 0; border-top: 2px dashed #fff; }
.key-range { width: 16px; height: 16px; border: 1.5px dashed rgba(255, 255, 255, 0.9); border-radius: 50%; background: rgba(255, 255, 255, 0.12); }
.key-boundary { width: 22px; height: 3px; background: #ffc72c; }
.key-radius { width: 16px; height: 16px; border: 1.5px dashed rgba(255, 255, 255, 0.75); border-radius: 50%; }

/* ── MAP SYMBOLS (Leaflet divIcons) ────────────────────── */
.map-anchor { width: 0 !important; height: 0 !important; background: none; border: 0; }
/* Trap pins: red circles, the shape growers know from the first dashboard. Yellow
   means the trap missed the rover's last pass. The soft shadow lifts a pin off the
   imagery; map symbols are the one place the dashboard uses a shadow. */
.pin {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%);
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: #dc2626; border: 2px solid #fff; color: #fff;
  box-shadow: 0 0 0 1px #dc2626, 0 2px 6px rgba(0, 0, 0, 0.3);
  font-family: var(--font-sans); font-size: 12px; font-weight: 600; line-height: 1;
  font-variant-numeric: tabular-nums; white-space: nowrap;
  transition: transform 0.15s var(--ease-out), outline-color 0.15s;
  outline: 2px solid transparent; outline-offset: 2px;
}
.pin.is-missed { background: #facc15; color: #1c261d; box-shadow: 0 0 0 1px #ca8a04, 0 2px 6px rgba(0, 0, 0, 0.3); }
/* While a heatmap is on, a pin becomes a round chip showing its own value, filled
   with that value's scale color (set inline). It grows to fit "56.3°". */
.pin.is-value {
  width: auto; height: auto; min-width: 32px; aspect-ratio: 1; padding: 0 5px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
}
.pin.is-value.is-missed { border-color: #facc15; box-shadow: 0 0 0 1px #ca8a04, 0 2px 6px rgba(0, 0, 0, 0.3); }
.pin.is-hot { transform: translate(-50%, -50%) scale(1.15); outline-color: var(--color-primary); z-index: 2; }
/* Leaflet makes markers keyboard-focusable; the ring goes on the visible symbol. */
.map-anchor:focus-visible { outline: none; }
.map-anchor:focus-visible .pin, .map-anchor:focus-visible .rover-mark { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.rover-mark {
  position: absolute; left: 0; top: 0; width: 14px; height: 14px; margin: -7px 0 0 -7px;
  background: var(--color-forest); border: 2px solid #fff; transform: rotate(45deg);
}
.rover-mark.is-past { width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-width: 1.5px; opacity: 0.6; }
.radius-label { position: absolute; transform: translate(-50%, -50%); font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: #fff; white-space: nowrap; text-shadow: 0 0 3px rgba(0, 0, 0, 0.9); }

/* ── LEAFLET, RESTYLED ─────────────────────────────────── */
.leaflet-container { font-family: var(--font-sans); background: var(--color-map-chip); }
.leaflet-bar, .leaflet-touch .leaflet-bar { border: 1px solid var(--color-rule); border-radius: 0; box-shadow: none; }
.leaflet-bar a, .leaflet-touch .leaflet-bar a {
  width: 34px; height: 34px; line-height: 32px; border-radius: 0 !important;
  border-bottom-color: var(--color-line); color: var(--color-text); font: 400 18px/32px var(--font-sans);
}
.leaflet-bar a:hover { background: var(--color-surface); color: var(--color-text); }
.leaflet-popup-content-wrapper { border-radius: 0; box-shadow: none; border: 1px solid var(--color-rule); padding: 0; }
.leaflet-popup-tip { box-shadow: none; border: 1px solid var(--color-rule); }
.leaflet-popup-content { margin: 14px 16px; font-size: 14px; line-height: 1.45; min-width: 170px; }
.leaflet-container a.leaflet-popup-close-button { width: 28px; height: 28px; font: 400 18px/26px var(--font-sans); color: var(--color-muted); }
.leaflet-control-attribution { font-size: 10px; background: rgba(255, 255, 255, 0.85) !important; }

.pop-title { font-family: var(--font-mono); font-size: 13px; font-weight: 500; }
.pop-status { margin-top: 3px; }
.pop dl { display: grid; grid-template-columns: auto auto; gap: 3px 14px; margin: 10px 0 0; font-variant-numeric: tabular-nums; }
.pop dt { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-muted); align-self: center; }
.pop dd { margin: 0; text-align: right; }
.pop-link { display: inline-block; margin-top: 12px; font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; text-decoration: none; }

/* ── PHONE MAP VIEW ────────────────────────────────────── */
.tab-bar { flex-shrink: 0; display: grid; grid-template-columns: 1fr 1fr; background: var(--color-bg); border-bottom: 1px solid var(--color-line); }
.tab-bar button {
  min-height: 46px; border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer;
  font-family: var(--font-mono); font-size: 12px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-muted);
}
.tab-bar button[aria-selected="true"] { color: var(--color-text); border-bottom-color: var(--color-primary); }
.phone-panel { flex: 1; min-height: 0; position: relative; }
.phone-panel.is-scroll { overflow-y: auto; background: var(--color-surface); }
.phone-panel #map-view { position: absolute; inset: 0; }
.phone-footer { padding: 4px 20px 28px; }
.phone-footer .btn + .btn { margin-top: 8px; }

/* ── CONTENT PAGES (trap detail, add a trap) ───────────── */
.page { width: 100%; max-width: 1240px; margin: 0 auto; padding: 28px 24px 64px; }
.page-narrow { max-width: 560px; }
.page-title { margin-top: 18px; font-size: 40px; letter-spacing: -0.035em; }
.page-title.is-mono { font-family: var(--font-mono); font-size: 34px; font-weight: 500; letter-spacing: -0.02em; }
.page-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-top: 10px; font-size: 14px; color: var(--color-muted); }
.page-meta.is-detail { margin-top: 16px; gap: 10px 20px; }

/* When the trap last reported, filled like its map pin so it reads at a glance. */
.report-box { display: flex; flex-direction: column; gap: 2px; padding: 10px 18px 11px; background: var(--color-primary); color: #fff; }
.report-label { font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(255, 255, 255, 0.9); }
.report-when { font-size: 24px; font-weight: 500; line-height: 1.2; letter-spacing: -0.015em; }
.report-box.is-missed { background: #facc15; color: var(--color-forest); }
.report-box.is-missed .report-label { color: var(--color-forest); }
.report-box.is-none { background: var(--color-surface); color: var(--color-muted); box-shadow: inset 0 0 0 1px var(--color-line); }
.report-box.is-none .report-label { color: var(--color-muted); }
.page-lead { margin-top: 10px; font-size: 16px; color: var(--color-muted); }
.section-title { font-size: 22px; letter-spacing: -0.02em; }
.loading-line { padding: 48px 0; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-muted); }

/* Four headline readings with hairline dividers, like the website's feature columns. */
.readings { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 28px; border-top: 1px solid var(--color-text); border-bottom: 1px solid var(--color-line); }
.readings > div { padding: 18px 20px 18px 0; }
.readings > div + div { padding-left: 20px; border-left: 1px solid var(--color-line); }
.readings .label { display: flex; align-items: center; gap: 7px; }
.readings .stat-value { margin-top: 10px; font-size: 34px; }
.readings .stat-battery { display: flex; align-items: center; gap: 12px; min-height: 37px; }
.readings .stat-battery .batt { width: 48px; height: 24px; }
.readings .stat-battery small { margin: 0; font-size: 18px; color: var(--color-text); letter-spacing: -0.01em; }
.readings .sub { margin-top: 6px; font-family: var(--font-mono); font-size: 11px; color: var(--color-muted); font-variant-numeric: tabular-nums; }

.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.chart-card { padding: 18px 18px 14px; border: 1px solid var(--color-line); background: var(--color-bg); min-width: 0; }
/* Beetles are what the trap is for, so their chart takes the full row. */
.chart-card.is-wide { grid-column: 1 / -1; }
.chart-card.is-wide .chart-wrap { height: 280px; }
.chart-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; min-height: 32px; margin-bottom: 12px; }
.chart-title { display: flex; align-items: center; gap: 9px; font-size: 17px; font-weight: 500; letter-spacing: -0.01em; }
.chart-title .unit { font-weight: 400; color: var(--color-muted); }
.chart-tools { display: flex; align-items: center; gap: 14px; }
.chart-stats { font-family: var(--font-mono); font-size: 11px; color: var(--color-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.chart-wrap { position: relative; height: 240px; }
.charts-hint { margin-top: 12px; font-size: 13px; color: var(--color-muted); }

.manage { margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--color-text); }
.manage-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; margin-top: 22px; }
.manage h3 { font-size: 17px; font-weight: 500; }
.manage-note { margin-top: 6px; font-size: 14px; color: var(--color-muted); max-width: 60ch; }
.danger-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 16px 0; border-bottom: 1px solid var(--color-line); }
.danger-row:first-of-type { border-top: 1px solid var(--color-line); margin-top: 14px; }

/* ── FORMS ─────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 7px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; margin-top: 16px; }
.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--color-rule); border-radius: 0;
  background: var(--color-bg); color: var(--color-text); font-family: var(--font-mono); font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: var(--color-faint); opacity: 1; }
.input:hover { border-color: var(--color-muted); }
.input:focus { outline: none; border-color: var(--color-text); box-shadow: inset 0 0 0 1px var(--color-text); }
.input.is-invalid { border-color: var(--color-error); box-shadow: inset 0 0 0 1px var(--color-error); }
.input:disabled { background: var(--color-surface); color: var(--color-faint); }
.form-status { min-height: 20px; margin-top: 10px; font-size: 14px; color: var(--color-muted); }
.form-status.is-success { color: var(--color-primary); }
.form-status.is-error { color: var(--color-error); }
.hint { margin-top: 10px; font-size: 13px; color: var(--color-muted); }

/* ── ORCHARD SETUP ─────────────────────────────────────── */
.toolbar { flex-shrink: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 10px 24px; border-bottom: 1px solid var(--color-line); background: var(--color-bg); }
.toolbar .label { margin-right: 2px; }
.toolbar-divider { width: 1px; height: 24px; background: var(--color-line); margin: 0 6px; }
.toolbar-status { font-size: 14px; color: var(--color-muted); }
.toolbar-status.is-success { color: var(--color-primary); }
.toolbar-status.is-error { color: var(--color-error); }
.toolbar-end { margin-left: auto; }

/* ── TRAP LAYOUT ───────────────────────────────────────── */
/* A planned point isn't installed yet, so it reads as hollow and dashed against
   the solid red pins of traps that actually exist. */
.pin.is-plan {
  background: rgba(255, 255, 255, 0.94); border: 2px dashed var(--color-forest);
  color: var(--color-forest); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
/* Square, like the rest of the site's corners, so a repeater reads as a different
   kind of device rather than a differently coloured trap. */
.pin.is-plan.is-repeater { border-radius: 0; background: var(--color-accent-light); }
.pin.is-plan.is-done { border-style: solid; opacity: 0.45; }
.key-chip .pin.is-plan { border-width: 1.5px; }
.key-drift { width: 22px; height: 0; border-top: 2px dotted #fff; }

/* The grower's chosen centre point: a crosshair, so it reads as a reference mark
   rather than another trap. */
.centre-mark {
  position: absolute; left: 0; top: 0; width: 26px; height: 26px; margin: -13px 0 0 -13px;
  border: 2px solid #fff; border-radius: 50%; background: rgba(28, 38, 29, 0.35);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}
.centre-mark::before, .centre-mark::after {
  content: ""; position: absolute; background: #fff;
}
.centre-mark::before { left: 50%; top: 4px; bottom: 4px; width: 2px; margin-left: -1px; }
.centre-mark::after  { top: 50%; left: 4px; right: 4px; height: 2px; margin-top: -1px; }
.key-centre { width: 16px; height: 16px; border: 1.5px solid #fff; border-radius: 50%; }

/* A read-only value sitting in an .id-row beside its button. */
.readout {
  display: flex; align-items: center; min-height: 38px;
  background: var(--color-surface); color: var(--color-muted); font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Where a trap actually went in, against where it was planned. */
.drift-mark {
  position: absolute; left: 0; top: 0; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px;
  border-radius: 50%; background: #dc2626; border: 1.5px solid #fff;
}

.layout-controls { padding: 16px 12px 4px; display: grid; gap: 14px; }
.layout-controls .field-row { grid-template-columns: 1fr 1fr; margin-top: 0; }
.layout-controls .input { min-height: 38px; }
.layout-check { display: flex; align-items: center; gap: 9px; font-size: 14px; }
.layout-check input { width: 16px; height: 16px; }

/* Segmented control, same construction as .heat-buttons. */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.seg .btn { min-height: 34px; padding: 0 8px; font-size: 10px; }
.seg .btn + .btn { margin-left: -1px; }
.seg .btn[aria-pressed="true"] { position: relative; z-index: 1; }

.plan-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.plan-actions .btn { min-height: 30px; padding: 0 10px; font-size: 10px; }
.plan-coords { margin-top: 10px; font-family: var(--font-mono); font-size: 12px; color: var(--color-muted); font-variant-numeric: tabular-nums; }
.role-chip {
  font-family: var(--font-mono); font-size: 10px; font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--color-muted); padding: 2px 7px; border: 1px solid var(--color-line);
}
.role-chip.is-repeater { color: var(--color-accent); border-color: var(--color-accent-light); background: #f2f8ec; }
.trap-card.is-done { opacity: 0.62; }
.drift-note { margin-top: 8px; font-family: var(--font-mono); font-size: 11px; color: var(--color-muted); }

.layout-empty { padding: 28px 20px; }
.layout-empty p { margin-top: 8px; color: var(--color-muted); font-size: 14px; }
.layout-empty .btn { margin-top: 16px; }
.export-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 12px 24px; }
.export-row .btn { flex: 1 1 auto; }

/* ── ADD A TRAP ────────────────────────────────────────── */
.step { margin-top: 24px; padding: 20px; border: 1px solid var(--color-line); }
.step-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.gps-state { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.gps-mark { width: 10px; height: 10px; margin-top: 7px; flex-shrink: 0; background: var(--color-rule); }
.gps-mark.is-loading { background: var(--color-muted); }
.gps-mark.is-success { background: var(--color-primary); }
.gps-mark.is-error { background: var(--color-error); }
@media (prefers-reduced-motion: no-preference) {
  .gps-mark.is-loading { animation: skeleton 1s ease-in-out infinite; }
}
.gps-main { font-family: var(--font-mono); font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; }
.gps-sub { margin-top: 2px; font-size: 14px; color: var(--color-muted); }
.accuracy { margin-bottom: 16px; }
.accuracy-head { display: flex; justify-content: space-between; margin-bottom: 6px; }
.accuracy-bar { height: 6px; background: var(--color-surface); }
.accuracy-fill { height: 100%; transform: scaleX(0); transform-origin: left; transition: transform 0.25s var(--ease-out); }
.id-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.id-row .input { min-height: 48px; font-size: 16px; }
.id-row .btn { min-height: 48px; }
.hint.is-error { color: var(--color-error); }
.submit { margin-top: 24px; }

.result { margin-top: 20px; padding: 18px 20px; border: 1px solid var(--color-line); }
.result-title { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 500; }
.result-title::before { content: ""; width: 8px; height: 8px; flex-shrink: 0; background: var(--color-muted); }
.result.is-success { border-color: #b7d8c1; }
.result.is-success .result-title::before { background: var(--color-primary); }
.result.is-error { border-color: #e3b9b9; }
.result.is-error .result-title::before { background: var(--color-error); }
.result-body { margin-top: 8px; font-size: 14px; color: var(--color-muted); }
.result-body strong { color: var(--color-text); font-weight: 500; font-family: var(--font-mono); }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.how { margin-top: 32px; padding-top: 18px; border-top: 1px solid var(--color-line); }
.how ol { margin: 10px 0 0; padding-left: 18px; font-size: 14px; color: var(--color-muted); }
.how li + li { margin-top: 4px; }

.spinner { width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff; border-radius: 50%; }
@media (prefers-reduced-motion: no-preference) {
  .spinner { animation: spin 0.7s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
}

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 1100px) {
  .map-layout { grid-template-columns: 330px minmax(0, 1fr); }
  .app-status { display: none; }
  .charts { grid-template-columns: 1fr; }
}

/* Narrow windows on the desktop page: map on top, list below. */
@media (max-width: 820px) {
  body.app-fixed.is-desktop-map { height: auto; overflow: visible; }
  .map-layout { grid-template-columns: 1fr; }
  .map-area { order: -1; height: 62vh; }
  .sidebar { border-right: 0; overflow: visible; }
  .heat-panel { width: auto; right: 16px; }
  .readings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .readings > div:nth-child(3) { padding-left: 0; border-left: 0; }
  .readings > div:nth-child(n + 3) { border-top: 1px solid var(--color-line); }
  .manage-grid { grid-template-columns: 1fr; gap: 32px; }
}

@media (max-width: 640px) {
  .app-header { flex-wrap: wrap; height: auto; gap: 0; padding: 0 16px; }
  .app-header > .wordmark { height: 56px; display: inline-flex; align-items: center; }
  .app-nav { order: 3; width: 100%; height: 44px; padding: 0; border-left: 0; border-top: 1px solid var(--color-line); gap: 20px; overflow-x: auto; }
  .app-header.is-compact { flex-wrap: nowrap; }
  .page { padding: 20px 16px 48px; }
  .page-title { font-size: 32px; }
  .page-title.is-mono { font-size: 26px; }
  .field-row { grid-template-columns: 1fr 1fr; }
  .field-row .btn { grid-column: 1 / -1; }
  .danger-row { flex-direction: column; align-items: flex-start; gap: 10px; }
  .toolbar { padding: 10px 16px; }
  .toolbar-divider { display: none; }
  .toolbar-end { margin-left: 0; }
}

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