:root {
  color-scheme: light;
  --ink: #142017;
  --muted: #5e6d5e;
  --line: rgba(29, 73, 43, 0.18);
  --paper: #f8f6e8;
  --panel: rgba(255, 255, 247, 0.94);
  --field: #eef2d5;
  --green: #1f5f2f;
  --green-deep: #12391f;
  --green-soft: #dcebd1;
  --yellow: #c49316;
  --yellow-bright: #f2c230;
  --yellow-soft: #fff0b8;
  --red: #a13c32;
  --red-soft: #f9dedb;
  --blue: #3a6f8d;
  --blue-soft: #dcebf0;
  --shadow: 0 18px 48px rgba(18, 57, 31, 0.18);
  --inner-glow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(12, 45, 22, 0.56) 0%, rgba(248, 246, 232, 0.74) 31%, rgba(248, 246, 232, 0.96) 68%),
    url("./assets/tractor-field-bg.png");
  background-attachment: fixed;
  background-position: center;
  background-size: cover;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  min-height: 210px;
  padding: 18px 0 26px;
  color: #fffdee;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.38);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--yellow-bright);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 0.95;
  max-width: 760px;
}

.status-pill {
  min-width: 112px;
  border: 1px solid rgba(255, 242, 170, 0.55);
  border-radius: 999px;
  background: rgba(18, 57, 31, 0.72);
  box-shadow: var(--inner-glow), 0 10px 28px rgba(0, 0, 0, 0.18);
  padding: 9px 14px;
  color: #fff4bf;
  font-weight: 700;
  text-align: center;
}

.control-band {
  display: grid;
  grid-template-columns: minmax(250px, 0.7fr) minmax(760px, 1.3fr);
  gap: 14px;
  align-items: end;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 230, 110, 0.35);
  border-radius: 8px;
  background: rgba(250, 249, 232, 0.94);
  box-shadow: var(--shadow);
  padding: 14px;
}

.control-band::before,
.location-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--green-deep), var(--green), var(--yellow-bright), var(--green));
}

.location-form label,
.settings label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

input,
select {
  min-height: 44px;
  width: 100%;
  border: 1px solid rgba(31, 95, 47, 0.24);
  border-radius: 6px;
  background: #fffdf0;
  color: var(--ink);
  padding: 0 12px;
}

.input-row button {
  min-height: 44px;
  border-radius: 6px;
  background: linear-gradient(180deg, #2e7b3f, var(--green));
  box-shadow: var(--inner-glow);
  color: #fff8d2;
  padding: 0 18px;
  font-weight: 800;
}

.settings {
  display: grid;
  grid-template-columns: repeat(7, minmax(96px, 1fr));
  gap: 10px;
}

.unit-input {
  display: grid;
  grid-template-columns: 1fr 34px;
}

.unit-input input {
  border-radius: 6px 0 0 6px;
}

.unit-input span {
  display: grid;
  min-height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 6px 6px 0;
  background: #efe6af;
  color: var(--muted);
  font-weight: 800;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.summary-tile,
.location-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.summary-tile {
  min-height: 94px;
  padding: 16px;
  border-top: 4px solid var(--yellow-bright);
}

.summary-label {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.summary-value {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.05rem, 1.7vw, 1.65rem);
  line-height: 1.1;
  color: var(--green-deep);
}

.plan-band {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.plan-card {
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 252, 230, 0.96), rgba(244, 240, 205, 0.95));
  box-shadow: var(--shadow);
  padding: 16px;
  border-top: 4px solid var(--green);
}

.plan-card span,
.explain-box span,
.hourly-grid > span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.plan-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.16rem;
  line-height: 1.25;
}

.plan-card p {
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.location-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 14px;
}

.location-card {
  display: grid;
  position: relative;
  overflow: hidden;
  gap: 14px;
  padding: 16px;
}

.location-head,
.best-window,
.metrics-row,
.window-row,
.day-cell {
  min-width: 0;
}

.location-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.place-region {
  color: var(--yellow);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.place-name {
  margin-top: 4px;
  font-size: 1.35rem;
  line-height: 1.1;
  color: var(--green-deep);
}

.ghost-button {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #efe6af;
  color: var(--green-deep);
  font-size: 1.2rem;
  font-weight: 900;
}

.best-window {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--inner-glow);
}

.best-window.green {
  background: linear-gradient(135deg, #cfe8bf, #f4e7a8);
}

.best-window.yellow {
  background: linear-gradient(135deg, #fff0b8, #f9dfa0);
}

.best-window.red {
  background: linear-gradient(135deg, #f9dedb, #f1c1ba);
}

.window-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.window-date {
  display: block;
  font-size: 1.35rem;
}

.bale-date {
  display: block;
  font-size: 1.35rem;
  text-align: right;
}

.window-score {
  display: block;
  margin-top: -6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
  text-align: right;
}

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

.insight-strip div,
.explain-box,
.hourly-grid,
.operation-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fffdf0, #f6f1cf);
  padding: 10px;
}

.insight-strip span,
.operation-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.insight-strip strong {
  display: block;
  margin-top: 5px;
  font-size: 1.05rem;
}

.explain-box p {
  margin-top: 6px;
  color: var(--ink);
  font-size: 0.94rem;
  line-height: 1.4;
}

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

.operation-grid strong {
  display: block;
  margin-top: 5px;
  font-size: 1rem;
}

.operation-grid small {
  display: block;
  min-height: 32px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.35;
}

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

.metrics-row div {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fffdf0, #f6f1cf);
  padding: 10px;
}

.metrics-row span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
  text-transform: uppercase;
}

.metrics-row strong {
  display: block;
  margin-top: 7px;
  font-size: 1.08rem;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(10, minmax(54px, 1fr));
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.hourly-grid {
  display: grid;
  gap: 8px;
}

.hourly-grid div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.hourly-grid div:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.hourly-grid strong {
  flex: 0 0 auto;
}

.hourly-grid span:not(:first-child) {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
  text-align: right;
}

.day-cell {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 5px;
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf0;
  padding: 8px;
}

.day-cell.green {
  border-color: rgba(39, 116, 71, 0.45);
  background: #dcebd1;
}

.day-cell.yellow {
  border-color: rgba(168, 111, 0, 0.5);
  background: #fff0b8;
}

.day-cell.red {
  border-color: rgba(161, 60, 50, 0.45);
  background: var(--red-soft);
}

.day-name {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.day-date {
  font-weight: 900;
}

.day-temp {
  font-size: 1.12rem;
  font-weight: 900;
}

.day-detail {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
}

.windows-list {
  display: grid;
  gap: 8px;
}

.window-row {
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 9px;
}

.rating-badge {
  width: fit-content;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.rating-badge.green {
  background: var(--green);
  color: #fff8d2;
}

.rating-badge.yellow {
  background: var(--yellow);
  color: #fff;
}

.rating-badge.red {
  background: var(--red);
  color: #fff;
}

.window-reason {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.window-row strong {
  line-height: 1.35;
  text-align: right;
}

.empty-state,
.error-state {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 24px;
  box-shadow: var(--shadow);
  color: var(--muted);
  font-weight: 750;
}

.error-state {
  border-color: rgba(161, 60, 50, 0.35);
  color: var(--red);
}

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

  .topbar,
  .control-band {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .settings,
  .summary-grid,
  .plan-band {
    grid-template-columns: 1fr;
  }

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

  .metrics-row,
  .insight-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .metrics-row div,
  .insight-strip div {
    min-height: 68px;
    padding: 8px;
  }

  .metrics-row strong,
  .insight-strip strong {
    font-size: 0.92rem;
  }

  .hourly-grid div {
    display: grid;
  }

  .hourly-grid span:not(:first-child) {
    text-align: left;
  }

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

  .best-window {
    grid-template-columns: 1fr;
  }

  .bale-date,
  .window-score {
    text-align: left;
  }

  .window-row strong {
    text-align: left;
  }
}
