/* amagi_shift base styles */
:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1f2933;
  --text-muted: #5b6b7d;
  --primary: #2e7dd1;
  --primary-hover: #1f5fa3;
  --danger: #d64545;
  --warn: #d97706;
  --ok: #2f9e64;
  --info: #2c7dd1;
  --shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 12px;
  padding-top: 12px;
  padding-bottom: 12px;
  position: relative;
}
.brand {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text);
}
.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.user-name {
  color: var(--text-muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

/* ナビをボタン状に */
.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  border-radius: 8px;
  background: #f7fafc;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.nav-btn:hover {
  background: #e6eef8;
  text-decoration: none;
  border-color: #c8d6e5;
}
.nav-btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.nav-btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}
.nav-btn-danger {
  background: #fff;
  color: var(--danger);
  border-color: #f5b5b5;
}
.nav-btn-danger:hover {
  background: #fdecec;
  color: var(--danger);
}
.nav-btn-pink {
  background: #fce2ec;
  color: #8a3050;
  border-color: #f4a8be;
}
.nav-btn-pink:hover {
  background: #f4a8be;
  color: #fff;
  border-color: #f4a8be;
}
.nav-btn-green {
  background: #d8f0e1;
  color: #15633b;
  border-color: #97d3b1;
}
.nav-btn-green:hover {
  background: #97d3b1;
  color: #fff;
  border-color: #97d3b1;
}
.nav-btn-admin {
  background: #fdf0d2;
  color: #8a5a14;
  border-color: #e8c781;
}
.nav-btn-admin:hover {
  background: #e8c781;
  color: #fff;
  border-color: #e8c781;
}

/* 管理メニュータイル */
.card.admin-section-card {
  padding: 12px 14px;
  margin-bottom: 8px;
}
.card.admin-section-card h2 {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 600;
}
.admin-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 6px;
}
.admin-tile {
  display: block;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.05s, box-shadow 0.15s;
}
.admin-tile:hover {
  border-color: var(--primary);
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(46, 125, 209, 0.15);
}
.admin-tile:active { transform: translateY(1px); }
.admin-tile .tile-icon { font-size: 1.6rem; margin-bottom: 4px; }
.admin-tile .tile-title { font-weight: 700; font-size: 1.05rem; margin-bottom: 4px; }
.admin-tile .tile-desc { color: var(--text-muted); font-size: 0.85rem; line-height: 1.4; }

/* タイル色分け */
.admin-tile.tile-green  { background: #f0faf3; border-color: #b3dcc4; }
.admin-tile.tile-green:hover  { background: #d8f0e1; border-color: var(--ok); box-shadow: 0 4px 12px rgba(47, 158, 100, 0.18); }
.admin-tile.tile-green  .tile-title { color: #15633b; }

.admin-tile.tile-yellow { background: #fff8e6; border-color: #e8c781; }
.admin-tile.tile-yellow:hover { background: #fdf0d2; border-color: #d6a445; box-shadow: 0 4px 12px rgba(214, 164, 69, 0.2); }
.admin-tile.tile-yellow .tile-title { color: #8a5a14; }

.admin-tile.tile-blue   { background: #f0f5fc; border-color: #b9c8e8; }
.admin-tile.tile-blue:hover   { background: #e2eafc; border-color: var(--primary); box-shadow: 0 4px 12px rgba(46, 125, 209, 0.18); }
.admin-tile.tile-blue   .tile-title { color: #1f4097; }

.admin-tile.tile-pink   { background: #fdebf3; border-color: #f0b9d3; }
.admin-tile.tile-pink:hover   { background: #fad0e3; border-color: #d6478e; box-shadow: 0 4px 12px rgba(214, 71, 142, 0.2); }
.admin-tile.tile-pink   .tile-title { color: #a13270; }
.admin-tile.tile-orange { background: #fff3e0; border-color: #f5c79e; }
.admin-tile.tile-orange:hover { background: #ffd9b3; border-color: #d97706; box-shadow: 0 4px 12px rgba(217, 119, 6, 0.2); }
.admin-tile.tile-orange .tile-title { color: #b8521a; }

/* ハンバーガー */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
}
.nav-toggle-bar {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
}
.store-tag {
  background: #fff3e0;
  color: #b8521a;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  border: 1px solid #f5c79e;
  font-weight: 600;
  white-space: nowrap;
}
.store-tag.master-tag {
  background: #fdf0d2;
  color: #8a5a14;
  border-color: #e8c781;
}
.store-switch select {
  padding: 4px 8px;
  border: 1px solid #f5c79e;
  border-radius: 999px;
  font-size: 0.85rem;
  background: #fff3e0;
  color: #b8521a;
  font-weight: 600;
}

main { padding: 24px 0 60px; }

.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 16px 0;
  color: var(--text-muted);
  text-align: center;
  font-size: 0.85rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}
.card.swap-card {
  padding: 10px 14px;
  margin-bottom: 8px;
}
.card.mypage-card {
  padding: 12px 14px;
  margin-bottom: 8px;
}
.mypage-card h2 { margin: 0 0 6px; font-size: 1rem; }
.mypage-card .table th,
.mypage-card .table td { padding: 6px 10px; font-size: 0.9rem; }
.mypage-card .table th { width: 110px; white-space: nowrap; }
.mypage-card .table td { word-break: break-all; }
.mypage-card .hint { margin: 4px 0; }
.mypage-card details { margin-bottom: 6px; }
.mypage-card .actions { margin-top: 6px; }
.card.swap-card form[hidden] { display: none !important; }

/* リンク化リスト (ホームの交代募集など、行全体タップで遷移) */
.link-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.link-list .link-list-item {
  display: block;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  border-radius: 4px;
}
.link-list .link-list-item:hover {
  background: #f5f7fa;
  text-decoration: none;
  color: var(--text);
}
.link-list .ll-date {
  font-weight: 600;
  color: var(--primary);
}

/* ホームのシフト交代+お知らせ横並び (PC幅のみ) */
.home-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}
@media (min-width: 1024px) {
  .home-grid {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  .home-grid > .card { margin-bottom: 0; }
}
.card h1 { margin-top: 0; }
.card h2 { margin-top: 0; }

.alert {
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
}
.alert-error { background: #fdecec; color: #8a1f1f; border: 1px solid #f5b5b5; }
.alert-info { background: #e6f2fb; color: #1c4f7c; border: 1px solid #b9d9ee; }

.form { display: flex; flex-direction: column; gap: 12px; }
.form[hidden], form[hidden] { display: none !important; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.92rem; color: var(--text-muted); }
.form input[type=text],
.form input[type=email],
.form input[type=password],
.form input[type=date],
.form input[type=time],
.form input[type=number],
.form select,
.form textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
.form textarea { resize: vertical; min-height: 60px; }
.password-wrap {
  position: relative;
  display: block;
}
.password-wrap input {
  width: 100%;
  padding-right: 42px;
}
.password-wrap .pwd-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 6px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.password-wrap .pwd-toggle svg { display: block; }
.password-wrap .pwd-toggle:hover { color: var(--text); }
.password-wrap .pwd-toggle:focus { outline: none; }
.form-foot { margin-top: 12px; font-size: 0.9rem; color: var(--text-muted); }
.login-foot { font-size: 1rem; line-height: 2; }
.login-foot a { font-weight: 600; }
.form label .field-label {
  display: inline;
}
.form label .req {
  font-size: 0.7rem;
  color: var(--danger);
  font-weight: 600;
  margin-left: 4px;
}
.form label .opt {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: 4px;
}
.hint { color: var(--text-muted); font-size: 0.9rem; }

.btn {
  display: inline-block;
  padding: 9px 16px;
  border: 0;
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  text-decoration: none;
}
.btn:hover { background: #f0f4f8; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-success { background: #27ae60; color: #fff; border-color: #27ae60; }
.btn-success:hover { background: #1e8449; border-color: #1e8449; color: #fff; }
.btn-purple { background: #8e44ad; color: #fff; border-color: #8e44ad; }
.btn-purple:hover { background: #6c3483; border-color: #6c3483; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b03030; border-color: #b03030; color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 0.85rem; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { background: #f7fafc; font-weight: 600; }
.table select, .table input[type="text"], .table input[type="email"], .table input[type="number"] {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
}

/* メンバー一覧 */
.member-table .member-row { cursor: pointer; }
.member-table .member-row:hover { background: #f7fafc; }
.member-table .col-emp { width: 90px; white-space: nowrap; }
.member-table .btn-unjoin {
  font-size: 0.75rem;
  padding: 3px 8px;
  white-space: nowrap;
  background: #fff;
  color: var(--danger);
  border: 1px solid #f5b5b5;
}
.member-table .btn-unjoin:hover { background: #fdecec; color: var(--danger); }
@media (max-width: 1023px) {
  .member-table .col-email,
  .member-table .col-joined { display: none; }
}
@media (max-width: 700px) {
  .member-table .col-roles { display: none; }
}

.role-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6em;
  height: 1.6em;
  padding: 0 6px;
  margin: 1px 2px 1px 0;
  border-radius: 4px;
  background: #eef3f8;
  color: #2a4660;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
}

/* 役割トグル(ボタン状) — 2列グリッド */
.role-toggle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 8px;
}
.role-toggle-grid .role-toggle {
  width: 100%;
  justify-content: flex-start;
}
.role-toggle {
  --role-color: #cccccc;
  --role-text: #fff;
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 5px;
  border: 2px solid #d4dae0;
  border-radius: 8px;
  cursor: pointer;
  background: #f3f5f7;
  color: #555;
  user-select: none;
  font-size: 0.88rem;
  white-space: nowrap;
  transition: background-color 120ms, border-color 120ms, color 120ms;
}
.role-toggle > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
/* .form label の flex-direction:column 上書きから守る (specificity 0,2,1) */
.form label.role-toggle {
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 6px;
}
.role-toggle input { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.role-toggle .role-chip {
  background: #fff;
  color: #555;
  border: 1px solid #cfd5db;
}
.role-toggle.is-on {
  background: var(--role-color);
  border-color: var(--role-color);
  color: var(--role-text);
}
.role-toggle.is-on .role-chip {
  background: #fff;
  color: var(--role-color);
  border-color: rgba(255,255,255,0.6);
}

/* 色パレットスウォッチ (24色) */
.role-color-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 4px;
  max-width: 360px;
  margin-top: 4px;
}
@media (max-width: 600px) { .role-color-grid { grid-template-columns: repeat(8, 1fr); } }
.role-color-swatch {
  display: inline-block;
  cursor: pointer;
}
.role-color-swatch input { position: absolute; opacity: 0; pointer-events: none; }
.role-color-swatch span {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--swatch);
  border: 2px solid transparent;
  border-radius: 4px;
  box-sizing: border-box;
}
.role-color-swatch:hover span { outline: 1px solid #888; }
.role-color-swatch input:checked + span {
  border-color: #222;
  box-shadow: 0 0 0 2px #fff inset;
}

/* color picker button (モーダル用) */
.role-color-swatch-btn {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--swatch);
  border: 2px solid transparent;
  border-radius: 4px;
  padding: 0;
  cursor: pointer;
  box-sizing: border-box;
}
.role-color-swatch-btn:hover { outline: 1px solid #888; }
.role-color-swatch-btn.is-selected {
  border-color: #222;
  box-shadow: 0 0 0 2px #fff inset;
}

/* admin_stores のカード一覧 */
.store-card { border-bottom: 1px solid var(--border, #e1e6ec); }
.store-card:last-child { border-bottom: none; }
.store-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
}
.store-row-info {
  appearance: none;
  background: none;
  border: none;
  padding: 4px 0;
  text-align: left;
  cursor: pointer;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
}
.store-row-info:hover { color: var(--primary); }
.store-row-info code {
  background: #f0f4f8;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
}
.store-row-code {
  display: inline-block;
  min-width: 3.4em;
  padding: 2px 6px;
  background: #fff7ec;
  color: #b06814;
  border: 1px solid #f5d8a8;
  border-radius: 4px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  flex-shrink: 0;
}
.store-row-code:empty { background: #f3f5f7; border-color: #e1e6ec; min-width: 1.2em; }
.store-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
/* 詳細モーダル内: 店舗情報を1行編集 */
.store-info-edit {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 10px;
  margin: 4px 0 8px;
}
.store-info-edit .store-info-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 160px;
  min-width: 0;
  margin: 0;
}
.store-info-edit .store-info-field input {
  padding: 5px 8px;
  border: 1px solid var(--border, #e1e6ec);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  background: #fff;
  width: 100%;
  height: 32px;
  box-sizing: border-box;
}
.store-info-edit .store-info-field-code { flex: 0 1 120px; }
.store-info-hours {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 8px;
}
.store-info-edit:not(.is-editing) .store-info-field input {
  background: #f3f5f7;
  color: #555;
}
/* 編集ボタン (編集モードOFF時の青系) */
.store-info-edit-btn {
  height: 32px;
  min-width: 72px;
  box-sizing: border-box;
  align-self: flex-end;
}
.store-info-edit-btn:not(.btn-primary) {
  background: #1e88e5;
  color: #fff;
  border-color: #1e88e5;
}
.store-info-edit-btn:not(.btn-primary):hover {
  background: #1976d2;
  border-color: #1976d2;
  color: #fff;
}

/* メンバー追加モーダル: 候補リスト */
.add-member-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border, #e1e6ec);
  border-radius: 6px;
}
.add-member-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border, #e1e6ec);
}
.add-member-item:last-child { border-bottom: none; }
.add-member-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.add-member-info strong { font-weight: 600; }
.add-member-item[hidden] { display: none; }
@media (max-width: 700px) {
  .store-row { flex-wrap: wrap; }
  .store-row-info { flex-wrap: wrap; }
  .store-row-invite { flex-basis: 100%; padding-left: 1.5em; }
  .store-row-actions { margin-left: auto; }
}

/* admin_roles の編集行 */
.role-edit-row {
  border: 1px solid var(--border, #e1e6ec);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  background: #fafbfc;
  display: block;
}
.role-edit-row .role-edit-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 10px;
}
.role-edit-row .role-edit-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
}
.role-edit-row .role-edit-field input,
.role-edit-row .role-edit-field select {
  padding: 5px 8px;
  border: 1px solid var(--border, #e1e6ec);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  background: #fff;
}
.role-edit-row .role-edit-field-code input,
.role-edit-row .role-edit-field-code select { width: 64px; padding-left: 6px; padding-right: 6px; }
.role-edit-row .role-edit-field-name { flex: 0 1 auto; min-width: 0; }
.role-edit-row .role-edit-field-name input { width: 240px; max-width: 100%; }
.role-edit-row .role-edit-field-order select { width: 70px; }
.role-edit-row .role-edit-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
}
.role-edit-row .role-edit-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
  margin-right: 10px;
}
/* 編集モードでないときはプレビューボタンのカーソルを通常に */
.role-edit-row:not(.is-editing) .role-color-trigger { cursor: default; }
.role-edit-row:not(.is-editing) .role-edit-field input,
.role-edit-row:not(.is-editing) .role-edit-field select { background: #f3f5f7; color: #555; }

/* 編集ボタン (編集モードOFF時の見た目) */
.role-edit-btn:not(.btn-primary) {
  min-width: 72px;
  background: #1e88e5;
  color: #fff;
  border-color: #1e88e5;
}
.role-edit-btn:not(.btn-primary):hover {
  background: #1976d2;
  border-color: #1976d2;
  color: #fff;
}
/* 更新ボタン (btn-primary 付与時) も同じ最小幅で揃える */
.role-edit-btn.btn-primary { min-width: 72px; }
@media (max-width: 1023px) {
  .role-edit-row .role-edit-buttons {
    flex-basis: 100%;
    justify-content: flex-start;
    margin-top: 4px;
  }
}

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.78rem; }
.month-nav .badge { font-size: 0.95rem; padding: 4px 12px; font-weight: 600; }
.badge-want { background: #d8f0e1; color: #15633b; }
.badge-ok { background: #e2eafc; color: #1f4097; }
.badge-ng { background: #fde0e0; color: #8a1f1f; }
.badge-admin { background: #fdf0d2; color: #8a5a14; margin-left: 6px; font-size: 0.7rem; }

.news-unread {
  background: #fce2ec;
}
.news-card {
  padding: 10px 14px;
  margin-bottom: 8px;
  position: relative;
}
.news-card.news-future {
  opacity: 0.7;
  border-left: 4px dashed #e8c781;
}
.news-card .news-link {
  display: block;
  color: inherit;
  text-decoration: none;
}
.news-card .news-link:hover { color: inherit; text-decoration: none; }
.news-card .news-title {
  margin: 0;
  font-size: 1rem;
  color: var(--primary);
}
.news-card .news-meta {
  margin: 4px 0;
  font-size: 0.8rem;
}
.news-card .news-preview {
  margin: 4px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  font-size: 0.9rem;
}
.news-card .news-delete {
  position: absolute;
  top: 8px;
  right: 10px;
}
.news-card.news-link-card .news-link { padding-right: 70px; }
.news-card .news-link { padding-right: 70px; }

/* お知らせ本文の表示 */
.news-body { line-height: 1.7; }
.news-body strong { font-weight: 700; }
.news-body a { color: var(--primary); text-decoration: underline; }
.news-body-preview {
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: #eef0f3;
  min-height: 60px;
  font-size: 0.95rem;
  color: var(--text);
}

/* 本文 + ライブプレビューのレイアウト */
.editor-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
@media (min-width: 1024px) {
  .editor-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: stretch;
  }
  .editor-row textarea { min-height: 240px; }
  .editor-row .news-body-preview { min-height: 240px; }
}

/* 共通モーダル内のlabel/input調整 */
.app-modal-inner label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.app-modal-inner label input[type="text"],
.app-modal-inner label input[type="date"],
.app-modal-inner label input[type="time"],
.app-modal-inner label input[type="datetime-local"],
.app-modal-inner label select,
.app-modal-inner label textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
.app-modal-inner label input:focus,
.app-modal-inner label select:focus,
.app-modal-inner label textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(46, 125, 209, 0.15);
}

/* お知らせ投稿エディタのツールバー */
.editor-toolbar {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.editor-toolbar .tool-btn {
  padding: 5px 12px;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  background: #f7fafc;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
}
.editor-toolbar .tool-btn:hover { background: #e6eef8; }
.editor-toolbar .editor-label {
  align-self: center;
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-right: 4px;
}
.editor-toolbar .editor-hint {
  align-self: center;
  font-size: 0.75rem;
}

/* 日付・日時入力をきれいに */
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
input[type="date"]:focus,
input[type="time"]:focus,
input[type="datetime-local"]:focus,
input[type="month"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(46, 125, 209, 0.15);
}

/* 店舗選択画面 */
.store-pick {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}
.store-pick-btn {
  padding: 6px 12px;
  text-align: left;
  font-size: 0.95rem;
  background: #fff;
  border: 1px solid var(--border);
  cursor: pointer;
}
.store-pick-btn:hover {
  background: #d8f0e1;
  border-color: var(--ok);
  color: var(--text);
}
.store-pick-btn[hidden] { display: none !important; }

/* お知らせ投稿: 店舗選択モーダルの3列グリッド */
.store-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-height: 60vh;
  overflow-y: auto;
}
.store-tile {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  background: #fff;
  user-select: none;
}
.store-tile:has(input:checked) {
  background: #d8f0e1;
  border-color: var(--ok);
}
.store-tile input { margin: 0; flex-shrink: 0; }
.store-tile .store-code { color: var(--text-muted); font-size: 0.75rem; }
@media (max-width: 600px) {
  .store-grid { grid-template-columns: repeat(2, 1fr); }
}

/* 既読/未読の2列レイアウト (スマホ幅でも2列維持) */
.read-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.read-col {
  padding: 8px 10px;
  border-radius: 8px;
}
.read-col h4 { margin: 0 0 6px; font-size: 0.9rem; }
.read-col-unread { background: #fce2ec; }
.read-col-unread h4 { color: #8a3050; }
.read-col-read { background: #e2eafc; }
.read-col-read h4 { color: #1f4097; }
.read-chips {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.read-chips li {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.8rem;
  white-space: nowrap;
}
.read-chips .read-time {
  color: var(--text-muted);
  font-size: 0.7rem;
  margin-left: 4px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.flex { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--text-muted); }
.right { text-align: right; }

.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 8px;
}
.month-nav h2 { margin: 0; font-size: 1.2rem; }

/* タブレット以下: バーガーメニュー */
@media (max-width: 1024px) {
  .nav-toggle { display: inline-flex; }
  .nav {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 16px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 6px 20px rgba(15,23,42,0.12);
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    min-width: 200px;
    max-width: calc(100vw - 32px);
    z-index: 90;
  }
  .nav.active { display: flex; }
  .nav-btn {
    width: 100%;
    justify-content: center;
    padding: 10px 14px;
    font-size: 0.95rem;
  }
}

@media (max-width: 600px) {
  .table th, .table td { padding: 8px 6px; font-size: 0.9rem; }
  .brand { font-size: 1.05rem; }
  .user-name { font-size: 0.8rem; }
}

/* シフト希望ヘッダ + 月ジャンプ */
html { scroll-behavior: smooth; }
.request-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.request-header .month-jump {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.request-header .month-jump .btn {
  padding: 5px 18px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  border: 0;
  transition: filter 0.15s, transform 0.05s;
}
.request-header .month-jump .btn:hover { filter: brightness(1.08); text-decoration: none; color: #fff; }
.request-header .month-jump .btn:active { transform: translateY(1px); }
.request-header .month-jump .btn:nth-child(1) { background: #d6336c; } /* 濃いピンク */
.request-header .month-jump .btn:nth-child(2) { background: #ec6991; } /* 普通ピンク */
.request-header .month-jump .btn:nth-child(3) { background: #f4a8be; color: #8a3050; } /* 薄いピンク */
.request-header .month-jump .btn:nth-child(3):hover { color: #8a3050; }
section.card[id] { scroll-margin-top: 80px; }

/* カレンダーグリッド */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}
.cal-head {
  text-align: center;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 6px 0;
  background: #f7fafc;
  border-radius: 6px;
}
.cal-empty { background: transparent; }
.cal-cell {
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: 6px;
  min-height: 80px;
  padding: 0;
  font-size: 0.82rem;
  position: relative;
}
.cal-cell .cal-date {
  font-weight: 700;
  font-size: 0.95rem;
}
.cal-cell.dow-sun .cal-date { color: var(--danger); }
.cal-cell.dow-sat .cal-date { color: var(--primary); }
.cal-cell .cal-holiday {
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  padding: 1px 4px;
  border-radius: 3px;
}
/* 3段レイアウト */
.cal-row {
  width: 100%;
}
.cal-row-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  min-height: 18px;
}
.cal-row-mid {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: clamp(0.6rem, 2.2vw, 0.85rem);
  color: var(--text);
  font-weight: 600;
  padding: 2px 0;
  white-space: nowrap;
  overflow: hidden;
  letter-spacing: -0.02em;
}
.cal-row-mid.time-mid { gap: 2px; }
.cal-row-mid.time-mid .t-start,
.cal-row-mid.time-mid .t-end { white-space: nowrap; }

@media (max-width: 700px) {
  .cal-cell { min-height: 96px; }
  .cal-row-mid.time-mid {
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 0;
    line-height: 1.1;
  }
  .cal-row-mid.time-mid .t-start { text-align: left; padding-left: 2px; }
  .cal-row-mid.time-mid .t-end   { text-align: right; padding-right: 2px; }
}
.cal-row-bot {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  min-height: 14px;
}
.cal-cell.pref-want { background: #d8f0e1; }
.cal-cell.pref-ok { background: #e2eafc; }
.cal-cell.pref-ng { background: #fde0e0; }
.cal-cell.pref-free { background: #d8f0e1; }
.cal-cell.pref-time { background: #e2eafc; }
.cal-cell.pref-off { background: #fde0e0; }
.cal-cell.cal-tap {
  display: flex;
  flex-direction: column;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  padding: 4px 6px 4px;
  margin: 0;
  width: 100%;
}
.cal-cell.cal-tap:hover { filter: brightness(0.97); }

/* 確定シフトカレンダーのセル */
.assign-cell {
  align-items: stretch;
  text-align: left;
  padding: 4px 6px 6px;
}
.assign-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 2px;
  flex: 1;
  overflow: hidden;
}
.assign-line {
  font-size: 0.72rem;
  line-height: 1.2;
  padding: 1px 4px;
  background: #eef5fb;
  color: #1565c0;
  border-radius: 3px;
  display: flex;
  justify-content: space-between;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
}
.assign-line .assign-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.assign-line .assign-time { color: #555; font-size: 0.68rem; flex-shrink: 0; }
.assign-line.is-mine { background: #fff3d6; color: #8a5a14; }
.assign-line.is-mine .assign-time { color: #8a5a14; }
.assign-cell.has-mine { box-shadow: inset 0 0 0 2px #f0b94a; }

/* カレンダー各日セルの集計表示 */
.day-counts {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
  font-size: 0.78rem;
  line-height: 1.2;
}
.day-count {
  padding: 1px 4px;
  border-radius: 3px;
}
.day-count-assigned { background: #e2eafc; color: #1f4097; font-weight: 600; }
.day-count-wish     { background: #fff8d6; color: #8a5a14; }

/* セル状態 (背景優先: 確定 > 希望 > 交代、 紫線は交代有無で独立) */
.assign-cell.day-mine-wish { background: #e6f4ea; }
.assign-cell.day-mine-assigned { background: #e6f4ea; box-shadow: inset 0 0 0 3px #2e7d32; }
.assign-cell.day-swap { background: #f0e9f7; }
/* 交代募集ある: 細い紫線 (内側) */
.assign-cell.day-has-swap { outline: 1.5px solid #7e57c2; outline-offset: -1.5px; }
/* 自分の確定 + 交代募集 が重なる場合: 緑の太枠を活かしつつ 紫線は外側に表示 */
.assign-cell.day-mine-assigned.day-has-swap { outline-offset: 0; }

/* カレンダー凡例 (文字自体を囲む) */
.shifts-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.78rem;
  color: #333;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 3px;
  line-height: 1.4;
}
.legend-item.legend-assigned { background: #e6f4ea; box-shadow: inset 0 0 0 3px #2e7d32; padding: 2px 10px; }
.legend-item.legend-wish     { background: #e6f4ea; }
.legend-item.legend-swap     { background: #f0e9f7; outline: 1.5px solid #7e57c2; outline-offset: -1.5px; }
@media (max-width: 700px) {
  .day-counts .dc-label { display: none; }
  .day-counts .day-count { text-align: right; }
}

/* シフト作成 日ヘッダ */
.day-head-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}
.day-head-center {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.day-head-right { text-align: right; }
@media (max-width: 700px) {
  .day-head-grid { grid-template-columns: 1fr auto; gap: 8px; align-items: start; }
  .day-head-spacer { display: none; }
  .day-head-center {
    justify-content: flex-start;
    flex-wrap: nowrap;
  }
  .day-head-right {
    flex-direction: column !important;
    align-items: flex-end !important;
    gap: 6px !important;
  }
  .day-head-right .print-btn { display: none !important; }
  .holiday-name { display: none; }
}

/* シフト作成 1日分: スクロールコンテナ (縦・横両方ここで発生 → sticky が効く) */
.card.dayplan-scroll {
  overflow: auto;
  max-height: calc(100vh - 200px);
}
@media (max-width: 700px) {
  .card.dayplan-scroll { max-height: calc(100vh - 160px); }
}

/* 印刷用 (A4 横) — assign_day を 1ページに収める */
@media print {
  @page { size: A4 landscape; margin: 5mm; }
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  html, body { background: #fff !important; }
  body .container { max-width: none !important; padding: 0 !important; }
  .site-header, .nav, .no-print, .role-palette, .dayplan-name-roles,
  .bar-handle, .day-head-right, footer { display: none !important; }
  .card { box-shadow: none !important; border: none !important; padding: 0 !important; margin: 0 0 2mm !important; background: transparent !important; }
  .card.dayplan-scroll { max-height: none !important; overflow: visible !important; }

  /* ガントチャートを 30人 でも A4 横 1枚 に収まるサイズに */
  /* CSS変数は inline style と同じ specificity なので !important で強制 */
  .dayplan {
    --name-w: 240px !important;
    --slot-w: 22px !important;
    --row-h: 18px !important;
    font-size: 0.7rem;
  }
  .dayplan-row { min-height: var(--row-h) !important; }
  .dayplan-name { padding: 0 4px !important; gap: 4px !important; height: var(--row-h) !important; }
  .dayplan-name-strong { font-size: 0.74rem !important; }
  .dayplan-confirmed { font-size: 0.66rem !important; flex: 0 0 8.5em !important; white-space: nowrap !important; }
  .dayplan-header .dayplan-confirmed { display: none !important; }
  .dayplan-slot-head { font-size: 0.62rem !important; line-height: var(--row-h) !important; }
  .dayplan-hour-label { font-size: 0.68rem !important; }
  .dayplan-bar {
    color: #fff !important;
    font-size: 0.72rem !important;
    top: 1px !important;
    bottom: 1px !important;
    padding: 0 3px !important;
    border-radius: 2px !important;
  }
  .dayplan-bar .bar-time { font-size: 0.62rem !important; }
  .dayplan-bar .bar-role { font-size: 0.82rem !important; margin-right: 2px !important; }
  .dayplan-header { background: #efefef !important; height: var(--row-h) !important; }
  /* 印刷時は 自分行の緑背景を消す (specificity を上げて通常ruleに勝つ) */
  .dayplan .dayplan-row.is-me { background: transparent !important; }
  .day-head-grid h2 { font-size: 0.92rem !important; }
  .day-head-spacer, .day-head-center > a { display: none !important; }
  .day-head-grid { grid-template-columns: 1fr !important; }
}

/* シフト作成 — 1日分のガントチャート風レイアウト */
.dayplan {
  --name-w: 140px;
  --slot-w: 28px;
  --row-h: 36px;
  --slot-count: 36;
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  min-width: calc(var(--name-w) + var(--slot-w) * var(--slot-count));
}
.dayplan-row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border, #e1e6ec);
  min-height: var(--row-h);
}
.dayplan-row:last-child { border-bottom: none; }
.dayplan-row.row-free { background: #f6fbf7; }
.dayplan-row.row-time { background: #f5f8fc; }
.dayplan-row.row-off  { background: #fef4f4; color: #8a8a8a; }
.dayplan-row.row-none { background: #fafbfc; color: #888; }
.dayplan-row.is-me    { background: #e6f4ea !important; }
.dayplan-header {
  position: sticky;
  top: 24px; /* 集計行 24px の下に重ねる */
  z-index: 4;
  background: #f3f5f7;
  font-weight: 600;
  border-bottom: 2px solid var(--border, #d4dae0);
  min-height: 28px !important;
  height: 28px !important;
}
.dayplan-header .dayplan-slot-head { line-height: 28px !important; }

/* 集計ブロック: 役割別稼働時間/人件費 + 売上予算 + 人件費率 (dayplan の外側に独立配置) */
.card.money-summary {
  padding: 8px 12px;
  background: #fffbe6;
}
.money-summary-body {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.money-summary-title {
  font-size: 0.85rem;
  color: #8a5a14;
  font-weight: 700;
  margin-right: 4px;
}
.money-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  background: #fff;
  border: 1px solid #d4dae0;
  font-size: 0.78rem;
  white-space: nowrap;
}
.money-chip.money-total { background: #2a2a2a; color: #fff; border-color: #2a2a2a; }
.money-chip.money-revenue { background: #e2eafc; color: #1f4097; border-color: #c5d0eb; }
.money-chip.money-ratio { background: #eef7e9; color: #2e7d32; border-color: #b7d6b3; }
.money-chip.money-ratio.is-high { background: #fde0e0; color: #8a1f1f; border-color: #f0b9b9; }

/* 集計行: 各時の稼働人数 */
.dayplan-counts-row {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #eef7e9;
  min-height: 24px !important;
  height: 24px !important;
  border-bottom: 1px solid var(--border, #d4dae0);
  font-size: 0.72rem;
  color: #2e7d32;
}
.dayplan-counts-row .dayplan-name {
  height: 24px !important;
  background: #eef7e9 !important;
  font-size: 0.72rem;
  color: #2e7d32;
  font-weight: 600;
}
.dayplan-count-slot {
  width: var(--slot-w);
  flex-shrink: 0;
  border-right: 1px solid #eef0f3;
  position: relative;
  line-height: 24px;
  text-align: center;
  font-size: 0.7rem;
}
.dayplan-count-slot.is-hour { border-right-color: #c9d0d8; }
.dayplan-count-num { font-weight: 700; }
.dayplan-name {
  width: var(--name-w);
  flex-shrink: 0;
  padding: 5px 6px;
  border-right: 1px solid var(--border, #e1e6ec);
  background: inherit;
  position: sticky;
  left: 0;
  z-index: 3;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  line-height: 1.15;
  min-width: 0;
}
.dayplan-name-left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}
.dayplan-name-strong {
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dayplan-confirmed {
  font-size: 0.82rem;
  color: #1565c0;
  font-weight: 700;
  white-space: nowrap;
  flex: 0 0 8.5em;
  text-align: right;
}
.dayplan-header .dayplan-confirmed {
  font-size: 0.66rem;
  color: #6c757d;
  font-weight: 500;
  flex: 0 0 auto;
}
.dayplan-name-roles {
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  overflow: hidden;
  min-width: 0;
}
.dayplan-name-roles .role-chip {
  margin: 0;
  font-size: 0.65rem;
  padding: 0 3px;
  min-width: 1.2em;
  height: 1.2em;
}
.dayplan-track {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  cursor: pointer;
  width: calc(var(--slot-w) * var(--slot-count));
}
.dayplan-track:hover { background: rgba(237,138,42,0.04); }
/* ヘッダ行 (時間目盛り) と 集計人数行 の track はクリック領域ではないので指マークを出さない */
.dayplan-header .dayplan-track,
.dayplan-counts-row .dayplan-track { cursor: default; }
.dayplan-header .dayplan-track:hover,
.dayplan-counts-row .dayplan-track:hover { background: transparent; }
.dayplan-count-slot.is-clickable { cursor: pointer; }
.dayplan-count-slot.is-clickable:hover { background: rgba(46,125,50,0.12); }
.dayplan-slot {
  width: var(--slot-w);
  flex-shrink: 0;
  border-right: 1px solid #eef0f3;
  position: relative;
}
.dayplan-slot.is-hour { border-right-color: #c9d0d8; }
.dayplan-slot-head {
  font-size: 0.7rem;
  color: #888;
  text-align: left;
  padding-left: 2px;
  line-height: var(--row-h);
}
.dayplan-hour-label { color: #333; font-weight: 600; }
/* 希望時間帯のハイライト (薄い黄色) */
.dayplan-wish {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(255, 224, 102, 0.4);
  border: none;
  pointer-events: none;
  z-index: 1;
}
/* 確定シフトのバー */
.dayplan-bar {
  position: absolute;
  top: 8px;
  bottom: 8px;
  background: #1e88e5;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0 6px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 2;
  font-family: inherit;
}
.dayplan-bar:hover { filter: brightness(0.92); }
.dayplan-bar .bar-time { font-size: 0.7rem; opacity: 0.9; }
.dayplan-bar .bar-role { font-size: 0.85rem; font-weight: 700; margin-right: 4px; }
.dayplan-bar.is-temp { opacity: 0.65; pointer-events: none; }
.dayplan-row.role-ineligible { opacity: 0.45; }
.dayplan-row.role-ineligible .dayplan-track { cursor: not-allowed; }

/* バーの両端ハンドル (時間調整) */
.bar-handle {
  position: absolute;
  top: 2px;
  bottom: 2px;
  width: 5px;
  background: rgba(255,255,255,0.85);
  border-radius: 1px;
  cursor: ew-resize;
  touch-action: none;
}
.bar-handle-left { left: 2px; }
.bar-handle-right { right: 2px; }
.bar-handle:hover { background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.15); }
.dayplan-bar.is-resizing { z-index: 5; box-shadow: 0 0 0 2px rgba(0,0,0,0.2); }

/* 役割パレット */
.role-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.palette-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  border: 2px solid #d4dae0;
  border-radius: 6px;
  background: #f3f5f7;
  color: #555;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.86rem;
  user-select: none;
}
.palette-btn:hover { border-color: #aab2bc; }
.palette-btn.is-active {
  background: var(--role-color, #1e88e5);
  border-color: var(--role-color, #1e88e5);
  color: var(--role-text, #fff);
}
.palette-btn[data-role-id=""].is-active {
  background: #555;
  border-color: #555;
  color: #fff;
}
.palette-btn-compact {
  padding: 3px;
  gap: 0;
}
/* 役割コード単独ボタン (B/S/P/E) */
.palette-btn-code {
  min-width: 3em;
  padding: 5px 14px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: #fff;
  color: var(--role-color);
  border: 2px solid var(--role-color);
  justify-content: center;
  text-align: center;
}
.palette-btn-code:hover { background: color-mix(in srgb, var(--role-color) 12%, #fff); }
.palette-btn-code.is-active {
  background: var(--role-color);
  color: var(--role-text);
  border-color: var(--role-color);
}
.history-btn {
  font-size: 1.05rem;
  line-height: 1;
  padding: 4px 10px;
  background: #fff;
  color: #444;
  border: 2px solid #d4dae0;
  border-radius: 6px;
  font-family: inherit;
  cursor: pointer;
}
.history-btn:hover:not(:disabled) { background: #f3f5f7; border-color: #aab2bc; }
.history-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ロック状態 (確定済み or 締切過ぎ) — はっきりグレーアウト */
.cal-cell:disabled,
.cal-cell.cal-assigned,
.cal-cell.cal-past-deadline {
  background: #e2e6eb !important;
  color: #9aa3ad !important;
  cursor: not-allowed !important;
  opacity: 0.7;
  filter: none !important;
  position: relative;
}
.cal-cell:disabled:hover,
.cal-cell.cal-assigned:hover,
.cal-cell.cal-past-deadline:hover { filter: none !important; }
.cal-cell.cal-assigned .cal-date,
.cal-cell.cal-past-deadline .cal-date { color: #8a929b !important; }
/* 斜線オーバーレイで「無効」感を強調 */
.cal-cell.cal-assigned::before,
.cal-cell.cal-past-deadline::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    135deg,
    transparent 0,
    transparent 6px,
    rgba(0,0,0,0.05) 6px,
    rgba(0,0,0,0.05) 12px
  );
  pointer-events: none;
  border-radius: inherit;
}
/* 右上の鍵 / チェックアイコン */
.cal-lock-mark {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 0.78rem;
  color: #6b7480;
  line-height: 1;
}
.cal-cell.cal-selected { outline: 3px solid var(--ok); outline-offset: -3px; background: #d8f0e1 !important; }
.cal-edit { padding: 8px 6px; display: flex; flex-direction: column; gap: 6px; }
.cal-edit-row { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.cal-edit-row label { font-size: 0.78rem; }
.cal-edit input[type=time] { padding: 4px 6px; border: 1px solid var(--border); border-radius: 5px; font-size: 0.8rem; }

@media (max-width: 720px) {
  .cal-cell { min-height: 56px; font-size: 0.75rem; }
  .cal-cell .cal-date { font-size: 0.85rem; }
  .badge { font-size: 0.7rem; padding: 1px 5px; }
}

/* PWAインストールボタン(ナビ内) */
.nav-install {
  font-size: 0.85rem;
  white-space: nowrap;
}
.nav-install[hidden] { display: none !important; }
/* スタンドアロン(=PWAアプリ起動)中はナビのインストールボタンを必ず隠す */
@media (display-mode: standalone) {
  .nav-install { display: none !important; }
}

/* 共通通知/確認モーダル */
.app-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 16px;
  animation: appModalFade 0.15s ease-out;
}
.app-modal[hidden] { display: none !important; }
@keyframes appModalFade {
  from { background: rgba(15, 23, 42, 0); }
  to   { background: rgba(15, 23, 42, 0.55); }
}
.app-modal-inner {
  background: #fff;
  border-radius: 12px;
  padding: 20px 22px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.3);
  animation: appModalPop 0.18s ease-out;
  position: relative;
}
@keyframes appModalPop {
  from { transform: scale(0.92); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.app-modal-msg {
  margin: 0 0 16px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}
.app-modal-msg.kind-info { color: var(--text); }
.app-modal-msg.kind-error { color: var(--danger); }
.app-modal-msg.kind-confirm { color: var(--text); }
.app-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

/* シフト希望入力モーダル */
.shift-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.shift-modal[hidden] { display: none !important; }
.shift-modal-inner {
  background: #fff;
  border-radius: 12px;
  padding: 20px 22px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.3);
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: transparent;
  border: 0;
  font-size: 1.6rem;
  line-height: 1;
  width: 36px;
  height: 36px;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 8px;
}
.modal-close:hover { color: var(--text); background: #f0f4f8; }
.shift-modal-inner h3 { margin: 0 0 4px; }
.seg-tabs {
  display: flex;
  gap: 4px;
  background: #f0f4f8;
  padding: 3px;
  border-radius: 999px;
}
.seg-tab {
  flex: 1;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}
.seg-tab.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.shift-modal-inner select,
.shift-modal-inner input[type="text"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  width: 100%;
}
.modal-block {
  min-height: 72px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.modal-block[hidden] { display: none; }
.shift-modal-inner #modalDelete {
  background: transparent;
  color: var(--danger);
  border: 1px solid #f5b5b5;
}
.shift-modal-inner #modalDelete:hover {
  background: #fdecec;
  color: var(--danger);
}
.shift-modal-inner #modalDup {
  background: var(--ok);
  color: #fff;
  border: 1px solid var(--ok);
}
.shift-modal-inner #modalDup:hover {
  background: #258050;
  border-color: #258050;
  color: #fff;
}

/* 複製モード */
.copy-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--ok);
  color: #fff;
  padding: 10px 16px;
  text-align: center;
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 110;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}
.copy-banner[hidden] { display: none !important; }
.copy-fab[hidden] { display: none !important; }
.copy-banner .btn {
  background: #fff;
  color: var(--ok);
  border: 0;
}
body.copy-mode-on { padding-top: 50px; }
.copy-fab {
  position: fixed;
  right: 20px;
  bottom: 24px;
  background: var(--ok);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(47, 158, 100, 0.4);
  z-index: 100;
  font-size: 0.82rem;
  border: 0;
  font-family: inherit;
}
.copy-fab:hover { filter: brightness(1.05); }
body.copy-mode-on .cal-tap { cursor: copy; }

/* インストールガイドモーダル */
.install-modal {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.install-modal-inner {
  background: #fff;
  border-radius: 10px;
  padding: 20px 22px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 12px 32px rgba(15,23,42,0.25);
}
.install-modal-inner h3 { margin-top: 0; }
.install-modal-inner ol { padding-left: 20px; line-height: 1.8; }
.install-modal-inner .btn { margin-top: 12px; }
