/* =========================================================
   シフトクラフター 共通スタイル（Cocoon調 白ベース・青基調）
   ========================================================= */

:root {
  --color-main: #2ca9e1;
  --color-main-dark: #1f7fae;
  --color-accent: #e9572b;
  --color-text: #333;
  --color-text-sub: #6b7178;
  --color-bg: #ffffff;
  --color-bg-alt: #f4f6f8;
  --color-bg-soft: #eef6fb;
  --color-border: #dcdcdc;
  --color-border-soft: #e8e8e8;
  --color-disabled-bg: #f0f0f0;
  --color-disabled-text: #a0a0a0;
  --color-success: #4caf50;
  --color-warn: #f5a623;
  --color-danger: #e03b3b;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.07);
  --radius: 6px;
  --font-base: "Hiragino Kaku Gothic ProN", "游ゴシック", "Yu Gothic", Meiryo, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font-base);
  color: var(--color-text);
  background: var(--color-bg-alt);
  font-size: 15px; line-height: 1.6;
}
a { color: var(--color-main-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== ヘッダー ===== */
.site-header {
  background: #fff;
  border-bottom: 3px solid var(--color-main);
  padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow-card);
}
.site-title { font-size: 20px; font-weight: bold; margin: 0; }
.site-title small { font-weight: normal; color: var(--color-text-sub); font-size: 13px; margin-left: 8px; }
.mode-badge {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: var(--color-bg-soft); color: var(--color-main-dark);
  border: 1px solid var(--color-main);
}

/* ===== ナビ（ヘッダー固定） ===== */
.global-nav {
  background: #fff;
  border-bottom: 1px solid var(--color-border-soft);
  display: flex; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-card);
}
.global-nav a {
  padding: 12px 18px; color: var(--color-text);
  border-right: 1px solid var(--color-border-soft); font-size: 14px;
}
.global-nav a:hover { background: var(--color-bg-soft); text-decoration: none; }
.global-nav a.active { background: var(--color-main); color: #fff; font-weight: bold; }

/* ===== コンテナ ===== */
.container { max-width: 1400px; margin: 22px auto; padding: 0 20px; }
.page-title {
  font-size: 20px; margin: 0 0 16px 0; padding-left: 12px;
  border-left: 5px solid var(--color-main);
}
.page-sub { color: var(--color-text-sub); font-size: 13px; margin: -8px 0 16px 0; }

/* ===== カード ===== */
.card {
  background: #fff; border: 1px solid var(--color-border-soft);
  border-radius: var(--radius); box-shadow: var(--shadow-card); margin-bottom: 20px;
}
.card-header {
  padding: 12px 16px; border-bottom: 1px solid var(--color-border-soft);
  font-weight: bold; background: var(--color-bg-soft); color: var(--color-main-dark);
  border-radius: var(--radius) var(--radius) 0 0;
}
.card-body { padding: 16px; }

/* ===== 通知 ===== */
.notice { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; border: 1px solid; }
.notice-success { background: #eefbf0; border-color: #b6e3bd; color: #277a36; }
.notice-error   { background: #fdeeee; border-color: #f0bcbc; color: #b22; }
.notice-warn    { background: #fff7e6; border-color: #f3d28a; color: #9b6a00; }

/* ===== フォーム ===== */
label { font-size: 14px; }
input[type=text], input[type=number], input[type=time], input[type=date],
select, textarea {
  font-family: inherit; font-size: 14px;
  padding: 7px 9px; border: 1px solid var(--color-border);
  border-radius: 5px; background: #fff; color: var(--color-text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--color-bg-soft); border-color: var(--color-main); }
.field { margin-bottom: 12px; }
.field label.lbl { display: block; font-weight: bold; margin-bottom: 4px; font-size: 13px; }
.field .hint { color: var(--color-text-sub); font-size: 12px; }
.form-row { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-start; }
.form-row > .btn { align-self: flex-end; }
.form-row .field { margin-bottom: 0; }
fieldset { border: 1px solid var(--color-border-soft); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 14px; }
fieldset legend { font-weight: bold; font-size: 13px; color: var(--color-main-dark); padding: 0 6px; }
.choice { display: inline-flex; align-items: center; gap: 5px; margin-right: 16px; font-size: 14px; }

/* ===== ボタン ===== */
.btn {
  display: inline-block; cursor: pointer; font-family: inherit; font-size: 14px;
  padding: 8px 16px; border-radius: 5px; border: 1px solid var(--color-main);
  background: var(--color-main); color: #fff; font-weight: bold;
}
.btn:hover { background: var(--color-main-dark); border-color: var(--color-main-dark); text-decoration: none; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-ghost { background: #fff; color: var(--color-main-dark); }
.btn-ghost:hover { background: var(--color-bg-soft); color: var(--color-main-dark); }
.btn-danger { background: var(--color-danger); border-color: var(--color-danger); }
.btn-danger:hover { background: #b22; border-color: #b22; }
.btn-muted { background: #eef0f2; color: var(--color-text); border-color: var(--color-border); }
.btn-muted:hover { background: #e2e5e8; color: var(--color-text); }

/* ===== テーブル（マスタ用） ===== */
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th, table.list td { padding: 9px 10px; border-bottom: 1px solid var(--color-border-soft); text-align: left; }
table.list th { background: var(--color-bg-soft); color: var(--color-main-dark); font-size: 13px; white-space: nowrap; }
table.list tr:hover td { background: #fafcfe; }
table.list td.actions { white-space: nowrap; text-align: right; }
.inactive td { color: var(--color-disabled-text); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--color-bg-soft); color: var(--color-main-dark); border: 1px solid var(--color-border-soft); }
.badge-off { background: #f0f0f0; color: #888; }
.chip { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 12px; margin: 1px; border: 1px solid var(--color-border-soft); }

.symbol-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 24px; padding: 0 6px; border-radius: 4px; font-weight: bold; font-size: 13px; border: 1px solid rgba(0,0,0,.12); }

/* 部署切替バー */
.dept-bar { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 14px; background: #fff; border: 1px solid var(--color-border-soft); border-radius: var(--radius); padding: 8px 12px; box-shadow: var(--shadow-card); }
.dept-bar .dept-bar-label { font-weight: bold; font-size: 13px; color: var(--color-main-dark); }

/* トップ画面のタイル */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.tile { display: block; border: 1px solid var(--color-border-soft); border-radius: var(--radius); padding: 16px; background: #fff; box-shadow: var(--shadow-card); }
.tile:hover { text-decoration: none; border-color: var(--color-main); background: #fafcfe; }
.tile .t-num { font-size: 12px; color: var(--color-main-dark); font-weight: bold; }
.tile .t-name { font-size: 16px; font-weight: bold; margin: 4px 0; color: var(--color-text); }
.tile .t-desc { font-size: 13px; color: var(--color-text-sub); }

.site-footer { text-align: center; color: var(--color-text-sub); padding: 24px; }
.muted { color: var(--color-text-sub); }
.right { text-align: right; }
.mb0 { margin-bottom: 0; }

/* =========================================================
   シフト作成エディタ
   ========================================================= */
.container-wide { max-width: 100%; padding: 0 16px; }

.shift-toolbar { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; margin-bottom: 8px; }
.shift-toolbar .dept-bar { margin-bottom: 0; }
.ym-nav { display: inline-flex; align-items: center; gap: 10px; }
.ym-label { font-size: 17px; }

.sc-editor-bar { margin-bottom: 12px; }
.palette-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.palette-label { font-size: 13px; color: var(--color-text-sub); margin-right: 4px; }
.mode-row { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.mode-sep { display: inline-block; width: 1px; height: 22px; background: var(--color-border); margin: 0 10px; }

/* パレットの記号チップ */
.sym-chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 30px; padding: 0 8px; margin: 0 1px;
  border-radius: 5px; font-weight: bold; font-size: 14px; cursor: pointer;
  border: 1px solid rgba(0,0,0,.15); user-select: none;
}
.sym-chip[title] { position: relative; }
.sym-chip.selected { outline: 3px solid var(--color-main); outline-offset: 1px; }
.sym-clear { background: #f3f4f6; color: #888; }

/* グリッド */
.grid-wrap { overflow: auto; max-height: 74vh; border: 1px solid var(--color-border-soft); border-radius: var(--radius); }
table.shift-grid { border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.shift-grid th, table.shift-grid td {
  border-right: 1px solid var(--color-border-soft);
  border-bottom: 1px solid var(--color-border-soft);
  padding: 0; text-align: center; white-space: nowrap;
}
/* 固定列・固定ヘッダー */
table.shift-grid thead th { position: sticky; top: 0; z-index: 6; background: var(--color-bg-soft); }
table.shift-grid .col-staff {
  position: sticky; left: 0; z-index: 5; background: #fff;
  min-width: 130px; max-width: 160px; text-align: left; padding: 4px 8px;
  border-right: 2px solid var(--color-border);
}
table.shift-grid thead th.col-staff { z-index: 7; background: var(--color-bg-soft); }
.staff-name { font-weight: bold; }
.staff-emp { font-size: 11px; color: var(--color-text-sub); }

table.shift-grid th.day-head { min-width: 30px; padding: 3px 2px; line-height: 1.25; font-size: 12px; }
table.shift-grid th.day-head .wd { font-size: 10px; color: var(--color-text-sub); display:block; }
.wd-sat { color: #2360c4 !important; }
.wd-sun { color: #c43030 !important; }
th.day-head.is-sat { background: #eef3fd; }
th.day-head.is-sun { background: #fdeeee; }

/* セル */
td.cell {
  min-width: 34px; height: 34px; cursor: pointer; position: relative;
  background: #fff; color: #333; vertical-align: middle; line-height: 1;
}
td.cell.col-sat { background: #f6f9ff; }
td.cell.col-sun { background: #fff6f6; }
td.cell.selected { box-shadow: inset 0 0 0 2px var(--color-main); }
td.cell .cell-code { font-weight: bold; font-size: 13px; pointer-events: none; }
td.cell .cell-flags { position: absolute; top: 0; left: 1px; font-size: 8px; line-height: 1; color: #7a5a00; font-weight: bold; pointer-events: none; }
td.cell .cell-hours { position: absolute; bottom: 0; right: 2px; font-size: 8px; line-height: 1; color: #555; pointer-events: none; }
td.cell.has-note::after {
  content: ""; position: absolute; top: 1px; right: 1px;
  border-width: 0 5px 5px 0; border-style: solid; border-color: transparent #e9572b transparent transparent;
}
td.cell.req-off { box-shadow: inset 0 0 0 2px #f5a623; } /* 希望休マーカー */
td.cell.req-off::before {
  content: "希"; position: absolute; bottom: 0; left: 1px; font-size: 9px; color: #9b6a00; pointer-events: none;
}
td.cell.alert { outline: 2px solid var(--color-danger); outline-offset: -2px; }
td.cell.alert::before { /* keep request marker if both: alert wins border */ }

/* 集計列 */
td.sumcol, th.sumcol { min-width: 36px; background: #fafbfc; font-size: 12px; padding: 2px 4px; }
td.sumcol.bad { background: #fdeeee; color: var(--color-danger); font-weight: bold; }

/* 集計行（下部：日ごとの人数） */
tr.sum-row td { background: #fafbfc; font-size: 11px; color: var(--color-text-sub); }
tr.sum-row td.short { background: #fdeeee; color: var(--color-danger); font-weight: bold; }
tr.sum-row th.col-staff { background: #fafbfc; font-weight: normal; font-size: 12px; }

/* アラートサマリ */
.alert-summary { margin-bottom: 12px; }
.alert-summary .alert-box {
  background: #fdeeee; border: 1px solid #f0bcbc; color: #b22;
  border-radius: var(--radius); padding: 10px 14px; font-size: 13px;
}
.alert-summary .alert-box.ok { background: #eefbf0; border-color: #b6e3bd; color: #277a36; }
.alert-summary ul { margin: 6px 0 0; padding-left: 20px; }
.alert-summary li { margin: 2px 0; }

.save-row { display: flex; align-items: center; margin-top: 8px; }
.dirty-flag { color: var(--color-accent); font-size: 13px; margin-left: 14px; font-weight: bold; }

@media print {
  .global-nav, .site-header, .sc-editor-bar, .shift-toolbar, #sc-cell-panel, #sc-save-form, .alert-summary { display: none !important; }
  .grid-wrap { max-height: none; overflow: visible; border: none; }
}