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

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --card: #0f3460;
  --accent: #e94560;
  --text: #eaeaea;
  --muted: #888;
  --green: #2ecc71;
  --yellow: #f39c12;
  --blue: #3498db;
  --radius: 12px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', sans-serif;
  min-height: 100vh;
  overscroll-behavior: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 0 120px 0;
}

.header {
  background: var(--surface);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid #ffffff15;
}

.header h1 { font-size: 1.1rem; font-weight: 700; }

.header-back {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 1.6rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.header-action {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px 8px;
}

.screen { padding: 16px; }

.name-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 20px;
  text-align: center;
  padding: 32px;
}

.name-screen h2 { font-size: 1.6rem; }
.name-screen p { color: var(--muted); }

input[type="text"],
input[type="tel"],
input[type="number"],
textarea,
select {
  width: 100%;
  background: var(--card);
  border: 1px solid #ffffff20;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  padding: 13px 16px;
  outline: none;
  appearance: none;
  font-family: inherit;
}

textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
select option { background: var(--card); }

.input-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 4px;
  display: block;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  text-align: center;
}

.btn:active { opacity: 0.7; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--card); color: var(--text); }
.btn-green { background: var(--green); color: #fff; }
.btn-yellow { background: var(--yellow); color: #fff; }
.btn-blue { background: var(--blue); color: #fff; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid #ffffff10;
}

.job-card { cursor: pointer; }
.job-card:active { opacity: 0.7; }

.job-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 4px;
}

.job-card-title { font-size: 1rem; font-weight: 700; }
.job-card-meta { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }

.job-card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}

.job-delete {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
}

.status-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-In\ Progress { background: #e9456025; color: var(--accent); }
.status-Quoting { background: #f39c1225; color: var(--yellow); }
.status-Complete { background: #2ecc7125; color: var(--green); }

.job-cost { font-size: 0.85rem; color: var(--green); font-weight: 700; }

.filter-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar { display: none; }

.filter-chip {
  background: var(--surface);
  border: 1px solid #ffffff15;
  border-radius: 20px;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 6px 14px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.search-wrap { padding: 0 16px 12px; }
.search-wrap input { background: var(--surface); }

.fab {
  position: fixed;
  bottom: 80px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  box-shadow: 0 4px 20px #e9456080;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.fab:active { opacity: 0.7; }

.job-info-section {
  background: var(--surface);
  border-bottom: 1px solid #ffffff10;
}

.job-info-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted);
}

.job-info-body {
  padding: 0 16px 16px;
  display: none;
  flex-direction: column;
  gap: 8px;
}

.job-info-body.open { display: flex; }

.job-info-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

.job-info-row span:first-child { color: var(--muted); }
.job-info-row span:last-child { font-weight: 600; text-align: right; max-width: 65%; }

.cost-bar {
  background: var(--surface);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #ffffff10;
  border-bottom: 1px solid #ffffff10;
}

.cost-bar-label { color: var(--muted); font-size: 0.85rem; }
.cost-bar-total { color: var(--green); font-size: 1.1rem; font-weight: 700; }

.supplier-filter {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  scrollbar-width: none;
}

.supplier-filter::-webkit-scrollbar { display: none; }

.part-group {
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 10px;
  border: 1px solid #ffffff10;
  overflow: hidden;
}

.part-group-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  cursor: pointer;
}

.part-group-header:active { opacity: 0.7; }

.part-check {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: none;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: #fff;
}

.part-group.all-checked .part-check {
  background: var(--green);
  border-color: var(--green);
}

.part-group-info { flex: 1; min-width: 0; }
.part-group-name { font-size: 0.95rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.part-group-sub { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }

.part-group-right { text-align: right; flex-shrink: 0; }
.part-group-qty { font-size: 0.9rem; color: var(--accent); font-weight: 700; }
.part-group-cost { font-size: 0.8rem; color: var(--green); }

.part-entries { display: none; border-top: 1px solid #ffffff10; }
.part-entries.open { display: block; }

.part-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid #ffffff08;
}

.part-entry:last-child { border-bottom: none; }

.entry-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #ffffff30;
  background: none;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: #fff;
}

.part-entry.checked .entry-check { background: var(--green); border-color: var(--green); }
.part-entry.checked { opacity: 0.5; }

.entry-info { flex: 1; min-width: 0; }
.entry-purpose { font-size: 0.85rem; color: var(--text); }
.entry-meta { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }

.entry-right { text-align: right; flex-shrink: 0; }
.entry-qty { font-size: 0.85rem; color: var(--accent); font-weight: 700; }
.entry-cost { font-size: 0.75rem; color: var(--green); }

.entry-delete {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
}

/* FREQUENT PARTS DRAWER */
.freq-drawer {
  position: fixed;
  bottom: 70px;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--surface);
  border-top: 2px solid var(--accent);
  border-radius: 16px 16px 0 0;
  z-index: 25;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.freq-drawer.open { transform: translateY(0); }

.freq-drawer-handle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  cursor: pointer;
}

.freq-drawer-title { font-size: 0.85rem; font-weight: 700; color: var(--accent); }
.freq-drawer-arrow { color: var(--muted); font-size: 1rem; transition: transform 0.3s; }
.freq-drawer.open .freq-drawer-arrow { transform: rotate(180deg); }

.freq-drawer-body {
  padding: 0 16px 16px;
  display: none;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.freq-drawer.open .freq-drawer-body { display: flex; }

.freq-part-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border: none;
  border-radius: var(--radius);
  color: var(--text);
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  width: 100%;
}

.freq-part-btn:active { opacity: 0.7; }
.freq-part-name { font-size: 0.9rem; font-weight: 600; }
.freq-part-meta { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.freq-part-add { color: var(--accent); font-size: 1.4rem; font-weight: 700; }

/* MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: #000000cc;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h3 { font-size: 1.1rem; }

.add-options {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 8px;
}

.add-option-btn {
  background: var(--card);
  border: none;
  border-radius: var(--radius);
  color: var(--text);
  padding: 14px 6px;
  font-size: 0.72rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.add-option-btn span.icon { font-size: 1.4rem; }
.add-option-btn:active { opacity: 0.7; }

.voice-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-btn.listening { background: var(--green); animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.voice-transcript {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  min-height: 40px;
}

#scanner-video {
  width: 100%;
  border-radius: var(--radius);
  max-height: 240px;
  object-fit: cover;
}

.autocomplete-wrap { position: relative; }

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card);
  border-radius: 0 0 var(--radius) var(--radius);
  z-index: 100;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid #ffffff20;
  border-top: none;
}

.autocomplete-item {
  padding: 12px 16px;
  cursor: pointer;
  font-size: 0.9rem;
  border-bottom: 1px solid #ffffff10;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:active { background: #ffffff15; }
.autocomplete-sub { font-size: 0.75rem; color: var(--muted); }

.receipt-upload-btn {
  background: var(--card);
  border: 2px dashed #ffffff30;
  border-radius: var(--radius);
  color: var(--muted);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.receipt-upload-btn span { font-size: 2rem; }

.receipt-match {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.receipt-match-info { flex: 1; }
.receipt-match-name { font-size: 0.9rem; font-weight: 600; }
.receipt-match-meta { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.receipt-match-cost { font-size: 0.9rem; color: var(--green); font-weight: 700; flex-shrink: 0; }

.match-toggle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--green);
  background: none;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: #fff;
}

.match-toggle.selected { background: var(--green); }

/* QUOTE */
.quote-section {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid #ffffff10;
  overflow: hidden;
  margin-bottom: 12px;
}

.quote-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #ffffff08;
  font-size: 0.9rem;
}

.quote-row:last-child { border-bottom: none; }
.quote-row-label { color: var(--muted); }
.quote-row-value { font-weight: 600; }
.quote-total-row { background: #ffffff08; }
.quote-total-row .quote-row-value { color: var(--green); font-size: 1.1rem; }

.quote-status {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
}

.quote-status-Draft { background: #ffffff15; color: var(--muted); }
.quote-status-Sent { background: #3498db25; color: var(--blue); }
.quote-status-Accepted { background: #2ecc7125; color: var(--green); }
.quote-status-Declined { background: #e9456025; color: var(--accent); }

/* TEMPLATES */
.template-card {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.template-card:active { opacity: 0.7; }
.template-card-info { flex: 1; }
.template-card-name { font-size: 0.95rem; font-weight: 700; }
.template-card-meta { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.template-delete { background: none; border: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 4px 8px; }

/* LIBRARY */
.library-item {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  border: 1px solid #ffffff10;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.library-item-info { flex: 1; }
.library-item-name { font-size: 0.95rem; font-weight: 600; }
.library-item-meta { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.library-item-cost { color: var(--green); font-weight: 700; font-size: 0.9rem; }

/* BOTTOM NAV */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid #ffffff15;
  display: flex;
  z-index: 30;
  max-width: 480px;
  margin: 0 auto;
}

.nav-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  padding: 10px 8px;
  font-size: 0.65rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.nav-btn .nav-icon { font-size: 1.3rem; }
.nav-btn.active { color: var(--accent); }

.share-btn {
  position: fixed;
  bottom: 80px;
  left: 24px;
  background: var(--card);
  border: none;
  color: var(--text);
  border-radius: 30px;
  padding: 12px 18px;
  font-size: 0.85rem;
  cursor: pointer;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
}

.loading { text-align: center; color: var(--muted); padding: 40px; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty .icon { font-size: 3rem; margin-bottom: 12px; }

.section-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
  margin-top: 4px;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.divider { height: 1px; background: #ffffff10; margin: 4px 0; }
