/* デザインシステム(UI/UX設計書 5.1) */
:root {
  --navy-900: #0f2238; --navy-800: #16324f; --navy-700: #1d4266;
  --teal-600: #0e8b7e; --teal-100: #d9f2ef;
  --amber-600: #b57a00; --amber-100: #fdf1d8;
  --red-700: #b3261e; --red-100: #fbe4e2;
  --gray-50: #f7f9fb; --gray-100: #eef2f6; --gray-300: #cfd8e3;
  --gray-600: #5b6b7c; --gray-900: #1c2733;
  --radius: 8px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--gray-50); color: var(--gray-900);
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif;
  font-size: 14px; line-height: 1.6;
  height: 100vh; display: flex; flex-direction: column; overflow: hidden;
}
main { flex: 1; width: 100%; }

/* フッター */
.site-footer {
  text-align: center; padding: 16px 20px;
  border-top: 1px solid var(--gray-300); background: #fff;
}
.site-footer a {
  color: var(--gray-600); font-size: 12px; text-decoration: none;
}
.site-footer a:hover { color: var(--navy-700); text-decoration: underline; }
.site-footer .footer-links { margin-bottom: 4px; }
.site-footer .footer-links a { text-decoration: underline; }
.site-footer .footer-lang { margin-bottom: 6px; font-size: 12px; }
.site-footer .footer-lang a { color: var(--navy-700); text-decoration: underline; }
.site-footer .footer-lang .lang-current { color: var(--gray-900); font-weight: 700; }
.site-footer .footer-lang .lang-sep { color: var(--gray-300); margin: 0 6px; }
a { color: var(--navy-700); }
code, pre, .mono { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }

/* ヘッダ・ナビ */
.topbar {
  background: var(--navy-900); color: #fff; display: flex; align-items: center;
  gap: 16px; padding: 10px 20px;
}
.topbar .brand { font-weight: 700; font-size: 15px; letter-spacing: .02em;
  display: flex; align-items: center; gap: 9px;
  color: #fff; text-decoration: none; }
.topbar .brand:hover { color: #9fd8d0; }
.topbar .brand-mini { width: 26px; height: 26px; border-radius: 6px; }

/* 右上ユーザメニュー */
.topbar .who { display: flex; align-items: center; gap: 4px; }
.who-btn {
  background: none; border: none; cursor: pointer; font-family: inherit;
  font-size: 12.5px; color: #dfe8f2; padding: 4px 8px; border-radius: 6px;
  display: flex; align-items: center; gap: 5px;
}
.who-btn:hover { background: var(--navy-700); color: #fff; }
.who-btn .caret { font-size: 10px; color: #9fd8d0; }
.menu-wrap { position: relative; }
.menu-wrap .dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 50;
  background: #fff; border: 1px solid var(--gray-300); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(15, 34, 56, .18); min-width: 220px; padding: 6px 0;
}
.menu-wrap .dropdown.right { left: auto; right: 0; }
.menu-wrap .dropdown a,
.topbar .who .dropdown a {
  display: block; padding: 9px 16px; color: var(--gray-900);
  text-decoration: none; font-size: 13.5px; margin-left: 0;
}
.menu-wrap .dropdown a:hover,
.topbar .who .dropdown a:hover { background: var(--gray-100); color: var(--navy-700); }
.topbar .ctx { color: #b8c7d9; font-size: 12.5px; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 12.5px; color: #dfe8f2; }
.topbar .who a { color: #9fd8d0; margin-left: 10px; }
.topbar .who a.who-name { color: #dfe8f2; margin-left: 0; text-decoration: none;
  border-bottom: 1px dashed #7f95ab; }
.topbar .who a.who-name:hover { color: #fff; border-bottom-color: #9fd8d0; }
/* レイアウト(左サイドバー固定 + コンテンツのみスクロール) */
.layout { display: flex; flex: 1; min-height: 0; align-items: stretch;
  overflow: hidden; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column;
  overflow-y: auto; }
.content main { flex: 1; }

/* ハンバーガー */
.nav-burger {
  background: none; border: none; color: #dfe8f2; font-size: 20px;
  cursor: pointer; padding: 4px 10px; border-radius: 6px; line-height: 1;
}
.nav-burger:hover { background: var(--navy-700); color: #fff; }

/* 左サイドメニュー */
nav.sidenav {
  width: 216px; flex-shrink: 0; background: var(--navy-800);
  display: flex; flex-direction: column; padding: 10px 0;
  transition: width .18s ease;
  overflow-y: auto;  /* コンテンツのスクロールから独立(メニュー自身のみスクロール) */
}
nav.sidenav a {
  display: flex; align-items: center; gap: 12px;
  color: #cddcec; text-decoration: none; padding: 11px 18px; font-size: 13.5px;
  border-left: 3px solid transparent; white-space: nowrap; overflow: hidden;
}
nav.sidenav a:hover { color: #fff; background: var(--navy-700); }
nav.sidenav a.active {
  color: #fff; background: var(--navy-700);
  border-left-color: var(--teal-600); font-weight: 600;
}
nav.sidenav .nav-icon { width: 22px; text-align: center; font-size: 15px; flex-shrink: 0; }
nav.sidenav .nav-label { overflow: hidden; text-overflow: ellipsis; }

/* 縮小状態(アイコンのみ) */
body.nav-collapsed nav.sidenav { width: 58px; }
body.nav-collapsed nav.sidenav .nav-label { display: none; }
body.nav-collapsed nav.sidenav a { padding: 11px 0; justify-content: center; }

main { max-width: 1180px; margin: 0 auto; padding: 22px 20px 60px; }

/* パンくず */
.breadcrumbs {
  max-width: 1180px; margin: 0 auto; padding: 12px 20px 0;
  font-size: 12.5px; color: var(--gray-600); width: 100%; box-sizing: border-box;
}
.breadcrumbs a { color: var(--navy-700); text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs .sep { margin: 0 7px; color: var(--gray-300); }
.breadcrumbs .current { color: var(--gray-900); font-weight: 600; }

/* テーブルソート */
table.list th.sortable { cursor: pointer; user-select: none; }
table.list th.sortable:hover { background: var(--navy-700); }
table.list th .sort-ind { color: #9fd8d0; }
table.list th.sortable a { color: inherit; text-decoration: none; display: block; }
h1 { font-size: 20px; margin: 0 0 14px; }
h2 { font-size: 16px; margin: 22px 0 10px; }
.sub { color: var(--gray-600); font-size: 12.5px; }

/* カード・KPI */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.card {
  background: #fff; border: 1px solid var(--gray-300); border-radius: var(--radius);
  padding: 14px 16px;
}
.card .kpi { font-size: 26px; font-weight: 700; }
.card .kpi.warn { color: var(--red-700); }
.card .kpi.ok { color: var(--teal-600); }
.card .label { color: var(--gray-600); font-size: 12.5px; }

/* テーブル */
table.list { width: 100%; border-collapse: collapse; background: #fff;
  border: 1px solid var(--gray-300); border-radius: var(--radius); overflow: hidden; }
table.list th {
  background: var(--navy-800); color: #fff; text-align: left; padding: 8px 12px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
table.list td { padding: 8px 12px; border-top: 1px solid var(--gray-100); vertical-align: top; }
table.list tr:hover td { background: var(--gray-50); }
.table-wrap { overflow-x: auto; }
/* 見出し追従(スクロールしても列名を表示し続ける)。
   横スクロール用の overflow を外し、.content のスクロールに対して th を sticky にする */
.table-wrap.sticky-head { overflow: visible; }
.table-wrap.sticky-head table.list { overflow: visible; }  /* table 自身の overflow:hidden が sticky の基準を閉じるため解除 */
.table-wrap.sticky-head table.list thead th {
  position: sticky; top: 0; z-index: 2;
  box-shadow: 0 1px 0 var(--navy-700);
}
/* 幅が足りない画面では .content(縦横スクロール可)ごと横スクロールさせ、追従は維持する */

/* バッジ(色+テキスト+形状で区別: 5.2 アクセシビリティ) */
.badge { display: inline-block; border-radius: 4px; padding: 1px 8px;
  font-size: 11.5px; font-weight: 700; border: 1.5px solid transparent; white-space: nowrap; }
.badge.critical { background: var(--red-700); color: #fff; }
.badge.high { background: var(--red-100); color: var(--red-700); border-color: var(--red-700); }
.badge.medium { background: var(--amber-100); color: var(--amber-600); border-color: var(--amber-600); }
.badge.low { background: var(--gray-100); color: var(--gray-600); }
.badge.info { background: var(--gray-100); color: var(--gray-600); border-style: dashed; }
.badge.ai { background: #eae4f7; color: #5a3ea6; border: 1.5px dashed #5a3ea6; }
.badge.rule { background: var(--teal-100); color: var(--teal-600); }
.badge.state { background: var(--gray-100); color: var(--gray-900); }
.badge.blocked { background: var(--red-700); color: #fff; }
.badge.mergeable { background: var(--teal-600); color: #fff; }
.badge.passed { background: var(--teal-100); color: var(--teal-600); border-color: var(--teal-600); }
.badge.failed { background: var(--red-100); color: var(--red-700); border-color: var(--red-700); }
.badge.pending { background: var(--amber-100); color: var(--amber-600); }

/* ボタン */
.btn {
  display: inline-block; border: 1px solid var(--navy-700); background: var(--navy-700);
  color: #fff; border-radius: 6px; padding: 6px 14px; font-size: 13px; cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--navy-800); }
.btn.secondary { background: #fff; color: var(--navy-700); }
.btn.teal { background: var(--teal-600); border-color: var(--teal-600); }
.btn.danger { background: #fff; color: var(--red-700); border-color: var(--red-700); }
.btn.small { padding: 3px 10px; font-size: 12px; }

/* ゲートバナー */
.gate-banner { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 12px; }
.gate-banner.blocked { background: var(--red-100); border: 1.5px solid var(--red-700); }
.gate-banner.mergeable { background: var(--teal-100); border: 1.5px solid var(--teal-600); }
.gate-banner .title { font-weight: 700; font-size: 15px; }

/* コード表示 */
pre.code {
  background: var(--navy-900); color: #dce7f2; padding: 12px 14px;
  border-radius: var(--radius); overflow-x: auto; margin: 8px 0;
}
pre.diff { background: #fff; border: 1px solid var(--gray-300); padding: 12px 14px;
  border-radius: var(--radius); overflow-x: auto; }
pre.diff .add { color: #0a7a43; background: #e6f6ec; display: block; }
pre.diff .del { color: var(--red-700); background: var(--red-100); display: block; }
pre.diff .hunk { color: #5a3ea6; display: block; }

/* フォーム */
form.inline { display: inline; }
input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
  border: 1px solid var(--gray-300); border-radius: 6px; padding: 7px 10px;
  font-size: 13.5px; font-family: inherit; width: 100%;
}
label { font-size: 12.5px; color: var(--gray-600); display: block; margin: 8px 0 3px; }
.form-narrow { max-width: 520px; }

/* 通知 */
.flash { background: var(--teal-100); border: 1px solid var(--teal-600);
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; }

/* ログイン */
.login-wrap { max-width: 400px; margin: 8vh auto; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 12px; }
.login-brand .brand-icon { width: 46px; height: 46px; border-radius: 10px; }
.btn-sso {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  border-radius: 6px; padding: 10px 14px; font-size: 14px; font-weight: 600;
  text-decoration: none; border: 1px solid var(--gray-300);
}
.btn-sso.google { background: #fff; color: #3c4043; }
.btn-sso.google:hover { background: var(--gray-50); }
.btn-sso.microsoft { background: #2f2f2f; color: #fff; border-color: #2f2f2f; }
.btn-sso.microsoft:hover { background: #1f1f1f; }

/* パスワード強度インジケータ */
.pw-meter {
  height: 6px; background: var(--gray-100); border-radius: 3px;
  margin-top: 6px; overflow: hidden;
}
.pw-meter span {
  display: block; height: 100%; width: 0;
  border-radius: 3px; transition: width .25s ease, background-color .25s ease;
}
.pw-meter span.weak { background: var(--red-700); }
.pw-meter span.fair { background: var(--amber-600); }
.pw-meter span.strong { background: var(--teal-600); }
.pw-meter span.vstrong { background: var(--navy-700); }
.pw-label { margin: 4px 0 0; }
.pw-label.ok { color: var(--teal-600); }
.pw-label.ng { color: var(--red-700); }
.login-brand { text-align: center; color: var(--navy-900); font-size: 20px;
  font-weight: 700; margin-bottom: 18px; }
.error-box { background: var(--red-100); border: 1px solid var(--red-700);
  color: var(--red-700); border-radius: 6px; padding: 8px 12px; margin-bottom: 10px; }

/* 攻撃経路 */
.attack-path { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.attack-path .step { background: var(--gray-100); border: 1px solid var(--gray-300);
  border-radius: 14px; padding: 2px 12px; font-size: 12px; }
.attack-path .arrow { color: var(--gray-600); }

/* アコーディオン(解析対象の一覧) */
.accordion {
  background: #fff; border: 1px solid var(--gray-300);
  border-radius: var(--radius); overflow: hidden;
}
.acc-item { border-bottom: 1px solid var(--gray-100); }
.acc-item:last-child { border-bottom: none; }
.acc-header { display: flex; align-items: center; gap: 10px; padding-right: 14px; }
.acc-toggle {
  flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0;
  background: none; border: none; cursor: pointer; font-family: inherit;
  text-align: left; padding: 12px 14px; font-size: 14px; color: var(--gray-900);
}
.acc-toggle:hover { background: var(--gray-50); }
.acc-caret { color: var(--teal-600); font-size: 12px; width: 14px; }
.acc-name { font-weight: 600; white-space: nowrap; }
.acc-last { margin-left: auto; white-space: nowrap; }
.acc-actions { display: flex; gap: 6px; white-space: nowrap; }
.acc-body {
  padding: 12px 16px 14px 38px; background: var(--gray-50);
  border-top: 1px solid var(--gray-100);
}
.acc-subtitle { font-size: 13.5px; margin: 12px 0 4px; color: var(--navy-800); }

/* カード内タブ */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--gray-100);
  margin-bottom: 16px; }
.tabs .tab {
  background: none; border: none; cursor: pointer; font-family: inherit;
  font-size: 14px; color: var(--gray-600); padding: 9px 16px;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.tabs .tab:hover { color: var(--navy-700); }
.tabs .tab.active {
  color: var(--navy-800); font-weight: 700; border-bottom-color: var(--teal-600);
}

/* モーダルダイアログ(ディレクトリ選択) */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 34, 56, .45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
/* display:flex が hidden属性のUAスタイルを上書きしてしまうため明示的に閉じる */
.modal-backdrop[hidden] { display: none !important; }
.modal {
  background: #fff; border-radius: var(--radius); padding: 18px 20px;
  width: min(560px, 100%); max-height: 80vh; display: flex; flex-direction: column;
  box-shadow: 0 12px 40px rgba(15, 34, 56, .3);
}
.dm-list {
  border: 1px solid var(--gray-300); border-radius: 6px; margin-top: 8px;
  overflow-y: auto; min-height: 200px; max-height: 46vh;
}
.dm-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: none; border: none; border-bottom: 1px solid var(--gray-100);
  padding: 8px 12px; font-size: 13.5px; font-family: inherit; cursor: pointer;
  color: var(--gray-900);
}
.dm-item:hover { background: var(--gray-50); color: var(--navy-700); }

dl.meta { display: grid; grid-template-columns: 140px 1fr; gap: 4px 12px; margin: 0; }
dl.meta dt { color: var(--gray-600); font-size: 12.5px; }
dl.meta dd { margin: 0; font-size: 13px; }
