:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #17202a;
  --muted: #6b7280;
  --line: #dfe3ea;
  --accent: #1f8a4c;
  --accent-pressed: #176d3b;
  --accent-soft: #eaf7ef;
  --accent-line: #bfe6ce;
  --danger-soft: #fff5f5;
  --shadow: 0 8px 22px rgba(22, 32, 42, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.app-shell {
  width: min(100%, 680px);
  margin: 0 auto;
  padding: 16px 14px 30px;
}

.app-header {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  margin-bottom: 16px;
}

.back-button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--accent);
  font-size: 38px;
  line-height: 1;
}

.back-button[hidden] {
  display: block;
  visibility: hidden;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 13px;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: 0;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
}

.menu-grid {
  display: grid;
  gap: 12px;
}

.menu-button,
.primary-button,
.secondary-button {
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 8px;
  font-weight: 700;
}

.menu-button {
  padding: 18px;
  background: var(--card);
  color: var(--text);
  text-align: left;
  box-shadow: var(--shadow);
}

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

.form-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

#sprayScreen .form-card {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.field-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.step-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
}

.step-title::before {
  content: "";
  width: 6px;
  height: 22px;
  border-radius: 999px;
  background: var(--accent);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-size: 16px;
}

input,
select {
  min-height: 48px;
  padding: 0 12px;
}

textarea {
  min-height: 96px;
  padding: 12px;
  resize: vertical;
}

.primary-button {
  margin-top: 6px;
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(31, 138, 76, 0.22);
}

.primary-button:active {
  background: var(--accent-pressed);
}

.secondary-button {
  background: var(--accent-soft);
  color: var(--accent);
}

.compact-button {
  min-height: 48px;
}

.field-block {
  display: grid;
  gap: 9px;
}

#sprayScreen .field-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  padding: 12px;
  box-shadow: var(--shadow);
}

.spray-edit-panel {
  display: grid;
  gap: 10px;
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  background: var(--accent-soft);
  padding: 12px;
  box-shadow: var(--shadow);
}

.spray-edit-panel[hidden] {
  display: none;
}

.spray-edit-panel strong {
  display: block;
  color: var(--accent);
  font-size: 16px;
}

.spray-edit-panel p,
.edit-save-warning {
  margin: 0;
  line-height: 1.5;
  font-size: 14px;
}

.spray-edit-panel.is-highlighted {
  outline: 3px solid rgba(31, 138, 76, 0.22);
}

.edit-save-warning {
  border: 1px solid #facc15;
  border-radius: 8px;
  background: #fffbeb;
  color: #8a4b00;
  padding: 10px 12px;
  font-weight: 700;
}

.pesticide-edit-panel {
  display: grid;
  gap: 10px;
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  background: var(--accent-soft);
  padding: 12px;
}

.pesticide-edit-panel[hidden] {
  display: none;
}

.pesticide-edit-panel strong {
  display: block;
  color: var(--accent);
}

.pesticide-edit-panel p {
  margin: 0;
  line-height: 1.5;
  font-size: 14px;
}

.pesticide-management-card {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
}

.section-header-row {
  display: grid;
  grid-template-columns: 1fr minmax(120px, auto);
  gap: 10px;
  align-items: center;
}

.section-header-row h2 {
  margin: 0;
  font-size: 18px;
}

.pesticide-manage-list {
  display: grid;
  gap: 10px;
}

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

.pesticide-manage-item strong,
.pesticide-manage-item span,
.pesticide-manage-item small {
  display: block;
}

.pesticide-manage-item span,
.pesticide-manage-item small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.pesticide-manage-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

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

.choice-button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--accent);
  font-weight: 700;
}

.choice-button.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

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

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

.spray-status-card {
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  padding: 10px 8px;
  background: var(--accent-soft);
  text-align: center;
}

.spray-status-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.spray-status-card strong {
  display: block;
  margin-top: 4px;
  color: var(--accent);
  font-size: 20px;
}

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

.pesticide-check-list {
  display: grid;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
}

.pesticide-check-card {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background: #ffffff;
}

.pesticide-check-card input {
  width: 26px;
  height: 26px;
  margin: 0;
  accent-color: var(--accent);
}

.pesticide-check-card strong,
.pesticide-check-card span {
  display: block;
}

.pesticide-check-card span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.selected-pesticide {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfe;
}

.selected-pesticide strong,
.selected-pesticide span {
  display: block;
}

.calc-result {
  margin-top: 4px;
  color: var(--accent);
  font-size: 20px;
  font-weight: 800;
}

.calc-summary {
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
}

.pre-save-summary {
  display: grid;
  gap: 10px;
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
  box-shadow: var(--shadow);
}

.pre-save-title {
  color: var(--accent);
  font-size: 16px;
  font-weight: 800;
}

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

.pre-save-item {
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  padding: 10px;
  background: var(--accent-soft);
}

.pre-save-item span,
.pre-save-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pre-save-item strong {
  display: block;
  margin-top: 4px;
  color: var(--accent);
  font-size: 18px;
}

.pre-save-block {
  display: grid;
  gap: 6px;
}

.pre-save-list {
  display: grid;
  gap: 6px;
}

.pre-save-line {
  margin: 0;
  padding: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.pre-save-message {
  margin: 0;
  color: #9a3412;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
}

.calc-note {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.remove-button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 24px;
  line-height: 1;
}

.empty-text {
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

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

.basic-info-panel summary {
  min-height: 48px;
  padding: 13px 14px;
  color: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

.panel-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.basic-info-grid {
  display: grid;
  gap: 12px;
  padding: 0 14px 14px;
}

.wide-field {
  grid-column: 1 / -1;
}

.field-application-item,
.field-total-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfe;
}

.inline-input-row {
  display: grid;
  grid-template-columns: 1fr minmax(112px, auto);
  gap: 8px;
  align-items: end;
}

.mini-record-list {
  display: grid;
  gap: 6px;
}

.mini-record-item,
.tank-batch-item {
  display: grid;
  grid-template-columns: 1fr 38px;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fbfcfe;
}

.small-remove-button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 22px;
  line-height: 1;
}

.field-detail-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.field-detail-group summary {
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 700;
}

.field-detail-group .mini-record-list {
  padding: 0 10px 10px;
}

.pre-save-edit-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.pre-save-edit-panel summary {
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 700;
  color: var(--accent);
}

.warning-text {
  display: none;
  margin: 0;
  border-radius: 8px;
  background: var(--danger-soft);
  color: #9a3412;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
}

.warning-text.is-visible {
  display: block;
}

.note {
  margin: 0;
  border-radius: 8px;
  background: var(--danger-soft);
  color: #8a4b00;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
}

#sprayScreen .primary-button {
  min-height: 60px;
  font-size: 17px;
}

.history-filter-panel {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding: 14px 14px 0;
}

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

.history-filter-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.history-filter-count {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.history-list {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
}

.history-item:first-child {
  padding-top: 12px;
}

.history-item strong {
  display: block;
  margin-bottom: 4px;
}

.history-item small {
  color: var(--muted);
}

.spray-history-card {
  overflow: hidden;
  border-left: 4px solid var(--accent);
  padding: 0;
}

.spray-history-summary {
  display: grid;
  gap: 10px;
  padding: 12px;
  cursor: pointer;
  list-style: none;
}

.spray-history-summary::-webkit-details-marker {
  display: none;
}

.history-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.history-type {
  display: block;
  margin-bottom: 3px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.detail-toggle {
  flex: 0 0 auto;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.toggle-opened,
.spray-history-card[open] .toggle-closed {
  display: none;
}

.spray-history-card[open] .toggle-opened {
  display: inline;
}

.history-meta-grid,
.history-detail-grid,
.history-usage-grid {
  display: grid;
  gap: 8px;
}

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

.history-volume-grid {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.history-meta-grid span,
.history-detail-grid span,
.history-usage-grid span {
  display: grid;
  gap: 3px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 9px 10px;
  color: var(--text);
  font-size: 14px;
}

.history-meta-grid b,
.history-detail-grid b,
.history-usage-grid b {
  color: var(--muted);
  font-size: 12px;
}

.history-usage-grid strong {
  margin: 0;
  color: var(--text);
  font-size: 18px;
}

.spray-history-detail {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  background: #ffffff;
  padding: 12px;
}

.history-detail-section {
  display: grid;
  gap: 8px;
}

.history-detail-section h3 {
  margin: 0;
  color: var(--accent);
  font-size: 15px;
}

.history-line-list {
  display: grid;
  gap: 6px;
}

.history-line-list p,
.history-memo,
.history-alert,
.history-note {
  margin: 0;
  border-radius: 8px;
  background: #fbfcfe;
  padding: 9px 10px;
  line-height: 1.5;
  font-size: 14px;
}

.history-line-list p {
  border-left: 3px solid var(--accent-line);
  font-weight: 700;
}

.history-alert,
.history-note {
  font-weight: 700;
}

.history-note {
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}

.history-danger-zone {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.history-edit-button {
  min-width: 120px;
  min-height: 44px;
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.history-delete-button {
  min-width: 120px;
  min-height: 44px;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  background: #fff5f5;
  color: #b91c1c;
  font-weight: 700;
}

.history-delete-button:disabled {
  opacity: 0.6;
}

.status {
  min-height: 24px;
  margin: 16px 4px 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

@media (min-width: 720px) {
  .app-shell {
    padding-top: 32px;
  }

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

  .tank-buttons {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .field-buttons {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }

  .amount-buttons {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .app-shell {
    padding-inline: 10px;
  }

  .spray-status-grid {
    gap: 6px;
  }

  .spray-status-card {
    padding: 8px 6px;
  }

  .spray-status-card strong {
    font-size: 18px;
  }

  .field-buttons,
  .amount-buttons,
  .tank-buttons {
    gap: 7px;
  }
}
