/* =========================================================================
   シフトシミュレーター — スタイル
   配色は dataviz スキルの検証済みパレットに準拠（validate_palette.js でPASS）
   ========================================================================= */

:root {
  /* Surfaces & ink (light) */
  --surface-1: #fcfcfb;      /* カード面 */
  --page: #f9f9f7;           /* ページ背景 */
  --surface-2: #f2f1ee;      /* サブ面 */
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);

  /* Status (fixed — never themed) */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --info: #2a78d6;           /* 過剰＝青（categorical slot 1） */

  /* Employment-type categorical (validated set) */
  --emp-fulltime: #2a78d6;   /* 社員 = blue */
  --emp-part: #1baf7a;       /* パート = aqua */
  --emp-arbeit: #eb6834;     /* アルバイト = orange */

  /* Soft washes for cells / chips */
  --good-wash: rgba(12, 163, 12, 0.14);
  --warning-wash: rgba(250, 178, 25, 0.20);
  --serious-wash: rgba(236, 131, 90, 0.24);
  --critical-wash: rgba(208, 59, 59, 0.20);
  --info-wash: rgba(42, 120, 214, 0.14);

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.06), 0 4px 16px rgba(11, 11, 11, 0.04);
  --font: system-ui, -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --surface-2: #232321;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);

    --good: #0ca30c;
    --warning: #fab219;
    --serious: #ec835a;
    --critical: #d03b3b;
    --info: #3987e5;

    --emp-fulltime: #3987e5;
    --emp-part: #199e70;
    --emp-arbeit: #d95926;

    --good-wash: rgba(12, 163, 12, 0.22);
    --warning-wash: rgba(250, 178, 25, 0.20);
    --serious-wash: rgba(236, 131, 90, 0.26);
    --critical-wash: rgba(208, 59, 59, 0.28);
    --info-wash: rgba(57, 135, 229, 0.20);

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; }
p { margin: 0; }

.app {
  max-width: 1800px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 4px 14px;
  flex-wrap: wrap;
}
.topbar__title { display: flex; align-items: center; gap: 12px; }
.topbar__logo { font-size: 30px; line-height: 1; }
.topbar h1 { font-size: 20px; letter-spacing: 0.01em; }
.topbar__sub { color: var(--text-secondary); font-size: 13px; }
.topbar__actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
#auth-bar:empty { display: none; }
.auth-org { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
#auth-bar select { padding: 5px 6px; font-size: 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-1); color: var(--text-primary); }

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--info); border-color: transparent; color: #fff; font-weight: 600; }
.btn--primary:hover { filter: brightness(1.06); background: var(--info); }
.btn--ghost { background: transparent; }
.btn--danger-ghost { background: transparent; color: var(--critical); border-color: var(--border); }
.btn--danger-ghost:hover { background: var(--critical-wash); }
.btn--sm { padding: 4px 9px; font-size: 12px; }
.btn--icon { padding: 4px 8px; line-height: 1; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--grid);
  margin: 6px 0 20px;
}
.tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text-primary); }
.tab.is-active { color: var(--text-primary); border-bottom-color: var(--info); }

/* ---------- Panels ---------- */
.panel { display: none; }
.panel.is-active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Cards ---------- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
/* 個人別シフトの「全員分」印刷用ブロックは、画面では常に非表示
   （印刷実行時のみ body.print-staff-all で可視化する） */
.rb-staff-all-print { display: none; }
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.card__head h2 { font-size: 16px; }
.card__desc { color: var(--text-secondary); font-size: 13px; margin-top: 2px; max-width: 900px; }

/* ---------- KPI tiles ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.kpi__label { color: var(--text-secondary); font-size: 12px; margin-bottom: 6px; }
.kpi__value { font-size: 26px; font-weight: 680; letter-spacing: -0.01em; }
.kpi__value small { font-size: 14px; font-weight: 500; color: var(--text-secondary); margin-left: 2px; }
.kpi__sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.kpi--good .kpi__value { color: var(--good); }
.kpi--warn .kpi__value { color: var(--serious); }
.kpi--crit .kpi__value { color: var(--critical); }

/* ---------- Heatmap ---------- */
.heatmap-wrap { overflow-x: auto; }
table.heatmap {
  border-collapse: separate;
  border-spacing: 3px;
  width: 100%;
  min-width: 560px;
  font-variant-numeric: tabular-nums;
}
.heatmap th {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  padding: 4px;
  text-align: center;
}
.heatmap th.hm-corner, .heatmap th.hm-hour { text-align: right; padding-right: 8px; white-space: nowrap; }
.heatmap td {
  text-align: center;
  border-radius: var(--radius-sm);
  padding: 6px 4px;
  font-size: 12px;
  font-weight: 600;
  min-width: 46px;
  cursor: default;
  color: var(--text-primary);
  border: 1px solid transparent;
}
.hm--closed { background: var(--surface-2); color: var(--text-muted); font-weight: 400; }
.hm--none   { background: var(--surface-2); color: var(--text-muted); font-weight: 400; }
.hm--good   { background: var(--good-wash); border-color: rgba(12,163,12,.35); }
.hm--warning{ background: var(--warning-wash); border-color: rgba(250,178,25,.5); }
.hm--serious{ background: var(--serious-wash); border-color: rgba(236,131,90,.55); }
.hm--critical{ background: var(--critical-wash); border-color: rgba(208,59,59,.55); }
.hm--surplus{ background: var(--info-wash); border-color: rgba(42,120,214,.35); }
.heatmap td[data-cell]:hover { outline: 2px solid var(--info); outline-offset: 1px; }

/* Legend */
.legend { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--text-secondary); margin-top: 12px; }
.legend__item { display: inline-flex; align-items: center; gap: 6px; }
.legend__swatch { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--border); display: inline-block; }
.sw--good { background: var(--good-wash); border-color: rgba(12,163,12,.5); }
.sw--warning { background: var(--warning-wash); border-color: rgba(250,178,25,.6); }
.sw--serious { background: var(--serious-wash); border-color: rgba(236,131,90,.6); }
.sw--critical { background: var(--critical-wash); border-color: rgba(208,59,59,.6); }
.sw--surplus { background: var(--info-wash); border-color: rgba(42,120,214,.5); }
.sw--closed { background: var(--surface-2); }

/* ---------- Tooltip ---------- */
.tooltip {
  position: fixed;
  z-index: 50;
  background: var(--surface-1);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12px;
  max-width: 240px;
  pointer-events: none;
  color: var(--text-primary);
}
.tooltip h4 { font-size: 12px; margin-bottom: 4px; }
.tooltip .tt-row { color: var(--text-secondary); }
.tooltip .tt-names { margin-top: 6px; color: var(--text-primary); font-size: 11px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 560px;
}
table.data th, table.data td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--grid);
  vertical-align: middle;
}
table.data th { color: var(--text-secondary); font-weight: 600; font-size: 12px; white-space: nowrap; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr:hover td { background: var(--surface-2); }

/* ---------- Chips / badges ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.chip__dot { width: 8px; height: 8px; border-radius: 50%; }
.chip--fulltime .chip__dot { background: var(--emp-fulltime); }
.chip--part .chip__dot { background: var(--emp-part); }
.chip--arbeit .chip__dot { background: var(--emp-arbeit); }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 6px; }
.badge--good { background: var(--good-wash); color: var(--good); }
.badge--warn { background: var(--warning-wash); color: var(--serious); }
.badge--crit { background: var(--critical-wash); color: var(--critical); }
.badge--muted { background: var(--surface-2); color: var(--text-muted); }
.badge--info { background: var(--info-wash); color: var(--info); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.field input, .field select {
  font-family: inherit;
  font-size: 14px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text-primary);
  width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid var(--info); outline-offset: 0; border-color: transparent; }
.hint { font-size: 11px; color: var(--text-muted); }

/* Availability editor */
.avail-grid { display: grid; grid-template-columns: 1fr; gap: 6px; margin-top: 8px; }
.avail-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
  border: 1px solid var(--grid);
  border-radius: var(--radius-sm);
}
.avail-row__day { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; }
.avail-row__time { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.avail-row__time select { width: auto; padding: 4px 6px; font-size: 13px; }
.avail-row.is-off .avail-row__time { opacity: .4; }
.preset-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }

/* Required-staffing grid editor */
.req-grid-wrap { overflow-x: auto; }
table.req-grid { border-collapse: separate; border-spacing: 2px; min-width: 560px; }
table.req-grid th { font-size: 12px; color: var(--text-secondary); font-weight: 600; padding: 4px; }
table.req-grid th.hm-hour { text-align: right; padding-right: 8px; }
table.req-grid input {
  width: 42px; text-align: center; padding: 4px 2px; font-size: 13px;
  border: 1px solid var(--grid); border-radius: 5px; background: var(--surface-1); color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
table.req-grid td.is-closed { background: var(--surface-2); border-radius: 5px; }
table.req-grid input:focus { outline: 2px solid var(--info); border-color: transparent; }

.band-row { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; padding: 10px; border: 1px solid var(--grid); border-radius: var(--radius-sm); margin-bottom: 8px; }
.band-row .field { min-width: 96px; }

/* Day-hours editor */
.dayhours { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.dayhours__day { border: 1px solid var(--grid); border-radius: var(--radius-sm); padding: 8px 10px; }
.dayhours__day h4 { font-size: 13px; display: flex; align-items: center; justify-content: space-between; }
.dayhours__times { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--text-secondary); margin-top: 6px; }
.dayhours__times select { width: auto; padding: 3px 5px; }
.dayhours__day.is-closed .dayhours__times { opacity: .4; }

/* Utility */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.spacer { flex: 1; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.empty-state { text-align: center; padding: 40px 16px; color: var(--text-secondary); }
.empty-state h3 { font-size: 16px; margin-bottom: 6px; }
.checkbox { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; font-size: 13px; }
.tag-note { font-size: 12px; color: var(--text-secondary); background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 12px; margin-top: 4px; }
.inline-actions { display: flex; gap: 6px; }

/* ---------- Footer ---------- */
.footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--grid);
  font-size: 12px; color: var(--text-muted); flex-wrap: wrap; gap: 8px;
}

@media (max-width: 560px) {
  .topbar { align-items: flex-start; }
  .kpi__value { font-size: 22px; }
  .avail-row { grid-template-columns: 84px 1fr; }
}

@media print {
  .topbar__actions, .tabs, .footer, .btn { display: none !important; }
  .panel { display: block !important; }
  .card { break-inside: avoid; box-shadow: none; }

  /* 「このカレンダーを印刷」: カレンダーカードのみをA4横1枚に収める */
  body.print-cal .topbar,
  body.print-cal .content > *:not(.rb-calcard) { display: none !important; }
  body.print-cal .rb-calcard { border: none; box-shadow: none; padding: 0; margin: 0; }
  body.print-cal .rb-calcard .card__desc,
  body.print-cal .rb-calcard .legend { display: none !important; }
  body.print-cal .cal-wrap { overflow: visible; }
  body.print-cal .rb-shiftcal { min-width: 0; width: 100%; }
  body.print-cal .rb-shiftcal .cal-cell { min-height: 0; border-radius: 3px; padding: 3px 5px; gap: 2px; }
  body.print-cal .sc-line { font-size: 9.5px; line-height: 1.3; }
  body.print-cal .cal-date .d-num { font-size: 12px; }
  body.print-cal .cal-head div { font-size: 10px; padding: 0; }
  body.print-cal .cal-week, body.print-cal .cal-head { gap: 3px; margin-bottom: 3px; }
  body.print-cal .cal-note, body.print-cal .sc-short { font-size: 8.5px; }
  body.print-cal .sc-empty { font-size: 9px; }
  .rb-shiftcal .rb-calday:hover { outline: none; }

  /* 個人別シフト：「この人だけ印刷」は選択中の1名のカードのみ表示 */
  body.print-staff .topbar,
  body.print-staff .content > *:not(.rb-staffcard) { display: none !important; }
  body.print-staff .rb-staffcard { border: none; box-shadow: none; padding: 0; margin: 0; }
  body.print-staff .card__desc,
  body.print-staff #staff-schedule-select { display: none !important; }
  body.print-staff .rb-staff-all-print { display: none !important; }

  /* 個人別シフト：「全員分をまとめて印刷」は1人1ページで出力 */
  body.print-staff-all .topbar,
  body.print-staff-all .content > *:not(.rb-staff-all-print) { display: none !important; }
  body.print-staff-all .rb-staff-all-print { display: block !important; }
  body.print-staff-all .rb-staff-print-page { break-after: page; padding: 8px 0; }
  body.print-staff-all .rb-staff-print-page:last-child { break-after: auto; }
}

/* =========================================================================
   月間カレンダー（シフト表）
   ========================================================================= */
.subtitle-month { font-size: 15px; color: var(--text-secondary); font-weight: 600; }

.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 16px; }
.controls .field label { font-weight: 600; }
.controls .field .hint { font-weight: 400; }
.controls .field input { padding: 6px 7px; min-width: 0; }
.control-group { border: 1px solid var(--grid); border-radius: var(--radius-sm); padding: 12px 14px; }
.control-group h3 { font-size: 13px; margin-bottom: 10px; color: var(--text-secondary); }

.holiday-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.holiday-chips .chip { cursor: default; }
.holiday-chips .chip button { border: none; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 13px; padding: 0 0 0 2px; line-height: 1; }

/* Calendar grid */
.cal-wrap { overflow-x: auto; }
.calendar { min-width: 720px; }
.rb-shiftcal { max-width: 1100px; margin: 0 auto; }
.cal-head, .cal-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head { margin-bottom: 6px; }
.cal-head div { text-align: center; font-size: 12px; font-weight: 700; color: var(--text-secondary); padding: 2px; }
.cal-head .dow-sun { color: var(--critical); }
.cal-head .dow-sat { color: var(--info); }
.cal-week { margin-bottom: 6px; }

.cal-cell {
  min-height: 92px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--baseline);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  background: var(--surface-1);
  display: flex; flex-direction: column; gap: 5px;
}
.cal-cell.is-empty { background: transparent; border: none; }
.cal-cell.type-holiday { background: color-mix(in srgb, var(--warning-wash) 40%, var(--surface-1)); }
.cal-cell.cov-good { border-left-color: var(--good); }
.cal-cell.cov-warning { border-left-color: var(--warning); }
.cal-cell.cov-serious { border-left-color: var(--serious); }
.cal-cell.cov-critical { border-left-color: var(--critical); }
.cal-cell.cov-surplus { border-left-color: var(--info); }

.cal-date { display: flex; align-items: baseline; justify-content: space-between; gap: 4px; }
.cal-date .d-num { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cal-date .d-dow { font-size: 11px; color: var(--text-muted); }
.cal-date .d-num.sun { color: var(--critical); }
.cal-date .d-num.sat { color: var(--info); }
table.data td.sun { color: var(--critical); font-weight: 700; }
table.data td.sat { color: var(--info); font-weight: 700; }
.cal-type { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 999px; align-self: flex-start; }
.cal-type.t-holiday { background: var(--warning-wash); color: var(--serious); }
.cal-type.t-weekday { background: var(--surface-2); color: var(--text-muted); }
.cal-note { font-size: 10px; color: var(--serious); font-weight: 600; }

.cov-line { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-variant-numeric: tabular-nums; }
.cov-line .cov-label { color: var(--text-secondary); font-size: 11px; }
.cov-line .cov-val { font-weight: 700; }
.cov-val.short { color: var(--critical); }
.cov-val.ok { color: var(--good); }
.cov-val.over { color: var(--info); }

.legend .legend__swatch.sw-accent { border-radius: 2px; width: 6px; height: 14px; }

/* Week-load table highlight */
tr.week-crunch td { background: var(--critical-wash); }
.big-answer { font-size: 15px; line-height: 1.7; max-width: 900px; }
.big-answer b { font-size: 17px; }

/* =========================================================================
   休館日（完全休業日）
   ========================================================================= */
.cal-cell.type-closed { background: var(--surface-2); opacity: .75; border-left-color: var(--baseline); }
.cal-type.t-closed { background: var(--surface-2); color: var(--text-muted); }
.cov-label.muted { color: var(--text-muted); font-style: italic; }

/* =========================================================================
   スタッフ管理（時間帯単位のカード表示）
   ========================================================================= */
.staff-card { border: 1px solid var(--grid); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 14px; }
.staff-card__head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.staff-name {
  min-width: 140px; font-weight: 600; padding: 6px 8px; font-size: 14px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface-1); color: var(--text-primary);
}
.staff-card__head select { width: auto; padding: 5px 6px; font-size: 13px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-1); color: var(--text-primary); }
.staff-input-sm { width: 64px; text-align: right; }
.staff-reorder { display: inline-flex; gap: 2px; }
.staff-reorder .btn { padding: 4px 8px; line-height: 1; }
.staff-reorder .btn[disabled] { opacity: .3; cursor: default; }

/* コアタイム強調（必要人数グリッド・ヒートマップ共通） */
tr.core-row th.hm-hour { color: var(--info); font-weight: 800; }
table.heatmap tr.core-row td { box-shadow: inset 0 2px 0 var(--info), inset 0 -2px 0 var(--info); }

/* 日付ヘッダーの土日祝カラー（ヒートマップ・グリッド共通） */
table.heatmap thead th.hm-h-hol { background: var(--warning-wash); color: var(--critical); border-radius: 5px 5px 0 0; }
table.heatmap thead th.hm-h-sat { background: var(--info-wash); color: var(--info); border-radius: 5px 5px 0 0; }
table.heatmap thead th.hm-h-closed { background: var(--surface-2); color: var(--text-muted); border-radius: 5px 5px 0 0; }

/* =========================================================================
   手動シフト作成ツール（builder）
   ========================================================================= */
table.rb-grid td.rb-cell { min-width: 26px; position: relative; padding: 1px 1px; font-size: 9px; font-weight: 600; white-space: nowrap; overflow: hidden; }
th.rb-dayhead { cursor: pointer; }
th.rb-dayhead:hover { color: var(--text-primary); text-decoration: underline; }
th.rb-selday { outline: 2px solid var(--info); outline-offset: -2px; border-radius: 4px; }

.rb-cell.rb-empty { color: var(--text-muted); font-weight: 400; cursor: pointer; }
.rb-cell.rb-empty:hover { background: var(--info-wash); color: var(--text-primary); }
.rb-cell.rb-na { color: var(--text-muted); font-weight: 400; cursor: pointer; background: var(--surface-2); opacity: .7; }
.rb-cell.rb-na:hover { opacity: 1; outline: 1px dashed var(--warning); }
/* 希望休のコマ: 勤務不可曜日(休=グレー)と区別できるよう、琥珀色で明示する */
.rb-cell.rb-dayoff { color: var(--serious); font-weight: 700; cursor: pointer; background: var(--warning-wash); border: 1px dashed var(--serious); border-radius: 5px; }
.rb-cell.rb-dayoff:hover { background: var(--serious-wash); }
.rb-cell.rb-closed { background: var(--surface-2); color: var(--text-muted); font-weight: 400; }
.rb-cell.rb-work { background: var(--good-wash); border: 1px solid rgba(12,163,12,.4); border-radius: 5px; }
.rb-cell.rb-work.rb-warn { background: var(--warning-wash); border-color: var(--serious); }
.rb-time { cursor: pointer; padding: 1px 2px; border-radius: 3px; white-space: nowrap; }
.rb-time:hover { background: rgba(42,120,214,.25); }
.rb-x { position: absolute; top: 0; right: 1px; border: none; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 11px; line-height: 1; padding: 0 2px; }
.rb-x:hover { color: var(--critical); }
/* インライン時刻編集はセル内の通常フローに置くと、狭いコマ幅に収まらず折り返して
   行の高さが変わり、下の行や固定列がガタつく。さらに絶対配置でセル内に重ねると、
   横スクロールする割当グリッド（overflow:auto）の端で切れてしまう。そのため
   position:fixed で画面基準の浮き出しポップオーバーとして表示し、座標はJS側で
   セルの位置から算出・画面内にクランプする（openTimeEditor 参照）。 */
.rb-edit {
  position: fixed; z-index: 50;
  display: flex; align-items: center; gap: 2px; white-space: nowrap;
  background: var(--surface-1); border: 1px solid var(--info); border-radius: 4px;
  padding: 3px 4px; box-shadow: var(--shadow);
}
.rb-edit select { font-size: 11px; padding: 1px; width: auto; border: 1px solid var(--info); border-radius: 3px; background: var(--surface-1); color: var(--text-primary); }
.rb-apply { border: 1px solid var(--info); background: var(--info); color: #fff; border-radius: 3px; font-size: 10px; line-height: 1; padding: 2px 4px; margin-left: 2px; cursor: pointer; }

/* シフトカレンダー（各日の出勤者名＋時間） */
.rb-shiftcal .cal-cell { min-height: 112px; }
.rb-shiftcal .rb-calday { cursor: pointer; }
.rb-shiftcal .rb-calday:hover { outline: 2px solid var(--info); outline-offset: -2px; }
.sc-line { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; font-size: 11px; line-height: 1.4; }
.sc-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-time { color: var(--text-secondary); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.sc-empty { font-size: 11px; color: var(--text-muted); }
.sc-short { font-size: 10px; font-weight: 700; color: var(--critical); margin-top: auto; }
.sc-short--soft { color: var(--serious); }

/* 割当グリッド／充足ヒートマップ／勤務表：スタッフ名(左)・日付セル(中央、横スクロール)・
   日数や実働hなどの集計(右) を、それぞれ独立したテーブルとして横に並べる。
   同じテーブル内でposition:stickyにするより、行の高ささえ揃えれば背景の隙間や
   スクロール幅のズレが原理的に起きないため、こちらの構成に統一している。 */
.rb-split { display: flex; align-items: flex-start; max-width: 100%; }
.rb-split__left, .rb-split__right { flex: none; }
.rb-split__scroll { flex: 1 1 auto; min-width: 0; overflow-x: auto; }
.rb-split table.heatmap { table-layout: fixed; width: auto; min-width: 0; border-spacing: 1px; }
.rb-split table.rb-fixed th.hm-corner, .rb-split table.rb-fixed-right th.num {
  width: 104px; min-width: 104px; max-width: 104px; overflow: hidden; text-overflow: ellipsis; box-sizing: border-box;
}
.rb-split table.rb-fixed-right th.num, .rb-split table.rb-fixed-right td.num { width: 54px; min-width: 54px; box-sizing: border-box; }
.rb-split table.rb-grid thead th, .rb-split table.rb-grid tbody td,
.rb-split table.rb-heat thead th, .rb-split table.rb-heat tbody td { width: 37px; min-width: 37px; box-sizing: border-box; }
/* 3つのテーブルの行の高さを厳密に揃える（内容の行数に依存しないよう固定） */
.rb-split table.heatmap thead th { height: 44px; box-sizing: border-box; }
.rb-split table.heatmap tbody th, .rb-split table.heatmap tbody td { height: 32px; box-sizing: border-box; }
.rb-split table.rb-fixed th.hm-corner, .rb-split table.rb-fixed-right th.num { height: 44px; }

tr.rb-sumrow th.hm-hour { color: var(--text-secondary); font-weight: 700; }
.rb-cell.rb-short { background: var(--critical-wash); color: var(--critical); font-weight: 800; }
.rb-cell.rb-short-soft { background: var(--warning-wash); color: var(--serious); font-weight: 700; }
.rb-cell.rb-ok { color: var(--good); }
.rb-cell.rb-surplus { background: var(--info-wash); color: var(--info); font-weight: 700; }

.roster-name.rb-name-warn { color: var(--serious); }
.rb-spot-tag { display: inline-block; font-size: 9px; font-weight: 700; color: #fff; background: var(--emp-arbeit); border-radius: 3px; padding: 0 4px; margin-left: 4px; vertical-align: middle; }
/* 連続勤務日数バッジ（連勤の最終日に表示） */
.rb-run { position: absolute; bottom: 0; right: 1px; font-size: 9px; font-weight: 800; color: var(--text-secondary); background: var(--surface-2); border-radius: 3px 0 4px 0; padding: 0 3px; line-height: 1.3; }
.rb-run-warn { color: var(--serious); }
.rb-run-crit { color: var(--critical); }
.rb-run-over { color: #fff; background: var(--critical); }
/* スポット勤務日エディタ */
.spot-editor { margin-top: 8px; }
.spot-input { padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-1); color: var(--text-primary); font-size: 13px; }
.rb-daypanel { border: 1px solid var(--serious); }
.rb-chiprow, .rb-candrow { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.rb-chiprow .chip button { border: none; background: transparent; color: var(--text-muted); cursor: pointer; padding: 0 0 0 3px; }
.rb-chiprow .chip button:hover { color: var(--critical); }
/* 日別パネルの希望休トグルボタン（ON時は琥珀色で強調） */
.rb-offbtn--on { background: var(--warning-wash); border-color: var(--serious); color: var(--serious); font-weight: 700; }
.rb-offbtn--on:hover { background: var(--serious-wash); }

/* 希望休の編集行 */
.daysoff-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.daysoff-row .holiday-chips { margin-top: 0; }
.dayoff-input { padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-1); color: var(--text-primary); font-size: 13px; }

/* 勤務表（スタッフ別ロースター） */
table.roster th.hm-corner, table.roster .roster-name { text-align: left; white-space: nowrap; min-width: 96px; background: var(--surface-1); }
table.roster th.dow-sun { color: var(--critical); }
table.roster th.dow-sat { color: var(--info); }
.roster-cell { font-size: 11px; font-weight: 600; white-space: nowrap; }
.roster-cell.rc-work { background: var(--good-wash); border-color: rgba(12,163,12,.35); color: var(--text-primary); }
.roster-cell.rc-idle { color: var(--text-muted); font-weight: 400; }
.roster-cell.rc-off { background: var(--surface-2); color: var(--text-muted); font-weight: 400; }
.roster-cell.rc-closed { background: var(--surface-2); color: var(--text-muted); font-weight: 400; }

/* ---- タブ（index.html: シフト作成 / 設定 / 分析・試算） ------------------- */
.tabbar {
  display: flex; gap: 4px; margin: 0 0 14px;
  border-bottom: 2px solid var(--border);
}
.tab-btn {
  appearance: none; border: none; background: transparent; cursor: pointer;
  padding: 10px 18px; font-size: 14px; font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  border-radius: 8px 8px 0 0;
}
.tab-btn:hover { background: var(--surface-2); color: var(--text-primary); }
.tab-btn--active { color: var(--info); border-bottom-color: var(--info); }
.tab-panel[hidden] { display: none; }
.tab-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; justify-content: flex-end; }

@media print {
  .tabbar, .tab-actions { display: none !important; }
}
