:root {
  --border: rgba(0, 0, 0, 0.12);
  --border-strong: rgba(0, 0, 0, 0.28);
  --fg: #1a1a1a;
  --fg-muted: rgba(0, 0, 0, 0.5);
  --bg: #ffffff;
  --accent: #1a1a1a;
  --accent-fg: #ffffff;
  --danger: #c0392b;
  --chip-bg: rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  color: var(--fg);
  background: var(--bg);
  font-size: 15px;
}

.site-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 30;
}
.site-title { font-weight: 700; text-decoration: none; color: var(--fg); margin-right: auto; }
.site-user { font-size: 13px; color: var(--fg-muted); }
.site-logout { font-size: 13px; color: var(--fg-muted); text-decoration: none; }

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 96px;
  position: relative;
}

h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 24px 0 8px; }

a { color: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--fg);
  text-decoration: none;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-fixed { position: fixed; top: 62px; right: 16px; z-index: 50; }
.btn[disabled] { opacity: 0.5; cursor: default; }

.menu-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.menu-list a {
  display: block;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--fg);
  font-weight: 600;
}

.card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}
.card-row { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; padding: 2px 0; }
.card-row .label { color: var(--fg-muted); flex-shrink: 0; }

/* hidden 属性は display の指定(.field の flex など)より優先して隠す(2026-10-16:物流シミュレーターで荷姿の精米前・精米後が両方出ていた) */
[hidden] { display: none !important; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--fg-muted); }
input[type=text], input[type=number], input[type=password], input[type=date], select, textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-size: 15px;
  background: var(--bg);
  color: var(--fg);
  width: 100%;
}

.date-select { display: flex; gap: 6px; flex-wrap: wrap; }
.date-select select { width: auto; flex: 1; min-width: 76px; }

.date-range { border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 16px; }
.date-range .field { margin-bottom: 10px; }
.date-range-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border-strong);
  background: var(--chip-bg);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 14px;
  cursor: pointer;
}
a.chip { text-decoration: none; color: var(--fg); }
a.chip.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.chip.excluded { opacity: 0.4; text-decoration: line-through; border-color: var(--border); background: transparent; }

.pager { display: flex; justify-content: space-between; align-items: center; margin: 16px 0; font-size: 14px; }
.pager a, .pager span { text-decoration: none; color: var(--fg); }
.pager .disabled { color: var(--fg-muted); }

.error { color: var(--danger); font-size: 14px; margin: 8px 0; padding: 10px; border: 1px solid var(--danger); border-radius: 8px; }
.hint { color: var(--fg-muted); font-size: 13px; }
.text-danger { color: var(--danger); font-weight: 600; }

.summary-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.summary-table td { padding: 8px 4px; border-bottom: 1px solid var(--border); font-size: 14px; }
.summary-table td:last-child { text-align: right; font-weight: 600; }

.list-actions { display: flex; gap: 8px; margin-top: 8px; }

.login-form { max-width: 320px; margin: 60px auto; display: flex; flex-direction: column; gap: 16px; }

/* タイトル横のカレンダーリンク */
.title-row { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; padding-right: 110px; }
.title-row h1 { margin: 0; }
.title-link { font-size: 13px; color: var(--fg-muted); text-decoration: none; border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; white-space: nowrap; }

/* 月カレンダー */
.calendar-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 14px; }
.calendar-nav a { text-decoration: none; }
.calendar { width: 100%; border-collapse: collapse; table-layout: fixed; }
.calendar th { font-size: 12px; font-weight: 600; padding: 4px 0; color: var(--fg-muted); }
.calendar td { border: 1px solid var(--border); vertical-align: top; height: 64px; padding: 3px; font-size: 11px; }
.calendar td.empty { background: var(--chip-bg); }
.calendar .sun, .calendar .sun .cal-day { color: var(--danger); }
.calendar .sat, .calendar .sat .cal-day { color: #2c5fa8; }
.calendar td.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.calendar td.has-data { background: rgba(0, 0, 0, 0.03); }
.cal-day { font-size: 12px; font-weight: 600; color: var(--fg); }
.cal-day a { text-decoration: underline; }
.cal-count { display: block; color: var(--fg); white-space: nowrap; line-height: 1.4; }

/* 発注フォーム */
.radio-row { display: flex; gap: 20px; flex-wrap: wrap; }
.radio-row label { font-size: 15px; color: var(--fg); display: inline-flex; align-items: center; gap: 6px; }
.product-block { border: 1px solid var(--border-strong); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.product-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.product-head strong { font-size: 15px; }
.type-checks { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 10px; }
.type-checks label { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; }
.type-panel { border-top: 1px dashed var(--border); padding-top: 10px; margin-top: 10px; }
.type-panel h3 { font-size: 14px; margin: 0 0 8px; }
.inline-pair { display: flex; gap: 8px; align-items: center; }
.inline-pair select { flex: 2; }
.inline-pair select.ratio { flex: 1; }
.kg-input { display: flex; align-items: center; gap: 6px; }
.qty-input { display: flex; gap: 8px; margin-bottom: 6px; }
.qty-input input { flex: 1; min-width: 0; }
.qty-input select { flex: 1.4; min-width: 0; }
.extract-result { background: var(--chip-bg); border-radius: 10px; padding: 10px; margin-top: 8px; }
.stock-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 16px; }
.stock-table th, .stock-table td { border-bottom: 1px solid var(--border); padding: 6px 8px; text-align: left; white-space: nowrap; }
.stock-table tfoot th { border-top: 2px solid var(--border-strong); }
.stock-table td.num, .stock-table th.num { text-align: right; white-space: nowrap; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 16px; }
.table-scroll .stock-table { margin-bottom: 0; }

/* 削除 */
.delete-area { margin-top: 28px; padding-top: 16px; border-top: 1px dashed var(--border); }
.delete-warning { color: var(--danger); font-weight: 700; font-size: 16px; line-height: 1.6; margin: 16px 0; }
.btn-delete { background: var(--danger); border-color: var(--danger); color: #fff; }

/* CSV取込 */
.spec-table td:first-child { white-space: nowrap; color: var(--fg-muted); }
.spec-table td:last-child { text-align: left; font-weight: 400; }
.table-scroll { overflow-x: auto; margin-bottom: 16px; }
.import-table { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.import-table th, .import-table td { border: 1px solid var(--border); padding: 6px 8px; white-space: nowrap; vertical-align: top; }
.import-table th { background: var(--bg-muted, #f5f5f5); }
.import-table .num { text-align: right; }
.import-table .warn { color: var(--danger); }
.error ul { margin: 6px 0 0; padding-left: 20px; }

/* 編集履歴の変更内容 */
.log-detail { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--fg-muted); }
.log-detail li { word-break: break-all; }

/* メニュー内の画面切り替えタブ(layout_header.php の render_section_nav) */
.section-nav { margin: -4px 0 16px; }
.back-menu { display: inline-block; font-size: 13px; color: var(--fg-muted); text-decoration: none; margin-bottom: 8px; }
.section-tabs { display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
.section-tabs a { flex: 0 0 auto; padding: 7px 14px; border: 1px solid var(--border-strong); border-radius: 999px; font-size: 13px; font-weight: 600; text-decoration: none; color: var(--fg); white-space: nowrap; }
.section-tabs a[aria-current="page"] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

/* ブレンドシミュレーターの費用 */
.cost-rows { display: flex; flex-direction: column; gap: 8px; }
.cost-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 14px; color: var(--fg); }
.cost-row[hidden] { display: none; }
.cost-row > label { min-width: 72px; color: var(--fg); font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.cost-row input[type=number] { width: 80px; padding: 6px 8px; margin: 0 4px; }

/* 請求書・納品書の発行 */
.doc-preview { width: 100%; height: 900px; border: 1px solid var(--border); border-radius: 8px; background: #fff; margin: 12px 0; }
.doc-line-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin-bottom: 8px; }
.doc-line-grid label { font-size: 12px; color: var(--fg-muted); display: flex; flex-direction: column; gap: 3px; }
.doc-line-grid label.wide { grid-column: 1 / -1; }
.doc-line-grid label.check { flex-direction: row; align-items: center; color: var(--fg); font-size: 14px; grid-column: 1 / -1; }

/* 完了・結果のお知らせ(登録した、保存した など) */
.notice { color: var(--fg); font-size: 15px; line-height: 1.6; border: 1px solid var(--border-strong); border-radius: 8px; padding: 12px; margin: 8px 0 12px; word-break: break-all; }

/* 撮影・画像からの読み取り */
.scan-box { border: 1px dashed var(--border-strong); border-radius: 12px; padding: 12px; margin-bottom: 16px; }
.scan-title { font-weight: 600; margin-bottom: 4px; }
.scan-box [data-scan-status] { white-space: pre-line; }
.scan-thumb { display: block; max-width: 100%; max-height: 240px; margin-top: 8px; border: 1px solid var(--border); border-radius: 8px; }

/* 一覧の上の「期間の合計」 */
.period-total { border: 1px solid var(--border-strong); border-radius: 12px; padding: 10px 12px 2px; margin-bottom: 14px; }
.period-total-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.period-total .summary-table { margin-bottom: 6px; }
.period-total .summary-table tr:last-child td { border-bottom: none; }

/* ブレンドシミュレーター(シミュレーション)の米1・米2の枠 */
.sim-rice { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px 2px; margin: 0 0 14px; min-width: 0; }
.sim-rice legend { font-weight: 700; padding: 0 6px; }

/* カレンダーの1件(社名・打ち合わせ)。長い文字は「…」で省略し、タップ(フォーカス)で全文を折り返して見せる */
.cal-item { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.45; color: var(--fg); text-decoration: none; font-size: 11px; }
.cal-item:focus, .cal-item:hover { white-space: normal; overflow-wrap: anywhere; }
a.cal-item { text-decoration: underline; text-decoration-color: var(--border-strong); }
.cal-more { color: var(--fg-muted); }

/* 打ち合わせの状況 */
.meeting-status { font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border-strong); color: var(--fg-muted); white-space: nowrap; }
.meeting-done { border-color: var(--accent); color: var(--fg); }
.meeting-canceled { text-decoration: line-through; }

/* 物流シミュレーター */
.logi-pack { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.logi-pack label { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; color: var(--fg); }
.logi-pack input { width: 5em; padding: 6px 8px; }
.logi-point { border-left: 3px solid var(--border-strong); padding-left: 10px; margin-bottom: 12px; min-width: 0; }
.logi-point select { max-width: 100%; }

/* 取引先の区分(複数選択のチェックボックス) */
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checks label.check { display: inline-flex; align-items: center; gap: 4px; font-weight: normal; color: var(--fg); }

/* 業者間相場:前回比の色・推移グラフ(SVG) */
.text-up { color: #b5452f; }
.text-down { color: #2f6fb5; }
.spot-chart { width: 100%; height: auto; max-width: 720px; display: block; }
.spot-chart .grid { stroke: #ddd; stroke-width: 1; }
.spot-chart text { font-size: 11px; fill: #666; }
.spot-legends { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 4px 0 12px; font-size: 13px; }
.spot-legend i { display: inline-block; width: 12px; height: 3px; margin-right: 4px; vertical-align: middle; }

/* 市場分析ダッシュボード:銘柄×重量 */
.dash-matrix td { vertical-align: top; font-size: 13px; white-space: nowrap; }
.dash-good { background: #e3f4e8; }
.dash-thin { background: #fbf3d6; }
.dash-bad { background: #fbe3df; }

/* 運賃表:到着地のチェックボックス(種類ごと) */
.freight-checks { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; }
.freight-checks fieldset { border: 0; padding: 4px 0; margin: 0; }
.freight-checks legend { font-weight: bold; font-size: 13px; }
.freight-checks label.check { display: inline-flex; align-items: center; gap: 4px; margin: 2px 12px 2px 0; font-weight: normal; }

/* EC分析:ランキング上位の構成(横に並べる) */
.ec-mix { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px 16px; }
.ec-mix h3 { margin: 4px 0; font-size: 14px; }
