:root {
  --bg: #f2efe7;
  --panel: rgba(255, 252, 245, 0.88);
  --panel-strong: rgba(255, 253, 247, 0.98);
  --ink: #18261d;
  --muted: #607064;
  --line: rgba(24, 38, 29, 0.12);
  --accent: #0f6b43;
  --accent-soft: #dcefe2;
  --warm: #d88933;
  --danger: #9d4738;
  --shadow: 0 24px 80px rgba(24, 38, 29, 0.12);
  --shadow-soft: 0 16px 42px rgba(24, 38, 29, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body.authenticated #auth-gate {
  display: none !important;
}

body:not(.authenticated) #app-content {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Mulish", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(216, 137, 51, 0.22), transparent 28%),
    radial-gradient(circle at top right, rgba(15, 107, 67, 0.16), transparent 24%),
    linear-gradient(180deg, #f7f3ea 0%, #ede7da 100%);
}

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

.page-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 32px auto 48px;
}

.page-shell::before {
  content: "";
  position: fixed;
  inset: auto auto 6% -8%;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15, 107, 67, 0.08), transparent 68%);
  pointer-events: none;
  filter: blur(12px);
}

.auth-shell {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 120px);
}

.auth-card {
  width: min(520px, 100%);
  padding: 32px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.auth-lockup {
  margin-bottom: 24px;
}

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

.brand-lockup .brand-logo {
  padding: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 30px rgba(24, 38, 29, 0.12);
}

.brand-name {
  margin: 0;
  font-family: "Lato", sans-serif;
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.brand-tagline {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

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

.auth-toggle {
  display: inline-flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.auth-toggle-button.active {
  background: var(--accent);
  color: #f5fff8;
}

.alert-inline {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: start;
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(157, 71, 56, 0.18);
  background: linear-gradient(135deg, rgba(255, 244, 241, 0.96), rgba(255, 250, 247, 0.96));
  box-shadow: 0 16px 40px rgba(157, 71, 56, 0.08);
}

.alert-inline-icon {
  width: 12px;
  height: 12px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 6px rgba(157, 71, 56, 0.12);
}

.alert-inline-body {
  margin: 4px 0 0;
  color: var(--muted);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 1fr);
  gap: 32px;
  align-items: center;
  margin-bottom: 24px;
}

.hero-copy-block {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.eyebrow,
.section-kicker,
.hero-card-label {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--accent);
  margin: 0 0 10px;
}

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

h1 {
  font-family: "Lato", sans-serif;
  font-size: clamp(2.2rem, 5vw, 4.6rem);
  line-height: 0.95;
  margin-bottom: 14px;
}

.hero-copy {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
  max-width: 48rem;
}

.session-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.session-state {
  display: inline-flex;
  align-items: center;
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(15, 107, 67, 0.1);
  color: var(--accent);
  font-weight: 700;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(216, 137, 51, 0.16);
  color: #8c5a19;
  font-weight: 800;
  text-transform: capitalize;
}

.toast-region {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 1000;
  display: grid;
  gap: 12px;
  width: min(380px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 16px 18px;
  border-radius: 20px;
  border: 1px solid rgba(24, 38, 29, 0.08);
  background: rgba(255, 252, 245, 0.96);
  box-shadow: 0 20px 50px rgba(24, 38, 29, 0.16);
  backdrop-filter: blur(16px);
  animation: toast-in 180ms ease-out;
}

.toast.success {
  border-left: 5px solid var(--accent);
}

.toast.error {
  border-left: 5px solid var(--danger);
}

.toast.info {
  border-left: 5px solid var(--warm);
}

.toast-dot {
  width: 12px;
  height: 12px;
  margin-top: 5px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 6px rgba(24, 38, 29, 0.08);
}

.toast.success .toast-dot {
  color: var(--accent);
}

.toast.error .toast-dot {
  color: var(--danger);
}

.toast.info .toast-dot {
  color: var(--warm);
}

.toast-title {
  display: block;
  margin-bottom: 3px;
  font-family: "Lato", sans-serif;
  font-size: 0.98rem;
}

.toast-body {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.toast-close {
  border: 0;
  background: transparent;
  padding: 0;
  line-height: 1;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.hero-card,
.panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.hero-card {
  padding: 28px 32px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  justify-content: space-between;
  background:
    linear-gradient(140deg, rgba(15, 107, 67, 0.95), rgba(16, 55, 38, 0.92)),
    var(--panel);
  color: #f8fffb;
}

.hero-card-label {
  color: rgba(248, 255, 251, 0.72);
}

.hero-card-text {
  font-size: 1.3rem;
  line-height: 1.4;
  font-weight: 700;
  margin: 0;
}

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

.hero-metric {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.hero-metric-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(248, 255, 251, 0.68);
}

.hero-metric strong {
  font-family: "Lato", sans-serif;
  font-size: 1rem;
  line-height: 1.35;
}

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

.overview-card {
  padding: 18px 20px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.36)),
    var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.58);
  box-shadow: var(--shadow-soft);
}

.overview-label {
  display: inline-block;
  margin-bottom: 10px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.overview-card strong {
  display: block;
  margin-bottom: 6px;
  font-family: "Lato", sans-serif;
  font-size: 1.4rem;
  line-height: 1.1;
}

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

.tabs-shell {
  padding: 14px;
}

.tabs-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tab-button {
  background: rgba(24, 38, 29, 0.08);
  color: var(--ink);
  flex: 0 0 auto;
  white-space: nowrap;
}

.tab-button.active {
  background: var(--accent);
  color: #f5fff8;
}

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

.panel {
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, rgba(15, 107, 67, 0.16), rgba(216, 137, 51, 0.12), transparent);
  pointer-events: none;
}

.panel-wide {
  grid-column: 1 / -1;
}

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

.section-tools {
  display: grid;
  gap: 10px;
  justify-items: end;
  min-width: min(100%, 360px);
}

.directory-summary {
  margin: 0;
  text-align: right;
  color: var(--muted);
  max-width: 42ch;
  line-height: 1.45;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

.stats-grid,
.dashboard-grid,
.insights-grid,
.score-grid {
  display: grid;
  gap: 14px;
}

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

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

.map-card {
  display: grid;
  grid-template-columns: minmax(260px, 0.95fr) minmax(320px, 1.2fr);
  gap: 18px;
  margin-bottom: 16px;
}

.map-copy,
.tanzania-map-wrap {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
}

.map-location-detail {
  margin-top: 18px;
  padding: 16px;
  border-radius: 16px;
  background: rgba(15, 107, 67, 0.08);
  border: 1px solid rgba(15, 107, 67, 0.12);
}

.map-location-detail ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.tanzania-map {
  width: 100%;
  height: auto;
  display: block;
}

.tanzania-outline {
  fill: rgba(15, 107, 67, 0.08);
  stroke: rgba(15, 107, 67, 0.55);
  stroke-width: 3;
}

.map-point {
  cursor: pointer;
}

.map-point circle {
  fill: var(--accent);
  stroke: #fff;
  stroke-width: 3;
  transition: transform 120ms ease, fill 120ms ease;
}

.map-point text {
  font-family: "Lato", sans-serif;
  font-size: 11px;
  fill: var(--ink);
}

.map-point:hover circle,
.map-point.active circle {
  fill: var(--warm);
  transform: scale(1.06);
  transform-origin: center;
}

.map-point-count {
  font-weight: 900;
}

.dashboard-card,
.stat-card,
.insight-card {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.stat-card strong {
  display: block;
  font-size: 2rem;
  margin-top: 6px;
  font-family: "Lato", sans-serif;
}

.stat-card span,
.dashboard-card p,
.insight-card p,
.entry-meta,
.subtle {
  color: var(--muted);
}

.list-stack,
.entry-list {
  display: grid;
  gap: 12px;
}

.list-item,
.entry-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.55);
}

.list-item strong,
.entry-card strong {
  display: block;
  margin-bottom: 4px;
}

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

label {
  display: grid;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 600;
}

input,
select,
textarea,
.search-input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  padding: 12px 14px;
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus,
.search-input:focus {
  outline: 0;
  border-color: rgba(15, 107, 67, 0.34);
  box-shadow: 0 0 0 4px rgba(15, 107, 67, 0.1);
}

.search-shell {
  width: min(100%, 360px);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 8px 10px 8px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(24, 38, 29, 0.08);
  box-shadow: var(--shadow-soft);
}

.search-shell-label {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.search-shell .search-input {
  border: 0;
  background: transparent;
  padding: 4px 0;
  box-shadow: none;
}

textarea {
  resize: vertical;
}

.full-span {
  grid-column: 1 / -1;
}

.score-block {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(220, 239, 226, 0.32);
}

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

.score-preview {
  margin-bottom: 0;
  margin-top: 14px;
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
  background: var(--accent);
  color: #f5fff8;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(15, 107, 67, 0.18);
}

button.secondary {
  background: rgba(24, 38, 29, 0.08);
  color: var(--ink);
}

button.danger {
  background: rgba(157, 71, 56, 0.12);
  color: var(--danger);
}

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

.insight-card {
  min-height: 164px;
}

.insight-card h3 {
  margin-bottom: 10px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.44);
}

.admin-role-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.role-select {
  min-width: 150px;
}

.role-note {
  font-size: 0.84rem;
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
  background: var(--panel-strong);
}

th,
td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(255, 253, 247, 0.96);
  backdrop-filter: blur(10px);
}

tbody tr:nth-child(even) {
  background: rgba(15, 107, 67, 0.025);
}

tbody tr:hover {
  background: rgba(216, 137, 51, 0.06);
}

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

.table-action {
  padding: 8px 12px;
  font-size: 0.84rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 700;
}

.badge.low {
  background: rgba(15, 107, 67, 0.12);
  color: var(--accent);
}

.badge.medium {
  background: rgba(216, 137, 51, 0.18);
  color: #8c5a19;
}

.badge.high {
  background: rgba(157, 71, 56, 0.14);
  color: var(--danger);
}

.empty-state,
.empty-state-inline {
  min-height: 110px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 980px) {
  .hero,
  .layout,
  .map-card,
  .overview-strip,
  .stats-grid,
  .dashboard-grid,
  .insights-grid,
  .score-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .page-shell {
    width: min(100% - 20px, 1200px);
    margin-top: 20px;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
  }

  .section-tools {
    width: 100%;
    justify-items: stretch;
  }

  .directory-summary {
    text-align: left;
    max-width: none;
  }

  .toast-region {
    top: 12px;
    right: 12px;
    width: calc(100vw - 24px);
  }

  .hero-card {
    min-height: auto;
  }
}

@media (max-width: 720px) {
  body {
    background:
      radial-gradient(circle at top left, rgba(216, 137, 51, 0.18), transparent 32%),
      radial-gradient(circle at top right, rgba(15, 107, 67, 0.12), transparent 26%),
      linear-gradient(180deg, #f7f3ea 0%, #ede7da 100%);
  }

  .page-shell {
    width: calc(100% - 16px);
    margin: 12px auto 24px;
  }

  .auth-shell {
    min-height: calc(100vh - 24px);
  }

  .auth-card,
  .panel,
  .hero-card,
  .hero-copy-block,
  .overview-card {
    border-radius: 22px;
  }

  .auth-card,
  .panel {
    padding: 18px;
  }

  .brand-lockup {
    gap: 12px;
  }

  .brand-logo {
    width: 56px;
    height: 56px;
  }

  .hero {
    gap: 14px;
    margin-bottom: 16px;
  }

  .hero-copy-block {
    padding: 0;
  }

  .hero-copy {
    font-size: 0.98rem;
  }

  .hero-metrics {
    grid-template-columns: 1fr;
  }

  .session-bar {
    align-items: stretch;
  }

  .session-state,
  .role-badge {
    width: fit-content;
    max-width: 100%;
  }

  .tabs-shell {
    position: sticky;
    top: 10px;
    z-index: 20;
    padding: 10px;
    backdrop-filter: blur(18px);
  }

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

  .tab-button {
    padding: 11px 15px;
    font-size: 0.94rem;
    width: 100%;
  }

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

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

  .search-input {
    min-width: 0;
  }

  .search-shell {
    width: 100%;
  }

  .map-copy,
  .tanzania-map-wrap,
  .dashboard-card,
  .stat-card,
  .insight-card,
  .score-block,
  .list-item,
  .entry-card,
  .overview-card {
    padding: 16px;
  }

  .tanzania-map-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tanzania-map {
    min-width: 320px;
  }

  .toast-region {
    top: auto;
    right: 8px;
    bottom: 10px;
    width: calc(100vw - 16px);
  }

  .toast {
    border-radius: 18px;
    padding: 14px 16px;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  table {
    min-width: 0;
    background: transparent;
  }

  table thead {
    display: none;
  }

  table tbody {
    display: grid;
    gap: 14px;
  }

  table tr {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel-strong);
    box-shadow: 0 10px 30px rgba(24, 38, 29, 0.06);
  }

  table td {
    display: grid;
    grid-template-columns: minmax(96px, 38%) 1fr;
    gap: 12px;
    padding: 0;
    border-bottom: 0;
    align-items: start;
  }

  table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .inline-actions {
    width: 100%;
  }

  .table-action {
    flex: 1 1 140px;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: clamp(2rem, 14vw, 3rem);
  }

  .auth-card,
  .panel {
    padding: 16px;
  }

  .hero {
    gap: 12px;
  }

  .tabs-bar {
    grid-template-columns: 1fr;
  }

  .form-actions,
  .inline-actions {
    flex-direction: column;
  }

  button,
  .table-action,
  .auth-toggle-button {
    width: 100%;
  }

  table td {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}
