:root {
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-2: #edf3ef;
  --ink: #1b2620;
  --muted: #66736b;
  --line: #dce4df;
  --green: #2f7d4b;
  --green-2: #d9efe2;
  --blue: #2d76b8;
  --blue-2: #dcecf8;
  --amber: #bc7b19;
  --amber-2: #faefd8;
  --red: #b84d43;
  --red-2: #f7e2df;
  --soil: #4b3f35;
  --shadow: 0 12px 34px rgba(30, 44, 35, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(245, 247, 244, 0.92) 28rem),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1800px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 20px 0 28px;
}

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

.brand-block {
  display: flex;
  align-items: center;
  min-width: 280px;
  gap: 13px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid #c9d9cf;
  border-radius: 8px;
  color: var(--surface);
  background: linear-gradient(135deg, #275d39, #4d8b51);
  font-size: 13px;
  font-weight: 800;
}

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

h1 {
  font-size: clamp(22px, 2.1vw, 34px);
  font-weight: 780;
  letter-spacing: 0;
  line-height: 1.04;
}

h2 {
  font-size: 17px;
  font-weight: 720;
  line-height: 1.2;
}

h3 {
  font-size: 13px;
  font-weight: 760;
  line-height: 1.2;
}

.brand-block p,
.panel-head p,
.metric p,
.metric small,
.field-strip span,
.compact-list dt,
.phase-window span,
.current-weather span {
  color: var(--muted);
}

.brand-block p,
.panel-head p {
  margin-top: 4px;
  font-size: 13px;
}

.map-weather-summary {
  color: #48554d;
  font-weight: 700;
}

.control-rack {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
}

.control-rack label,
.number-field {
  display: grid;
  gap: 5px;
  color: #59675f;
  font-size: 12px;
  font-weight: 680;
}

select,
input[type="date"],
input[type="number"] {
  height: 38px;
  min-width: 130px;
  border: 1px solid #cfdad4;
  border-radius: 7px;
  color: var(--ink);
  background: var(--surface);
  padding: 0 11px;
  outline: none;
}

select:focus,
input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 125, 75, 0.13);
}

.primary-button,
.file-loader {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  border: 0;
  border-radius: 7px;
  color: #fff;
  background: var(--green);
  padding: 0 14px;
  font-size: 13px;
  font-weight: 760;
  cursor: pointer;
}

.primary-button svg,
.file-loader svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.2;
}

.file-loader {
  border: 1px solid #cfdad4;
  color: var(--ink);
  background: #f9fbfa;
}

.file-loader input {
  display: none;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(310px, 0.93fr) minmax(620px, 1.55fr) minmax(290px, 0.82fr);
  gap: 16px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 16px 12px;
}

.map-panel,
.forecast-panel,
.chart-panel,
.output-panel,
.month-panel,
.side-panel {
  overflow: hidden;
}

.map-shell {
  position: relative;
}

.map-canvas,
.map-fallback {
  height: min(57vh, 610px);
  min-height: 430px;
  background: #dce8e0;
}

.map-all-button {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 500;
  min-width: 58px;
  height: 38px;
  border: 1px solid #bcd7c8;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 22px rgba(25, 38, 31, 0.16);
  color: #1f6f43;
  cursor: pointer;
  font-size: 13px;
  font-weight: 820;
  transform: translateX(-50%);
}

.map-all-button:hover {
  border-color: #1f9a51;
  color: #0f8f3e;
}

.map-fallback {
  display: grid;
  place-items: center;
  padding: 18px;
}

.fallback-svg {
  width: 100%;
  height: 100%;
  min-height: 360px;
}

.field-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  background: #fbfcfb;
}

.field-strip div {
  display: grid;
  gap: 4px;
  padding: 13px 14px;
  border-right: 1px solid var(--line);
}

.field-strip div:last-child {
  border-right: 0;
}

.field-strip span {
  font-size: 11px;
  font-weight: 720;
  text-transform: uppercase;
}

.field-strip strong {
  font-size: 14px;
}

.workbench {
  display: grid;
  gap: 16px;
}

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

.metric {
  display: grid;
  min-height: 118px;
  grid-template-rows: auto auto 1fr auto;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 13px;
  box-shadow: var(--shadow);
}

.metric svg {
  width: 19px;
  height: 19px;
  margin-bottom: 10px;
  color: var(--green);
  stroke-width: 2.1;
}

.metric p {
  font-size: 12px;
  font-weight: 740;
}

.metric strong {
  margin-top: 6px;
  font-size: clamp(22px, 3vw, 33px);
  line-height: 1;
}

.metric small {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.25;
}

.legend-row {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  border-radius: 50%;
}

.legend-dot.good {
  background: var(--green);
}

.legend-dot.risk {
  background: var(--amber);
}

.legend-dot.bad {
  background: var(--red);
}

.hourly-timeline {
  display: grid;
  gap: 13px;
  padding: 0 16px 16px;
}

.day-row {
  display: grid;
  grid-template-columns: 126px 1fr 84px;
  gap: 12px;
  align-items: center;
}

.day-label strong {
  display: block;
  font-size: 14px;
  line-height: 1.2;
}

.day-label span,
.day-stat {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.hour-band {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  height: 44px;
  overflow: hidden;
  border: 1px solid #d7e0da;
  border-radius: 7px;
  background: #f2f5f3;
}

.hour-cell {
  position: relative;
  min-width: 16px;
  border-right: 1px solid rgba(255, 255, 255, 0.72);
}

.hour-cell:last-child {
  border-right: 0;
}

.hour-cell.good {
  background: linear-gradient(180deg, #3f965e, #2f7d4b);
}

.hour-cell.risk {
  background: linear-gradient(180deg, #d59531, #bc7b19);
}

.hour-cell.bad {
  background: linear-gradient(180deg, #cc685e, #b84d43);
}

.hour-cell.night {
  background: repeating-linear-gradient(
    -45deg,
    #dbe2de,
    #dbe2de 6px,
    #cfd8d3 6px,
    #cfd8d3 12px
  );
}

.hour-cell::after {
  content: attr(data-hour);
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.82);
  font-size: 9px;
  font-weight: 760;
}

.hour-cell.night::after {
  color: #6b756f;
}

.split-row {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.8fr);
  gap: 16px;
}

.chart-wrap {
  height: 260px;
  padding: 0 16px 16px;
}

.history-bars {
  display: grid;
  gap: 7px;
  padding: 0 16px 16px;
}

.history-bar {
  display: grid;
  grid-template-columns: 74px 1fr 46px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.history-bar span {
  color: var(--muted);
}

.history-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2ef;
}

.history-fill {
  display: block;
  height: 100%;
  background: var(--green);
}

.output-panel {
  min-height: 354px;
}

.number-field {
  margin: 0 16px 16px;
}

.number-field input {
  width: 100%;
}

.output-score {
  display: grid;
  gap: 4px;
  margin: 0 16px;
}

.output-score span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.output-score strong {
  font-size: 26px;
  line-height: 1.05;
}

.progress-track {
  height: 10px;
  margin: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #ecf1ee;
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
  transition: width 240ms ease;
}

.progress-track.pending span {
  background: #c8d4cd;
}

.month-panel {
  min-height: 210px;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  padding: 0 16px 16px;
}

.month-day {
  display: grid;
  gap: 4px;
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfb;
  padding: 8px;
  color: var(--ink);
  text-align: left;
  cursor: help;
}

.month-day span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 740;
}

.month-day strong {
  font-size: 13px;
  line-height: 1.1;
}

.month-day small {
  color: #59675f;
  font-size: 11px;
  font-weight: 680;
  line-height: 1.2;
}

.month-day.good {
  border-color: #cfe3d5;
  background: #f3faf6;
}

.month-day.good strong {
  color: var(--green);
}

.month-day.risk {
  border-color: #ecd3a6;
  background: var(--amber-2);
}

.month-day.risk strong {
  color: var(--amber);
}

.month-day.bad {
  border-color: #ebc5bf;
  background: var(--red-2);
}

.month-day.bad strong {
  color: var(--red);
}

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

.current-weather {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 16px 14px;
  padding: 14px;
  border: 1px solid #d9e4dd;
  border-radius: 8px;
  background: linear-gradient(135deg, #f5fbf7, #edf6fb);
}

.weather-icon {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 8px;
  color: var(--blue);
  background: #fff;
}

.weather-icon svg {
  width: 26px;
  height: 26px;
}

.current-weather strong {
  display: block;
  font-size: 31px;
  line-height: 1;
}

.current-weather span {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  font-weight: 700;
}

.compact-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0 16px 16px;
}

.compact-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 38px;
  border-bottom: 1px solid var(--line);
}

.compact-list div:last-child {
  border-bottom: 0;
}

.compact-list dt,
.compact-list dd {
  margin: 0;
  font-size: 13px;
}

.compact-list dt {
  font-weight: 690;
}

.compact-list dd {
  font-weight: 780;
  text-align: right;
}

.threshold-box,
.action-list {
  margin: 0 16px 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.threshold-box ul,
.action-list ul {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.threshold-box li,
.action-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: #425047;
  font-size: 13px;
  line-height: 1.3;
}

.threshold-box li::before,
.action-list li::before {
  content: "";
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--green);
}

.action-list li.warn::before {
  background: var(--amber);
}

.action-list li.stop::before {
  background: var(--red);
}

.phase-window {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 0 16px 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.phase-window div {
  display: grid;
  gap: 4px;
  padding: 12px;
  background: #fbfcfb;
}

.phase-window span {
  font-size: 12px;
  font-weight: 720;
}

.phase-window strong {
  font-size: 17px;
}

.leaflet-container {
  font: inherit;
}

.weather-area-icon {
  border: 0;
  background: transparent;
}

.weather-area-marker {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid #d6e1db;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 22px rgba(25, 38, 31, 0.14);
  padding: 0;
  color: var(--ink);
  backdrop-filter: blur(6px);
}

.weather-area-marker svg {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  stroke-width: 2.2;
}

.weather-area-marker div {
  position: absolute;
  left: 42px;
  z-index: 2;
  display: none;
  gap: 1px;
  min-width: 94px;
  border: 1px solid #d6e1db;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 22px rgba(25, 38, 31, 0.14);
  padding: 7px 9px;
}

.weather-area-marker:hover div {
  display: grid;
}

.weather-area-marker strong {
  overflow: hidden;
  font-size: 12px;
  font-weight: 790;
  line-height: 1.08;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weather-area-marker small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 760;
  line-height: 1.05;
}

.weather-area-marker.good svg,
.weather-area-marker.good strong {
  color: var(--green);
}

.weather-area-marker.risk svg,
.weather-area-marker.risk strong {
  color: var(--amber);
}

.weather-area-marker.bad svg,
.weather-area-marker.bad strong {
  color: var(--red);
}

.weather-area-marker.nodata svg,
.weather-area-marker.nodata strong {
  color: #68746d;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  color: var(--ink);
  border-radius: 8px;
}

.field-popup strong {
  display: block;
  margin-bottom: 4px;
}

.area-popup {
  min-width: 220px;
}

.area-popup strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.area-popup span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.area-popup dl {
  display: grid;
  gap: 5px;
  margin: 0;
}

.area-popup div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 5px;
}

.area-popup dt,
.area-popup dd {
  margin: 0;
  font-size: 12px;
}

.area-popup dt {
  color: var(--muted);
  font-weight: 700;
}

.area-popup dd {
  font-weight: 780;
  text-align: right;
}

.loading-note,
.error-note {
  display: grid;
  min-height: 160px;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  font-weight: 720;
}

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

  .control-rack {
    justify-content: flex-start;
  }

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

  .side-panel {
    position: static;
  }

  .map-canvas,
  .map-fallback {
    height: 480px;
    min-height: 360px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 20px, 720px);
    padding-top: 12px;
  }

  .brand-block {
    min-width: 0;
  }

  .control-rack {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .control-rack label,
  .primary-button {
    width: 100%;
  }

  select,
  input[type="date"] {
    min-width: 0;
    width: 100%;
  }

  .kpi-grid,
  .split-row,
  .field-strip,
  .phase-window,
  .month-grid {
    grid-template-columns: 1fr;
  }

  .day-row {
    grid-template-columns: 1fr;
  }

  .day-stat {
    text-align: left;
  }

  .chart-wrap {
    height: 230px;
  }

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