/* Spark Pest Control — WDI Inspector portal. Vanilla CSS, no build step.
   Brand system: steel blue = structure, lime = action/attention,
   white/off-white = space, charcoal = readability. */
:root {
  --brand: #315B7D;        /* steel blue — nav, headers, primary elements */
  --brand-dark: #203E57;   /* dark navy — darker headers, hover states */
  --brand-soft: #E4EBF2;   /* light steel tint — subtle branded backgrounds */
  --lime: #A8D32A;         /* spark lime — PRIMARY actions only, never large areas */
  --lime-dark: #86AA22;    /* lime hover / darker accent states */
  --lime-soft: #F3F8E1;    /* light lime tint — success backgrounds */
  --white: #FFFFFF;        /* cards, forms, content areas */
  --bg: #F7F9FA;           /* off-white page background */
  --border: #E8ECEF;       /* light gray — borders, dividers, inputs */
  --ink: #29343D;          /* charcoal — body text */
  --muted: #5F6E7A;        /* cool gray — secondary text */
  --danger: #C0392B;       /* restrained red — destructive only */
  --danger-soft: #FBEDEB;
  --warn: #8A5A00;
  --warn-soft: #FDF3E0;
  --radius: 12px;
  --header-h: 58px;
  --shadow: 0 1px 3px rgba(32, 62, 87, 0.10);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  overflow-x: clip; /* backstop: never allow horizontal page scroll */
}

/* ---------- header ---------- */
#site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--brand-dark);
  color: #fff;
  box-shadow: var(--shadow);
}
.header-inner {
  height: var(--header-h);
  max-width: 960px;
  margin: 0 auto;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 17px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}
.brand-logo {
  height: 30px;
  width: auto;
  display: block;
  flex: none;
}
.mainnav { display: flex; gap: 4px; }
.mainnav a {
  color: #C9D8E3;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 15px;
}
.mainnav a.active { background: var(--brand); color: #fff; font-weight: 600; }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.userbox .btn { white-space: nowrap; flex: none; }
.username { font-size: 14px; color: #C9D8E3; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- layout ---------- */
.container { max-width: 960px; margin: 0 auto; padding: 12px 12px 96px; }
.page-head { display: flex; align-items: center; gap: 10px; margin: 6px 0 12px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; flex: 1; min-width: 160px; color: var(--brand-dark); }
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
  overflow-wrap: break-word;
}
.card h2 { font-size: 18px; margin: 0 0 4px; color: var(--brand-dark); }
.card h3 { font-size: 16px; margin: 18px 0 8px; color: var(--brand-dark); }
.card h3:first-child { margin-top: 0; }
.section-sub { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- buttons ----------
   Primary = lime bg + dark-navy text (never white on lime).
   Secondary = steel blue bg + white text. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  background: var(--lime);
  color: var(--brand-dark);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--lime-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { background: #C9D2D8; color: #7A8894; cursor: not-allowed; opacity: 1; }
.btn-secondary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-secondary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); min-height: 40px; padding: 6px 12px; font-size: 14px; }
.btn-ghost:hover { background: rgba(255,255,255,.12); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #A93226; }
.btn-danger-outline { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn-sm { min-height: 40px; padding: 8px 14px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.split-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.split-head h2 { margin: 0; }

/* ---------- forms ---------- */
label.f-label { display: block; font-weight: 600; font-size: 15px; margin: 14px 0 6px; color: var(--ink); }
label.f-label .req { color: var(--danger); }
.hint { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="number"], select, textarea {
  width: 100%;
  font-size: 16px; /* prevents iOS zoom */
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  min-height: 48px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
input:disabled, select:disabled, textarea:disabled { background: #EFF2F4; color: var(--muted); }
.f-row { display: grid; gap: 0 12px; }
@media (min-width: 640px) { .f-row.two { grid-template-columns: 1fr 1fr; } }

.radio-row, .check-row {
  display: flex; align-items: center; gap: 10px;
  min-height: 48px; padding: 8px 4px;
}
.radio-row input, .check-row input {
  width: 24px; height: 24px; min-height: 0; flex: none;
  accent-color: var(--brand); margin: 0;
}
.radio-row label, .check-row label { font-weight: 500; }
.checkgrid { display: grid; grid-template-columns: 1fr; gap: 2px; }
@media (min-width: 520px) { .checkgrid.two-col { grid-template-columns: 1fr 1fr; } }
.checkgrid .check-row { border-bottom: 1px solid var(--bg); }

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
}
.badge.draft { background: var(--warn-soft); color: var(--warn); }
.badge.submitted { background: var(--lime); color: var(--brand-dark); }
.badge.demo { background: var(--brand-soft); color: var(--brand-dark); }

/* ---------- dashboard list ---------- */
.filter-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.filter-tabs .btn { flex: 1 1 0; min-width: 0; background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.filter-tabs .btn:hover { background: var(--brand-soft); }
.filter-tabs .btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.insp-list { display: grid; gap: 10px; }
.insp-row {
  display: block; background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; text-decoration: none; color: inherit;
  box-shadow: var(--shadow);
}
.insp-row:active { background: #F2F6F9; }
.insp-row .row-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.insp-row .cust { font-weight: 700; font-size: 16px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.insp-row .addr { color: var(--muted); font-size: 14px; margin-bottom: 4px; }
.insp-row .meta { font-size: 13px; color: var(--muted); }
/* Admin-only delete, nested in the row link: compact destructive target. */
.row-del {
  flex: none; width: 40px; height: 40px; border-radius: 10px;
  background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger);
  font-size: 22px; font-weight: 700; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.row-del:hover { background: var(--danger); color: #fff; }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }

/* ---------- TARF ---------- */
.tarf-item {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px;
  background: #fff;
}
.tarf-item.urgent { border-left: 6px solid var(--danger); }
.tarf-item.soon { border-left: 6px solid var(--warn); }
.tarf-item .info { flex: 1; min-width: 180px; overflow-wrap: anywhere; }
.tarf-due { font-weight: 700; color: var(--brand-dark); }

/* ---------- admin ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 560px; }
table.data th, table.data td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
table.data th { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .4px; }

/* ---------- inspection section nav ---------- */
.secnav {
  position: sticky; top: var(--header-h); z-index: 50;
  background: var(--bg);
  padding: 8px 12px;
  display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, #000 88%, transparent 100%);
  mask-image: linear-gradient(to right, #000 88%, transparent 100%);
}
.secnav::-webkit-scrollbar { display: none; }
.secnav a {
  flex: none; padding: 10px 14px; border-radius: 999px;
  background: var(--white); border: 1px solid var(--border);
  color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow);
}
.secnav a.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.form-section { scroll-margin-top: calc(var(--header-h) + 60px); }
.sec-title { display: flex; align-items: center; gap: 10px; }
.sec-num {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-dark);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px;
}
.save-state { font-size: 13px; color: var(--muted); margin-left: auto; white-space: nowrap; }
.save-state.saving { color: var(--warn); }
.save-state.error { color: var(--danger); font-weight: 700; }

/* ---------- dynamic rows ---------- */
.dyn-row {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px;
  margin-bottom: 10px; background: #FBFCFD; position: relative;
}
.dyn-row .row-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.dyn-row .row-title { font-weight: 700; font-size: 15px; color: var(--brand-dark); }
.remove-btn {
  background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger);
  border-radius: 8px; min-width: 44px; min-height: 44px; font-size: 18px; font-weight: 700; cursor: pointer;
}
.add-btn { width: 100%; margin-top: 4px; }

/* ---------- quote table (legacy, kept for reference) ---------- */
.quote-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
table.quote { width: 100%; border-collapse: collapse; min-width: 640px; }
table.quote th { font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); text-align: left; padding: 8px 6px; border-bottom: 2px solid var(--border); }
table.quote td { padding: 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.quote input { min-height: 44px; padding: 8px 10px; }
table.quote .amt { font-weight: 700; white-space: nowrap; text-align: right; }
.quote-total { text-align: right; font-size: 18px; font-weight: 800; margin-top: 10px; color: var(--brand-dark); border-top: 3px solid var(--lime); padding-top: 10px; }

/* ---------- quote builder ---------- */
.reco-hint { background: #F2F7E4; border: 1px solid #D7E5B0; border-left: 4px solid var(--lime); border-radius: 8px; padding: 10px 12px; }
.svc-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 14px; }
.svc-btn { padding: 12px 6px; font-size: 14px; }
.qb-row { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.qb-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.qb-head strong { color: var(--brand-dark); font-size: 16px; }
.qb-remove { border: none; background: none; color: var(--muted); font-size: 22px; line-height: 1; padding: 4px 8px; cursor: pointer; border-radius: 8px; }
.qb-remove:hover { background: var(--bg); color: #C0392B; }
.qb-row .f-label { display: block; margin-bottom: 4px; }
.qb-row input { min-height: 44px; }
.qb-hint { font-size: 13px; color: var(--muted); margin: 6px 0; }
.qb-math { font-weight: 700; color: var(--brand); font-size: 15px; margin: 8px 0 2px; overflow-wrap: anywhere; }
.qb-note { font-size: 13px; color: var(--muted); margin: 4px 0 2px; overflow-wrap: anywhere; }
.qb-amount { font-weight: 800; color: var(--brand-dark); font-size: 16px; margin-top: 6px; }
.qb-custom-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.qb-custom-grid .f-label:first-child { grid-column: 1 / -1; }
.qb-warn { background: #FFF8E1; border: 1px solid #F0D97A; border-left: 4px solid #D9A900; border-radius: 8px; padding: 10px 12px; margin: 8px 0; font-size: 14px; color: #5c4a00; }
.qb-flag { background: #EAF3FB; border: 1px solid #C9D6E2; border-left: 4px solid var(--brand); border-radius: 8px; padding: 10px 12px; margin: 8px 0; font-size: 14px; color: var(--brand-dark); }
@media (max-width: 480px) {
  .svc-picker { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- gallery ---------- */
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
@media (min-width: 640px) { .gallery { grid-template-columns: repeat(4, 1fr); } }
.g-item { position: relative; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #000; aspect-ratio: 1; }
.g-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.g-del {
  position: absolute; top: 4px; right: 4px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(192, 57, 43, .92); color: #fff; border: none;
  font-size: 20px; font-weight: 700; cursor: pointer;
}
.file-label {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px; border-radius: 10px;
  background: #fff; color: var(--brand-dark); border: 1px solid var(--brand);
  font-weight: 600; cursor: pointer; font-size: 16px;
}
input[type="file"].hidden-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }

/* ---------- sketch / signature pads ---------- */
.pad-wrap { border: 2px dashed var(--border); border-radius: 10px; background: #fff; overflow: hidden; margin-top: 8px; }
canvas.pad { display: block; width: 100%; touch-action: none; cursor: crosshair; }
.pad-actions { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- aerial view (satellite background for sketch pad) ---------- */
.aerial-box { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin: 10px 0; background: var(--bg); }
.aerial-box .f-label { margin-bottom: 4px; }
.aerial-row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.aerial-row input { flex: 1 1 200px; min-width: 0; }
#aerial-zoom-out, #aerial-zoom-in { min-width: 44px; }
#aerial-status { margin: 8px 0 0; }
#aerial-status:empty { display: none; }
#aerial-attrib { margin: 8px 0 0; }
.link-btn { background: none; border: none; color: var(--brand); text-decoration: underline; cursor: pointer; font-size: 14px; padding: 10px 4px; }
canvas.pad.aerial-on { background-size: 100% 100%; background-repeat: no-repeat; }
.sig-preview { max-width: 100%; border: 1px solid var(--border); border-radius: 8px; background: #fff; margin-top: 8px; }

/* ---------- review ---------- */
.kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 6px 12px; font-size: 15px; }
.kv dt { color: var(--muted); font-weight: 600; min-width: 0; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.warn-list { background: var(--warn-soft); border: 1px solid #EBD9A8; border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.warn-list li { margin-bottom: 4px; }
.ok-list { background: var(--lime-soft); border: 1px solid #D9E4A8; border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; color: var(--ink); }
.banner {
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px;
  border: 1px solid var(--border); background: var(--white); box-shadow: var(--shadow);
  overflow-wrap: break-word;
}
.banner.submitted { border-left: 6px solid var(--lime); }
.dl-links { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- login ---------- */
.login-wrap { max-width: 420px; margin: 8vh auto 0; padding: 0 12px; }
.login-wrap .card { border-top: 4px solid var(--lime); }
.login-logo-band {
  background: var(--brand-dark);
  margin: -16px -16px 16px;
  padding: 18px 16px;
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
  display: flex;
  justify-content: center;
}
.login-logo-band img { height: 54px; width: auto; display: block; }
.login-logo-band { flex-direction: column; align-items: center; gap: 8px; }
.login-portal-name { color: var(--lime); font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.login-hint { background: var(--brand-soft); border: 1px solid #C9D6E2; border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-top: 14px; }
.login-hint code { background: #fff; padding: 1px 6px; border-radius: 4px; font-weight: 700; }

/* ---------- toast ---------- */
#toast-wrap {
  position: fixed; left: 12px; right: 12px; bottom: 16px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: #222; color: #fff; border-radius: 10px; padding: 12px 18px;
  font-size: 15px; max-width: 560px; width: 100%; text-align: center;
  opacity: 0; transform: translateY(12px); transition: all .25s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--brand-dark); }

/* ---------- misc ---------- */
.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.cond-block { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 12px; background: #fff; }
.cond-block > .cond-head { font-weight: 700; font-size: 16px; margin-bottom: 4px; color: var(--brand-dark); }
.yesno { display: flex; gap: 16px; margin: 6px 0; }
.hidden { display: none !important; }
.center { text-align: center; }
.mt { margin-top: 14px; }

/* ---------- small screens ---------- */
@media (max-width: 480px) {
  /* Full-width primary button under the page title — never truncated */
  .page-head .btn { flex: 1 1 100%; }
  /* Filter tabs: fit three across without clipping */
  .filter-tabs { gap: 6px; }
  .filter-tabs .btn { padding: 10px 6px; font-size: 15px; }
  /* Tighter review grid on narrow screens */
  .kv { grid-template-columns: 118px minmax(0, 1fr); }
  .username { max-width: 84px; }
  .header-inner { gap: 8px; padding: 0 10px; }
  .mainnav a { padding: 10px 8px; }
  /* Compact logo on small screens — leaves room for username + Log out */
  .brand-logo { height: 26px; }
  #logout-btn { white-space: nowrap; flex: none; }
}
