/* 栽培歴（cultivation-history.js）・栽培設定（cultivation-setting.js）共通 */
.cult-modal {
  position: fixed;
  inset: 0;
  z-index: 10080;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  font-family: sans-serif;
  color: #333;
}

.cult-modal--setting {
  z-index: 10090;
}

.cult-modal *,
.cult-modal *::before,
.cult-modal *::after {
  box-sizing: border-box;
}

.cult-dialog {
  display: flex;
  flex-direction: column;
  width: min(980px, 96vw);
  max-height: 92vh;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

.cult-head {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 12px 16px;
  background: #f1f8e9;
  border-bottom: 1px solid #dcedc8;
}

.cult-title {
  flex: 1;
  min-width: 0;
  font-size: 17px;
  font-weight: 700;
  color: #1b5e20;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cult-title-sub {
  margin-left: 8px;
  font-size: 12px;
  font-weight: normal;
  color: #666;
}

.cult-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: #555;
  cursor: pointer;
}

.cult-close:hover {
  background: rgba(0, 0, 0, 0.06);
}

.cult-tabs {
  display: flex;
  flex-shrink: 0;
  gap: 2px;
  padding: 0 10px;
  border-bottom: 1px solid #e3e8e3;
  overflow-x: auto;
  overflow-y: hidden;
}

.cult-tab {
  padding: 10px 14px;
  border: none;
  border-bottom: 3px solid transparent;
  background: none;
  font-size: 14px;
  color: #555;
  cursor: pointer;
  white-space: nowrap;
}

.cult-tab.active {
  border-bottom-color: #2e7d32;
  color: #2e7d32;
  font-weight: 700;
}

.cult-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px 18px;
}

/* ---- 汎用パーツ ---- */
.cult-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.cult-spacer {
  flex: 1;
}

.cult-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 12px;
  border: 1px solid #c8d1c8;
  border-radius: 8px;
  background: #fff;
  color: #333;
  font-size: 13px;
  line-height: 1.3;
  white-space: nowrap;
  cursor: pointer;
}

.cult-btn:hover {
  background: #f5f7f5;
}

.cult-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.cult-btn--primary {
  border-color: #2e7d32;
  background: #2e7d32;
  color: #fff;
  font-weight: 700;
}

.cult-btn--primary:hover {
  background: #256b29;
}

.cult-btn--ghost {
  border-color: transparent;
  background: transparent;
  color: #2e7d32;
}

.cult-btn--ghost:hover {
  background: #e8f5e9;
}

.cult-btn--danger {
  border-color: #ef9a9a;
  color: #c62828;
}

.cult-btn--danger:hover {
  background: #ffebee;
}

.cult-btn--sm {
  padding: 4px 8px;
  font-size: 12px;
}

.cult-head-btn {
  flex-shrink: 0;
}

.cult-link-btn {
  padding: 0;
  border: none;
  background: none;
  color: #1565c0;
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}

.cult-icon-btn {
  padding: 4px 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
}

.cult-icon-btn:hover {
  background: #f1f1f1;
}

.cult-icon-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.cult-icon-btn--danger:hover {
  background: #ffebee;
}

.cult-input {
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid #ccc;
  border-radius: 7px;
  background: #fff;
  color: #333;
  font-size: 14px;
}

.cult-input:focus {
  outline: 2px solid #a5d6a7;
  outline-offset: 0;
  border-color: #66bb6a;
}

.cult-input--num {
  width: 84px;
}

.cult-input--search {
  width: 220px;
  max-width: 100%;
}

.cult-field .cult-field-row .cult-input--unit {
  flex: 0 1 auto;
  width: auto;
  min-width: 0;
  max-width: 58%;
}

.cult-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #555;
}

.cult-field > .cult-input,
.cult-field > select.cult-input {
  width: 100%;
}

.cult-field small {
  font-size: 11px;
  color: #888;
}

.cult-field--wide {
  grid-column: span 2;
}

.cult-field-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #555;
}

.cult-field-row .cult-input {
  flex: 1 1 64px;
  min-width: 64px;
  width: 100%;
}

.cult-field-inline {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #555;
}

.cult-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px 12px;
  margin-bottom: 10px;
}

.cult-section {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid #e3e8e3;
  border-radius: 10px;
  background: #fff;
}

.cult-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  margin-bottom: 8px;
}

.cult-section-head b {
  font-size: 14px;
}

.cult-muted {
  font-size: 12px;
  color: #777;
}

.cult-note {
  margin-top: 2px;
  font-size: 11px;
  color: #888;
}

.cult-warn {
  margin: 8px 0;
  padding: 8px 10px;
  border: 1px solid #ffe082;
  border-radius: 8px;
  background: #fff8e1;
  color: #8d6e00;
  font-size: 13px;
}

.cult-warn-inline {
  font-size: 12px;
  color: #b26a00;
}

.cult-message {
  margin: 6px 0 10px;
  padding: 8px 10px;
  border: 1px solid #c8e6c9;
  border-radius: 8px;
  background: #e8f5e9;
  color: #1b5e20;
  font-size: 13px;
}

.cult-status-line {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 0 0 10px;
}

.cult-empty {
  padding: 28px 12px;
  color: #666;
  text-align: center;
  font-size: 14px;
}

.cult-empty--intro {
  max-width: 640px;
  margin: 20px auto;
  padding: 20px;
  border: 1px dashed #c5e1a5;
  border-radius: 12px;
  background: #f9fbf7;
  line-height: 1.8;
  text-align: left;
}

.cult-empty-title {
  margin-bottom: 6px;
  font-size: 16px;
  font-weight: 700;
  color: #2e7d32;
}

.cult-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 1px 4px 1px 0;
  padding: 1px 8px;
  border: 1px solid #e0e0e0;
  border-radius: 999px;
  background: #fafafa;
  color: #555;
  font-size: 11px;
  line-height: 1.6;
  white-space: nowrap;
}

.cult-chip--ok { border-color: #c8e6c9; background: #e8f5e9; color: #2e7d32; }
.cult-chip--warn { border-color: #ffe082; background: #fff8e1; color: #a66900; }
.cult-chip--info { border-color: #bbdefb; background: #e3f2fd; color: #1565c0; }
.cult-chip--muted { border-color: #e0e0e0; background: #f1f1f1; color: #777; }
.cult-chip--danger { border-color: #ffcdd2; background: #ffebee; color: #c62828; }
.cult-chip--edit { border-color: #ffe0b2; background: #fff3e0; color: #e65100; }

.cult-chip-x {
  padding: 0 0 0 2px;
  border: none;
  background: none;
  color: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.cult-cat {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.cult-cond {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #e8f5e9;
  color: #33691e;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.cult-cond--house_cold { background: #e3f2fd; color: #1565c0; }
.cult-cond--house_heated { background: #fce4ec; color: #ad1457; }

.cult-seg {
  display: inline-flex;
  border: 1px solid #c8d1c8;
  border-radius: 8px;
  overflow: hidden;
}

.cult-seg-btn {
  padding: 6px 12px;
  border: none;
  border-left: 1px solid #e0e0e0;
  background: #fff;
  color: #333;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.cult-seg-btn:first-child {
  border-left: none;
}

.cult-seg-btn.active {
  background: #2e7d32;
  color: #fff;
  font-weight: 700;
}

.cult-seg--wide {
  display: flex;
  margin-top: 4px;
}

.cult-seg--wide .cult-seg-btn {
  flex: 1;
  padding: 9px 6px;
}

.cult-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: #333;
  cursor: pointer;
}

.cult-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 4px;
}

.cult-check--box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid #dcedc8;
  border-radius: 10px;
  background: #f9fbf7;
  line-height: 1.5;
}

.cult-check--box input {
  margin-top: 3px;
}

.cult-check--box .cult-muted {
  display: block;
  margin-top: 2px;
}

.cult-actions-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
}

.cult-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px -16px 0;
  padding: 10px 16px 12px;
  border-top: 1px solid #e8e8e8;
  background: rgba(255, 255, 255, 0.97);
}

.cult-table-wrap {
  margin: 8px 0;
  border: 1px solid #e3e8e3;
  border-radius: 10px;
  overflow-x: auto;
}

.cult-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.cult-table th {
  padding: 7px 8px;
  border-bottom: 1px solid #e3e8e3;
  background: #f4f7f2;
  color: #555;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}

.cult-table td {
  padding: 7px 8px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: top;
}

.cult-table tr:last-child td {
  border-bottom: none;
}

.cult-table tr.is-muted td {
  color: #999;
}

.cult-table tr.is-done td {
  background: #fbfefb;
}

.cult-row-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.cult-inline-edit {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.cult-inline-edit label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}

/* ---- 栽培歴：一覧 ---- */
.cult-card-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
}

.cult-card {
  padding: 12px;
  border: 1px solid #dfe7dc;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.cult-card:hover {
  border-color: #a5d6a7;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.cult-card.is-finished {
  background: #fafafa;
  opacity: 0.75;
}

.cult-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.cult-card-crop {
  font-size: 15px;
  font-weight: 700;
}

.cult-card-crop small,
.cult-detail-title small {
  font-weight: normal;
  color: #666;
}

.cult-card-meta {
  margin-top: 4px;
  font-size: 12px;
  color: #555;
}

.cult-next {
  margin-top: 8px;
  padding: 8px 10px;
  border-left: 3px solid #66bb6a;
  border-radius: 6px;
  background: #f9fbf7;
  font-size: 13px;
}

.cult-next-date {
  margin-left: 4px;
  font-weight: 700;
}

.cult-next-rel {
  margin-left: 6px;
  font-size: 12px;
  color: #e65100;
}

.cult-next-basis {
  margin-top: 2px;
  font-size: 11px;
  color: #777;
}

.cult-progress {
  height: 5px;
  margin-top: 10px;
  border-radius: 3px;
  background: #eee;
  overflow: hidden;
}

.cult-progress-bar {
  height: 100%;
  background: #66bb6a;
}

.cult-card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
  color: #666;
}

/* ---- 栽培歴：詳細・フォーム ---- */
.cult-detail-head {
  margin: 4px 0 10px;
}

.cult-detail-title {
  font-size: 18px;
  font-weight: 700;
}

.cult-detail-meta {
  margin: 4px 0;
  font-size: 13px;
  color: #555;
}

.cult-detail-memo {
  margin: 6px 0;
  padding: 6px 10px;
  border-radius: 6px;
  background: #fffde7;
  font-size: 13px;
  white-space: pre-wrap;
}

.cult-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.cult-stat {
  flex: 1 1 140px;
  padding: 8px 10px;
  border: 1px solid #e3e8e3;
  border-radius: 10px;
  background: #fcfdfb;
  font-size: 12px;
  color: #555;
}

.cult-stat span {
  display: block;
  font-size: 11px;
  color: #777;
}

.cult-stat b {
  margin-right: 2px;
  font-size: 18px;
  color: #2e7d32;
}

.cult-stat small {
  margin-left: 6px;
  font-size: 11px;
  color: #999;
}

.cult-form-title {
  font-size: 15px;
}

.cult-picked {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.cult-field-list {
  max-height: 260px;
  margin-top: 8px;
  border: 1px solid #e3e8e3;
  border-radius: 8px;
  overflow-y: auto;
}

.cult-field-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid #f2f2f2;
  font-size: 13px;
  cursor: pointer;
}

.cult-field-item:last-child {
  border-bottom: none;
}

.cult-field-item.is-on {
  background: #f1f8e9;
}

.cult-field-item-name {
  font-weight: 600;
}

/* ---- 栽培設定 ---- */
.cult-work-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cult-work-card {
  border: 1px solid #e3e8e3;
  border-radius: 10px;
  background: #fff;
}

.cult-work-card.is-open {
  border-color: #a5d6a7;
  box-shadow: 0 2px 8px rgba(46, 125, 50, 0.1);
}

.cult-work-sum {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
}

.cult-work-name {
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 700;
}

.cult-work-desc {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: #666;
}

.cult-work-btns {
  display: flex;
  flex-shrink: 0;
  gap: 2px;
}

.cult-work-form {
  padding: 10px 12px 12px;
  border-top: 1px dashed #e0e0e0;
  background: #fcfdfb;
}

.cult-logic {
  margin: 0 0 10px;
  padding-left: 20px;
  font-size: 13px;
  line-height: 1.75;
  color: #444;
}

.cult-env-table .cult-input {
  width: 76px;
}

/* ---- スマホ ---- */
@media (max-width: 768px) {
  .cult-dialog {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }

  .cult-title-sub {
    display: none;
  }

  .cult-body {
    padding: 12px 12px 16px;
  }

  .cult-footer {
    margin: 14px -12px 0;
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .cult-card-list {
    grid-template-columns: 1fr;
  }

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

  .cult-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .cult-input--search {
    width: 100%;
  }

  .cult-work-sum {
    flex-wrap: wrap;
  }

  .cult-work-desc {
    flex-basis: 100%;
    order: 3;
  }

  .cult-work-btns {
    margin-left: auto;
  }

  /* 作業タイムラインはカード状に並べる */
  .cult-timeline thead {
    display: none;
  }

  .cult-timeline,
  .cult-timeline tbody,
  .cult-timeline tr,
  .cult-timeline td {
    display: block;
    width: 100%;
  }

  .cult-timeline tr {
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
  }

  .cult-timeline td {
    padding: 2px 0;
    border: none;
  }

  .cult-timeline td[data-label="区分"],
  .cult-timeline td[data-label="作業"] {
    display: inline-block;
    width: auto;
  }

  .cult-timeline td[data-label="日付"]::before,
  .cult-timeline td[data-label="算出根拠"]::before {
    content: attr(data-label) "：";
    font-size: 11px;
    color: #888;
  }
}

/* ---- 施肥・農薬（栽培設定・栽培歴） ---- */
.cult-mat-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cult-mat-card {
  padding: 10px 12px;
  border: 1px solid #e3e8e3;
  border-radius: 10px;
  background: #fcfdfb;
}

.cult-mat-card--fert {
  border-left: 4px solid #8d6e63;
}

.cult-mat-card--pest {
  border-left: 4px solid #5c6bc0;
}

.cult-mat-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px dashed #e0e0e0;
}

.cult-mat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.cult-mat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.45;
  color: #333;
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
}

.cult-mat-chip--fert {
  background: #efebe9;
  border-color: #d7ccc8;
  color: #4e342e;
}

.cult-mat-chip--pest {
  background: #e8eaf6;
  border-color: #c5cae9;
  color: #283593;
}

.cult-work-mats-box {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid #e3e8e3;
  border-radius: 8px;
  background: #fff;
}

.cult-work-mats-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 12px;
}

.cult-input-with-btn {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cult-input-with-btn .cult-input {
  flex: 1;
  min-width: 0;
}

.cult-npk-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cult-npk-row label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: #555;
}

.cult-npk-row .cult-input {
  width: 100%;
  min-width: 0;
  padding: 6px;
}

.cult-picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10095;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
}

.cult-picker-dialog {
  display: flex;
  flex-direction: column;
  width: min(680px, 95vw);
  max-height: 86vh;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.28);
}

.cult-picker-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px 16px;
}

.cult-picker-sub {
  margin: 4px 0 6px;
  font-size: 12px;
  font-weight: 700;
  color: #555;
}

.cult-picker-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cult-picker-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.cult-picker-item:hover {
  border-color: #66bb6a;
  background: #f1f8e9;
}

.cult-picker-item b {
  font-size: 13px;
  color: #222;
}

.cult-picker-item span {
  font-size: 11px;
  color: #666;
}

@media (max-width: 768px) {
  .cult-picker-dialog {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }

  .cult-mat-head {
    gap: 6px;
  }
}
