:root {
  color-scheme: light;
  --pa-green: #8ed9a4;
  --pa-green-strong: #5fbf7e;
  --pa-ink: #145c34;
  --pa-heading: #173326;
  --pa-text: #24382d;
  --pa-muted: #5c7264;
  --pa-line: #d7eadc;
  --pa-soft: #f3faf5;
  --pa-card: #ffffff;
  --danger: #8d2f45;
  --danger-bg: #fdecef;
  --progress: #1d6f9a;
  --progress-bg: #e7f4fb;
  --received: #8a5a12;
  --received-bg: #fff6e8;
  --ok: #146b38;
  --ok-bg: #e5f6eb;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--pa-soft);
  color: var(--pa-text);
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.5;
}

body {
  padding-bottom: calc(4.75rem + env(safe-area-inset-bottom));
}

img { max-width: 100%; height: auto; }

a { color: var(--pa-ink); font-weight: 700; }

h1, h2, h3 { color: var(--pa-heading); line-height: 1.25; margin: 0 0 0.6rem; }

h1 { font-size: 1.7rem; }

p { margin: 0 0 0.75rem; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #fff;
  border-bottom: 1px solid var(--pa-line);
  padding-top: env(safe-area-inset-top);
}

.site-header-inner,
.site-main,
.site-footer-inner {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 0.75rem 0;
}

.site-header-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--pa-heading);
  text-decoration: none;
  min-width: 0;
}

.brand img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  border: 1px solid var(--pa-line);
}

.brand strong { display: block; font-size: 1rem; }
.brand small { display: block; color: var(--pa-muted); font-weight: 600; font-size: 0.72rem; }

.header-nav { display: none; gap: 0.35rem; }
.header-nav a, .bottom-nav a {
  color: var(--pa-muted);
  text-decoration: none;
  font-weight: 700;
}
.header-nav a {
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
}
.header-nav a.is-active { background: var(--pa-soft); color: var(--pa-ink); }

.header-tools { display: flex; align-items: center; gap: 0.45rem; margin-left: auto; }

.whatsapp, .header-link, .bell {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 44px;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--pa-line);
  background: #fff;
  text-decoration: none;
  font-size: 0.92rem;
}

.whatsapp { color: #1f8a4c; }

.badge {
  min-width: 1.3rem;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: var(--pa-ink);
  color: #fff;
  font-size: 0.75rem;
  text-align: center;
}

.site-main { padding-top: 0.4rem; padding-bottom: 1.5rem; }

.site-footer {
  border-top: 1px solid var(--pa-line);
  background: #fff;
}

.site-footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--pa-muted);
  font-size: 0.9rem;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  background: #fff;
  border-top: 1px solid var(--pa-line);
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav a {
  flex: 1;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.4rem 0.2rem;
  font-size: 0.78rem;
}

.bottom-nav a.is-active {
  color: var(--pa-ink);
  box-shadow: inset 0 3px 0 var(--pa-green-strong);
}

.panel, .card, .hero {
  background: var(--pa-card);
  border: 1px solid var(--pa-line);
  border-radius: 16px;
  padding: 1rem;
  margin: 0 0 1rem;
}

.hero { background: #fff; }

.narrow { max-width: 460px; margin-left: auto; margin-right: auto; }

.muted { color: var(--pa-muted); font-weight: 500; }

.grid, .filters {
  display: grid;
  gap: 0.75rem;
}

label { display: grid; gap: 0.3rem; font-weight: 700; margin: 0 0 0.8rem; }

.check {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  font-weight: 600;
}

.check input { width: 1.15rem; height: 1.15rem; margin-top: 0.15rem; }

.control, .btn, .text-button {
  font: inherit;
}

.control {
  width: 100%;
  min-height: 48px;
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  border: 1px solid #b7d7c2;
  background: #fff;
  color: var(--pa-text);
}

textarea.control { min-height: 120px; resize: vertical; }

.control:focus {
  outline: 3px solid rgba(95, 191, 126, 0.35);
  border-color: var(--pa-ink);
}

.btn, .text-button {
  min-height: 48px;
  border-radius: 999px;
  padding: 0.7rem 1rem;
  border: 1px solid var(--pa-green-strong);
  font-weight: 800;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--pa-green);
  color: #08331a;
  text-decoration: none;
}

.btn.secondary, .text-button {
  background: #fff;
  color: var(--pa-ink);
}

.text-button { width: auto; margin: 0 0 0.8rem; }

.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  border: 0;
  padding: 0;
  margin: 0 0 1rem;
}

.tile { margin: 0; }

.tile span {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.7rem;
  border-radius: 14px;
  border: 2px solid var(--pa-line);
  background: #fff;
}

.tile input { position: absolute; opacity: 0; pointer-events: none; }
.tile:has(input:checked) span,
.tile input:focus-visible + span {
  border-color: var(--pa-ink);
  background: var(--pa-green);
  color: #08331a;
}

.totals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  margin: 0 0 1rem;
}

.totals article {
  background: #fff;
  border: 1px solid var(--pa-line);
  border-radius: 16px;
  padding: 0.9rem;
}

.totals span { display: block; color: var(--pa-muted); font-weight: 700; font-size: 0.85rem; }
.totals strong { display: block; font-size: 1.8rem; color: var(--pa-ink); }

.card-top, .location-row {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.is-received { color: var(--received); background: var(--received-bg); }
.is-progress { color: var(--progress); background: var(--progress-bg); }
.is-resolved { color: var(--ok); background: var(--ok-bg); }

.thumb, .preview, .photo {
  display: block;
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: 12px;
  margin: 0.4rem 0 0.8rem;
  background: var(--pa-soft);
}

.preview { max-width: 360px; }

.loc-status { margin: 0; min-height: 1.5rem; }
.loc-status:empty { display: none; }
.loc-status.is-captured,
.loc-status.is-fallback {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
}
.loc-status.is-captured { color: var(--pa-ink); }
.loc-status.is-fallback { color: var(--received); font-weight: 700; }
.map-pin {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50% 50% 50% 0;
  background: var(--pa-ink);
  transform: rotate(-45deg);
  flex: 0 0 auto;
}

.notice {
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  margin: 0 0 1rem;
  font-weight: 700;
}

.notice.success { background: var(--ok-bg); color: var(--ok); }
.notice.error { background: var(--danger-bg); color: var(--danger); }

.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.7rem; }
.timeline li { border-top: 1px solid var(--pa-line); padding-top: 0.7rem; }
.timeline span { display: block; color: var(--pa-muted); font-size: 0.85rem; }

.more-list { display: grid; gap: 0.6rem; margin-bottom: 1rem; }
.more-link {
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 0.8rem 1rem;
  background: #fff;
  border: 1px solid var(--pa-line);
  border-radius: 14px;
  text-decoration: none;
}

.is-unread { border-color: var(--pa-green-strong); }

.submit-bar {
  position: sticky;
  bottom: calc(4.4rem + env(safe-area-inset-bottom));
  padding: 0.6rem 0 0.2rem;
  background: #fff;
}

fieldset { border: 1px solid var(--pa-line); border-radius: 12px; margin: 0 0 0.8rem; }
legend { font-weight: 800; padding: 0 0.3rem; }

@media (min-width: 860px) {
  body { padding-bottom: 0; }
  .site-header-inner,
  .site-main,
  .site-footer-inner { width: min(1120px, calc(100% - 3rem)); }
  .site-main { padding-top: 1.25rem; padding-bottom: 3rem; }
  .bottom-nav { display: none; }
  .header-nav {
    display: flex;
    align-items: center;
    margin-left: auto;
    gap: 0.15rem;
  }
  .header-nav + .header-tools { margin-left: 0.75rem; }
  .grid { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: minmax(180px, 280px) minmax(180px, 280px) auto; align-items: end; justify-content: start; }
  .tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .submit-bar { position: static; background: none; }
  .card-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }
  .card-list > .card { margin: 0; }
  .form-shell { max-width: 760px; margin-left: auto; margin-right: auto; }
  .narrow { margin-top: 1.5rem; }
  .totals { max-width: 640px; }
  .category-totals { max-width: none; grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    align-items: start;
  }
  .settings-grid > .panel { margin: 0; }
  .hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
  }
  .hero-action { margin: 0; }
  .action-stack {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.75rem 1rem;
    align-items: end;
  }
  .action-stack form { margin: 0; }
  .action-stack label { margin-bottom: 0; }
}

@media (max-width: 420px) {
  .brand small { display: none; }
}
