/* ═══════════════════════════════════════════════
   Fiber Meter — Professional Field Tool
   Light/Dark theme via system preference
   ═══════════════════════════════════════════════ */

/* ── Light theme (default) ── */

:root {
  --bg: #F2F4F6;
  --surface: #FFFFFF;
  --surface-2: #F7F8FA;
  --surface-3: #EDF0F3;

  --border: #D8DEE5;
  --border-strong: #B8C4D0;

  --cyan: #00C896;
  --blue: #005288;
  --blue-light: #3B8FCA;
  --mint: #5EDBA8;

  --text: #1A2B3C;
  --text-2: #425B76;
  --text-3: #7A8FA2;

  --gps-color: #2E7DB8;
  --pdr-color: #0EA06C;
  --fused-color: #005288;

  --good: #0EA06C;
  --warn: #C89820;
  --bad: #C43030;

  --btn-primary-bg: #005288;
  --btn-primary-text: #FFFFFF;
  --btn-stop-bg: #C43030;
  --btn-stop-text: #FFFFFF;
  --btn-secondary-bg: #EDF0F3;
  --btn-secondary-text: #425B76;
  --btn-secondary-border: #D8DEE5;

  --badge-a-bg: #005288;
  --badge-a-text: #FFFFFF;
  --badge-b-bg: #3B8FCA;
  --badge-b-text: #FFFFFF;

  --gps-active-badge-bg: #E0F5ED;
  --gps-active-badge-text: #0EA06C;

  --modal-bg: rgba(0, 0, 0, 0.5);
  --modal-border-top: #005288;

  --install-border-top: #005288;

  --r: 8px;
  --r-sm: 6px;
}


*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

/* ════ HEADER ════ */

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 500px;
  margin: 0 auto;
  padding: 12px 16px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: var(--blue);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-icon svg {
  width: 18px;
  height: 18px;
}

.brand-text h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1.5px;
  line-height: 1.1;
}

.brand-text p {
  font-size: 10px;
  color: var(--text-3);
  line-height: 1.2;
}

.lang-toggle {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lang-toggle:active {
  background: var(--surface-3);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logout-btn {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.logout-btn:active {
  background: var(--surface-3);
}

.logout-btn svg {
  width: 18px;
  height: 18px;
}

/* ════ MAIN ════ */

.main-content {
  max-width: 500px;
  margin: 0 auto;
  padding: 12px 12px 90px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ════ CARDS ════ */

.card {
  background: var(--surface);
  border-radius: var(--r);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-body {
  padding: 14px;
}

/* ════ GPS ════ */

.gps-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.gps-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
}

.gps-indicator.active {
  background: var(--good);
  box-shadow: 0 0 6px var(--good);
}

.gps-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-3);
  flex: 1;
}

.gps-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-3);
  letter-spacing: 0.3px;
}

.gps-badge.active {
  background: var(--gps-active-badge-bg);
  color: var(--gps-active-badge-text);
}

.gps-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.gps-metric {
  background: var(--surface-2);
  border-radius: var(--r-sm);
  padding: 8px 10px;
}

.gps-metric-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 3px;
}

.gps-metric-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.gps-metric-value.good { color: var(--good); }
.gps-metric-value.medium { color: var(--warn); }
.gps-metric-value.poor { color: var(--bad); }

.gps-coords { grid-column: 1 / -1; }

.gps-coords .gps-metric-value {
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text-2);
  font-weight: 500;
}

.gps-card.gps-active {
  border-color: var(--border-strong);
}

/* ════ POINTS ════ */

.point-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface-2);
}

.point-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
}

.point-badge.a { background: var(--badge-a-bg); color: var(--badge-a-text); }
.point-badge.b { background: var(--badge-b-bg); color: var(--badge-b-text); }

.point-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-2);
}

.photo-area {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.photo-area img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.photo-area img.visible { display: block; }

.photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-3);
}

.photo-placeholder svg { width: 28px; height: 28px; opacity: 0.35; }
.photo-placeholder span { font-size: 10px; opacity: 0.4; }
.photo-area:has(img.visible) .photo-placeholder { display: none; }

.point-fields {
  padding: 12px 14px;
}

.field-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  margin-bottom: 8px;
}

.field-input:focus {
  border-color: var(--border-strong);
}

.field-input::placeholder { color: var(--text-3); }

.point-coords {
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text-3);
}

/* ════ TRACKING ════ */

.tracking-card {
  border-color: var(--border-strong);
}

.tracking-hero {
  text-align: center;
  padding: 24px 14px 18px;
  background: var(--surface);
}

.tracking-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 6px;
}

.tracking-distance {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
}

.tracking-distance-value {
  font-size: 52px;
  font-weight: 300;
  color: var(--fused-color);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -1px;
}

.tracking-distance-unit {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-3);
}

.tracking-source {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 6px;
  font-weight: 500;
}

.tracking-breakdown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--border);
}

.tracking-metric {
  padding: 12px 14px;
  text-align: center;
  background: var(--surface-2);
}

.tracking-metric:nth-child(odd) {
  border-right: 1px solid var(--border);
}

.tracking-metric:nth-child(n+3) {
  border-top: 1px solid var(--border);
}

.tracking-metric-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.tracking-metric-label.gps { color: var(--gps-color); }
.tracking-metric-label.pdr { color: var(--pdr-color); }
.tracking-metric-label.steps { color: var(--text-3); }
.tracking-metric-label.cadence { color: var(--text-3); }

.tracking-metric-value {
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.tracking-metric-value small {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
}

.tracking-timer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.tracking-timer-icon { font-size: 12px; color: var(--text-3); }

.tracking-timer-value {
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  letter-spacing: 1px;
}

/* ════ BUTTONS ════ */

.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--r);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  cursor: pointer;
}

.btn:active { opacity: 0.85; }

.btn-primary, .btn-start, .btn-save {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
}

.btn-stop {
  background: var(--btn-stop-bg);
  color: var(--btn-stop-text);
}

.btn-secondary {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
  border: 1px solid var(--btn-secondary-border);
}

.btn-secondary:active {
  background: var(--surface-3);
}

/* Measurement methods */

.measurement-methods {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 0 4px;
}

.measurement-methods-label {
  padding: 0 2px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.measurement-method-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 15px;
}

.pdr-method-card {
  border-left: 3px solid var(--pdr-color);
}

.map-measure-card {
  border-left: 3px solid var(--blue);
}

.measurement-method-title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
}

.measurement-method-desc {
  margin: 0;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.4;
}

.measurement-method-btn {
  width: auto;
  min-width: 156px;
  padding: 12px 14px;
  font-size: 11px;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-measure-modal {
  position: fixed;
  inset: 0;
  z-index: 2500;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.map-measure-modal.hidden {
  display: none !important;
}

.map-measure-toolbar,
.map-measure-footer {
  position: relative;
  z-index: 2;
  background: var(--surface);
  border-color: var(--border);
}

.map-measure-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px;
  border-bottom: 1px solid var(--border);
}

.map-measure-toolbar-main h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
}

.map-measure-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--text-3);
  font-size: 11px;
}

.map-measure-stats strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.map-measure-tools {
  display: flex;
  gap: 6px;
  align-items: center;
}

.map-tool-btn {
  min-width: 44px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
}

.map-tool-btn.close {
  width: 34px;
  min-width: 34px;
  padding: 0;
}

.map-measure-map {
  flex: 1;
  min-height: 320px;
  background: var(--surface-2);
}

.map-measure-footer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
}

.map-measure-footer p {
  margin: 0;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.35;
}

.map-measure-footer .btn {
  width: auto;
  min-width: 190px;
  padding: 12px 14px;
  font-size: 11px;
}

.map-measure-footer .btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.map-point-label {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  border: 2px solid white;
  box-shadow: 0 2px 8px rgba(0, 27, 46, 0.25);
  font-size: 11px;
  font-weight: 800;
}

.route-breakdown-chip.map {
  color: var(--blue);
}

.route-map-summary {
  margin: -2px 0 8px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
}

@media (max-width: 560px) {
  .measurement-method-card,
  .map-measure-footer {
    grid-template-columns: 1fr;
  }

  .measurement-method-btn,
  .map-measure-footer .btn {
    width: 100%;
    min-width: 0;
  }

  .map-measure-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .map-measure-tools {
    width: 100%;
  }

  .map-tool-btn {
    flex: 1;
  }

  .map-tool-btn.close {
    flex: 0 0 44px;
    width: 44px;
  }
}

/* ════ HISTORY ════ */

.history-section {
  margin-top: 6px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2px;
  margin-bottom: 10px;
}

.history-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-3);
}

.btn-export {
  background: var(--blue);
  color: white;
  border: none;
  padding: 5px 12px;
  border-radius: var(--r-sm);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.btn-export:active { opacity: 0.85; }
.btn-export.hidden { display: none; }

.routes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.no-routes {
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  padding: 28px 0;
}

.route-item {
  background: var(--surface);
  border-radius: var(--r);
  border: 1px solid var(--border);
  overflow: hidden;
}

.route-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface-2);
}

.route-distance-display {
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.route-distance-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--fused-color);
  font-variant-numeric: tabular-nums;
}

.route-distance-unit {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
}

.route-duration {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.route-item-body {
  padding: 10px 14px;
}

.route-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.route-breakdown-chip {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
  background: var(--surface-2);
  letter-spacing: 0.3px;
}

.route-breakdown-chip.gps { color: var(--gps-color); }
.route-breakdown-chip.pdr { color: var(--pdr-color); }

.route-endpoints {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 8px;
}

.route-endpoint {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-2);
}

.route-endpoint .point-badge {
  width: 18px;
  height: 18px;
  font-size: 9px;
}

.route-photos {
  display: flex;
  gap: 6px;
}

.route-thumb {
  width: 48px;
  height: 48px;
  border-radius: var(--r-sm);
  object-fit: cover;
  border: 1px solid var(--border);
}

.route-item-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
}

.route-date {
  font-size: 10px;
  color: var(--text-3);
}

.btn-delete {
  background: transparent;
  border: 1px solid var(--bad);
  color: var(--bad);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.btn-delete:active {
  opacity: 0.7;
}

/* ════ MODAL ════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-bg);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.hidden { display: none !important; }

.modal-card {
  background: var(--surface);
  border-radius: var(--r) var(--r) 0 0;
  padding: 6px 16px 16px;
  max-width: 500px;
  width: 100%;
  border-top: 2px solid var(--modal-border-top);
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

.modal-handle {
  width: 32px;
  height: 3px;
  background: var(--text-3);
  border-radius: 2px;
  margin: 8px auto 14px;
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
}

.modal-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.modal-option:active {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

.modal-option-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.modal-cancel {
  display: block;
  width: 100%;
  padding: 11px;
  margin-top: 4px;
  background: transparent;
  border: none;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.modal-cancel:active { color: var(--text-2); }

/* ════ SUCCESS MODAL ════ */

.success-modal-card {
  text-align: center;
  padding: 6px 24px 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  border-top: 3px solid var(--good);
}

.success-modal-icon {
  margin: 12px auto 16px;
  animation: successPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes successPop {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.success-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.success-modal-msg {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 14px;
  line-height: 1.4;
}

.success-modal-detail {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  padding: 8px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: 14px;
  display: none;
}

.success-modal-detail.visible { display: block; }

.success-modal-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--good);
  background: var(--gps-active-badge-bg);
  padding: 4px 10px;
  border-radius: 10px;
  margin-bottom: 16px;
}

.success-modal-btn {
  width: 100%;
  padding: 13px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
}

/* ════ INSTALL ════ */

.install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--surface);
  border-top: 2px solid var(--install-border-top);
}

.install-content {
  max-width: 500px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}

.install-text { flex: 1; }
.install-text strong { font-size: 13px; display: block; }
.install-text span { font-size: 10px; color: var(--text-3); }

.install-btn {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border: none;
  padding: 8px 16px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.install-close {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 15px;
  cursor: pointer;
  padding: 2px;
}

/* ════ FOOTER ════ */

.app-footer {
  text-align: center;
  padding: 16px;
  color: var(--text-3);
  font-size: 10px;
  letter-spacing: 0.5px;
}

/* ════ NAVIGATION TABS ════ */

.app-tabs {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 99;
}

.tabs-container {
  display: flex;
  max-width: 500px;
  margin: 0 auto;
  padding: 0 12px;
  gap: 0;
}

.tab-btn {
  flex: 1;
  padding: 10px 0;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-3);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.tab-btn.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.tab-btn:active {
  opacity: 0.7;
}

/* ════ REPORT FORM ════ */

.report-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rpt-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 8px 2px 2px;
}

.rpt-card {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rpt-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rpt-field-row {
  flex-direction: row;
  gap: 10px;
}

.rpt-field-half {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nap-power-diff {
  min-height: 18px;
  margin: -2px 0 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--blue);
}

.nap-power-diff.empty {
  color: var(--text-3);
  font-weight: 600;
}

.rpt-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

/* Toggle button group */
.rpt-toggle-group {
  display: flex;
  gap: 6px;
}

.rpt-toggle-wrap {
  flex-wrap: wrap;
}

.rpt-toggle {
  flex: 1;
  min-width: 0;
  padding: 9px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.rpt-toggle-wrap .rpt-toggle {
  flex: 0 1 auto;
  min-width: calc(33% - 4px);
  padding: 9px 12px;
}

.rpt-toggle.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #FFFFFF;
  font-weight: 700;
}

.rpt-toggle:active {
  opacity: 0.85;
}

/* Photo capture */
.rpt-photo-hint {
  font-size: 10px;
  color: var(--text-3);
  margin-top: -2px;
}

.rpt-photo-capture {
  position: relative;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
  min-height: 48px;
}

.rpt-photo-capture.has-photo {
  border-style: solid;
  border-color: var(--good);
}

.rpt-photo-preview {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  display: none;
}

.rpt-photo-capture.has-photo .rpt-photo-preview {
  display: block;
}

.rpt-photo-buttons {
  display: flex;
  gap: 0;
}

.rpt-photo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.rpt-gallery-btn {
  border-left: 1px solid var(--border);
}

.rpt-photo-capture.has-photo .rpt-photo-btn {
  padding: 8px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--blue);
  font-size: 11px;
}

.rpt-photo-source {
  display: none;
  font-size: 10px;
  font-weight: 600;
  padding: 4px 12px;
}

.rpt-photo-capture.has-photo .rpt-photo-source:not(:empty) {
  display: block;
}

.rpt-photo-source.source-camera {
  color: var(--good);
}

.rpt-photo-source.source-gallery {
  color: var(--warn, #e67e22);
}

.rpt-photo-source.source-gallery-nogeo {
  color: var(--danger, #e74c3c);
}

.rpt-photo-btn svg {
  width: 20px;
  height: 20px;
  opacity: 0.5;
}

.rpt-photo-capture.has-photo .rpt-photo-btn svg {
  width: 16px;
  height: 16px;
  opacity: 1;
}

.rpt-photo-geo {
  font-size: 10px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--good);
  padding: 0 12px 8px;
  display: none;
}

.rpt-photo-capture.has-photo .rpt-photo-geo {
  display: block;
}

/* Select input in report form */
.filter-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237A8FA2' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.filter-input:focus { border-color: var(--border-strong); }

.rpt-field-help {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-3);
}

.rpt-inline-link {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

/* Textarea */
.rpt-textarea {
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
}

.nap-client-codes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nap-client-code-row {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 8px;
  align-items: center;
}

.nap-client-code-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
}

.nap-client-code-input {
  margin-bottom: 0;
}

.nap-evidence-uploader {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nap-evidence-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.nap-evidence-preview-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.nap-evidence-preview-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.nap-evidence-source {
  padding: 5px 8px;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 700;
}

.nap-evidence-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(17, 24, 39, 0.82);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.nap-evidence-picker {
  min-height: 52px;
}

.nap-evidence-picker.is-full {
  display: none;
}

@media (max-width: 560px) {
  .nap-evidence-preview-grid {
    grid-template-columns: 1fr;
  }
}

/* Measurement banner */
.rpt-measurement-banner {
  background: var(--surface);
  border: 2px solid var(--good);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 4px;
}

.rpt-measurement-banner.rpt-measurement-warning {
  border-color: var(--bad);
}

.rpt-measurement-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #E0F5ED;
  color: var(--good);
  font-size: 12px;
  font-weight: 700;
}

.rpt-measurement-banner.rpt-measurement-warning .rpt-measurement-header {
  background: #FDE8E8;
  color: var(--bad);
}

.rpt-measurement-title {
  flex: 1;
  letter-spacing: 0.5px;
}

.rpt-measurement-remove {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.rpt-measurement-body {
  padding: 12px 14px;
}

.rpt-measurement-distance {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 6px;
}

.rpt-meas-value {
  font-size: 32px;
  font-weight: 300;
  color: var(--fused-color);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.rpt-measurement-banner.rpt-measurement-warning .rpt-meas-value {
  color: var(--bad);
}

.rpt-measurement-warning-text {
  margin: -2px 0 8px;
  color: var(--bad);
  font-size: 12px;
  font-weight: 700;
}

.rpt-meas-unit {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-3);
}

.rpt-measurement-details {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
}

.rpt-meas-detail {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  padding: 2px 8px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
}

.rpt-measurement-photos {
  display: flex;
  gap: 8px;
}

.rpt-meas-point {
  position: relative;
  display: none;
}

.rpt-meas-point.visible {
  display: block;
}

.rpt-meas-thumb {
  width: 64px;
  height: 64px;
  border-radius: var(--r-sm);
  object-fit: cover;
  border: 1px solid var(--border);
}

.rpt-meas-point .point-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  width: 18px;
  height: 18px;
  font-size: 9px;
}

/* No measurement info */
.rpt-no-measurement {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--r);
  color: var(--text-3);
  font-size: 12px;
  margin-bottom: 4px;
}

.rpt-no-measurement svg {
  flex-shrink: 0;
  opacity: 0.5;
}

.rpt-no-measurement.hidden { display: none !important; }

/* Inline measurement widget */
.inline-meas-start { }

.inline-meas-actions {
  display: grid;
  gap: 8px;
}

.inline-meas-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.rpt-saved-meas-link {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--blue-light);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 0 2px;
  text-decoration: underline;
  text-align: center;
}

.rpt-saved-meas-link:active { opacity: 0.7; }

.inline-meas-step {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.inline-meas-step-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface-3);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

.inline-meas-step-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inline-meas-photo {
  width: 100%;
  max-height: 150px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}

.inline-meas-photo.hidden { display: none; }

.inline-meas-coords {
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--good);
}

.inline-meas-tracking {
  text-align: center;
  padding: 16px 12px 12px;
}

.inline-meas-tracking-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 4px;
}

.inline-meas-tracking-dist {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  margin-bottom: 8px;
}

.inline-meas-tracking-dist span:first-child {
  font-size: 40px;
  font-weight: 300;
  color: var(--fused-color);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.inline-meas-tracking-details {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.inline-meas-tracking-details span {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  padding: 2px 8px;
  background: var(--surface);
  border-radius: var(--r-sm);
}

/* Submit button */
.rpt-submit-btn {
  margin-top: 4px;
  margin-bottom: 8px;
}

.rpt-submit-btn.submitting {
  opacity: 0.6;
  pointer-events: none;
}

/* Report history items */
.report-item {
  background: var(--surface);
  border-radius: var(--r);
  border: 1px solid var(--border);
  overflow: hidden;
}

.report-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface-2);
}

.report-item-order {
  font-size: 15px;
  font-weight: 700;
  color: var(--blue);
}

.report-item-type {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  background: var(--blue);
  color: white;
  letter-spacing: 0.3px;
}

.report-item-body {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.report-item-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-2);
}

.report-item-row span:first-child {
  color: var(--text-3);
  font-weight: 500;
}

.report-item-photos {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  overflow-x: auto;
}

.report-item-photos img {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.report-item-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
}

/* ── Barcode Scanner ── */

.rpt-input-scan {
  display: flex;
  gap: 6px;
  align-items: flex-start;
}

.rpt-input-scan .field-input {
  flex: 1;
  margin-bottom: 0;
}

.rpt-scan-btn {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.rpt-scan-btn:active {
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--blue);
}

.scanner-modal-card {
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}

.scanner-viewfinder {
  width: 100%;
  aspect-ratio: 1;
  max-height: 320px;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: #000;
}

.scanner-viewfinder video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}

#scannerViewfinder img[alt="Info icon"] { display: none !important; }

/* Scanner file mode (iOS fallback) */
.scanner-file-mode {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px 16px;
}

.scanner-file-icon {
  color: var(--text-3);
  opacity: 0.5;
}

.scanner-file-btn {
  width: 100%;
  max-width: 280px;
}

.scanner-file-mode .scanner-hint {
  margin: 0;
}

.scanner-zoom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 8px 0 0;
}
.scanner-zoom-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.scanner-zoom-btn:active { background: var(--surface-3); }
.scanner-zoom-level {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  min-width: 36px;
  text-align: center;
}

.scanner-hint {
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
  margin: 10px 0 4px;
}

.scanner-success {
  color: var(--good);
  font-weight: 600;
}

/* Field validation */
.field-input.rpt-error,
.filter-input.rpt-error {
  border-color: var(--bad);
}

.rpt-photo-capture.rpt-error {
  border-color: var(--bad);
}

/* ── Update Banner ── */

.update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2000;
  background: var(--blue);
  color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  animation: updatePulse 1.5s ease-in-out infinite;
}

.update-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}

.update-content svg {
  animation: updateSpin 1s linear infinite;
}

@keyframes updateSpin {
  to { transform: rotate(360deg); }
}

@keyframes updatePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ════ UTILITIES ════ */

.hidden { display: none !important; }
.hidden-input { position: absolute; opacity: 0; pointer-events: none; }

@supports (padding-top: env(safe-area-inset-top)) {
  .header-content {
    padding-top: calc(12px + env(safe-area-inset-top));
  }
}

::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
