/* ==========================================================================
   BondMnE - application stylesheet

   Designed for a phone held in one hand on a construction site: large tap
   targets, high contrast, and a dark theme that survives direct sunlight
   glare as well as a dim plant room.
   ========================================================================== */

:root {
  --navy: #1f3864;
  --navy-600: #2c4a80;
  --accent: #0f8a5f;
  --accent-600: #0b6e4b;
  --danger: #c0392b;
  --warn: #b26a00;

  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --border: #d5dbe4;
  --text: #14181f;
  --text-muted: #5b6675;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 12px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 8px 32px rgba(16, 24, 40, 0.18);

  --tap: 44px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10131a;
    --surface: #191d26;
    --surface-2: #222834;
    --border: #333b4a;
    --text: #e8ecf3;
    --text-muted: #9aa5b6;
    --navy: #3b5fa4;
    --navy-600: #4a72bd;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

h1, h2, h3 { margin: 0 0 0.4em; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
p { margin: 0 0 0.8em; }
a { color: var(--navy); }

.muted { color: var(--text-muted); font-size: 0.875rem; }
.grow { flex: 1 1 auto; min-width: 0; }
.shrink { flex: 0 0 auto; }

/* --------------------------------------------------------------------------
   layout primitives
   -------------------------------------------------------------------------- */
.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.row { display: flex; align-items: center; gap: 0.5rem; }
.row--end { justify-content: flex-end; }
.row--between { justify-content: space-between; }
.row.wrap, .wrap { flex-wrap: wrap; }
.gap { gap: 0.5rem; }

.boot {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--text-muted);
}

.shell { min-height: 100vh; display: flex; flex-direction: column; }

/* --------------------------------------------------------------------------
   top bar
   -------------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  padding-top: calc(0.5rem + env(safe-area-inset-top));
  background: var(--navy);
  color: #fff;
  box-shadow: var(--shadow);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.topbar__mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 0.8rem;
  font-weight: 800;
}

/* The Bond M & E lockup is blue artwork on transparency and would disappear
   into the navy bar, so it gets a white chip to sit on. Height is fixed and
   width follows the artwork's 4.5:1 ratio via `width: auto`. */
.topbar__wordmark {
  display: block;
  height: 40px;          /* bond-logo-header.png is 7.1:1, so this puts the
                            wording at ~17px cap height */
  width: auto;
  padding: 5px 11px;
  border-radius: 8px;
  background: #fff;
}

.topbar__nav { display: flex; gap: 0.25rem; margin-left: auto; }
.topbar__link {
  position: relative;
  /* inline-flex, not inline: the pending badge is a block-level box, and on the
     text baseline it dragged this link's label ~3px below its neighbours. */
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
}
.topbar__link:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.topbar__link.is-active { background: rgba(255, 255, 255, 0.18); color: #fff; }

/* Count of changes still waiting to upload. Hidden when there are none. */
.badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  margin-left: 0.35rem;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--warn);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
}
/* The UA rule `[hidden] { display: none }` has the same specificity as `.badge`
   and loses to it, so `el.hidden = true` left an empty amber circle showing.
   Any class that sets `display` needs this companion rule. */
.badge[hidden] { display: none; }

.topbar__status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa5b6; flex: none; }
.status-dot--ok { background: #2ecc71; }
.status-dot--pending { background: #f39c12; }
.status-dot--syncing { background: #3498db; animation: pulse 1.1s ease-in-out infinite; }
.status-dot--offline { background: #e74c3c; }
@keyframes pulse { 50% { opacity: 0.25; } }

.topbar__user {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* The top bar is the one row that cannot wrap, so every item in it must be
   able to shrink. Without this the bar measured 488px inside a 360px phone
   viewport and the whole page scrolled sideways with dead space at the right. */
.topbar > * { min-width: 0; }
.topbar__brand { flex: 0 1 auto; overflow: hidden; }
.topbar__nav { flex: 0 1 auto; min-width: 0; overflow: hidden; }
.topbar__install-icon { display: none; }

@media (max-width: 560px) {
  .topbar { gap: 0.4rem; padding-left: 0.5rem; padding-right: 0.5rem; }
  .topbar__wordmark { display: none; }          /* the Cx mark carries the brand */
  .topbar__link { padding: 0.45rem 0.4rem; font-size: 0.82rem; }
  .topbar__status { padding: 0.35rem 0.45rem; }
  .topbar__status .status-text { display: none; }
  .topbar__user { width: 30px; height: 30px; font-size: 0.85rem; }
  .topbar__install-label { display: none; }     /* icon-only install button */
  .topbar__install-icon { display: inline; }
  .topbar__install { padding: 0.4rem 0.6rem; }
}

@media (max-width: 380px) {
  .topbar__link { padding: 0.4rem 0.3rem; font-size: 0.78rem; }
}

/* Belt and braces: nothing should ever scroll the page sideways. `clip` rather
   than `hidden` because `hidden` would turn body into a scroll container and
   break the sticky top bar. */
html, body { max-width: 100%; overflow-x: clip; }

/* --------------------------------------------------------------------------
   view
   -------------------------------------------------------------------------- */
.view {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 0.9rem calc(3rem + env(safe-area-inset-bottom));
}

.view__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.view__head--stack { align-items: flex-start; }
.view__title { margin: 0; }
.view__sub { margin: 0.15rem 0 0; color: var(--text-muted); font-size: 0.9rem; }

.view__actions {
  position: sticky;
  bottom: 0;
  display: none;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding: 0.6rem 0 calc(0.6rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
@media (max-width: 720px) {
  .view__actions { display: flex; }
  /* Hide ONLY the header buttons the sticky bar restates, marked `is-dup`.
     Two rules here, learned the hard way:
       - never hide by variant (.btn--primary) — that also strips
         "+ New inspection" and "Generate new" from screens with no bottom bar;
       - never put a control ONLY in .view__actions — it vanishes above 720px. */
  .view__head--sticky-dup .is-dup { display: none; }
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.crumbs a { color: var(--text-muted); text-decoration: none; }
.crumbs a:hover { color: var(--navy); text-decoration: underline; }

/* --------------------------------------------------------------------------
   buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--tap);
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--navy-600); }
.btn--accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--accent:hover:not(:disabled) { background: var(--accent-600); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover:not(:disabled) { filter: brightness(1.08); }
.btn--block { width: 100%; flex: 1; }
.btn--sm { min-height: 34px; padding: 0.3rem 0.65rem; font-size: 0.85rem; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.link-btn {
  border: 0;
  background: none;
  padding: 0.25rem 0;
  color: var(--navy);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }
.link-btn--danger { color: var(--danger); }

/* --------------------------------------------------------------------------
   forms
   -------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 0.75rem; }
.field__label { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); }
.field__hint { font-size: 0.78rem; color: var(--text-muted); }

input[type='text'], input[type='password'], input[type='email'], input[type='date'],
input[type='number'], input:not([type]), select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem; /* 16px stops iOS zooming on focus */
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--navy);
  outline-offset: 1px;
  border-color: var(--navy);
}
input[type='file'] { padding: 0.4rem; font-size: 0.9rem; }

.combo { display: block; }

/* Category / level filters above an asset-tag input.
   They sit on one row and wrap on a narrow screen rather than squeezing the
   selects below a usable width. */
.combo--filtered { display: flex; flex-direction: column; gap: 0.3rem; }
.combo__filters {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.combo__filter {
  width: auto;
  flex: 1 1 8rem;
  min-width: 0;                 /* a flex item will not shrink below its content without this */
  min-height: 2.1rem;           /* secondary to the input below it, so below --tap on purpose */
  padding: 0.2rem 1.4rem 0.2rem 0.5rem;
  font-size: 0.82rem;
}
.combo__count {
  flex: 0 0 auto;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--tap);
  font-size: 0.95rem;
  cursor: pointer;
}
.check input { width: 20px; height: 20px; min-height: 0; flex: none; }

.details { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.5rem 0.75rem; background: var(--surface); }
.details summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; color: var(--text-muted); }
.details[open] summary { margin-bottom: 0.6rem; }

.form-error {
  margin: 0 0 0.6rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  background: rgba(192, 57, 43, 0.1);
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 500;
}

/* segmented Pass / Fail / N/A control */
.seg { display: flex; gap: 0.4rem; }
.seg__opt {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}
.seg__opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg__opt:has(input:checked) { color: #fff; }
.seg__opt--pass:has(input:checked) { background: var(--accent); border-color: var(--accent); }
.seg__opt--fail:has(input:checked) { background: var(--danger); border-color: var(--danger); }
.seg__opt--na:has(input:checked) { background: var(--text-muted); border-color: var(--text-muted); }

/* --------------------------------------------------------------------------
   cards and lists
   -------------------------------------------------------------------------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.card--action:hover { border-color: var(--navy); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.card__code { font-size: 1.15rem; font-weight: 800; color: var(--navy); }
.card__title { font-weight: 600; }
.card__meta { font-size: 0.85rem; color: var(--text-muted); }
.card__stats { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.35rem; font-size: 0.82rem; color: var(--text-muted); }

.row-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  flex-wrap: wrap;
}
.row-card--static { cursor: default; }
.row-card:not(.row-card--static):hover { border-color: var(--navy); }
.row-card.is-muted { opacity: 0.6; }
.row-card__main { flex: 1 1 260px; min-width: 0; }
.row-card__title { font-weight: 700; margin-bottom: 0.15rem; word-break: break-word; }
.row-card__meta { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; font-size: 0.83rem; color: var(--text-muted); }
.row-card__side { display: flex; align-items: center; gap: 0.4rem; flex: none; }

.count { font-size: 1.35rem; font-weight: 800; line-height: 1; }
.count__label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* --------------------------------------------------------------------------
   pills, chips, dots
   -------------------------------------------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
/* One hue per test family, shared by its cable and busway variants: a glance
   at a list should say what was tested, and the report type spells out which. */
.pill--continuity,
.pill--continuity_busway { background: rgba(52, 152, 219, 0.16); color: #1f6fa5; }
.pill--insulation,
.pill--insulation_busway { background: rgba(155, 89, 182, 0.16); color: #7d3c98; }
.pill--contact_resistance_busway { background: rgba(26, 188, 156, 0.18); color: #10745f; }
.pill--torque     { background: rgba(230, 126, 34, 0.16); color: #a05a12; }
.pill--earth_loop { background: rgba(52, 73, 94, 0.16); color: #3d566e; }
.pill--phase_rotation { background: rgba(233, 30, 99, 0.14); color: #a3145a; }
.pill--voltage    { background: rgba(241, 196, 15, 0.22); color: #8a6d0b; }
.pill--admin      { background: rgba(31, 56, 100, 0.14); color: var(--navy); }
.pill--user       { background: rgba(15, 138, 95, 0.14); color: var(--accent-600); }
.pill--draft      { background: rgba(243, 156, 18, 0.16); color: #a06a04; }
.pill--completed  { background: rgba(52, 152, 219, 0.16); color: #1f6fa5; }
.pill--reported   { background: rgba(15, 138, 95, 0.16); color: var(--accent-600); }
.pill--ok         { background: rgba(15, 138, 95, 0.16); color: var(--accent-600); }
.pill--muted      { background: var(--surface-2); color: var(--text-muted); }

@media (prefers-color-scheme: dark) {
  .pill--continuity, .pill--continuity_busway { color: #7cc2ec; }
  .pill--insulation, .pill--insulation_busway { color: #c9a0dd; }
  .pill--contact_resistance_busway { color: #63d6bd; }
  .pill--torque     { color: #f0a75a; }
  .pill--earth_loop { color: #a4b6c8; }
  .pill--phase_rotation { color: #f28bb4; }
  .pill--voltage    { color: #ecd06a; }
  .pill--admin      { color: #8aa8dd; }
  .pill--user, .pill--reported, .pill--ok { color: #5fd3a6; }
  .pill--draft      { color: #f5c26b; }
  .pill--completed  { color: #7cc2ec; }
}

.chips { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip {
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.chip:hover { border-color: var(--navy); color: var(--text); }
.chip.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }

.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.dot--pending { background: var(--warn); }

/* --------------------------------------------------------------------------
   photo grid (capture screen)
   -------------------------------------------------------------------------- */
.summary {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.summary__stat {
  flex: 1 1 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.summary__stat b { font-size: 1.25rem; line-height: 1.1; }
.summary__stat span { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.summary__stat--warn { border-color: var(--warn); color: var(--warn); }
.summary__stat--ok { border-color: var(--accent); color: var(--accent-600); }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
}

.photo-cell {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.photo-cell--fail { border-color: var(--danger); }

.photo-cell__no {
  padding: 0.4rem 0.6rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
}

.photo-cell__img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: #0d0f13;
  cursor: pointer;
  overflow: hidden;
}
.photo-cell__img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.photo-cell__placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: #7c8798;
  font-size: 0.82rem;
}

.photo-cell__facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.1rem 0.5rem;
  margin: 0;
  padding: 0.5rem 0.6rem;
  font-size: 0.82rem;
}
.photo-cell__facts dt { color: var(--text-muted); }
.photo-cell__facts dd { margin: 0; font-weight: 600; word-break: break-word; }

.result--pass { color: var(--accent-600); }
.result--fail { color: var(--danger); }
.result--na { color: var(--text-muted); }
@media (prefers-color-scheme: dark) { .result--pass { color: #5fd3a6; } }

.photo-cell__foot {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: auto;
  padding: 0.35rem 0.6rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.photo-cell__foot .link-btn:last-child { margin-left: auto; }

.photo-preview {
  display: grid;
  place-items: center;
  width: 100%;
  max-height: 42vh;
  aspect-ratio: 4 / 3;
  margin-bottom: 0.75rem;
  border-radius: var(--radius-sm);
  background: #0d0f13;
  overflow: hidden;
}
.photo-preview img { width: 100%; height: 100%; object-fit: contain; }

/* --------------------------------------------------------------------------
   panels, notices, stats
   -------------------------------------------------------------------------- */
.panel {
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.panel h2 { font-size: 1rem; }

.notice {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--navy);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.9rem;
}
.notice--warn { border-left-color: var(--warn); background: rgba(178, 106, 0, 0.07); }
.notice--ok { border-left-color: var(--accent); background: rgba(15, 138, 95, 0.07); }
.notice ul { margin: 0.35rem 0 0; padding-left: 1.1rem; }
.notice li { margin-bottom: 0.15rem; }

.warn { color: var(--warn); font-size: 0.88rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.6rem; }
.stat {
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.stat b { font-size: 1.4rem; line-height: 1.1; }
.stat span { font-size: 0.78rem; color: var(--text-muted); }
.stat--warn { border-color: var(--warn); }
.stat--ok { border-color: var(--accent); }

.meter__bar {
  height: 8px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}
.meter__bar span { display: block; height: 100%; background: var(--navy); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 0.8rem; margin: 0 0 1rem; font-size: 0.9rem; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; font-weight: 600; }

.fail-list { margin: 0.5rem 0; padding-left: 1.1rem; font-size: 0.85rem; }
.fail-list li { margin-bottom: 0.3rem; }

.asset-preview {
  padding: 0.6rem;
  margin-bottom: 0.6rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
}
.asset-preview img { max-width: 100%; max-height: 90px; object-fit: contain; display: block; margin: 0 auto; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 3rem 1rem;
  color: var(--text-muted);
  text-align: center;
}

.loading { display: flex; align-items: center; gap: 0.6rem; padding: 2rem 0; color: var(--text-muted); }

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   login
   -------------------------------------------------------------------------- */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: linear-gradient(160deg, var(--navy) 0%, #0d1b33 100%);
}
.login__card {
  width: 100%;
  max-width: 380px;
  padding: 1.75rem 1.5rem;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.login__brand { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.25rem; }
.login__brand h1 { margin: 0; font-size: 1.5rem; }
/* Sized by width, not height: the card is only 380px wide and narrower on a
   phone, so the lockup has to shrink with it rather than overflow. The white
   plate is invisible on the light card and is what keeps the blue artwork
   legible once --surface goes dark. */
.login__logo {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  max-width: 250px;
  height: auto;
  padding: 4px 8px;
  border-radius: 8px;
  background: #fff;
}
.login__mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
}
.login__sub { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.25rem; }
.login__note {
  margin: 1rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.45;
}
/* Signing in with no server in reach — reassure rather than alarm. */
.login__note--offline {
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  background: rgba(15, 138, 95, 0.1);
  color: var(--accent-600);
  font-weight: 600;
}
.login__note--warn {
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  background: rgba(178, 106, 0, 0.12);
  color: var(--warn);
}
@media (prefers-color-scheme: dark) {
  .login__note--offline { color: #5fd3a6; }
  .login__note--warn { color: #f5c26b; }
}

/* --------------------------------------------------------------------------
   modal
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: rgba(10, 14, 22, 0.55);
  opacity: 0;
  transition: opacity 0.18s;
}
.modal-backdrop.is-in { opacity: 1; }

.modal {
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  border-radius: 14px 14px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  transform: translateY(16px);
  transition: transform 0.18s;
}
.modal-backdrop.is-in .modal { transform: none; }
.modal--wide { max-width: 640px; }

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}
.modal__head h2 { margin: 0; font-size: 1.05rem; }

.modal__body {
  padding: 1rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 620px) {
  .modal-backdrop { align-items: center; padding: 1.5rem; }
  .modal { border-radius: 14px; transform: scale(0.97); }
  .modal-backdrop.is-in .modal { transform: none; }
}

/* --------------------------------------------------------------------------
   toast
   -------------------------------------------------------------------------- */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transform: translateX(-50%);
  width: min(92vw, 420px);
  pointer-events: none;
}
.toast {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  background: #1c2431;
  color: #fff;
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.is-in { opacity: 1; transform: none; }
.toast--success { background: var(--accent-600); }
.toast--error { background: var(--danger); }
.toast--warn { background: var(--warn); }

/* --------------------------------------------------------------------------
   print - the on-screen shell should never end up on paper
   -------------------------------------------------------------------------- */
@media print {
  .topbar, .view__actions, .toast-host, .modal-backdrop { display: none !important; }
  .view { max-width: none; padding: 0; }
}

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

/* --------------------------------------------------------------------------
   install button + diagnostics
   -------------------------------------------------------------------------- */
.topbar__install {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.7rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.topbar__install:hover { background: var(--accent-600); }
.topbar__install[hidden] { display: none; }

.check-list { list-style: none; margin: 0 0 0.9rem; padding: 0; }
.check-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  line-height: 1.4;
}
.check-list li:last-child { border-bottom: 0; }
.check-list__mark {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 0.1rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 800;
  color: #fff;
}
.check-list .is-ok  .check-list__mark { background: var(--accent); }
.check-list .is-bad .check-list__mark { background: var(--danger); }
