/*
 * Copyright (c) 2026 VitaHub LLC
 * All Rights Reserved.
 *
 * This source code is proprietary and confidential.
 * Use is permitted only with explicit authorization from VitaHub LLC.
 * See the LICENSE file for details.
 */

/* ============================================================
   TIMOCA デザインシステム
   企業向け管理コンソール（Desktop / Tablet / Mobile 対応）
   ============================================================ */

/* ---------- カラートークン ---------- */
:root {
    --primary: #3DBBC3;
    --primary-hover: #329FA6;
    --primary-active: #288A90;
    --primary-light: #E8F7F8;
    --primary-very-light: #F3FBFB;

    --bg: #F6F8FA;
    --surface: #FFFFFF;
    --border: #E2E8EC;

    --text-primary: #263238;
    --text-secondary: #607078;
    --text-muted: #8A979D;

    --success: #22A06B;
    --success-light: #E9F6F0;
    --warning: #E6A23C;
    --warning-light: #FCF3E6;
    --danger: #D9534F;
    --danger-light: #FBECEB;
    --info: #3DBBC3;
    --info-light: #E8F7F8;

    --radius: 6px;
    --radius-lg: 8px;
    --shadow: 0 1px 2px rgba(38, 50, 56, 0.06);
    --shadow-md: 0 2px 8px rgba(38, 50, 56, 0.10);

    --header-h: 56px;
    --sidebar-w: 250px;
    --sidebar-w-compact: 64px;
}

/* ---------- ベース ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", Meiryo, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg);
}
a { color: var(--primary-hover); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 4px; font-weight: 700; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 700; }
code {
    font-family: "SFMono-Regular", Consolas, Menlo, monospace;
    font-size: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 6px;
    word-break: break-all;
}
.hidden { display: none !important; }
.mt { margin-top: 16px; }
.note { font-size: 12px; color: var(--text-muted); }
.text-muted { color: var(--text-muted); }
.required {
    font-size: 10px; color: #ffffff; background: var(--danger);
    border-radius: 3px; padding: 1px 5px; margin-left: 6px; vertical-align: middle;
}

/* ---------- アプリレイアウト ---------- */
.app-header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px;
    padding: 0 16px;
}
.app-logo {
    font-size: 17px; font-weight: 700; letter-spacing: 0.08em;
    color: var(--text-primary); text-decoration: none;
    display: flex; align-items: center; gap: 8px;
}
.app-logo:hover { text-decoration: none; }
.app-logo-mark {
    width: 26px; height: 26px; border-radius: 6px;
    background: var(--primary); color: #ffffff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; letter-spacing: 0;
}
.header-spacer { flex: 1; }
.header-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
    position: relative;
    width: 44px; height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
    background: none; border: none; border-radius: var(--radius);
    color: var(--text-secondary); cursor: pointer;
}
.icon-btn:hover { background: var(--bg); color: var(--text-primary); }
.icon-btn svg { width: 20px; height: 20px; }
.badge-dot {
    position: absolute; top: 8px; right: 8px;
    min-width: 16px; height: 16px; padding: 0 4px;
    background: var(--danger); color: #ffffff;
    border-radius: 999px; font-size: 10px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
}
.header-user { position: relative; }
.header-user-btn {
    display: flex; align-items: center; gap: 8px;
    background: none; border: none; cursor: pointer;
    padding: 6px 10px; border-radius: var(--radius);
    color: var(--text-primary); font-size: 13px; min-height: 44px;
}
.header-user-btn:hover { background: var(--bg); }
.user-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--primary-light); color: var(--primary-active);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700;
}
.dropdown-menu {
    position: absolute; right: 0; top: calc(100% + 4px);
    min-width: 180px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-md); padding: 6px; z-index: 120;
}
.dropdown-menu a, .dropdown-menu button {
    display: block; width: 100%; text-align: left;
    padding: 10px 12px; border: none; background: none;
    font-size: 13px; color: var(--text-primary);
    border-radius: 4px; cursor: pointer; text-decoration: none;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--bg); text-decoration: none; }
.dropdown-note { padding: 8px 12px; font-size: 11px; color: var(--text-muted); border-bottom: 1px solid var(--border); margin-bottom: 4px; }

/* ---------- サイドバー ---------- */
.app-sidebar {
    position: fixed; top: var(--header-h); bottom: 0; left: 0; z-index: 90;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 12px 8px 24px;
}
.nav-group-label {
    font-size: 11px; color: var(--text-muted); font-weight: 700;
    padding: 14px 12px 4px; letter-spacing: 0.05em;
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; margin: 1px 0;
    border-radius: var(--radius);
    color: var(--text-secondary); font-size: 13px;
    text-decoration: none; min-height: 40px;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg); color: var(--text-primary); text-decoration: none; }
.nav-item.active {
    background: var(--primary-light);
    color: var(--primary-active);
    font-weight: 700;
}
.nav-item.active svg { color: var(--primary); }

.sidebar-overlay { display: none; }

.app-main {
    margin-left: var(--sidebar-w);
    padding: calc(var(--header-h) + 20px) 24px 40px;
    min-height: 100vh;
}
.container { max-width: 1200px; }

/* ---------- ページ見出し ---------- */
.page-heading {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.page-heading h1 { margin: 0; }
.breadcrumb { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.breadcrumb a { color: var(--text-muted); }

/* ---------- カード ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 20px;
}
.card-heading {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; margin-bottom: 10px;
}
.card-heading h2 { margin: 0; }
.center-card { max-width: 480px; margin: 60px auto; text-align: center; }

/* ---------- KPIカード ---------- */
.kpi-grid {
    display: grid; gap: 14px;
    grid-template-columns: repeat(4, 1fr);
}
.kpi-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow);
    padding: 14px 18px;
    display: flex; flex-direction: column; gap: 2px;
}
.kpi-label { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.kpi-label svg { width: 15px; height: 15px; color: var(--primary); }
.kpi-value { font-size: 26px; font-weight: 700; line-height: 1.3; }
.kpi-unit { font-size: 13px; font-weight: 400; color: var(--text-secondary); margin-left: 3px; }
.kpi-sub { font-size: 11px; color: var(--text-muted); }
.kpi-alert .kpi-value { color: var(--danger); }
.diff-up { color: var(--success); font-weight: 700; }
.diff-down { color: var(--danger); font-weight: 700; }

/* ---------- 統計（勤怠ブロック互換） ---------- */
.stat-grid { display: grid; gap: 14px; }
.stat-grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.stat-card .stat-label { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; }
.stat-no {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; margin-right: 6px;
    border: 1px solid var(--border); border-radius: 50%;
    font-size: 12px; color: var(--text-muted); flex-shrink: 0;
}
.stat-value { font-size: 26px; font-weight: 700; }
.stat-value-mid { font-size: 20px; }
.stat-unit { font-size: 13px; font-weight: 400; color: var(--text-secondary); margin-left: 3px; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.stat-split { display: flex; gap: 24px; margin-top: 4px; }
.stat-split-label { font-size: 12px; color: var(--text-muted); }

.dash-columns { display: grid; grid-template-columns: 3fr 2fr; gap: 14px; align-items: start; }

/* ---------- グラフ ---------- */
.line-chart { width: 100%; height: auto; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis { font-size: 10px; fill: var(--text-muted); }
.chart-line { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; }
.chart-line-sub { fill: none; stroke: #9AB2BD; stroke-width: 2; stroke-linejoin: round; stroke-dasharray: 4 3; }
.chart-legend { font-size: 12px; color: var(--text-secondary); margin-top: 4px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.legend-line { display: inline-block; width: 18px; height: 2px; background: var(--primary); margin-right: 4px; vertical-align: middle; }
.legend-line-sub { display: inline-block; width: 18px; height: 2px; background: #9AB2BD; margin-right: 4px; vertical-align: middle; }

/* ---------- ボタン ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 40px; padding: 8px 18px;
    font-size: 13px; font-weight: 600;
    border-radius: var(--radius); border: 1px solid transparent;
    cursor: pointer; text-decoration: none; transition: background 0.12s;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn-primary { background: var(--primary); color: #ffffff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { background: var(--primary-active); }
.btn-secondary {
    background: var(--surface); color: var(--text-primary);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #ffffff; }
.btn-danger:hover { background: #C64944; }
.btn-small { min-height: 34px; padding: 4px 12px; font-size: 12px; }
.btn-large { min-height: 56px; padding: 12px 32px; font-size: 17px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- バッジ ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-failure, .badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: #B47B22; }
.badge-info { background: var(--info-light); color: var(--primary-active); }
.badge-guest { background: var(--primary-light); color: var(--primary-active); }
.badge-muted { background: var(--bg); color: var(--text-muted); }

.error-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-red { background: var(--danger); }
.dot-orange { background: var(--warning); }
.dot-green { background: var(--success); }
.dot-gray { background: var(--text-muted); }

/* ---------- アラートボックス ---------- */
.alert {
    padding: 10px 14px; border-radius: var(--radius);
    font-size: 13px; margin-bottom: 14px;
    border: 1px solid transparent;
}
.alert-info { background: var(--info-light); color: var(--primary-active); border-color: #C6EBEE; }
.alert-success { background: var(--success-light); color: #17734C; border-color: #C4E8D8; }
.alert-warning { background: var(--warning-light); color: #9A6A1E; border-color: #F3DDB8; }
.alert-error { background: var(--danger-light); color: #A93E3B; border-color: #F2CFCE; }

/* ---------- フォーム ---------- */
label { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.checkbox-label { display: flex; align-items: flex-start; gap: 8px; font-weight: 400; padding: 6px 0; }
.checkbox-label input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--primary); }
input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="date"], input[type="month"], input[type="datetime-local"], input[type="url"],
input[type="file"], select, textarea {
    width: 100%; max-width: 480px;
    min-height: 40px; padding: 8px 12px;
    font-size: 14px; font-family: inherit;
    color: var(--text-primary);
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface);
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(61, 187, 195, 0.18);
}
.form-row { margin-bottom: 14px; }
.form-row label { display: block; margin-bottom: 5px; }
.form-row-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 640px; }
.inline-form { display: inline-block; margin: 0; }
.filter-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-form input, .filter-form select { max-width: 240px; }

/* ---------- フィルターパネル ---------- */
.filter-toggle { display: none; }
.authlog-filter { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.filter-field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.filter-field input, .filter-field select { max-width: 220px; }
.filter-range { display: flex; align-items: center; gap: 6px; }
.range-sep { color: var(--text-muted); }
.filter-actions { display: flex; gap: 8px; }

/* ---------- テーブル ---------- */
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
    text-align: left; font-size: 12px; color: var(--text-secondary);
    background: var(--bg);
    padding: 9px 12px; border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td, .data-table tr:hover td { background: var(--primary-very-light); }
.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.reason-cell { font-size: 12px; color: var(--text-secondary); max-width: 280px; }
.authlog-detail td { background: var(--bg); }
.detail-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px 24px; font-size: 13px; padding: 4px;
}
.detail-label { display: block; font-size: 11px; color: var(--text-muted); }
.detail-wide { grid-column: 1 / -1; }

/* ---------- ページネーション ---------- */
.pagination-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.pagination { display: flex; gap: 4px; flex-wrap: wrap; }
.pagination a {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 40px; min-height: 40px; padding: 4px 8px;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); color: var(--text-primary);
    font-size: 13px; text-decoration: none;
}
.pagination a:hover { background: var(--bg); }
.pagination a.active { background: var(--primary); border-color: var(--primary); color: #ffffff; font-weight: 700; }
.page-ellipsis { padding: 8px 4px; color: var(--text-muted); }

/* ---------- 空状態 ---------- */
.empty-state { text-align: center; padding: 32px 16px; color: var(--text-muted); font-size: 13px; }

/* ---------- ダッシュボード: アラート・最近のログ ---------- */
.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list li {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 9px 2px; border-bottom: 1px solid var(--border); font-size: 13px;
}
.alert-list li:last-child { border-bottom: none; }
.alert-time { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.link-more { font-size: 13px; font-weight: 600; }

/* ---------- 在室状況 ---------- */
.presence-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.presence-room { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 16px; background: var(--surface); }
.presence-room-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.presence-room-name { font-weight: 700; }
.presence-count { font-size: 13px; color: var(--primary-active); font-weight: 700; }
.presence-list { list-style: none; margin: 0; padding: 0; }
.presence-list li { padding: 7px 0; border-top: 1px solid var(--bg); font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- 拠点・エリアツリー ---------- */
.tree { list-style: none; margin: 0; padding: 0; }
.tree-node { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; background: var(--surface); }
.tree-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; flex-wrap: wrap; }
.tree-title { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.tree-children { padding: 0 14px 12px 28px; }
.tree-leaf { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--bg); flex-wrap: wrap; font-size: 13px; }

/* ---------- 打刻・入退室端末（公開画面） ---------- */
.public-body { background: var(--bg); }
.admin-body { background: var(--bg); }
.clock-page { max-width: 560px; margin: 0 auto; padding: 24px 16px 48px; }
.clock-card { text-align: center; }
.clock-time { font-size: 46px; font-weight: 700; letter-spacing: 0.04em; line-height: 1.2; }
.clock-date { font-size: 14px; color: var(--text-secondary); margin-bottom: 14px; }
.kiosk-room {
    font-size: 14px; font-weight: 700; color: var(--primary-active);
    background: var(--primary-light); border-radius: var(--radius);
    padding: 8px 12px; margin-bottom: 10px;
}
.kiosk-tabs { display: flex; gap: 8px; justify-content: center; margin-bottom: 12px; }
.kiosk-tab {
    min-height: 44px; padding: 8px 24px; font-size: 14px;
    border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface); color: var(--text-secondary); cursor: pointer;
}
.kiosk-tab.active { background: var(--primary); border-color: var(--primary); color: #ffffff; font-weight: 700; }
.face-capture { margin: 0 auto 12px; max-width: 420px; }
.face-video {
    width: 100%; border-radius: var(--radius-lg);
    border: 1px solid var(--border); background: #101820;
}
.clock-buttons { display: flex; gap: 12px; justify-content: center; margin: 14px 0 8px; flex-wrap: wrap; }

/* ---------- ログイン ---------- */
.login-page { min-height: calc(100vh - var(--header-h) - 140px); display: flex; align-items: center; justify-content: center; padding: 24px 0; }
.login-card { width: 100%; max-width: 400px; }
.login-brand { text-align: center; margin-bottom: 18px; }
.login-brand .app-logo-mark { width: 44px; height: 44px; font-size: 20px; border-radius: 10px; margin-bottom: 8px; }
.login-brand h1 { letter-spacing: 0.1em; }

/* ---------- 確認画面・顔登録 ---------- */
.confirm-section { margin-bottom: 24px; }
.confirm-section h2 { display: flex; align-items: center; margin-bottom: 8px; }
.confirm-table th { width: 180px; }
.confirm-photo { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.confirm-photo img {
    width: 160px; height: 160px; object-fit: cover;
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
}
.confirm-photo .confirm-table { flex: 1; min-width: 260px; }
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- QR ---------- */
.qr-card { max-width: 480px; }
.qr-print-area { text-align: center; }
.qr-box { display: flex; justify-content: center; margin: 16px 0; }
.qr-box svg { width: 220px; height: 220px; }
.qr-actions { justify-content: center; margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   Tablet (768px〜1199px): コンパクトサイドバー
   ============================================================ */
@media (max-width: 1199px) {
    .app-sidebar { width: var(--sidebar-w-compact); padding: 12px 6px 24px; }
    .app-sidebar .nav-group-label { display: none; }
    .app-sidebar .nav-item { justify-content: center; padding: 12px 6px; }
    .app-sidebar .nav-item .nav-label { display: none; }
    .app-main { margin-left: var(--sidebar-w-compact); padding: calc(var(--header-h) + 16px) 16px 36px; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .dash-columns { grid-template-columns: 1fr; }
    /* ドロワー展開（タブレットでもハンバーガーで全文メニュー） */
    body.nav-open .app-sidebar {
        width: var(--sidebar-w); box-shadow: var(--shadow-md);
    }
    body.nav-open .app-sidebar .nav-group-label { display: block; }
    body.nav-open .app-sidebar .nav-item { justify-content: flex-start; padding: 10px 12px; }
    body.nav-open .app-sidebar .nav-item .nav-label { display: inline; }
}

/* ============================================================
   Mobile (〜767px): ドロワー＋カードUI
   ============================================================ */
@media (max-width: 767px) {
    .app-sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        width: min(300px, 84vw);
        padding: 12px 8px 24px;
        top: var(--header-h);
    }
    body.nav-open .app-sidebar { transform: translateX(0); width: min(300px, 84vw); }
    .sidebar-overlay {
        display: none; position: fixed; inset: var(--header-h) 0 0 0;
        background: rgba(38, 50, 56, 0.4); z-index: 80;
    }
    body.nav-open .sidebar-overlay { display: block; }
    .app-main { margin-left: 0; padding: calc(var(--header-h) + 14px) 12px 36px; }
    .header-user-name { display: none; }

    .kpi-grid { grid-template-columns: 1fr; }
    .form-row-2col { grid-template-columns: 1fr; }
    .card { padding: 16px; }
    .page-heading { flex-direction: column; align-items: flex-start; }

    /* フィルター: ボトムシート形式 */
    .filter-toggle { display: inline-flex; }
    .filter-panel { display: none; }
    body .filter-panel.open {
        display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 130;
        background: var(--surface); border-top-left-radius: 14px; border-top-right-radius: 14px;
        box-shadow: 0 -4px 24px rgba(38, 50, 56, 0.25);
        padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
        max-height: 80vh; overflow-y: auto;
    }
    .filter-panel.open .authlog-filter { flex-direction: column; align-items: stretch; }
    .filter-panel.open .filter-field input, .filter-panel.open .filter-field select { max-width: none; }
    .filter-panel.open .filter-actions { position: sticky; bottom: 0; background: var(--surface); padding-top: 8px; }
    .filter-panel.open .filter-actions .btn { flex: 1; }
    .filter-sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
    .filter-overlay { display: none; }
    body.filter-open .filter-overlay {
        display: block; position: fixed; inset: 0; z-index: 125;
        background: rgba(38, 50, 56, 0.4);
    }

    /* テーブル → カード変換（data-label方式） */
    .data-table.responsive, .data-table.responsive tbody { display: block; width: 100%; }
    .data-table.responsive thead, .data-table.responsive > tr:first-child:has(th) { display: none; }
    .data-table.responsive tr {
        display: block; border: 1px solid var(--border); border-radius: var(--radius-lg);
        margin-bottom: 10px; padding: 6px 12px; background: var(--surface);
    }
    .data-table.responsive td {
        display: flex; justify-content: space-between; align-items: center; gap: 12px;
        border: none; padding: 7px 0; font-size: 13px;
    }
    .data-table.responsive td::before {
        content: attr(data-label);
        font-size: 12px; color: var(--text-muted); flex-shrink: 0;
    }
    .data-table.responsive td[data-label=""]::before { display: none; }
    .data-table.responsive tr:hover td { background: transparent; }
    .data-table.responsive .actions-cell { justify-content: flex-end; }
    .reason-cell { max-width: none; text-align: right; }

    .clock-time { font-size: 38px; }
    .btn-large { width: 100%; }
    .confirm-actions .btn { flex: 1; }
}

/* ---------- 印刷（QR） ---------- */
@media print {
    .app-header, .app-sidebar, .sidebar-overlay, .qr-actions, .page-heading, .alert { display: none !important; }
    .app-main { margin: 0; padding: 0; }
    body { background: #ffffff; }
    .card { border: none; box-shadow: none; }
}

/* ---------- 公開画面レイアウト ---------- */
.public-main { padding: calc(var(--header-h) + 20px) 16px 40px; max-width: 960px; margin: 0 auto; }
.public-footer { text-align: center; padding: 12px 16px 24px; }
.public-nav { gap: 8px; }
@media (max-width: 480px) {
    .public-nav .btn-small { padding: 4px 10px; }
}

/* ---------- トップページ ---------- */
.home-hero { margin-bottom: 20px; }
.home-hero h1 { font-size: 22px; }
.home-lead { color: var(--text-secondary); margin: 0; }
.home-grid {
    display: grid; gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.home-card {
    display: flex; flex-direction: column; gap: 6px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow);
    padding: 20px; color: var(--text-primary); text-decoration: none;
}
.home-card:hover { border-color: var(--primary); text-decoration: none; }
.home-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.home-card-title { font-size: 16px; font-weight: 700; }
.home-card-text { font-size: 13px; color: var(--text-secondary); flex: 1; }
.home-card-action { font-size: 13px; font-weight: 700; color: var(--primary-active); }

/* ---------- 補助クラス ---------- */
.main-content { padding: 32px 16px 40px; max-width: 960px; margin: 0 auto; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 4px 16px; }
.ai-comment {
    background: var(--primary-very-light); border: 1px solid #C6EBEE;
    border-radius: var(--radius); padding: 14px 16px; font-size: 13px; line-height: 1.8;
}
.debug-detail {
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-all;
}
.authlog-table code { font-size: 11px; }
@media (max-width: 767px) {
    .main-content { padding: 24px 12px 36px; }
    .checkbox-grid { grid-template-columns: 1fr; }
}
