:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-strong: #eef4ef;
  --ink: #18231d;
  --muted: #647067;
  --line: #d9e2dc;
  --green: #1f7a4d;
  --green-dark: #155c39;
  --amber: #b26b16;
  --red: #b5362e;
  --blue: #2f5f98;
  --shadow: 0 18px 40px rgba(31, 49, 38, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(19, 36, 25, 0.72), rgba(19, 36, 25, 0.56)),
    url("https://images.unsplash.com/photo-1588621207689-727cd310e551?auto=format&fit=crop&w=1800&q=72") center/cover fixed,
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.is-locked .topbar,
.is-locked .app-shell {
  filter: blur(4px);
  pointer-events: none;
  user-select: none;
}

.access-gate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 29, 21, 0.68);
}

.access-card {
  width: min(440px, 100%);
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.access-card .eyebrow {
  color: var(--green-dark);
}

.access-card h2 {
  margin-bottom: 16px;
}

.access-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.access-tab {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--green-dark);
  font-weight: 850;
}

.access-tab.active {
  background: var(--green);
  color: #fff;
}

.access-form {
  display: grid;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 48px) 20px;
  color: #fff;
}

.eyebrow {
  margin: 0 0 4px;
  color: #d9eee0;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 1.18rem;
}

.topbar-actions,
.card-actions,
.toolbar,
.button-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.session-pill {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  max-width: 220px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--green-dark);
  font-size: 0.86rem;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 0 clamp(14px, 3vw, 40px) 36px;
}

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

.admin-panel {
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

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

.admin-header.compact {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.admin-header p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 700;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto minmax(220px, 0.7fr);
  gap: 16px;
  align-items: start;
}

.button-row {
  flex-wrap: wrap;
  margin-top: 10px;
}

.qr-box {
  display: grid;
  gap: 10px;
  justify-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.qr-box img {
  width: 220px;
  height: 220px;
  border-radius: 6px;
  background: #fff;
}

.qr-box a {
  max-width: 220px;
  color: var(--green-dark);
  font-size: 0.82rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.package-admin {
  margin-top: 4px;
}

.package-form,
.package-actions {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 0.7fr) auto;
  gap: 12px;
  align-items: end;
}

.package-actions {
  grid-template-columns: minmax(220px, 1fr) auto auto;
  margin-top: 12px;
}

.package-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

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

.package-row strong,
.package-row span {
  display: block;
}

.package-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.stats article {
  min-height: 96px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.stats span {
  display: block;
  color: var(--green-dark);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.stats p {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 650;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 390px) 1fr;
  gap: 16px;
  align-items: start;
}

.panel,
.list-area {
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.panel {
  position: sticky;
  top: 16px;
  padding: 20px;
}

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

form {
  display: grid;
  gap: 14px;
}

label,
legend {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

.photo-field {
  display: grid;
  gap: 9px;
}

.photo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 750;
}

.photo-header .ghost-button {
  min-height: 32px;
  padding: 0 10px;
}

.photo-header .ghost-button:disabled {
  cursor: default;
  opacity: 0.48;
}

.photo-dropzone {
  display: grid;
  place-items: center;
  min-height: 158px;
  overflow: hidden;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.photo-dropzone img {
  width: 100%;
  height: 190px;
  object-fit: cover;
}

#photoInput {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 122, 77, 0.16);
}

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

fieldset {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-weight: 650;
}

.check-row input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--green);
}

.primary-button,
.ghost-button,
.icon-button {
  border: 0;
  border-radius: 6px;
  font-weight: 800;
}

.primary-button {
  min-height: 46px;
  background: var(--green);
  color: #fff;
}

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

.ghost-button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--green-dark);
}

.ghost-button:disabled {
  cursor: default;
  opacity: 0.48;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.92);
  color: var(--green-dark);
  font-size: 1.18rem;
}

.import-label input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.list-area {
  min-width: 0;
  padding: 14px;
}

.toolbar {
  justify-content: space-between;
  margin-bottom: 12px;
}

.location-field {
  display: grid;
  gap: 9px;
}

.field-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.map-panel {
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
}

.map-header h2 {
  margin-bottom: 4px;
}

.map-header p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.map {
  min-height: 380px;
  width: 100%;
  display: grid;
  place-items: center;
  border-top: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--muted);
  font-weight: 800;
}

.leaflet-container {
  font-family: inherit;
}

.search-box {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding-left: 12px;
}

.search-box input {
  margin: 0;
  border: 0;
  box-shadow: none;
}

.toolbar select {
  width: 160px;
  margin: 0;
}

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

.group-divider {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--green-dark);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 850;
}

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

.hydrant-photo {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 7;
  margin-bottom: 14px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-strong);
}

.card-main,
.card-title-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.card-main {
  align-items: flex-start;
}

.card-title-row {
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.hydrant-card h3 {
  margin-bottom: 0;
  font-size: 1.15rem;
}

.location,
.notes {
  color: var(--muted);
}

.location {
  margin: 6px 0 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 850;
}

.status-ok {
  background: #dff2e7;
  color: var(--green-dark);
}

.status-due {
  background: #fff0d9;
  color: var(--amber);
}

.status-issue,
.status-blocked {
  background: #ffe3e0;
  color: var(--red);
}

.card-actions .icon-button {
  width: 34px;
  height: 34px;
  border-color: var(--line);
  background: #fff;
}

.card-details {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.card-details div {
  min-width: 0;
}

dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  font-weight: 750;
}

.notes {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--surface-strong);
}

.empty-state {
  padding: 42px 20px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  text-align: center;
  font-weight: 750;
}

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
  }

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

  .package-form,
  .package-actions {
    grid-template-columns: 1fr;
  }

  .panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

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

  .toolbar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .session-pill {
    max-width: 100%;
  }

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

  .map-header .ghost-button {
    width: 100%;
  }

  .map {
    min-height: 320px;
  }

  .toolbar select,
  .toolbar .ghost-button {
    width: 100%;
  }

  .card-details,
  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 460px) {
  .topbar {
    flex-direction: column;
  }

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

  .card-main {
    flex-direction: column;
  }
}
