:root {
  --ink: #18212b;
  --muted: #617083;
  --line: #d8dee7;
  --panel: #ffffff;
  --soft: #f4f7fb;
  --blue: #1f5d8f;
  --blue-dark: #16466d;
  --green: #1f7a4d;
  --amber: #b46b18;
  --red: #a83c33;
  --shadow: 0 14px 40px rgba(18, 32, 48, 0.12);
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--soft);
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  background: #152333;
  color: white;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #f0b64d;
  color: #111820;
  font-weight: 800;
}

.brand h1,
.brand p {
  margin: 0;
}

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

.brand p {
  color: #b8c6d6;
  font-size: 13px;
  margin-top: 3px;
}

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

.nav-item {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: transparent;
  color: #d9e4f0;
  text-align: left;
  padding: 0 13px;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.12);
  color: white;
}

.sidebar-card {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.07);
}

.sidebar-card span {
  color: #f0b64d;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-card strong {
  display: block;
  margin-top: 8px;
}

.sidebar-card p {
  color: #c6d4e1;
  margin: 8px 0 0;
  line-height: 1.45;
  font-size: 13px;
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.topbar h2 {
  margin: 0;
  font-size: 30px;
}

.top-actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  border: 1px solid transparent;
}

.primary-button {
  background: var(--blue);
  color: white;
}

.primary-link-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  border: 1px solid transparent;
  background: var(--blue);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.primary-button:hover {
  background: var(--blue-dark);
}

.primary-link-button:hover {
  background: var(--blue-dark);
}

.secondary-button {
  background: white;
  border-color: var(--line);
  color: var(--ink);
}

.ghost-button {
  background: transparent;
  border-color: var(--line);
  color: var(--blue);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.metric,
.panel,
.prospect-card,
.pipeline-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 16px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.6fr);
  gap: 14px;
  margin-top: 14px;
}

.panel {
  padding: 16px;
  min-width: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.panel h3 {
  margin: 0;
  font-size: 17px;
}

.filters {
  display: grid;
  grid-template-columns: 1.8fr repeat(5, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.filters input,
.filters select,
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 10px;
  min-height: 40px;
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.mobile-list {
  display: none;
}

.mobile-prospect-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 12px;
}

.mobile-card-main {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  color: var(--ink);
  text-align: left;
}

.mobile-card-main strong {
  display: block;
  font-size: 16px;
  line-height: 1.25;
}

.mobile-card-main small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px;
}

.mobile-card-score {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #edf2f7;
  color: var(--blue);
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 700;
}

.mobile-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.mobile-prospect-card p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 880px;
}

th,
td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--muted);
  background: #f8fafc;
  font-weight: 700;
}

tr:hover td {
  background: #f7fbff;
}

.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--blue);
  text-align: left;
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
  background: #edf2f7;
  color: #37465a;
  white-space: nowrap;
}

.badge-link {
  text-decoration: none;
}

.badge-link:hover {
  text-decoration: underline;
}

.badge.high,
.badge.won {
  background: #e5f4ed;
  color: var(--green);
}

.badge.medium-high,
.badge.contacted,
.badge.quoted,
.badge.proposal-sent {
  background: #e7f0fa;
  color: var(--blue);
}

.badge.medium,
.badge.site-visit,
.badge.negotiation {
  background: #fff2df;
  color: var(--amber);
}

.badge.low,
.badge.no-patio,
.badge.lost {
  background: #fae9e7;
  color: var(--red);
}

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

.prospect-card,
.pipeline-card {
  padding: 12px;
}

.prospect-card h4,
.pipeline-card h4 {
  margin: 0 0 6px;
  font-size: 15px;
}

.prospect-card p,
.pipeline-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.pipeline-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.pipeline-col {
  min-width: 220px;
  background: #edf2f7;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.pipeline-col h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.roi-layout {
  display: grid;
  grid-template-columns: minmax(300px, 430px) minmax(0, 1fr);
  gap: 14px;
}

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

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

.field-help {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.roi-result {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.result-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: white;
}

.result-box span {
  color: var(--muted);
  font-size: 13px;
}

.result-box strong {
  display: block;
  margin-top: 7px;
  font-size: 24px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 24, 36, 0.45);
  z-index: 10;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(680px, 100vw);
  height: 100vh;
  overflow: auto;
  background: white;
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: translateX(100%);
  transition: transform 0.18s ease;
  z-index: 11;
  padding: 22px;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.drawer-head h3 {
  margin: 4px 0 0;
  font-size: 24px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.detail-section {
  margin-top: 18px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.detail-section h4 {
  margin: 0 0 10px;
}

.photo-upload {
  display: grid;
  grid-template-columns: minmax(140px, 180px) minmax(220px, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.quote-notes-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.quote-add-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.measurement-list {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.measurement-row {
  display: grid;
  grid-template-columns: 1.1fr 0.8fr 0.8fr 1.1fr auto;
  align-items: end;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
}

.measurement-row button {
  min-height: 40px;
}

.quote-summary {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: #2d3b4d;
  padding: 12px;
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: 13px;
}

.quote-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.quote-submit-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.quote-summary-page {
  display: grid;
  gap: 14px;
}

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

.summary-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: #f8fafc;
}

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.summary-item strong {
  display: block;
  font-size: 14px;
  line-height: 1.35;
}

.summary-note {
  white-space: pre-wrap;
  line-height: 1.5;
  margin: 0;
  color: #2d3b4d;
}

.photo-upload select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: white;
}

.photo-picker {
  min-height: 44px;
  border-radius: 8px;
  background: var(--blue);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.photo-picker input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.photo-gallery {
  display: grid;
  gap: 16px;
}

.photo-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
}

.photo-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.photo-group h5 {
  margin: 0;
  font-size: 14px;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.photo-tile {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.photo-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #e7edf5;
}

.photo-tile figcaption {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 8px;
  font-size: 12px;
  color: var(--muted);
}

.photo-empty {
  min-height: 68px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.empty {
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

@media (max-width: 1000px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 12px;
  }

  .brand,
  .sidebar-card {
    display: none;
  }

  .nav {
    grid-template-columns: repeat(5, 1fr);
  }

  .nav-item {
    text-align: center;
    padding: 0 8px;
  }

  .metric-grid,
  .content-grid,
  .roi-layout {
    grid-template-columns: 1fr;
  }

  .filters {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 14px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions button {
    flex: 1;
  }

  .nav {
    overflow-x: auto;
    grid-template-columns: repeat(5, minmax(96px, 1fr));
  }

  .filters,
  .detail-grid,
  .roi-result,
  .photo-upload,
  .quote-notes-grid,
  .summary-grid,
  .quote-add-row,
  .measurement-row {
    grid-template-columns: 1fr;
  }

  .quote-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .primary-button,
  .primary-link-button,
  .secondary-button,
  .ghost-button,
  .nav-item,
  .filters input,
  .filters select,
  .field input,
  .field select,
  .field textarea {
    min-height: 48px;
  }

  .topbar h2 {
    font-size: 25px;
  }

  .panel {
    padding: 12px;
  }

  .metric {
    padding: 13px;
  }

  .metric strong {
    font-size: 24px;
  }

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

  #prospects-view .table-wrap {
    display: none;
  }

  .drawer {
    width: 100vw;
    padding: 16px;
  }

  .drawer-head {
    position: sticky;
    top: -16px;
    margin: -16px -16px 14px;
    padding: 14px 16px;
    background: white;
    border-bottom: 1px solid var(--line);
    z-index: 2;
  }

  .drawer-head h3 {
    font-size: 21px;
  }

  .drawer-head p {
    font-size: 13px;
  }

  .photo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .photo-picker,
  .photo-upload select {
    min-height: 48px;
  }
}

/* Passphrase gate */
.gate-overlay { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; padding: 16px; background: #152333; }
.gate-card { width: 100%; max-width: 380px; display: grid; gap: 12px; padding: 28px 24px; border-radius: 14px; background: #ffffff; color: #18212b; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.gate-card h2 { margin: 0; font-size: 22px; }
.gate-card p { margin: 0; color: #61707f; font-size: 14px; }
.gate-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 10px; background: #f2a93b; color: #152333; font-weight: 800; font-size: 13px; }
.gate-card input[type="password"] { width: 100%; padding: 11px 12px; border: 1px solid #c9d3de; border-radius: 8px; font-size: 16px; box-sizing: border-box; }
.gate-remember { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #3d4b59; }
.gate-error { min-height: 18px; color: #b3261e !important; }
.gate-actions { display: flex; gap: 10px; }
.gate-actions button { flex: 1; }

/* Drive list */
.drive-panel { margin-bottom: 18px; }
.drive-next { display: block; text-align: center; text-decoration: none; margin: 4px 0 12px; padding: 14px 16px; }
.drive-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.drive-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.drive-stop { border: 1px solid #d9e1ea; border-radius: 10px; padding: 12px; background: #fff; }
.drive-stop.done { opacity: .6; }
.drive-stop.done .link-button { text-decoration: line-through; }
.drive-stop-head { display: flex; align-items: center; gap: 10px; }
.drive-num { flex: none; width: 28px; height: 28px; border-radius: 50%; background: #152333; color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.drive-info { flex: 1; min-width: 0; display: grid; }
.drive-info small { color: #5b6b7e; }
.drive-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.drive-actions a.primary-button { text-decoration: none; display: inline-flex; align-items: center; }
.drive-actions .secondary-button.active { background: #e7f0fa; border-color: #2f6db5; font-weight: 700; }
.drawer-drive { margin: 0 0 16px; }
.drive-empty { color: #5b6b7e; margin: 6px 0 0; }
@media (max-width: 700px) { .drive-actions .secondary-button, .drive-actions a.primary-button { min-height: 44px; } }

.main, .view, .content-grid > * { min-width: 0; }
.table-wrap { overflow-x: auto; max-width: 100%; }
@media (max-width: 1000px) {
  .app-shell, .metric-grid, .content-grid, .roi-layout { grid-template-columns: minmax(0, 1fr); }
}

.sort-field { display: grid; gap: 4px; font-size: 12px; font-weight: 700; color: #5b6b7e; }

.drive-maps { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.drive-maps a { text-decoration: none; display: inline-flex; align-items: center; }
.drive-maps small { flex-basis: 100%; color: #5b6b7e; }
.drive-auto { display: flex; gap: 8px; align-items: center; font-size: 14px; margin-bottom: 12px; }

.drive-status { color: #5b6b7e; font-size: 14px; margin: 0 0 10px; min-height: 1em; }
