/* Saunton Jindalee VO Tracker — mobile-first, outdoor-readable */
:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #3d4f66;
  --text: #f4f6f8;
  --muted: #a8b4c4;
  --accent: #f5a623;
  --accent-dim: #c47d0a;
  --ok: #2ecc71;
  --ok-bg: #1a3d2a;
  --warn: #e74c3c;
  --warn-bg: #3d1a1a;
  --info: #3498db;
  --tap: 48px;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100dvh;
  padding-bottom: 80px;
}

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

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 2px solid var(--accent);
  padding: 12px 16px;
}
.app-header h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.app-header .sub {
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.nav-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  background: var(--bg);
  position: sticky;
  top: 58px;
  z-index: 40;
  border-bottom: 1px solid var(--border);
}
.nav-tabs button {
  flex: 1;
  min-height: var(--tap);
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.nav-tabs button.active {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
}

.page { display: none; padding: 12px; max-width: 720px; margin: 0 auto; }
.page.active { display: block; }

.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.search-row input {
  flex: 1;
  min-height: var(--tap);
  padding: 10px 14px;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.chip {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 20px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}
.chip.active {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
}

.unit-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  color: var(--text);
  cursor: pointer;
  min-height: 72px;
}
.unit-card:active { border-color: var(--accent); }
.unit-card .row1 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.unit-card .unit-name {
  font-size: 1.25rem;
  font-weight: 800;
}
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge.pct-high { background: var(--ok-bg); color: var(--ok); }
.badge.pct-mid { background: #3d351a; color: var(--accent); }
.badge.pct-low { background: var(--warn-bg); color: #ff8a80; }
.badge.pct-none { background: var(--surface2); color: var(--muted); }

.unit-card .meta {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}
.unit-card .meta strong { color: var(--text); }

.back-btn {
  min-height: var(--tap);
  padding: 10px 16px;
  margin-bottom: 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface2);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.unit-detail-header {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.unit-detail-header h2 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}
.progress-bar {
  height: 12px;
  background: var(--surface2);
  border-radius: 6px;
  overflow: hidden;
  margin: 10px 0 6px;
}
.progress-bar > span {
  display: block;
  height: 100%;
  background: var(--ok);
  border-radius: 6px;
  transition: width 0.2s;
}

.item-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.item-card.installed {
  border-color: var(--ok);
  background: var(--ok-bg);
}
.item-card.margin-card {
  border-style: dashed;
  border-color: var(--info);
  background: #152030;
}
.item-card .ref-line {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}
.item-card .ref {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--accent);
}
.item-card .value {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
}
.item-card .desc {
  font-size: 0.95rem;
  margin: 0 0 12px;
}
.item-card .var-no {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.toggle-btn {
  flex: 1;
  min-height: 56px;
  border-radius: 12px;
  border: 3px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 0.03em;
}
.toggle-btn.on {
  background: var(--ok);
  color: #0a1a0f;
  border-color: var(--ok);
}
.margin-note {
  font-size: 0.85rem;
  color: var(--info);
  padding: 10px;
  background: #0d1a28;
  border-radius: 8px;
  margin-bottom: 8px;
}

.item-card textarea {
  width: 100%;
  min-height: 72px;
  padding: 12px;
  font-size: 1rem;
  font-family: inherit;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}
.btn {
  min-height: var(--tap);
  padding: 12px 16px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}
.btn.primary {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
}
.btn.danger {
  background: var(--warn-bg);
  color: #ff8a80;
  border-color: var(--warn);
}
.btn:disabled { opacity: 0.5; }

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-bottom: 16px;
}
.summary-table th, .summary-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.summary-table th {
  background: var(--surface);
  position: sticky;
  top: 110px;
  z-index: 10;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}
.summary-table tr.total {
  background: var(--surface2);
  font-weight: 800;
}
.summary-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.summary-table button.linkish {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  padding: 0;
  min-height: 40px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #111;
  padding: 12px 20px;
  border-radius: 10px;
  font-weight: 700;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 16px;
}

.footer-note {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 20px 12px;
}

@media (min-width: 600px) {
  .app-header h1 { font-size: 1.25rem; }
  .summary-table { font-size: 0.9rem; }
}
