/* ============================================================
   CLOSE CALL HVAC — Field Tools
   Industrial / utilitarian dark theme
   ============================================================ */

/* -------- Design tokens -------- */
:root {
  /* Brand */
  --brand-teal:    #4FB8DD;
  --brand-blue:    #2C75AF;
  --brand-deep:    #1E4A8F;
  --brand-glow:    rgba(79, 184, 221, 0.15);

  /* Neutrals (dark theme) */
  --bg:            #0a0e14;
  --bg-elevated:   #11161e;
  --surface:       #161c26;
  --surface-2:     #1e2532;
  --border:        #232c3b;
  --border-strong: #2f3a4d;

  /* Text */
  --text:          #f1f5f9;
  --text-muted:    #94a3b8;
  --text-dim:      #64748b;

  /* Status */
  --pass:          #22c55e;
  --pass-bg:       rgba(34, 197, 94, 0.12);
  --fail:          #ef4444;
  --fail-bg:       rgba(239, 68, 68, 0.12);
  --warn:          #f59e0b;
  --warn-bg:       rgba(245, 158, 11, 0.12);
  --na:            #64748b;
  --na-bg:         rgba(100, 116, 139, 0.12);
  --info:          var(--brand-teal);
  --info-bg:       rgba(79, 184, 221, 0.12);

  /* Spacing scale */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s7: 32px;
  --s8: 48px;
  --s9: 64px;

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* Type */
  --font-body: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Touch */
  --touch-min: 48px;

  /* Layout */
  --header-h: 60px;
  --nav-h: 68px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* -------- Reset & base -------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

body {
  overflow: hidden; /* let .view scroll, not body */
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, textarea, select {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

a {
  color: var(--brand-teal);
  text-decoration: none;
}

img { max-width: 100%; display: block; }

/* -------- Splash -------- */
.splash {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 100;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.splash.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-mark { width: 96px; height: 96px; margin-bottom: var(--s5); }
.splash-mark svg { width: 100%; height: 100%; }
.splash-text {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--text);
}
.splash-sub {
  margin-top: var(--s2);
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

/* -------- App shell -------- */
.app-root {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

/* The shell that wraps header + view + nav must itself be a flex column
   container so .view (flex:1) can grow and scroll. Without this, .view
   gets natural block height and the page won't scroll. */
.app-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
  position: relative;
}

.app-header {
  flex-shrink: 0;
  height: calc(var(--header-h) + var(--safe-top));
  padding-top: var(--safe-top);
  padding-left: max(var(--s4), var(--safe-left));
  padding-right: max(var(--s4), var(--safe-right));
  display: flex;
  align-items: center;
  gap: var(--s3);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 10;
}

.header-back {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  color: var(--text-muted);
  margin-left: -8px;
  transition: background 0.15s ease;
}
.header-back:active { background: var(--surface); }
.header-back svg { width: 22px; height: 22px; }

.header-title {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-logo svg { width: 28px; height: 28px; }
.header-logo-text {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text);
}

.header-action {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  color: var(--text-muted);
  transition: background 0.15s ease;
  margin-right: -8px;
}
.header-action:active { background: var(--surface); }
.header-action svg { width: 22px; height: 22px; }

/* Offline indicator (in header) */
.offline-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 3px var(--warn-bg);
  margin-right: 4px;
}

/* -------- Main view area -------- */
.view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + var(--s4));
}
.view-inner {
  padding: var(--s5) max(var(--s4), var(--safe-left)) var(--s5) max(var(--s4), var(--safe-right));
}

/* When no bottom nav (e.g. detail screens), reduce bottom padding */
.app-root.no-nav .view {
  padding-bottom: calc(var(--safe-bottom) + var(--s4));
}

/* -------- Bottom navigation -------- */
.bottom-nav {
  flex-shrink: 0;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  z-index: 9;
}
.app-root.no-nav .bottom-nav { display: none; }

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color 0.15s ease;
  position: relative;
}
.nav-item svg { width: 24px; height: 24px; }
.nav-item.active { color: var(--brand-teal); }
.nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 2px;
  background: var(--brand-teal);
  border-radius: 0 0 2px 2px;
}

/* -------- Typography -------- */
.h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.2; }
.h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.005em; line-height: 1.25; }
.h3 { font-size: 16px; font-weight: 600; letter-spacing: 0.005em; }
.h4 { font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.body { font-size: 15px; }
.small { font-size: 13px; color: var(--text-muted); }
.tiny { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }
.mono { font-family: var(--font-mono); }

.section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  margin-bottom: var(--s2);
  padding-left: var(--s2);
}

.page-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.015em;
  line-height: 1.1;
  margin-bottom: var(--s2);
}
.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: var(--s6);
}

/* -------- Cards -------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s4);
  margin-bottom: var(--s3);
}
.card-tight { padding: var(--s3) var(--s4); }
.card-pressable {
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.card-pressable:active {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  margin-bottom: var(--s3);
}
.card-header:last-child { margin-bottom: 0; }

.card-title { font-size: 16px; font-weight: 600; }
.card-meta { font-size: 13px; color: var(--text-muted); }

/* -------- Buttons -------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: var(--touch-min);
  padding: 0 var(--s5);
  border-radius: var(--r-md);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform 0.06s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  user-select: none;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn svg { width: 20px; height: 20px; flex-shrink: 0; }

.btn-primary {
  background: var(--brand-teal);
  color: #0a0e14;
}
.btn-primary:active:not(:disabled) { background: #6cc4e3; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn-secondary:active:not(:disabled) { background: var(--surface-2); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:active:not(:disabled) { background: var(--surface); color: var(--text); }

.btn-danger {
  background: transparent;
  color: var(--fail);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:active:not(:disabled) { background: var(--fail-bg); }

.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 var(--s3); font-size: 13px; }
.btn-lg { min-height: 56px; padding: 0 var(--s6); font-size: 16px; }

.btn-row {
  display: flex;
  gap: var(--s3);
  margin-top: var(--s4);
}
.btn-row .btn { flex: 1; }

/* Sticky action footer */
.action-footer {
  position: sticky;
  bottom: 0;
  margin-left: calc(-1 * max(var(--s4), var(--safe-left)));
  margin-right: calc(-1 * max(var(--s4), var(--safe-right)));
  margin-top: var(--s5);
  padding: var(--s4) max(var(--s4), var(--safe-left)) calc(var(--s4) + var(--safe-bottom)) max(var(--s4), var(--safe-right));
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  backdrop-filter: blur(8px);
}

/* -------- Form fields -------- */
.field { margin-bottom: var(--s4); }

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--s2);
  padding-left: var(--s1);
}
.field-label .req { color: var(--fail); margin-left: 2px; }

.input,
.textarea,
.select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s3) var(--s4);
  font-size: 16px; /* 16px prevents zoom on iOS */
  color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease;
  min-height: var(--touch-min);
}
.input::placeholder,
.textarea::placeholder { color: var(--text-dim); }
.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--brand-teal);
  background: var(--bg-elevated);
}

.textarea {
  min-height: 96px;
  resize: vertical;
  font-family: var(--font-body);
  line-height: 1.5;
  padding: var(--s3) var(--s4);
}

.input-mono { font-family: var(--font-mono); }

.input-prefix {
  position: relative;
}
.input-prefix .input { padding-left: 32px; }
.input-prefix-symbol {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 16px;
  pointer-events: none;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
}
.field-row.three { grid-template-columns: repeat(3, 1fr); }

.field-help {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: var(--s2);
  padding-left: var(--s1);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) 0;
  min-height: var(--touch-min);
  cursor: pointer;
}
.checkbox-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--brand-teal);
  cursor: pointer;
}
.checkbox-row span { flex: 1; font-size: 15px; }

/* -------- Segmented control (Pass/Fail/N/A) -------- */
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 4px;
}
.seg-btn {
  min-height: 40px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  transition: background 0.15s ease, color 0.15s ease;
}
.seg-btn.active.pass { background: var(--pass-bg); color: var(--pass); }
.seg-btn.active.fail { background: var(--fail-bg); color: var(--fail); }
.seg-btn.active.na   { background: var(--na-bg);   color: var(--text); }

/* -------- Badges & pills -------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.badge.pass    { background: var(--pass-bg); color: var(--pass); }
.badge.fail    { background: var(--fail-bg); color: var(--fail); }
.badge.warn    { background: var(--warn-bg); color: var(--warn); }
.badge.info    { background: var(--info-bg); color: var(--info); }
.badge.muted   { background: var(--surface-2); color: var(--text-muted); }
.badge.dot::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Job status visual */
.job-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.job-status-pill::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.job-status-pill.not_started::before { background: var(--text-dim); }
.job-status-pill.not_started { color: var(--text-muted); }
.job-status-pill.in_progress::before { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.job-status-pill.in_progress { color: var(--warn); }
.job-status-pill.completed::before { background: var(--pass); }
.job-status-pill.completed { color: var(--pass); }

/* -------- Job list cards -------- */
.job-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s4);
  margin-bottom: var(--s3);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  display: block;
}
.job-card:active {
  background: var(--surface-2);
  border-color: var(--border-strong);
}
.job-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s3);
  margin-bottom: var(--s2);
}
.job-card-name {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
}
.job-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s3);
  font-size: 13px;
  color: var(--text-muted);
  margin-top: var(--s2);
}
.job-card-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.job-card-meta-item svg { width: 14px; height: 14px; opacity: 0.7; }

/* -------- Detail screens -------- */
.detail-section {
  margin-bottom: var(--s6);
}
.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--border);
  gap: var(--s3);
}
.detail-row:last-child { border-bottom: none; }
.detail-row-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}
.detail-row-value {
  font-size: 15px;
  color: var(--text);
  font-weight: 500;
  text-align: right;
  word-break: break-word;
}
.detail-row-value.mono { font-family: var(--font-mono); }

/* Action grid (Start Checklist / Build Estimate / etc) */
.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
  margin-top: var(--s4);
}
.action-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s4);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s2);
  min-height: 100px;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.action-tile:active {
  background: var(--surface-2);
  border-color: var(--brand-teal);
}
.action-tile svg { width: 24px; height: 24px; color: var(--brand-teal); }
.action-tile-title { font-size: 15px; font-weight: 600; color: var(--text); }
.action-tile-meta { font-size: 12px; color: var(--text-muted); }

.action-tile.completed svg { color: var(--pass); }
.action-tile.completed::after {
  content: '✓';
  position: absolute;
  top: var(--s3);
  right: var(--s3);
  color: var(--pass);
  font-size: 18px;
  font-weight: 700;
}
.action-tile { position: relative; }

/* -------- Checklist items -------- */
.checklist-section {
  margin-bottom: var(--s5);
}
.checklist-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s3) 0;
  margin-bottom: var(--s2);
}
.checklist-section-title {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.checklist-section-progress {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.checklist-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s2);
}
.checklist-item-name {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: var(--s3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
}
.checklist-item-name .req-marker {
  color: var(--fail);
  font-size: 12px;
}

.checklist-item-notes {
  margin-top: var(--s3);
}
.checklist-item-notes .textarea {
  min-height: 64px;
  font-size: 14px;
  padding: var(--s2) var(--s3);
}

.checklist-item-photos {
  margin-top: var(--s3);
}

/* -------- Photo gallery -------- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: var(--s2);
}
.photo-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo-thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  color: white;
  display: grid;
  place-items: center;
  font-size: 14px;
  line-height: 1;
}
.photo-add {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text-dim);
}
.photo-add svg { width: 24px; height: 24px; }
.photo-add:active { border-color: var(--brand-teal); color: var(--brand-teal); }

/* -------- Signature pad -------- */
.sig-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s2);
  margin-bottom: var(--s3);
}
.sig-canvas {
  width: 100%;
  height: 180px;
  background: #f8fafc;
  border-radius: var(--r-sm);
  display: block;
  touch-action: none;
}
.sig-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--s2);
  padding: 0 var(--s2);
  font-size: 12px;
}
.sig-clear {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* -------- Empty state -------- */
.empty {
  padding: var(--s8) var(--s4);
  text-align: center;
  color: var(--text-muted);
}
.empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--s4);
  color: var(--text-dim);
  opacity: 0.6;
}
.empty-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--s2);
}
.empty-text { font-size: 14px; line-height: 1.5; }

/* -------- Banner / alert -------- */
.banner {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-radius: var(--r-md);
  margin-bottom: var(--s4);
  font-size: 13px;
  line-height: 1.4;
}
.banner svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.banner.info { background: var(--info-bg); color: var(--info); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.success { background: var(--pass-bg); color: var(--pass); }

/* Offline strip across top of view */
.offline-strip {
  background: var(--warn);
  color: #0a0e14;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  padding: 6px var(--s4);
  letter-spacing: 0.04em;
}

/* -------- Estimate -------- */
.parts-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s3);
  align-items: start;
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--border);
}
.parts-row:last-child { border-bottom: none; }
.parts-row-info { font-size: 14px; font-weight: 500; line-height: 1.3; }
.parts-row-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; font-family: var(--font-mono); }
.parts-row-actions { display: flex; gap: var(--s2); align-items: center; }
.parts-qty {
  width: 60px;
  text-align: center;
  font-family: var(--font-mono);
  padding: 6px 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 14px;
}

.estimate-summary {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s5);
  margin-top: var(--s5);
}
.estimate-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--s2) 0;
  font-size: 14px;
}
.estimate-line .label { color: var(--text-muted); }
.estimate-line .val { font-family: var(--font-mono); font-weight: 600; }
.estimate-total {
  margin-top: var(--s3);
  padding-top: var(--s3);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.estimate-total .label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.estimate-total .val { font-family: var(--font-mono); font-weight: 700; font-size: 22px; color: var(--brand-teal); }

/* -------- Modal -------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.modal-backdrop.open { opacity: 1; }

.modal {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
  padding-bottom: var(--safe-bottom);
}
.modal-backdrop.open .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s4);
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 17px; font-weight: 600; }
.modal-close {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
}
.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--s4);
}

/* Confirmation modal */
.confirm-text {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: var(--s5);
}

/* -------- Toast -------- */
#toast-container {
  position: fixed;
  top: calc(var(--safe-top) + var(--s4));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  pointer-events: none;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: var(--s3) var(--s4);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  gap: var(--s2);
  max-width: 90vw;
  animation: toastIn 0.25s ease;
  pointer-events: auto;
}
.toast.success { border-color: rgba(34, 197, 94, 0.4); }
.toast.success::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pass);
}
.toast.error { border-color: rgba(239, 68, 68, 0.4); }
.toast.error::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--fail);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* -------- Tabs (used in Settings) -------- */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 4px;
  margin-bottom: var(--s4);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab-btn {
  min-height: 38px;
  padding: 0 var(--s4);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.tab-btn.active { background: var(--surface-2); color: var(--text); }

/* -------- Search input -------- */
.search-wrap {
  position: relative;
  margin-bottom: var(--s4);
}
.search-wrap svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-dim);
  pointer-events: none;
}
.search-wrap .input { padding-left: 42px; }

/* -------- FAB -------- */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + var(--s4));
  right: calc(max(var(--s4), var(--safe-right)));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--brand-teal);
  color: #0a0e14;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 28px rgba(79, 184, 221, 0.35);
  z-index: 8;
  transition: transform 0.1s ease;
}
.fab:active { transform: scale(0.94); }
.fab svg { width: 26px; height: 26px; }

/* When viewport wider than app container, center the FAB relative to container */
@media (min-width: 560px) {
  .fab {
    right: calc(50vw - 280px + var(--s4));
  }
}

/* -------- Misc -------- */
.divider { height: 1px; background: var(--border); margin: var(--s5) 0; }
.spacer-sm { height: var(--s3); }
.spacer-md { height: var(--s5); }
.spacer-lg { height: var(--s7); }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-center { text-align: center; }
.flex-row { display: flex; align-items: center; gap: var(--s3); }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.flex-1 { flex: 1; }
.hidden { display: none !important; }

/* Online/saved indicator */
.save-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.save-indicator.saved { color: var(--pass); }
.save-indicator.saving { color: var(--warn); }
.save-indicator::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* -------- PDF Print view styles (used for fallback printing only) -------- */
@media print {
  body { background: white; color: black; }
  .app-header, .bottom-nav, .fab, .action-footer { display: none !important; }
}

/* -------- Larger screens (tablet/desktop preview) -------- */
@media (min-width: 560px) {
  .app-root {
    margin-top: 20px;
    margin-bottom: 20px;
    height: calc(100vh - 40px);
    height: calc(100dvh - 40px);
    border-radius: var(--r-xl);
    overflow: hidden;
    box-shadow: 0 20px 80px rgba(0,0,0,0.6);
    border: 1px solid var(--border);
  }
  body {
    background: #050810;
  }
}
