:root {
  color-scheme: light;
  --ink: #050505;
  --muted: #4b5563;
  --panel: #ffffff;
  --line: #d8dee8;
  --wash: #ffffff;
  --accent: #174ea6;
  --accent-dark: #0b2f6b;
  --accent-soft: #eaf1ff;
  --red: #c1121f;
  --red-soft: #fff0f1;
  --warning: #a23b00;
  --danger: #c1121f;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--wash);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.topbar {
  display: grid;
  grid-template-columns: 72px 1fr 44px;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  border-bottom: 4px solid var(--red);
  color: var(--ink);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  width: 64px;
  height: 44px;
  object-fit: contain;
  flex: 0 0 auto;
}

.eyebrow,
.topbar h1,
.stats-grid p,
.section-heading h2,
.opportunity-card h3,
.contact-line,
.notes {
  margin: 0;
}

.eyebrow {
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar h1 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: 0;
  text-align: center;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  text-decoration: none;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.stats-grid article,
.stats-grid a {
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--accent-dark);
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  text-decoration: none;
}

.stats-grid span,
.stats-grid a span {
  display: block;
  font-size: 1rem;
  font-weight: 800;
}

.stats-grid p {
  color: #dbe8ff;
  font-size: 0.78rem;
  font-weight: 700;
}

.stats-grid small {
  color: #dbe8ff;
  font-size: 0.78rem;
  font-weight: 700;
}

.page-links a {
  display: grid;
  align-items: center;
  justify-items: center;
  text-align: center;
}

.entry-panel,
.opportunity-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.entry-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.edit-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 10px 12px;
  font-weight: 800;
}

.edit-banner[hidden] {
  display: none;
}

.edit-banner .text-button {
  padding: 4px 0 4px 10px;
}

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

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
  padding: 12px;
}

textarea {
  resize: vertical;
}

#followUpDate {
  max-width: 100%;
  min-width: 0;
  padding-left: 8px;
  padding-right: 8px;
  font-size: 0.9rem;
  -webkit-appearance: none;
  appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 78, 166, 0.16);
}

.primary-button,
.small-button,
.text-button,
.filter {
  border: 0;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  min-height: 48px;
  border-radius: 7px;
  background: var(--accent);
  color: #ffffff;
}

.secondary-button {
  width: 100%;
  min-height: 42px;
  margin-bottom: 10px;
  border: 1px solid var(--accent-dark);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.secondary-button:disabled {
  border-color: var(--line);
  background: #f3f5f8;
  color: #8b95a3;
  cursor: not-allowed;
}

.secondary-button.active {
  background: var(--accent);
  color: #ffffff;
}

.view-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.route-filters {
  margin-bottom: 10px;
}

.route-map-button {
  width: 100%;
  margin-bottom: 10px;
}

.route-map-button[hidden] {
  display: none;
}

.route-map-button:disabled {
  background: #f3f5f8;
  color: #8b95a3;
  cursor: not-allowed;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin: 16px -16px 0;
  padding: 0 16px 8px;
  overflow-x: auto;
}

.filter {
  flex: 0 0 auto;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  padding: 0 14px;
}

.filter.active {
  border-color: var(--accent-dark);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.list-section {
  padding-top: 4px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0;
}

.section-heading h2 {
  font-size: 1.05rem;
}

.text-button {
  background: transparent;
  color: var(--accent-dark);
  padding: 8px 0 8px 12px;
}

.empty-state {
  border: 1px dashed #aeb8c8;
  border-radius: 8px;
  padding: 22px 14px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
}

.empty-state p {
  margin: 0;
}

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

.opportunity-card {
  padding: 12px;
}

.card-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.status-pill {
  display: inline-flex;
  margin: 0 0 6px;
  border-radius: 999px;
  background: var(--red-soft);
  color: var(--red);
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 900;
}

.status-pill.sold {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.status-pill.closed {
  background: #fff4e8;
  color: var(--warning);
}

.opportunity-card h3 {
  font-size: 1rem;
}

.contact-line,
.notes,
.details {
  color: var(--muted);
  font-size: 0.9rem;
}

.delete-button {
  flex: 0 0 auto;
  border-color: #f0d1ce;
  background: var(--red-soft);
  color: var(--danger);
}

.details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0 0;
}

.details div {
  min-height: 50px;
  border-radius: 7px;
  background: #f7f9fd;
  padding: 8px;
}

.details dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.details dd {
  margin: 2px 0 0;
  font-weight: 800;
}

.sold-fields {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.next-service-date {
  display: block;
  min-height: 45px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 12px;
  font-weight: 800;
}

.notes {
  margin-top: 10px;
  line-height: 1.35;
}

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

.small-button {
  min-height: 38px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

@media (max-width: 360px) {
  .split-fields,
  .details {
    grid-template-columns: 1fr;
  }

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