:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #102033;
  --muted: #62718a;
  --line: #dce4ef;
  --blue: #0b5cad;
  --blue-2: #0a74c9;
  --green: #1f8a70;
  --yellow: #f2b705;
  --coral: #e2574c;
  --violet: #6554c0;
  --shadow: 0 14px 38px rgba(19, 38, 67, .12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(12px, env(safe-area-inset-top)) clamp(14px, 3vw, 28px) 12px;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.brand img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.brand span {
  display: grid;
  line-height: 1.05;
}

.brand strong {
  font-size: 16px;
}

.brand small {
  color: var(--muted);
  margin-top: 3px;
}

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

.icon-button,
.ghost-button,
.primary-button,
.submit-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  min-height: 44px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.icon-button {
  width: 44px;
}

.primary-button,
.submit-button {
  padding: 0 16px;
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 700;
}

.ghost-button {
  padding: 0 14px;
  font-weight: 700;
}

.submit-button {
  width: 100%;
  min-height: 52px;
  font-size: 17px;
}

main {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 54px;
}

.hero {
  min-height: clamp(250px, 43vh, 430px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 380px);
  gap: 24px;
  align-items: end;
  padding: clamp(28px, 6vw, 54px);
  border-radius: var(--radius);
  color: #fff;
  background:
    linear-gradient(rgba(8, 42, 79, .24), rgba(8, 42, 79, .5)),
    image-set(
      url("https://images.unsplash.com/photo-1500534314209-a25ddb2bd429?auto=format&fit=crop&w=1600&q=80") 1x
    ) center / cover;
  overflow: hidden;
}

.hero h1 {
  margin: 12px 0 10px;
  font-size: clamp(38px, 7vw, 74px);
  line-height: .95;
  max-width: 760px;
}

.hero p {
  margin: 0;
  font-size: clamp(17px, 2.1vw, 22px);
  line-height: 1.45;
  max-width: 680px;
}

.live-badge,
.section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
}

.live-badge span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #2ee391;
  box-shadow: 0 0 0 6px rgba(46, 227, 145, .2);
}

.section-kicker {
  color: var(--blue);
}

.hero-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.hero-panel div {
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, .34);
  border-radius: var(--radius);
  background: rgba(6, 34, 64, .45);
  backdrop-filter: blur(10px);
}

.hero-panel small {
  display: block;
  color: rgba(255, 255, 255, .78);
}

.hero-panel strong {
  display: block;
  margin-top: 3px;
  font-size: clamp(24px, 5vw, 36px);
}

.compose-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.28fr) minmax(300px, .72fr);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.report-form,
.side-panel,
.map-section,
.data-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.report-form,
.side-panel,
.data-section {
  padding: clamp(16px, 3vw, 24px);
}

.form-head,
.panel-head,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

h2 {
  margin: 4px 0 0;
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.1;
}

.position-line {
  margin: 8px 0 0;
  color: var(--green);
  font-weight: 800;
  line-height: 1.3;
}

output {
  color: var(--muted);
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 18px;
}

legend,
label > span {
  display: block;
  margin-bottom: 8px;
  color: #2b3b51;
  font-weight: 750;
}

.weather-picks {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.weather-picks label,
.choice-pills label {
  position: relative;
  min-width: 0;
}

.weather-picks input,
.choice-pills input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.weather-picks span,
.choice-pills span,
.photo-action {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  min-height: 58px;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f9fbfe;
  font-weight: 900;
  text-align: center;
  white-space: normal;
}

.weather-picks span {
  min-height: 78px;
  line-height: 1.1;
}

.weather-picks b {
  display: block;
  font-size: 27px;
  line-height: 1;
  font-weight: 900;
}

.choice-pills span,
.photo-action {
  flex-direction: row;
}

.weather-picks input:checked + span,
.choice-pills input:checked + span {
  background: #eaf4ff;
  border-color: var(--blue);
  color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
}

.choice-pills {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.choice-pills {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

label {
  min-width: 0;
}

input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  min-height: 46px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 94px;
}

input:focus,
textarea:focus,
select:focus,
button:focus-visible {
  border-color: var(--blue-2);
  box-shadow: 0 0 0 3px rgba(10, 116, 201, .18);
}

.photo-field {
  display: block;
  margin: 0 0 14px;
}

.photo-field input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.photo-action {
  background: #eef7f3;
  border-color: #bddfd5;
  color: #126e5c;
}

.photo-preview {
  margin: 12px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 92px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #f9fbff;
  color: var(--muted);
  overflow: hidden;
}

.photo-preview[hidden] {
  display: none;
}

.photo-preview img {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
}

.context-strip {
  margin: 10px 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: #f4f8fc;
  color: #41536d;
  font-size: 14px;
}

.side-panel {
  position: sticky;
  top: 84px;
}

.trend-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.trend-strip span {
  padding: 10px;
  background: #f9fbff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
}

.trend-strip small {
  display: block;
  color: var(--muted);
}

.trend-strip b {
  font-size: 20px;
}

.feed-list {
  display: grid;
  gap: 10px;
  max-height: 720px;
  overflow: auto;
  padding-right: 2px;
}

.report-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.report-item.has-photo {
  grid-template-columns: 84px minmax(0, 1fr);
}

.report-item img {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: var(--radius);
}

.report-item h3 {
  margin: 2px 0 4px;
  font-size: 16px;
}

.report-item p {
  margin: 0;
  color: #384a62;
  line-height: 1.35;
}

.report-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef4fb;
  color: #294260;
  font-weight: 800;
  font-size: 12px;
}

.chip.pioggia,
.chip.temporale {
  background: #e8f4ff;
  color: #075aa5;
}

.chip.grandine,
.chip.freddo {
  background: #eef7fa;
  color: #236779;
}

.chip.vento,
.chip.mare {
  background: #e9f7f3;
  color: #126e5c;
}

.chip.caldo,
.chip.afa {
  background: #fff2e7;
  color: #a9471f;
}

.chip.umidita {
  background: #f1edff;
  color: #5542a8;
}

.chip.danno {
  background: #ffeceb;
  color: #a63831;
}

.map-section {
  margin-top: 18px;
  overflow: hidden;
}

.map-section .section-head {
  padding: 20px 20px 0;
}

.map-section select {
  width: min(260px, 100%);
}

.reports-map {
  height: min(72vh, 680px);
  min-height: 420px;
  margin-top: 12px;
  border-top: 1px solid var(--line);
}

.leaflet-popup-content {
  margin: 12px;
  min-width: 210px;
}

.popup-title {
  margin: 0 0 4px;
  font-size: 16px;
}

.popup-photo {
  width: 100%;
  max-height: 150px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-top: 8px;
}

.data-section {
  margin-top: 18px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: #fff;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid #edf1f7;
  text-align: left;
  vertical-align: top;
}

th {
  color: #5c6c84;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  background: #f9fbff;
}

td {
  font-size: 14px;
}

.empty-state {
  padding: 18px;
  border: 1px dashed #bdcadd;
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 2000;
  width: min(520px, calc(100% - 28px));
  padding: 13px 15px;
  border-radius: var(--radius);
  background: #102033;
  color: #fff;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .26);
}

.toast.error {
  background: #9f302a;
}

.toast.success {
  background: #16755e;
}

@media (max-width: 920px) {
  main {
    width: min(100% - 20px, 780px);
  }

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

  .side-panel {
    position: static;
  }

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

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

@media (max-width: 640px) {
  .topbar {
    padding-left: 10px;
    padding-right: 10px;
  }

  .brand img {
    width: 38px;
    height: 38px;
  }

  main {
    width: 100%;
    padding-top: 0;
  }

  .hero,
  .report-form,
  .side-panel,
  .map-section,
  .data-section {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .hero {
    min-height: 410px;
    padding: 26px 16px;
    align-content: end;
  }

  .hero-panel,
  .choice-pills,
  .trend-strip {
    grid-template-columns: 1fr;
  }

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

  .reports-map {
    height: 62vh;
    min-height: 390px;
  }

  .report-item.has-photo {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .report-item img {
    width: 72px;
    height: 72px;
  }
}
