/* Spray Irrigation Co. — field & client app design system
   Tokens match sprayirrigationco.com so the app reads as the same company. */
:root {
  --green: #5C7020;
  --green-mid: #88A031;
  --green-light: #A8C248;
  --green-pale: #F4F8DC;
  --green-wash: #F8FBE8;
  --clay: #8B5E3C;
  --clay-light: #B8845A;
  --clay-pale: #F5EEE4;
  --gold: #C9953A;
  --gold-pale: #FBF3E0;
  --water: #78A6BF;
  --water-deep: #4A7088;
  --water-pale: #EDF3F6;
  --red: #B23A2E;
  --red-pale: #FBECE9;
  --cream: #FAF8F4;
  --cream-dark: #F0EBE0;
  --line: #E4E0D4;
  --line-strong: #D3CDBE;
  --midnight: #0F1C14;
  --slate: #2A3A2E;
  --stone: #5C6B5E;
  --stone-light: #8FA090;
  --white: #FFFFFF;

  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-mono: 'DM Mono', 'SF Mono', Consolas, monospace;

  --r-sm: 8px;
  --r: 14px;
  --r-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(15,28,20,.06), 0 2px 8px rgba(15,28,20,.04);
  --shadow-md: 0 8px 32px rgba(15,28,20,.10);
  --shadow-lg: 0 24px 64px rgba(15,28,20,.16);
  --ease: cubic-bezier(.22,1,.36,1);
  --tap: 44px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--midnight);
  font: 400 16px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; display: block; }
a { color: var(--green); text-decoration-thickness: 1px; text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
p { margin: 0 0 .75em; }
:focus-visible { outline: 3px solid var(--green-light); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.display { font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em; }
.h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(26px, 6vw, 34px); letter-spacing: -.015em; }
.h2 { font-family: var(--font-display); font-weight: 700; font-size: 22px; }
.h3 { font-weight: 600; font-size: 17px; }
.label {
  font: 500 11px/1.3 var(--font-mono);
  letter-spacing: .08em; text-transform: uppercase; color: var(--stone);
}
.muted { color: var(--stone); }
.small { font-size: 14px; }
.tiny { font-size: 12.5px; }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── layout ── */
.stack > * + * { margin-top: var(--gap, 12px); }
.row { display: flex; align-items: center; gap: var(--gap, 10px); }
.row.wrap { flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.spread { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
@media (max-width: 380px) { .grid3 { grid-template-columns: repeat(2, minmax(0,1fr)); } }

/* ── cards ── */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.card.flush { padding: 0; overflow: hidden; }
.card.tinted { background: var(--green-wash); border-color: #E3EBC0; }
.card.warn { background: var(--gold-pale); border-color: #EFDDB1; }
.card.alert { background: var(--red-pale); border-color: #EFC9C2; }
.card.water { background: var(--water-pale); border-color: #D3E2EA; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 26px 2px 10px; }
.section-title:first-child { margin-top: 4px; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--line); }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; min-height: 60px;
  color: inherit; text-decoration: none; background: none; border: 0; width: 100%; text-align: left; cursor: pointer;
}
a.list-item:active, button.list-item:active { background: var(--cream); }
.list-item .chev { color: var(--stone-light); flex: none; }

/* ── buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px;
  border-radius: 999px; border: 1px solid transparent;
  background: var(--green); color: #fff;
  font-weight: 600; font-size: 15.5px; text-decoration: none; cursor: pointer;
  transition: transform .12s var(--ease), background .15s, box-shadow .15s;
  white-space: nowrap; user-select: none;
}
.btn:hover { background: #4E611A; }
.btn:active { transform: scale(.97); }
.btn[disabled], .btn.is-busy { opacity: .55; pointer-events: none; }
.btn.secondary { background: var(--white); color: var(--slate); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--cream); }
.btn.ghost { background: transparent; color: var(--green); padding: 0 10px; }
.btn.ghost:hover { background: var(--green-pale); }
.btn.clay { background: var(--clay); }
.btn.clay:hover { background: #774F31; }
.btn.danger { background: var(--white); color: var(--red); border-color: #E6C2BC; }
.btn.danger:hover { background: var(--red-pale); }
.btn.block { width: 100%; }
.btn.lg { min-height: 54px; font-size: 17px; padding: 0 24px; }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn.icon { width: var(--tap); padding: 0; }
.btn svg { width: 19px; height: 19px; flex: none; }

.icon-btn {
  width: var(--tap); height: var(--tap); display: inline-grid; place-items: center;
  border-radius: 12px; border: 0; background: transparent; color: var(--slate); cursor: pointer;
}
.icon-btn:hover { background: var(--cream-dark); }
.icon-btn svg { width: 22px; height: 22px; }

/* ── badges & chips ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font: 500 11.5px/1.4 var(--font-mono); letter-spacing: .04em; text-transform: uppercase;
  background: var(--cream-dark); color: var(--slate); white-space: nowrap;
}
.badge.green { background: var(--green-pale); color: var(--green); }
.badge.plan { background: var(--green); color: #fff; }
.badge.clay { background: var(--clay-pale); color: var(--clay); }
.badge.gold { background: var(--gold-pale); color: #8A6420; }
.badge.water { background: var(--water-pale); color: var(--water-deep); }
.badge.red { background: var(--red-pale); color: var(--red); }
.badge.dot::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 38px; padding: 0 15px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--white); color: var(--slate);
  font-weight: 500; font-size: 14.5px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.chip[aria-pressed="true"] { background: var(--midnight); border-color: var(--midnight); color: #fff; }

/* ── forms ── */
.field { display: block; }
.field > .label { display: block; margin: 0 0 6px 2px; }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 11px 14px;
  border: 1px solid var(--line-strong); border-radius: 12px; background: var(--white);
  font-size: 16px; /* keeps iOS from zooming */
  transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--green-mid); box-shadow: 0 0 0 3px rgba(136,160,49,.22); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235C6B5E' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 420px) { .form-grid { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--green); }
.hint { font-size: 13px; color: var(--stone); margin-top: 6px; }
.error-text { color: var(--red); font-size: 14px; }

.segmented { display: flex; background: var(--cream-dark); border-radius: 12px; padding: 4px; gap: 4px; }
.segmented button {
  flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: transparent;
  font-weight: 600; font-size: 14.5px; color: var(--stone); cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--white); color: var(--midnight); box-shadow: var(--shadow-sm); }

/* ── key/value ── */
.kv { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 9px 14px; margin: 0; }
.kv dt { font: 500 11.5px/1.6 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--stone); padding-top: 2px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.stat { padding: 14px 14px 12px; border-radius: var(--r); background: var(--white); border: 1px solid var(--line); }
.stat .num { font: 700 24px/1.1 var(--font-display); margin-top: 6px; }
.stat .sub { font-size: 12.5px; color: var(--stone); margin-top: 4px; }

/* ── avatar ── */
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--green-pale); color: var(--green); font-weight: 700; font-size: 15px;
}
.avatar.sm { width: 32px; height: 32px; font-size: 12.5px; }

/* ── sheet (bottom drawer on phones, dialog on desktop) ── */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 900; background: rgba(15,28,20,.42);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease;
}
.sheet {
  width: 100%; max-width: 560px; max-height: calc(100dvh - 28px - var(--safe-t));
  background: var(--cream); border-radius: 22px 22px 0 0;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: rise .26s var(--ease);
}
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 6px 20px; }
.sheet-head .h2 { flex: 1; font-size: 21px; }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 8px auto 0; }
.sheet-body { padding: 6px 20px 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 12px 20px calc(14px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--white); display: flex; gap: 10px; border-radius: 0; }
.sheet-foot .btn { flex: 1; }
@media (min-width: 720px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 22px; max-height: min(86vh, 860px); }
  .sheet-foot { border-radius: 0 0 22px 22px; }
  .sheet-grip { display: none; }
}
@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } }

/* ── toast ── */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(86px + var(--safe-b)); z-index: 1000; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  pointer-events: auto; max-width: 480px;
  background: var(--midnight); color: #fff; border-radius: 14px; padding: 12px 16px;
  font-size: 15px; box-shadow: var(--shadow-md); animation: rise .22s var(--ease);
  display: flex; gap: 10px; align-items: center;
}
.toast.error { background: var(--red); }
.toast.ok::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--green-light); flex: none; }

/* ── empty / loading ── */
.empty { text-align: center; padding: 34px 18px; color: var(--stone); }
.empty .h3 { color: var(--slate); margin-bottom: 4px; }
.skeleton { background: linear-gradient(90deg, var(--cream-dark), #F6F2EA, var(--cream-dark)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--line-strong); border-top-color: var(--green); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── photos ── */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photo-thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--cream-dark); border: 0; padding: 0; cursor: zoom-in; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb .lock { position: absolute; top: 6px; left: 6px; background: rgba(15,28,20,.72); color: #fff; border-radius: 6px; font-size: 10.5px; padding: 1px 6px; font-family: var(--font-mono); }
.lightbox { position: fixed; inset: 0; z-index: 1100; background: rgba(8,14,10,.94); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.lightbox img { max-height: 86vh; border-radius: 8px; }
.lightbox figcaption { color: #E9EFE6; text-align: center; margin-top: 10px; font-size: 15px; }
.lightbox .close { position: absolute; top: calc(10px + var(--safe-t)); right: 10px; color: #fff; }

/* ── conversation ── */
.thread { display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 86%; padding: 10px 14px; border-radius: 18px; font-size: 15.5px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.them { align-self: flex-start; background: var(--white); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.bubble.us { align-self: flex-end; background: var(--green); color: #fff; border-bottom-right-radius: 6px; }
.bubble.system { align-self: center; background: transparent; color: var(--stone); font-size: 13.5px; text-align: center; padding: 2px 10px; }
.bubble-meta { font-size: 11.5px; color: var(--stone); margin: -4px 6px 0; }
.bubble-meta.us { align-self: flex-end; }
.quote-card { align-self: stretch; border: 1px solid var(--line); background: var(--white); border-radius: 16px; overflow: hidden; }
.quote-card .qc-head { background: var(--green-wash); padding: 10px 14px; border-bottom: 1px solid var(--line); }
.quote-options { display: grid; grid-template-columns: 1fr 1fr; }
.quote-options > div { padding: 14px; }
.quote-options > div + div { border-left: 1px solid var(--line); }
.quote-options .price { font: 700 22px/1.1 var(--font-display); margin: 4px 0; }

/* ── map ── */
.map { width: 100%; background: #DDE3D8; border-radius: var(--r); overflow: hidden; z-index: 0; }
.leaflet-container { font-family: var(--font-body); }
.pin {
  width: 30px; height: 30px; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg);
  display: grid; place-items: center; border: 2.5px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.pin span { transform: rotate(45deg); color: #fff; font: 700 12.5px/1 var(--font-mono); }
.pin.sm { width: 16px; height: 16px; border-width: 2px; border-radius: 50%; }
.pin.sm span { display: none; }
.pin.ghost { opacity: .55; }
.leaflet-popup-content { margin: 12px 14px; font-size: 14.5px; line-height: 1.45; }
.leaflet-popup-content-wrapper { border-radius: 14px; }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--slate); }
.map-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }

/* ── misc ── */
.divider { height: 1px; background: var(--line); margin: 14px 0; border: 0; }
.callout { display: flex; gap: 12px; align-items: flex-start; }
.callout svg { width: 22px; height: 22px; flex: none; margin-top: 1px; }
.progress { height: 8px; background: var(--cream-dark); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--green-mid); border-radius: 99px; }
.dot-sep::before { content: '·'; margin: 0 6px; color: var(--stone-light); }
.urgent-pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.empty .h2 { color: var(--midnight); }
svg.chev { flex: none; }
