/* ===========================================
   GANECCI Staff Manager - 共通スタイル
   =========================================== */

/* 2026-07-24 (Round T3-HC #20): sticky header (header.app-header top:0 z:50) 用の
   scroll-padding-top。アンカージャンプ (`#id` 遷移) が sticky header 裏に隠れる問題を回避。
   ヘッダー実測高さ ~56-64px 相当 + 余白 = 70px。 */
html { scroll-padding-top: 70px; }

/* 2026-07-24 (Round T3-HC #18): browser 既定選択色がテーマ (dark/light) と不整合な
   ため明示指定。text は既存 --text (dark #ecf0f9 / light #1a1f2e) を継承。 */
::selection { background: rgba(94, 158, 255, 0.35); color: var(--text, #ecf0f9); }
body.theme-light ::selection { background: rgba(37, 99, 235, 0.25); color: var(--text, #1a1f2e); }

/* 2026-07-24 (Round T3-HC #9): 123 箇所の placeholder が browser 既定灰 (#757575) で
   ダーク bg #0d1018 上に WCAG 1.4.3 未満コントラスト。--text-3 (#6c7596) に統一。 */
::placeholder { color: var(--text-3, #6c7596); opacity: 1; }
input::placeholder, textarea::placeholder { color: var(--text-3, #6c7596); }
body.theme-light ::placeholder { color: #5a6472; }

:root {
  /* 2026-07-23 (Round 15 CSS-Agent S2-HC #33): color-scheme 宣言でネイティブ scrollbar/
     form control をダーク色に。ライトモード時は body.theme-light が上書き。
     2026-07-23 (Round 15 CSS-Agent S2-HC #42): accent-color でチェックボックス/radio の
     OS ブルーを --accent (#5b8cff) に統一。 */
  color-scheme: light dark;
  accent-color: #5b8cff;
  /* デフォルト: ダーク (月モード) */
  --bg: #0d1018;
  --bg-2: #161a25;
  --bg-3: #1f2433;
  --line: #2a3045;
  /* 2026-07-23 (Round 14 CSS-Agent R1-HC #36): --border は --line への alias。
     32 箇所で var(--border) を使用しているが :root 未定義だったため、
     未定義変数扱いで無効 (初期値 currentColor) になっていた defensive alias。
     動作差分ゼロ: 元々 fallback 無しの var(--border) は無効化されていた border が、
     alias 定義後は --line (dark #2a3045 / light #d6dbe6) が確実に効くようになる。 */
  --border: var(--line);
  --text: #ecf0f9;
  --text-2: #98a2bd;
  --text-3: #6c7596;
  /* 2026-07-24 (Round T2-HC #40): --muted は公開チャット CSS のみで定義され、
     53-communication.js 等が var(--muted, #8b95a8) フォールバックに依存していた。
     admin/employee/mypage 文脈で明示定義し、フォールバック依存を解消。既存の視覚は
     フォールバック値と同一 (#8b95a8) を採用したため差分ゼロ。 */
  --muted: #8b95a8;
  --accent: #5b8cff;            /* GANECCI primary - ロイヤルブルー */
  --accent-2: #3d6ee0;
  --gold: #f0b73a;              /* GANECCI accent - ゴールド */
  --ok: #4ade80;
  --warn: #fbbf24;
  --ng: #f87171;
  --purple: #a78bfa;
  --pink: #f472b6;
  --teal: #2dd4bf;
  --shadow: 0 4px 28px rgba(0, 0, 0, .45);
  --radius: 10px;
  /* 2026-07-23 (Round 14 CSS-Agent R3-HC #17): z-index スケール将来統一のための変数定義。
     現状: .modal-bg{z-index:100} / .toast{z-index:1200} / .cc-overlay{z-index:10000} 混在。
     既存 rule は変更せず変数のみ追加 (visual diff ゼロ)。 */
  --z-modal-bg: 100;
  --z-toast: 1200;
  --z-overlay: 10000;
}

/* ===== ☀️ ライトモード (太陽モード) — 2026-05-21 礒貝CEO指示 ===== */
body.theme-light {
  /* 2026-07-24 (Round T1-HC #14): color-scheme / accent-color をライトモード時に上書き。
     元は :root 側 `light dark` (dark 優先) だったため、ライトモード適用時も native
     scrollbar/form control はダーク色のまま = 見た目と不整合。ここで上書きして
     ライトモード時は light、accent-color もライトの --accent (#2563eb) に。 */
  color-scheme: light;
  accent-color: #2563eb;
  --bg: #f5f7fa;
  --bg-2: #ffffff;
  --bg-3: #eef1f8;
  --line: #d6dbe6;
  --text: #1a1f2e;
  --text-2: #4b5269;
  --text-3: #7e859b;
  --muted: #8a92a5;              /* 2026-07-24 (Round T2-HC #40): ライトモード muted */
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --gold: #c98a14;
  --ok: #15803d;
  --warn: #ca8a04;
  --ng: #dc2626;
  --purple: #7c3aed;
  --pink: #db2777;
  --teal: #0d9488;
  --shadow: 0 4px 18px rgba(15, 23, 42, .12);
}
body.theme-light img, body.theme-light .logo img { filter: none; }
body.theme-light .badge { filter: contrast(1.05); }
body.theme-light input, body.theme-light textarea, body.theme-light select {
  background: #ffffff !important; color: #1a1f2e !important; border-color: #c5cad6 !important;
}
body.theme-light .modal { background: #ffffff !important; color: #1a1f2e !important; }
body.theme-light .modal-bg { background: rgba(15, 23, 42, .35) !important; }
body.theme-light header { background: #ffffff !important; border-color: var(--line) !important; }
body.theme-light .user-pill { background: var(--bg-3) !important; color: var(--text) !important; }
body.theme-light pre, body.theme-light code { background: #f0f3f9 !important; color: #1a1f2e !important; }

/* ☀️🌙 テーマ切替トグルボタン */
.theme-toggle {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  /* 2026-07-23 (Round 13-2 B-5): transition: all を明示リスト化 (ローエンド Android の jank 軽減) */
  transition: transform .15s, background .15s, border-color .15s, box-shadow .15s, color .15s, opacity .15s;
}
.theme-toggle:hover { background: var(--accent); color: #fff; transform: scale(1.05); }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  /* 2026-07-24 (Round T2-HC #30): 長スタッフ名/URL/英字テキストが table cell や
     narrow container で overflow するのを防ぐ。日本語 (CJK) は hyphens: auto の
     影響を受けないため既存日本語表示に差分無し。混在英字部分にのみ hyphenation。 */
  hyphens: auto;
  overflow-wrap: anywhere;
}

/* 2026-07-22 (Round 5): 動きに敏感なユーザーへの配慮 (WCAG 2.3.3) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  /* 2026-07-22 (Round 6): ローディング系はゆっくり維持 (完全停止すると「読み込み中」表示が壊れる) */
  .sm-spinner, .typing span {
    animation-duration: 1.6s !important;
    animation-iteration-count: infinite !important;
  }
  /* 2026-07-23 (Round 14 CSS-Agent R2-HC #31): .pulse-badge は注意喚起系 (loading 系ではない) なので
     prefers-reduced-motion 時に完全停止する。ローディング表示が壊れる懸念は無い。 */
  .pulse-badge {
    animation: none !important;
  }
}

/* 2026-05-28 礒貝CEO指示 [強化]: スマホ限定で横にグラグラ動かない & モーダルが下までスクロール可能 */
@media (max-width: 768px) {
  html, body {
    overflow-x: hidden !important;
    overscroll-behavior-x: none;
    width: 100%;
    max-width: 100vw;
    /* 2026-07-23 (Round 13-2 G-23): pinch-zoom 阻害を解消 (WCAG 1.4.4 準拠) */
    touch-action: pan-y pinch-zoom;
  }
  /* 全要素が画面幅を超えないように (横ブレ抑制) */
  body * {
    max-width: 100vw;
  }
  /* タイムテーブル等の横スクロール「するべき」要素は例外 */
  .table-wrap, #rooms-timetable, #emp-rooms-timetable, #rooms-month-cal,
  .table-wrap *, #rooms-timetable *, #emp-rooms-timetable *, #rooms-month-cal * {
    max-width: none;
    touch-action: pan-x pan-y;
  }
  /* ===== モーダルを「画面全体スクロール可能」に確定 ===== */
  .modal-bg.show {
    display: block !important;
    place-items: unset !important;
    align-items: unset !important;
    justify-content: unset !important;
    padding: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y !important;
    /* iOS Safari の URL バーで隠れないよう、画面外余白を確保 */
    min-height: 100vh;
    min-height: 100dvh;
  }
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    min-height: auto !important;
    max-height: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 16px !important;
    /* 下に大きな余白: 登録ボタンが iOS の Safari URL バー / ホームインジケーターに隠れないように */
    padding-bottom: calc(120px + env(safe-area-inset-bottom)) !important;
    overflow: visible !important;
    touch-action: pan-y !important;
    animation: none !important;
  }
}

a { color: var(--accent); text-decoration: none; }
/* 2026-07-24 (Round T2-HC #31): link 判別を色のみに依存させない (WCAG 1.4.1)。
   underline offset で本文と重ならず、thickness で細かく hover 変化を可視化。 */
a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 2px; }

/* ====== ヘッダー ====== */
header.app-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(15, 17, 23, .92);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
header .brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 15px; letter-spacing: .03em;
}
header .brand-logo {
  width: 28px; height: 28px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent) 0%, #2c4ba8 60%, var(--gold) 130%);
  display: grid; place-items: center; color: white; font-weight: 800; font-size: 13px;
  box-shadow: 0 0 0 1px rgba(240,183,58,.3), inset 0 1px 0 rgba(255,255,255,.15);
}
/* 会社名・ロゴはクリックで変更できる(2026-06-15)。押せることを薄く示し、誤操作しないよう控えめに。 */
header .brand[role="button"]:hover { opacity: .85; }
header .brand [data-brand-edit="logo"]:hover { filter: brightness(1.08); }
header .brand[role="button"]:focus-visible,
header .brand [data-brand-edit="logo"]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px;
}
header nav { display: flex; gap: 6px; }
header nav a {
  padding: 6px 12px; border-radius: 6px; color: var(--text-2); font-size: 13px;
}
header nav a.active { background: var(--bg-3); color: var(--text); }
header nav a:hover { background: var(--bg-3); text-decoration: none; }
header .user-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; background: var(--bg-3); border-radius: 20px; font-size: 13px;
  /* 2026-06-11 修正: スマホ幅 (360〜414px) で「ログアウト」「氏名」が 2 行に割れる崩れを防ぐ。
     ピル内は 1 行で表示し、入りきらない場合はピル自体を横スクロール可能にする。 */
  white-space: nowrap; flex-shrink: 0; max-width: 100%;
}
header .user-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex-shrink: 0; }
header .user-pill .avatar { flex-shrink: 0; }
header .user-pill #logout-btn { white-space: nowrap; flex-shrink: 0; }

/* ====== レイアウト ====== */
.container { max-width: 1400px; margin: 0 auto; padding: 24px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ====== カード ====== */
.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card h2, .card h3 {
  margin: 0 0 12px;
  font-size: 14px;
  letter-spacing: .04em;
  color: var(--text-2);
  text-transform: uppercase;
  font-weight: 600;
}
.card h2 { font-size: 15px; color: var(--text); text-transform: none; }

/* ====== KPI ====== */
.kpi {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.kpi .label { font-size: 11px; color: var(--text-3); letter-spacing: .08em; text-transform: uppercase; }
/* 2026-07-23 (Round 15 CSS-Agent S2-HC #40): tabular-nums で桁変化時の Layout Shift 抑止。 */
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: 11px; color: var(--text-2); margin-top: 2px; }
/* クリッカブル KPI(詳細モーダル誘導)*/
.kpi.clickable { cursor: pointer; transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease; user-select: none; }
.kpi.clickable:hover { border-color: var(--accent); transform: translateY(-1px); background: linear-gradient(135deg, var(--bg-2), rgba(91,140,255,0.05)); }
.kpi.clickable:active { transform: translateY(0); }

/* 本日休暇中メンバーカード(視覚的区別 = 業務中 8 / 休暇 2 が一目で分かる)*/
.member-card.on-leave { opacity: 0.62; border-color: var(--gold) !important; background: linear-gradient(135deg, rgba(240,183,58,0.06), rgba(91,140,255,0.02)) !important; position: relative; }
.member-card.on-leave .leave-banner { background: linear-gradient(135deg, var(--gold), #f5cc4a); color: #1a1410; padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 700; margin-bottom: 10px; text-align: center; line-height: 1.4; box-shadow: 0 2px 8px rgba(240,183,58,0.25); }
.member-card.on-leave .workload-bar { filter: grayscale(0.4); }

/* ===== 🚀 グローバル FAB(全ページ共通フローティング) ===== */
#global-fab-root { position: fixed; right: 20px; bottom: 20px; z-index: 9000; }
.fab-button { width: 56px; height: 56px; border-radius: 50%; border: none; background: linear-gradient(135deg, #5b8cff, #f0b73a); color: #fff; font-size: 28px; font-weight: 700; cursor: pointer; box-shadow: 0 6px 20px rgba(91,140,255,0.45), 0 2px 6px rgba(0,0,0,0.3); display: grid; place-items: center; transition: transform 0.18s ease, box-shadow 0.18s ease; line-height: 1; }
.fab-button:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 10px 28px rgba(240,183,58,0.45), 0 4px 10px rgba(0,0,0,0.3); }
.fab-button.open { transform: rotate(45deg); background: linear-gradient(135deg, #f0b73a, #5b8cff); }
.fab-button .fab-icon-plus { display: block; transition: transform 0.18s ease; }
.fab-menu { position: absolute; bottom: 72px; right: 0; width: 320px; max-height: 70vh; overflow-y: auto; background: var(--bg, #0d1018); border: 1px solid var(--line, #1f2333); border-radius: 14px; box-shadow: 0 16px 40px rgba(0,0,0,0.6); padding: 10px; opacity: 0; transform: translateY(10px) scale(0.96); transform-origin: bottom right; pointer-events: none; transition: opacity 0.18s ease, transform 0.18s ease; }
.fab-menu.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.fab-menu-header { padding: 8px 12px 10px; border-bottom: 1px solid var(--line, #1f2333); margin-bottom: 6px; }
.fab-menu-title { font-weight: 700; font-size: 13px; color: var(--text, #ecf0f9); }
.fab-menu-sub { font-size: 10px; color: var(--text-2, #98a2bd); margin-top: 2px; letter-spacing: 0.04em; }
.fab-menu-list { display: flex; flex-direction: column; gap: 2px; }
.fab-menu-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--text, #ecf0f9); transition: background 0.12s ease; }
.fab-menu-item:hover { background: linear-gradient(135deg, rgba(91,140,255,0.14), rgba(240,183,58,0.06)); }
.fab-menu-item .fab-emoji { font-size: 20px; flex-shrink: 0; width: 28px; text-align: center; }
.fab-menu-item .fab-text { flex: 1; min-width: 0; }
.fab-menu-item .fab-label { font-weight: 600; font-size: 13px; }
.fab-menu-item .fab-desc { font-size: 10px; color: var(--text-2, #98a2bd); margin-top: 1px; line-height: 1.3; }
@media (max-width: 600px) {
  #global-fab-root { right: 14px; bottom: 14px; }
  .fab-button { width: 52px; height: 52px; font-size: 26px; }
  .fab-menu { width: calc(100vw - 28px); max-width: 360px; right: -2px; }
}

/* 承認待ちパルスバッジ(自分が承認者の pending 件数)*/
.pulse-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: linear-gradient(135deg, var(--gold), #f5cc4a); color: #1a1410; font-weight: 700; font-size: 11px; margin-left: 6px; box-shadow: 0 0 0 0 rgba(240,183,58,0.7); animation: pulse-glow 1.6s infinite; }
.pulse-badge .pulse-dot { width: 6px; height: 6px; border-radius: 50%; background: #1a1410; }
@keyframes pulse-glow {
  0%   { box-shadow: 0 0 0 0   rgba(240,183,58,0.7); transform: scale(1); }
  50%  { box-shadow: 0 0 0 8px rgba(240,183,58,0);   transform: scale(1.06); }
  100% { box-shadow: 0 0 0 0   rgba(240,183,58,0);   transform: scale(1); }
}

/* ===== 読み込み中スピナー(LINE 確認中などの「待っています」表示・2026-06-28) =====
   どの画面でも使える共通の小さなくるくる。色は LINE グリーンを基調にする。 */
.sm-spinner {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.18);
  border-top-color: #06C755;
  animation: sm-spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes sm-spin { to { transform: rotate(360deg); } }
/* 2026-07-24 (Round T2-HC #24): prefers-reduced-motion 対応は L109 の統合ブロック側で
   `.sm-spinner { animation-duration: 1.6s !important }` を !important 付きで指定済。
   ここに同定義があると重複 (かつ !important 無しで後発 cascade により無効化リスク)。
   dead code を削除して定義を 1 箇所に集約。 */

/* タイムブロック クリック → スケジュール追加(本日のタイムブロック)*/
.timeline-block.empty-slot { cursor: pointer; transition: background 0.12s ease; border-radius: 6px; min-height: 36px; display: flex; align-items: center; }
.timeline-block.empty-slot:hover { background: rgba(91,140,255,0.10); }
.timeline-block.has-slot { cursor: pointer; transition: opacity 0.12s ease; }
.timeline-block.has-slot:hover { opacity: 0.78; }
.timeline-empty-hint { color: var(--text-3); font-size: 11px; padding: 4px 10px; opacity: 0; transition: opacity 0.15s ease; pointer-events: none; }
.timeline-block.empty-slot:hover .timeline-empty-hint { opacity: 0.85; color: var(--accent); font-weight: 600; }

/* ====== バッジ・ピル ====== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600;
  background: var(--bg-3); color: var(--text-2);
}
.badge.ok { background: rgba(74, 222, 128, .15); color: var(--ok); }
.badge.warn { background: rgba(251, 191, 36, .15); color: var(--warn); }
.badge.ng { background: rgba(248, 113, 113, .15); color: var(--ng); }
.badge.info { background: rgba(94, 158, 255, .15); color: var(--accent); }
.badge.purple { background: rgba(167, 139, 250, .15); color: var(--purple); }
.badge.pink { background: rgba(244, 114, 182, .15); color: var(--pink); }
.badge.teal { background: rgba(45, 212, 191, .15); color: var(--teal); }

/* ====== ボタン ====== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  /* 2026-07-23 (Round 13-2 B-5): transition: all を明示リスト化 */
  transition: transform .15s, background .15s, border-color .15s, box-shadow .15s, color .15s, opacity .15s;
  font-family: inherit;
}
.btn:hover { background: var(--line); }
.btn.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--ng); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
/* 2026-07-22: 60+ 箇所で btn.disabled=true するが視覚差ゼロだった問題を修正 (WCAG 3.2.4) */
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; filter: grayscale(.3); }
/* キーボード操作時のフォーカス可視化 (WCAG 2.4.7) */
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ====== フォーム ====== */
input, select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
}
/* iOS Safari は 16px 未満の input にフォーカスすると自動ズームするので、スマホでは 16px に */
@media (max-width: 768px) {
  input, select, textarea { font-size: 16px; padding: 11px 12px; }
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(94, 158, 255, .15);
}
/* ブラウザのオートフィル白背景を上書き(ダークテーマ対応) */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-text-fill-color: var(--text) !important;
  -webkit-box-shadow: 0 0 0px 1000px var(--bg) inset !important;
  caret-color: var(--text);
  transition: background-color 5000s ease-in-out 0s;
}
/* disabled 入力欄は半透明だが完全に編集不可だと分かるように */
input:disabled, select:disabled, textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: rgba(255,255,255,0.02);
}
textarea { resize: vertical; min-height: 70px; }
label {
  display: block;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 5px;
  font-weight: 500;
}

/* ====== テーブル ====== */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -4px;
}
.card .table-wrap { margin: 0 -10px; padding: 0 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  text-align: left; padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}
th { color: var(--text-2); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
tr:hover td { background: rgba(94, 158, 255, .04); }

/* ====== タイムライン ====== */
.timeline { display: grid; grid-template-columns: 60px 1fr; gap: 0; }
.timeline-time { font-size: 11px; color: var(--text-3); padding: 8px 0; border-right: 1px solid var(--line); padding-right: 8px; text-align: right; }
.timeline-block {
  padding: 8px 12px; border-bottom: 1px solid var(--line);
  min-height: 36px;
}
.timeline-task {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: rgba(94, 158, 255, .15);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  font-size: 12px;
}

/* ====== カレンダー ====== */
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head { font-size: 11px; color: var(--text-3); text-align: center; padding: 6px; font-weight: 600; }
.cal-cell {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px;
  min-height: 70px;
  font-size: 11px;
  position: relative;
}
.cal-cell.today { border-color: var(--accent); background: rgba(94, 158, 255, .06); }
.cal-cell.weekend { background: var(--bg-2); }
.cal-cell.other { opacity: .35; }
.cal-cell .day-num { font-weight: 600; font-size: 12px; margin-bottom: 4px; }
.cal-cell .leave-mark {
  display: inline-block;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(167, 139, 250, .25);
  color: var(--purple);
  margin-bottom: 2px;
}
.cal-cell .event-mark {
  font-size: 10px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ====== チームグリッド ====== */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.member-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.member-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px; color: white;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.avatar > img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; border-radius: 50%;
  display: block;
}
.member-name { font-weight: 600; font-size: 14px; }
.member-role { font-size: 11px; color: var(--text-3); }
.member-status { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.member-task {
  font-size: 12px;
  padding: 6px 8px;
  background: var(--bg);
  border-radius: 5px;
  margin-bottom: 4px;
  border-left: 2px solid var(--accent);
}
.member-task.done { opacity: .55; border-left-color: var(--ok); text-decoration: line-through; }

/* ====== Status dot color set ====== */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.status-dot.work { background: var(--ok); }
.status-dot.break { background: var(--warn); }
.status-dot.off { background: var(--text-3); }
.status-dot.leave { background: var(--purple); }

/* ====== ナビ・タブ ====== */
.tabs {
  display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  /* 2026-07-24 (Round T3-HC #22): Firefox は scrollbar-width のみで scrollbar-color 未指定だと
     system 既定色 (灰) が dark bg 上で視認性低下。--line 色を明示。Chrome/Safari は
     ::-webkit-scrollbar-thumb で個別指定済 (下記 L536) のため両ブラウザで一貫化。 */
  scrollbar-color: var(--line, #2a3045) transparent;
}
.tabs::-webkit-scrollbar { height: 4px; }
.tabs::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }
.tab {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  scroll-snap-align: start;
  flex-shrink: 0;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab:hover { color: var(--text); }
/* 2026-07-23 (Round 15 CSS-Agent S1-HC #20): tabindex="0" 付与済み tab の
   キーボード focus 可視化 (WCAG 2.4.7 / N-10 で属性のみ付与、視覚不可能だった)。 */
/* 2026-07-24 (Round T1-HC #4 対応済確認): admin/employee/mypage 側は role="tab" 付与済で
   .tab class 併用。role 単体運用 (将来 .tab class 剥がし) にも対応するため
   [role="tab"] セレクタも併記。specificity は同一 (単一 attr/class) で cascade 不変。 */
.tab:focus-visible,
[role="tab"]:focus-visible { outline: 2px solid var(--accent, #5b8cff); outline-offset: 2px; }

/* ====== 空状態 ====== */
.empty {
  text-align: center; padding: 30px;
  color: var(--text-3); font-size: 13px;
}

/* ====== 入口ページ ====== */
.entry-wrap {
  /* 2026-07-23 (Round 14 CSS-Agent R1-HC #34): 100dvh 併記で iOS Safari URL バー分の見切れを回避。
     100vh (large viewport) → 100dvh (dynamic viewport, URL バー考慮) の順で後者優先。 */
  min-height: 100vh;
  min-height: 100dvh;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at top, rgba(94, 158, 255, .15), transparent 60%),
              radial-gradient(ellipse at bottom, rgba(167, 139, 250, .12), transparent 60%),
              var(--bg);
  padding: 30px;
}
.entry-card {
  max-width: 920px; width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 40px;
  box-shadow: var(--shadow);
}
.entry-card .logo {
  width: 48px; height: 48px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: grid; place-items: center;
  color: white; font-weight: 800; font-size: 20px;
  margin-bottom: 18px;
}
.entry-card h1 { margin: 0 0 6px; font-size: 24px; }
.entry-card .lead { color: var(--text-2); font-size: 14px; margin-bottom: 28px; }
.entry-options { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; margin-top: 20px; }
@media (max-width: 720px) { .entry-options { grid-template-columns: 1fr; } }
.entry-opt {
  display: block;
  padding: 22px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  /* 2026-07-23 (Round 13-2 B-5): transition: all を明示リスト化 */
  transition: transform .15s, background .15s, border-color .15s, box-shadow .15s, color .15s, opacity .15s;
}
.entry-opt:hover {
  border-color: var(--accent);
  background: rgba(94, 158, 255, .05);
  transform: translateY(-2px);
  text-decoration: none;
}
.entry-opt .icon { font-size: 28px; margin-bottom: 10px; }
.entry-opt h3 { margin: 0 0 4px; font-size: 15px; color: var(--text); }
.entry-opt p { margin: 0; font-size: 12px; color: var(--text-2); line-height: 1.5; }

/* ====== モーダル ====== */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .65);
  display: none; place-items: center; z-index: var(--z-modal-bg, 100); padding: 20px;
}
.modal-bg.show { display: grid; }
.modal {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  /* 2026-07-24 (Round T3-HC #21): モーダル内スクロールが背景 body に伝播するのを防ぐ
     (iOS Safari のバウンス波及回避)。既存 overflow-y:auto のスクロール挙動は維持。 */
  overscroll-behavior: contain;
}
.modal h3 { margin: 0 0 16px; font-size: 16px; }
.modal-row { margin-bottom: 14px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* ====== 進捗バー ====== */
.progress {
  height: 6px; background: var(--bg-3); border-radius: 3px; overflow: hidden;
}
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--purple)); }

/* ====== サクセスフラッシュ (アクション完了画面) ====== */
.success-flash {
  position: fixed; inset: 0;
  background: rgba(13, 16, 24, .55);
  display: none; place-items: center;
  z-index: 300;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.success-flash.show { display: grid; animation: flash-fade-in .15s ease-out; }
@keyframes flash-fade-in { from { opacity: 0 } to { opacity: 1 } }

.success-flash-card {
  background: var(--bg-2);
  border: 1px solid var(--ok);
  border-radius: 14px;
  padding: 28px 36px;
  text-align: center;
  box-shadow: 0 0 36px rgba(74, 222, 128, .35);
  animation: flash-pop .25s cubic-bezier(.2,1.6,.4,1);
}
@keyframes flash-pop {
  from { transform: scale(.7); opacity: 0 }
  60% { transform: scale(1.05); opacity: 1 }
  to { transform: scale(1); opacity: 1 }
}
.success-flash-icon {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4ade80, #2dd4bf);
  display: grid; place-items: center;
  color: white; font-size: 32px; font-weight: 800;
  margin: 0 auto 12px;
  box-shadow: 0 6px 20px rgba(74, 222, 128, .4);
}
.success-flash-msg {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

/* 要素を一瞬光らせる (申請履歴の更新箇所など) */
.flash-highlight {
  animation: flash-glow 1.4s ease-out;
}
@keyframes flash-glow {
  0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); background: transparent; }
  20% { box-shadow: 0 0 24px 4px rgba(74, 222, 128, .55); background: rgba(74, 222, 128, .1); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); background: transparent; }
}

/* ====== トースト ====== */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--bg-3); border: 1px solid var(--line);
  padding: 12px 20px; border-radius: 8px;
  font-size: 13px; color: var(--text);
  box-shadow: var(--shadow);
  /* 2026-07-23 (Round 13-2 C-8): .modal-bg (1000) より上に載せる (トースト隠れ対策)
     2026-07-24 (Round T2-HC #25): --z-toast (1200) 変数を参照。フォールバック 1200 で
     :root 未定義時も従来値と一致 (visual diff ゼロ)。 */
  z-index: var(--z-toast, 1200);
  transform: translateY(20px); opacity: 0;
  /* 2026-07-23 (Round 13-2 B-5): transition: all を明示リスト化 (opacity/transform 必須) */
  transition: transform .2s, background .2s, border-color .2s, box-shadow .2s, color .2s, opacity .2s;
  pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ====== ユーティリティ ====== */
.muted { color: var(--text-2); }
.small { font-size: 11px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 6px; }
.gap-2 { gap: 12px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
hr.divider { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* ====== バッジ ゴールド ====== */
.badge.gold { background: rgba(240, 183, 58, .15); color: var(--gold); }

/* ====== 緊急度カラー (期限までの残り時間で変化) ====== */
/* 期限が遠い → 青 → 緑 → 黄 → オレンジ → 赤 → 赤点滅 */
.urgency-far      { border-left: 3px solid #5e9eff !important; background: linear-gradient(to right, rgba(94,158,255,.10), transparent 60%) !important; }
.urgency-mid      { border-left: 3px solid #4ade80 !important; background: linear-gradient(to right, rgba(74,222,128,.10), transparent 60%) !important; }
.urgency-soon     { border-left: 3px solid #fbbf24 !important; background: linear-gradient(to right, rgba(251,191,36,.12), transparent 60%) !important; }
.urgency-near     { border-left: 3px solid #fb923c !important; background: linear-gradient(to right, rgba(251,146,60,.15), transparent 60%) !important; }
.urgency-imminent { border-left: 3px solid #f87171 !important; background: linear-gradient(to right, rgba(248,113,113,.18), transparent 60%) !important; }
.urgency-overdue  {
  border-left: 3px solid #ef4444 !important;
  background: linear-gradient(to right, rgba(239,68,68,.22), rgba(239,68,68,.05) 70%) !important;
  color: var(--text);
}
.urgency-overdue-blink {
  border-left: 3px solid #ef4444 !important;
  animation: urgent-blink 1s steps(2, start) infinite;
}
@keyframes urgent-blink {
  0%, 49%   { background: linear-gradient(to right, rgba(239,68,68,.45), rgba(239,68,68,.10) 70%) !important; box-shadow: 0 0 12px rgba(239,68,68,.4); }
  50%, 100% { background: linear-gradient(to right, rgba(239,68,68,.08), transparent 70%) !important; box-shadow: none; }
}
.urgency-done { opacity: .55; }

/* テーブル行にもグラデが効くように */
tr.urgency-far td, tr.urgency-mid td, tr.urgency-soon td,
tr.urgency-near td, tr.urgency-imminent td, tr.urgency-overdue td { background-clip: padding-box; }
tr.urgency-overdue td:first-child { border-left: 3px solid #ef4444; }
tr.urgency-overdue-blink td {
  animation: urgent-blink 1s steps(2, start) infinite;
}
tr.urgency-done td { opacity: .55; text-decoration: line-through; }

/* タスク進捗バー (member-task の中に入れる用) */
.task-progress {
  height: 5px;
  background: var(--bg-3);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 6px;
  position: relative;
}
.task-progress > .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width .25s ease;
}
.task-progress.done > .fill { background: linear-gradient(90deg, var(--ok), var(--teal)); }
.task-progress-label {
  font-size: 10px; color: var(--text-3);
  display: flex; justify-content: space-between; margin-top: 3px;
}

/* メンバーのリソース負荷バー */
.workload-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: var(--bg);
  border-radius: 6px; border: 1px solid var(--line);
  font-size: 12px;
}
.workload-bar .lvl-emoji { font-size: 16px; line-height: 1; }
.workload-bar .lvl-label { font-weight: 600; }
.workload-bar .lvl-meter {
  flex: 1; height: 6px; background: var(--bg-3); border-radius: 3px; overflow: hidden;
}
.workload-bar .lvl-fill {
  height: 100%; transition: width .25s ease;
}
.workload-bar.lvl-free  { border-color: rgba(74,222,128,.4); }
.workload-bar.lvl-free  .lvl-fill { background: var(--ok); }
.workload-bar.lvl-free  .lvl-label { color: var(--ok); }
.workload-bar.lvl-normal { border-color: rgba(91,140,255,.4); }
.workload-bar.lvl-normal .lvl-fill { background: var(--accent); }
.workload-bar.lvl-normal .lvl-label { color: var(--accent); }
.workload-bar.lvl-busy { border-color: rgba(240,183,58,.5); background: rgba(240,183,58,.05); }
.workload-bar.lvl-busy .lvl-fill { background: var(--gold); }
.workload-bar.lvl-busy .lvl-label { color: var(--gold); }
.workload-bar.lvl-overflow {
  border-color: var(--ng);
  background: rgba(248,113,113,.08);
  animation: workload-pulse 2s ease-in-out infinite;
}
.workload-bar.lvl-overflow .lvl-fill { background: var(--ng); }
.workload-bar.lvl-overflow .lvl-label { color: var(--ng); font-weight: 700; }
@keyframes workload-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248,113,113,0); }
  50%      { box-shadow: 0 0 12px 2px rgba(248,113,113,.35); }
}

/* 緊急度ドット (バッジの左に付ける小さな印) */
.urgency-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 6px; vertical-align: middle;
}
.urgency-dot.far { background: #5e9eff; }
.urgency-dot.mid { background: #4ade80; }
.urgency-dot.soon { background: #fbbf24; }
.urgency-dot.near { background: #fb923c; }
.urgency-dot.imminent { background: #f87171; }
.urgency-dot.overdue, .urgency-dot.overdue-blink { background: #ef4444; }
.urgency-dot.overdue-blink { animation: urgent-blink 1s steps(2, start) infinite; }

/* ====== チャート ====== */
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 12px; }
.bar-row .label { width: 90px; flex-shrink: 0; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .bar-track { flex: 1; height: 14px; background: var(--bg-3); border-radius: 7px; overflow: hidden; position: relative; }
.bar-row .bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); border-radius: 7px; }
.bar-row .bar-val { width: 60px; text-align: right; flex-shrink: 0; font-weight: 600; }

.donut { width: 120px; height: 120px; }
.donut-wrap { display: flex; align-items: center; gap: 16px; }
.donut-wrap .legend { font-size: 12px; }
.donut-wrap .legend-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.donut-wrap .legend-row .swatch { width: 10px; height: 10px; border-radius: 2px; }

/* ====== 通知 ====== */
.notif-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  margin-bottom: 8px;
}
.notif-item.warn { border-left-color: var(--warn); }
.notif-item.ng { border-left-color: var(--ng); }
.notif-item.info { border-left-color: var(--accent); }
.notif-item .icon { font-size: 18px; flex-shrink: 0; line-height: 1.2; }
.notif-item .body { flex: 1; min-width: 0; }
.notif-item .title { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.notif-item .msg { font-size: 12px; color: var(--text-2); }
.notif-item .meta { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* ====== カンバン (採用/稟議) ====== */
.kanban { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.kanban-col {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px;
  min-height: 200px;
}
.kanban-col h4 { margin: 0 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); }
.kanban-card {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px; margin-bottom: 8px;
  font-size: 12px; cursor: pointer;
}
.kanban-card:hover { border-color: var(--accent); }
.kanban-card .name { font-weight: 600; margin-bottom: 4px; }
.kanban-card .meta { font-size: 11px; color: var(--text-3); }
.kanban-card .stars { color: var(--gold); font-size: 11px; margin-top: 4px; }

/* ====== モバイル対応 ====== */
@media (max-width: 768px) {
  body { font-size: 14px; }

  header.app-header {
    padding: 10px 14px;
    padding-top: max(10px, env(safe-area-inset-top));
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
    flex-wrap: wrap;
    gap: 8px;
  }
  header .brand { font-size: 14px; }
  header nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }
  header nav a {
    font-size: 13px; padding: 7px 14px; flex-shrink: 0;
    border-radius: 6px;
    scroll-snap-align: start;
  }
  header nav a.active { background: var(--bg-3); color: var(--text); }
  header .user-pill { padding: 5px 12px; font-size: 13px; }
  header .user-pill .btn.sm { padding: 4px 8px; font-size: 12px; min-height: 28px; }

  .container {
    padding: 14px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; }
  .grid.grid-2 { gap: 12px; }

  .tab { padding: 10px 14px; font-size: 13px; min-height: 42px; display: flex; align-items: center; }

  .kpi { padding: 12px 14px; }
  .kpi .value { font-size: 24px; }
  .kpi .label { font-size: 10px; }

  .card { padding: 14px; }
  .card h2 { font-size: 14px; }

  table { font-size: 13px; min-width: max-content; }
  th, td { padding: 10px 8px; }

  .timeline { grid-template-columns: 56px 1fr; }
  .timeline-time { font-size: 11px; padding: 8px 0; padding-right: 6px; }
  .timeline-task { font-size: 12px; padding: 6px 10px; }

  .calendar { gap: 2px; }
  .cal-cell {
    min-height: 60px; padding: 5px;
    font-size: 11px;
  }
  .cal-cell .day-num { font-size: 12px; margin-bottom: 3px; }
  .cal-cell .leave-mark, .cal-cell .event-mark { font-size: 10px; }
  .cal-head { font-size: 10px; padding: 4px; }

  .team-grid { grid-template-columns: 1fr; }
  .member-card { padding: 14px; }

  .entry-card { padding: 22px; border-radius: 12px; }
  .entry-options { grid-template-columns: 1fr !important; }
  .entry-opt { padding: 18px; }

  .kanban { grid-template-columns: 1fr; }

  /* 旧モーダル CSS は冒頭の @media (max-width: 768px) の新ルールに統合 (画面全体スクロール対応) */
  @keyframes slide-up {
    from { transform: translateY(40px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
  }

  /* タッチ最小領域 */
  .btn { min-height: 42px; padding: 10px 16px; }
  .btn.sm { min-height: 36px; padding: 7px 12px; font-size: 13px; }
  input[type="checkbox"] { min-height: 22px; min-width: 22px; }

  /* バーチャート: ラベルのwidth拡大 */
  .bar-row .label { width: 100px; font-size: 12px; }
  .bar-row .bar-val { width: 70px; font-size: 11px; }

  /* 通知アイテムのアイコン縮小 */
  .notif-item { padding: 12px 10px; }
  .notif-item .icon { font-size: 20px; }

  /* トースト位置調整 */
  .toast {
    bottom: max(12px, env(safe-area-inset-bottom));
    right: 12px; left: 12px;
    text-align: center;
  }

  /* ページタイトル + アクションボタン群を縦積みに */
  .container > .flex-between {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .container > .flex-between > .flex.gap-1 {
    flex-wrap: wrap;
    gap: 6px;
  }
  .container > .flex-between > .flex.gap-1 > .btn {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
  }

  /* h1 行のサブタイトル (時刻 + Google ステータス) は読みやすく */
  .container h1 + .muted.small,
  .container > .flex-between .muted.small {
    line-height: 1.5;
  }
}

/* 2026-07-23 (Round 15 CSS-Agent S3-HC #24): 元は同一 @media (max-width:480px) が 2 ブロック
   (旧 L980 と旧 L1002) で `header nav { justify-content: flex-start | center }` が衝突していた。
   cascade 上、後発の `center` が有効値だったため、その効果を統合ブロックで保持。
   他 rules は完全重複だったため 1 度にまとめる。視覚差ゼロ。 */
@media (max-width: 480px) {
  header.app-header {
    flex-direction: column;
    align-items: stretch;
  }
  header .brand { justify-content: center; }
  /* 統合前は L986 で flex-start / L1008 で center。cascade 有効値 center を保持。 */
  header nav { justify-content: center; }
  header .user-pill { justify-content: center; }

  /* 1行で見えにくい長いタブ用 */
  .tabs { padding-left: 2px; }
  .tab { padding: 10px 12px; }

  .kpi .value { font-size: 22px; }

  /* テーブルセル詰める */
  th, td { padding: 8px 6px; font-size: 12px; }
}

/* スマホ実機での縦並び iframe 切替 (旧コードがあれば対応) */
iframe { max-width: 100%; }

/* ===========================================================
   📱 スマホ統合最適化 (2026-05-18 礒貝CEO 要望: スマホ閲覧主体に)
   - iOS Safari の自動ズーム回避(input font-size: 16px)
   - タブ container 横スクロール対応
   - 全グリッド 1 列化
   - モーダル全画面化
   - タッチターゲット 44x44px 確保
   - ボタンの可読性
   =========================================================== */
@media (max-width: 768px) {
  /* iOS Safari の自動ズーム回避 (input/select/textarea: 16px) */
  input, select, textarea, button { font-size: 16px !important; }
  input[type="checkbox"], input[type="radio"] { font-size: inherit !important; }

  /* タブ container を横スクロール (8〜10タブが画面に入らない場合の対応) */
  .tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    /* 2026-07-24 (Round T3-HC #22): Firefox で scrollbar-color 未指定だと system 既定色。
       ベース (L536 area) と一貫化。 */
    scrollbar-color: var(--line, #2a3045) transparent;
    padding-bottom: 4px;
  }
  .tab {
    flex-shrink: 0;
    white-space: nowrap;
    min-width: max-content;
    padding: 12px 14px;
    font-size: 13px;
  }

  /* 全グリッドを 1 列に */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; gap: 12px !important; }

  /* KPI カードを 2 列(画面が狭くても KPI は 2 つ並べる) */
  .grid.grid-4 { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }
  .kpi { padding: 12px 10px !important; }
  .kpi .label { font-size: 11px !important; }
  .kpi .value { font-size: 22px !important; }
  .kpi .delta { font-size: 10px !important; }

  /* ボタンのタッチターゲット (44x44px 確保 = Apple HIG 推奨) */
  .btn { min-height: 44px; padding: 11px 16px; font-size: 14px; }
  .btn.sm { min-height: 36px; padding: 8px 12px; font-size: 13px; }

  /* ヘルプ「?」ボタン: 見た目は小さいまま、指で押せる実効 44px の当たり判定を確保。
     透明な擬似要素を中央に重ね、カード本体クリックと誤タップしないよう余白も足す。 */
  .help-btn { position: relative; }
  .help-btn::before {
    content: ""; position: absolute; top: 50%; left: 50%;
    width: 44px; height: 44px; transform: translate(-50%, -50%);
    border-radius: 50%;
  }
  .help-corner { top: 6px; right: 6px; }

  /* 旧モーダル CSS は @media (max-width: 768px) の新ルール (画面全体スクロール) で上書き済 */
  /* min-height:100vh を残すと iOS Safari の URL バー分でフッターが隠れて登録ボタン押せない事故が再発するため、ここでは何も指定しない */

  /* 入力ラベル + 入力欄を縦並びにして可読性UP */
  .modal-row { display: block !important; margin-bottom: 14px; }
  .modal-row label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; }
  .modal-row input, .modal-row select, .modal-row textarea { width: 100% !important; }

  /* テーブルを横スクロール可能に */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 600px; }

  /* カード余白 */
  .card { padding: 14px !important; }
  .container { padding: 12px !important; }

  /* ヘッダー要素 stack */
  .flex-between { flex-wrap: wrap; gap: 8px; }
  .flex-between > * { flex: 1 1 auto; min-width: 0; }

  /* インラインカレンダー (休暇申請) は元から compact 設計だが、念のため */
  .inline-cal { padding: 10px !important; }
  .inline-cal button[data-cal-day] { min-height: 36px; padding: 6px 0 !important; }

  /* FAB の位置調整 (固定 FAB が画面下部のボタンを覆わないように) */
  .fab-btn, [id*="fab-button"] { bottom: 14px !important; right: 14px !important; }

  /* index/login の entry-card */
  .entry-card { padding: 20px !important; }
  .entry-options { grid-template-columns: 1fr !important; }
}

@media (max-width: 480px) {
  /* さらに小さい画面 (iPhone SE 等) */
  h1 { font-size: 18px !important; }
  h2 { font-size: 16px !important; }
  h3 { font-size: 14px !important; }
  .kpi .value { font-size: 20px !important; }
  .container { padding: 10px !important; }
  .tab { padding: 10px 12px; font-size: 12px; }
}

/* ===== ❓ ヘルプボタン (全画面共通) ===== */
.help-btn {
  background: rgba(91,140,255,.12);
  border: 1px solid var(--accent, #5b8cff);
  color: var(--accent, #5b8cff);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  line-height: 1;
  vertical-align: middle;
  /* 2026-07-23 (Round 13-2 B-5): transition: all を明示リスト化 */
  transition: transform .15s, background .15s, border-color .15s, box-shadow .15s, color .15s, opacity .15s;
  flex-shrink: 0;
}
.help-btn:hover { background: var(--accent, #5b8cff); color: #fff; transform: scale(1.1); }
.help-btn.sm { width: 18px; height: 18px; font-size: 10px }
.help-corner { position: absolute; top: 8px; right: 8px; z-index: 5 }
.help-corner-left { position: absolute; top: 8px; right: 60px; z-index: 5 }

/* ヘルプモーダル */
.help-modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  /* 2026-07-24 (Round T2-HC #25): --z-overlay (10000) 変数を参照。フォールバック 10000 で
     :root 未定義時も従来値と一致 (visual diff ゼロ)。 */
  z-index: var(--z-overlay, 10000);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.help-modal {
  max-width: 560px; width: 100%; max-height: 85vh; overflow-y: auto;
  background: var(--bg-2, #1a1f2e);
  border: 1px solid var(--line, #2a3045);
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  color: var(--text, #ecf0f9);
  /* 2026-07-24 (Round T3-HC #21): モーダル内スクロールが背景 body に伝播しないよう。 */
  overscroll-behavior: contain;
}
.help-modal h3 {
  margin: 0 0 14px;
  color: var(--accent, #5b8cff);
  font-size: 16px;
  display: flex; align-items: center; gap: 8px;
}
.help-modal .help-body {
  font-size: 13px; line-height: 1.8;
  color: var(--text, #ecf0f9);
}
.help-modal .help-body ol, .help-modal .help-body ul { padding-left: 20px; margin: 8px 0 }
.help-modal .help-body li { margin-bottom: 4px }
.help-modal .help-body code { background: var(--bg-3, #252a3d); padding: 2px 6px; border-radius: 4px; font-size: 12px }
.help-modal .help-body .hint { background: rgba(74,222,128,.06); border:1px solid rgba(74,222,128,.30); color: #4ade80; padding: 8px 10px; border-radius: 6px; font-size: 12px; margin: 8px 0 }
.help-modal .help-body .warn { background: rgba(248,113,113,.06); border:1px solid rgba(248,113,113,.30); color: #f87171; padding: 8px 10px; border-radius: 6px; font-size: 12px; margin: 8px 0 }
.help-modal .help-close {
  background: var(--accent, #5b8cff); color: #fff; border: 0;
  padding: 8px 16px; border-radius: 8px; cursor: pointer;
  margin-top: 14px; font-weight: bold;
}

/* =====================================================================
   🔄 待機オーバーレイ スピナー — sm-spin (L275) に統一 (2026-07-22)
   元コード: index.html:180 / admin.html:1337 / employee.html:815 で
   各々 home-spin / adm-spin / emp-spin として定義されていたが、いずれも
   `to { transform: rotate(360deg); }` で byte-identical だったため
   sm-spin (L275) を canonical として集約。renderWaitOverlay 呼出側
   (admin/00-guard, employee/02-overlay-render, index/init) も sm-spin 指定に更新済。
   ===================================================================== */

/* =====================================================================
   ♿ アクセシビリティ / 印刷 用の @media クエリ (2026-07-23 Round 15 CSS-Agent)
   ===================================================================== */

/* S3-HC #19: Windows High Contrast Mode (forced-colors) 対応。
   status pill / urgency-* は色のみで意味を伝えており、High Contrast Mode では
   単色化されて識別不能になる (WCAG 1.4.11 非適合)。CanvasText/ButtonText で
   OS 提供の輪郭を強制付与し形状で識別可能に。既存 border が有る要素は視覚差ゼロ。 */
@media (forced-colors: active) {
  .badge, .urgency-far, .urgency-near, .urgency-soon, .urgency-overdue, .urgency-overdue-blink {
    border: 1px solid CanvasText;
  }
  .btn { border: 1px solid ButtonText; }
  /* 2026-07-24 (Round T2-HC #38): input:focus は base で outline:none + box-shadow に依存。
     Windows High Contrast Mode では box-shadow が無視され focus 位置が完全に消失 = WCAG 2.4.7 違反。
     Highlight (OS 指定 focus 色) で強制輪郭付与。同様にタブ/ボタンにも適用 (base の focus-visible
     `2px solid var(--accent)` が forced-colors で透ける可能性への保険)。 */
  input:focus, select:focus, textarea:focus,
  [role="tab"]:focus, .tab:focus, .btn:focus {
    outline: 2px solid Highlight;
    outline-offset: 2px;
  }
}

/* S3-HC #20: prefers-contrast: more 対応。text-2/text-3 の淡色を高コントラストに。
   OS 設定に応じて自動発動。通常環境では発動しない。
   2026-07-24 (Round T1-HC #4): body.theme-light も上書き。以前は :root のみ指定で
   ライトテーマ (白背景) 上に `#dddddd` を text-3 として使うと 1.4:1 のコントラスト比で
   WCAG AA (4.5:1) 大失敗だった。ライトモード時は黒系に反転して確実に高コントラスト化。 */
@media (prefers-contrast: more) {
  :root { --text-2: #ffffff; --text-3: #dddddd; }
  body.theme-light { --text-2: #000000; --text-3: #333333; }
}

/* S3-HC #23: 印刷時のダーク背景トナー消費対策。no-print / btn / fab / toast /
   modal 系は印刷時に非表示。リンクは URL を可視化。
   2026-07-24 (Round T1-HC #15): 元 body のみ background/color !important で --text 系変数を
   使う子要素は白色残存 → **印刷が白背景に白文字**で不可視 (会計 CSV/日報でクリティカル)。
   :root/body/* に --text 系変数を黒系で上書き + 全要素の color/background を強制黒/白に。
   2026-07-24 (Round T1-HC #16,17): mailto:/tel:/javascript:/#anchor は URL 後置しない
   (http/https 外部リンクのみ)。長テーブル/tr に page-break-inside:avoid で行途中改ページ回避。 */
@media print {
  :root, body { --text: #000; --text-2: #333; --text-3: #555; --bg: #fff; --bg-2: #fff; --card: #fff; --line: #999; --border: #999; }
  body { background: #fff !important; color: #000 !important; }
  * { color: #000 !important; background: #fff !important; }
  table, th, td { border: 1px solid #999 !important; }
  .no-print, .btn, .fab, .fab-menu, .toast, .modal-bg { display: none !important; }
  table { page-break-inside: avoid; }
  tr { page-break-inside: avoid; }
  a[href^="http"]:after { content: " (" attr(href) ")"; font-size: 0.8em; }
}

/* =====================================================================
   ⏭️  Skip to main content (T2-HC #36) — 全 HTML 共通
   HTML 側で `<a class="skip-link" href="#main-content">` を <body> 直下先頭に置く前提。
   デフォルトは画面外に絶対配置 (Tab focus 時にのみ画面内に降りてくる)。
   WCAG 2.4.1 (Bypass Blocks) 対応。JS 更新は不要 (CSS のみで完結)。
   ===================================================================== */
.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  transform: translateY(-100%);
  padding: 8px 12px;
  background: var(--accent, #5b8cff);
  color: #fff;
  z-index: 10001;
  border-radius: 0 0 6px 0;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  transition: transform 0.15s;
}
.skip-link:focus-visible,
.skip-link:focus {
  transform: translateY(0);
  outline: 2px solid #fff;
  outline-offset: 2px;
}
