:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --warn-bg: #fef3c7;
  --warn-text: #92400e;
  --bar: #0f172a;
  --bar-text: #f8fafc;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #020617;
    --surface: #0f172a;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --line: #1e293b;
    --accent: #3b82f6;
    --danger: #f87171;
    --warn-bg: #422006;
    --warn-text: #fcd34d;
    --bar: #020617;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}
main { max-width: 640px; margin: 0 auto; }
input, select, textarea, button { font: inherit; color: inherit; }
h3 { margin: 0 0 10px; font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.pad { padding: 12px 16px; }
.hint { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
.hint.warn { background: var(--warn-bg); color: var(--warn-text); border-radius: 10px; margin: 12px 16px 0; padding: 10px 12px; }
.muted { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 40px 16px; }
.spacer { height: 120px; }

/* Top bar */
.bar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  background: var(--bar); color: var(--bar-text);
}
.bar-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .btn.ghost { color: var(--bar-text); }
.who { background: transparent; border: 0; color: var(--bar-text); font-weight: 700; font-size: 18px; padding: 6px 0; max-width: 60vw; }
.who option { color: #0f172a; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text); text-decoration: none; cursor: pointer; font-weight: 600;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; border-color: transparent; padding: 0 8px; }
.btn.danger { color: var(--danger); }
.btn.big { width: 100%; min-height: 54px; font-size: 18px; }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--surface); margin: 12px 16px; border-radius: 14px; padding: 14px 16px; }

/* Bid list */
.list { padding: 0 16px 40px; }
.row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--surface); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px;
  color: inherit; text-decoration: none;
}
.row-main { min-width: 0; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--muted); font-size: 14px; }
.row-side { text-align: right; flex: none; }
.row-price { font-weight: 700; }
.row-price small { font-weight: 400; color: var(--muted); }
.chip {
  display: inline-block; font-size: 12px; font-weight: 600; text-transform: capitalize;
  padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
}
.chip.sent { color: #2563eb; }
.chip.won { color: #16a34a; }
.chip.lost { color: var(--muted); }
.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* Address search */
.search { position: relative; }
.search-row { display: flex; gap: 8px; }
.search input { flex: 1; min-width: 0; }
input[type=search], .field input, .field select, .field textarea, .custom-row input, .custom-row select {
  min-height: 44px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
}
.suggest {
  position: absolute; left: 16px; right: 16px; z-index: 1100;
  list-style: none; margin: 4px 0 0; padding: 4px; border-radius: 10px;
  background: var(--surface); box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.suggest li { padding: 12px; border-radius: 8px; cursor: pointer; }
.suggest li:active, .suggest li:hover { background: var(--bg); }

/* Map */
.mapwrap { position: relative; }
#map { height: 58vh; min-height: 320px; background: #1e293b; }
.maptools {
  position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 900;
  display: flex; flex-direction: column; gap: 6px; pointer-events: none;
}
.tool-row { display: flex; gap: 6px; pointer-events: auto; }
.tool {
  flex: 1; min-height: 46px; border-radius: 10px; border: 0; font-weight: 700; font-size: 14px;
  background: rgba(15, 23, 42, .85); color: #fff; border-bottom: 3px solid var(--c, transparent);
  backdrop-filter: blur(4px); cursor: pointer;
}
.tool.done { background: #16a34a; }
.tool:disabled { opacity: .45; }
.draw-msg {
  align-self: center; pointer-events: none;
  background: rgba(15, 23, 42, .85); color: #fff; font-weight: 700;
  padding: 6px 14px; border-radius: 999px; border: 2px solid var(--c);
}
.area-label {
  background: rgba(15, 23, 42, .75); color: #fff; border: 0; box-shadow: none;
  font-weight: 600; text-align: center; padding: 2px 6px;
}
.area-label::before { display: none; }

/* Measured areas */
.area {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border-radius: 10px; padding: 8px 8px 8px 12px; margin-bottom: 6px;
}
.swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--c); flex: none; }
.area-name { font-weight: 600; }
.area-size { margin-left: auto; font-variant-numeric: tabular-nums; }
.width { font-size: 14px; color: var(--muted); white-space: nowrap; }
.width input { width: 52px; min-height: 36px; padding: 4px 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.x { width: 40px; height: 40px; border: 0; background: transparent; font-size: 22px; color: var(--muted); cursor: pointer; flex: none; }

/* Form fields */
.field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.field input, .field select, .field textarea { color: var(--text); font-size: 16px; }
.field.inline { flex-direction: row; align-items: center; justify-content: space-between; }
.field.inline input { width: 90px; }
.field.rate { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.unit-wrap { display: flex; align-items: center; gap: 6px; flex: none; }
.unit-wrap input { width: 100px; text-align: right; }
.unit { width: 34px; color: var(--muted); font-size: 13px; }
.toggle { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.toggle input { width: 22px; height: 22px; }
.custom-row { display: flex; gap: 6px; margin-bottom: 8px; }
.custom-row input:first-child { flex: 1; min-width: 0; }
.custom-row input[type=number] { width: 80px; }
.custom-row select { width: 112px; }

/* Price bar */
.pricebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
  max-width: 640px; margin: 0 auto;
  background: var(--bar); color: var(--bar-text);
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
  border-radius: 16px 16px 0 0; box-shadow: 0 -6px 24px rgba(0,0,0,.25);
}
.price-empty { text-align: center; color: #94a3b8; padding: 8px; }
.price-sum {
  display: flex; align-items: flex-end; gap: 18px; width: 100%;
  background: none; border: 0; color: inherit; text-align: left; cursor: pointer; padding: 2px 4px;
}
.price-sum span { display: flex; flex-direction: column; font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.price-sum small { font-size: 12px; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: .05em; }
.price-sum .caret { margin-left: auto; font-size: 14px; font-weight: 600; color: #94a3b8; }
.price-detail { margin-top: 10px; border-top: 1px solid #334155; padding-top: 8px; max-height: 40vh; overflow-y: auto; }
.pl { display: flex; justify-content: space-between; gap: 12px; padding: 4px; font-size: 15px; }
.pl.head { margin-top: 6px; color: #94a3b8; font-size: 13px; text-transform: uppercase; }
.pl.note { color: #94a3b8; font-size: 13px; }

/* Customer quote */
.quote { background: #fff; color: #0f172a; margin: 12px 16px; border-radius: 14px; padding: 20px; }
.quote .muted { color: #64748b; }
.q-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; border-bottom: 2px solid #0f172a; padding-bottom: 12px; }
.q-biz { font-size: 22px; font-weight: 800; }
.q-contact { color: #64748b; font-size: 14px; }
.q-tag { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #64748b; text-align: right; }
.q-to { margin: 14px 0; }
.q-map { height: 220px; border-radius: 10px; margin-bottom: 12px; }
.q-services { font-size: 15px; margin-bottom: 14px; }
.q-prices { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 520px) { .q-prices { grid-template-columns: 1fr 1fr; } }
.q-option { border: 1px solid #e2e8f0; border-radius: 12px; padding: 14px; }
.q-option.best { border: 2px solid #2563eb; }
.q-opt-name { font-weight: 700; margin-bottom: 8px; }
.q-option table { width: 100%; border-collapse: collapse; }
.q-option td { padding: 5px 0; border-bottom: 1px solid #f1f5f9; }
.q-option td:last-child { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.q-big { font-size: 34px; font-weight: 800; }
.q-notes { margin-top: 14px; padding: 12px; background: #f8fafc; border-radius: 10px; white-space: pre-wrap; }
.actions { display: flex; flex-direction: column; gap: 10px; padding-bottom: 40px; }
.status-row { display: flex; gap: 8px; justify-content: center; margin-top: 6px; }
.status-row .chip { font-size: 14px; padding: 8px 14px; cursor: pointer; }

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .quote { margin: 0; padding: 0; }
}

/* Sync status, banners, toasts */
.sync-row { margin-top: 8px; text-align: center; font-size: 13px; }
.sync { color: var(--muted); text-decoration: none; }
.sync.ok { color: #16a34a; }
.sync.warn { color: var(--warn-text); }
.sync.off { color: var(--muted); text-decoration: underline; }
.banner { margin: 12px 16px 0; padding: 10px 12px; border-radius: 10px; background: var(--surface); font-size: 14px; }
.banner.ok { background: #dcfce7; color: #166534; font-weight: 600; }
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 90px); transform: translateX(-50%); z-index: 2000;
  background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 999px; font-weight: 600;
}
.center { text-align: center; }
.area-name small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.link { border: 0; background: none; color: var(--accent); text-decoration: underline; padding: 0; cursor: pointer; font-size: 12px; }
.toggle small { font-size: 12px; }

/* Customer's link page: always light, like paper */
body.customer { background: #f1f5f9; color: #0f172a; color-scheme: light; }
body.customer .card { background: #fff; }
body.customer .field input { background: #fff; border-color: #e2e8f0; color: #0f172a; }
body.customer .hint { color: #64748b; }
.accepted p { margin: 0; }
