/* ============================================================
   点呼チェッ君 管理画面スタイル v1.6.7
   - slate＋indigoを基調にした、明暗テーマ対応のモダンUI
   - 既存クラス名は互換維持（全ページ共通）
   ============================================================ */
:root {
  color-scheme: light;
  --bg:        #eef2f6;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --text:      #0f172a;
  --text-soft: #334155;
  --text-mid:  #475569;
  --muted:     #64748b;
  --border:    #e2e8f0;
  --border-2:  #cbd5e1;
  --accent:    #4f46e5;
  --accent-d:  #4338ca;
  --accent-sf: #eef2ff;
  --ok:        #059669;
  --ok-bg:     #dcfce7;
  --warn:      #b45309;
  --warn-bg:   #fef3c7;
  --danger:    #dc2626;
  --danger-bg: #fee2e2;
  --info:      #1d4ed8;
  --info-bg:   #dbeafe;
  --on-accent: #ffffff;
  --on-danger: #ffffff;
  --neutral-bg:#e2e8f0;
  --topbar:    rgba(15,23,42,.94);
  --code-bg:   #0f172a;
  --code-text: #e2e8f0;
  --glow-1:    rgba(79,70,229,.10);
  --glow-2:    rgba(14,165,233,.07);
  --radius:    14px;
  --radius-s:  9px;
  --shadow:    0 1px 2px rgba(15,23,42,.05), 0 8px 28px rgba(15,23,42,.07);
  --shadow-lg: 0 10px 40px rgba(15,23,42,.18);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #080d17; --surface: #111827; --surface-2: #182235;
  --text: #eef2ff; --text-soft: #dbe4f3; --text-mid: #c0cbda; --muted: #94a3b8;
  --border: #263449; --border-2: #3a4a61;
  --accent: #8b83ff; --accent-d: #a49eff; --accent-sf: rgba(139,131,255,.14);
  --ok: #34d399; --ok-bg: rgba(16,185,129,.16);
  --warn: #fbbf24; --warn-bg: rgba(245,158,11,.16);
  --danger: #fb7185; --danger-bg: rgba(244,63,94,.16);
  --info: #93c5fd; --info-bg: rgba(59,130,246,.16);
  --on-accent: #080d17; --on-danger: #080d17;
  --neutral-bg: #263449; --topbar: rgba(5,10,20,.92);
  --code-bg: #050914; --code-text: #dbeafe;
  --glow-1: rgba(139,131,255,.13); --glow-2: rgba(14,165,233,.08);
  --shadow: 0 1px 2px rgba(0,0,0,.25), 0 12px 32px rgba(0,0,0,.22);
  --shadow-lg: 0 16px 48px rgba(0,0,0,.42);
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --bg: #080d17; --surface: #111827; --surface-2: #182235;
    --text: #eef2ff; --text-soft: #dbe4f3; --text-mid: #c0cbda; --muted: #94a3b8;
    --border: #263449; --border-2: #3a4a61;
    --accent: #8b83ff; --accent-d: #a49eff; --accent-sf: rgba(139,131,255,.14);
    --ok: #34d399; --ok-bg: rgba(16,185,129,.16);
    --warn: #fbbf24; --warn-bg: rgba(245,158,11,.16);
    --danger: #fb7185; --danger-bg: rgba(244,63,94,.16);
    --info: #93c5fd; --info-bg: rgba(59,130,246,.16);
    --on-accent: #080d17; --on-danger: #080d17;
    --neutral-bg: #263449; --topbar: rgba(5,10,20,.92);
    --code-bg: #050914; --code-text: #dbeafe;
    --glow-1: rgba(139,131,255,.13); --glow-2: rgba(14,165,233,.08);
    --shadow: 0 1px 2px rgba(0,0,0,.25), 0 12px 32px rgba(0,0,0,.22);
    --shadow-lg: 0 16px 48px rgba(0,0,0,.42);
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: radial-gradient(circle at 5% 0, var(--glow-1), transparent 34rem),
                    radial-gradient(circle at 95% 18%, var(--glow-2), transparent 32rem);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent);
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}
.skip-link {
  position: fixed; left: 12px; top: -80px; z-index: 100;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-s); padding: 9px 14px; box-shadow: var(--shadow-lg);
}
.skip-link:focus { top: 10px; }
.visually-hidden {
  position: absolute !important; width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important; overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important; clip-path: inset(50%) !important;
  white-space: nowrap !important; border: 0 !important;
}

/* ---- トップバー ---- */
.topbar {
  background: var(--topbar);
  backdrop-filter: saturate(150%) blur(16px);
  -webkit-backdrop-filter: saturate(150%) blur(16px);
  color: #e2e8f0;
  padding: 0 20px;
  border-bottom: 1px solid rgba(148,163,184,.15);
  box-shadow: 0 6px 28px rgba(0,0,0,.12);
  position: sticky; top: 0; z-index: 30;
}
.topbar-row { min-height: 52px; display: flex; align-items: center; gap: 16px; }
.topbar .brand {
  font-weight: 700; font-size: 15px; letter-spacing: .02em;
  padding: 12px 20px 12px 0; color: #fff;
  display: flex; align-items: center; gap: 8px;
}
.topbar .brand:hover { text-decoration: none; }
.topbar .brand::before {
  content: ""; width: 9px; height: 9px; border-radius: 50%;
  background: #34d399; box-shadow: 0 0 0 3px rgba(52,211,153,.25);
}
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.desktop-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; border-top: 1px solid rgba(148,163,184,.10); }
.nav-group { display: flex; align-items: center; gap: 1px; }
.nav-group + .nav-group { margin-left: 8px; padding-left: 10px; border-left: 1px solid rgba(148,163,184,.22); }
.nav-group-label { color: #64748b; font-size: 10px; font-weight: 700; margin-right: 2px; }
.topbar a {
  color: #a8b5c7; padding: 10px 9px; font-size: 12.5px;
  border-bottom: 2px solid transparent; transition: color .15s, border-color .15s;
}
.topbar a:hover { color: #fff; text-decoration: none; }
.topbar a.active { color: #fff; border-bottom-color: var(--accent); }
.topbar .logout { margin-left: 10px; color: #fca5a5; }
.topbar .logout:hover { color: #fecaca; }
.verinfo { color: #94a3b8; font-size: 11px; }
.theme-toggle {
  min-height: 32px; padding: 5px 10px; border: 1px solid rgba(148,163,184,.28);
  border-radius: 999px; background: rgba(255,255,255,.07); color: #e2e8f0;
  font-size: 11.5px; box-shadow: none;
}
.theme-toggle:hover { background: rgba(255,255,255,.14); }
.mobile-tabbar { display: none; }

.warnbar {
  background: var(--danger-bg); border-bottom: 1px solid var(--danger);
  color: var(--danger); padding: 10px 16px; text-align: center; font-size: 13px;
}
.warnbar a { color: inherit; font-weight: 700; }

main { max-width: 1180px; margin: 0 auto; padding: 26px 20px 60px; }
h1 { font-size: 22px; font-weight: 700; margin: 4px 0 20px; letter-spacing: .01em; }
h2 { font-size: 15px; font-weight: 700; margin: 0; color: var(--text-soft); }
h3 { font-size: 16px; font-weight: 700; margin: 0 0 4px; }

/* ---- 見出し行（タイトル＋ツール） ---- */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 30px 0 12px; flex-wrap: wrap;
}
.section-head:first-of-type { margin-top: 8px; }
.section-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 12.5px; margin: 0 0 12px; }

/* ---- 統計バー ---- */
.statbar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.stat {
  flex: 1 1 120px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px;
}
.stat-num { font-size: 26px; font-weight: 800; line-height: 1.1; color: var(--accent); }
.stat-lbl { font-size: 12px; color: var(--muted); }

/* ---- テーブル ---- */
.tablewrap {
  min-width: 0; max-width: 100%;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
table { border-collapse: collapse; width: 100%; background: var(--surface); }
table.sheet, .tablewrap > table { border-radius: var(--radius); overflow: hidden; }
th, td { padding: 11px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
th {
  background: var(--surface-2); color: var(--text-mid); font-weight: 600; font-size: 12px;
  letter-spacing: .02em; white-space: nowrap; position: sticky; top: 0;
}
tbody tr { transition: background .12s; }
tbody > tr:hover > td { background: var(--accent-sf); }
tr:last-child > td { border-bottom: none; }
td.center, th.center { text-align: center; }
td.muted, .muted { color: var(--muted); }
td.mono, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }

/* 素の table（tablewrap で包まれていないページ）にも枠と影を付与 */
main > table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

.mname { font-weight: 600; }
.sub { display: block; font-size: 11.5px; color: var(--muted); }
.sub.note { color: #94a3b8; }
.members-list-table td[data-label="LINE"] > div { padding: 3px 0; overflow-wrap: anywhere; }
.members-list-table td[data-label="LINE"] > div + div { margin-top: 5px; padding-top: 8px; border-top: 1px dashed var(--border); }

/* ---- バッジ ---- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; line-height: 1.5;
}
.b-pending { background: var(--danger-bg); color: var(--danger); }
.b-text    { background: var(--info-bg);   color: var(--info); }
.b-image   { background: var(--ok-bg);     color: var(--ok); }
.b-warn    { background: var(--warn-bg);   color: var(--warn); }
.b-danger  { background: var(--danger-bg); color: var(--danger); font-weight: 700; }
.b-muted   { background: var(--neutral-bg); color: var(--text-mid); }

/* 有効/無効ドット */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.dot.on  { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.dot.off { background: #cbd5e1; }

/* ---- チップ（表記ゆれ） ---- */
.aliascell { min-width: 180px; }
.chip {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 4px 2px 10px; margin: 2px 3px 2px 0;
  font-size: 12px; color: var(--text-soft);
}
.chip-x {
  background: none; border: none; color: #94a3b8; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0 4px; min-height: 0;
}
.chip-x:hover { color: var(--danger); background: none; }
.chip-add input { width: 76px; padding: 4px 8px; font-size: 12px; }

/* ---- 管理者トグル ---- */
.toggle {
  border: 1px solid var(--border-2); border-radius: 999px; padding: 5px 14px;
  font-size: 12px; font-weight: 600; cursor: pointer; min-height: 0; line-height: 1.4;
}
.toggle.on  { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.toggle.on:hover  { background: var(--accent-d); }
.toggle.off { background: var(--surface); color: var(--muted); }
.toggle.off:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-sf); }

/* ---- フォーム要素 ---- */
form.inline { display: inline; }
label { font-size: 13px; }
input, select, textarea {
  min-width: 0; max-width: 100%;
  padding: 8px 11px; border: 1px solid var(--border-2); border-radius: var(--radius-s);
  font-size: 14px; background: var(--surface); color: var(--text);
  font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-sf);
}
input[type="search"] { min-width: 200px; }

button {
  padding: 8px 16px; border: 1px solid transparent; border-radius: var(--radius-s);
  background: var(--accent); color: var(--on-accent); cursor: pointer; font-size: 13px; font-weight: 600;
  transition: background .15s, box-shadow .15s, border-color .15s; font-family: inherit;
}
button:hover { background: var(--accent-d); }
button.small  { padding: 5px 11px; font-size: 12px; }
button.danger { background: var(--danger); color: var(--on-danger); }
button.danger:hover { background: var(--danger); filter: brightness(.88); }
button.gray   { background: var(--neutral-bg); color: var(--text-soft); }
button.gray:hover { filter: brightness(.96); }
button.ghost {
  background: var(--surface); color: var(--accent); border-color: var(--border-2);
}
button.ghost:hover { background: var(--accent-sf); border-color: var(--accent); }

/* ---- カード ---- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover { transform: translateY(-1px); border-color: var(--border-2); }

/* ---- フラッシュ通知 ---- */
.flash {
  background: var(--ok-bg); border: 1px solid #86efac; color: #14532d;
  padding: 12px 16px; margin-bottom: 18px; border-radius: var(--radius-s);
  display: flex; align-items: center; gap: 8px; font-weight: 500;
}
.flash::before { content: "✓"; font-weight: 800; color: var(--ok); }
.flash.error {
  background: var(--danger-bg); border-color: #fca5a5; color: #7f1d1d;
}
.flash.error::before { content: "!"; color: var(--danger); }

/* ---- 設定画面 ---- */
.settings-section { margin-bottom: 22px; }
.settings-section h3 { margin-bottom: 4px; }
.settings-table td:first-child { width: 48%; font-weight: 600; color: var(--text-soft); }
.settings-table input[type="number"] { width: 90px; }
.setting-help { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.advanced-settings {
  margin: 18px 0; border: 1px solid var(--border); border-radius: var(--radius-s);
  background: var(--surface-2); overflow: hidden;
}
.advanced-settings summary {
  padding: 12px 14px; cursor: pointer; font-weight: 700; color: var(--text-mid);
}
.advanced-settings[open] summary { border-bottom: 1px solid var(--border); }
.advanced-settings .advanced-body { padding: 14px; }
.admin-edit-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 12px; align-items: end;
}
.admin-edit-grid label { display: flex; flex-direction: column; gap: 4px; color: var(--text-mid); font-weight: 600; }
.admin-edit-grid .wide { grid-column: 1 / -1; }
.admin-edit-grid .checkline { flex-direction: row; align-items: center; }
.admin-card-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.admin-card-head .note { margin: 0; }

/* ---- モーダル（native dialog） ---- */
dialog.modal {
  border: none; border-radius: 16px; padding: 0; box-shadow: var(--shadow-lg);
  width: min(92vw, 460px); color: var(--text); background: var(--surface);
}
dialog.modal::backdrop { background: rgba(15,23,42,.5); backdrop-filter: blur(2px); }
.modal-form { padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.modal-form h3 { margin-bottom: 6px; }
.modal-form label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; color: var(--text-mid); font-size: 12.5px; }
.modal-form label input, .modal-form label textarea { font-weight: 400; color: var(--text); }
.modal-form .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-form label.chk { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); }

/* ---- 画像・比較（images/analysis） ---- */
.thumb { max-width: 120px; max-height: 120px; border: 1px solid var(--border); border-radius: var(--radius-s); }
.compare { display: flex; gap: 16px; flex-wrap: wrap; }
.compare figure { margin: 0; text-align: center; }
.compare img { max-width: 380px; max-height: 380px; border: 1px solid var(--border); border-radius: var(--radius-s); }

/* ---- ログイン ---- */
.login-box {
  max-width: 380px; margin: 72px auto; background: var(--surface);
  padding: 32px; border-radius: 16px; border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.login-box label { display: block; margin-top: 14px; font-weight: 700; color: var(--text-mid); }
.login-box input { width: 100%; margin-top: 6px; }
.login-box button { width: 100%; margin-top: 20px; padding: 11px; }
.error { color: var(--danger); }

/* ---- 補助 ---- */
.note { color: var(--muted); font-size: 12px; }
.filter { margin-bottom: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filter > *, .filter form { min-width: 0; max-width: 100%; }
.filter-form {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; width: 100%;
}
.filter-form .log-query { flex: 1 1 260px; width: min(100%, 320px); }
.form-row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.form-row > label {
  display: flex; flex: 1 1 150px; min-width: 0; flex-direction: column; gap: 4px;
  color: var(--text-mid); font-weight: 600;
}
.form-row > label input, .form-row > label select { width: 100%; font-weight: 400; }
.analysis-note { width: min(100%, 580px); resize: vertical; }
.copy { background: var(--code-bg); color: var(--code-text); padding: 12px 14px; border-radius: var(--radius-s); font-family: ui-monospace, Consolas, monospace; font-size: 13px; word-break: break-all; }
pre.raw { background: var(--code-bg); color: var(--code-text); padding: 14px; border-radius: var(--radius-s); overflow-x: auto; font-size: 12px; max-height: 400px; }
.bulkbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.bulkbar > span { font-size: 13px; color: var(--text-soft); font-weight: 600; }
.bulkbar .bulkhint { margin-left: auto; font-size: 13px; color: var(--text-soft); }

/* ---- 日付・並び順ナビ ---- */
.date-nav {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.date-step, .date-today {
  display: inline-flex; align-items: center; justify-content: center; min-height: 38px;
  border: 1px solid var(--border); border-radius: var(--radius-s); padding: 6px 11px;
  background: var(--surface-2); color: var(--text-soft); font-weight: 650;
}
.date-step:hover, .date-today:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.date-picker { display: flex; align-items: end; gap: 7px; }
.date-picker label { display: flex; align-items: center; gap: 7px; }
.date-label { color: var(--muted); font-size: 11.5px; font-weight: 650; }
.date-picker input { min-height: 38px; }
.date-submit { min-height: 38px; padding: 6px 13px; }
.date-today { color: var(--accent); background: var(--accent-sf); border-color: transparent; }
.date-readable { margin-left: auto; color: var(--text-soft); font-size: 13px; white-space: nowrap; }
.sort-switch {
  display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface-2);
}
.sort-switch a { padding: 5px 11px; border-radius: 999px; color: var(--muted); font-size: 12px; font-weight: 650; }
.sort-switch a:hover { text-decoration: none; color: var(--accent); }
.sort-switch a.active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 4px rgba(15,23,42,.12); }
.source-order-note { display: flex; gap: 7px; align-items: flex-start; color: var(--muted); font-size: 12px; margin: -4px 0 12px; }
.row-number { color: var(--muted); font-variant-numeric: tabular-nums; text-align: center; }

/* ---- ダッシュボード監視UI ---- */
.dashboard-page { min-width: 0; max-width: 100%; }
.dashboard-overview {
  display: flex; align-items: stretch; justify-content: space-between; gap: 12px;
  margin: 0 0 10px; padding: 9px;
  background: linear-gradient(120deg, var(--surface), var(--accent-sf));
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.dashboard-counts {
  display: grid; grid-template-columns: repeat(4, minmax(64px, 1fr));
  gap: 5px; flex: 1 1 auto; min-width: 0;
}
.dashboard-count {
  display: flex; align-items: baseline; justify-content: center; gap: 5px;
  min-width: 0; padding: 5px 8px; border-radius: 10px; color: var(--text-soft);
}
.dashboard-count strong { font-size: 20px; line-height: 1; font-variant-numeric: tabular-nums; color: var(--text); }
.dashboard-count small { font-size: 11px; white-space: nowrap; color: var(--muted); }
.dashboard-count.is-reacted strong { color: var(--ok); }
.dashboard-count.is-pending strong { color: var(--danger); }
.dashboard-count.is-attention strong { color: var(--warn); }
.dashboard-live {
  display: flex; align-items: center; justify-content: flex-end; gap: 7px;
  flex: 0 0 auto; min-width: 225px; padding-left: 12px; border-left: 1px solid var(--border);
  color: var(--text-soft); font-size: 12px;
}
.dashboard-live-dot {
  width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 0 4px var(--ok-bg);
}
.dashboard-live-label { font-weight: 700; }
.dashboard-live time { color: var(--muted); font-variant-numeric: tabular-nums; }
.dashboard-live[data-live-state="updating"] .dashboard-live-dot { animation: dashboard-pulse 1.2s ease-in-out infinite; }
.dashboard-live[data-live-state="stale"] .dashboard-live-dot,
.dashboard-live[data-live-state="error"] .dashboard-live-dot { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-bg); }
.dashboard-live[data-live-state="stale"] .dashboard-live-label,
.dashboard-live[data-live-state="error"] .dashboard-live-label { color: var(--danger); }
@keyframes dashboard-pulse { 50% { opacity: .42; transform: scale(.82); } }

.attendance-watch {
  margin: 0 0 10px; padding: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.attendance-watch-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.attendance-watch-heading h2 { margin: 0 0 3px; color: var(--text); font-size: 15px; }
.attendance-watch-heading p { margin: 0; color: var(--muted); font-size: 11.5px; }
.attendance-watch-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.attendance-watch-group {
  min-width: 0; overflow: hidden; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-s);
}
.attendance-watch-group > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 58px; padding: 8px 10px; border-bottom: 1px solid var(--border);
  cursor: pointer; list-style: none;
}
.attendance-watch-group > summary::-webkit-details-marker { display: none; }
.attendance-watch-group h3 { margin: 0 0 2px; color: var(--text); font-size: 13px; }
.attendance-watch-group summary p { margin: 0; color: var(--muted); font-size: 10.5px; line-height: 1.35; }
.attendance-watch-group.is-not-attended > summary { background: linear-gradient(110deg, var(--danger-bg), transparent 72%); }
.attendance-watch-group.is-out-of-scope > summary { background: linear-gradient(110deg, var(--neutral-bg), transparent 72%); }
.attendance-watch-count {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  min-width: 31px; height: 31px; padding: 0 7px; border-radius: 999px;
  color: var(--text); background: var(--surface); border: 1px solid var(--border);
  font-size: 15px; font-variant-numeric: tabular-nums;
}
.is-not-attended .attendance-watch-count { color: var(--danger); }
.attendance-watch-list { max-height: 310px; overflow-y: auto; overscroll-behavior: contain; }
.attendance-watch-item { padding: 9px 10px; background: var(--surface); }
.attendance-watch-item + .attendance-watch-item { border-top: 1px solid var(--border); }
.attendance-watch-person { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.attendance-watch-person strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.attendance-watch-person .badge { flex: 0 0 auto; }
.attendance-watch-meta {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px;
  margin: 7px 0 0; color: var(--text-soft); font-size: 11px;
}
.attendance-watch-meta > div { display: flex; min-width: 0; gap: 4px; }
.attendance-watch-meta dt { flex: 0 0 auto; color: var(--muted); }
.attendance-watch-meta dd { min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.attendance-watch-reason { margin: 6px 0 0; overflow-wrap: anywhere; color: var(--text-soft); font-size: 11px; line-height: 1.45; }
.attendance-watch-reason span { margin-right: 6px; color: var(--muted); }
.attendance-watch-empty { margin: 0; padding: 18px 10px; color: var(--muted); text-align: center; font-size: 12px; }

.dashboard-quota {
  margin: 0 0 10px; color: var(--text-soft); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-s); box-shadow: var(--shadow);
}
.dashboard-quota summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 40px; padding: 7px 12px; cursor: pointer; font-size: 12.5px; list-style: none;
}
.dashboard-quota summary::-webkit-details-marker { display: none; }
.dashboard-quota summary::after { content: "詳細⌄"; color: var(--muted); font-size: 11px; }
.dashboard-quota[open] summary::after { content: "閉じる⌃"; }
.dashboard-quota-remaining { margin-left: auto; color: var(--muted); }
.dashboard-quota p { margin: 0; padding: 9px 12px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.dashboard-quota-error { padding: 9px 12px; color: var(--danger); font-size: 12px; }
.dashboard-controls {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-width: 0; margin-bottom: 9px;
}
.pending-only-toggle {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px; padding: 5px 10px; color: var(--text-soft); background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px; cursor: pointer; font-weight: 650;
}
.pending-only-count {
  min-width: 23px; padding: 1px 6px; border-radius: 999px; text-align: center;
  color: var(--danger); background: var(--danger-bg); font-size: 11px; font-variant-numeric: tabular-nums;
}
.dashboard-bulkbar .bulk-select-all,
.dashboard-bulkbar .bulk-selected { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.dashboard-bulkbar .bulk-selected { color: var(--muted); font-size: 12px; }
.dashboard-bulkbar .bulk-selected strong { color: var(--text); font-size: 14px; font-variant-numeric: tabular-nums; }
.bulk-actions-desktop { display: flex; align-items: center; gap: 7px; margin-left: auto; }
.bulk-actions-mobile { display: none; }
.mobile-target-monitor { display: none; }
.dashboard-target-record[hidden] { display: none !important; }

/* ---- 情報・シフト確認 ---- */
.about-hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--surface) 20%, var(--accent-sf));
  border: 1px solid var(--border); border-radius: 20px; padding: 24px; margin-bottom: 22px; box-shadow: var(--shadow);
}
.about-hero::after {
  content: ""; position: absolute; width: 180px; height: 180px; right: -70px; top: -90px;
  border-radius: 50%; background: var(--glow-1); filter: blur(2px); pointer-events: none;
}
.about-hero h2 { font-size: 22px; color: var(--text); margin-bottom: 5px; }
.about-hero p { margin: 0; color: var(--muted); }
.version-pill { display: inline-block; margin-bottom: 10px; padding: 3px 9px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 750; }
.feature-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 12px 0 26px; }
.feature-card { margin: 0; min-height: 150px; }
.feature-card:last-child:nth-child(odd) { grid-column: 1 / -1; min-height: 0; }
.feature-icon { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 10px; background: var(--accent-sf); margin-bottom: 10px; }
.feature-card h3 { font-size: 15px; }
.feature-card p { margin: 6px 0 0; color: var(--muted); }
.command-cell { min-width: 210px; font-weight: 700; color: var(--text-soft); }
.command-old { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 400; }
.operation-steps { counter-reset: step; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 12px 0 26px; }
.operation-step { position: relative; padding-left: 50px; min-height: 90px; margin: 0; }
.operation-step::before {
  counter-increment: step; content: counter(step); position: absolute; left: 14px; top: 17px;
  width: 27px; height: 27px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); font-weight: 800;
}
.operation-step b { display: block; margin-bottom: 4px; }
.shift-review-grid { display: grid; grid-template-columns: minmax(280px, 1.05fr) minmax(420px, 1fr); gap: 16px; align-items: start; }
.shift-preview { margin: 0; position: sticky; top: 116px; }
.shift-preview img { display: block; width: 100%; height: auto; border-radius: var(--radius-s); }
.shift-read-list { min-width: 0; }
.shift-read-list .tablewrap { max-height: 72vh; }

/* ---- 一覧行の直下に開くシフト・写真詳細 ---- */
.review-summary-row { scroll-margin-top: 112px; }
.review-summary-row.is-open > td { background: var(--accent-sf); }
.review-detail-toggle {
  display: inline-flex; align-items: center; justify-content: center; min-height: 32px;
  padding: 4px 9px; border: 1px solid var(--border-2); border-radius: var(--radius-s);
  background: var(--surface); font-size: 12px; font-weight: 700; white-space: nowrap;
}
.review-detail-toggle:hover { background: var(--accent-sf); border-color: var(--accent); text-decoration: none; }
.review-detail-row > td { padding: 0; background: var(--surface-2); }
.review-detail-row:hover > td { background: var(--surface-2); }
.review-detail-panel { min-width: 0; padding: 16px; border-top: 2px solid var(--accent); }
.review-detail-head { margin: 0 0 14px; }
.review-detail-panel > .advanced-settings:last-child { margin-bottom: 0; }
.review-detail-panel .shift-preview { position: static; }
.review-detail-panel .shift-preview img { max-height: 72vh; object-fit: contain; }
.review-analysis-card { margin-bottom: 0; }
.review-analysis-card .compare figure { min-width: 0; flex: 1 1 280px; }

/* ダーク時に残る固定色をテーマ色へ寄せる */
:root[data-theme="dark"] .chip,
:root[data-theme="dark"] button.gray { background: var(--neutral-bg); color: var(--text-soft); }
:root[data-theme="dark"] .flash { color: #a7f3d0; border-color: rgba(52,211,153,.45); }
:root[data-theme="dark"] .flash.error,
:root[data-theme="dark"] .warnbar { color: #fecdd3; border-color: rgba(251,113,133,.45); }
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] .chip,
  :root[data-theme="system"] button.gray { background: var(--neutral-bg); color: var(--text-soft); }
  :root[data-theme="system"] .flash { color: #a7f3d0; border-color: rgba(52,211,153,.45); }
  :root[data-theme="system"] .flash.error,
  :root[data-theme="system"] .warnbar { color: #fecdd3; border-color: rgba(251,113,133,.45); }
}

/* ---- スマホ最適化 ---- */
@media (max-width: 1020px) {
  body { font-size: 15px; }
  main { padding: 16px 12px calc(92px + env(safe-area-inset-bottom)); }
  h1 { font-size: 19px; }
  .topbar { padding: 0 12px; }
  .topbar-row { min-height: 56px; }
  .topbar .brand { white-space: nowrap; padding: 12px 4px 12px 0; font-size: 15px; }
  .desktop-nav { display: none; }
  .top-actions { gap: 7px; }
  .verinfo { font-size: 10px; }
  .theme-toggle { min-height: 36px; padding: 6px 9px; font-size: 11px; }
  .mobile-tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr); align-items: stretch;
    position: fixed; left: 8px; right: 8px; bottom: calc(7px + env(safe-area-inset-bottom)); z-index: 45;
    background: var(--surface);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg);
    backdrop-filter: saturate(160%) blur(18px); -webkit-backdrop-filter: saturate(160%) blur(18px);
    padding: 4px;
  }
  .mobile-tabbar > a, .mobile-more > summary {
    min-height: 48px; display: flex; align-items: center; justify-content: center;
    padding: 5px 4px; border-radius: 12px; color: var(--muted); font-size: 11.5px; font-weight: 700;
    cursor: pointer; text-align: center; list-style: none;
  }
  .mobile-tabbar > a:hover { text-decoration: none; }
  .mobile-tabbar > a.active, .mobile-more.active > summary,
  .mobile-more[open] > summary { background: var(--accent-sf); color: var(--accent); }
  .mobile-more > summary::-webkit-details-marker { display: none; }
  .mobile-more { position: static; }
  .mobile-menu-panel {
    position: absolute; left: 0; right: 0; bottom: calc(100% + 8px);
    display: grid; grid-template-columns: 1fr 1fr; gap: 5px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    padding: 10px; box-shadow: var(--shadow-lg);
  }
  .mobile-more:not([open]) > .mobile-menu-panel { display: none; }
  .mobile-menu-panel a {
    min-height: 44px; display: flex; align-items: center; padding: 8px 11px;
    border-radius: 10px; color: var(--text-soft); font-size: 13px; font-weight: 650;
  }
  .mobile-menu-panel a:hover { background: var(--surface-2); text-decoration: none; }
  .mobile-menu-panel a.active { background: var(--accent-sf); color: var(--accent); }
  .mobile-menu-panel .logout { color: var(--danger); }
  .statbar .stat { flex-basis: calc(50% - 6px); }
  .section-head { align-items: flex-start; }
  input[type="search"] { min-width: 0; width: 100%; }
  th, td { padding: 10px 11px; }
  button { padding: 11px 16px; font-size: 15px; min-height: 44px; }
  button.small, .toggle { padding: 8px 14px; font-size: 13px; min-height: 38px; }
  .chip-x { min-height: 0; }
  input, select, textarea { font-size: 16px; }  /* iOS自動ズーム防止 */
  input[type="checkbox"] { width: 22px; height: 22px; }
  .bulkbar { position: sticky; top: 62px; z-index: 10; }
  .bulkbar .bulkhint { margin-left: 0; }
  .compare img { max-width: 100%; height: auto; }
  .thumb { max-width: 88px; max-height: 88px; }
  dialog.modal { width: 94vw; }
  .modal-form .grid2 { grid-template-columns: 1fr; }
  .settings-table td { display: block; width: 100% !important; border-bottom: 0; padding-bottom: 4px; }
  .settings-table td + td { padding-top: 0; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
  .admin-edit-grid { grid-template-columns: 1fr; }
  .admin-edit-grid .wide { grid-column: auto; }
  .date-nav { padding: 9px; gap: 6px; }
  .date-step, .date-today { min-height: 42px; flex: 1; }
  .date-nav > .date-step:first-child { order: 1; }
  .date-picker + .date-step { order: 3; }
  .date-today { order: 2; }
  .date-picker { order: 5; width: 100%; align-items: end; }
  .date-picker label { flex: 1; align-items: stretch; flex-direction: column; gap: 2px; }
  .date-picker input { width: 100%; min-height: 44px; }
  .date-submit { min-height: 44px; }
  .date-readable { order: 4; width: 100%; margin: 2px 0 0; text-align: center; }
  .sort-switch { width: 100%; }
  .sort-switch a { flex: 1; text-align: center; }
  .feature-grid, .operation-steps { grid-template-columns: 1fr; }
  .feature-card { min-height: 0; }
  .feature-card:last-child:nth-child(odd) { grid-column: auto; }
  .shift-review-grid { grid-template-columns: 1fr; }
  .shift-preview { position: static; }
  .shift-read-list .tablewrap { max-height: none; }
  th { position: static; }
  .login-box { width: calc(100% - 24px); margin: 24px auto; padding: 24px; }
  .tablewrap .sticky-name {
    position: sticky; left: 0; z-index: 2; background: var(--surface);
    box-shadow: 1px 0 0 var(--border);
  }
  .tablewrap th.sticky-name { z-index: 3; background: var(--surface-2); }

  /* ダッシュボードは表の横移動ではなく、常時情報を絞った監視リストに切り替える。 */
  .dashboard-page { overflow-x: visible; }
  .dashboard-overview { flex-direction: column; gap: 6px; padding: 7px; }
  .dashboard-counts { width: 100%; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dashboard-count { padding: 4px 3px; flex-direction: column; align-items: center; gap: 2px; }
  .dashboard-count strong { font-size: 19px; }
  .dashboard-count small { font-size: 10.5px; }
  .dashboard-live {
    width: 100%; min-width: 0; min-height: 44px; padding: 4px 0 0;
    justify-content: flex-start; border-left: 0; border-top: 1px solid var(--border);
  }
  .dashboard-live .dashboard-refresh { margin-left: auto; min-height: 44px; }
  .attendance-watch { padding: 9px; }
  .attendance-watch-grid { grid-template-columns: 1fr; }
  .attendance-watch-list { max-height: 270px; }
  .attendance-watch-group > summary { min-height: 56px; border-bottom: 0; }
  .attendance-watch-group[open] > summary { border-bottom: 1px solid var(--border); }
  .dashboard-quota summary { min-height: 44px; }
  .dashboard-controls { align-items: stretch; }
  .dashboard-controls .sort-switch { width: auto; flex: 1 1 auto; min-width: 0; }
  .pending-only-toggle { min-height: 44px; flex: 0 0 auto; }

  .dashboard-bulkbar {
    min-height: 52px; flex-wrap: nowrap; gap: 8px; padding: 5px 8px;
  }
  .dashboard-bulkbar .bulk-selected { margin-right: auto; }
  .bulk-actions-desktop { display: none; }
  .bulk-actions-mobile { display: block; position: relative; flex: 0 0 auto; }
  .bulk-actions-mobile > summary {
    display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
    padding: 7px 11px; border: 1px solid var(--border-2); border-radius: var(--radius-s);
    color: var(--accent); background: var(--surface); font-size: 13px; font-weight: 700;
    cursor: pointer; list-style: none; white-space: nowrap;
  }
  .bulk-actions-mobile > summary::-webkit-details-marker { display: none; }
  .bulk-actions-mobile[open] > summary { background: var(--accent-sf); border-color: var(--accent); }
  .bulk-action-menu {
    position: absolute; z-index: 24; right: 0; top: calc(100% + 7px); width: min(254px, calc(100vw - 24px));
    display: grid; grid-template-columns: 1fr 1fr; gap: 7px; padding: 9px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
  }
  .bulk-action-menu button.small { min-height: 44px; }

  .desktop-target-table { display: none; }
  .mobile-target-monitor { display: grid; width: 100%; min-width: 0; gap: 7px; }
  .monitor-card {
    --monitor-accent: var(--border-2); --monitor-tint: var(--surface-2);
    position: relative; display: grid;
    grid-template-columns: 24px minmax(0, 1fr) 44px;
    grid-template-areas: "check primary expand" "check secondary expand" "panel panel panel";
    align-items: center; gap: 3px 6px; width: 100%; min-width: 0; min-height: 66px;
    padding: 7px 8px 7px 10px; overflow: hidden;
    color: var(--text); background-color: var(--surface);
    background-image: linear-gradient(100deg, var(--monitor-tint), transparent 34%);
    border: 1px solid var(--border); border-radius: 11px; box-shadow: var(--shadow);
  }
  .monitor-card::before {
    content: ""; position: absolute; inset: 0 auto 0 0; width: 4px;
    background: var(--monitor-accent);
  }
  .monitor-card::after {
    content: ""; position: absolute; z-index: 0; inset: 0 0 auto 4px; height: 1px;
    background: linear-gradient(90deg, rgba(255,255,255,.20), transparent 70%); pointer-events: none;
  }
  .monitor-card.status-pending { --monitor-accent: var(--danger); --monitor-tint: var(--danger-bg); }
  .monitor-card.status-text_reported { --monitor-accent: var(--info); --monitor-tint: var(--info-bg); }
  .monitor-card.status-image_reported,
  .monitor-card.status-completed { --monitor-accent: var(--ok); --monitor-tint: var(--ok-bg); }
  .monitor-card.status-unknown { --monitor-accent: var(--warn); --monitor-tint: var(--warn-bg); }
  .monitor-card.status-stopped,
  .monitor-card.status-cancelled { --monitor-accent: var(--muted); --monitor-tint: var(--neutral-bg); }
  .monitor-card.is-expanded { border-color: var(--monitor-accent); }
  .monitor-check {
    grid-area: check; align-self: stretch; display: flex; align-items: center; justify-content: center;
    min-width: 0; cursor: pointer;
  }
  .monitor-check input { margin: 0; }
  .monitor-primary {
    grid-area: primary; display: flex; align-items: center; gap: 5px; min-width: 0;
  }
  .monitor-position {
    flex: 0 0 auto; min-width: 22px; color: var(--muted); font-size: 11px;
    font-weight: 750; font-variant-numeric: tabular-nums; text-align: center;
  }
  .monitor-name {
    flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 14px; line-height: 1.3;
  }
  .monitor-status { flex: 0 0 auto; min-width: 0; }
  .monitor-card .badge { max-width: 100%; padding: 2px 7px; font-size: 10.5px; }
  .monitor-secondary {
    grid-area: secondary; display: grid; grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center; gap: 6px; min-width: 0; color: var(--text-soft); font-size: 11px;
  }
  .monitor-timing { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; white-space: nowrap; }
  .monitor-timing > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .monitor-timing b { color: var(--muted); font-size: 10px; }
  .monitor-report { min-width: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
  .last-report-value { display: inline-flex; align-items: center; gap: 3px; }
  .report-type-icon { font-size: 11px; }
  .monitor-photo { min-width: 0; white-space: nowrap; }
  .monitor-expand {
    grid-area: expand; align-self: stretch; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 0; width: 44px; min-width: 44px; min-height: 44px;
    padding: 2px; color: var(--muted); background: transparent; border: 1px solid transparent; box-shadow: none;
  }
  .monitor-expand:hover, .monitor-expand:focus-visible { color: var(--accent); background: var(--accent-sf); }
  .monitor-expand-icon { font-size: 18px; line-height: 1; transition: transform .14s ease; }
  .monitor-expand[aria-expanded="true"] .monitor-expand-icon { transform: rotate(180deg); }
  .monitor-expand-label { font-size: 9.5px; line-height: 1.2; }
  .monitor-detail-panel {
    grid-area: panel; position: relative; z-index: 1; display: grid;
    grid-template-columns: minmax(150px, .8fr) minmax(180px, 1.2fr) auto;
    gap: 8px 12px; min-width: 0; margin: 5px -8px -7px -10px; padding: 10px 12px 11px 14px;
    background: var(--surface-2); border-top: 1px solid var(--border);
  }
  .monitor-detail-panel[hidden] { display: none; }
  .monitor-detail-item { min-width: 0; }
  .monitor-detail-label { display: block; margin-bottom: 3px; color: var(--muted); font-size: 10.5px; font-weight: 700; }
  .monitor-phone a {
    display: inline-flex; align-items: center; min-height: 44px; max-width: 100%;
    padding: 5px 9px; overflow-wrap: anywhere; font-weight: 700;
  }
  .monitor-memo p { margin: 0; overflow-wrap: anywhere; color: var(--text-soft); font-size: 12px; }
  .monitor-empty { color: var(--muted); font-size: 12px; }
  .monitor-actions {
    display: grid; grid-template-columns: repeat(2, minmax(72px, 1fr)); align-items: end; gap: 7px; min-width: 0;
  }
  .monitor-actions button { min-height: 44px; }
  .monitor-empty-state {
    padding: 18px; text-align: center; color: var(--muted); background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
  }
}

@media (min-width: 700px) and (max-width: 1020px) {
  .monitor-card {
    grid-template-columns: 26px minmax(210px, .95fr) minmax(320px, 1.45fr) 44px;
    grid-template-areas: "check primary secondary expand" "panel panel panel panel";
    column-gap: 10px; row-gap: 0; min-height: 56px; padding-top: 4px; padding-bottom: 4px;
  }
  .monitor-detail-panel { margin-top: 4px; margin-bottom: -6px; }
}

@media (min-width: 481px) and (max-width: 699px) {
  .monitor-detail-panel { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); }
  .monitor-actions { grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 480px) {
  .attendance-watch-heading p { font-size: 11px; }
  .attendance-watch-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .attendance-watch-meta > div:last-child { grid-column: 1 / -1; }
  .monitor-detail-panel { grid-template-columns: 1fr; }
  .monitor-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 360px) {
  .dashboard-controls { flex-direction: column; }
  .dashboard-controls .sort-switch, .pending-only-toggle { width: 100%; }
  .pending-only-toggle { justify-content: center; }
  .dashboard-bulkbar .bulk-select-all { font-size: 12px; }
  .dashboard-bulkbar .bulk-selected { font-size: 11px; }
}

@media (max-width: 340px) {
  .dashboard-live-label { display: none; }
  .dashboard-live { gap: 5px; }
  .dashboard-live .dashboard-refresh { padding-left: 9px; padding-right: 9px; }
  .dashboard-bulkbar { gap: 5px; }
  .dashboard-bulkbar .bulk-select-all { font-size: 11px; }
  .bulk-actions-mobile > summary { padding-left: 8px; padding-right: 8px; font-size: 12px; }
  .monitor-card { grid-template-columns: 22px minmax(0, 1fr) 44px; column-gap: 4px; }
  .monitor-expand { width: 44px; min-width: 44px; }
  .monitor-primary { gap: 3px; }
  .monitor-name { font-size: 13.5px; }
  .monitor-card .badge { padding-left: 5px; padding-right: 5px; font-size: 10px; }
  .monitor-secondary { gap: 4px; font-size: 10.5px; }
}

.image-row-actions { min-width: 132px; }
.image-row-actions > a { display: inline-flex; margin-bottom: 7px; }
.image-row-exclusion-form { margin: 0; }
.image-row-exclusion-form button { width: 100%; min-height: 36px; padding: 6px 9px; font-size: 12px; }

/* 主要業務表は狭い画面で1件ずつ読めるカードにする。履歴・診断表の横スクロールは維持。 */
@media (max-width: 1020px) {
  .tablewrap.mobile-card-table {
    overflow: visible; background: transparent; border: 0; border-radius: 0; box-shadow: none;
  }
  .mobile-card-table > table,
  .mobile-card-table > table > tbody {
    display: block; width: 100%; background: transparent; overflow: visible;
  }
  .mobile-card-table > table > thead {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%);
    white-space: nowrap; border: 0;
  }
  .mobile-card-table #checkall2 { display: none; }
  .mobile-card-table > table > tbody > tr {
    display: block; width: 100%; margin: 0 0 10px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  }
  .mobile-card-table > table > tbody > tr:last-child { margin-bottom: 0; }
  .mobile-card-table > table > tbody > tr > td {
    display: block; position: relative; min-width: 0; min-height: 42px;
    padding: 9px 12px 9px calc(38% + 10px); border-bottom: 1px solid var(--border);
    text-align: left; overflow-wrap: anywhere;
  }
  .mobile-card-table > table > tbody > tr > td:last-child { border-bottom: 0; }
  .mobile-card-table > table > tbody > tr > td::before {
    content: attr(data-label); position: absolute; top: 9px; left: 12px;
    width: calc(38% - 10px); color: var(--muted); font-size: 11.5px; font-weight: 700;
  }
  .mobile-card-table > table > tbody > tr > td[data-label=""] {
    min-height: 0; padding-left: 12px;
  }
  .mobile-card-table > table > tbody > tr > td[data-label=""]::before { content: none; }
  .mobile-card-table > table > tbody > tr:hover > td { background: var(--surface); }
  .mobile-card-table .sticky-name,
  .mobile-card-table th.sticky-name {
    position: static; left: auto; z-index: auto; background: transparent; box-shadow: none;
  }
  .mobile-card-table td > form {
    display: flex; min-width: 0; max-width: 100%; gap: 6px; flex-wrap: wrap;
  }
  .mobile-card-table td input:not([type="checkbox"]),
  .mobile-card-table td select,
  .mobile-card-table td textarea { width: 100%; }
  .images-list-table .image-row-actions { min-width: 0; }
  .images-list-table .image-row-actions > a { align-items: center; min-height: 40px; margin: 0 8px 0 0; }
  .images-list-table .image-row-exclusion-form { display: inline-flex; width: auto; vertical-align: middle; }
  .images-list-table .image-row-exclusion-form button { width: auto; min-height: 40px; }
  .images-list-table .thumb { width: 112px; max-width: 100%; height: auto; }
  .filter-form { align-items: stretch; }
  .filter-form .log-query { flex-basis: 100%; width: 100%; }
  .form-row { align-items: stretch; }
  .form-row > label { flex-basis: 100%; }
  .form-row > button { width: 100%; }
  textarea { width: 100%; resize: vertical; }
}

@media (max-width: 1020px) {
  .review-list-table > table > tbody > tr.review-summary-row.is-open {
    margin-bottom: 0; border-bottom-color: transparent;
    border-bottom-right-radius: 0; border-bottom-left-radius: 0; box-shadow: none;
  }
  .review-list-table > table > tbody > tr.review-detail-row {
    display: block; width: 100%; margin: -1px 0 10px;
    background: var(--surface-2); border: 1px solid var(--border); border-top: 0;
    border-radius: 0 0 var(--radius) var(--radius); box-shadow: var(--shadow); overflow: hidden;
  }
  .review-list-table > table > tbody > tr.review-detail-row > td {
    display: block; min-width: 0; min-height: 0; padding: 0; border: 0;
  }
  .review-list-table > table > tbody > tr.review-detail-row > td::before { content: none; }
  .review-detail-panel { padding: 12px; }
  .review-detail-head { margin-bottom: 10px; }
  .review-detail-head h2 { font-size: 14px; }
  .review-detail-panel .card { padding: 13px; }
  .review-detail-toggle { width: 100%; min-height: 44px; }
  .review-analysis-card .compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .review-analysis-card .compare figure { width: 100%; }
  .review-analysis-card .compare img { display: block; width: 100%; max-height: 54vh; object-fit: contain; }

  /* 写真チェックは7列を縦に積まず、2列の確認カードにする。 */
  .analysis-review-table > table > tbody > tr.review-summary-row {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0; padding: 4px;
  }
  .analysis-review-table > table > tbody > tr.review-summary-row > td {
    display: flex; position: static; align-items: center; gap: 6px;
    min-width: 0; min-height: 38px; padding: 6px 8px; border: 0; overflow-wrap: anywhere;
  }
  .analysis-review-table > table > tbody > tr.review-summary-row > td::before {
    content: attr(data-label); position: static; flex: 0 0 auto; width: auto;
    color: var(--muted); font-size: 10.5px; font-weight: 700;
  }
  .analysis-review-table .review-verdict .sub { display: inline-block; }
  .analysis-review-table .review-verdict { grid-column: 1 / -1; }
  .analysis-review-table .review-admin { grid-column: 1 / -1; }
  .analysis-review-table .review-action { grid-column: 1 / -1; }
}

@media (min-width: 700px) and (max-width: 1020px) {
  .analysis-review-table > table > tbody > tr.review-summary-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .analysis-review-table .review-verdict { grid-column: 3 / 5; }
  .analysis-review-table .review-admin { grid-column: auto; }
  .analysis-review-table .review-action { grid-column: 4; }
}

@media (max-width: 480px) {
  .review-analysis-card .compare { grid-template-columns: 1fr; }
  .images-list-table .image-row-actions > a,
  .images-list-table .image-row-exclusion-form { width: 100%; margin-right: 0; }
  .images-list-table .image-row-exclusion-form button { width: 100%; }
}

@media (min-width: 601px) and (max-width: 1020px) {
  .date-nav > *, .date-picker, .date-readable { order: 0 !important; }
  .date-step, .date-today { flex: 0 0 auto; }
  .date-picker { width: auto; align-items: end; }
  .date-picker label { flex: 0 1 auto; flex-direction: row; align-items: center; gap: 7px; }
  .date-picker input { width: auto; min-height: 42px; }
  .date-readable { width: auto; margin-left: auto; text-align: right; }
  .sort-switch { width: auto; }
  .feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .feature-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .operation-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .card:hover { transform: none; }
  .dashboard-live-dot { animation: none !important; }
}
