:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --surface: #ffffff;
  --ink: #17201f;
  --muted: #61706c;
  --line: #d8ded8;
  --primary: #17605a;
  --primary-dark: #0d413d;
  --blue: #315f9d;
  --gold: #b98213;
  --red: #ad3d31;
  --shadow: 0 12px 28px rgba(23, 32, 31, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

[hidden] {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--bg);
}

.topbar {
  min-height: 76px;
  padding: 16px 18px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: 1.45rem;
}

.brand-mark {
  width: 4.1rem;
  line-height: 0.82;
}

.brand-mark-logo {
  width: 3.9rem;
}

.brand-primary,
.brand-secondary {
  display: block;
  white-space: nowrap;
}

.brand-logo {
  display: block;
  width: 3.45rem;
  height: 3.45rem;
  margin: -1px 0 0 0.1rem;
  border-radius: 0.92rem;
  box-shadow: 0 6px 14px rgba(13, 65, 61, 0.15);
}

.brand-primary {
  color: var(--ink);
  font-size: 1.46rem;
  font-weight: 900;
  letter-spacing: 0.045rem;
  text-transform: lowercase;
}

.brand-secondary {
  transform: translateY(6px);
  color: #3e5550;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.082rem;
}

h2 {
  margin: 0;
  font-size: 1.35rem;
}

h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

main {
  padding: 16px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.section-heading {
  margin-bottom: 14px;
}

.section-heading.compact {
  margin: 22px 0 10px;
}

.sync-badge {
  min-width: 78px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(23, 96, 90, 0.12);
  color: var(--primary-dark);
  text-align: center;
  font-size: 0.78rem;
  font-weight: 800;
}

.sync-badge.offline {
  background: rgba(173, 61, 49, 0.12);
  color: var(--red);
}

.entry-form,
.info-panel,
.recent-panel {
  display: grid;
  gap: 14px;
}

.form-panel,
.info-panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 4px 16px rgba(23, 32, 31, 0.05);
}

.form-panel {
  display: grid;
  gap: 18px;
}

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

.field span {
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 800;
}

.field small {
  min-height: 18px;
  color: var(--muted);
  font-size: 0.82rem;
}

input,
select {
  width: 100%;
  min-height: 54px;
  padding: 13px 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 1.05rem;
}

.combo-input {
  position: relative;
  display: grid;
}

.combo-input input {
  padding-right: 52px;
}

.combo-button {
  position: absolute;
  top: 2px;
  right: 2px;
  bottom: 2px;
  width: 48px;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0 6px 6px 0;
  background: #eef3f0;
  color: var(--primary-dark);
  font-size: 1.4rem;
  font-weight: 900;
}

.map-choice-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.map-choice {
  min-height: 44px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 800;
}

.map-choice:last-child {
  border-bottom: 0;
}

.map-choice:focus,
.map-choice:hover {
  background: rgba(23, 96, 90, 0.08);
  outline: 0;
}

.street-suggest {
  display: grid;
  gap: 6px;
}

.street-suggest-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 4px 12px rgba(23, 32, 31, 0.08);
}

.street-suggest-option {
  min-height: 46px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
}

.street-suggest-option:last-child {
  border-bottom: 0;
}

.street-suggest-option:focus,
.street-suggest-option:hover {
  background: rgba(23, 96, 90, 0.08);
  outline: 0;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(23, 96, 90, 0.2);
  outline: 0;
}

.field-row {
  margin-top: -8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.check-field {
  min-height: 54px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: 0.96rem;
  font-weight: 800;
}

.check-field input {
  width: 24px;
  height: 24px;
  min-height: 24px;
  flex: 0 0 auto;
  accent-color: var(--primary);
}

.check-field span {
  line-height: 1.25;
}

.check-field:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(23, 96, 90, 0.2);
}

.primary-button {
  min-height: 60px;
  margin-top: 2px;
  padding: 14px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  font-size: 1.02rem;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.secondary-button {
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--primary-dark);
  font-weight: 900;
}

.danger-action {
  color: var(--red);
}

.access-qr-image {
  display: block;
  width: 220px;
  height: 220px;
  margin: 12px auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.access-page,
.auth-page {
  min-height: 100vh;
  padding: 20px;
  display: grid;
  place-items: center;
}

.access-card,
.auth-card {
  width: min(100%, 520px);
}

.auth-card {
  display: grid;
  justify-items: center;
  text-align: center;
}

.auth-card .primary-button,
.auth-card .secondary-button {
  width: min(100%, 320px);
}

body.access-mode {
  background: var(--surface);
}

.access-request-item {
  align-items: flex-start;
  flex-direction: column;
}

.admin-actions {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.release-button {
  width: 100%;
  margin: 0;
}

.helper-note {
  margin: 14px 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.form-message {
  margin: -4px 0 0;
  color: var(--red);
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.35;
}

#accessRequestMessage {
  margin-top: 8px;
}

.form-message.is-empty {
  display: none;
}

.form-message.is-empty + .primary-button {
  margin-top: -10px;
}

.followup-guidance {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.holding-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

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

.compact-list {
  margin-bottom: 8px;
}

.list-item,
.followup-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.list-item {
  min-height: 70px;
  padding: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.list-item p,
.followup-card p,
.info-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.followup-card .lock-expiry {
  margin-top: 3px;
  color: #8a9994;
  font-size: 0.78rem;
  font-weight: 700;
}

.followup-card .address-helper {
  margin-top: 3px;
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 900;
}

.list-item .address-helper {
  margin-top: 3px;
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 900;
}

.followup-card {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.followup-card-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
}

.followup-card-details {
  width: 100%;
}

.maps-link {
  min-height: 38px;
  width: fit-content;
  padding: 9px 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--primary-dark);
  background: #ffffff;
  font-size: 0.86rem;
  font-weight: 900;
  text-decoration: none;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 6px;
  flex-wrap: wrap;
}

.card-action {
  font-family: inherit;
  cursor: pointer;
}

.followup-group {
  display: grid;
  gap: 10px;
}

.group-heading {
  margin: 10px 0 0;
  width: 100%;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--primary-dark);
  background: #ffffff;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 900;
  text-align: left;
  cursor: pointer;
}

.group-heading span:last-child {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

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

.choice {
  min-height: 54px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  font-weight: 900;
}

.choice.contact {
  background: var(--primary);
}

.choice.no-contact {
  background: var(--blue);
}

.delete-button {
  min-height: 46px;
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 0;
  border-radius: 7px;
  background: var(--red);
  color: #ffffff;
  font-size: 0.86rem;
  font-weight: 900;
}

.delete-button.is-locked,
.delete-button:disabled {
  background: #8a9994;
  color: #ffffff;
  cursor: default;
  box-shadow: none;
}

.bottom-nav {
  min-height: 72px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  position: sticky;
  bottom: 0;
}

.build-reference {
  display: block;
  margin: 0;
  color: #9aa5a1;
  font-size: 0.76rem;
  font-weight: 700;
  text-align: center;
  width: 100%;
}

.map-history-heading {
  margin-top: 18px;
}

.map-update-item,
.map-update-history-item {
  align-items: flex-start;
}

.map-update-status {
  color: var(--primary-dark);
  font-weight: 900;
}

.map-update-map-list {
  margin: 8px 0 0;
  padding-left: 20px;
  color: var(--muted);
}

.map-update-map-list li + li {
  margin-top: 4px;
}

.nav-item {
  min-height: 52px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.nav-item.is-active {
  background: rgba(23, 96, 90, 0.12);
  color: var(--primary-dark);
}

@media (max-width: 360px) {
  .field-row,
  .choice-row {
    grid-template-columns: 1fr;
  }

  .nav-item {
    font-size: 0.72rem;
  }
}

@media (min-width: 620px) {
  main {
    padding: 22px;
  }
}
