@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&family=Public+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg: #F1F5F2;
  --surface: #FFFFFF;
  --border: #E3EAE4;
  --ink: #16231C;
  --muted: #63756A;
  --accent: #2D6A4F;
  --accent2: #E1A33D;
  --success: #0E8A63;
  --danger: #C0392B;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-btn: 13px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 32px;
  --font-heading: 'Space Grotesk', sans-serif;
  --font-body: 'Public Sans', sans-serif;
  --shadow-card: 0 2px 10px rgba(22,35,28,.06);
  --shadow-card-active: 0 6px 20px rgba(45,106,79,.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: auto;
  overscroll-behavior-x: none;
  overflow-x: hidden; /* safety net: no element should ever be able to push the page sideways */
  max-width: 100vw;
}

body { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }

h1, h2, h3 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 var(--space-sm);
  color: var(--ink);
}

p { margin: 0 0 var(--space-md); color: var(--muted); }

#app { min-height: 100vh; display: flex; flex-direction: column; }

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--space-md) var(--space-md) var(--space-lg);
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px var(--space-md);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h1 { font-size: 18px; }

.brand-logo {
  width: 34px;
  height: 34px;
  background-image: url('/app/icons/icon-192.svg?v=39');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  flex: none;
}

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

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  padding: var(--space-sm);
}

.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; flex: none; }

.field { margin-bottom: var(--space-md); }

.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.field input, .field select {
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-btn);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
}

.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--accent);
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 56px;
  padding: 0 20px;
  border-radius: var(--radius-btn);
  border: none;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  width: 100%;
}

.btn svg { width: 20px; height: 20px; stroke: currentColor; flex: none; }

.btn-primary { background: var(--accent); color: #FFFFFF; }
.btn-primary:active { opacity: 0.88; }
.btn-secondary { background: var(--surface); color: var(--ink); border: 1.5px solid var(--border); box-shadow: var(--shadow-card); }
.btn-secondary:active { background: #FAFBFA; }
.btn:disabled { opacity: 0.5; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  padding: var(--space-sm);
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: var(--space-sm);
}

.card-badge {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex: none;
}

.card-icon {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(45,106,79,0.1);
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.card-icon svg { width: 16px; height: 16px; stroke: var(--accent); }

.card h3 { font-size: 14.5px; margin: 0; }

/* Job list */
.job-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-sm); }

.job-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: var(--space-md);
  cursor: pointer;
}

.job-card.active { box-shadow: var(--shadow-card-active); }

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

.job-card h3 { font-size: 16px; margin: 0; }

.badge {
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-scheduled { background: rgba(99,117,106,0.12); color: var(--muted); }
.badge-in_progress { background: rgba(225,163,61,0.16); color: #A6740E; }
.badge-done { background: rgba(14,138,99,0.12); color: var(--success); }

.job-card .address { font-size: 14px; color: var(--muted); margin: 0; display: flex; align-items: center; gap: 6px; }
.job-card .address svg { width: 14px; height: 14px; stroke: var(--muted); flex: none; }

.job-detail-section { margin-bottom: var(--space-md); }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-sm); margin-top: var(--space-sm); }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); cursor: pointer; }
.photo-thumb-wrap { position: relative; }
.photo-delete-btn {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px;
  background: rgba(22,35,28,.75);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer; padding: 0;
}
.photo-delete-btn svg { width: 12px; height: 12px; stroke: #fff; }
.lightbox-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.9);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.lightbox-overlay img { max-width: 100%; max-height: 100%; border-radius: 8px; object-fit: contain; }
.lightbox-close {
  position: absolute; top: 16px; right: 16px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,.15); border: none;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.lightbox-close svg { width: 20px; height: 20px; stroke: #fff; }
.photo-add {
  aspect-ratio: 1;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  cursor: pointer;
  background: #FAFBFA;
}
.photo-add svg { width: 26px; height: 26px; stroke: var(--muted); }

.equip-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}
.equip-row:last-child { border-bottom: none; }
.equip-check {
  width: 24px; height: 24px;
  border-radius: 7px;
  border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  flex: none;
  cursor: pointer;
  background: var(--surface);
}
.equip-check.checked { background: var(--accent); border-color: var(--accent); }
.equip-check svg { width: 15px; height: 15px; stroke: #fff; opacity: 0; }
.equip-check.checked svg { opacity: 1; }

.bottom-actions { position: sticky; bottom: 0; background: var(--bg); padding-top: var(--space-md); margin-top: auto; display: flex; flex-direction: column; gap: var(--space-sm); }

.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--muted); gap: var(--space-sm); }
.empty-state svg { width: 40px; height: 40px; stroke: var(--muted); opacity: 0.6; }

.spinner { width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.map-link { display: flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 600; font-size: 14px; text-decoration: none; margin-top: 8px; }
.map-link svg { width: 15px; height: 15px; stroke: currentColor; }

/* Toasts */
.toast-wrap { position: fixed; left: 16px; right: 16px; bottom: 20px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: 480px; margin: 0 auto; pointer-events: none; }
.toast {
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  opacity: 0;
  transform: translateY(12px);
  transition: .25s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }
.toast svg { width: 18px; height: 18px; stroke: currentColor; flex: none; }


@media print {
  .topbar, .toast-wrap { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
