/* 介護・養護施設向け シフト調整アプリ - プレミアムデザインシステム */

/* 1. デザイン変数の定義 */
:root {
  /* フォントファミリー */
  --font-sans: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'Outfit', Consolas, monospace;

  /* テーマカラー (ライトテーマデフォルト) */
  --primary: #2563a8;
  --primary-hover: #1d4f87;
  --primary-glow: rgba(37, 99, 168, 0.14);
  --bg-app: #f3f5f7;
  --bg-sidebar: #f8fafc;
  --bg-card: #ffffff;
  --bg-header: rgba(255, 255, 255, 0.85);
  --bg-admin-panel: #f7f8fc;
  --bg-workspace-panel: #ffffff;
  
  --text-main: #2d3748;
  --text-title: #1a202c;
  --text-muted: #718096;
  --border: #e2e8f0;
  --border-hover: #cbd5e0;
  
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.02);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
  --shadow-glow: 0 2px 5px rgba(15, 23, 42, 0.12);

  /* シフトカラーパレット (調和のとれた配色) */
  --color-hayaban: #ff9f43;
  --color-nikkin: #00d2d3;
  --color-osoban: #10ac84;
  --color-yakin: #5f27cd;
  --color-holiday: #8395a7;
  --color-paid: #2e86de;

  /* 背景色 (不透明度付き) */
  --color-hayaban-bg: rgba(255, 159, 67, 0.12);
  --color-nikkin-bg: rgba(0, 210, 211, 0.12);
  --color-osoban-bg: rgba(16, 172, 132, 0.12);
  --color-yakin-bg: rgba(95, 39, 205, 0.12);
  --color-holiday-bg: rgba(131, 149, 167, 0.1);
  --color-paid-bg: rgba(46, 134, 222, 0.12);

  /* 文字色 */
  --color-hayaban-text: #e67e22;
  --color-nikkin-text: #0984e3;
  --color-osoban-text: #0f8664;
  --color-yakin-text: #5f27cd;
  --color-holiday-text: #636e72;
  --color-paid-text: #1b65a7;

  --color-danger: #ee5253;
  --color-danger-bg: rgba(238, 82, 83, 0.12);
  --color-warning: #f1c40f;
  --color-warning-bg: rgba(241, 196, 15, 0.12);
  --color-success: #10ac84;
}

/* ダークテーマ用上書き */
.theme-dark {
  --bg-app: #0f172a;
  --bg-sidebar: #111827;
  --bg-card: #1e293b;
  --bg-header: rgba(30, 41, 59, 0.85);
  --bg-admin-panel: #172033;
  --bg-workspace-panel: #1e293b;
  
  --text-main: #cbd5e1;
  --text-title: #f8fafc;
  --text-muted: #64748b;
  --border: #334155;
  --border-hover: #475569;
  
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.15);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.2);

  /* 背景色 (不透明度高め) */
  --color-hayaban-bg: rgba(255, 159, 67, 0.2);
  --color-nikkin-bg: rgba(0, 210, 211, 0.2);
  --color-osoban-bg: rgba(16, 172, 132, 0.2);
  --color-yakin-bg: rgba(95, 39, 205, 0.2);
  --color-holiday-bg: rgba(131, 149, 167, 0.15);
  --color-paid-bg: rgba(46, 134, 222, 0.22);

  /* 文字色 (より高コントラスト) */
  --color-hayaban-text: #ffb067;
  --color-nikkin-text: #00d2d3;
  --color-osoban-text: #1dd1a1;
  --color-yakin-text: #a55eea;
  --color-holiday-text: #94a3b8;
  --color-paid-text: #74b9ff;
}

.theme-dark .app-main {
  background:
    linear-gradient(180deg, rgba(30, 41, 59, 0.6) 0%, rgba(15, 23, 42, 0) 260px),
    var(--bg-app);
}

.theme-dark .admin-label {
  color: #93c5fd;
}

/* 2. リセット & ベーススタイル */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  overflow: hidden; /* メインスクロールは個別エリアで行う */
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.3s, color 0.3s;
}

input,
select,
textarea {
  user-select: text;
  -webkit-user-select: text;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  grid-template-columns: minmax(360px, .95fr) minmax(480px, 1.05fr);
  min-height: 100vh;
  background: #eef3f8;
  overflow: auto;
  user-select: text;
}
.auth-gate[hidden] { display: none; }
.auth-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px clamp(36px, 6vw, 88px);
  color: #fff;
  background: radial-gradient(circle at 82% 15%, rgba(91,176,255,.28), transparent 34%), linear-gradient(145deg, #0d2944, #174f7f 55%, #2375aa);
}
.auth-hero::after {
  content: "";
  position: absolute;
  right: -180px;
  bottom: -170px;
  width: 430px;
  height: 430px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 50%;
  box-shadow: 0 0 0 80px rgba(255,255,255,.035), 0 0 0 160px rgba(255,255,255,.025);
}
.auth-brand { display: flex; align-items: center; gap: 12px; font: 700 1.3rem 'Outfit', sans-serif; }
.auth-logo { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: #fff; color: #18588d; font-size: .9rem; }
.auth-hero-copy { position: relative; z-index: 1; max-width: 520px; }
.auth-eyebrow { display: inline-block; margin-bottom: 18px; color: #b9dcf4; font-size: .82rem; font-weight: 700; letter-spacing: .12em; }
.auth-hero h1 { margin: 0 0 24px; color: #fff; font-size: clamp(2.5rem, 5vw, 4.6rem); line-height: 1.14; letter-spacing: -.06em; }
.auth-hero p { max-width: 440px; color: rgba(255,255,255,.72); font-size: 1rem; line-height: 1.9; }
.auth-price { position: relative; z-index: 1; display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; color: #d6eafa; }
.auth-price strong { color: #fff; font: 600 2rem 'Outfit', sans-serif; }
.auth-price small { margin-left: 3px; font-size: .85rem; }
.auth-panel { display: grid; place-items: center; padding: 48px 32px; background: #f7f9fc; }
.auth-card { width: min(100%, 450px); padding: 38px; border: 1px solid #dde6ef; border-radius: 22px; background: #fff; box-shadow: 0 24px 70px rgba(29,58,88,.12); }
.registration-field { display: grid; gap: 7px; margin-bottom: 18px; }
.registration-field label { color: #34495e; font-size: .82rem; font-weight: 700; }
.registration-field input { width: 100%; min-height: 48px; border: 1px solid #cbd5e1; border-radius: 10px; padding: 10px 13px; color: #26384a; background: #fff; font: inherit; outline: none; }
.registration-field input:focus { border-color: #2563a8; box-shadow: 0 0 0 3px rgba(37,99,168,.12); }
.registration-note { display: block; margin-top: 16px; color: #7a8b9b; font-size: .72rem; line-height: 1.65; }
.registration-account { display: grid; gap: 3px; margin-bottom: 18px; padding: 14px; border-radius: 10px; background: #f2f6fa; }
.registration-account span { color: #718096; font-size: .72rem; }
.registration-account strong { margin-bottom: 8px; color: #26384a; font-size: .9rem; overflow-wrap: anywhere; }
.gate-price { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 18px; padding: 16px; border: 1px solid #dde6ef; border-radius: 12px; background: #f7f9fc; }
.gate-price span { color: #718096; font-size: .78rem; }
.gate-price strong { color: #183149; font-size: 1rem; }
.gate-secondary { margin-top: 10px; }
.gate-sign-out { display: block; margin: 14px auto 0; border: 0; color: #718096; background: transparent; cursor: pointer; font: inherit; font-size: .78rem; text-decoration: underline; }
.auth-price > span { color: #d6eafa; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 30px; padding: 4px; border-radius: 12px; background: #eef3f7; }
.auth-tab { border: 0; border-radius: 9px; padding: 10px; color: #718096; background: transparent; cursor: pointer; font: inherit; font-weight: 700; }
.auth-tab.active { color: #1d4f87; background: #fff; box-shadow: 0 2px 8px rgba(34,68,102,.1); }
.auth-heading h2 { margin-bottom: 7px; color: #183149; font-size: 1.55rem; }
.auth-heading p { margin-bottom: 28px; color: #7a8b9b; font-size: .9rem; }
.auth-primary { width: 100%; min-height: 50px; border: 0; border-radius: 11px; background: linear-gradient(135deg, #2563a8, #1c78ac); color: #fff; cursor: pointer; font: inherit; font-weight: 700; box-shadow: 0 8px 20px rgba(37,99,168,.23); }
.auth-primary:disabled { opacity: .6; cursor: wait; }
.auth-google-direct { display: flex; align-items: center; justify-content: center; }
.auth-google-direct .google-mark { margin-right: 10px; color: #fff; }
.auth-direct-note { margin-top: 10px; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 24px 0; color: #9aa8b5; font-size: .75rem; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: #e4eaf0; }
.google-login { position: relative; width: 100%; min-height: 48px; border: 1px solid #dce4eb; border-radius: 11px; background: #fff; color: #34495e; cursor: pointer; font: inherit; font-weight: 600; }
.google-login:disabled { cursor: not-allowed; opacity: .68; }
.google-auth-status { margin: 0; color: var(--color-danger); font-size: .72rem; line-height: 1.5; }
.google-top-login {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  padding: 7px 12px;
  color: #26384a;
  background: #fff;
  cursor: pointer;
  font: inherit;
  font-size: .8rem;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.google-top-login:hover { border-color: var(--primary); color: var(--primary); }
.google-top-login:disabled { cursor: not-allowed; opacity: .55; }
.google-mark { margin-right: 10px; color: #4285f4; font-weight: 800; }
.coming-soon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); padding: 3px 7px; border-radius: 99px; color: #7a8b9b; background: #eef3f7; font-size: .66rem; }
.auth-legal { margin-top: 24px; color: #a0acb7; font-size: .7rem; line-height: 1.7; text-align: center; }
.auth-status { margin: 0 0 16px; padding: 10px 12px; border-radius: 9px; color: #a33b3b; background: #fff0f0; font-size: .82rem; }
.auth-status[data-kind="success"] { color: #137458; background: #eaf9f3; }
.auth-status[data-kind="info"] { color: #235b86; background: #edf6fc; }
.billing-cta { width: 100%; padding: 13px; border: 1px solid rgba(37,99,168,.18); border-radius: 11px; background: linear-gradient(135deg, rgba(37,99,168,.12), rgba(37,99,168,.04)); color: var(--text-main); cursor: pointer; text-align: left; }
.billing-cta span, .billing-cta strong { display: block; }
.billing-cta-kicker { margin-bottom: 3px; color: var(--primary); font-size: .68rem; font-weight: 700; }
.billing-cta strong { color: var(--text-title); }
.billing-cta > span:last-child { color: var(--text-muted); font-size: .72rem; }
.office-account { padding: 10px 0; border-bottom: 1px solid var(--border); }
.office-account-label { display: block; color: var(--text-muted); font-size: .68rem; }
.office-account strong { display: block; margin: 3px 0 8px; color: var(--text-title); font-size: .84rem; }
.billing-modal { max-width: 620px; }
.billing-plan { padding: 8px 28px 28px; }
.billing-price-row { display: grid; grid-template-columns: 1fr; align-items: center; gap: 18px; margin: 18px 0 24px; }
.billing-price-row > div { padding: 20px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-app); }
.billing-price-row span, .billing-price-row strong { display: block; }
.billing-price-row span { color: var(--text-muted); font-size: .76rem; }
.billing-price-row strong { margin-top: 4px; color: var(--text-title); font-size: 1.22rem; }
.billing-plus { color: var(--primary) !important; font-size: 1.4rem !important; font-weight: 700; }
.billing-plan ul { display: grid; gap: 8px; margin: 0 0 24px 22px; color: var(--text-main); }
.billing-plan > small { display: block; margin-top: 12px; color: var(--text-muted); text-align: center; }

@media (max-width: 820px) {
  .auth-gate { grid-template-columns: 1fr; }
  .auth-hero { min-height: 290px; padding: 28px; }
  .auth-hero-copy { margin: 52px 0 36px; }
  .auth-hero h1 { font-size: 2.4rem; }
  .auth-price { display: none; }
  .auth-panel { padding: 24px 16px; }
  .auth-card { padding: 26px 22px; }
  .gate-price { align-items: flex-start; flex-direction: column; gap: 4px; }
  .billing-price-row { grid-template-columns: 1fr; gap: 8px; }
  .billing-plus { text-align: center; }
}

/* 3. アプリ全体のレイアウト */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  min-width: 0;
}

/* サイドバー */
.app-sidebar {
  width: 304px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
  box-shadow: 2px 0 10px rgba(15, 23, 42, 0.04);
  transition: background-color 0.3s, border-color 0.3s;
  overflow-y: auto;
  scrollbar-gutter: stable;
  min-height: 0;
}

.sidebar-brand {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background-color: var(--bg-admin-panel);
}

.brand-icon {
  width: 28px;
  height: 28px;
  color: var(--primary);
  filter: none;
}

.brand-text {
  display: block;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--text-title);
  letter-spacing: 0;
}

.brand-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
}

.surface-label {
  align-self: flex-start;
  border-radius: 999px;
  border: 1px solid rgba(37, 99, 168, 0.18);
  background-color: rgba(37, 99, 168, 0.08);
  color: var(--primary);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
  padding: 5px 8px;
}

.admin-label {
  color: #1d4f87;
}

.brand-accent {
  color: var(--primary);
}

.sidebar-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: var(--bg-sidebar);
}

.admin-control-section {
  background-color: var(--bg-admin-panel);
}

.admin-roster-section {
  background: var(--bg-sidebar);
}

/* 左側メニュー全体を一続きでスクロールする。 */
.app-sidebar .roster-section.flex-grow {
  flex-grow: 0;
  overflow: visible;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-title);
  text-transform: uppercase;
  letter-spacing: 0;
}

.flex-grow {
  flex-grow: 1;
  overflow-y: auto; /* スタッフ名簿が増えたらスクロール */
}

/* メインコンテンツ */
.app-main {
  flex-grow: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 28px 32px;
  gap: 24px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.7) 0%, rgba(255,255,255,0) 260px),
    var(--bg-app);
  scrollbar-gutter: stable;
}

/* ヘッダー */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-left: 5px solid var(--primary);
  border-radius: 12px;
  background-color: var(--bg-workspace-panel);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-title);
}

.workspace-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.office-header-name {
  color: var(--text-muted);
  font-size: .8rem;
  font-weight: 700;
}

.month-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.month-nav-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.month-nav-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.current-month-label {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-title);
  min-width: 110px;
  text-align: center;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  min-width: 0;
}

/* 4. コンポーネントスタイル */

/* ボタン */
.action-btn {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.action-btn.primary {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: var(--shadow-glow);
}

.action-btn.primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.action-btn.secondary {
  background-color: var(--bg-card);
  border-color: var(--border);
  color: var(--text-main);
}

.action-btn.secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
  background-color: rgba(108, 92, 231, 0.04);
  transform: translateY(-1px);
}

.action-btn.small {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 6px;
}

.icon-btn-small {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.icon-btn-small:hover {
  background-color: var(--border);
  color: var(--text-title);
}

/* 操作モード選択 */
.tool-modes {
  display: flex;
  background-color: var(--bg-app);
  padding: 4px;
  border-radius: 8px;
}

.tool-btn {
  flex: 1;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}

.tool-btn.active {
  background-color: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}

/* ブラシパレット */
.brush-selector {
  animation: slideDown 0.3s ease;
  background-color: var(--bg-app);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.help-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.brush-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.brush-chip {
  padding: 6px 8px;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 6px;
  border: 2px solid transparent;
  background-color: var(--bg-card);
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.brush-chip::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--chip-color);
}

.brush-chip:hover {
  border-color: var(--border-hover);
}

.brush-chip.active {
  border-color: var(--primary);
  background-color: rgba(37, 99, 168, 0.05);
}


/* 事業所別必要人数 */
.requirement-section {
  max-height: none;
  background-color: var(--bg-sidebar);
}

.location-select {
  width: 100%;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background-color: var(--bg-card);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.requirement-editor {
  height: min(58vh, 560px);
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--bg-app);
}

.requirement-editor-title {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 10px 12px;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border);
  color: var(--text-title);
  font-size: 0.9rem;
  font-weight: 700;
}

.requirement-row {
  display: grid;
  grid-template-columns: 48px repeat(4, minmax(0, 1fr));
  gap: 6px;
  align-items: center;
  min-height: 42px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
}

.requirement-row:last-child {
  border-bottom: none;
}

.requirement-row-head {
  position: sticky;
  top: 42px;
  z-index: 2;
  background-color: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
}

.requirement-row.is-weekend .requirement-day {
  color: var(--color-danger);
}

.requirement-day {
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-title);
}

.requirement-day small {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.requirement-row input {
  width: 100%;
  min-width: 0;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background-color: var(--bg-card);
  color: var(--text-main);
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.requirement-row input:focus,
.location-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 168, 0.15);
}

/* 緊急調整・ヘルプ */
.adjustment-section {
  background-color: var(--bg-admin-panel);
}

.adjustment-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 170px;
  overflow-y: auto;
}

.adjustment-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  padding: 9px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  background: var(--bg-card);
  font-size: 0.75rem;
}

.adjustment-item strong {
  color: var(--text-title);
}

.adjustment-item span {
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.adjustment-item.off {
  border-left-color: var(--color-danger);
}

.adjustment-delete {
  align-self: start;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.ai-proposal-actions {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.ai-proposal-action {
  padding: 8px;
  border-left: 3px solid var(--primary);
  background: var(--bg-card);
  border-radius: 4px;
  font-size: 0.8rem;
}

.ai-assistant-result {
  white-space: pre-wrap;
  max-height: 260px;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-app);
  color: var(--text-main);
  font-size: 0.85rem;
  line-height: 1.7;
}

.copy-target-dates {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-app);
}

.copy-date-option {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--text-main);
}

.copy-date-option input {
  accent-color: var(--primary);
}

.adjustment-actions {
  display: flex;
  gap: 3px;
}

.adjustment-edit {
  align-self: start;
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 700;
}

.master-requirement-grid {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

.master-requirement-row {
  display: grid;
  grid-template-columns: 68px repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
}

.master-requirement-row input {
  width: 100%;
  min-width: 0;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-main);
  text-align: center;
  font-family: var(--font-mono);
}

.master-requirement-head {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
}

#escort-staff {
  min-height: 112px;
}

#escort-staff option {
  padding: 6px 8px;
}

.help-section details {
  color: var(--text-main);
  font-size: 0.8rem;
}

.help-section summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text-title);
}

.help-list {
  margin: 10px 0 0 18px;
  display: grid;
  gap: 6px;
  color: var(--text-muted);
}

/* ダッシュボード統計カード */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.stat-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stat-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-title);
  margin-top: 2px;
}

.text-danger {
  color: var(--color-danger) !important;
}

/* 5. シフト表グリッド */
.grid-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.grid-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.grid-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.legend-badge {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.border-requested {
  border: 2px solid var(--color-danger);
  background-color: transparent;
}

.grid-helper {
  font-size: 0.775rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.grid-helper span {
  overflow-wrap: anywhere;
}

/* 横スクロール対応のテーブル構造 */
.grid-scroll-container {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  scrollbar-gutter: stable both-edges;
  border-radius: 10px;
  border: 1px solid var(--border);
  background-color: var(--bg-card);
  -webkit-overflow-scrolling: touch;
}

/* 横に長い月間表は、スクロール位置が常に分かるようにする。 */
.grid-scroll-container::-webkit-scrollbar,
.app-sidebar::-webkit-scrollbar,
.app-main::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.grid-scroll-container::-webkit-scrollbar-thumb,
.app-sidebar::-webkit-scrollbar-thumb,
.app-main::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.45);
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

.grid-scroll-container::-webkit-scrollbar-track,
.app-sidebar::-webkit-scrollbar-track,
.app-main::-webkit-scrollbar-track {
  background: rgba(148, 163, 184, 0.12);
}

.shift-grid-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.875rem;
  text-align: center;
  min-width: 1000px;
}

/* セル共通定義 */
.shift-grid-table th, 
.shift-grid-table td {
  border: 1px solid var(--border);
  padding: 8px 6px;
  width: 42px;
  min-width: 42px;
  height: 48px;
  vertical-align: middle;
  position: relative;
}

/* 1列目 (スタッフ名カラム) の固定表示 */
.shift-grid-table th:first-child,
.shift-grid-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 5;
  background-color: var(--bg-card);
  width: 180px;
  min-width: 180px;
  text-align: left;
  padding-left: 16px;
  box-shadow: 2px 0 5px rgba(0,0,0,0.04);
}

.shift-grid-table thead tr:first-child th:first-child {
  z-index: 6; /* 日付ヘッダーとスタッフヘッダーの交差点 */
}

/* ヘッダー行 */
.shift-grid-table thead tr th {
  background-color: var(--bg-app);
  color: var(--text-main);
  font-weight: 500;
  height: 36px;
}

/* 日付と曜日の色分け */
.day-sat {
  color: #0984e3 !important;
  background-color: rgba(9, 132, 227, 0.04);
}

.day-sun {
  color: #d63031 !important;
  background-color: rgba(214, 48, 49, 0.04);
}

/* スタッフ情報セル (1列目) */
.staff-cell-info {
  display: flex;
  width: 100%;
  min-height: 42px;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 0;
  padding: 6px 10px;
  color: inherit;
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-align: left;
  border-radius: 8px;
  touch-action: manipulation;
}

.staff-cell-info:hover,
.staff-cell-info:focus-visible {
  background: var(--primary-glow);
  outline: 2px solid transparent;
}

.staff-cell-name {
  font-weight: 700;
  color: var(--text-title);
}

.staff-cell-edit-hint {
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.2s;
}

.staff-cell-info:hover .staff-cell-edit-hint,
.staff-cell-info:focus-visible .staff-cell-edit-hint {
  opacity: 1;
}

.staff-header-add {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 0;
  padding: 7px 10px;
  color: inherit;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-align: left;
  touch-action: manipulation;
}

.staff-header-add span {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--primary);
}

@media (hover: none) {
  .staff-cell-edit-hint { opacity: 1; }
}



/* シフト選択用チップ */
.shift-chip {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  margin: 0 auto;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
  position: relative;
}

.shift-chip:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* 希望休マーク */
.shift-chip.is-requested {
  border: 2px solid var(--color-danger);
}

/* シフト別の背景・文字色 */
.bg-hayaban {
  background-color: var(--color-hayaban-bg);
  color: var(--color-hayaban-text);
}
.bg-nikkin {
  background-color: var(--color-nikkin-bg);
  color: var(--color-nikkin-text);
}
.bg-osoban {
  background-color: var(--color-osoban-bg);
  color: var(--color-osoban-text);
}
.bg-yakin {
  background-color: var(--color-yakin-bg);
  color: var(--color-yakin-text);
}
.bg-holiday {
  background-color: var(--color-holiday-bg);
  color: var(--color-holiday-text);
}
.bg-paid {
  background-color: var(--color-paid-bg);
  color: var(--color-paid-text);
}
.bg-empty {
  background-color: transparent;
  color: var(--text-muted);
  border: 1px dashed var(--border);
}

/* セル内の制約違反警告マーク */
.cell-warning-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--color-danger);
  box-shadow: 0 0 4px var(--color-danger);
  animation: pulseWarning 1.5s infinite;
}

/* 集計フッター行 */
.shift-grid-table tfoot tr {
  background-color: var(--bg-app);
}

.shift-grid-table tfoot td {
  font-size: 0.775rem;
  font-weight: 600;
  height: 38px;
  padding: 4px;
}

.stat-summary-num {
  font-family: var(--font-mono);
  display: block;
}

.stat-summary-status {
  font-size: 0.65rem;
  border-radius: 4px;
  padding: 1px 3px;
  display: inline-block;
  margin-top: 1px;
}

.status-ok {
  background-color: rgba(16, 172, 132, 0.15);
  color: var(--color-success);
}

.status-ng {
  background-color: rgba(238, 82, 83, 0.15);
  color: var(--color-danger);
}

/* 6. スタッフ名簿サイドバー */
.staff-list-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px;
}

.staff-card-item {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s;
}

.staff-card-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.staff-info-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.staff-name-text {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-title);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}



.staff-card-actions {
  display: flex;
  gap: 4px;
}

.staff-stats-sidebar {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* 7. 制約警告パネル */
.alerts-panel {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.panel-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-title);
}

.alerts-count-badge {
  background-color: var(--color-danger-bg);
  color: var(--color-danger);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
}

.alerts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 250px;
  overflow-y: auto;
}

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: 10px;
  background-color: var(--bg-app);
  border-left: 4px solid var(--color-warning);
  font-size: 0.85rem;
  animation: slideIn 0.25s ease;
}

.alert-item.critical {
  border-left-color: var(--color-danger);
}

.alert-item-icon {
  margin-top: 2px;
  flex-shrink: 0;
}

.alert-item-text {
  flex-grow: 1;
  color: var(--text-main);
  min-width: 0;
  overflow-wrap: anywhere;
}

.alert-item-action {
  font-size: 0.75rem;
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
  flex-shrink: 0;
}

.empty-alerts-msg {
  text-align: center;
  padding: 24px;
  color: var(--color-success);
  font-weight: 500;
  font-size: 0.9rem;
}

/* 8. モーダルダイアログ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background-color: var(--bg-card);
  border-radius: 20px;
  width: 550px;
  max-width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  transform: scale(0.95);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-small {
  width: 420px;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-title);
}

.modal-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.modal-close:hover {
  background-color: var(--bg-app);
  color: var(--text-title);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.footer-right {
  display: flex;
  gap: 10px;
}

/* フォーム要素 */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-title);
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select,
.form-group textarea,
.requested-dates-input input[type="date"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background-color: var(--bg-card);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  background-color: var(--bg-app);
  padding: 12px;
  border-radius: 8px;
}

.checkbox-grid label,
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text-main);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.requested-dates-input {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.request-month-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 10px;
}

.requested-dates-input input[type="date"],
.requested-dates-input select {
  flex-grow: 1;
  font-family: var(--font-mono);
  min-width: 0;
}

.requested-dates-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  max-height: 100px;
  overflow-y: auto;
}

.requested-date-tag {
  background-color: var(--color-danger-bg);
  color: var(--color-danger);
  font-family: var(--font-mono);
  font-size: 0.775rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.requested-date-tag button {
  background: transparent;
  border: none;
  color: currentColor;
  cursor: pointer;
  font-weight: 900;
  font-size: 0.8rem;
}

.request-photo-panel {
  display: grid;
  gap: 10px;
  background-color: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.request-photo-preview {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--bg-card);
}

.request-photo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.request-photo-actions .action-btn {
  justify-content: center;
}

/* シフト選択詳細グリッド (モーダル内) */
.shift-selection-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.shift-select-btn {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  transition: all 0.2s;
}

.shift-select-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  border-color: var(--border-hover);
}

.shift-select-btn.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}

.shift-code-lg {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
}

.shift-name-lg {
  font-weight: 700;
  font-size: 0.9rem;
  margin-top: 4px;
}

.shift-time-lg {
  font-size: 0.725rem;
  opacity: 0.8;
  margin-top: 2px;
}

.style-top-divider {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

/* 9. アニメーションキーフレーム */
@keyframes pulseWarning {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

/* 10. フッター切替ボタンの調整 */
.footer-btn {
  width: 100%;
  background-color: var(--bg-app);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.footer-btn:hover {
  background-color: var(--border);
  color: var(--text-title);
}

.theme-dark .icon-light {
  color: #f1c40f;
  fill: #f1c40f;
}

.sidebar-footer {
  margin-top: auto;
  padding: 20px;
  background-color: var(--bg-admin-panel);
  border-top: 1px solid var(--border);
}

.workspace-label {
  margin-bottom: 2px;
}

.app-header + .dashboard-stats {
  margin-top: 2px;
}

.dashboard-stats {
  padding: 4px 0;
}

.grid-card {
  border-top: 4px solid rgba(0, 210, 211, 0.35);
}

.alerts-panel {
  border-top: 4px solid rgba(238, 82, 83, 0.28);
}

.admin-control-section .section-title,
.admin-roster-section .section-title {
  color: var(--primary);
}

/* ペイントモード中のカーソルとテーブルホバー */
body.paint-mode {
  cursor: cell;
}

body.paint-mode .shift-grid-table td:not(:first-child) {
  cursor: cell;
}

body.paint-mode .shift-grid-table td:not(:first-child):hover {
  background-color: rgba(108, 92, 231, 0.08);
}

/* 表の行列ハイライト用の補助スタイル */
.shift-grid-table tbody tr:hover td {
  background-color: rgba(108, 92, 231, 0.02);
}

.shift-grid-table tbody tr:hover td:first-child {
  background-color: var(--bg-app);
}

/* 11. レスポンシブ調整 */
@media (max-width: 1180px) {
  .app-sidebar {
    width: 280px;
  }

  .app-main {
    padding: 20px;
    gap: 20px;
  }

  .app-header {
    align-items: flex-start;
    gap: 16px;
  }

  .dashboard-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-btn {
    padding: 9px 12px;
  }
}

/* ノートPC幅では、操作ボタンを表の横幅と競合させない。 */
@media (min-width: 901px) and (max-width: 1500px) {
  .app-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .header-actions .action-btn {
    min-width: 0;
    justify-content: center;
    white-space: nowrap;
  }

  .grid-controls {
    align-items: flex-start;
  }

  .grid-helper {
    max-width: 360px;
    text-align: right;
    justify-content: flex-end;
  }
}

@media (min-width: 901px) and (max-width: 1180px) {
  .app-sidebar {
    width: 248px;
  }

  .app-main {
    padding: 18px;
  }
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .app-container {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    width: 100%;
  }

  .app-sidebar {
    width: 100%;
    height: auto;
    min-height: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: visible;
    position: relative;
    z-index: auto;
  }

  .sidebar-brand {
    padding: 16px 20px;
  }

  .sidebar-section {
    padding: 16px 20px;
  }

  .roster-section {
    max-height: none;
    overflow: visible;
  }

  .app-sidebar .roster-section.flex-grow {
    max-height: none;
    overflow: visible;
  }

  .sidebar-footer {
    margin-top: 0;
    padding: 16px 20px;
  }

  .app-main {
    overflow: visible;
    padding: 20px;
    position: relative;
    z-index: 0;
  }

  .app-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-left {
    gap: 8px;
  }

  .month-selector {
    flex-wrap: wrap;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .header-actions .action-btn {
    flex: 1 1 calc(50% - 10px);
    justify-content: center;
  }

  .grid-card,
  .alerts-panel {
    padding: 18px;
    border-radius: 12px;
  }

  .shift-grid-table {
    min-width: 900px;
  }

  .shift-grid-table th:first-child,
  .shift-grid-table td:first-child {
    width: 150px;
    min-width: 150px;
    padding-left: 12px;
  }
}

@media (max-width: 640px) {
  .app-sidebar {
    background: var(--bg-app);
  }

  .sidebar-brand {
    padding: 14px 16px;
    background: var(--bg-sidebar);
  }

  .sidebar-section {
    margin: 0;
    padding: 14px 16px;
    gap: 10px;
    background: var(--bg-sidebar);
  }

  .admin-control-section,
  .adjustment-section,
  .help-section,
  .roster-section {
    border-top: 8px solid var(--bg-app);
  }

  .requirement-section {
    max-height: none;
    border-top: 8px solid var(--bg-app);
  }

  .requirement-section .section-title {
    font-size: 1rem;
  }

  .location-select,
  .requirement-section .action-btn {
    min-height: 44px;
    font-size: 0.95rem;
  }

  .requirement-editor {
    max-height: min(56vh, 460px);
    border-radius: 10px;
    overscroll-behavior: contain;
  }

  .requirement-editor-title {
    min-height: 42px;
    display: flex;
    align-items: center;
    padding: 10px 12px;
    font-size: 0.85rem;
  }

  .requirement-row {
    grid-template-columns: 52px repeat(4, minmax(42px, 1fr));
    gap: 5px;
    min-width: 0;
    padding: 8px 6px;
  }

  .requirement-row-head {
    top: 42px;
    min-height: 34px;
    font-size: 0.72rem;
  }

  .requirement-day {
    font-size: 0.95rem;
  }

  .requirement-row input {
    height: 44px;
    border-radius: 8px;
    font-size: 1rem;
    touch-action: manipulation;
  }

  .brand-text {
    font-size: 1.15rem;
  }

  .tool-modes {
    display: grid;
    gap: 4px;
  }

  .brush-options,
  .checkbox-grid,
  .form-row,
  .shift-selection-grid {
    grid-template-columns: 1fr;
  }

  .page-title {
    font-size: 1.35rem;
  }

  .dashboard-stats {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stat-card {
    padding: 16px;
    border-radius: 12px;
  }

  .grid-controls,
  .panel-header,
  .modal-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .grid-helper {
    align-items: flex-start;
  }

  .header-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .header-actions .action-btn,
  .modal-footer .action-btn,
  .footer-right,
  .footer-right .action-btn {
    width: 100%;
  }

  .header-actions .action-btn {
    min-height: 44px;
    padding: 9px 8px;
    justify-content: center;
  }

  .header-actions #btn-auto-generate {
    grid-column: span 2;
  }

  .footer-right {
    flex-direction: column;
  }

  .grid-card,
  .alerts-panel {
    margin-inline: -8px;
    padding: 14px;
  }

  .shift-grid-table {
    min-width: 760px;
    font-size: 0.8rem;
  }

  .shift-grid-table th,
  .shift-grid-table td {
    width: 36px;
    min-width: 36px;
    height: 42px;
    padding: 6px 4px;
  }

  .shift-grid-table th:first-child,
  .shift-grid-table td:first-child {
    width: 128px;
    min-width: 128px;
    padding-left: 10px;
  }

  .shift-chip {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    font-size: 0.82rem;
  }

  .alert-item {
    flex-wrap: wrap;
  }

  .alert-item-action {
    width: 100%;
  }

  .modal-overlay {
    align-items: flex-end;
    padding: 12px;
  }

  .modal-card,
  .modal-small {
    width: 100%;
    max-width: 100%;
    max-height: calc(100vh - 24px);
    border-radius: 14px;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 16px;
  }

  .requested-dates-input {
    flex-direction: column;
  }
}

/* 12. 印刷メディアクエリ */
@media print {
  body {
    overflow: visible;
    background: #fff;
    color: #000;
  }
  .app-sidebar,
  .app-header .header-actions,
  .month-selector button,
  .grid-controls,
  .alerts-panel,
  .modal-overlay {
    display: none !important;
  }
  .app-container {
    display: block;
    height: auto;
  }
  .app-main {
    padding: 0;
    margin: 0;
    display: block;
  }
  .page-title {
    font-size: 20pt;
    text-align: center;
    margin-bottom: 20px;
  }
  .dashboard-stats {
    grid-template-columns: repeat(4, 1fr);
    margin-bottom: 20px;
  }
  .stat-card {
    border: 1px solid #ccc;
    box-shadow: none !important;
    transform: none !important;
  }
  .grid-card {
    border: none;
    padding: 0;
    box-shadow: none !important;
  }
  .grid-scroll-container {
    overflow: visible;
    border: none;
  }
  .shift-grid-table {
    min-width: 100%;
    page-break-inside: avoid;
  }
  .shift-grid-table th,
  .shift-grid-table td {
    border: 1px solid #555;
    padding: 4px 2px;
    height: auto;
    font-size: 8pt;
  }
  .shift-grid-table th:first-child,
  .shift-grid-table td:first-child {
    position: static;
    width: 120px;
    min-width: 120px;
    box-shadow: none;
    background: transparent !important;
  }
  .shift-chip {
    border: none !important;
    background: transparent !important;
    color: #000 !important;
    font-size: 9pt;
    width: auto;
    height: auto;
  }
}
