* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f5f5f5; color: #333; }

/* ---- ナビ ---- */
nav { background: #fff; border-bottom: 1px solid #e0e0e0; padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; }
nav .logo { font-size: 18px; font-weight: 700; color: #ff5252; display: flex; align-items: center; gap: 8px; }
nav .logo a { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 8px; }
nav .logo .logo-icon { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; }
nav .nav-links { display: flex; gap: 20px; align-items: center; }
nav .nav-links a { text-decoration: none; color: #666; font-size: 14px; }
nav .nav-links a[data-roles] { display: none; }
nav .nav-links a.active { color: #ff5252; font-weight: 600; }
nav .user-area { display: flex; align-items: center; gap: 12px; }
nav .user-email { font-size: 13px; color: #999; }
nav .btn-logout { background: none; border: 1px solid #ddd; padding: 4px 12px; border-radius: 4px; font-size: 12px; color: #666; cursor: pointer; }
nav .btn-logout:hover { background: #f5f5f5; }

/* ---- コンテナ ---- */
.container { max-width: 1000px; margin: 0 auto; padding: 24px 16px; }

/* ---- ログインページ ---- */
.login-wrapper { display: flex; justify-content: center; align-items: center; min-height: 80vh; }
.login-box { background: #fff; padding: 40px; border-radius: 12px; width: 100%; max-width: 400px; text-align: center; }
.login-box h1 { font-size: 22px; margin-bottom: 8px; color: #ff5252; }
.login-box p { font-size: 13px; color: #999; margin-bottom: 24px; }
.login-box input { width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; margin-bottom: 12px; }
.login-box input:focus { outline: none; border-color: #ff5252; }
.btn-primary { width: 100%; padding: 10px; background: #ff5252; color: #fff; border: none; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-primary:hover { background: #e04848; }
.btn-primary:disabled { background: #ccc; cursor: not-allowed; }
.divider { margin: 16px 0; font-size: 12px; color: #ccc; }
.btn-google { width: 100%; padding: 10px; background: #fff; color: #333; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; cursor: pointer; }
.btn-google:hover { background: #f9f9f9; }
.login-toggle { margin-top: 16px; font-size: 13px; color: #999; }
.login-toggle a { color: #ff5252; text-decoration: none; cursor: pointer; }
.error-msg { color: #e53935; font-size: 13px; margin-bottom: 12px; display: none; }
.field-group { margin-bottom: 4px; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: #666; text-align: left; margin-bottom: 4px; margin-top: 8px; }
.confirm-field { font-size: 13px !important; border-color: #e0e0e0 !important; background: #fafafa; overflow: hidden; max-height: 0; opacity: 0; padding: 0 12px !important; margin: 0 !important; border-width: 0 !important; transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease, margin 0.3s ease, border-width 0.3s ease; }
.confirm-field.visible { max-height: 50px; opacity: 1; padding: 8px 12px !important; margin-bottom: 12px !important; border-width: 1px !important; }
.kaihipay-notice { font-size: 12px; color: #999; margin-top: 16px; }

/* ---- βテストモード ---- */
.beta-mode .login-box { border: 2px solid #1976d2; }
.beta-mode .login-box h1 { color: #1976d2; }
.beta-mode .btn-primary { background: #1976d2; }
.beta-mode .btn-primary:hover { background: #1565c0; }
.beta-mode .btn-primary:disabled { background: #ccc; }
.beta-mode .login-box input:focus { border-color: #1976d2; }
.beta-mode .login-toggle a { color: #1976d2; }
.beta-badge { display: none; background: #1976d2; color: #fff; font-size: 11px; font-weight: 700; padding: 4px 14px; border-radius: 20px; letter-spacing: 0.5px; margin-bottom: 12px; }
.beta-mode .beta-badge { display: inline-block; }
.beta-steps { display: none; text-align: left; background: #e3f2fd; border-radius: 8px; padding: 14px 18px; margin-bottom: 16px; font-size: 12px; color: #1565c0; line-height: 1.8; }
.beta-steps strong { font-size: 13px; display: block; margin-bottom: 4px; }
.beta-mode .beta-steps { display: block; }
.beta-mode .kaihipay-notice { display: none; }

/* ---- サマリーカード ---- */
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.summary-card { background: #fff; border-radius: 8px; padding: 16px; text-align: center; }
.summary-card .num { font-size: 28px; font-weight: 700; }
.summary-card .label { font-size: 12px; color: #999; margin-top: 4px; }
.summary-card.warn .num { color: #ff9800; }
.summary-card.ok .num { color: #4caf50; }

/* ---- セクション ---- */
.section { background: #fff; border-radius: 8px; margin-bottom: 20px; overflow: hidden; }
.section-header { padding: 16px 20px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; }
.section-header h2 { font-size: 16px; font-weight: 600; }
.section-header .badge { background: #ff9800; color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 10px; }
.section-header .sub { font-size: 12px; color: #999; }

/* ---- テーブル ---- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 16px; font-size: 12px; color: #999; font-weight: 500; border-bottom: 1px solid #eee; background: #fafafa; }
td { padding: 12px 16px; font-size: 14px; border-bottom: 1px solid #f5f5f5; }
tr:last-child td { border-bottom: none; }
.item-link { color: #333; text-decoration: none; font-weight: 500; }
.item-link:hover { color: #ff5252; }
.price { font-weight: 600; }
.days { font-weight: 600; }
.days.over { color: #ff5252; }
.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 500; }
.tag.alert { background: #fff3e0; color: #e65100; }
.tag.safe { background: #e8f5e9; color: #2e7d32; }
.tag.action-above { background: #e3f2fd; color: #1565c0; }
.tag.action-below { background: #fce4ec; color: #c62828; }

/* ---- スヌーズ/除外ボタン ---- */
.action-cell { white-space: nowrap; }
.btn-snooze, .btn-dismiss { border: none; background: none; cursor: pointer; font-size: 16px; padding: 4px 6px; border-radius: 4px; opacity: 0.6; transition: opacity 0.15s; }
.btn-snooze:hover { opacity: 1; background: #e3f2fd; }
.btn-dismiss:hover { opacity: 1; background: #fce4ec; }
.btn-snooze:disabled, .btn-dismiss:disabled { opacity: 0.3; cursor: not-allowed; }
.action-status { padding: 8px 20px; font-size: 12px; color: #999; }
.action-status:empty { padding: 0; }
.hidden-toggle { padding: 10px 20px; font-size: 13px; color: #666; cursor: pointer; border-top: 1px solid #eee; }
.hidden-toggle:hover { color: #ff5252; background: #fafafa; }
.btn-restore { border: 1px solid #ddd; background: #fff; padding: 4px 12px; border-radius: 4px; font-size: 12px; color: #666; cursor: pointer; }
.btn-restore:hover { background: #e8f5e9; color: #2e7d32; border-color: #4caf50; }

/* ---- ソート可能ヘッダー ---- */
.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.sortable:hover { color: #ff5252; }
.sortable::after { content: " ⇅"; font-size: 10px; color: #ccc; }
.sortable.sort-asc::after { content: " ▲"; color: #ff5252; }
.sortable.sort-desc::after { content: " ▼"; color: #ff5252; }

/* ---- 通知履歴 ---- */
.notif-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid #f5f5f5; }
.notif-row:last-child { border-bottom: none; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.notif-time { font-size: 12px; color: #999; flex-shrink: 0; }
.notif-text { font-size: 13px; flex: 1; }

/* ---- 設定ページ ---- */
.settings-form { padding: 24px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-group .hint { font-size: 12px; color: #999; margin-bottom: 6px; }
.form-group .hint.set { color: #4caf50; font-weight: 600; }
.form-group .hint.unset { color: #e53935; font-weight: 600; }
.form-group input { width: 100%; max-width: 500px; padding: 10px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
.form-group input:focus { outline: none; border-color: #ff5252; }
.btn-line { padding: 8px 20px; background: #06c755; color: #fff; border: none; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-line:hover { background: #05b34c; }
.btn-line:disabled { background: #ccc; cursor: not-allowed; }
.btn-save { padding: 10px 32px; background: #ff5252; color: #fff; border: none; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-save:hover { background: #e04848; }
.save-result { margin-top: 12px; font-size: 13px; display: none; }
.save-result.ok { color: #4caf50; }
.save-result.ng { color: #e53935; }

/* ---- 解除ボタン ---- */
.btn-unlink { padding: 4px 12px; background: none; border: 1px solid #e53935; color: #e53935; border-radius: 4px; font-size: 12px; cursor: pointer; margin-left: 8px; }
.btn-unlink:hover { background: #fce4ec; }
.btn-unlink:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- トグルスイッチ ---- */
.toggle { position: relative; display: inline-block; width: 48px; height: 26px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #ccc; border-radius: 26px; transition: 0.3s; }
.toggle-slider::before { content: ""; position: absolute; height: 20px; width: 20px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.3s; }
.toggle input:checked + .toggle-slider { background: #e53935; }
.toggle input:checked + .toggle-slider::before { transform: translateX(22px); }

/* ---- デバッグ ---- */
.btn-trigger { padding: 8px 20px; background: #ff9800; color: #fff; border: none; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-trigger:hover { background: #f57c00; }
.btn-trigger:disabled { background: #ccc; cursor: not-allowed; }

/* ---- ローディング ---- */
.loading { text-align: center; padding: 40px; color: #999; font-size: 14px; }
.empty { text-align: center; padding: 40px; color: #bbb; font-size: 14px; }

/* ---- 講師: 受講者カードグリッド ---- */
.user-card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.user-card { display: block; background: #fff; border-radius: 8px; padding: 20px; text-decoration: none; color: #333; transition: box-shadow 0.15s, transform 0.15s; border: 1px solid #eee; }
.user-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); transform: translateY(-2px); }
.user-card-name { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.user-card-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #999; }
.user-card-seller { color: #999; }
.user-card-slot { color: #666; font-weight: 500; }
.status-badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 500; }
.status-badge.status-active { background: #e8f5e9; color: #2e7d32; }
.status-badge.status-dunning { background: #fff3e0; color: #e65100; }
.status-badge.status-inactive { background: #fce4ec; color: #c62828; }

/* ---- 講師: 受講者ダッシュボードヘッダー ---- */
.instructor-header { margin-bottom: 20px; }
.instructor-header h1 { font-size: 20px; font-weight: 600; margin-top: 8px; }
.back-link { font-size: 13px; color: #666; text-decoration: none; }
.back-link:hover { color: #ff5252; }

/* ---- マスター: 時間帯バーチャート ---- */
.hour-chart { padding: 16px 20px; }
.hour-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.hour-label { font-size: 12px; color: #999; width: 44px; text-align: right; flex-shrink: 0; }
.hour-fill-bg { flex: 1; background: #f5f5f5; border-radius: 4px; height: 22px; }
.hour-fill { height: 100%; border-radius: 4px; transition: width 0.3s; min-width: 2px; }
.hour-fill.normal { background: #ff5252; }
.hour-fill.high { background: #ff9800; }
.hour-fill.peak { background: #e53935; }
.hour-count { font-size: 12px; color: #666; width: 80px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.peak-badge { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 3px; background: #fff3e0; color: #e65100; font-weight: 600; margin-left: 2px; }

/* ---- マスター: ステータスインジケーター ---- */
.status-indicator { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.status-indicator.safe { background: #e8f5e9; color: #2e7d32; }
.status-indicator.caution { background: #fff3e0; color: #e65100; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-indicator.safe .status-dot { background: #4caf50; }
.status-indicator.caution .status-dot { background: #ff9800; }

/* ---- マスター: トレンドテーブル ---- */
.num-cell { font-variant-numeric: tabular-nums; text-align: right; }
.num-header { text-align: right; }
.trend-peak { color: #ff9800; font-weight: 600; }
.trend-today { background: #fffde7; }

/* ---- マスター: 注記 ---- */
.note { padding: 12px 20px; font-size: 12px; color: #999; border-top: 1px solid #f5f5f5; }

/* ---- ハンバーガーボタン (min 44x44 touch target) ---- */
.hamburger { display: none; background: none; border: 1px solid #e0e0e0; border-radius: 8px; cursor: pointer; width: 44px; height: 44px; padding: 0; transition: background 0.2s; flex-shrink: 0; }
.hamburger:hover { background: #f5f5f5; }
.hamburger:active { background: #eee; }
.hamburger span { display: block; width: 18px; height: 2px; background: #555; margin: 4px auto; border-radius: 2px; transition: transform 0.25s, opacity 0.2s; }
.hamburger.active span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }

/* ---- モバイルメニュー オーバーレイ ---- */
.mobile-menu-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); z-index: 999; opacity: 0; pointer-events: none; transition: opacity 0.25s ease; }
.mobile-menu-overlay.active { opacity: 1; pointer-events: auto; }

/* ---- モバイルメニュー ドロワーパネル ---- */
.mobile-menu { display: none; position: fixed; top: 0; right: 0; width: 280px; max-width: 85vw; height: 100%; background: #fff; z-index: 1000; overflow-y: auto; -webkit-overflow-scrolling: touch; transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); transform: translateX(100%); box-shadow: -4px 0 24px rgba(0,0,0,0.08); }
.mobile-menu.active { transform: translateX(0); }

/* ドロワーヘッダー */
.mm-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #eee; }
.mm-logo { font-size: 16px; font-weight: 700; color: #ff5252; display: flex; align-items: center; gap: 8px; }
.mm-logo .logo-icon { width: 26px; height: 26px; border-radius: 6px; object-fit: cover; }
.mm-close { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; background: none; border: none; border-radius: 50%; font-size: 22px; color: #999; cursor: pointer; transition: background 0.2s, color 0.2s; }
.mm-close:hover { background: #f5f5f5; color: #333; }

/* セクションラベル */
.mm-nav-label { font-size: 11px; font-weight: 600; color: #bbb; letter-spacing: 0.5px; padding: 20px 20px 8px; }

/* ナビリンク (min 44px touch target) */
.mm-nav { display: block; padding-bottom: 4px; }
.mm-link { display: block; min-height: 44px; padding: 12px 20px; font-size: 15px; font-weight: 500; color: #333; text-decoration: none; line-height: 20px; transition: background 0.15s, color 0.15s; }
.mm-link:active { background: #f5f5f5; }
.mm-link.active { color: #ff5252; font-weight: 600; }
.mm-link[data-roles] { display: none; }

/* ユーザーエリア */
.mm-user { margin-top: 8px; padding: 0 20px 24px; border-top: 1px solid #eee; }
.mm-user-email { font-size: 13px; color: #888; word-break: break-all; line-height: 1.5; padding: 4px 0 0; }
.mm-logout { display: block; width: 100%; min-height: 44px; margin-top: 16px; padding: 12px; background: none; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; color: #666; cursor: pointer; transition: background 0.2s, border-color 0.2s, color 0.2s; text-align: center; }
.mm-logout:hover { background: #fce4ec; border-color: #ef9a9a; color: #c62828; }
.mm-login-link { display: block; min-height: 44px; padding: 12px; background: #ff5252; color: #fff; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; text-decoration: none; text-align: center; line-height: 20px; transition: background 0.2s; }
.mm-login-link:hover { background: #e04848; }

/* ---- レスポンシブ ---- */
@media (max-width: 900px) {
  .user-card-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .hamburger { display: block; }
  .mobile-menu, .mobile-menu-overlay { display: block; }
  nav .nav-links { display: none; }
  nav .user-area { display: none; }
}
@media (max-width: 600px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
  th, td { padding: 8px 10px; font-size: 12px; }
  .login-box { padding: 24px; margin: 0 16px; }
  nav { padding: 12px 16px; }
  .user-card-grid { grid-template-columns: 1fr; }
}
