/* 水耕栽培管理 共通スタイル（タブレット・PC両対応） */
:root {
  --bg: #f4f6f3;
  --card: #ffffff;
  --text: #1f2a1f;
  --muted: #667066;
  --line: #d8ddd6;
  --primary: #2f7d32;
  --primary-dark: #1f5e22;
  --danger: #b3261e;
  --warn-bg: #fff4d6;
  --ok-bg: #e3f2e1;
  --info-bg: #e6f0fa;
  --err-bg: #fde8e7;
  --radius: 8px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif; font-size: 16px; line-height: 1.6; }
a { color: var(--primary-dark); }
h1 { font-size: 1.4rem; margin: 0 0 16px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 16px 0 8px; }
code { background: #eef1ec; padding: 2px 6px; border-radius: 4px; font-size: .95em; }
code.secret { font-size: 1.15rem; letter-spacing: .05em; user-select: all; }
code.wrap { word-break: break-all; display: inline-block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.big { font-size: 1.6rem; font-weight: 700; margin: 0 0 8px; }
.nowrap { white-space: nowrap; }

/* ヘッダー */
.topbar { background: var(--primary); color: #fff; }
.topbar-inner { display: flex; align-items: center; gap: 12px; padding: 10px 16px; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.1rem; }
.site-switch select { padding: 6px 8px; border-radius: 6px; border: 0; max-width: 60vw; font-size: .95rem; }
.site-name { font-size: .9rem; opacity: .9; }
.menu-toggle { margin-left: auto; background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.6); border-radius: 6px; padding: 6px 12px; font-size: .95rem; display: none; }
.mainnav { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; background: var(--primary-dark); padding: 6px 16px; }
.mainnav a, .nav-soon { color: #fff; text-decoration: none; padding: 6px 10px; border-radius: 6px; display: inline-block; }
.mainnav a.active, .mainnav a:hover { background: rgba(255,255,255,.18); }
.nav-soon { opacity: .5; cursor: default; }
.nav-links, .nav-user { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.who { color: #e6f2e6; font-size: .9rem; margin-right: 6px; }
@media (max-width: 760px) {
  .menu-toggle { display: inline-block; }
  .mainnav { display: none; flex-direction: column; }
  .mainnav.open { display: flex; }
  .nav-links, .nav-user { flex-direction: column; align-items: stretch; }
  .mainnav a, .nav-soon { padding: 10px; }
}

/* レイアウト */
.container { max-width: 1400px; margin: 0 auto; padding: 20px 16px 48px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.narrow { max-width: 560px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-decoration: none; color: var(--text); min-height: 80px; }
.tile:hover { border-color: var(--primary); }
.stats { display: flex; gap: 16px; flex-wrap: wrap; margin: 12px 0 0; }
.stats div { min-width: 70px; }
.stats dt { font-size: .8rem; color: var(--muted); }
.stats dd { margin: 0; font-size: 1.4rem; font-weight: 700; }
.links li { margin: 6px 0; }

/* フラッシュ・バッジ */
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid transparent; }
.flash-success { background: var(--ok-bg); border-color: #b9dbb5; }
.flash-info { background: var(--info-bg); border-color: #bcd3ec; }
.flash-error { background: var(--err-bg); border-color: #f2b8b5; }
.flash-warn { background: var(--warn-bg); border-color: #f0d68a; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .85rem; }
.badge-ok { background: var(--ok-bg); }
.badge-muted { background: #ececec; }
.badge-warn { background: var(--warn-bg); }
.error-code { font-weight: 700; color: var(--danger); }

/* フォーム（タブレットで押しやすい大きさ） */
.form .field, fieldset.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; border: 0; padding: 0; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 4px; }
.field > span, legend { font-weight: 600; font-size: .95rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  font: inherit; padding: 10px 12px; border: 1px solid #b9c1b6; border-radius: 6px; background: #fff; min-height: 44px; width: 100%;
}
input[type=color] { width: 64px; height: 44px; padding: 2px; border: 1px solid #b9c1b6; border-radius: 6px; }
input[readonly] { background: #f1f3f0; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(47,125,50,.3); border-color: var(--primary); }
.input-row { display: flex; align-items: center; gap: 8px; }
.input-row input[type=number] { max-width: 140px; }
.input-small { width: 80px !important; min-height: 36px !important; padding: 6px !important; }
.input-code { font-size: 1.4rem; letter-spacing: .3em; max-width: 220px; }
.suffix { color: var(--muted); }
.help { color: var(--muted); font-size: .8rem; }
.err { color: var(--danger); font-style: normal; font-size: .875rem; }
.has-error input, .has-error select { border-color: var(--danger); }
.req { color: var(--danger); font-size: .75rem; font-weight: 600; margin-left: 4px; }
.check { display: flex; align-items: center; gap: 8px; margin: 8px 0; min-height: 36px; }
.check input { width: 22px; height: 22px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
form.inline { display: inline; }
.inline-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 12px; }
.filters input, .filters select { width: auto; min-height: 38px; padding: 6px 8px; }
.steps li { margin-bottom: 10px; }

/* ボタン */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; font: inherit; font-size: .95rem; padding: 10px 16px; min-height: 44px; border-radius: 6px; border: 1px solid #b9c1b6; background: #fff; color: var(--text); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn-ghost { background: transparent; }
.mainnav .btn-ghost { color: #fff; border-color: rgba(255,255,255,.6); }
.btn-small { padding: 4px 10px; min-height: 34px; font-size: .875rem; }
.btn-block { width: 100%; }

/* 表 */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table thead th { background: #eef1ec; font-size: .85rem; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.row-inactive td { color: #9aa29a; }
.row-warn td, .row-warn th { background: #fff8e6; }
.swatch { display: inline-block; width: 18px; height: 18px; border-radius: 4px; border: 1px solid rgba(0,0,0,.15); vertical-align: middle; }
.plain-list { list-style: none; padding: 0; }
.plain-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.pager { display: flex; gap: 8px; flex-wrap: wrap; }

/* 棚の構成 */
.shelf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: 640px; margin-bottom: 16px; }
.shelf-cell { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }

/* ログイン画面 */
body.plain { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
.auth-box { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.auth-brand { color: var(--primary); font-weight: 700; margin-bottom: 8px; }

/* 栽培カレンダー */
.cal-toolbar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { padding: 8px 16px; border: 1px solid var(--line); border-radius: 6px; background: #fff; text-decoration: none; color: var(--text); min-height: 40px; }
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.legend-item { display: inline-flex; align-items: center; gap: 4px; }
.legend-box { display: inline-block; width: 16px; height: 16px; border: 1px solid rgba(0,0,0,.15); border-radius: 3px; }
.cal-wrap { overflow: auto; max-height: 75vh; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.cal { border-collapse: separate; border-spacing: 0; font-size: .75rem; }
.cal th, .cal td { border-right: 1px solid #e3e6e1; border-bottom: 1px solid #e3e6e1; padding: 0; text-align: center; }
.cal td { width: 26px; min-width: 26px; height: 26px; }
.cal td a { display: block; color: inherit; text-decoration: none; font-weight: 700; }
.cal thead { position: sticky; top: 0; z-index: 3; } /* 見出し2行をまとめて固定（行ごとに固定すると縦スクロールでずれるため） */
.cal thead th { background: #eef1ec; }
.cal thead tr:first-child th { height: 20px; }
.cal-month { text-align: left !important; font-weight: 700; white-space: nowrap; }
.cal th.cal-ws, .cal td.cal-ws { border-left: 1px solid #333; } /* 週の区切り線（日曜と月曜の間） */
.cal th.cal-ms, .cal td.cal-ms { border-left: 3px solid #e07a00; } /* 月の区切り線（週の線より優先） */
.cal-day { line-height: 1.1; padding: 2px 0 !important; font-weight: 400; }
.cal-day span { font-size: .65rem; }
.cal-off { background: #fbe3d6 !important; color: #a1452a; }
.cal-today { outline: 2px solid var(--primary); outline-offset: -2px; }
.cal-label, .cal-head-label { position: sticky; left: 0; background: #f7f8f6; z-index: 1; text-align: left !important; padding: 2px 8px !important; white-space: nowrap; min-width: 120px; font-weight: 600; }
.cal thead th.cal-head-label { z-index: 2; background: #eef1ec; } /* 横スクロールで日付の下に隠れないよう前面に */
.cal-label small { display: block; font-weight: 400; color: var(--muted); font-size: .65rem; }
.cal-slot-start th, .cal-slot-start td { border-top: 2px solid #9aa59a; }
.cal-nursery { background: #e6e6e6; }
.cal-off-cell { background: repeating-linear-gradient(45deg, #fff, #fff 3px, #f4efe9 3px, #f4efe9 6px); }
.cal-mark { color: #8a1c1c; }
.cal-clean { background: #b3261e !important; color: #fff !important; font-weight: 700; }
.cal tfoot th, .cal tfoot td { background: #f7f8f6; font-size: .7rem; }
.cal-count { color: var(--muted); }
.cal-empty-row td { background: #fcfcfb; }
.input-short { width: 90px !important; }
.input-medium { width: 200px !important; }

/* 作業予定 */
.day-card h2 { font-size: 1rem; }
.day-off { opacity: .85; }
.task-list { list-style: none; padding: 0; margin: 0; }
.task-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.task-list li:last-child { border-bottom: 0; }
.task-type { display: inline-block; min-width: 3.5em; text-align: center; font-size: .8rem; padding: 2px 6px; border-radius: 4px; margin-right: 6px; background: #eee; }
.task-sow { background: #e6f0fa; }
.task-transplant { background: #e3f2e1; }
.task-harvest { background: #fde8d7; }
.task-clean { background: #b3261e; color: #fff; }
.cal td.cal-done, .cal td.cal-done a, .cal-done-sample { color: #1b7a2b !important; text-decoration: underline; }

/* 作業の行（完了・遅れ） */
.task-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.task-what { flex: 1 1 200px; }
.task-state .ok { color: #1b7a2b; }
.task-state .late { color: var(--danger); font-weight: 600; }
.task-state .early { color: #1f5e9e; }
.task-row.is-done .task-what { color: var(--muted); }
.task-row.is-late { background: #fff6f5; }
.task-actions { margin-left: auto; }
.input-date-small { width: 150px !important; min-height: 36px !important; padding: 4px 6px !important; }
.check-inline { display: inline-flex; align-items: center; gap: 4px; }
.late-box { margin: 10px 0; }
.late-box summary { cursor: pointer; color: var(--danger); font-weight: 600; }

/* 日報 */
.section-nav { position: sticky; top: 0; z-index: 5; display: flex; gap: 4px; flex-wrap: wrap; background: var(--bg); padding: 6px 0; margin-bottom: 8px; }
.section-nav a { padding: 6px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); text-decoration: none; font-size: .9rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 760px) { .grid-3 { grid-template-columns: 1fr; } }
.input-table input[type=text], .input-table select { min-height: 40px; padding: 6px 8px; }
.input-table td { min-width: 90px; }
.input-qty { width: 80px !important; }
.input-unit { width: 90px !important; }
.input-wide { width: 320px !important; max-width: 100%; }
.radio-pill { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; margin-right: 4px; cursor: pointer; }
.radio-pill input { width: 18px; height: 18px; }
.radio-pill.ng:has(input:checked) { background: var(--err-bg); border-color: #f2b8b5; }
.radio-pill:not(.ng):has(input:checked) { background: var(--ok-bg); border-color: #b9dbb5; }
textarea { font: inherit; width: 100%; padding: 10px 12px; border: 1px solid #b9c1b6; border-radius: 6px; }
.save-bar { position: sticky; bottom: 0; background: rgba(244,246,243,.95); padding: 10px 0; display: flex; gap: 12px; align-items: center; border-top: 1px solid var(--line); z-index: 5; }
.late { color: var(--danger); }
.late-title { color: var(--danger); }

/* 収穫・販売 */
.table .num, .table th.num { text-align: right; white-space: nowrap; }
.table-compact th, .table-compact td { padding: 6px 8px; font-size: .9rem; }
.table tfoot th { background: #f7f8f6; border-top: 2px solid var(--line); }
.input-table .input-qty { width: 5.5em; }
details.field > summary { cursor: pointer; color: var(--muted, #667); margin-bottom: 8px; }
fieldset.field { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; }
fieldset.field legend { font-size: .9rem; padding: 0 4px; }
