:root {
  --bg: #f4f1ea;
  --card: #fffdf8;
  --text: #1f2a24;
  --muted: #637168;
  --line: #ddd4c5;
  --green: #4f7f52;
  --green-dark: #2f5f37;
  --orange: #c9792a;
  --red: #b9483f;
  --blue: #2d6cdf;
  --shadow: 0 12px 28px rgba(31, 42, 36, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(135deg, #efe8dc, #f7f4ee);
  color: var(--text);
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

.app-header {
  padding: max(.75rem, env(safe-area-inset-top)) .85rem .65rem;
}
.eyebrow {
  margin: 0 0 .18rem;
  color: var(--green-dark);
  font-size: .74rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
h1 { margin: 0; font-size: 1.9rem; line-height: 1; }
.subline { margin: .35rem 0 0; color: var(--muted); font-size: .92rem; }

.app-shell {
  display: grid;
  gap: .75rem;
  padding: 0 .75rem max(1rem, env(safe-area-inset-bottom));
  max-width: 980px;
  margin: 0 auto;
}

.controls-card,
.mission,
.map-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.controls-card { padding: .9rem; }

.field-label {
  display: block;
  margin: .05rem 0 .35rem;
  font-size: .84rem;
  color: var(--muted);
  font-weight: 850;
}
.select,
.kitze-select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--text);
  font-size: 1rem;
  padding: .9rem .85rem;
  min-height: 48px;
}

.filters,
.top-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .45rem;
  margin-top: .75rem;
}
.top-actions { grid-template-columns: 1fr 1fr; }
button, a, select { touch-action: manipulation; }
.ghost-btn,
.filter,
.status-btn,
.map-toggle,
.action-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: .78rem .65rem;
  font-weight: 850;
  font-size: .95rem;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  min-height: 46px;
}
.filter.active { background: var(--green-dark); border-color: var(--green-dark); color: #fff; }
.summary {
  margin-top: .8rem;
  padding: .78rem .85rem;
  border-radius: 16px;
  background: #efe8dc;
  color: var(--muted);
  font-weight: 750;
}
.progress { margin-top: .55rem; height: 9px; border-radius: 999px; background: #ded5c8; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0%; background: var(--green); }

.mission-list { display: grid; gap: .75rem; }
.mission { padding: .9rem; overflow: hidden; }
.mission.is-done { background: #f4fbf3; border-color: rgba(79,127,82,.48); }
.mission.empty { padding: 1rem; color: var(--muted); font-weight: 750; }
.mission-head { display: flex; justify-content: space-between; gap: .65rem; align-items: flex-start; }
.mission h2 { margin: 0; font-size: 1.16rem; line-height: 1.2; overflow-wrap: anywhere; }
.badge { flex: 0 0 auto; border-radius: 999px; padding: .22rem .55rem; color: #fff; font-size: .76rem; font-weight: 900; }
.badge.today { background: var(--orange); }
.badge.tomorrow { background: #b87333; }
.badge.later { background: var(--red); }
.badge.done { background: var(--green); }

.meta { display: grid; gap: .28rem; margin: .65rem 0 .8rem; color: var(--muted); font-size: .94rem; overflow-wrap: anywhere; }
.meta a { color: var(--green-dark); font-weight: 800; }
.feedback-grid { display: grid; grid-template-columns: 1fr 98px; gap: .55rem; align-items: end; }
.status-btn { width: 100%; border: 0; color: #fff; background: var(--orange); }
.status-btn.is-done { background: var(--green); }
.kitze-box label { display: grid; gap: .28rem; font-size: .82rem; color: var(--muted); font-weight: 850; }
.kitze-select { padding: .7rem .75rem; border-radius: 14px; min-height: 46px; }
.save-state { min-height: 1rem; margin: .45rem 0 .7rem; color: var(--muted); font-size: .78rem; font-weight: 800; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; }
.action-btn { display: flex; align-items: center; justify-content: center; background: var(--green-dark); border-color: var(--green-dark); color: #fff; padding: .7rem .45rem; }
.action-btn.secondary { background: #786851; border-color: #786851; }
.action-btn.light { background: #fff; border-color: var(--line); color: var(--text); }

.map-panel { overflow: hidden; }
.map-toggle { width: 100%; border: 0; border-radius: 0; background: var(--green-dark); color: #fff; }
.map-wrap { position: relative; height: 310px; background: #d8d2c5; }
#map { width: 100%; height: 100%; }
.legend {
  position: absolute;
  left: .55rem;
  right: .55rem;
  bottom: .55rem;
  z-index: 500;
  display: flex;
  flex-wrap: wrap;
  gap: .35rem .55rem;
  max-height: 70px;
  overflow: hidden;
  padding: .45rem .55rem;
  border-radius: 16px;
  background: rgba(255,253,248,.93);
  border: 1px solid var(--line);
  box-shadow: 0 8px 20px rgba(0,0,0,.12);
  font-size: .78rem;
  pointer-events: none;
}
.dot { display: inline-block; width: .7rem; height: .7rem; margin-right: .32rem; border-radius: 50%; }
.dot.open { background: var(--orange); }
.dot.tomorrow { background: #b87333; }
.dot.done { background: var(--green); }
.dot.own { background: var(--blue); }

.flash-polygon { animation: flashStroke .9s ease-in-out 2; }
@keyframes flashStroke { 0%,100% { filter: none; } 50% { filter: drop-shadow(0 0 8px #ffd400); } }

@media (min-width: 760px) {
  .app-header { padding-left: 1.25rem; padding-right: 1.25rem; }
  .app-shell { padding-left: 1.25rem; padding-right: 1.25rem; }
  .mission-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-wrap { height: 430px; }
}

@media (max-width: 380px) {
  .top-actions, .actions, .feedback-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .map-wrap { height: 270px; }
}
