/* 食数管理システム 共通スタイル（iPad・PC両対応、タッチ操作前提） */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  background: #f2f4f7;
  color: #1f2933;
  font-size: 16px;
}

/* 上部バー */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  background: #1b6d63; color: #fff;
  padding: 10px 16px;
}
.topbar-title { font-size: 1.15rem; font-weight: 700; white-space: nowrap; }
.topbar-nav { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.topbar-nav a {
  color: #fff; text-decoration: none; padding: 8px 14px;
  border-radius: 8px; background: rgba(255,255,255,.14); font-size: .95rem;
}
.topbar-nav a:active { background: rgba(255,255,255,.3); }
.topbar-user { display: flex; align-items: center; gap: 10px; white-space: nowrap; font-size: .95rem; }

main { padding: 16px; max-width: 1200px; margin: 0 auto; }

/* ボタン */
.btn {
  display: inline-block; border: none; border-radius: 10px;
  padding: 10px 18px; font-size: 1rem; cursor: pointer;
  background: #1b6d63; color: #fff; min-height: 44px;
}
.btn:active { opacity: .8; }
.btn-ghost { background: rgba(255,255,255,.18); color: #fff; padding: 8px 12px; min-height: 36px; font-size: .9rem; }
.btn-outline { background: #fff; color: #1b6d63; border: 2px solid #1b6d63; }
.btn-danger { background: #c0392b; }
.btn-small { padding: 6px 12px; min-height: 36px; font-size: .9rem; }

/* 日付切替 */
.date-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.date-bar .current-date { font-size: 1.3rem; font-weight: 700; }
.date-bar input[type="date"] {
  font-size: 1rem; padding: 8px; border: 1px solid #cbd2d9; border-radius: 8px; min-height: 44px;
}

/* カード */
.card {
  background: #fff; border-radius: 14px; padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: 16px;
}
.card h2 { font-size: 1.1rem; margin-bottom: 12px; color: #1b6d63; }

/* 厨房の食数カード */
.count-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.meal-counts { display: flex; gap: 10px; }
.meal-count {
  flex: 1; text-align: center; background: #f0f6f5;
  border-radius: 12px; padding: 12px 6px;
}
.meal-count .meal-name { font-size: .95rem; color: #52606d; }
.meal-count .num { font-size: 2.4rem; font-weight: 800; line-height: 1.2; }
.meal-count .sub { font-size: .85rem; color: #52606d; }
.meal-count.has-cancel { background: #fdecea; }
.meal-count.has-cancel .sub { color: #c0392b; font-weight: 700; }

/* 表 */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; background: #fff; }
table.list th, table.list td {
  border-bottom: 1px solid #e4e7eb; padding: 10px 8px;
  text-align: left; vertical-align: top; font-size: .95rem;
}
table.list th { background: #f5f7fa; position: sticky; top: 0; white-space: nowrap; }
table.list td.num-col { color: #7b8794; width: 2.5em; }
.res-name { font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.res-detail { color: #52606d; font-size: .85rem; }

/* 変更があった行の強調（食堂担当者向け） */
tr.changed { background: #fff4d6; }
tr.changed td:first-child { border-left: 6px solid #f0a202; }
.change-note {
  margin-top: 6px; padding: 8px 10px; background: #fff;
  border: 1px solid #f0a202; border-radius: 8px; font-size: .9rem;
}
.change-note .when { color: #7b8794; margin-left: 6px; }

/* 食事キャンセルボタン */
.meal-btns { display: flex; gap: 8px; }
.meal-btn {
  min-width: 92px; min-height: 52px; border-radius: 10px;
  border: 2px solid #1b6d63; background: #fff; color: #1b6d63;
  font-size: 1rem; font-weight: 700; cursor: pointer;
}
.meal-btn .state { display: block; font-size: .75rem; font-weight: 400; }
.meal-btn.cancelled {
  background: #c0392b; border-color: #c0392b; color: #fff;
}
.meal-btn.na { visibility: hidden; }

/* キャンセル速報・変更お知らせ */
.feed-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 6px; border-bottom: 1px solid #e4e7eb; font-size: 1rem;
}
.feed-item .time { color: #7b8794; white-space: nowrap; }
.feed-item .loc-tag {
  background: #1b6d63; color: #fff; border-radius: 6px;
  padding: 2px 8px; font-size: .85rem; white-space: nowrap;
}
.feed-item .meal-tag {
  background: #c0392b; color: #fff; border-radius: 6px;
  padding: 2px 8px; font-size: .85rem; white-space: nowrap;
}
.feed-item.fresh { background: #fdecea; }
.feed-empty { color: #7b8794; padding: 12px 4px; }

/* モーダル */
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal {
  background: #fff; border-radius: 16px; padding: 20px;
  width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto;
}
.modal h3 { margin-bottom: 14px; font-size: 1.15rem; }
.modal .reason-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 16px; }
.reason-chip {
  border: 2px solid #cbd2d9; background: #fff; border-radius: 20px;
  padding: 10px 16px; font-size: .95rem; cursor: pointer; min-height: 44px;
}
.reason-chip.sel { border-color: #c0392b; background: #fdecea; color: #c0392b; font-weight: 700; }
.modal .modal-btns { display: flex; gap: 10px; justify-content: flex-end; }
.modal label { display: block; margin: 10px 0 4px; font-size: .9rem; color: #52606d; }
.modal input[type="text"], .modal input[type="number"], .modal textarea, .modal select {
  width: 100%; padding: 10px; font-size: 1rem;
  border: 1px solid #cbd2d9; border-radius: 8px;
}

/* ログイン画面 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card {
  background: #fff; border-radius: 18px; padding: 32px;
  width: 100%; max-width: 400px; box-shadow: 0 4px 20px rgba(0,0,0,.1);
}
.login-card h1 { font-size: 1.4rem; color: #1b6d63; text-align: center; margin-bottom: 6px; }
.login-card .sub { text-align: center; color: #7b8794; margin-bottom: 20px; font-size: .9rem; }
.login-card label { display: block; margin: 14px 0 6px; font-size: .95rem; }
.login-card input {
  width: 100%; padding: 12px; font-size: 1.05rem;
  border: 1px solid #cbd2d9; border-radius: 10px;
}
.login-card .btn { width: 100%; margin-top: 22px; font-size: 1.1rem; min-height: 52px; }
.login-error { color: #c0392b; margin-top: 12px; text-align: center; min-height: 1.4em; }

/* 役割えらびボタン */
.role-btns { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.role-btn { width: 100%; font-size: 1.15rem; min-height: 60px; position: relative; }
.notif-card { border-left: 6px solid #c0392b; }
.notif-card h2 { color: #c0392b; }

/* 操作履歴 */
.log-time { color: #7b8794; white-space: nowrap; }
tr.log-day td { background: #f0f6f5; font-weight: 700; color: #1b6d63; }

.role-badge {
  position: absolute; top: -8px; right: -8px;
  min-width: 28px; height: 28px; padding: 0 7px; border-radius: 14px;
  background: #c0392b; color: #fff; font-size: 1rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.relock-line { text-align: center; margin-top: 18px; font-size: .85rem; }
.relock-line a { color: #7b8794; }

.setup-note { max-width: 560px; margin: 80px auto; background: #fff; padding: 32px; border-radius: 16px; text-align: center; }
.setup-note h2 { color: #c0392b; margin-bottom: 12px; }

.summary-bar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.summary-pill {
  background: #fff; border-radius: 10px; padding: 8px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); font-size: 1rem;
}
.summary-pill b { font-size: 1.3rem; }
.summary-pill .c { color: #c0392b; }
.summary-pill .h { color: #6b4fa0; }

/* 入院・帰園 */
.hos-card { border-left: 6px solid #6b4fa0; }
.hos-card h2 { color: #6b4fa0; }
.hos-list { display: flex; flex-direction: column; gap: 8px; }
.hos-item { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid #e4e7eb; }
.hos-item .res-name { min-width: 6em; }
.hos-since { color: #6b4fa0; font-size: .95rem; }
.hos-item .btn { margin-left: auto; }
.hos-btn { margin-top: 0; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.early-toggle { background: #e8710a; color: #fff; }
.early-toggle.btn-outline { background: #fff; color: #e8710a; border: 2px solid #e8710a; }
.meal-btn.na-hos { background: #efeaf6; border-color: #b6a7d6; color: #6b4fa0; cursor: default; }

/* DS 用意したチェック（操作枠の中に表示） */
.prep-box {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 8px; padding: 8px; border: 2px solid #1b6d63; border-radius: 10px;
  background: #fff; color: #1b6d63; font-size: 1rem; font-weight: 700; cursor: pointer;
}
.prep-box input { width: 26px; height: 26px; }
tr:has(.prep-chk:checked) { background: #eef7f0; }
tr:has(.prep-chk:checked) .prep-box { background: #1b6d63; color: #fff; }

/* iPadの画面に収まるよう、食堂の表を詰める */
@media (max-width: 1024px) {
  main { padding: 10px; }
  table.list th, table.list td { padding: 6px 5px; font-size: .85rem; }
  .res-name { font-size: 1rem; white-space: normal; }
  .res-detail { font-size: .8rem; }
  .meal-btn { min-width: 62px; min-height: 46px; font-size: .9rem; }
  .action-col { min-width: 200px; }
}

.toggle-line { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: .95rem; }
.toggle-line input { width: 22px; height: 22px; }
.view-toggle { gap: 10px; }

/* 形態別テーブル */
.tex-table th.tex-name { text-align: left; white-space: nowrap; font-weight: 700; }
.tex-table td.tex-num {
  text-align: center; font-size: 1.5rem; font-weight: 800; white-space: nowrap;
}
.tex-table td.tex-num.has-cancel { color: #c0392b; }
.tex-table .tex-sub { display: block; font-size: .72rem; font-weight: 400; color: #7b8794; }
.tex-table td.tex-num.has-cancel .tex-sub { color: #c0392b; }
.tex-table thead th { text-align: center; }
.tex-table thead th:first-child { text-align: left; }
.tex-table tr.tex-total { background: #f0f6f5; }
.tex-table tr.tex-total th, .tex-table tr.tex-total td { border-top: 2px solid #1b6d63; }
.tex-note { color: #7b8794; font-size: .85rem; margin-top: 10px; }
.tex-merged { display: block; font-size: .72rem; font-weight: 400; color: #7b8794; margin-top: 2px; }

/* ダッシュボード：サマリータイル */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-tile { background: #fff; border-radius: 14px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.08); text-align: center; border-left: 6px solid #1b6d63; }
.stat-tile .stat-num { font-size: 2.4rem; font-weight: 800; line-height: 1.1; color: #1b6d63; }
.stat-tile .stat-label { font-size: .85rem; color: #52606d; margin-top: 4px; }
.stat-tile.warn { border-left-color: #f0a202; }
.stat-tile.warn .stat-num { color: #b9770a; }
.stat-tile.alert { border-left-color: #c0392b; }
.stat-tile.alert .stat-num { color: #c0392b; }

/* ダッシュボード：2列カード */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 16px; }

/* 横棒グラフ */
.bar-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.bar-label { width: 40%; max-width: 220px; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; background: #eef1f4; border-radius: 8px; height: 22px; overflow: hidden; }
.bar-fill { height: 100%; background: #2a9d8f; border-radius: 8px; min-width: 2px; }
.bar-value { width: 4.5em; text-align: right; font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.bar-value .bar-sub { display: inline-block; margin-left: 4px; font-size: .7rem; font-weight: 700; color: #fff; background: #f0a202; border-radius: 6px; padding: 1px 6px; vertical-align: middle; }

/* 要確認 */
.ok-line { color: #1b6d63; font-weight: 700; }
.warn-head { color: #b9770a; font-weight: 700; margin-bottom: 8px; }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.warn-chip { background: #fff4d6; border: 1px solid #f0a202; border-radius: 8px; padding: 4px 10px; font-size: .9rem; }

/* ショートステイ */
.ss-now { display: inline-block; margin-left: 6px; background: #1b6d63; color: #fff; border-radius: 6px; padding: 1px 8px; font-size: .75rem; }
.ss-floor { display: flex; gap: 16px; margin-top: 4px; }
.ss-radio { display: flex; align-items: center; gap: 6px; font-size: 1rem; }
.ss-radio input { width: 20px; height: 20px; }
.ss-meals { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 4px; }
.ss-meal-chk { display: flex; align-items: center; gap: 6px; font-size: 1rem; border: 1px solid #cbd2d9; border-radius: 8px; padding: 8px 12px; }
.ss-meal-chk input { width: 20px; height: 20px; }
/* 厨房のSSカード */
.ss-card { border-left: 6px solid #2a9d8f; }
.ss-floor-block { margin-top: 10px; }
.ss-floor-block:first-of-type { margin-top: 0; }
.ss-floor-name { font-weight: 700; color: #1b6d63; margin-bottom: 6px; }
.meal-count.zero { opacity: .45; }

/* 食札 */
.fuda-filter-label { font-weight: 700; color: #52606d; }
.fuda-count-line { margin-left: 12px; }
.fuda-count-line b { font-size: 1.2rem; color: #1b6d63; }
.fuda-wrap { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 12px; }
.fuda {
  border: 2px solid #1b6d63; border-radius: 10px; padding: 10px 12px;
  background: #fff; break-inside: avoid; page-break-inside: avoid;
}
.fuda-ss { border-color: #2a9d8f; }
.fuda-head { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: #7b8794; }
.fuda-head .loc-tag { font-size: .85rem; }
.fuda-no { font-weight: 700; color: #1f2933; }
.fuda-meal { margin-left: auto; white-space: nowrap; }
.fuda-tag-ss { background: #2a9d8f; color: #fff; border-radius: 6px; padding: 1px 8px; font-size: .75rem; }
.fuda-name { font-size: 1.6rem; font-weight: 800; margin: 4px 0 8px; line-height: 1.2; }
.fuda-body { display: flex; flex-direction: column; gap: 3px; }
.fuda-row { display: flex; gap: 8px; font-size: .95rem; }
.fuda-k { min-width: 4.5em; color: #52606d; font-weight: 700; }
.fuda-v { flex: 1; }
.fuda-allergy {
  margin-top: 8px; background: #ffd8a8; color: #8a3b00; font-weight: 700;
  border: 1px solid #e8710a; border-radius: 8px; padding: 6px 8px; font-size: .95rem;
}

/* 食札の色ルール（元Excel「印刷用食札」準拠。背景の塗り分け） */
.fuda-row.hl-staple, .fuda-row.hl-soup,
.fuda-row.hl-spoon, .fuda-row.hl-mousse {
  border-radius: 4px; padding: 1px 4px; margin: 0 -4px;
}
.fuda-row.hl-staple { background: #ff99cc; }  /* ピンク：米飯以外の主食 */
.fuda-row.hl-soup   { background: #8db4e2; }  /* 水色：汁物ブレンダー・とろみ */
.fuda-row.hl-spoon  { background: #ffff00; }  /* 黄色：スプーン類 */
.fuda-row.hl-mousse { background: #ccc0da; }  /* 薄紫：形態ムース */

/* 食札1枚の印刷サイズ（プレートに合わせてここだけ変える） */
:root { --fuda-w: 83mm; --fuda-h: 52mm; }

@media print {
  @page { size: A4; margin: 8mm; }
  body { background: #fff; }
  /* 背景色・塗りを印刷でも出す（プリンタ設定の「背景のグラフィック」もONが必要） */
  .fuda, .fuda * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .topbar, .no-print { display: none !important; }
  .fuda-date { display: none; }   /* 印刷時は日付を出さない */
  main { padding: 0; max-width: none; }
  .fuda-wrap { display: flex; flex-wrap: wrap; gap: 4mm; align-content: flex-start; }
  .fuda {
    width: var(--fuda-w); height: var(--fuda-h);
    overflow: hidden; box-sizing: border-box; padding: 3mm 4mm;
    border-color: #000; border-radius: 6px;
  }
  .fuda-head { font-size: 8pt; }
  .fuda-name { font-size: 18pt; margin: 1mm 0 2mm; }
  .fuda-row { font-size: 9pt; }
  .fuda-allergy { font-size: 9pt; margin-top: 2mm; padding: 1mm 2mm; }
}

/* 変更履歴の確認バッジ */
.ack-badge { margin-left: auto; border-radius: 6px; padding: 2px 8px; font-size: .8rem; white-space: nowrap; }
.ack-badge.done { background: #e3f1ee; color: #1b6d63; }
.ack-badge.pending { background: #fff4d6; color: #b9770a; }

.badge-inactive { background: #7b8794; color: #fff; border-radius: 6px; padding: 2px 8px; font-size: .8rem; }
.badge-early { background: #e8710a; color: #fff; border-radius: 6px; padding: 2px 8px; font-size: .8rem; font-weight: 700; }
/* 食札の早出し */
.fuda-tag-early { background: #e8710a; color: #fff; border-radius: 6px; padding: 1px 8px; font-size: .78rem; font-weight: 700; }
.fuda-early { border-color: #e8710a; border-width: 3px; }
tr.inactive-row { opacity: .55; }

@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; }
  main { padding: 10px; }
  .meal-btn { min-width: 72px; }
}
