/* ============================================================
   Human State Dashboard 共通スタイル
   基準: 1920×1080。992px 未満はサイドメニューを引き出し式に切り替える。
   ============================================================ */
:root {
    --hs-sidebar-bg: #0f1e3d;
    --hs-sidebar-fg: #c8d3ea;
    --hs-sidebar-active: #2563eb;
    --hs-sidebar-width: 240px;
    --hs-body-bg: #f3f6fb;
    --hs-card-bg: #ffffff;
    --hs-border: #e3e8f2;
}

html { font-size: 15px; }

body {
    background: var(--hs-body-bg);
    font-family: "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif;
}

/* ---- レイアウト ---- */
.hs-shell { display: flex; min-height: 100vh; }

.hs-sidebar {
    background: var(--hs-sidebar-bg);
    color: var(--hs-sidebar-fg);
}

@media (min-width: 992px) {
    /* Bootstrap の offcanvas-lg は 992px 以上で背景を透明にするため、上書きする */
    .hs-sidebar.offcanvas-lg { background-color: var(--hs-sidebar-bg) !important; }
    .hs-sidebar {
        width: var(--hs-sidebar-width);
        flex-shrink: 0;
        position: sticky;
        top: 0;
        height: 100vh;
        overflow-y: auto;
    }
}

@media (max-width: 991.98px) {
    .hs-sidebar.offcanvas-lg { --bs-offcanvas-width: var(--hs-sidebar-width); --bs-offcanvas-bg: var(--hs-sidebar-bg); }
}

.hs-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.25rem 1.25rem 1rem;
    color: #fff;
    font-weight: 700;
    line-height: 1.15;
}
.hs-brand .bi { font-size: 1.9rem; color: #60a5fa; }
.hs-brand small { font-weight: 400; color: var(--hs-sidebar-fg); }

.hs-nav { display: flex; flex-direction: column; padding: .5rem .75rem; gap: .15rem; width: 100%; }
.hs-nav-section { font-size: .75rem; color: #7f8db0; margin: 1rem .75rem .25rem; }
.hs-nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem .9rem;
    border-radius: .5rem;
    color: var(--hs-sidebar-fg);
    text-decoration: none;
}
.hs-nav-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.hs-nav-link.active { background: var(--hs-sidebar-active); color: #fff; }
.hs-nav-link .bi { font-size: 1.1rem; }

.hs-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.hs-header {
    display: flex;
    align-items: center;
    padding: .9rem 1.5rem;
    background: var(--hs-card-bg);
    border-bottom: 1px solid var(--hs-border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.hs-page-title { font-size: 1.25rem; font-weight: 700; margin: 0; }

.hs-content { flex: 1; padding: 1.5rem; }

.hs-footer { padding: .75rem 1.5rem; font-size: .75rem; color: #8590a6; }

@media (max-width: 575.98px) {
    .hs-header { padding: .75rem 1rem; }
    .hs-content { padding: 1rem; }
    .hs-footer { padding: .75rem 1rem; }
}

/* ---- カード ---- */
.hs-card {
    background: var(--hs-card-bg);
    border: 1px solid var(--hs-border);
    border-radius: .75rem;
    padding: 1.25rem;
}
.hs-card-title { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; }

.table > :not(caption) > * > * { vertical-align: middle; }

/* ---- ログイン画面 ---- */
.hs-auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, #0f1e3d 0%, #1d3a75 100%);
}
.hs-auth-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, .25);
}
.hs-auth-brand { display: flex; gap: .75rem; align-items: center; margin-bottom: 1.5rem; }
.hs-auth-brand .bi { font-size: 2.25rem; color: #2563eb; }

/* ---- 管理画面：フィルター行・サマリー ---- */
.hs-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem 1.25rem;
    margin-bottom: 1rem;
}
.hs-filter-row .form-select { min-width: 10rem; }

.hs-num { font-variant-numeric: tabular-nums; }

.hs-kpi-grid {
    display: grid;
    gap: .75rem;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.hs-kpi-grid-6 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.hs-kpi {
    display: flex;
    gap: .9rem;
    align-items: flex-start;
    background: var(--hs-card-bg);
    border: 1px solid var(--hs-border);
    border-radius: .75rem;
    padding: 1rem 1.1rem;
}
.hs-kpi-compact { padding: .75rem 1rem; }
.hs-kpi-icon {
    flex-shrink: 0;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: .6rem;
    display: grid;
    place-items: center;
    background: #e8f0fb;
    color: #2a78d6;
    font-size: 1.3rem;
}
.hs-kpi-label { font-size: .8rem; color: #52514e; }
.hs-kpi-value { font-size: 1.6rem; font-weight: 700; line-height: 1.25; color: #0b0b0b; }
.hs-kpi-compact .hs-kpi-value { font-size: 1.3rem; }
.hs-kpi-unit { font-size: .85rem; font-weight: 400; color: #52514e; margin-left: .2rem; }
.hs-kpi-sub { font-size: .75rem; color: #898781; margin-top: .15rem; }

/* 自動更新中：前回表示を薄くして残す（レイアウトを動かさない） */
.hs-refreshing { opacity: .6; transition: opacity .2s; }

/* ---- 一覧テーブル ---- */
.hs-table thead th { font-size: .8rem; font-weight: 600; color: #52514e; background: #f7f8fa; white-space: nowrap; }
.hs-row-inactive { color: #898781; }
.hs-row-inactive .fw-semibold { color: #52514e; }

/* ---- 変化レベル（状態色＋ラベル。色だけで意味を伝えない） ---- */
.hs-level {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 600;
    white-space: nowrap;
}
.hs-level::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.hs-level-baseline { background: #f0efec; color: #52514e; }
.hs-level-small { background: rgba(250, 178, 25, .18); color: #7a5300; }
.hs-level-small::before { background: #fab219; }
.hs-level-medium { background: rgba(236, 131, 90, .18); color: #8a3511; }
.hs-level-medium::before { background: #ec835a; }
.hs-level-large { background: rgba(208, 59, 59, .13); color: #a12828; }
.hs-level-large::before { background: #d03b3b; }
.hs-level-none { background: transparent; color: #898781; padding-left: 0; }
.hs-level-none::before { display: none; }

/* ---- 計測状態 ---- */
.hs-status { font-size: .8rem; white-space: nowrap; }
.hs-status::before { content: "●"; margin-right: .25rem; font-size: .7rem; }
.hs-status-measuring { color: #006300; }
.hs-status-measuring::before { color: #0ca30c; }
.hs-status-interrupted { color: #8a3511; }
.hs-status-idle { color: #898781; }

/* ---- 個人詳細：グラフ ---- */
.hs-chart-main { position: relative; height: 340px; }
@media (max-width: 575.98px) { .hs-chart-main { height: 260px; } }

.hs-band-legend {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem 1rem;
    list-style: none;
    padding: 0;
    margin: .25rem 0 .5rem;
    font-size: .75rem;
    color: #52514e;
}
.hs-band-legend li { display: inline-flex; align-items: center; gap: .35rem; }
.hs-band-swatch { width: .9rem; height: .6rem; border-radius: 2px; border: 1px solid rgba(11, 11, 11, .10); }
.hs-band-baseline { background: #f0efec; }
.hs-band-small { background: rgba(250, 178, 25, .35); }
.hs-band-medium { background: rgba(236, 131, 90, .40); }
.hs-band-large { background: rgba(208, 59, 59, .30); }
.hs-band-basis { background: rgba(42, 120, 214, .18); }

.hs-data-table { max-height: 260px; overflow-y: auto; }

/* ---- 個人詳細：根拠データ ---- */
.hs-evidence { display: flex; flex-direction: column; gap: .5rem; }
.hs-evidence-row {
    display: grid;
    grid-template-columns: 7.5rem 1fr 7rem;
    align-items: center;
    gap: .5rem;
    padding: .35rem 0;
    border-bottom: 1px solid #f0efec;
}
.hs-evidence-row:last-child { border-bottom: 0; }
.hs-evidence-label { font-size: .85rem; color: #52514e; }
.hs-evidence-chart { position: relative; height: 40px; min-width: 0; }
.hs-evidence-values { text-align: right; line-height: 1.2; }

/* 表のセルは折り返さず、狭い画面では表の中だけ横スクロールさせる */
.hs-table th, .hs-table td { white-space: nowrap; }

/* スマホ：サマリーを2列にして縦の長さを抑える */
@media (max-width: 575.98px) {
    .hs-kpi-grid, .hs-kpi-grid-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
    .hs-kpi { padding: .7rem .8rem; }
    .hs-kpi-icon { display: none; }
    .hs-kpi-value { font-size: 1.3rem; }
}

.hs-name-link { color: inherit; text-decoration: none; }
.hs-name-link:hover, .hs-name-link:focus { color: #2a78d6; text-decoration: underline; }
