/* TanLabOS - 科学・事業管理のモダンデザイン */
:root {
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --fg: #0f172a;
  --fg-muted: #64748b;
  --primary: #0891b2;
  --primary-hover: #0e7490;
  --primary-soft: #ccfbf1;
  --accent: #06b6d4;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #059669;
  --success-soft: #ecfdf5;
  --border: #e2e8f0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(15,23,42,0.06);
  --shadow-md: 0 4px 14px rgba(15,23,42,0.08);
  --shadow-hover: 0 8px 25px rgba(8,145,178,0.12);
  --header-bg: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  --header-fg: #f8fafc;
}

* { box-sizing: border-box; }

html {
  height: 100%;
  min-height: 100%;
  font-size: 16px;
  /* スマホで縦方向の高さを確実に取る */
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  min-height: 100vh;
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%) fixed;
  color: var(--fg);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
}

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

/* ===== ヘッダー ===== */
.header {
  flex-shrink: 0;
  background: var(--header-bg);
  color: var(--header-fg);
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  position: relative;
}
.header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.6;
}
.header a { color: var(--header-fg); }
.header a:hover { color: #67e8f9; text-decoration: none; }
.header { flex-wrap: wrap; gap: 0.5rem; }
.nav-main { display: flex; flex-wrap: nowrap; align-items: center; }
.nav-main a, .nav-main .nav-dropdown { margin-left: 0; margin-right: 0.5rem; }

/* Growth Engine ナビボタン */
.nav-growth-btn {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  background: linear-gradient(135deg, #0ea5e9 0%, #6366f1 100%);
  color: #fff !important;
  border-radius: 999px;
  border: none;
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: opacity 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 4px rgba(99,102,241,0.3);
  margin-right: 0.7rem;
}
.nav-growth-btn:hover { opacity: 0.88; box-shadow: 0 2px 8px rgba(99,102,241,0.4); color: #fff !important; }
.nav-growth-btn.is-active { background: linear-gradient(135deg, #0284c7 0%, #4f46e5 100%); box-shadow: 0 2px 8px rgba(99,102,241,0.5); }
.nav-categories a { margin-left: 0; margin-right: 0.75rem; }
.header nav a {
  font-weight: 500;
  font-size: 0.8125rem;
}
.nav-categories { display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; }
.nav-cat-link { font-size: 0.8125rem; }

/* 作業リンク ドロップダウン（ホバーで表示） */
.nav-dropdown {
  position: relative;
  display: inline-block;
}
.nav-dropdown-trigger {
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--header-fg);
  padding: 0.25rem 0;
}
.nav-dropdown-trigger:hover { color: #67e8f9; }
.nav-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin: 0;
  padding: 0.5rem 0;
  list-style: none;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  min-width: 12rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  z-index: 100;
}
.nav-dropdown:hover .nav-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(4px);
}
.nav-dropdown-menu a {
  display: block;
  padding: 0.4rem 1rem;
  color: var(--fg);
  font-size: 0.875rem;
}
.nav-dropdown-menu a:hover {
  background: var(--primary-soft);
  color: var(--primary-hover);
}
.nav-cat-stats { font-size: 0.75rem; opacity: 0.85; }

/* ヘッダー1行目（ロゴ＋ハンバーガー）。PCでは display: contents でレイアウトに参加させない */
.header-row { display: contents; }

/* ハンバーガーボタン（PCでは非表示） */
.header-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--header-fg);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.header-hamburger:hover { color: #67e8f9; }
.hamburger-line {
  display: block;
  width: 22px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.header.is-nav-open .hamburger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.header.is-nav-open .hamburger-line:nth-child(2) {
  opacity: 0;
}
.header.is-nav-open .hamburger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.project-list-mini { list-style: none; padding: 0; margin: 0; font-size: 0.875rem; }
.project-list-mini li { padding: 0.25rem 0; border-bottom: 1px solid var(--border); }
.project-list-mini li:last-child { border-bottom: none; }
.project-list-mini a { color: inherit; }
.category-stats-bar { display: flex; gap: 1.5rem; margin-bottom: 1rem; padding: 0.75rem; background: var(--bg-card); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.cat-stat { font-weight: 500; }
.cat-stat-overdue { color: var(--danger); }
.sns-calendar-section { margin-bottom: 1.5rem; }
.calendar-nav { margin-bottom: 0.5rem; }
.calendar-nav a { margin-right: 1rem; }
.sns-post-list { list-style: none; padding: 0; margin: 0; }
.sns-post-item { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.sns-post-item a { display: block; color: inherit; }
.sns-post-media { font-weight: 500; margin-right: 0.5rem; }
.sns-post-datetime { font-size: 0.875rem; color: var(--fg-muted); margin-right: 0.5rem; }
.sns-post-text { font-size: 0.875rem; color: var(--fg-muted); }
.staff-top-categories { margin-bottom: 1.5rem; }
.staff-top-calendar { margin-bottom: 1.5rem; }
.staff-list .btn-edit { margin-left: 0.5rem; font-size: 0.75rem; }
.logo {
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  padding-left: 0.5rem;
  border-left: 3px solid var(--accent);
  position: relative;
  z-index: 1;
}

/* ===== メイン・フッター ===== */
.main {
  flex: 1;
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.flash-messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.flash { padding: 0.5rem 0.75rem; border-radius: var(--radius-sm); margin-bottom: 0.25rem; }
.flash-error { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); }
.flash-success { background: var(--success-soft); color: var(--success); }
.footer {
  flex-shrink: 0;
  padding: 0.75rem 1.5rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--fg-muted);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
}

/* ===== タイポグラフィ ===== */
h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  color: var(--fg);
  letter-spacing: -0.02em;
}
h2 {
  font-size: 1.0625rem;
  font-weight: 600;
  margin: 1.25rem 0 0.75rem;
  color: var(--fg);
}
h3 { font-size: 1rem; font-weight: 600; margin: 0.75rem 0 0.5rem; }
.lead { color: var(--fg-muted); margin-bottom: 1.5rem; font-size: 0.9375rem; }

/* ===== スクロール可能エリア（量が多いコンテンツ用） ===== */
.scroll-area {
  max-height: min(calc(100vh - 220px), 600px);
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  padding: 0.5rem;
}
.project-list.scroll-area { padding: 0.75rem; }
.scroll-area::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-area::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 4px; }
.scroll-area::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.scroll-area::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===== カテゴリグリッド ===== */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
}
.category-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  font-weight: 500;
  transition: all 0.2s ease;
  box-shadow: var(--shadow);
}
.category-card {
  border-left: 3px solid transparent;
}
.category-card:hover {
  border-color: var(--primary);
  border-left-color: var(--primary);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}
.category-label { font-weight: 600; font-size: 0.9375rem; }
.category-stats { font-size: 0.75rem; color: var(--fg-muted); line-height: 1.4; }

/* ===== スタッフ ===== */
.staff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}
.staff-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.2s ease;
  box-shadow: var(--shadow);
}
.staff-card {
  border-left: 3px solid transparent;
}
.staff-card:hover {
  border-left-color: var(--primary);
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}
.staff-name { font-weight: 600; font-size: 0.9375rem; }
.staff-stats { font-size: 0.75rem; color: var(--fg-muted); }

/* ===== ボタン ===== */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: all 0.2s ease;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(8,145,178,0.3);
}
.btn-primary:hover {
  box-shadow: 0 4px 12px rgba(8,145,178,0.4);
  transform: translateY(-1px);
}
.btn-small {
  padding: 0.3rem 0.6rem;
  font-size: 0.8125rem;
}
.btn-tiny {
  padding: 0.15rem 0.35rem;
  font-size: 0.7rem;
  line-height: 1.2;
}

/* SNSカレンダー: 投稿状態ボタン（2x2・全セル均一サイズ） */
.sns-status-segmented {
  display: inline-flex;
  border-radius: 6px;
  overflow: hidden;
  font-size: 0.7rem;
  border: 1px solid #9ca3af;
}
.sns-status-segmented.sns-status-grid-2x2 {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  width: 10.5rem;
  height: 3.5rem;
  gap: 0;
}
.sns-status-segmented-form {
  display: flex;
  margin: 0;
  min-height: 0;
}
.sns-status-segmented.sns-status-grid-2x2 .sns-status-segmented-form {
  display: flex;
  height: 100%;
}
.sns-status-segmented .sns-status-btn {
  margin: 0;
  padding: 0.2rem 0.25rem;
  border: none;
  border-right: 1px solid #9ca3af;
  border-bottom: 1px solid #9ca3af;
  cursor: pointer;
  font-size: inherit;
  line-height: 1.2;
  transition: background 0.12s, color 0.12s;
  box-sizing: border-box;
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sns-status-grid-2x2 .sns-status-segmented-form:nth-child(2n) .sns-status-btn { border-right: none; }
.sns-status-grid-2x2 .sns-status-segmented-form:nth-child(n+3) .sns-status-btn { border-bottom: none; }

/* 共通: 未選択は白地＋グレー文字、選択時のみ塗り */
.sns-status-segmented .sns-status-btn {
  background: #fff;
  color: #374151;
}
.sns-status-segmented .sns-status-btn:hover:not(.is-active) {
  background: #f3f4f6;
  color: #111827;
}
.sns-status-segmented .sns-status-btn.is-active {
  color: #fff;
  font-weight: 600;
}
/* 投稿未完成: 選択時＝グレー */
.sns-status-segmented .sns-status-btn.sns-status-incomplete.is-active {
  background: #4b5563;
}
.sns-status-segmented .sns-status-btn.sns-status-incomplete.is-active:hover {
  background: #374151;
  color: #fff;
}
/* 未予約: 選択時＝青 */
.sns-status-segmented .sns-status-btn.sns-status-draft.is-active {
  background: #2563eb;
}
.sns-status-segmented .sns-status-btn.sns-status-draft.is-active:hover {
  background: #1d4ed8;
  color: #fff;
}
/* 予約済み: 選択時＝オレンジ */
.sns-status-segmented .sns-status-btn.sns-status-scheduled.is-active {
  background: #ea580c;
}
.sns-status-segmented .sns-status-btn.sns-status-scheduled.is-active:hover {
  background: #c2410c;
  color: #fff;
}
/* 投稿済み: 選択時＝緑 */
.sns-status-segmented .sns-status-btn.sns-status-posted.is-active {
  background: #059669;
}
.sns-status-segmented .sns-status-btn.sns-status-posted.is-active:hover {
  background: #047857;
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
}
.btn-danger:hover {
  background: #b91c1c;
  color: #fff;
}
.btn-disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== プロジェクト一覧 ===== */
.project-list { list-style: none; padding: 0; margin: 0; }
.project-item {
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}
.project-item:hover {
  box-shadow: var(--shadow-md);
  border-left-color: var(--primary-hover);
}
.project-item a { color: inherit; }
.project-item .meta {
  display: block;
  font-size: 0.8125rem;
  color: var(--fg-muted);
  margin-top: 0.25rem;
}
.project-item.project-block {
  flex-direction: column;
  align-items: stretch;
}
.project-item .project-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.project-item .project-header a { flex: 1; min-width: 0; }
.project-list-simple .project-item-simple {
  display: block;
  padding: 0.75rem 1rem;
}
.project-list-simple .project-item-simple .project-link {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  color: inherit;
}
.project-list-simple .project-item-simple .project-link:hover { text-decoration: none; }
.project-list-simple .project-item-simple .meta { font-size: 0.875rem; color: var(--fg-muted); }
.panel-scroll-alert { flex: 1; min-height: 120px; }
.dashboard-col-right .projects-panel { flex: 1; min-height: 0; }
.project-item .task-list { margin-top: 0.75rem; margin-left: 0; }
.project-item .task-list.compact .task-item { padding: 0.5rem 0.75rem; }

/* ===== タスク ===== */
.task-list { list-style: none; padding: 0; margin: 0; }
.task-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  font-size: 0.9375rem;
}
.task-item .task-name { flex: 1; min-width: 0; font-weight: 500; }
.task-item .task-name-link { color: inherit; text-decoration: none; }
.task-item .task-name-link:hover { text-decoration: underline; }
.task-item .task-due,
.task-item .task-estimate,
.task-item .task-project,
.task-item .task-status {
  font-size: 0.8125rem;
  color: var(--fg-muted);
}
.task-overdue {
  border-color: #fecaca;
  background: var(--danger-soft);
}
.task-overdue .task-due { color: var(--danger); font-weight: 600; }
.task-escalated {
  border-color: var(--danger);
  background: var(--danger-soft);
  box-shadow: 0 0 0 2px rgba(239,68,68,0.2);
}
/* 状態別色分け: 未処理・作業中・完了 */
.task-todo {
  border-left: 4px solid var(--fg-muted);
  background: var(--bg-card);
}
.task-in_progress {
  border-left: 4px solid var(--primary);
  background: var(--primary-soft);
}
.task-done {
  opacity: 0.85;
  border-left: 4px solid var(--success);
  background: var(--success-soft);
}
/* 一覧テーブル行の状態色（all_tasks 等） */
.task-row.task-status-todo { border-left: 4px solid var(--fg-muted); }
.task-row.task-status-in_progress { border-left: 4px solid var(--primary); background: var(--primary-soft); }
.task-row.task-status-done { border-left: 4px solid var(--success); background: var(--success-soft); opacity: 0.9; }
.btn-in-progress { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-in-progress:hover { background: var(--primary-hover); color: #fff; }
.task-header { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 0.25rem; }
.task-sop {
  font-size: 0.875rem;
  color: var(--fg-muted);
  margin: 0.5rem 0;
  padding-left: 0.75rem;
  border-left: 3px solid var(--border);
  white-space: pre-wrap; /* 改行をそのまま表示 */
}
.sop-content-view {
  white-space: pre-wrap;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.sop-content-view a { color: var(--primary); text-decoration: underline; }
.task-owner { font-size: 0.75rem; color: var(--fg-muted); }
.inline { display: inline; margin-left: 0.5rem; }

/* バッジ */
.badge {
  font-size: 0.6875rem;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  font-weight: 500;
}
.badge-mine { background: var(--primary-soft); color: var(--primary-hover); }
.badge-lock { background: #fef3c7; color: #92400e; }
.badge-escalated { background: var(--danger); color: #fff; }
.badge-general { background: #f1f5f9; color: #475569; }
.badge-improvement { background: #cffafe; color: #0e7490; }
.badge-admin { background: #fef3c7; color: #92400e; }
.badge-brand { background: #e0e7ff; color: #3730a3; font-size: 0.7rem; }

/* ===== ダッシュボード ===== */
.dashboard-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  flex: 1;
  min-width: 110px;
  padding: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
}
.stat-value { display: block; font-size: 1.5rem; font-weight: 700; color: var(--fg); }
.stat-label { font-size: 0.8125rem; color: var(--fg-muted); margin-top: 0.25rem; }
.stat-alert .stat-value { color: var(--danger); }
.dashboard-section { margin-bottom: 1.5rem; }
.project-block {
  margin-bottom: 1.25rem;
  padding: 1.25rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.project-block h3 { margin-top: 0; font-size: 1rem; }
.task-list.compact .task-item { padding: 0.5rem 0.75rem; }
.reminder-list, .variance-list { list-style: none; padding: 0; }
.reminder-item, .variance-item {
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.35rem;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
}
.variance-item.over { background: var(--danger-soft); color: #991b1b; }
.variance-item.under { background: var(--success-soft); color: #166534; }
.task-section.overdue h2 { color: var(--danger); }

/* ===== ToDo一覧 一括編集 ===== */
.bulk-edit-form { display: block; }
.bulk-edit-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.bulk-edit-bar .bulk-edit-label { font-weight: 600; margin-right: 0.25rem; }
.bulk-edit-bar label { display: inline-flex; align-items: center; gap: 0.35rem; }
.bulk-edit-bar select { min-width: 8rem; }
.task-table .col-check { width: 2.5rem; text-align: center; vertical-align: middle; }

/* ===== カレンダー ===== */
.calendar-section { margin-top: 1.5rem; }
.calendar-grid {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.calendar-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: #f8fafc;
  font-weight: 600;
  font-size: 0.8125rem;
}
.cal-dow {
  padding: 0.6rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  color: var(--fg-muted);
}
.cal-dow:not(:last-child) { border-right: 1px solid var(--border); }
.calendar-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  min-height: 88px;
}
.calendar-day {
  padding: 0.4rem;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  font-size: 0.875rem;
  overflow: hidden;
}
.calendar-day:nth-child(7n) { border-right: none; }
.calendar-day.empty { background: #f8fafc; }
.calendar-day.today { background: var(--primary-soft); }
.cal-date { font-weight: 600; color: var(--fg); }
.calendar-day.today .cal-date { color: var(--primary); font-weight: 700; }
.cal-events { list-style: none; padding: 0; margin: 0.3rem 0 0; }
.cal-event {
  font-size: 0.75rem;
  padding: 0.2rem 0.35rem;
  margin-bottom: 0.2rem;
  background: #e2e8f0;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.calendar-day.today .cal-event { background: var(--primary-soft); }
.cal-event-link a { color: inherit; text-decoration: none; }
.cal-event-link a:hover { text-decoration: underline; }

/* ===== イベント詳細 ===== */
.event-detail-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1.25rem;
  font-size: 0.9375rem;
}
.event-detail-dl dt { font-weight: 500; color: var(--fg-muted); }
.event-detail-dl dd { margin: 0; }
.event-detail-sub { font-size: 0.9375rem; margin: 1rem 0 0.5rem; color: var(--fg-muted); }
.event-calendar-notes { line-height: 1.65; font-size: 0.9375rem; }
.event-calendar-notes.scroll-area { max-height: 280px; padding: 0.75rem 1rem; }
.project-meta {
  display: flex;
  gap: 1.25rem;
  font-size: 0.875rem;
  color: var(--fg-muted);
  margin-bottom: 1rem;
}
.event-detail-section, .requirements-section, .tasks-section {
  background: var(--bg-card);
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* ===== フォーム ===== */
.form-block .form-group { margin-bottom: 1rem; }
.form-block .form-group label code {
  font-size: 0.85em;
  padding: 0.1em 0.35em;
  background: var(--bg-muted, #eee);
  border-radius: 3px;
  font-weight: normal;
}
.form-block label, .form-block .block-label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 500;
  font-size: 0.9375rem;
}
.form-block input, .form-block select, .form-block textarea {
  width: 100%;
  max-width: 420px;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
}
.form-inline { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.form-inline .form-group { margin-bottom: 0; }
.form-create .form-group { margin-bottom: 1.25rem; }
.form-create textarea { font-family: ui-monospace, monospace; resize: vertical; }
.template-multi-select {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin: 0.35rem 0;
}
.template-check-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: normal;
  cursor: pointer;
}
.sync-template-form .sync-template-label { margin-right: 0.5rem; }
.sync-template-form .sync-template-check {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-right: 0.75rem;
  font-weight: normal;
  cursor: pointer;
}
.manual-rows-container { margin-bottom: 0.5rem; }
.manual-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.35rem;
}
.manual-row .manual-name { width: 14rem; max-width: 100%; }
.manual-row .manual-sop { flex: 1; min-width: 10rem; max-width: 24rem; }
.import-section {
  margin-bottom: 1.5rem;
  padding: 1.25rem;
  background: var(--primary-soft);
  border-radius: var(--radius);
  border: 1px solid rgba(8,145,178,0.3);
  border-left: 4px solid var(--primary);
}
.alert { padding: 0.875rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: 0.9375rem; }
.alert-error { background: var(--danger-soft); color: #991b1b; border: 1px solid #fecaca; }

/* ===== テーブル ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}
.data-table th, .data-table td {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  text-align: left;
}
.data-table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--fg);
}
.data-table .col-sop { min-width: 18rem; }
.data-table .sop-input {
  width: 100%;
  min-width: 16rem;
  resize: vertical;
  font: inherit;
  padding: 0.4rem 0.5rem;
  box-sizing: border-box;
}
.shortage { color: var(--danger); font-weight: 600; }
.btn-edit { font-size: 0.75rem; margin-left: 0.5rem; }
.btn-sop { font-size: 0.75rem; margin-left: 0.5rem; }
.btn-block { width: 100%; }

/* ===== クイックリンク ===== */
.quick-links ul { list-style: none; padding: 0; margin: 0; }
.quick-links li { margin: 0.5rem 0; }
.quick-links a {
  display: inline-block;
  padding: 0.4rem 0;
  font-size: 0.9375rem;
}
.staff-section { margin-top: 0.5rem; }
.categories { margin-bottom: 1rem; }

/* ===== その他 ===== */
.generate-list { list-style: none; padding: 0; }
.generate-item {
  padding: 0.875rem;
  margin-bottom: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.generate-item label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.generate-item .meta { font-size: 0.8125rem; color: var(--fg-muted); }
.back-link { margin-bottom: 1rem; }
.page-header { margin-bottom: 1rem; }
.page-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  margin-top: 0.5rem;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  margin-top: 1rem;
}
.empty-message { color: var(--fg-muted); font-size: 0.9375rem; }
.today-section { margin-bottom: 1.5rem; }
.today-section h2 { font-size: 1rem; margin-bottom: 0.5rem; }

/* ===== 在庫管理 ===== */
.inventory-actions { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
/* ===== イベント準備物（inventory） ===== */
.event-prep-project-current {
  background: #e8f4fc !important;
  border-left: 4px solid var(--primary, #2563eb);
}
.event-prep-bar-link {
  text-decoration: none;
  color: inherit;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.event-prep-bar-triangle {
  display: inline-block;
  font-size: 0.75em;
  transition: transform 0.2s ease;
}
.event-prep-entry { margin-bottom: 1.5rem; }
.event-prep-under-project { margin-bottom: 1.5rem; }
.event-prep-project-info {
  margin: 1rem 0;
  padding: 0.75rem;
  background: #f5f5f5;
  border-radius: 4px;
}
.event-prep-section,
.purchase-section,
.manufacture-section,
.product-list {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.form-block .estimate-options { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.form-block .estimate-options input[type="number"] { width: 90px; }

/* ===== スタッフ今日ページ ===== */
.staff-today-page .task-card {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow);
}
.staff-today-page .task-card-body { flex: 1; min-width: 0; }
.staff-today-page .task-card .task-project { font-size: 0.8125rem; color: var(--fg-muted); margin-top: 0.15rem; }
.staff-today-page .task-card-actions { flex-shrink: 0; }
.staff-today-page .task-card-actions form { margin: 0; }

/* ===== インポート ===== */
.import-category-block { margin-bottom: 1.5rem; }
.import-task-list { list-style: none; padding: 0; }
.import-task-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9375rem;
}
.import-task-item label { margin: 0; cursor: pointer; }
.import-task-existing { opacity: 0.7; }
.import-task-existing label { cursor: default; }
.badge-existing { font-size: 0.75rem; padding: 0.15rem 0.4rem; background: var(--fg-muted); color: #fff; border-radius: 4px; margin-left: 0.25rem; }
.todo-type-select { font-size: 0.875rem; }
.todo-type-select label { margin-right: 1rem; }

/* ===== ダッシュボード全画面レイアウト ===== */
body.dashboard-page .main {
  overflow: hidden;
  padding: 0.75rem;
  max-width: none;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
body.dashboard-page .main .dashboard-fullscreen {
  flex: 1;
  min-height: 0;
}
.dashboard-fullscreen {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.dashboard-fit {
  height: 100%;
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.dashboard-fit .dashboard-grid {
  flex: 1;
  min-height: 0;
}
.dashboard-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
  overflow: hidden;
}
.dashboard-col {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.dashboard-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease;
  flex: 1 1 auto;
}
.dashboard-fit .dashboard-panel {
  flex: 1 1 0;
  min-height: 0;
}
.dashboard-panel:hover {
  box-shadow: var(--shadow-md);
}
.dashboard-panel h2 {
  font-size: 0.875rem;
  font-weight: 600;
  margin: -0.5rem -0.75rem 0.35rem -0.75rem;
  padding: 0.4rem 0.75rem;
  flex-shrink: 0;
  background: #f8fafc;
  border-left: 4px solid #1e293b;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: var(--fg);
}
.panel-meta { font-size: 0.75rem; font-weight: 400; color: var(--fg-muted); }
.panel-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.panel-scroll::-webkit-scrollbar { width: 4px; }
.panel-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }
.daily-panel { flex: 0 0 auto; }
/* DAILY 各ブロックの開閉（三角） */
.daily-section-details { margin-bottom: 0.5rem; }
.daily-section-summary {
  list-style: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9375rem;
  padding: 0.25rem 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.daily-section-summary::-webkit-details-marker { display: none; }
.daily-section-summary::marker { content: none; }
.daily-section-triangle { display: inline-block; transition: transform 0.2s ease; }
.daily-section-details[open] .daily-section-triangle { transform: rotate(90deg); }
.daily-todo-list, .daily-done-list { list-style: none; padding: 0; margin: 0; font-size: 0.875rem; }
.daily-todo-item { padding: 0.25rem 0; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.daily-todo-item.done { color: var(--fg-muted); text-decoration: line-through; }
.daily-check { color: var(--success); font-weight: 700; }
.daily-uncheck { color: var(--primary); }
.daily-category-badge { font-size: 0.7rem; padding: 0.1rem 0.35rem; border-radius: 4px; background: var(--bg-muted); color: var(--fg-muted); white-space: nowrap; }
.daily-todo-name { flex: 1; min-width: 0; }
.daily-todo-actions { display: inline; }
.daily-todo-actions .inline { display: inline; margin-left: 0.25rem; }
.daily-todo-actions .btn-small { margin-left: 0.25rem; }
.daily-todo-item form.inline { display: inline; margin-left: auto; }
.daily-done-title { font-size: 0.8125rem; margin: 0.75rem 0 0.25rem; color: var(--fg-muted); }
.daily-done-list li { padding: 0.15rem 0; font-size: 0.8125rem; }
.stats-panel .dashboard-summary { margin-bottom: 0; gap: 0.5rem; }
.stats-panel .stat-card { padding: 0.6rem; min-width: 60px; }
.stats-panel .stat-value { font-size: 1.125rem; }
.schedule-stats-panel .dashboard-summary { margin-bottom: 0; gap: 0.5rem; margin-top: 0.75rem; }
.schedule-stats-panel .stat-card { padding: 0.6rem; min-width: 60px; }
.schedule-stats-panel .stat-value { font-size: 1.125rem; }
/* スケジュール・進捗: 枠いっぱいに表示 */
.schedule-stats-panel-inner {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.schedule-stats-panel-inner .schedule-stats-grid { flex-shrink: 0; margin: 0 0 0.5rem 0; }
.schedule-stats-panel-inner .schedule-progress-row { flex: 1; min-height: 0; margin-top: 0.5rem; }
.schedule-stats-panel-inner .schedule-progress-row:first-child { margin-top: 0; }
.schedule-stats-panel-inner > p { flex-shrink: 0; margin: 0.5rem 0 0; }
/* スケジュール・進捗: 進捗率・完了・遅延・必要時間を横並び（横書き）で表示 */
.schedule-progress-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1rem;
}
.schedule-progress-item {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  white-space: nowrap;
}
.schedule-progress-label {
  font-size: 0.75rem;
  color: var(--fg-muted);
}
.schedule-progress-value {
  font-size: 0.9375rem;
  font-weight: 600;
}
.schedule-progress-value .stat-link { color: inherit; text-decoration: none; }
.schedule-progress-value .stat-link:hover { color: var(--primary); text-decoration: underline; }
.schedule-progress-item.schedule-progress-alert .schedule-progress-value { color: var(--danger); }
.category-grid-compact { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 0.4rem; }
.category-grid-compact .category-card { padding: 0.5rem; }
.category-grid-compact .category-label { font-size: 0.8125rem; }
.category-grid-compact .category-stats { font-size: 0.6875rem; }
.quick-links-panel ul {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.8125rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem 0.5rem;
}
.quick-links-panel li { margin: 0; }
.calendar-grid-compact .calendar-week { min-height: 36px; }
.calendar-grid-compact .calendar-day { padding: 0.15rem; font-size: 0.7rem; }
.calendar-scroll-full {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.calendar-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
/* 管理者ダッシュボード: イベントカレンダーを遅延タスク枠と同じ高さまで拡大 */
.dashboard-col-center.dashboard-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.dashboard-col-center .dashboard-calendar-tabs {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.dashboard-col-center .calendar-tab-panels {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.dashboard-col-center .calendar-panel {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.dashboard-col-center .ai-proposals-panel {
  flex: 0 0 auto;
}
.calendar-panel .calendar-grid {
  min-height: auto;
}
.calendar-panel .calendar-week {
  min-height: 32px;
}
.calendar-panel .calendar-day {
  padding: 0.2rem;
  font-size: 0.75rem;
}
.calendar-panel .cal-event {
  font-size: 0.65rem;
  padding: 0.1rem 0.25rem;
}
.calendar-grid-compact .cal-event { font-size: 0.65rem; padding: 0.1rem 0.2rem; }
/* ToDo 日付別棒グラフ（枠が潰れないよう flex で縮めない） */
.todo-chart-panel {
  flex: 0 0 auto;
  min-height: 100px;
  margin-bottom: 0.75rem;
}
.todo-chart-title { font-size: 0.9375rem; margin: 0 0 0.5rem; color: var(--fg-muted); font-weight: 600; }
.todo-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  padding: 0.25rem 0;
  overflow-x: auto;
}
.todo-chart-bar-wrap {
  flex: 1;
  min-width: 14px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 20px;
}
.todo-chart-bar-area {
  width: 100%;
  height: 64px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
}
.todo-chart-bar {
  width: 100%;
  border-radius: 2px 2px 0 0;
  background: var(--primary);
  opacity: 0.85;
  transition: opacity 0.15s;
}
.todo-chart-bar-wrap:hover .todo-chart-bar { opacity: 1; }
.todo-chart-bar-today { background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.todo-chart-bar-overdue { background: var(--danger); opacity: 0.9; }
.todo-chart-value {
  font-size: 0.6rem;
  font-weight: 600;
  color: #000;
  line-height: 1;
  flex-shrink: 0;
  margin-bottom: 2px;
  white-space: nowrap;
  height: 1em;
  display: flex;
  align-items: center;
  justify-content: center;
}
.todo-chart-label {
  font-size: 0.6rem;
  color: var(--fg-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.delay-chart-panel { margin-top: 1rem; }
.delay-chart-title { font-size: 0.9375rem; margin: 0 0 0.5rem; color: var(--fg-muted); font-weight: 600; }
.delay-chart-wrap { width: 100%; max-width: 60px; }
.delay-chart-period a { color: var(--primary); text-decoration: none; }
.delay-chart-period a:hover { text-decoration: underline; }
.delay-chart-period a.is-active { font-weight: 600; color: var(--fg); }
/* カイゼンメモ */
.improvement-memo-form { margin-bottom: 1.5rem; padding: 1rem; background: var(--bg-card); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.improvement-memo-form textarea { margin-bottom: 0.5rem; width: 100%; max-width: 36rem; }
.improvement-memo-list .memo-list { list-style: none; padding: 0; margin: 0; }
.improvement-memo-list .memo-item { padding: 0.75rem; margin-bottom: 0.5rem; background: var(--bg-card); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.improvement-memo-list .memo-body { margin-bottom: 0.35rem; white-space: pre-wrap; }
.improvement-memo-list .memo-meta { font-size: 0.8125rem; color: var(--fg-muted); display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.improvement-memo-list .memo-action-form,
.improvement-memo-list .memo-delete-form { margin-left: 0.25rem; }
.improvement-memo-list .memo-meta .memo-delete-form { margin-left: auto; }
/* 購入が必要な物品 */
.purchase-section { margin-bottom: 1.5rem; }
.purchase-add-form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin-bottom: 0.75rem; }
.purchase-add-form .purchase-select { min-width: 12rem; }
.purchase-add-form input[type="text"] { min-width: 10rem; }
.purchase-completed-details { margin-top: 0.75rem; font-size: 0.875rem; }
.purchase-completed-list { list-style: none; padding: 0; margin: 0.25rem 0 0; }
.purchase-completed-list li { padding: 0.2rem 0; color: var(--fg-muted); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #047857; color: #fff; }
.staff-grid-compact { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 0.4rem; }
.staff-grid-compact .staff-card-wrap { display: flex; flex-direction: column; gap: 0.2rem; }
.staff-grid-compact .staff-card { padding: 0.5rem; }
.staff-grid-compact .staff-name { font-size: 0.8125rem; }
.staff-grid-compact .staff-stats { font-size: 0.6875rem; }
/* ダッシュボード: スタッフ枠を同じ大きさに */
.staff-panel .staff-grid-compact {
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  align-items: stretch;
}
.staff-panel .staff-card-wrap {
  min-height: 4.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.staff-panel .staff-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.5rem 0.4rem;
}
.staff-panel .staff-calendar-link { text-align: center; }
.staff-calendar-link { font-size: 0.7rem; color: var(--fg-muted); text-decoration: none; }
.staff-calendar-link:hover { text-decoration: underline; color: var(--primary); }
.projects-panel .project-block { padding: 0.6rem; margin-bottom: 0.5rem; }
.projects-panel .project-block h3 { font-size: 0.875rem; }
.projects-panel .task-list.compact .task-item { padding: 0.35rem 0.5rem; font-size: 0.8125rem; }
.alert-panel .task-item { padding: 0.4rem 0.5rem; font-size: 0.8125rem; }
.dashboard-grid-staff {
  grid-template-columns: 1fr 1fr;
}
.task-item-compact {
  padding: 0.4rem 0.6rem;
  font-size: 0.8125rem;
}
.task-item-compact .task-header { margin-bottom: 0.15rem; }
.task-item-compact .task-name { font-size: 0.8125rem; }
.all-tasks-panel .panel-scroll { flex: 1; min-height: 0; }
/* ===== スマホ・タブレット縦: 縦つぶれ防止・全体スクロール ===== */
@media (max-width: 1023px) {
  html { min-height: 100vh; }
  body {
    display: block;
    min-height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .main {
    flex: none;
    min-height: 60vh;
    overflow-y: visible;
    padding: 1rem;
  }
  /* ヘッダー: タブの重なり防止（縦並び・折り返し） */
  .header {
    padding: 0.5rem 1rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  .header .logo {
    flex-shrink: 0;
  }
  .nav-main,
  .nav-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
    align-items: center;
  }
  .nav-main a,
  .nav-categories .nav-cat-link {
    margin-right: 0;
    white-space: nowrap;
  }
  .nav-cat-stats { white-space: nowrap; }
  .footer { padding: 0.5rem 1rem; }
  /* トップ(index)・ダッシュボード・スタッフトップ共通: main を潰さない */
  body.dashboard-page .main {
    overflow-y: visible;
    display: block;
    min-height: 60vh;
    padding: 1rem;
  }
  /* トップ(index)の page-layout-grid / index-top-grid: モバイルでは縦積み */
  .page-layout-grid,
  .index-top-grid {
    display: block;
  }
  .page-layout-grid + .page-layout-grid { margin-top: 1rem; }
  .index-top-grid .categories,
  .index-top-grid .quick-links,
  .index-top-grid .calendar-section,
  .index-top-grid .staff-section { margin-bottom: 1.25rem; }
  .index-top-grid .staff-section:last-child { margin-bottom: 0; }
  /* ダッシュボード: 1列縦積みにして枠の重なりを解消 */
  .dashboard-fullscreen,
  .dashboard-fit {
    height: auto;
    max-height: none;
    min-height: 0;
    overflow: visible;
  }
  .dashboard-fit .dashboard-grid,
  .dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    flex: none;
    min-height: 0;
    overflow: visible;
    gap: 1rem;
  }
  .dashboard-col {
    min-height: 0;
    overflow: visible;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }
  /* 詳細度で負けないよう .dashboard-fit .dashboard-panel も明示（PC用の flex: 1 1 0 を打ち消す） */
  .dashboard-fit .dashboard-panel,
  .dashboard-panel {
    flex: none;
    min-height: 0;
    overflow: visible;
    margin-bottom: 0;
  }
  .dashboard-col .dashboard-panel {
    margin-bottom: 0.5rem;
  }
  .dashboard-col .dashboard-panel:last-child {
    margin-bottom: 0;
  }
  .panel-scroll,
  .panel-scroll-alert,
  .calendar-scroll-full {
    flex: none;
    max-height: none;
    min-height: 0;
    overflow-y: visible;
  }
  .scroll-area {
    max-height: none;
  }
}

/* ===== スマホ: ヘッダーをハンバーガーメニューに ===== */
@media (max-width: 768px) {
  .header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }
  .header-hamburger {
    display: flex;
    flex-shrink: 0;
  }
  .header .logo {
    flex: 1 1 auto;
    min-width: 0;
  }
  .nav-main,
  .nav-categories {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    padding: 0.5rem 0 0;
    border-top: 1px solid rgba(255,255,255,0.2);
    margin-top: 0.25rem;
  }
  .header.is-nav-open .nav-main,
  .header.is-nav-open .nav-categories {
    display: flex;
  }
  .nav-main a,
  .nav-categories .nav-cat-link {
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }
  .nav-main a:last-child,
  .nav-categories .nav-cat-link:last-child {
    border-bottom: none;
  }
  .nav-dropdown .nav-dropdown-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    margin-top: 0.25rem;
    margin-bottom: 0.5rem;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(255,255,255,0.15);
  }
  .nav-dropdown .nav-dropdown-menu a {
    color: var(--header-fg);
  }
}

@media (min-width: 769px) {
  .header-hamburger { display: none !important; }
}

/* ===== スマホ（小画面）共通: タップ・表・フォーム ===== */
@media (max-width: 640px) {
  .main {
    padding: 0.75rem 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .header {
    padding: 0.5rem 0.75rem;
  }
  .header .logo { font-size: 1.15rem; }
  .nav-main a,
  .nav-categories .nav-cat-link {
    font-size: 0.8125rem;
    padding: 0.35rem 0;
  }
  h1 { font-size: 1.25rem; }
  h2 { font-size: 1rem; margin-top: 1rem; }
  /* 表: 横スクロール可能に（親でスクロール） */
  .data-table {
    font-size: 0.875rem;
    display: table;
    min-width: min(100%, 480px);
  }
  .data-table th,
  .data-table td { padding: 0.4rem 0.5rem; }
  /* フォーム: 幅を画面内に（インライン min-width も上書き） */
  .main input[type="text"],
  .main input[type="number"],
  .main input[type="url"],
  .main input[type="date"],
  .main input[type="time"],
  .main select,
  .main textarea {
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
  }
  .main select { width: auto; max-width: 100%; }
  .main .form-control,
  .main .purchase-select { min-width: 0; max-width: 100%; }
  .form-group { display: block; margin-bottom: 0.5rem; }
  .form-group label { display: block; margin-bottom: 0.2rem; }
  /* タップしやすいボタン */
  .btn {
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .btn-small { min-height: 36px; padding: 0.35rem 0.5rem; }
  /* 在庫・製造セクションの余白 */
  .event-prep-section,
  .purchase-section,
  .manufacture-section,
  .product-list {
    padding: 0.75rem 1rem;
    margin-top: 1rem;
  }
  /* カード・パネル類の余白 */
  .category-card,
  .dashboard-panel,
  .task-card {
    padding: 0.75rem 1rem;
  }
  .footer { padding: 0.5rem 0.75rem; font-size: 0.75rem; }
  /* タスク行を2列に：左＝タスク名、右＝○/カテゴリ/締切を縦並びで重ならないように、下段＝ボタン */
  .daily-todo-item {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto auto;
    gap: 0.2rem 0.75rem;
    align-items: start;
    padding: 0.5rem 0;
  }
  .daily-todo-name {
    grid-column: 1;
    grid-row: 1 / 4;
    min-width: 0;
    word-break: break-word;
  }
  .daily-uncheck {
    grid-column: 2;
    grid-row: 1;
    text-align: right;
  }
  .daily-category-badge {
    grid-column: 2;
    grid-row: 2;
    text-align: right;
    white-space: nowrap;
  }
  .daily-due {
    grid-column: 2;
    grid-row: 3;
    text-align: right;
    white-space: nowrap;
  }
  .daily-todo-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
  }
  .daily-todo-actions .inline { display: inline; margin-left: 0; }
  .daily-todo-actions .btn-small { margin-left: 0; }
  /* .task-item：タスク名が縦書きにならないよう最小幅を確保 */
  .task-item .task-name,
  .task-item .task-name-link {
    min-width: 50%;
    word-break: break-word;
  }
}

/* ===== PC全画面レイアウト ===== */
@media (min-width: 1024px) {
  .main { padding: 1.5rem 2rem; }
  .page-layout-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
  }
  .page-layout-grid.sidebar-right {
    grid-template-columns: 1fr 340px;
  }
  .page-layout-grid + .page-layout-grid { margin-top: 1.5rem; }
  /* トップ(index): 7枠（3+2+2）、スタッフはカレンダー下 */
  .index-top-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1rem 1.25rem;
    align-items: start;
  }
  .index-top-grid .categories { grid-column: 1 / 4; }
  .index-top-grid .quick-links { grid-column: 4 / 6; }
  .index-top-grid .calendar-section { grid-column: 6 / 8; }
  .index-top-grid .staff-section { grid-column: 1 / -1; }
  .scroll-area { max-height: min(calc(100vh - 240px), 680px); }
  /* プロジェクト詳細: イベント詳細は全幅、必要商品とToDoを横並び */
  .detail-layout-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
  }
  .detail-layout-grid .event-detail-section { grid-column: 1 / -1; }
}

/* ===== 投稿自動登録：コンテンツ編集プレビュー（2カラム・媒体タブ） ===== */
.phenomenon-form-layout {
  display: block;
}
.phenomenon-form-layout.has-preview {
  display: grid;
  grid-template-columns: 1fr 480px;
  gap: 1.5rem;
  align-items: start;
  grid-template-areas: "form preview";
}
.phenomenon-form-layout.has-preview .phenomenon-form-main {
  grid-area: form;
}
.phenomenon-form-layout.has-preview .phenomenon-preview-panel {
  grid-area: preview;
}
.phenomenon-form-main {
  min-width: 0;
}
/* フォーム内の説明文（small）が折り返されず横に伸びないようにする */
.phenomenon-form-main .form-block {
  max-width: 100%;
  overflow-wrap: break-word;
}
.phenomenon-form-main .form-block small {
  display: block;
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: normal;
}
.phenomenon-preview-panel {
  position: sticky;
  top: 1rem;
  padding: 1rem;
  background: var(--bg-card, #f8f9fa);
  border: 1px solid var(--border, #dee2e6);
  border-radius: var(--radius-sm, 6px);
  min-width: 0;
}
.phenomenon-preview-title {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  font-weight: 600;
}
.phenomenon-preview-panel .panel-meta {
  margin: 0 0 0.75rem 0;
  font-size: 0.85rem;
  color: var(--text-muted, #6c757d);
}
/* 媒体タブ（ラジオ＋ラベルでCSSのみ切り替え） */
.phenomenon-preview-tabs-wrapper {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border, #dee2e6);
}
.phenomenon-tab-radio {
  position: absolute;
  width: 0;
  height: 0;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}
.phenomenon-tab {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--radius-sm, 6px) var(--radius-sm, 6px) 0 0;
  cursor: pointer;
  color: var(--text-muted, #6c757d);
  margin-bottom: -1px;
}
.phenomenon-tab:hover {
  color: var(--text, #333);
  background: rgba(0,0,0,0.04);
}
.phenomenon-tab-radio:checked + .phenomenon-tab {
  background: var(--bg-card, #fff);
  color: var(--text, #333);
  border-color: var(--border, #dee2e6);
  border-bottom: 1px solid var(--bg-card, #fff);
}
.phenomenon-preview-tabs-wrapper .phenomenon-preview-panes {
  flex: 1 1 100%;
  min-height: 120px;
  margin-top: 0;
}
.phenomenon-preview-text {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text, #333);
  white-space: pre-wrap;
  word-break: break-word;
}
@media (max-width: 960px) {
  .phenomenon-form-layout.has-preview {
    grid-template-columns: 1fr;
    grid-template-areas: "form" "preview";
  }
  .phenomenon-preview-panel {
    position: static;
  }
}

/* ===== スケジュール管理 ===== */
.schedule-dashboard, .schedule-availability, .schedule-export, .schedule-import {
  max-width: 900px;
}
.schedule-calendar {
  max-width: 3200px;
  width: 100%;
}
.schedule-stats-grid {
  display: flex;
  gap: 1rem;
  margin: 1rem 0;
}
.schedule-stat-card {
  flex: 1;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  text-align: center;
}
.schedule-stat-card .schedule-stat-value { font-size: 1.5rem; font-weight: 700; display: block; }
.schedule-stat-card .schedule-stat-label { font-size: 0.875rem; color: var(--fg-muted); }
.schedule-stat-card.schedule-stat-alert { border-color: var(--danger); background: var(--danger-soft); }
.schedule-stat-card.schedule-stat-alert .schedule-stat-value { color: var(--danger); }
.schedule-dashboard-inline { margin: 1rem 0; }
.schedule-stat-inline { margin-right: 1rem; padding: 0.25rem 0.5rem; background: var(--bg-card); border-radius: var(--radius-sm); }
.schedule-stat-inline.schedule-stat-alert { background: var(--danger-soft); color: var(--danger); }
.schedule-stats-note { font-size: 0.75rem; color: var(--fg-muted); margin-top: 0.25rem; }
.availability-section { margin: 1.5rem 0; padding: 1rem; background: var(--bg-card); border-radius: var(--radius-sm); }
.availability-table { border-collapse: collapse; margin: 0.5rem 0; }
.availability-table th, .availability-table td { padding: 0.5rem; border: 1px solid var(--border); }
.availability-table-weekly { font-size: 0.8125rem; }
.availability-table-weekly input[type="time"] { max-width: 5rem; }
/* 週テンプレート カレンダー形式 */
.weekly-template-calendar-wrap { margin-bottom: 1rem; min-height: 120px; }
.wt-cal-title { font-size: 0.9375rem; margin: 0 0 0.35rem 0; font-weight: 600; }
.weekly-template-calendar { border-collapse: collapse; max-width: 480px; font-size: 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-card); }
.weekly-template-calendar th,
.weekly-template-calendar td { border: 1px solid var(--border); padding: 0.2rem 0.35rem; min-width: 2rem; }
.weekly-template-calendar .wt-cal-hour { width: 3rem; color: var(--fg-muted); text-align: right; }
.weekly-template-calendar .wt-cal-dow { font-weight: 600; text-align: center; }
.weekly-template-calendar .wt-cal-cell { min-width: 2rem; min-height: 1rem; }
.weekly-template-calendar .wt-cal-cell.wt-cal-available { background: var(--primary-soft); border-left: 2px solid var(--primary); }
.weekly-template-calendar .wt-cal-dot { display: inline-block; width: 6px; height: 6px; background: var(--primary); border-radius: 50%; }
.inline-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin: 0.5rem 0; }

.services-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem 1rem;
}
.services-span-2 { grid-column: 1 / -1; }
.services-inline-pair .services-pair-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.services-material-fields {
  margin-top: 0.5rem;
  display: grid;
  gap: 0.45rem;
}
@media (max-width: 900px) {
  .services-form-grid { grid-template-columns: 1fr; }
  .services-inline-pair .services-pair-fields { grid-template-columns: 1fr 1fr; }
}
.block-list { list-style: none; padding: 0; }
.block-list li { padding: 0.5rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.calendar-week-view { overflow-x: auto; margin: 1rem 0; width: 100%; }
.calendar-table { border-collapse: collapse; min-width: 2000px; width: 100%; --calendar-row-height: 72; }
.calendar-table th, .calendar-table td { border: 1px solid var(--border); padding: 0.25rem; font-size: 0.8125rem; }
.calendar-table tbody tr { height: calc(var(--calendar-row-height) * 1px); position: relative; overflow: visible; }
/* 0〜7時は約1/3の高さ、7〜24時は約2倍の高さで表示 */
.calendar-table tbody tr:nth-child(-n+7) { --calendar-row-height: 24; height: 24px; }
.calendar-table tbody tr:nth-child(n+8) { --calendar-row-height: 144; height: 144px; }
/* 行の z-index は使わず、ブロック種別でレイヤーを固定（レイヤー1=使える時間、2=シフト・予定、3=ToDo） */
.calendar-hour { width: 3rem; text-align: right; color: var(--fg-muted); }
.calendar-today { background: var(--primary-soft); }
.calendar-cell { min-width: 280px; vertical-align: top; position: relative; overflow: visible; }
.calendar-table-by-staff .calendar-cell { min-width: 200px; }
.calendar-staff-col { font-size: 0.75rem; font-weight: 600; padding: 0.25rem 0.35rem; }
.calendar-block-clickable { cursor: pointer; }
.calendar-block-clickable:hover { opacity: 0.9; filter: brightness(0.98); }
.calendar-modal { display: none; position: fixed; inset: 0; z-index: 1000; align-items: center; justify-content: center; }
.calendar-modal.is-open { display: flex; }
.calendar-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.4); }
.calendar-modal-content { position: relative; background: var(--bg-card); padding: 1.5rem; border-radius: var(--radius); box-shadow: var(--shadow-md); max-width: 90vw; max-height: 80vh; overflow: auto; }
.calendar-modal-close { position: absolute; top: 0.5rem; right: 0.5rem; font-size: 1.5rem; line-height: 1; background: none; border: none; cursor: pointer; color: var(--fg-muted); }
.calendar-modal-close:hover { color: var(--fg); }
.calendar-modal-title { margin: 0 0 0.5rem; font-size: 1rem; }
.calendar-modal-meta { margin: 0 0 1rem; font-size: 0.875rem; color: var(--fg-muted); }
.calendar-modal-actions { margin: 0; }
.calendar-modal-actions .inline { display: inline; margin-left: 0.25rem; }
.calendar-modal-has-iframe .calendar-modal-content { width: 95vw; max-width: 720px; height: 85vh; max-height: 720px; padding: 2.5rem 1.5rem 1.5rem; display: flex; flex-direction: column; }
.calendar-modal-has-iframe #calendar-block-modal-body { flex: 1; min-height: 0; }
.calendar-modal-iframe { width: 100%; height: 100%; min-height: 400px; border: 1px solid var(--border); border-radius: 4px; }
body.task-edit-embed { margin: 0; padding: 0; background: var(--bg-card); }
.task-edit-embed .form-block-wrap { max-width: 100%; }
.calendar-cell-available { background: rgba(34, 197, 94, 0.08); }
.calendar-task { padding: 0.25rem; margin: 0.125rem 0; border-radius: 4px; font-size: 0.75rem; border-left: 4px solid transparent; }
.calendar-task-due-overdue { background: #fef2f2; border-left-color: #dc2626; }
.calendar-task-due-overdue .calendar-task-due { color: #dc2626; }
.calendar-task-due-late { background: #fefce8; border-left-color: #ca8a04; }
.calendar-task-due-late .calendar-task-due { color: #b45309; }
.calendar-task-due-ok { background: #eff6ff; border-left-color: #2563eb; }
.calendar-task-due-ok .calendar-task-due { color: #1d4ed8; }
.calendar-task-in-progress { background: var(--accent); color: white; border-left-color: rgba(0,0,0,0.2); }
.calendar-task-in-progress .calendar-task-due { color: rgba(255,255,255,0.9); }
.calendar-task-time { display: block; font-size: 0.7rem; color: var(--fg-muted); }
.calendar-task-due { display: block; font-size: 0.65rem; margin-top: 0.1rem; }
.calendar-task-block { position: absolute; left: 2px; right: 2px; top: calc(var(--start-percent, 0) * 1%); height: calc(var(--duration-hours, 1) * var(--calendar-row-height, 72) * 1px); z-index: 3; min-height: 2.5em; box-sizing: border-box; overflow: visible; padding: 0.35rem; font-size: 0.75rem; border-radius: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem; }
/* 非管理者のカラム：タスクの左を開けて黄色いシフトブロックが覗く。ToDoはシフトより前面に表示 */
.calendar-task-over-shift { left: calc(2px + 1.2em); border-left: 2px solid var(--fg-muted); padding-left: 0.35rem; z-index: 4; }
/* 管理者のカレンダーで他スタッフ（原など）のタスクを表示するとき：左を開けて区別 */
.calendar-task-other-staff { left: calc(2px + 1.25em); right: 2px; border-left: 2px solid var(--fg-muted); padding-left: 0.4rem; }
.calendar-task-other-staff-label { font-size: 0.65rem; color: var(--fg-muted); margin-right: 0.25rem; flex-shrink: 0; }
.calendar-task-block-list { list-style: none; margin: 0; padding: 0; }
.calendar-task-block-item { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem; padding: 0.2rem 0; border-bottom: 1px solid rgba(0,0,0,0.08); font-size: 0.75rem; }
.calendar-task-block-item:last-child { border-bottom: none; }
.calendar-task-pin-form { position: absolute; top: 0.2rem; right: 0.2rem; z-index: 5; margin: 0; }
.calendar-task-pin-label { display: flex; cursor: pointer; margin: 0; }
.calendar-task-pin-label input[type="checkbox"] { cursor: pointer; width: 1em; height: 1em; }
.calendar-task-block .calendar-task-block-name { flex: 1 1 auto; min-width: 0; }
.calendar-task-block-name a { color: inherit; text-decoration: none; font-weight: 500; }
.calendar-task-block-name a:hover { text-decoration: underline; }
.calendar-task-block-time { font-size: 0.7rem; color: var(--fg-muted); flex-shrink: 0; }
.calendar-task-block-actions { display: inline-flex; gap: 0.2rem; flex-shrink: 0; }
.btn-calendar-task { font-size: 0.65rem; padding: 0.15rem 0.35rem; border: 1px solid var(--border); background: var(--bg-card); border-radius: 4px; cursor: pointer; }
.btn-calendar-task:hover:not(:disabled) { background: var(--primary-soft); border-color: var(--primary); }
.btn-calendar-task:disabled { opacity: 0.7; cursor: default; }
.calendar-imported { padding: 0.25rem; margin: 0.125rem 0; background: #e2e8f0; border-left: 3px solid var(--fg-muted); border-radius: 4px; font-size: 0.75rem; }
.calendar-imported-block { position: absolute; left: 2px; right: 2px; top: calc(var(--start-percent, 0) * 1%); height: calc(var(--duration-hours, 1) * var(--calendar-row-height, 72) * 1px); z-index: 2; min-height: 1.5em; box-sizing: border-box; overflow: hidden; }
/* 予定が重なるセルは2カラム表示 */
.calendar-task-block.calendar-block-cols-2[data-col="0"],
.calendar-imported-block.calendar-block-cols-2[data-col="0"] { left: 2px; right: auto; width: calc(50% - 3px); }
.calendar-task-block.calendar-block-cols-2[data-col="1"],
.calendar-imported-block.calendar-block-cols-2[data-col="1"] { left: calc(50% + 1px); right: 2px; width: calc(50% - 3px); }
.calendar-task-other-staff.calendar-block-cols-2[data-col="0"] { left: calc(2px + 1.25em); width: calc(50% - 3px - 1.25em); }
.calendar-task-other-staff.calendar-block-cols-2[data-col="1"] { left: calc(50% + 1px + 1.25em); width: calc(50% - 3px - 1.25em); }
.calendar-imported-event { background: #fed7aa; border-left-color: #ea580c; }
.calendar-imported-shift { background: #fef08a; border-left-color: #ca8a04; }
.calendar-imported-title { font-weight: 500; }
.calendar-all-day { margin-bottom: 1rem; }
.calendar-all-day-heading { font-size: 0.9rem; margin-bottom: 0.5rem; }
.calendar-all-day-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.5rem; }
.calendar-all-day-day { padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); }
.calendar-all-day-day.calendar-today { background: var(--primary-soft); }
.calendar-all-day-date { display: block; font-size: 0.75rem; color: var(--fg-muted); margin-bottom: 0.25rem; }
.calendar-all-day-list { list-style: none; margin: 0; padding: 0; font-size: 0.8rem; }
.calendar-all-day-item { padding: 0.15rem 0; border-bottom: 1px solid var(--border); }
.calendar-all-day-item:last-child { border-bottom: none; }
.badge-in-progress { font-size: 0.65rem; background: var(--danger); color: white; padding: 0.1rem 0.3rem; border-radius: 4px; }
.unscheduled-section { margin-top: 1.5rem; }
.export-table { border-collapse: collapse; margin: 1rem 0; }
.export-table th, .export-table td { padding: 0.5rem; border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }

/* ダッシュボード カレンダー（3パネル縦並び・タブなし） */
.dashboard-calendar-tabs { margin-bottom: 0.5rem; }
.calendar-tab-panels { display: flex; flex-direction: column; gap: 0.75rem; }
.calendar-tab-panel { display: block; }
/* SNS発信ページのタブ */
.sns-tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.sns-tab { padding: 0.5rem 1rem; color: var(--fg-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.sns-tab:hover { color: var(--fg); }
.sns-tab.is-active { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }
/* 売上ページ: メインタブの下にネストしたブランド・ECチャネル用タブ */
.revenue-main-tabs { flex-wrap: wrap; }
.revenue-subtabs,
.revenue-ec-ch-tabs { margin-top: 0.25rem; }
.revenue-brand-top-tabs { margin-bottom: 0.75rem; }
.revenue-inner-tabs { margin-bottom: 1rem; }
.revenue-ec-form-anchor { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.calendar-subtitle { font-size: 0.9375rem; margin: 0.75rem 0 0.5rem; color: var(--fg-muted); }
.imported-events-list { list-style: none; padding: 0; margin: 0; font-size: 0.875rem; }
.imported-event-item { padding: 0.35rem 0; border-bottom: 1px solid var(--border); display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; }
.imported-event-date { font-weight: 600; min-width: 3.5rem; }
.imported-event-time { color: var(--fg-muted); min-width: 6rem; }
.imported-event-title { flex: 1; }
.cal-event-time { font-size: 0.8em; color: var(--fg-muted); }

/* ===== 営業管理（顧客詳細タブ・コンパクト表示） ===== */
.sales-index-lead,
.sales-form-lead,
.sales-templates-lead {
  font-size: 0.9rem;
  color: var(--fg-muted);
  max-width: 52rem;
  line-height: 1.55;
  margin-bottom: 1rem;
}
.sales-detail-page { max-width: 1100px; margin: 0 auto; }
.sales-detail-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.sales-detail-title { margin: 0; font-size: 1.35rem; }
.sales-detail-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.sales-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0;
  padding: 0;
  border-bottom: 2px solid var(--border);
}
.sales-tab {
  appearance: none;
  border: none;
  background: transparent;
  font: inherit;
  cursor: pointer;
  padding: 0.55rem 0.9rem;
  color: var(--fg-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.sales-tab:hover { color: var(--fg); background: rgba(8, 145, 178, 0.06); }
.sales-tab.is-active {
  color: var(--primary);
  font-weight: 600;
  border-bottom-color: var(--primary);
}
.sales-tab-badge {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0.05rem 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--primary-soft);
  color: var(--primary-hover);
  border-radius: 6px;
  vertical-align: middle;
}
.sales-tab-panels {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem 1.25rem;
  min-height: 12rem;
}
.sales-tab-panel { display: none; }
.sales-tab-panel.is-active { display: block; }
.sales-subhead {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg-muted);
  margin: 0 0 0.65rem;
  text-transform: none;
  letter-spacing: 0;
}
.sales-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1.5rem;
  align-items: start;
}
@media (max-width: 800px) {
  .sales-detail-grid { grid-template-columns: 1fr; }
}
.sales-detail-span2 { grid-column: 1 / -1; }
.sales-inline-dates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
@media (max-width: 520px) {
  .sales-inline-dates { grid-template-columns: 1fr; }
}
.sales-inline-checks label { display: inline-block; margin-right: 1rem; }
.sales-form-footer { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.sales-panel-split {
  display: grid;
  grid-template-columns: 1fr minmax(240px, 320px);
  gap: 1rem 1.25rem;
  align-items: start;
}
@media (max-width: 900px) {
  .sales-panel-split { grid-template-columns: 1fr; }
}
.sales-todo-split { grid-template-columns: 1fr minmax(220px, 300px); }
.sales-panel-scroll { min-height: 0; }
.sales-table-wrap {
  max-height: min(52vh, 520px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 0.35rem;
}
.sales-orders-table { margin: 0; font-size: 0.875rem; }
.sales-orders-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f1f5f9;
  box-shadow: 0 1px 0 var(--border);
}
.sales-orders-table .sales-num { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.sales-orders-table .sales-desc { max-width: 12rem; word-break: break-word; }
.sales-order-add-card,
.sales-todo-add-card {
  background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
}
.sales-empty-hint { color: var(--fg-muted); font-size: 0.9rem; margin: 0.5rem 0; }
.sales-todo-list { margin-top: 0.35rem; }
.sales-done-line { margin-top: 0.75rem; font-size: 0.85rem; }
.sales-mail-panel { max-width: 40rem; }
.sales-mail-lead { font-size: 0.9rem; line-height: 1.55; margin-bottom: 0.75rem; }
.sales-mail-placeholders { font-size: 0.8rem; }
.sales-mail-picker { margin-top: 0.5rem; }
.sales-mail-select-label { display: block; font-weight: 500; margin-bottom: 0.35rem; font-size: 0.9rem; }
.sales-mail-select {
  width: 100%;
  max-width: 28rem;
  padding: 0.45rem 0.5rem;
  margin-bottom: 0.75rem;
}
.sales-mail-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
#sales-templates-json { display: none !important; }

/* スタッフ一覧：権限マトリクス */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.staff-perm-head { margin-top: 1.25rem; font-size: 1.125rem; }
.staff-perm-lead { max-width: 48rem; line-height: 1.55; }
.staff-perm-bulk-form { margin-bottom: 1rem; }
.staff-perm-matrix-wrap {
  overflow-x: auto;
  margin: 0.75rem 0 1rem;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.staff-perm-matrix {
  margin: 0;
  min-width: 720px;
  width: 100%;
}
.staff-perm-matrix th.staff-perm-col {
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.25;
  max-width: 4.5rem;
  vertical-align: bottom;
  hyphens: auto;
  word-break: break-word;
}
.staff-perm-matrix .staff-perm-sticky-col {
  min-width: 9rem;
  max-width: 12rem;
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
  box-shadow: 3px 0 6px rgba(15, 23, 42, 0.06);
}
.staff-perm-matrix thead .staff-perm-sticky-col {
  z-index: 3;
  background: #f8fafc;
}
.staff-perm-name-cell {
  vertical-align: top;
  font-size: 0.875rem;
}
.staff-perm-name-line { margin-bottom: 0.35rem; }
.staff-perm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  align-items: center;
}
.staff-perm-check-cell {
  text-align: center;
  vertical-align: middle;
  padding: 0.35rem;
}
.staff-perm-matrix-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.staff-perm-matrix-check input { margin: 0; width: 1.1rem; height: 1.1rem; }
.staff-perm-cell-muted {
  text-align: center;
  color: var(--fg-muted, #64748b);
  font-size: 0.875rem;
}
.staff-perm-row-admin .staff-perm-sticky-col {
  background: #fafafa;
}
.form-actions-row { margin: 0.5rem 0 0; }

/* 売上・入金：一覧＋サマリー左 / 登録フォーム右 */
.revenue-page-wrap { align-items: start; }
.revenue-col-main { min-width: 0; }
.revenue-sidebar {
  background: var(--bg-card, #fff);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
}
.revenue-sidebar-title { font-size: 1.05rem; margin: 0 0 0.35rem; }
.revenue-sidebar-lead { font-size: 0.8125rem; line-height: 1.5; margin-bottom: 1rem; }
.revenue-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem 1rem;
  margin: 0 0 1rem;
}
.revenue-legend { font-size: 0.875rem; font-weight: 600; padding: 0 0.35rem; }
.revenue-summary-embed {
  margin: 1rem 0 1.5rem;
  padding: 1rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.revenue-summary-embed h2 { font-size: 1.05rem; margin: 0 0 0.5rem; }
.revenue-subhead { font-size: 0.9375rem; margin: 1rem 0 0.5rem; }
.revenue-total-list { margin: 0 0 0.75rem; padding-left: 1.25rem; line-height: 1.6; }
.revenue-total-list-compact { font-size: 0.9rem; margin-bottom: 0; }
.revenue-brand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem;
  margin: 0.75rem 0 1.25rem;
}
.revenue-brand-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  background: #fff;
}
.revenue-brand-card-title { margin: 0 0 0.5rem; font-size: 0.95rem; }
.revenue-new-account-fields {
  margin: 0.5rem 0 0.75rem;
  padding: 0.65rem 0.75rem;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
}
.sales-dup-group { margin: 1.25rem 0; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.sales-dup-group:last-of-type { border-bottom: none; }
.sales-dup-list { margin: 0.35rem 0 0; padding-left: 1.25rem; line-height: 1.7; }
.inventory-lead-hint { max-width: 48rem; font-size: 0.875rem; line-height: 1.55; margin: 0.5rem 0 1rem; }
.stock-by-loc-lead { margin: 0.25rem 0 0.15rem; font-size: 0.875rem; }
.stock-by-loc-list { margin: 0 0 0.75rem; padding-left: 1.25rem; line-height: 1.5; font-size: 0.9rem; }
.stock-requirements { margin: 1.25rem 0; }
.stock-loc-form { max-width: 28rem; }
.revenue-summary-table { font-size: 0.875rem; }
.revenue-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0.5rem 0; }
.revenue-add-form .form-group { margin-bottom: 0.65rem; }
@media (min-width: 1024px) {
  .revenue-page-wrap .revenue-sidebar {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
  }
}
