:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #f2f4f9;
  --line: #dde2ec;
  --line-strong: #c6cddd;
  --text: #1d2233;
  --sub: #4b5266;
  --muted: #79809a;
  --accent: #3b62d9;
  --accent-soft: #eaeffc;
  --ok: #12855a;
  --ng: #d33049;
  --warn: #b7791f;
  --neutral: #aab2c5;
  --radius: 10px;
  font-family: "Yu Gothic UI", "Meiryo", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--accent); }

/* ---------------- ヘッダー ---------------- */
header.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(29, 34, 51, .05);
  position: sticky;
  top: 0;
  z-index: 30;
  flex-wrap: wrap;
}
header.top h1 { font-size: 17px; margin: 0; letter-spacing: .02em; }
header.top .spacer { flex: 1; }
.badge-role {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--sub);
}
.badge-role.admin { color: #8a5a00; border-color: #f0d9a8; background: #fdf5e4; }

/* ---------------- ボタン ---------------- */
button, .btn {
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 7px 13px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { background: var(--panel-2); border-color: #a9b3c9; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
button.primary:hover { background: #2f52c0; border-color: #2f52c0; }
button.danger { color: var(--ng); border-color: #f0bcc4; }
button.danger:hover { background: #fdeef0; border-color: #e59aa6; }
button.ghost { background: transparent; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.small { padding: 4px 9px; font-size: 12px; }

/* ---------------- フォーム ---------------- */
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; min-height: 66px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.check input { width: auto; }

/* ---------------- レイアウト ---------------- */
.layout { display: flex; gap: 16px; padding: 16px 20px; align-items: flex-start; }
.main { flex: 1; min-width: 0; }
.side { width: 320px; flex-shrink: 0; }
@media (max-width: 1000px) {
  .layout { flex-direction: column; }
  .side { width: 100%; }
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(29, 34, 51, .05);
  padding: 14px;
  margin-bottom: 14px;
}
.card h2 { font-size: 14px; margin: 0 0 10px; letter-spacing: .04em; color: var(--sub); font-weight: 700; }

/* ---------------- カレンダー ---------------- */
.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-title { font-size: 20px; font-weight: 700; min-width: 150px; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal-dow { background: var(--panel-2); text-align: center; padding: 6px 0; font-size: 12px; color: var(--sub); font-weight: 600; }
.cal-dow.sat { color: #2f6fd0; }
.cal-dow.sun { color: #cf3b52; }

.cal-cell {
  background: #fff;
  min-height: 108px;
  padding: 4px 5px 6px;
  cursor: pointer;
  position: relative;
  transition: background .12s;
}
.cal-cell:hover { background: #f7f9fd; }
.cal-cell.other-month { background: #f7f8fb; }
.cal-cell.other-month .cal-day { color: #b6bccb; }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-cell.selected { background: var(--accent-soft); }
.cal-cell.has-ng::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(211, 48, 73, .07), rgba(211, 48, 73, 0) 55%);
  pointer-events: none;
}
.cal-day { font-size: 12px; font-weight: 700; color: var(--sub); }
.cal-cell.sat .cal-day { color: #2f6fd0; }
.cal-cell.sun .cal-day { color: #cf3b52; }

/* 予定チップ：帯・背景はメンバーカラー、OK/NG は右端のドットで表現 */
.chip {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; line-height: 1.55;
  padding: 1px 4px 1px 5px; border-radius: 5px; margin-top: 2px;
  background: var(--panel-2);
  border-left: 4px solid var(--neutral);
  white-space: nowrap; overflow: hidden;
  position: relative; z-index: 1;
  color: var(--text);
  /* メンバーカラーが白系でも輪郭が見えるように */
  box-shadow: inset 0 0 0 1px rgba(29, 34, 51, .08);
}
.chip .txt { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.chip .status { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: var(--neutral); }
.chip.ng .status { background: var(--ng); }
.chip.ok .status { background: var(--ok); }
.more { font-size: 10px; color: var(--muted); margin-top: 2px; }

/* ---------------- 予定リスト ---------------- */
.ev {
  border: 1px solid var(--line);
  border-left: 5px solid var(--neutral);
  border-radius: 8px; padding: 10px; margin-bottom: 8px; background: #fff;
}
.ev-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ev-title { font-weight: 700; }
.ev-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.ev-note { font-size: 12px; color: var(--sub); margin-top: 6px; white-space: pre-wrap; border-top: 1px dashed var(--line); padding-top: 6px; }
.ev-actions { display: flex; gap: 6px; margin-top: 8px; }

.tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--sub); background: #fff; }
.tag.ok { color: var(--ok); border-color: #a9dcc4; background: #eefaf4; }
.tag.ng { color: var(--ng); border-color: #f2b9c2; background: #fdeef1; }
.tag.talent { color: var(--text); }

.empty { color: var(--muted); font-size: 13px; padding: 8px 2px; }
.hint { font-size: 11px; color: var(--warn); margin-top: 4px; line-height: 1.45; }

/* ---------------- モーダル ---------------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(29, 34, 51, .38);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 40px rgba(29, 34, 51, .18);
  width: 100%; max-width: 480px; max-height: 90vh; overflow: auto; padding: 18px;
}
.modal h2 { margin: 0 0 14px; font-size: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.hidden { display: none !important; }

/* ---------------- テーブル ---------------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
tr.inactive td { opacity: .45; }

/* ---------------- ログイン ---------------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box {
  width: 100%; max-width: 380px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; padding: 26px;
  box-shadow: 0 6px 24px rgba(29, 34, 51, .08);
}
.login-box h1 { font-size: 19px; margin: 0 0 4px; }
.login-box .sub { color: var(--muted); font-size: 12px; margin-bottom: 20px; }

.msg { font-size: 13px; padding: 9px 11px; border-radius: 8px; margin-bottom: 12px; }
.msg.error { background: #fdeef1; color: #a51f34; border: 1px solid #f2b9c2; }
.msg.ok { background: #eefaf4; color: #0c6b48; border: 1px solid #a9dcc4; }
.msg.info { background: var(--accent-soft); color: #23409c; border: 1px solid #bfd0f5; }

/* ---------------- スマホ表示（リスト） ---------------- */
.cal-list { display: none; }
.daylist-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 14px 0 6px; padding: 6px 10px; border-radius: 8px;
  background: var(--panel-2); font-weight: 700; font-size: 13px; cursor: pointer;
}
.daylist-head.ng { background: #fdeef1; color: #a51f34; }
.daylist-head.today { box-shadow: inset 0 0 0 2px var(--accent); }

@media (max-width: 700px) {
  .layout { padding: 12px; gap: 12px; }
  .cal-grid { display: none; }
  .cal-list { display: block; }
  .legend { display: none; }
  .cal-title { font-size: 18px; min-width: 0; }
  .cal-head { gap: 6px; }
  .filters .field { min-width: 100px; flex: 1; }
  header.top { padding: 10px 12px; gap: 8px; }
  header.top h1 { font-size: 15px; }
  .modal { padding: 14px; }
  .row { flex-direction: column; gap: 0; }
}

.msg.warn { background: #fff6e5; color: #8a5a00; border: 1px solid #f0d9a8; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.legend i.bar { width: 5px; height: 13px; border-radius: 2px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin-bottom: 0; min-width: 130px; }

.cred-box { background: var(--panel-2); border: 1px dashed var(--accent); border-radius: 8px; padding: 12px; font-family: Consolas, monospace; font-size: 13px; color: var(--text); }
