:root {
  --green: #8DC63F;
  --orange: #F47920;
  --charcoal: #414042;
  --light-green: #E8F5D0;
  --olive: #8a7a30;
  --border: #e2e2e2;
  --bg: #fafafa;
  --danger: #c0392b;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--charcoal);
  background: var(--bg);
}
a { color: inherit; text-decoration: none; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
}

/* ---------- Header ---------- */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; background: white; border-bottom: 3px solid var(--green);
  position: sticky; top: 0; z-index: 20;
}
.app-header-brand { display: flex; align-items: center; gap: 12px; }
.app-logo { height: 68px; width: 68px; object-fit: contain; border-radius: 10px; }
.app-header-titles { display: flex; flex-direction: column; line-height: 1.2; }
.app-name { font-weight: 800; font-size: 20px; color: var(--charcoal); }
.app-subtitle { font-weight: 400; font-size: 13px; color: #777; }
.app-tagline { font-style: italic; color: var(--olive); font-size: 13px; }
.user-switch {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); font-size: 14px;
  background: white;
}

/* ---------- Layout ---------- */
.app-content { max-width: 900px; margin: 0 auto; padding: 20px 16px 80px; }
.page-title { font-size: 22px; font-weight: 800; margin: 4px 0 16px; }
.page-subtitle { color: #777; margin: -12px 0 20px; font-size: 14px; }
.page-badge-row { margin: 0 0 20px; }
.back-link { display: inline-block; margin-bottom: 12px; color: var(--charcoal); font-weight: 600; }
.back-link::before { content: '← '; }

/* ---------- Nav tiles (Dashboard) ---------- */
.nav-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
@media (max-width: 640px) { .nav-tiles { grid-template-columns: repeat(2, 1fr); } }
.nav-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 18px 8px; border-radius: var(--radius); background: white;
  border: 1px solid var(--border); font-weight: 700; text-align: center; cursor: pointer;
  transition: transform .1s ease;
}
.nav-tile:active { transform: scale(0.97); }
.nav-tile-icon { font-size: 26px; }
.nav-tile-primary { background: var(--green); color: white; border-color: var(--green); }

/* ---------- Cards ---------- */
.card { background: white; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card-title { font-weight: 700; margin-bottom: 12px; font-size: 15px; }

/* ---------- Job list ---------- */
.filter-tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-tab {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border); background: white;
  cursor: pointer; font-size: 14px; font-weight: 600; color: #666;
}
.filter-tab.active { background: var(--charcoal); color: white; border-color: var(--charcoal); }
.job-row {
  display: flex; align-items: center; gap: 12px; background: white; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
}
.job-row:hover { border-color: var(--green); }
.crew-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.job-row-main { flex: 1; min-width: 0; }
.job-row-name { font-weight: 700; }
.job-row-address { color: #777; font-size: 13px; }
.job-row-meta { display: flex; align-items: center; gap: 10px; font-size: 12px; color: #999; }
.job-row-detail { display: none; padding: 10px 14px 4px; font-size: 13px; }
.job-row-detail.open { display: block; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge-estimate { background: #FFE9D6; color: #b45309; }
.badge-contract { background: var(--light-green); color: #4b6b1f; }
.badge-in_progress { background: #dbeafe; color: #1e40af; }
.badge-complete { background: #d1fae5; color: #065f46; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; border-radius: 10px; border: none; font-weight: 700; font-size: 15px;
  cursor: pointer;
}
.btn-primary { background: var(--orange); color: white; }
.btn-primary:active { opacity: 0.85; }
.btn-secondary { background: var(--charcoal); color: white; }
.btn-green { background: var(--green); color: white; }
.btn-ghost { background: #eee; color: var(--charcoal); }
.btn-danger { background: var(--danger); color: white; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* ---------- Forms ---------- */
label.field { display: block; margin-bottom: 12px; font-size: 13px; font-weight: 600; color: #555; }
.field input[type=text], .field input[type=email], .field input[type=tel], .field input[type=number],
.field input[type=date], .field select, .field textarea {
  display: block; width: 100%; margin-top: 5px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); font-size: 15px; font-family: inherit;
}
.field textarea { resize: vertical; min-height: 70px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .field-row-3 { grid-template-columns: 1fr; } }

/* ---------- Chips / checkboxes ---------- */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 14px; }
.chip {
  padding: 7px 13px; border-radius: 999px; border: 1px solid var(--border); background: white;
  font-size: 13px; cursor: pointer; font-weight: 600;
}
.chip-selected { background: var(--light-green); border-color: var(--green); color: #4b6b1f; }
.checkbox-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin-bottom: 8px; }
@media (max-width: 560px) { .checkbox-grid { grid-template-columns: 1fr; } }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 5px 0; }
.checkbox-row input { width: 17px; height: 17px; }

/* ---------- Wizard ---------- */
.wizard-steps { display: flex; gap: 6px; margin-bottom: 18px; }
.wizard-step-dot {
  flex: 1; height: 6px; border-radius: 4px; background: var(--border);
}
.wizard-step-dot.done { background: var(--green); }
.wizard-step-dot.active { background: var(--orange); }
.wizard-step-label { font-size: 13px; color: #777; margin-bottom: 4px; }

/* ---------- Line items ---------- */
.line-item {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
  background: #fff;
}
.line-item-header { display: flex; justify-content: space-between; align-items: center; }
.line-item-title { font-weight: 700; }
.line-item-total { font-weight: 800; color: var(--charcoal); }
.line-item-sub { color: #777; font-size: 13px; margin-top: 2px; }
.line-item-remove { color: var(--danger); font-size: 13px; cursor: pointer; font-weight: 600; }

.room-table, .component-table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.room-table th, .component-table th { text-align: left; font-size: 12px; color: #888; padding: 4px 6px; }
.room-table td, .component-table td { padding: 4px 6px; }
.room-table input, .component-table input, .room-table select, .component-table select {
  width: 100%; padding: 7px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px;
}
.room-table .num-col, .component-table .num-col { width: 80px; }
.room-table .remove-col, .component-table .remove-col { width: 30px; text-align: center; }

.addon-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 10px; margin: 10px 0; }
@media (max-width: 640px) { .addon-grid { grid-template-columns: repeat(2, 1fr); } }

.total-bar {
  display: flex; justify-content: space-between; align-items: center; font-size: 18px;
  font-weight: 800; padding: 14px 0; border-top: 2px solid var(--charcoal); margin-top: 6px;
}
.customer-preview {
  background: var(--light-green); border-radius: 10px; padding: 10px 14px; font-size: 14px;
  margin-top: 10px; color: #3f5a1a;
}

/* ---------- Signature pad ---------- */
.sig-pad-wrap { position: relative; border: 2px dashed var(--border); border-radius: 10px; overflow: hidden; }
.sig-pad-canvas { width: 100%; height: 180px; display: block; touch-action: none; background: white; }
.sig-pad-line { position: absolute; bottom: 10px; left: 14px; color: #bbb; font-size: 12px; pointer-events: none; }
.sig-pad-clear { margin-top: 8px; }

/* ---------- Disclaimers ---------- */
.disclaimer-box { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: #fff; }
.disclaimer-box h4 { margin: 0 0 6px; font-size: 14px; color: var(--charcoal); }
.disclaimer-box p { margin: 0; font-size: 13px; color: #555; white-space: pre-line; line-height: 1.5; }

/* ---------- Rating stars/numbers ---------- */
.rating-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.rating-buttons { display: flex; gap: 6px; }
.rating-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: white;
  font-weight: 700; cursor: pointer;
}
.rating-btn.selected { background: var(--orange); color: white; border-color: var(--orange); }

/* ---------- Photos ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 560px) { .photo-grid { grid-template-columns: repeat(2, 1fr); } }
.photo-slot {
  aspect-ratio: 1; border: 2px dashed var(--border); border-radius: 10px; display: flex;
  align-items: center; justify-content: center; overflow: hidden; position: relative; background: #f4f4f4;
  cursor: pointer;
}
.photo-slot img { width: 100%; height: 100%; object-fit: cover; }
.photo-slot-label { color: #999; font-size: 13px; text-align: center; }
.photo-slot-remove {
  position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,0.6); color: white; border: none;
  border-radius: 50%; width: 22px; height: 22px; cursor: pointer;
}

/* ---------- Toggle switch ---------- */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.toggle-row:last-child { border-bottom: none; }
.switch { position: relative; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute; inset: 0; background: #ccc; border-radius: 999px; cursor: pointer; transition: .15s;
}
.switch-track::before {
  content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: white;
  border-radius: 50%; transition: .15s;
}
.switch input:checked + .switch-track { background: var(--green); }
.switch input:checked + .switch-track::before { transform: translateX(20px); }

/* ---------- Tabs (Settings, Pricing categories) ---------- */
.tab-bar { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab-btn { padding: 10px 16px; font-weight: 700; color: #888; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab-btn.active { color: var(--charcoal); border-bottom-color: var(--orange); }

/* ---------- Pricing table ---------- */
.price-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.price-table th { text-align: left; padding: 8px 6px; color: #888; font-size: 12px; border-bottom: 1px solid var(--border); }
.price-table td { padding: 8px 6px; border-bottom: 1px solid #f0f0f0; }
.price-table input { width: 90px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; }
.contractor-tag { background: #FFF4E5; color: #92600a; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; margin-left: 6px; }
.collapsible-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; padding: 12px 0; font-weight: 700; }
.collapsible-body { display: none; }
.collapsible-body.open { display: block; }
.search-input { width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 15px; margin-bottom: 16px; }

/* ---------- Toast / modal ---------- */
.toast {
  position: fixed; bottom: -80px; left: 50%; transform: translateX(-50%); background: var(--charcoal);
  color: white; padding: 12px 20px; border-radius: 10px; font-size: 14px; max-width: 90vw; text-align: center;
  transition: bottom .25s ease; z-index: 100; box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.toast-show { bottom: 24px; }
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center;
  justify-content: center; z-index: 200; padding: 20px;
}
.modal-card { background: white; border-radius: var(--radius); padding: 20px; max-width: 380px; width: 100%; }
.modal-message { margin: 0 0 16px; font-size: 15px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Misc ---------- */
.empty-state { text-align: center; color: #999; padding: 40px 20px; }
.section-divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.hint-text { font-size: 12px; color: #999; margin-top: -8px; margin-bottom: 12px; }
.internal-badge { background: #F0F0F0; color: #888; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
