:root {
  color-scheme: light;
  --ink: #16201d;
  --muted: #65726d;
  --line: #dfe6e2;
  --paper: #f4f5f0;
  --panel: #ffffff;
  --brand: #24695a;
  --brand-dark: #163f37;
  --accent: #c85f32;
  --safety: #c73a32;
  --ok: #1f7a56;
  --map: #91bd91;
  --shadow: 0 22px 50px rgba(33, 38, 34, .16);
}

body[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eef5f1;
  --muted: #aab8b2;
  --line: #34443f;
  --paper: #101715;
  --panel: #18221f;
  --brand: #4fb294;
  --brand-dark: #2f735f;
  --accent: #df7a4f;
  --safety: #ee746c;
  --ok: #62c999;
  --map: #385d4f;
  --shadow: 0 22px 50px rgba(0, 0, 0, .34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(135deg, rgba(36, 105, 90, .14), rgba(200, 95, 50, .12)), var(--paper);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: .7;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.phone {
  width: min(100%, 430px);
  height: min(900px, calc(100vh - 48px));
  min-height: 680px;
  background: var(--panel);
  border: 1px solid rgba(22, 32, 29, .12);
  border-radius: 30px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 10px;
  align-items: center;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.topbar h1 {
  margin: 0;
  font-size: 23px;
  line-height: 1.1;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  display: grid;
  place-items: center;
}

.hamburger {
  display: grid;
  gap: 4px;
  width: 18px;
}

.hamburger i {
  display: block;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.hidden {
  visibility: hidden;
}

.screen {
  overflow-y: auto;
  padding: 18px;
  background: #fbfcf8;
}

.bottom-nav {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(68px, 1fr);
  overflow-x: auto;
  border-top: 1px solid var(--line);
  background: #fff;
}

.bottom-nav button {
  min-height: 64px;
  min-width: 68px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  display: grid;
  place-items: center;
  gap: 2px;
}

.bottom-nav span {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #eef3ef;
  font-size: 12px;
}

.bottom-nav button.active {
  color: var(--brand);
}

.hero {
  min-height: 380px;
  display: grid;
  align-content: end;
  gap: 20px;
  padding: 28px 8px 8px;
}

.hero.compact {
  min-height: 190px;
  padding-top: 6px;
}

.brand-mark {
  width: 86px;
  height: 86px;
  border-radius: 24px;
  background: linear-gradient(145deg, var(--brand), var(--brand-dark));
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  font-size: 30px;
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, .14);
}

.hero h2 {
  font-size: 43px;
  line-height: .98;
  margin-bottom: 10px;
}

.hero p {
  color: var(--muted);
  line-height: 1.55;
}

.stack {
  display: grid;
  gap: 14px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.card,
.compare-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.role-card {
  text-align: left;
}

.card h3,
.compare-card h3 {
  margin-bottom: 6px;
  font-size: 16px;
}

.card p,
.compare-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.card > .button.full {
  margin-top: 12px;
}

.alert-card {
  border-color: rgba(200, 95, 50, .45);
  background: #fff8f2;
}

.button {
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 900;
  background: var(--brand);
  color: #fff;
}

.button.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.button.warning {
  background: var(--safety);
}

.button.full {
  width: 100%;
}

.mini-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.mini-actions .button {
  min-height: 38px;
  font-size: 12px;
}

.backend-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 5px;
}

.backend-card strong {
  font-size: 15px;
}

.backend-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.dev-panel {
  border: 1px dashed var(--accent);
  border-radius: 8px;
  background: rgba(200, 95, 50, .08);
  padding: 10px;
  display: grid;
  gap: 4px;
  font-size: 11px;
  color: var(--ink);
}

.dev-panel strong {
  font-size: 12px;
  font-weight: 900;
}

.dev-panel span {
  color: var(--muted);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  font-size: 13px;
  font-weight: 900;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 13px 12px;
  resize: vertical;
}

.upload-box,
.photo-card,
.portfolio-tile {
  min-height: 132px;
  border: 1px dashed #9db0a8;
  border-radius: 8px;
  background: linear-gradient(135deg, #eef5f1, #fff8f2);
  color: var(--ink);
  padding: 16px;
  text-align: left;
  display: grid;
  align-content: end;
  gap: 6px;
}

.upload-box span,
.photo-card span,
.portfolio-tile span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 900;
}

.chip.active {
  background: var(--brand-dark);
  color: #fff;
  border-color: var(--brand-dark);
}

.chip.static {
  display: inline-block;
  cursor: default;
}

.toggle-row {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.notice {
  border-left: 4px solid var(--safety);
  background: #fff1ef;
  padding: 13px;
  border-radius: 8px;
  color: #752424;
  font-size: 13px;
  line-height: 1.45;
}

.notice.ok {
  border-left-color: var(--ok);
  background: #eef8f2;
  color: #1d5d43;
}

.stat-row,
.bid-row,
.profile-row,
.planning-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.stat {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.value {
  font-size: 22px;
  font-weight: 900;
}

.value.small {
  font-size: 18px;
}

.estimate-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.estimate-grid div,
.planning-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcf8;
}

.estimate-grid span,
.planning-row span,
.compare-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.estimate-grid strong,
.planning-row strong,
.compare-card strong {
  font-size: 15px;
}

.planning-row {
  margin-top: 10px;
}

.map {
  position: relative;
  min-height: 360px;
  overflow: hidden;
  background:
    linear-gradient(90deg, transparent 47%, rgba(255,255,255,.95) 48% 52%, transparent 53%),
    linear-gradient(16deg, transparent 56%, rgba(255,255,255,.95) 57% 61%, transparent 62%),
    linear-gradient(126deg, transparent 36%, rgba(255,255,255,.9) 37% 41%, transparent 42%),
    var(--map);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.job-location-map {
  min-height: 270px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #d9e6de;
}

.mapbox-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 12px;
}

.mapbox-panel div {
  display: grid;
  gap: 5px;
}

.mapbox-panel span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.distance-panel strong {
  font-size: 14px;
}

.mapboxgl-ctrl {
  font-family: Inter, system-ui, sans-serif;
}

.contractor-map {
  min-height: 410px;
}

.contractor-hub-map {
  min-height: 500px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #d9e6de;
}

.contractor-work-pin {
  border: 0;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(0, 0, 0, .24);
  position: relative;
  display: grid;
  gap: 1px;
  min-width: 64px;
  text-align: center;
}

.contractor-work-pin.active {
  background: var(--brand-dark);
  outline: 3px solid rgba(255, 255, 255, .88);
}

.contractor-work-pin strong,
.contractor-work-pin span {
  display: block;
  line-height: 1.1;
}

.contractor-work-pin span {
  font-size: 10px;
  opacity: .9;
}

.contractor-work-pin::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 12px;
  height: 12px;
  background: inherit;
  transform: translateX(-50%) rotate(45deg);
}

.contractor-user-pin {
  width: 42px;
  height: 42px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(0, 0, 0, .24);
}

.pin {
  position: absolute;
  border: 0;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(0, 0, 0, .24);
}

.pin.active {
  background: var(--brand-dark);
  outline: 3px solid rgba(255, 255, 255, .88);
}

.pin::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 12px;
  height: 12px;
  background: inherit;
  transform: translateX(-50%) rotate(45deg);
}

.pin:nth-child(1) { left: 14%; top: 25%; }
.pin:nth-child(2) { left: 58%; top: 18%; }
.pin:nth-child(3) { left: 39%; top: 54%; }
.pin:nth-child(4) { left: 67%; top: 67%; }

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand-dark);
  color: #fff;
  font-weight: 900;
  flex: 0 0 auto;
}

.badge {
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.badge.certified {
  background: #e6f4ed;
  color: var(--ok);
}

.badge.general {
  background: #fff1df;
  color: #95501d;
}

.badge.warning {
  background: #ffe5e2;
  color: var(--safety);
}

.button.danger-light {
  color: var(--safety);
}

.progress {
  height: 10px;
  border-radius: 999px;
  background: #ecece6;
  overflow: hidden;
  margin-top: 12px;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--ok);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.tabs button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 900;
  font-size: 12px;
}

.tabs button.active {
  color: #fff;
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.live-board-strip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.live-board-strip strong,
.live-board-strip span {
  display: block;
}

.live-board-strip strong {
  font-size: 13px;
  font-weight: 900;
}

.live-board-strip span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
}

.live-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--ok);
  box-shadow: 0 0 0 6px rgba(31, 122, 86, .14);
  flex: 0 0 auto;
}

.portfolio-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.portfolio-tile {
  min-height: 92px;
}

.media-grid {
  display: grid;
  gap: 12px;
}

.media-card,
.portfolio-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.media-visual {
  width: 100%;
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: #eef5f1;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.media-visual img,
.media-visual video {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}

.media-placeholder,
.viewer-placeholder {
  min-height: 160px;
  padding: 16px;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 8px;
  color: var(--ink);
}

.media-placeholder span,
.viewer-placeholder span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.media-body {
  display: grid;
  gap: 4px;
}

.media-body span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.viewer-media {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 8px;
  background: #000;
}

.filter-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.job-preview {
  border-color: rgba(36, 105, 90, .34);
}

.bid-board-row {
  border-color: rgba(36, 105, 90, .26);
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcf8;
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.history-item p {
  margin-bottom: 0;
}

.estimate-grid.compact {
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 12px;
}

.estimate-grid.compact strong {
  font-size: 13px;
}

.compare-card {
  display: grid;
  grid-template-columns: 1fr 76px;
  gap: 10px;
  align-items: center;
}

.alert-list {
  display: grid;
  gap: 10px;
}

.alert-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.message-list {
  display: grid;
  gap: 10px;
}

.message-bubble {
  width: min(86%, 320px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 5px;
}

.message-bubble.mine {
  justify-self: end;
  background: #e9f5ef;
  border-color: rgba(36, 105, 90, .34);
}

.message-bubble p {
  margin-bottom: 0;
}

.message-bubble span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.alert-item strong {
  font-size: 14px;
}

.alert-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.alert-item.read {
  opacity: .68;
}

.image-preview {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.price-diff {
  border: 1px solid rgba(200, 95, 50, .36);
  background: #fff8f2;
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.price-diff p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(22, 32, 29, .48);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-layer.hidden,
.toast.hidden {
  display: none;
}

.modal-card {
  width: min(100%, 360px);
  border-radius: 12px;
  background: #fff;
  padding: 18px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.modal-card.media-viewer-card {
  width: min(96vw, 920px);
  max-height: 92vh;
  overflow-y: auto;
}

.modal-card h2 {
  margin-bottom: 0;
  font-size: 20px;
}

.modal-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.toast {
  position: fixed;
  z-index: 11;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(calc(100% - 32px), 390px);
  border-radius: 8px;
  background: var(--brand-dark);
  color: #fff;
  padding: 13px 14px;
  font-size: 13px;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.legal-scroll {
  max-height: 430px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.legal-scroll p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

body[data-theme="dark"] .phone,
body[data-theme="dark"] .topbar,
body[data-theme="dark"] .bottom-nav,
body[data-theme="dark"] .card,
body[data-theme="dark"] .compare-card,
body[data-theme="dark"] .backend-card,
body[data-theme="dark"] .dev-panel,
body[data-theme="dark"] .alert-item,
body[data-theme="dark"] .message-bubble,
body[data-theme="dark"] .media-card,
body[data-theme="dark"] .portfolio-card,
body[data-theme="dark"] .modal-card,
body[data-theme="dark"] .legal-scroll,
body[data-theme="dark"] .live-board-strip,
body[data-theme="dark"] .field input,
body[data-theme="dark"] .field select,
body[data-theme="dark"] .field textarea,
body[data-theme="dark"] .toggle-row,
body[data-theme="dark"] .mapbox-panel,
body[data-theme="dark"] .chip,
body[data-theme="dark"] .button.secondary {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
}

body[data-theme="dark"] .screen {
  background: #111a17;
}

body[data-theme="dark"] .bottom-nav span {
  background: #22312d;
}

body[data-theme="dark"] .estimate-grid div,
body[data-theme="dark"] .planning-row,
body[data-theme="dark"] .price-diff,
body[data-theme="dark"] .history-item,
body[data-theme="dark"] .message-bubble.mine {
  background: #121c19;
  border-color: var(--line);
}

body[data-theme="dark"] .alert-card,
body[data-theme="dark"] .upload-box,
body[data-theme="dark"] .photo-card,
body[data-theme="dark"] .portfolio-tile,
body[data-theme="dark"] .media-visual,
body[data-theme="dark"] .job-location-map,
body[data-theme="dark"] .contractor-hub-map,
body[data-theme="dark"] .media-placeholder,
body[data-theme="dark"] .viewer-placeholder {
  background: #1d2925;
}

body[data-theme="dark"] .notice {
  background: #321b1a;
  color: #ffc6c1;
}

body[data-theme="dark"] .notice.ok {
  background: #132a21;
  color: #a6f1ce;
}

@media (max-width: 520px) {
  body {
    background: var(--panel);
    overflow: hidden;
  }

  .app-shell {
    padding: 0;
    place-items: stretch;
  }

  .phone {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .topbar {
    padding: max(14px, env(safe-area-inset-top)) 14px 10px;
    grid-template-columns: 42px minmax(0, 1fr) 42px;
  }

  .screen {
    padding: 14px;
  }

  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
    grid-auto-columns: minmax(62px, 1fr);
  }

  .bottom-nav button {
    min-width: 62px;
    min-height: 62px;
    font-size: 11px;
  }

  .hero h2 {
    font-size: 38px;
  }

  .modal-card {
    width: min(calc(100% - 24px), 430px);
  }
}

@media (max-width: 370px) {
  .grid-2,
  .estimate-grid,
  .estimate-grid.compact {
    grid-template-columns: 1fr;
  }

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

  .hero h2 {
    font-size: 34px;
  }

  .bottom-nav {
    grid-auto-columns: minmax(56px, 1fr);
  }

  .bottom-nav button {
    min-width: 56px;
  }
}
