/* ==========================================================================
   デザインテンプレート - 業務管理画面UI
   otng.net
   ==========================================================================

   目次 (各セクションは "=== 見出し ===" コメントで区切り)
   ------------------------------------------------------------------------
   1.  :root 変数 / リセット / 基本タイポグラフィ
   2.  アプリ骨格 (app-header / sidebar / main) とレスポンシブ
   3.  サイドバー折り畳み時の共通ルール
   4.  サイドバー上部「新規作成」ボタン
   5.  構成図（SVG）
   6.  ボタンシステム
   7.  バッジ
   8.  システム構成カード
   9.  フォーム (プルダウン .pd-select・標準 select の開いた一覧 .sm-panel を含む)
   10. ページヘッダー / メインエリア タイトルヒーロー / ブレッドクラム
   11. タブ / テーブル / ページネーション
   12. アラート / カード / モーダル / トースト / 空状態・スケルトン
   13. タイポグラフィ（記事・本文）/ 補助
   14. ユーティリティクラス (.mt-14 / .text-sm-flush 等)
   15. チャート / アコーディオン / タイムライン / プログレスバー
   16. ツールチップ / チップ / ステッパー / アバターグループ
   17. ドロワー / ファイルアップロード / 絞り込みフィルター
   18. コマンドパレット / 通知センター / マスター・ディテール
   19. アクションバー / カレンダー / ステータスインジケーター / Diff
   20. ログイン画面
   21. ダークモード (:root.dark 上書き)
   ========================================================================== */

:root {
  /* 文字サイズスケール（メイン領域） */
  --font-scale: 1;

  /* ======================================================================
     ブランドカラー — ここの3値だけ変えれば派生色が全て自動更新される
     --brand-h : 色相 (0–360)  例: 青=210, 緑=145, 赤=4
     --brand-s : 彩度          例: 86%
     --brand-l : 明度          例: 38%
     ====================================================================== */
  --brand-h: 210;
  --brand-s: 86%;
  --brand-l: 38%;

  /* ベース ----------------------------------------------------------------- */
  --color-bg: #f5f7fa;
  --color-surface: #ffffff;
  --color-surface-2: #fafbfd;
  --color-surface-hover: #f1f4f9;
  --color-border: #e8ebf0;
  --color-border-strong: #d4d9e0;
  --color-text: #1a2233;
  --color-text-sub: #5b6573;
  --color-text-muted: #8a93a3;
  --color-text-faint: #b3bac6;

  /* ブランド／プライマリ（--brand-* から自動算出） ------------------------- */
  --color-primary:        hsl(var(--brand-h) var(--brand-s) var(--brand-l));
  --color-primary-hover:  hsl(var(--brand-h) var(--brand-s) calc(var(--brand-l) - 6%));
  --color-primary-active: hsl(var(--brand-h) var(--brand-s) calc(var(--brand-l) - 13%));
  --color-primary-soft:   hsl(var(--brand-h) var(--brand-s) 95%);
  --color-primary-soft-2: hsl(var(--brand-h) var(--brand-s) 91%);

  /* Neutral（戻る系） ---------------------------------------------------- */
  --color-neutral: #c8d0d7;
  --color-neutral-hover: #b8c1c9;
  --color-neutral-active: #a6b0b9;

  /* シャドウ階層 ---------------------------------------------------------- */
  --shadow-1: 0 1px 1px rgba(15, 23, 42, 0.03);
  --shadow-2: 0 1px 3px rgba(15, 23, 42, 0.04), 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-3: 0 4px 12px rgba(15, 23, 42, 0.06), 0 12px 28px rgba(15, 23, 42, 0.07);
  --shadow-focus: 0 0 0 3px hsl(var(--brand-h) var(--brand-s) var(--brand-l) / 0.14);

  --header-h: 64px;
  --sidebar-w: 208px;
  --sidebar-w-collapsed: 72px;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
               "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP",
               "Yu Gothic UI", "Yu Gothic", "Meiryo UI", Meiryo, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: calc(13px * var(--font-scale));
  line-height: 1.65;
  font-feature-settings: "palt" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  font-weight: 400;
}
::selection { background: rgba(14, 98, 181, 0.18); }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* レイアウト ---------------------------------------------------------------- */
.app {
  display: grid;
  grid-template-rows: var(--header-h) 1fr;
  height: 100vh;
}

.app-body {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 0;
  position: relative;
}

.app.is-collapsed .app-body {
  grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}

/* === サイドバー折り畳み時の共通ルール（デスクトップ/タブレット共通） === */
/* 折り畳みはサイドバーの中だけに効かせる。
   .sidebar を付けないと、同じクラスを使う設定画面のサブナビまで文字が消える。 */
.app.is-collapsed .sidebar .nav-label,
.app.is-collapsed .sidebar .nav-count,
.app.is-collapsed .sidebar .nav-caret,
.app.is-collapsed .sidebar .nav-section-title,
.app.is-collapsed .sidebar .nav-children {
  display: none;
}
.app.is-collapsed .sidebar .nav-item {
  grid-template-columns: 1fr;
  padding: 0;
  justify-items: center;
  border-radius: var(--radius-pill);
  margin: 0 8px;
  width: 48px;
  height: 32px;
}
.app.is-collapsed .sidebar .nav-item.is-active::before { display: none; }
.app.is-collapsed .nav-section + .nav-section { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--color-border); }
.app.is-collapsed .nav-section + .nav-section .nav-item:first-child { margin-top: 0; }

.app.is-collapsed .sidebar-footer {
  padding: 10px 0;
  text-align: center;
}
.app.is-collapsed .credit-org,
.app.is-collapsed .credit-team,
.app.is-collapsed .credit-logo,
.app.is-collapsed .credit-version { display: none; }
.app.is-collapsed .credit-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  margin: 0 auto;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  border-radius: 50%;
  font-size: calc(13px * var(--font-scale));
  font-weight: 700;
}
/* 折り畳み時のシステム情報リンク */
.app.is-collapsed .sidebar-system-link {
  grid-template-columns: 1fr;
  justify-items: center;
  padding: 10px 0;
}
.app.is-collapsed .sidebar-system-link .sys-label,
.app.is-collapsed .sidebar-system-link .sys-arrow { display: none; }

/* ヘッダー ----------------------------------------------------------------- */
.app-header {
  display: grid;
  /* 右列 280px: 文字サイズ「大」でも氏名と所属が入る幅（中 261.6px・大 273.6px） */
  grid-template-columns: minmax(240px, 320px) 1fr minmax(140px, 280px);
  align-items: center;
  padding: 0 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  gap: 16px;
}

.header-left { display: flex; align-items: center; gap: 4px; min-width: 0; }
.header-center { display: flex; justify-content: center; min-width: 0; }
.header-right { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }

/* タイトル（1行・案Z） */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  border-radius: var(--radius-md);
  transition: background 0.15s;
  min-width: 0;
}
.brand:hover { background: var(--color-surface-hover); }
.brand-text {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  overflow: hidden;   /* 列幅を超えた分をここで止める（中央の検索欄に重ねない） */
}

.logo {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
               "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP",
               "Yu Gothic UI", "Yu Gothic", "Meiryo UI", Meiryo, sans-serif;
  font-size: calc(18px * var(--font-scale));
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--color-primary);
  white-space: nowrap;
  line-height: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;   /* 入らない幅では「…」で省く */
}

.brand-sub {
  font-size: calc(11px * var(--font-scale));
  color: var(--color-text-muted);
  letter-spacing: 0.4px;
  white-space: nowrap;
  line-height: 1;
  position: relative;
  padding-left: 12px;
}
.brand-sub::before {
  content: "";
  position: absolute;
  left: 0; top: 0; height: 11px; align-self: center;
  width: 1px;
  background: var(--color-border-strong);
}

.icon-btn {
  width: 38px; height: 38px;
  border: none; background: transparent; color: var(--color-text-sub);
  border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: calc(15px * var(--font-scale));
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--color-surface-hover); color: var(--color-text); }
.icon-btn svg { width: 18px; height: 18px; stroke-width: 1.6; }

.search-box {
  display: flex; align-items: center; gap: 10px;
  width: 100%; max-width: 680px;
  height: 40px;
  padding: 0 14px;
  background: var(--color-bg);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.search-box:hover { background: var(--color-surface-hover); }
.search-box:focus-within {
  background: var(--color-surface);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-focus);
}
.search-box .search-icon {
  width: 18px;
  height: 18px;
  color: var(--color-text-sub);
  flex-shrink: 0;
  stroke-width: 2;
}
.search-box input {
  flex: 1; border: none; background: transparent; outline: none;
  font-size: calc(14px * var(--font-scale)); color: var(--color-text);
  min-width: 0;
}

.avatar {
  width: 32px; height: 32px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: calc(13px * var(--font-scale));
  flex-shrink: 0;
}

/* ユーザーメニュー（ログイン情報） */
.user-menu {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 4px 4px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  margin-left: 4px;
}
.user-menu:hover { background: var(--color-surface-hover); border-color: var(--color-border); }
.user-info {
  display: flex; flex-direction: column; align-items: flex-start;
  line-height: 1.2;
  min-width: 0;
}
.user-name {
  font-size: calc(12px * var(--font-scale));
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  max-width: 140px;
}
.user-role {
  font-size: calc(10.5px * var(--font-scale));
  color: var(--color-text-sub);
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  max-width: 140px;
}
.user-caret {
  width: 12px; height: 12px;
  color: var(--color-text-sub);
  flex-shrink: 0;
  transition: transform 0.18s;
}
.user-menu-wrap.is-open .user-caret { transform: rotate(180deg); }
.user-menu-wrap.is-open .user-menu { background: var(--color-surface-hover); border-color: var(--color-border); }

/* ユーザードロップダウン */
.user-menu-wrap { position: relative; }
.user-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-3);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.15s, transform 0.15s;
  overflow: hidden;
}
.user-menu-wrap.is-open .user-dropdown {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.user-dropdown-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-2);
}
.user-dropdown-name {
  font-size: calc(13.5px * var(--font-scale));
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: 0.2px;
  margin-bottom: 2px;
}
.user-dropdown-role {
  font-size: calc(11.5px * var(--font-scale));
  color: var(--color-text-sub);
}
.user-dropdown-list {
  list-style: none;
  margin: 0;
  padding: 6px;
}
.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: calc(13px * var(--font-scale));
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.user-dropdown-item:hover { background: var(--color-surface-hover); }
.user-dropdown-item svg { width: 16px; height: 16px; stroke-width: 1.6; flex-shrink: 0; color: var(--color-text-sub); }
.user-dropdown-item.is-danger { color: #c5221f; }
.user-dropdown-item.is-danger svg { color: #c5221f; }
.user-dropdown-item.is-danger:hover { background: #fce8e6; }
.user-dropdown-arrow { margin-left: auto; color: var(--color-text-muted); }
.user-status-dot {
  position: absolute;
  bottom: -1px; right: -1px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #2da55b;
  border: 2px solid var(--color-surface);
  box-shadow: 0 0 0 0.5px rgba(15, 23, 42, 0.04);
}
.avatar-wrap { position: relative; display: inline-flex; }

/* ロゴアイコン（ヘッダー左） */
.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 7px;
  flex-shrink: 0;
  box-shadow: var(--shadow-1);
}
.logo-icon svg { width: 16px; height: 16px; stroke-width: 2; }

/* サイドバー -------------------------------------------------------------- */
.sidebar {
  background: var(--color-bg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 8px 8px 0;
  overflow-y: auto;
}


/* === サイドバー上部「新規作成」ボタン (CRM .sidebar-new-cust-* 同型) === */
.sidebar-new-cust-row {
  padding: 12px 12px 8px;
}
.sidebar-new-cust-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 38px;
  padding: 0 12px;
  background: var(--color-primary);
  color: #fff;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-md);
  font-size: calc(13px * var(--font-scale));
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.05s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.sidebar-new-cust-btn:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  box-shadow: var(--shadow-2);
  color: #fff;
}
.sidebar-new-cust-btn:active {
  background: var(--color-primary-active);
  border-color: var(--color-primary-active);
  transform: translateY(0.5px);
}
.sidebar-new-cust-btn svg { flex-shrink: 0; width: 16px; height: 16px; }
.sidebar-new-cust-btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

/* collapsed 時: アイコンのみの丸ボタン */
.app.is-collapsed .sidebar-new-cust-row { padding: 12px 4px 8px; }
.app.is-collapsed .sidebar-new-cust-btn {
  width: 44px; height: 44px;
  padding: 0;
  border-radius: 50%;
}
.app.is-collapsed .sidebar-new-cust-label { display: none; }

.nav { display: flex; flex-direction: column; gap: 0; flex-shrink: 0; padding: 0 4px; }
.nav-section { display: flex; flex-direction: column; gap: 0; }
.nav-section + .nav-section { margin-top: 8px; }
.nav-section-title {
  display: flex;
  align-items: center;
  height: 26px;
  padding: 0 14px;
  font-size: calc(10.5px * var(--font-scale));
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  margin-top: 6px;
}

.nav-item {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 10px;
  height: 30px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: calc(13px * var(--font-scale));
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  position: relative;
}
.nav-item:hover { background: var(--color-surface-hover); }
.nav-item.is-active {
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 600;
}
.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 6px; bottom: 6px;
  width: 3px;
  background: var(--color-primary);
  border-radius: 2px;
}
.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  color: var(--color-text-sub);
}
.nav-icon svg { width: 16px; height: 16px; stroke-width: 1.6; }
.nav-item.is-active .nav-icon { color: var(--color-primary); }
.nav-item:hover .nav-icon { color: var(--color-text); }
.nav-count {
  font-size: calc(10.5px * var(--font-scale));
  color: var(--color-text-muted);
  background: transparent;
  font-weight: 500;
  letter-spacing: 0.2px;
}
.nav-item.is-active .nav-count { color: var(--color-primary); font-weight: 700; }

/* 親メニュー（折り畳み式） */
.nav-parent {
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.nav-caret {
  display: inline-flex;
  width: 12px; height: 12px;
  color: var(--color-text-muted);
  transition: transform 0.18s;
}
.nav-caret svg { width: 12px; height: 12px; stroke-width: 2; }
.nav-parent.is-open .nav-caret { transform: rotate(90deg); }

/* 子メニュー */
.nav-children {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.22s ease;
}
.nav-parent.is-open + .nav-children { max-height: 320px; }
.nav-child {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  height: 28px;
  padding: 0 14px 0 38px;
  border-radius: var(--radius-md);
  color: var(--color-text-sub);
  font-size: calc(12px * var(--font-scale));
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  position: relative;
}
.nav-child::before {
  content: "";
  position: absolute;
  left: 22px;
  top: 50%;
  width: 8px;
  height: 1px;
  background: var(--color-border-strong);
}
.nav-child:hover { background: var(--color-surface-hover); color: var(--color-text); }
.nav-child.is-active { color: var(--color-primary); font-weight: 600; }
.nav-child.is-active::before { background: var(--color-primary); }

.nav-divider {
  height: 1px; background: var(--color-border);
  margin: 6px 14px;
  flex-shrink: 0;
}

/* サイドバー下部ブロック（クレジット + システム情報リンク） */
.sidebar-bottom {
  margin-top: auto;
  flex-shrink: 0;
}

/* サイドバーフッター（クレジット） */
.sidebar-footer {
  padding: 14px 18px 12px;
  border-top: 1px solid var(--color-border);
  font-size: calc(11px * var(--font-scale));
  color: var(--color-text-sub);
  line-height: 1.6;
  flex-shrink: 0;
}

/* システム情報リンク（最下部） */
.sidebar-system-link {
  display: grid;
  grid-template-columns: 18px 1fr 12px;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-top: 1px solid var(--color-border);
  font-size: calc(12px * var(--font-scale));
  color: var(--color-text-sub);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  text-decoration: none;
}
.sidebar-system-link:hover { background: var(--color-surface-hover); color: var(--color-text); }
.sidebar-system-link.is-active { background: var(--color-primary-soft); color: var(--color-primary); font-weight: 600; }
.sidebar-system-link svg { width: 16px; height: 16px; stroke-width: 1.6; }
.sidebar-system-link .sys-arrow { color: var(--color-text-muted); width: 12px; height: 12px; }
.sidebar-system-link.is-active .sys-arrow { color: var(--color-primary); }
.credit-org { font-weight: 600; color: var(--color-text); font-size: calc(12px * var(--font-scale)); }
.credit-team { font-size: calc(11px * var(--font-scale)); }
.credit-logo { display: block; width: 140px; height: auto; margin-top: 3px; color: var(--color-text); }
.credit-logo-btn { display: block; width: 100%; padding: 0; margin: 0; background: none; border: 0; text-align: left; cursor: pointer; }
.credit-logo-btn:hover .credit-logo { opacity: 0.65; }
.credit-version { font-size: calc(10px * var(--font-scale)); color: var(--color-text-muted); margin-top: 6px; letter-spacing: 0.3px; }
.credit-mini { display: none; }

/* ロゴマークについて モーダル */
.about-modal { max-width: 460px; }
.about-modal-header { border-bottom: 0; padding-bottom: 0; min-height: 0; justify-content: flex-end; }
.about-modal-body { padding-top: 4px; }
.about-logo { display: block; width: 200px; height: auto; margin: 0 auto 22px; color: var(--color-text); }
.about-text { font-size: calc(13px * var(--font-scale)); line-height: 2.0; color: var(--color-text); text-align: left; margin: 0 0 20px; }
.about-dept { font-size: calc(12px * var(--font-scale)); color: var(--color-text-muted); text-align: right; margin: 0; }

/* メインコンテンツ -------------------------------------------------------- */
.main {
  background: var(--color-surface);
  margin: 10px 10px 10px 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
  min-height: 0;
  box-shadow: var(--shadow-1);
  border: 1px solid var(--color-border);
  font-size: calc(13px * var(--font-scale));
}
/* メイン領域内の主要テキスト系をフォントスケールで可変化 */
.main .badge { font-size: calc(11px * var(--font-scale)); }
.main .tab-count { font-size: calc(10.5px * var(--font-scale)); }
.main .info-label, .main .field-help, .main .field-error,
.main .list-date, .main .metric-label, .main .metric-delta,
.main .article-meta { font-size: calc(11.5px * var(--font-scale)); }
.main .page-subtitle, .main .btn-sm, .main .table thead th,
.main .breadcrumb, .main .pager { font-size: calc(12px * var(--font-scale)); }
.main .section-desc, .main .field-label, .main .alert-text,
.main .typography code, .main .typography pre,
.main .page-link { font-size: calc(12px * var(--font-scale)); }
.main .btn, .main .table, .main .alert,
.main .list-from, .main .list-body, .main .tab,
.main .notice { font-size: calc(13px * var(--font-scale)); }
.main .info-value, .main .input, .main .textarea, .main .select,
.main .choice, .main .switch, .main .typography h4,
.main .typography blockquote, .main .def-list,
.main .card-title { font-size: calc(13.5px * var(--font-scale)); }
.main .typography, .main .btn-lg { font-size: calc(14px * var(--font-scale)); }
.main .typography h3 { font-size: calc(14px * var(--font-scale)); }
.main .section-title { font-size: calc(16px * var(--font-scale)); }
.main .typography h2 { font-size: calc(16px * var(--font-scale)); }
.main .page-title { font-size: calc(20px * var(--font-scale)); }
.main .typography h1 { font-size: calc(20px * var(--font-scale)); }
.main .metric-value { font-size: calc(24px * var(--font-scale)); }

/* 文字サイズ切替ボタン（小A/大A アイコンで現在のサイズを表現） */
.font-size-btn { position: relative; }
.font-size-btn .font-size-aa {
  font-family: var(--font-sans);
  font-weight: 500;
  color: var(--color-text-sub);
  line-height: 1;
  user-select: none;
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
  transition: color 0.15s;
}
.font-size-btn .fs-a-sm { font-size: calc(11px * var(--font-scale)); transition: color 0.15s; }
.font-size-btn .fs-a-lg { font-size: calc(17px * var(--font-scale)); transition: color 0.15s; }
.font-size-btn[data-size="small"] .fs-a-sm,
.font-size-btn[data-size="large"] .fs-a-lg { color: var(--color-primary); }
.font-size-btn:hover .font-size-aa,
.font-size-btn:hover .fs-a-sm,
.font-size-btn:hover .fs-a-lg { color: var(--color-primary); }

/* === 構成図（SVG） === */
.diagram-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}
.diagram-svg {
  width: 100%;
  height: auto;
  display: block;
  font-family: var(--font-sans);
}
.diagram-box { fill: var(--color-surface-2); stroke: var(--color-border-strong); stroke-width: 1.5; }
.diagram-box.primary { fill: var(--color-primary-soft); stroke: var(--color-primary); }
.diagram-box.warn    { fill: rgba(176, 96, 0, 0.08); stroke: #b06000; stroke-dasharray: 4 3; }
.diagram-box.muted   { fill: var(--color-surface-2); stroke: var(--color-border-strong); stroke-dasharray: 4 3; }
.diagram-component   { fill: var(--color-surface); stroke: var(--color-border-strong); stroke-width: 1; }
.diagram-title       { font-size: calc(13px * var(--font-scale)); font-weight: 700; fill: var(--color-text); }
.diagram-comp-title  { font-size: calc(12px * var(--font-scale)); font-weight: 600; fill: var(--color-text); }
.diagram-comp-sub    { font-size: calc(10.5px * var(--font-scale)); fill: var(--color-text-sub); }
.diagram-sub         { font-size: calc(11px * var(--font-scale)); fill: var(--color-text-sub); }
.diagram-label       { font-size: calc(10.5px * var(--font-scale)); fill: var(--color-primary); font-weight: 700; letter-spacing: 0.3px; }
.diagram-label.warn  { fill: #b06000; }
.diagram-arrow       { stroke: var(--color-primary); stroke-width: 1.8; fill: none; }
.diagram-arrow.dashed{ stroke-dasharray: 4 3; stroke: #b06000; }
.diagram-arrow-head  { fill: var(--color-primary); }
.diagram-arrow-head.warn { fill: #b06000; }

/* ダーク調整 */
:root.dark .diagram-box.warn { fill: rgba(240, 184, 120, 0.10); stroke: #d68a30; }
:root.dark .diagram-label.warn { fill: #f0b878; }
:root.dark .diagram-arrow.dashed { stroke: #d68a30; }
:root.dark .diagram-arrow-head.warn { fill: #d68a30; }

/* レイヤー図の小型表示 */
.diagram-card.compact { padding: 14px 16px; max-width: 540px; }
.diagram-card.compact .diagram-svg { max-width: 100%; }

/* フォルダ構成ツリー */
.folder-tree {
  margin: 0;
  padding: 18px 20px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: calc(12px * var(--font-scale));
  line-height: 1.85;
  color: var(--color-text);
  overflow-x: auto;
  white-space: pre;
}
.folder-tree .ft-folder { color: var(--color-primary); font-weight: 700; }
.folder-tree .ft-file { color: var(--color-text); }
.folder-tree .ft-tree { color: var(--color-text-faint); }
.folder-tree .ft-comment { color: var(--color-text-muted); margin-left: 8px; font-style: normal; }
.folder-tree .ft-root { color: var(--color-primary-active); font-weight: 700; }
:root.dark .folder-tree .ft-root { color: var(--color-primary-hover); }

/* AIポータル（9ドット）アイコン */
.apps-btn svg { width: 20px; height: 20px; }
.apps-btn:hover svg circle { fill: var(--color-primary); }

/* テーマ切替 ピルトグル（左:太陽/月 · 右:ノブ · ダークで地色反転） */
.theme-toggle {
  position: relative; flex: 0 0 auto;
  width: 54px; height: 26px; padding: 0;
  border: 1px solid var(--color-text-muted);
  border-radius: 999px; background: var(--color-surface);
  cursor: pointer; -webkit-appearance: none; appearance: none;
  transition: background 0.2s, border-color 0.2s;
  /* ノブ塗り = メインカラーを30%薄めた色 (primary 70% + 白 30%) */
  --tt-knob-fill: color-mix(in srgb, var(--color-primary) 70%, #fff);
}
.theme-toggle .tt-icon {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  color: var(--color-text-sub); display: inline-flex; transition: color 0.2s;
}
.theme-toggle .tt-icon svg { width: 13px; height: 13px; }
.theme-toggle .tt-sun { stroke-width: 1.5; }
/* 表示切替: .tt-icon を含めて .tt-icon svg より詳細度を高くする */
.theme-toggle .tt-icon .tt-sun  { display: block; }
.theme-toggle .tt-icon .tt-moon { display: none; }
.theme-toggle .tt-knob {
  position: absolute; right: 3px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; box-sizing: border-box; border-radius: 50%;
  background: var(--tt-knob-fill); border: 1px solid var(--tt-knob-fill);
  transition: background 0.2s, border-color 0.2s;
}
.theme-toggle:hover { border-color: var(--color-primary); }
.theme-toggle:hover .tt-icon { color: var(--color-primary); }
.theme-toggle:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
:root.dark .theme-toggle { background: var(--color-surface-hover); border-color: var(--color-text-muted); }
:root.dark .theme-toggle .tt-icon .tt-sun  { display: none; }
:root.dark .theme-toggle .tt-icon .tt-moon { display: block; }
:root.dark .theme-toggle .tt-icon { color: var(--color-text); }
/* ダークは左右反転: 月=右 / ノブ=左 (スライド表現) */
:root.dark .theme-toggle .tt-icon { left: auto; right: 8px; }
:root.dark .theme-toggle .tt-knob { right: auto; left: 3px; }

.toolbar {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--color-border);
  height: 44px;
  flex-shrink: 0;
  background: var(--color-surface);
}
.toolbar-spacer { flex: 1; }
.tool-btn {
  width: 34px; height: 34px;
  border: none; background: transparent; color: var(--color-text-sub);
  border-radius: 50%; cursor: pointer;
  font-size: calc(15px * var(--font-scale));
  transition: background 0.15s;
}
.tool-btn:hover { background: var(--color-surface-hover); }
.checkbox { padding: 0 6px; }
.pager { font-size: calc(12px * var(--font-scale)); color: var(--color-text-sub); margin-right: 4px; }

.content { display: flex; flex-direction: column; min-height: 0; flex: 1; overflow-y: auto; }

/* セクション/カード（メイン領域内） ---------------------------------------- */
.section {
  padding: 32px;
  border-bottom: 1px solid var(--color-border);
}
.section:last-child { border-bottom: none; }
/* ページの最後の区画の下線は出さない (2026-11-04 ユーザー指示・CRM と同じ)。区画のあとにモーダル・script が続くと :last-child が効かず、
   画面の幅いっぱいの灰色の線が出るため。後ろに区画の兄弟が無い区画を消す (区画どうしの間の線は残る) */
.section:not(:has(~ .section)) { border-bottom: none; }
.section-title {
  font-size: calc(16px * var(--font-scale));
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--color-text);
  letter-spacing: 0.3px;
}
.section-desc {
  font-size: calc(13px * var(--font-scale));
  color: var(--color-text-sub);
  margin: 0 0 20px;
  line-height: 1.6;
}

/* リスト ----------------------------------------------------------------- */
.list {
  list-style: none; margin: 0; padding: 0;
}
.list-item {
  display: grid;
  grid-template-columns: 32px 24px 160px 1fr 80px;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  height: 44px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  background: var(--color-surface);
  position: relative;
  transition: background 0.12s;
}
.list-item:hover { background: var(--color-surface-hover); }
.list-item.is-unread { font-weight: 600; }
.list-item.is-unread::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--color-primary);
}
.list-item.is-unread .list-snippet { font-weight: 400; color: var(--color-text-sub); }

.list-star { color: #c8cdd5; cursor: pointer; transition: color 0.15s; }
.list-from { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: calc(13px * var(--font-scale)); }
.list-body { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: calc(13px * var(--font-scale)); }
.list-subject { color: var(--color-text); }
.list-snippet { color: var(--color-text-sub); font-weight: 400; }
.list-date { font-size: calc(11.5px * var(--font-scale)); color: var(--color-text-sub); text-align: right; font-variant-numeric: tabular-nums; }

/* === ボタンシステム (添付準拠) === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 18px;
  height: 34px;
  min-width: 96px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: calc(13px * var(--font-scale));
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s,
              box-shadow 0.15s, transform 0.05s;
  user-select: none;
  white-space: nowrap;
  text-align: center;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:disabled:hover { transform: none; }

/* Primary --------------------------------------------------------------- */
.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-1);
}
.btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); box-shadow: var(--shadow-2); }
.btn-primary:active { background: var(--color-primary-active); border-color: var(--color-primary-active); transform: translateY(0.5px); }

/* Secondary ------------------------------------------------------------- */
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn-secondary:hover { background: var(--color-primary-soft); }
.btn-secondary:active { background: var(--color-primary-soft-2); transform: translateY(0.5px); }

/* Neutral (戻る) — フラットな灰色ベタをやめ、淡いサーフェス+繊細な枠線+影の上品な二次ボタンに */
.btn-neutral {
  background: var(--color-surface);
  color: var(--color-text-sub);
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-1);
}
.btn-neutral:hover { background: var(--color-surface-hover); color: var(--color-text); border-color: var(--color-border-strong); box-shadow: var(--shadow-2); }
.btn-neutral:active { background: var(--color-border); border-color: var(--color-border-strong); transform: translateY(0.5px); box-shadow: var(--shadow-1); }

/* サイズバリアント ------------------------------------------------------- */
.btn-sm { height: 28px; padding: 0 12px; font-size: calc(12px * var(--font-scale)); min-width: 64px; }
.btn-lg { height: 40px; padding: 0 22px; font-size: calc(14px * var(--font-scale)); min-width: 128px; }
.btn-block { width: 100%; }

/* グループ -------------------------------------------------------------- */
.btn-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.btn-row.two { grid-template-columns: repeat(3, 1fr); gap: 12px; }
.btn-row.two .btn:nth-child(1) { grid-column: 1 / 2; }
.btn-row.two .btn:nth-child(2) { grid-column: 2 / 3; }
.btn-row.two .btn:nth-child(3) { grid-column: 3 / 4; }

/* === バッジ === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 9px;
  border-radius: var(--radius-pill);
  font-size: calc(10.5px * var(--font-scale));
  font-weight: 600;
  letter-spacing: 0.5px;
  line-height: 1;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}
.badge-success { background: #e6f4ea; color: #137333; }
.badge-info    { background: var(--color-primary-soft); color: var(--color-primary); }
.badge-warn    { background: #fef7e0; color: #b06000; }
.badge-muted   { background: #eef0f3; color: var(--color-text-sub); }
.badge.no-dot::before { display: none; }

/* === システム構成カード === */
.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.info-card {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.info-card:hover { border-color: var(--color-border-strong); background: var(--color-surface-2); }
.info-label {
  font-size: calc(11.5px * var(--font-scale));
  color: var(--color-text-sub);
  font-weight: 600;
  letter-spacing: 0.4px;
}
.info-value {
  font-size: calc(13.5px * var(--font-scale));
  color: var(--color-text);
  font-weight: 500;
  word-break: break-all;
}
.info-value code {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: calc(12px * var(--font-scale));
  background: #eef2f7;
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--color-primary-active);
}

/* === フォーム === */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px 24px;
}
.form-grid .full { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 6px; }
/* ラベルは横並びの中央揃え。文字と必須マークの高さが違うため、
   行の基準線に任せず中央で揃える（入力モーダル側の .field-label と同じ作り）。 */
.field-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: calc(12px * var(--font-scale));
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: 0.2px;
}
/* 必須マーク。文字の * ではなく単色 SVG のアスタリスクを置く（色は親から継承）。
   間隔は親の gap に任せるので margin は持たせない。 */
.field-required {
  color: var(--color-primary);
  display: inline-flex;
  align-items: center;
}
.field-required svg { width: 9px; height: 9px; }
.field-help { font-size: calc(11.5px * var(--font-scale)); color: var(--color-text-sub); }
.field-error { font-size: calc(11.5px * var(--font-scale)); color: #c5221f; font-weight: 600; }

.input,
.textarea,
.select {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  font-size: calc(13.5px * var(--font-scale));
  font-family: inherit;
  color: var(--color-text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.input:hover, .textarea:hover, .select:hover { border-color: #b3bac6; }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-focus);
}
.input::placeholder, .textarea::placeholder { color: var(--color-text-muted); }

.textarea {
  height: auto;
  min-height: 96px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.55;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235b6573' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 32px;
  cursor: pointer;
}

/* バリエーション */
.field.is-error .input,
.field.is-error .textarea,
.field.is-error .select { border-color: #c5221f; }
.field.is-error .input:focus,
.field.is-error .textarea:focus,
.field.is-error .select:focus { box-shadow: 0 0 0 3px rgba(197, 34, 31, 0.18); }

.input:disabled, .textarea:disabled, .select:disabled {
  background: #f3f4f6;
  color: var(--color-text-muted);
  cursor: not-allowed;
}

/* ===== プルダウン (検索なし) .pd-select (動きは static/js/pd_select.js) =====
   CRM (crm-pg) の検索なしプルダウンと同じデザイン (2026-10-22)。ボタンは .select と同じ高さ 38px・枠・角丸。
   一覧は角丸 10px・やわらかい影・内側 6px。行は 7px 12px・行の間 2px。指している行は淡い青の地に太字・青、今の値は太字・青とチェックの印。
   下に入りきらず上の方が広いときは .pd-panel に .is-up を付けて上に開く。
   使い方 (HTML):
     <div class="pd-select" data-blank-text="未選択">
       <input type="hidden" name="store" class="pd-value" value="">
       <button type="button" class="pd-btn is-blank" aria-haspopup="listbox" aria-expanded="false"><span class="pd-label">未選択</span>(下向きの矢印の svg.pd-caret)</button>
       <div class="pd-panel" hidden><ul class="pd-list" role="listbox">
         <li><button type="button" class="pd-opt" role="option" data-val="1" data-label="町田店"><span class="pd-opt-label">町田店</span><span class="pd-opt-tag">右に出す印</span>(svg.pd-check)</button></li>
       </ul></div>
     </div> */
.pd-select { position: relative; width: 100%; }
.pd-select .pd-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; height: 38px; padding: 0 12px;
  background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius-md);
  font-size: calc(13.5px * var(--font-scale)); font-family: inherit; color: var(--color-text); text-align: left; cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.pd-select .pd-btn:hover { border-color: var(--color-primary); }
.pd-select .pd-btn:focus-visible, .pd-select.is-open .pd-btn { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-soft); }
.pd-select .pd-btn.is-blank .pd-label { color: var(--color-text-muted); }
.pd-select .pd-label { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; }
.pd-select .pd-caret { flex: 0 0 auto; width: 16px; height: 16px; color: var(--color-text-sub); transition: transform 0.15s; }
.pd-select.is-open .pd-caret { transform: rotate(180deg); }
.pd-select .pd-panel {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 1000;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06); padding: 6px;
}
.pd-select .pd-panel.is-up { top: auto; bottom: calc(100% + 4px); }
.pd-select .pd-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; }
.pd-select .pd-list li + li { margin-top: 2px; }   /* 行の背景 (ハイライト) の間に隙間 */
.pd-select .pd-opt {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 12px;
  border: 0; background: transparent; border-radius: 8px;
  font-size: calc(13.5px * var(--font-scale)); font-family: inherit; color: var(--color-text); text-align: left; cursor: pointer; white-space: nowrap;
}
/* 指している行 (マウス・キーボード) は背景だけでなく文字も太字・青。開いたときに JS が今の値へ focus() を当てるので :focus で書く */
.pd-select .pd-opt:hover, .pd-select .pd-opt:focus { background: var(--color-primary-soft); color: var(--color-primary-active); font-weight: 600; outline: none; }
.pd-select .pd-opt.is-current { color: var(--color-primary-active); font-weight: 600; }
.pd-select .pd-opt.is-blank { color: var(--color-text-sub); }
.pd-select .pd-opt-label { flex: 1 1 auto; min-width: 0; overflow: hidden; }
.pd-select .pd-opt-tag { flex: 0 0 auto; font-size: calc(11px * var(--font-scale)); color: var(--color-text-sub); }
.pd-select .pd-check { flex: 0 0 auto; width: 16px; height: 16px; color: var(--color-primary); visibility: hidden; }
.pd-select .pd-opt.is-current .pd-check { visibility: visible; }

/* ===== 標準の select の開いた一覧 .sm-panel (static/js/select_menu.js が body に置く) =====
   閉じた select はそのまま (.select の見た目・name・値・送信・change)。開いたときの一覧だけを .pd-select の一覧と同じ見た目にする。
   optgroup は見出し (.sm-group)・disabled は薄く選べない (.is-disabled)。z-index は固定のパネルや重ねより上。
   長い選択肢は画面の幅まで広がる (切らない・折り返さない) */
.sm-panel {
  position: fixed; z-index: 10000; box-sizing: border-box;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06); padding: 6px;
}
.sm-panel .sm-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; overscroll-behavior: contain; }   /* 端まで送ってもページへ伝えない */
.sm-panel .sm-list li + li { margin-top: 2px; }
.sm-panel .sm-opt {
  display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-radius: 8px;
  font-size: calc(13.5px * var(--font-scale)); color: var(--color-text); cursor: pointer; white-space: nowrap; user-select: none;
}
.sm-panel .sm-opt.is-in-group { padding-left: 24px; }
.sm-panel .sm-opt.is-cursor { background: var(--color-primary-soft); color: var(--color-primary-active); font-weight: 600; }
.sm-panel .sm-opt.is-current { color: var(--color-primary-active); font-weight: 600; }
.sm-panel .sm-opt.is-blank { color: var(--color-text-sub); }
.sm-panel .sm-opt.is-disabled { color: var(--color-text-muted); font-weight: 400; cursor: default; }
.sm-panel .sm-opt-label { flex: 1 1 auto; }
.sm-panel .sm-check { flex: 0 0 auto; width: 16px; height: 16px; color: var(--color-primary); visibility: hidden; }
.sm-panel .sm-opt.is-current .sm-check { visibility: visible; }
.sm-panel .sm-group {
  padding: 6px 12px 2px; font-size: calc(11px * var(--font-scale)); font-weight: 600; color: var(--color-text-sub);
  white-space: nowrap; user-select: none; cursor: default;
}

/* インプットグループ（左アイコン） */
.input-group {
  position: relative;
  display: flex;
  align-items: center;
}
.input-group .input { padding-left: 36px; }
.input-group-icon {
  position: absolute;
  left: 12px;
  width: 16px; height: 16px;
  color: var(--color-text-sub);
  pointer-events: none;
}

/* ラジオ / チェックボックス（カスタム） */
.choice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: calc(13.5px * var(--font-scale));
  color: var(--color-text);
  user-select: none;
}
.choice input[type="radio"],
.choice input[type="checkbox"] {
  appearance: none;
  width: 18px; height: 18px;
  margin: 0;
  border: 1.5px solid var(--color-border-strong);
  background: var(--color-surface);
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.choice input[type="radio"] { border-radius: 50%; }
.choice input[type="checkbox"] { border-radius: 4px; }
.choice:hover input { border-color: var(--color-primary); }
.choice input:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.choice input:checked {
  background: var(--color-primary);
  border-color: var(--color-primary);
}
.choice input[type="radio"]:checked::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #fff;
  transform: translate(-50%, -50%);
}
.choice input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px; top: 1px;
  width: 5px; height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.choice-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

/* スイッチ（トグル） */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: calc(13.5px * var(--font-scale));
  user-select: none;
}
.switch input { display: none; }
.switch-track {
  width: 38px; height: 22px;
  background: #cbd2d9;
  border-radius: 999px;
  position: relative;
  transition: background 0.18s;
  flex-shrink: 0;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 0.18s;
}
.switch input:checked + .switch-track { background: var(--color-primary); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }

/* ファイル選択 */
.file-field {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.file-field input[type="file"] { display: none; }
.file-field-name { font-size: calc(12px * var(--font-scale)); color: var(--color-text-sub); }

/* フォームアクション */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--color-border);
}
.form-actions.start { justify-content: flex-start; }

/* === ページヘッダー（タイトル + ブレッドクラム + アクション） === */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.page-title {
  font-size: calc(20px * var(--font-scale));
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.3px;
  color: var(--color-text);
}
.page-subtitle {
  font-size: calc(12px * var(--font-scale));
  color: var(--color-text-sub);
  margin: 6px 0 0;
  line-height: 1.55;
}
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* === メインエリア タイトルヒーロー (CRM .dl-hero 同型・アイコン色はテンプレprimary) === */
.dl-hero {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 24px; flex-wrap: wrap; margin-bottom: 16px;
}
.dl-hero-title h1 {
  margin: 0 0 4px;
  font-size: calc(20px * var(--font-scale));
  font-weight: 700;
  color: var(--color-text);
  display: flex; align-items: center; gap: 10px;
}
.dl-hero-title h1 svg { color: var(--color-primary); }
.dl-hero-title p {
  margin: 0;
  color: var(--color-text-sub);
  font-size: calc(12px * var(--font-scale));
}

/* === ブレッドクラム === */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: calc(12px * var(--font-scale));
  color: var(--color-text-sub);
  margin: 0 0 6px;
  list-style: none;
  padding: 0;
}
.breadcrumb a:hover { color: var(--color-primary); text-decoration: underline; }
.breadcrumb-sep { color: var(--color-text-muted); }
.breadcrumb-current { color: var(--color-text); font-weight: 600; }

/* === タブ === */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 16px;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: calc(13px * var(--font-scale));
  font-weight: 500;
  color: var(--color-text-sub);
  cursor: pointer;
  border: none;
  background: transparent;
  border-bottom: 3px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.tab:hover { color: var(--color-text); }
.tab.is-active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}
.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: #eef0f3;
  color: var(--color-text-sub);
  border-radius: 9px;
  font-size: calc(10.5px * var(--font-scale));
  font-weight: 600;
}
.tab.is-active .tab-count { background: var(--color-primary-soft); color: var(--color-primary); }

/* === テーブル === */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: calc(13px * var(--font-scale));
}
.table thead th {
  text-align: center;
  font-weight: 600;
  padding: 11px 16px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: calc(11px * var(--font-scale));
  letter-spacing: 0.6px;
  text-transform: uppercase;
  white-space: nowrap;
  /* 見出しの固定は .table-wrap に高さを与えた表でだけ効く。
     .table-wrap は overflow-x:auto により overflow-y も auto 扱いになり、
     高さの指定が無いと縦に動く余地が無いため sticky は働かない。
     使うときは .table-wrap.is-scroll で高さを決める。 */
  position: sticky;
  top: 0;
}
.table-wrap.is-scroll { max-height: 420px; overflow-y: auto; }
.table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: middle;
  white-space: nowrap;
}
.table tbody tr:nth-child(even) td { background: var(--color-surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--color-primary-soft); }
.table .num,
.table .text-mono { font-variant-numeric: tabular-nums; }
.table .num { text-align: right; }
.table .actions { text-align: center; white-space: nowrap; }
.table .actions .btn { margin-left: 4px; }

/* === ページネーション === */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin-top: 14px;
}
.page-link {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text);
  border: 1px solid transparent;
  font-size: calc(12px * var(--font-scale));
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.page-link:hover { background: var(--color-surface-hover); }
.page-link.is-active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  font-weight: 700;
}
.page-link.is-disabled { color: var(--color-text-muted); cursor: not-allowed; }
.page-link.is-disabled:hover { background: transparent; }
.page-ellipsis { padding: 0 4px; color: var(--color-text-muted); }

/* === アラート === */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  border-left-width: 4px;
  font-size: calc(13px * var(--font-scale));
  margin-bottom: 10px;
}
.alert:last-child { margin-bottom: 0; }
.alert-icon {
  flex-shrink: 0;
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700;
  border-radius: 50%;
  font-size: calc(11px * var(--font-scale));
  color: #fff;
  margin-top: 1px;
}
.alert-body { flex: 1; }
.alert-title { font-weight: 600; margin-bottom: 2px; }
.alert-text { color: var(--color-text-sub); font-size: calc(12px * var(--font-scale)); line-height: 1.55; }
.alert-close {
  background: none; border: none; cursor: pointer;
  color: var(--color-text-muted);
  font-size: calc(16px * var(--font-scale)); line-height: 1;
  padding: 0 4px;
}
.alert-info    { background: var(--color-primary-soft); border-color: var(--color-primary); }
.alert-info .alert-icon { background: var(--color-primary); }
.alert-success { background: #e6f4ea; border-color: #137333; }
.alert-success .alert-icon { background: #137333; }
.alert-warn    { background: #fef7e0; border-color: #b06000; }
.alert-warn .alert-icon { background: #b06000; }
.alert-error   { background: #fce8e6; border-color: #c5221f; }
.alert-error .alert-icon { background: #c5221f; }

/* === カード === */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.card:hover { box-shadow: var(--shadow-2); border-color: var(--color-border-strong); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-2);
}
.card-title { font-size: calc(13.5px * var(--font-scale)); font-weight: 600; margin: 0; }
.card-body { padding: 16px; }
.card-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-2);
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

/* 統計カード（メトリクス用） */
.metric {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}
.metric-label { font-size: calc(11px * var(--font-scale)); color: var(--color-text-muted); font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase; }
.metric-value {
  font-size: calc(26px * var(--font-scale));
  font-weight: 700;
  color: var(--color-text);
  margin-top: 6px;
  letter-spacing: -0.6px;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.metric-delta { font-size: calc(11.5px * var(--font-scale)); font-weight: 600; margin-top: 6px; display: inline-flex; gap: 4px; font-variant-numeric: tabular-nums; }
.metric-delta.up { color: #137333; }
.metric-delta.down { color: #c5221f; }

/* === モーダル === */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  /* visibility も切る。opacity:0 だけだと閉じたモーダルの中のボタンが
     Tab の移動先に残り、どこにも枠が出ない状態になる。 */
  visibility: hidden;
  transition: opacity 0.18s, visibility 0.18s;
}
.modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}
.modal {
  background: var(--color-surface);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-3);
  transform: translateY(8px) scale(0.98);
  transition: transform 0.18s;
  overflow: hidden;
  border: 1px solid var(--color-border);
}
.modal-backdrop.is-open .modal { transform: translateY(0) scale(1); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--color-border);
}
.modal-title { font-size: calc(15px * var(--font-scale)); font-weight: 700; margin: 0; }
.modal-close {
  background: none; border: none; cursor: pointer;
  width: 28px; height: 28px;
  border-radius: 50%;
  color: var(--color-text-sub);
  font-size: calc(18px * var(--font-scale)); line-height: 1;
}
.modal-close:hover { background: var(--color-surface-hover); }
.modal-body { padding: 18px; font-size: calc(13.5px * var(--font-scale)); color: var(--color-text); }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-2);
}

/* === トースト（通知） === */
.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 250;
  max-width: 320px;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-3);
  font-size: calc(13px * var(--font-scale));
  animation: toast-in 0.2s ease-out;
}
.toast.success { border-left-color: #137333; }
.toast.warn { border-left-color: #b06000; }
.toast.error { border-left-color: #c5221f; }
.toast-title { font-weight: 600; margin-bottom: 2px; }
.toast-text { color: var(--color-text-sub); font-size: calc(12px * var(--font-scale)); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* === 空状態 / スケルトン === */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 20px;
  text-align: center;
}
.empty-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  border: 1px solid var(--color-primary-soft-2);
}
.empty-icon svg { width: 28px; height: 28px; stroke-width: 1.5; }
.empty-title { font-size: calc(14.5px * var(--font-scale)); font-weight: 700; margin: 0; }
.empty-desc { font-size: calc(12px * var(--font-scale)); color: var(--color-text-sub); margin: 4px 0 14px; }

.skeleton {
  display: block;
  background: linear-gradient(90deg, #eef0f3 0%, #f5f7fa 40%, #eef0f3 80%);
  background-size: 200% 100%;
  border-radius: 4px;
  animation: skeleton 1.4s ease-in-out infinite;
}
.skeleton.line { height: 10px; margin: 6px 0; }
.skeleton.line.short { width: 40%; }
.skeleton.line.medium { width: 70%; }
@keyframes skeleton {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* === タイポグラフィ（記事・本文） === */
.typography {
  font-size: calc(14px * var(--font-scale));
  line-height: 1.85;
  color: var(--color-text);
  max-width: 760px;
}
.typography h1,
.typography h2,
.typography h3,
.typography h4 {
  margin: 1.4em 0 0.6em;
  line-height: 1.4;
  color: var(--color-text);
  letter-spacing: 0.2px;
}
.typography h1:first-child,
.typography h2:first-child,
.typography h3:first-child,
.typography h4:first-child { margin-top: 0; }

.typography h1 {
  font-size: calc(20px * var(--font-scale));
  font-weight: 700;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--color-primary);
}
.typography h2 {
  font-size: calc(16px * var(--font-scale));
  font-weight: 700;
  padding-left: 10px;
  border-left: 3px solid var(--color-primary);
}
.typography h3 {
  font-size: calc(14px * var(--font-scale));
  font-weight: 600;
  color: var(--color-primary-active);
}
.typography h4 {
  font-size: calc(13.5px * var(--font-scale));
  font-weight: 600;
  color: var(--color-text-sub);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.typography p { margin: 0.6em 0; }
.typography strong { font-weight: 700; color: var(--color-text); }
.typography em { font-style: normal; background: linear-gradient(transparent 60%, #fef3c7 60%); padding: 0 2px; }
.typography a { color: var(--color-primary); text-decoration: underline; text-underline-offset: 3px; }
.typography a:hover { color: var(--color-primary-hover); }

.typography ul,
.typography ol { margin: 0.6em 0; padding-left: 1.5em; }
.typography li { margin: 4px 0; }
.typography ul li::marker { color: var(--color-primary); }

.typography blockquote {
  margin: 1em 0;
  padding: 12px 16px;
  background: var(--color-surface-2);
  border-left: 4px solid var(--color-primary);
  color: var(--color-text-sub);
  font-size: calc(13.5px * var(--font-scale));
  border-radius: 0 6px 6px 0;
}
.typography blockquote cite {
  display: block;
  margin-top: 6px;
  font-size: calc(11.5px * var(--font-scale));
  color: var(--color-text-muted);
  font-style: normal;
}

.typography code {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: calc(12px * var(--font-scale));
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--color-primary-active);
}

.typography pre {
  margin: 1em 0;
  padding: 14px 16px;
  background: #1f2937;
  color: #e5e7eb;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: calc(12px * var(--font-scale));
  line-height: 1.6;
}
.typography pre code {
  background: transparent; border: none; padding: 0;
  color: inherit; font-size: inherit;
}

.typography hr {
  border: 0;
  border-top: 1px dashed var(--color-border-strong);
  margin: 1.6em 0;
}

/* メタ情報（記事日時など） */
.article-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: calc(11.5px * var(--font-scale));
  color: var(--color-text-sub);
  margin: -6px 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
}
.article-meta-sep::before { content: "·"; margin: 0 4px; color: var(--color-text-muted); }

/* 注釈ボックス（補足/注意/ヒント） */
.notice {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  margin: 1em 0;
  font-size: calc(13px * var(--font-scale));
  line-height: 1.65;
}
.notice-tip   { background: var(--color-primary-soft); color: var(--color-primary-active); border: 1px solid var(--color-primary-soft-2); }
.notice-note  { background: var(--color-surface-2); color: var(--color-text); border: 1px solid var(--color-border); }
.notice-warn  { background: #fef7e0; color: #6b4500; border: 1px solid #f8d77a; }
.notice-icon { flex-shrink: 0; font-weight: 700; line-height: 1.55; min-width: 18px; text-align: center; }
.notice-body { flex: 1; }
.notice-title { font-weight: 700; display: block; margin-bottom: 2px; }

/* 定義リスト */
.def-list { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; margin: 0.6em 0; font-size: calc(13.5px * var(--font-scale)); }
.def-list dt { font-weight: 600; color: var(--color-text-sub); }
.def-list dd { margin: 0; color: var(--color-text); }

/* === タイポグラフィ補助 === */
.text-muted { color: var(--color-text-sub); }
.text-mono { font-family: "SF Mono", Menlo, Consolas, monospace; }
.text-right { text-align: right; }
.text-center { text-align: center; }

.kbd {
  display: inline-block;
  padding: 1px 6px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: calc(11px * var(--font-scale));
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--color-text);
}

/* === ユーティリティクラス（デモ・サブヘッダ・エラーページ等） === */

/* 余白・テキスト ユーティリティ */
.mt-14 { margin-top: 14px; }
.text-sm-flush { margin: 0; font-size: calc(13px * var(--font-scale)); }

/* デモ内サブヘッダ */
.demo-h3 {
  font-size: calc(13px * var(--font-scale));
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--color-text);
}
.demo-h3.spaced { margin: 18px 0 8px; }
.demo-h3.uppercase {
  font-size: calc(11px * var(--font-scale));
  font-weight: 700;
  color: var(--color-text-sub);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin: 18px 0 8px;
}

/* デモ用 行レイアウト */
.demo-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.demo-row.lg-gap { gap: 18px; }
.demo-row.center { justify-content: center; }
.demo-row.mb { margin-bottom: 18px; }
.demo-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: center; }
.demo-grid-2.start { align-items: flex-start; }

/* エラー（カード型） */
.error-card { text-align: center; padding: 28px 16px; }
.error-card .err-code {
  font-size: calc(44px * var(--font-scale));
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1;
  color: var(--color-primary);
}
.error-card .err-code.warn   { color: #b06000; }
.error-card .err-code.danger { color: #c5221f; }
.error-card .err-title { font-size: calc(14px * var(--font-scale)); font-weight: 700; margin: 6px 0 0; }
.error-card .err-desc { font-size: calc(12px * var(--font-scale)); color: var(--color-text-sub); margin: 6px 0 14px; }
:root.dark .error-card .err-code.warn   { color: #f0b878; }
:root.dark .error-card .err-code.danger { color: #ff8b89; }

/* 404 等 フルページエラー */
.error-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}
.error-page-content { text-align: center; max-width: 420px; }
.error-page-code {
  font-size: calc(96px * var(--font-scale));
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: -3px;
  line-height: 1;
  margin-bottom: 8px;
}
.error-page-title { font-size: calc(20px * var(--font-scale)); font-weight: 700; margin: 0 0 8px; }
.error-page-desc {
  font-size: calc(13px * var(--font-scale));
  color: var(--color-text-sub);
  line-height: 1.7;
  margin: 0 0 22px;
}
.error-page-actions { display: flex; gap: 8px; justify-content: center; }

/* 設定ページ レイアウト */
.settings-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 28px;
}
.settings-nav { position: sticky; top: 0; align-self: start; }
.settings-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings-nav-list .nav-item { text-decoration: none; }
.settings-card-stack > .card { margin-bottom: 18px; }
.settings-card-stack > .card:last-child { margin-bottom: 0; }
@media (max-width: 767px) {
  .settings-layout { grid-template-columns: 1fr; gap: 18px; }
  .settings-nav { position: static; }
}

/* スイッチ/チェックの縦並び */
.stack-list { display: flex; flex-direction: column; gap: 14px; }

/* 注釈系 */
.note-fine { font-size: calc(12px * var(--font-scale)); color: var(--color-text-sub); margin-top: 10px; }

/* 区切り */
.dotted-card {
  border: 1px dashed var(--color-border-strong);
  border-radius: 10px;
  background: var(--color-surface-2);
}
.bordered-card {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 14px;
  background: var(--color-surface);
}

/* === チャート（簡易SVG） === */
.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}
.chart-title { font-size: calc(13px * var(--font-scale)); font-weight: 600; color: var(--color-text); margin-bottom: 4px; }
.chart-subtitle { font-size: calc(11.5px * var(--font-scale)); color: var(--color-text-sub); margin-bottom: 12px; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-svg .axis { stroke: var(--color-border); stroke-width: 1; }
.chart-svg .grid { stroke: var(--color-border); stroke-width: 1; stroke-dasharray: 2 3; opacity: 0.6; }
.chart-svg .label { font-size: calc(10px * var(--font-scale)); fill: var(--color-text-muted); }
.chart-svg .bar { fill: var(--color-primary); transition: fill 0.15s; }
.chart-svg .bar:hover { fill: var(--color-primary-hover); }
.chart-svg .line { fill: none; stroke: var(--color-primary); stroke-width: 2; }
.chart-svg .area { fill: var(--color-primary); opacity: 0.12; }
.chart-svg .point { fill: var(--color-primary); }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: calc(11px * var(--font-scale)); color: var(--color-text-sub); margin-top: 10px; }
.chart-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend-dot { width: 10px; height: 10px; border-radius: 2px; }

/* === アコーディオン（<details>） === */
.accordion { border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; background: var(--color-surface); }
.accordion-item { border-bottom: 1px solid var(--color-border); }
.accordion-item:last-child { border-bottom: none; }
.accordion-item[open] { background: var(--color-surface-2); }
.accordion-header {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  font-size: calc(13.5px * var(--font-scale));
  font-weight: 600;
  color: var(--color-text);
  user-select: none;
  transition: background 0.12s;
}
.accordion-header:hover { background: var(--color-surface-hover); }
.accordion-header::-webkit-details-marker { display: none; }
.accordion-header::before {
  content: "›";
  display: inline-block;
  color: var(--color-text-muted);
  font-size: calc(16px * var(--font-scale));
  width: 14px;
  transition: transform 0.18s;
}
.accordion-item[open] > .accordion-header::before { transform: rotate(90deg); }
.accordion-body { padding: 8px 16px 16px 36px; font-size: calc(13px * var(--font-scale)); color: var(--color-text-sub); line-height: 1.7; }

/* === タイムライン === */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
  content: "";
  position: absolute;
  top: 8px; bottom: 8px;
  left: 8px;
  width: 2px;
  background: var(--color-border);
}
.timeline-item {
  position: relative;
  padding: 0 0 18px 28px;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-marker {
  position: absolute;
  left: 2px; top: 4px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 2px solid var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-surface);
  z-index: 1;
}
.timeline-item.is-success .timeline-marker { border-color: #2da55b; }
.timeline-item.is-warn .timeline-marker { border-color: #b06000; }
.timeline-item.is-muted .timeline-marker { border-color: var(--color-text-muted); }
.timeline-time { font-size: calc(11px * var(--font-scale)); color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.timeline-title { font-size: calc(13px * var(--font-scale)); font-weight: 600; color: var(--color-text); margin-top: 2px; }
.timeline-desc { font-size: calc(12px * var(--font-scale)); color: var(--color-text-sub); margin-top: 2px; line-height: 1.6; }

/* === プログレスバー === */
.progress {
  position: relative;
  height: 8px;
  background: var(--color-bg);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.progress.lg { height: 14px; }
.progress-bar.success { background: #2da55b; }
.progress-bar.warn { background: #b06000; }
.progress-bar.error { background: #c5221f; }
.progress-bar.striped {
  background-image: linear-gradient(45deg, rgba(255,255,255,0.2) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.2) 50%, rgba(255,255,255,0.2) 75%, transparent 75%);
  background-size: 16px 16px;
  animation: progress-stripe 1s linear infinite;
}
@keyframes progress-stripe {
  0% { background-position: 0 0; }
  100% { background-position: 16px 0; }
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: calc(11px * var(--font-scale));
  color: var(--color-text-sub);
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

/* 円形プログレス（SVG） */
.progress-circle { width: 64px; height: 64px; transform: rotate(-90deg); }
.progress-circle .track { fill: none; stroke: var(--color-bg); stroke-width: 6; }
.progress-circle .fill { fill: none; stroke: var(--color-primary); stroke-width: 6; stroke-linecap: round; transition: stroke-dashoffset 0.4s ease; }
.progress-circle-wrap { position: relative; display: inline-block; }
.progress-circle-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(13px * var(--font-scale));
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

/* === ツールチップ === */
.has-tooltip { position: relative; }
.has-tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(2px);
  background: #1f2937;
  color: #fff;
  font-size: calc(11px * var(--font-scale));
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 50;
}
.has-tooltip::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: #1f2937;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 50;
}
.has-tooltip:hover::after,
.has-tooltip:hover::before { opacity: 1; transform: translateX(-50%) translateY(0); }
.has-tooltip:hover::before { transform: translateX(-50%); }

/* === チップ / タグ === */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 10px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  font-size: calc(11.5px * var(--font-scale));
  color: var(--color-text);
  white-space: nowrap;
}
.chip.primary { background: var(--color-primary-soft); border-color: var(--color-primary-soft-2); color: var(--color-primary-active); }
.chip.success { background: #e6f4ea; border-color: #c1e6cd; color: #137333; }
.chip-close {
  background: none; border: none; cursor: pointer;
  margin-left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  color: var(--color-text-muted);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: calc(14px * var(--font-scale)); line-height: 1;
}
.chip-close:hover { background: rgba(0,0,0,0.06); color: var(--color-text); }
.chip-list { display: flex; gap: 6px; flex-wrap: wrap; }

/* === ステッパー / ウィザード === */
.stepper {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: stepper;
  gap: 0;
}
.stepper-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  text-align: center;
  counter-increment: stepper;
  min-width: 0;
}
.stepper-item::before {
  content: "";
  position: absolute;
  top: 14px; left: 50%; right: -50%;
  height: 2px;
  background: var(--color-border);
  z-index: 0;
}
.stepper-item:last-child::before { display: none; }
.stepper-item.is-complete::before { background: var(--color-primary); }
.stepper-marker {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 2px solid var(--color-border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: calc(12px * var(--font-scale));
  font-weight: 700;
  color: var(--color-text-muted);
  z-index: 1;
  position: relative;
  font-variant-numeric: tabular-nums;
}
.stepper-marker::before { content: counter(stepper); }
.stepper-item.is-active .stepper-marker { border-color: var(--color-primary); color: var(--color-primary); background: var(--color-primary-soft); }
.stepper-item.is-complete .stepper-marker { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.stepper-item.is-complete .stepper-marker::before { content: "✓"; }
.stepper-label {
  font-size: calc(12px * var(--font-scale));
  font-weight: 500;
  color: var(--color-text-muted);
  margin-top: 8px;
  padding: 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.stepper-item.is-active .stepper-label,
.stepper-item.is-complete .stepper-label { color: var(--color-text); font-weight: 600; }

/* === アバターグループ === */
.avatar.avatar-sm { width: 24px; height: 24px; font-size: calc(10.5px * var(--font-scale)); }
.avatar.avatar-md { width: 32px; height: 32px; font-size: calc(12px * var(--font-scale)); }
.avatar.avatar-lg { width: 40px; height: 40px; font-size: calc(14px * var(--font-scale)); }
.avatar-group {
  display: inline-flex;
  align-items: center;
}
.avatar-group .avatar {
  border: 2px solid var(--color-surface);
  margin-left: -8px;
  background: var(--color-primary);
}
.avatar-group .avatar:first-child { margin-left: 0; }
.avatar-group .avatar.avatar-more {
  background: var(--color-bg);
  color: var(--color-text-sub);
  border-color: var(--color-surface);
}

/* === ドロワー（右からスライド） === */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 180;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 380px;
  max-width: 90vw;
  background: var(--color-surface);
  box-shadow: var(--shadow-3);
  z-index: 200;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
}
.drawer.is-open { transform: translateX(0); }
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--color-border);
}
.drawer-title { font-size: calc(14.5px * var(--font-scale)); font-weight: 700; margin: 0; }
.drawer-close {
  background: none; border: none; cursor: pointer;
  width: 28px; height: 28px;
  border-radius: 50%;
  color: var(--color-text-sub);
  font-size: calc(18px * var(--font-scale)); line-height: 1;
}
.drawer-close:hover { background: var(--color-surface-hover); }
.drawer-body { flex: 1; padding: 18px; overflow-y: auto; }
.drawer-footer { padding: 12px 18px; border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; gap: 8px; background: var(--color-surface-2); }

/* === ファイルアップロード（ドラッグドロップ） === */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  border: 2px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
}
.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
}
.dropzone-icon {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.dropzone-icon svg { width: 22px; height: 22px; stroke-width: 1.6; }
.dropzone-title { font-size: calc(13.5px * var(--font-scale)); font-weight: 600; color: var(--color-text); }
.dropzone-desc { font-size: calc(12px * var(--font-scale)); color: var(--color-text-sub); margin-top: 4px; }
.dropzone-list { margin-top: 12px; list-style: none; padding: 0; font-size: calc(12px * var(--font-scale)); color: var(--color-text); text-align: left; }
.dropzone-list li {
  padding: 6px 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}

/* === 絞り込みフィルターパネル === */
.filter-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
}
.filter-section {
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}
.filter-section:last-child { border-bottom: none; padding-bottom: 0; }
.filter-section:first-child { padding-top: 0; }
.filter-section-title {
  font-size: calc(11.5px * var(--font-scale));
  font-weight: 700;
  color: var(--color-text-sub);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.filter-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
  margin-top: 8px;
}

/* === コマンドパレット（⌘+K） === */
.cmdk-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 220;
  padding: 80px 16px 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.cmdk-backdrop.is-open { opacity: 1; pointer-events: auto; }
.cmdk {
  width: 100%;
  max-width: 540px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  overflow: hidden;
  border: 1px solid var(--color-border);
  transform: translateY(-8px);
  transition: transform 0.18s;
}
.cmdk-backdrop.is-open .cmdk { transform: translateY(0); }
.cmdk-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
}
.cmdk-search svg { width: 18px; height: 18px; color: var(--color-text-sub); flex-shrink: 0; }
.cmdk-search input {
  flex: 1;
  border: none; background: transparent; outline: none;
  font-size: calc(14px * var(--font-scale)); color: var(--color-text);
  font-family: inherit;
}
.cmdk-list { list-style: none; margin: 0; padding: 6px 0; max-height: 360px; overflow-y: auto; }
.cmdk-group { padding: 6px 0; }
.cmdk-group-title {
  padding: 4px 16px;
  font-size: calc(10.5px * var(--font-scale));
  font-weight: 700;
  color: var(--color-text-muted);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.cmdk-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  font-size: calc(13px * var(--font-scale));
  cursor: pointer;
}
.cmdk-item:hover,
.cmdk-item.is-active { background: var(--color-surface-hover); }
.cmdk-item svg { width: 16px; height: 16px; color: var(--color-text-sub); }
.cmdk-item .kbd { margin-left: auto; }

/* === 通知センター === */
.notification-list { list-style: none; margin: 0; padding: 0; }
.notification-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}
.notification-item:last-child { border-bottom: none; }
.notification-item.is-unread { background: var(--color-primary-soft); padding: 12px; margin: 0 -12px; border-radius: var(--radius-sm); border-bottom: 1px solid transparent; }
.notification-icon {
  width: 32px; height: 32px;
  flex-shrink: 0;
  background: var(--color-primary-soft-2);
  color: var(--color-primary);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.notification-icon svg { width: 16px; height: 16px; stroke-width: 1.6; }
.notification-body { flex: 1; min-width: 0; }
.notification-title { font-size: calc(13px * var(--font-scale)); font-weight: 600; color: var(--color-text); margin-bottom: 2px; }
.notification-text { font-size: calc(12px * var(--font-scale)); color: var(--color-text-sub); line-height: 1.55; }
.notification-time { font-size: calc(11px * var(--font-scale)); color: var(--color-text-muted); margin-top: 4px; font-variant-numeric: tabular-nums; }

/* === マスター・ディテール === */
.master-detail {
  display: grid;
  grid-template-columns: 280px 1fr;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  overflow: hidden;
  min-height: 360px;
}
.master {
  border-right: 1px solid var(--color-border);
  background: var(--color-surface-2);
  overflow-y: auto;
}
.master-list { list-style: none; margin: 0; padding: 0; }
.master-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background 0.12s;
}
.master-item:hover { background: var(--color-surface-hover); }
.master-item.is-active { background: var(--color-primary-soft); border-left: 3px solid var(--color-primary); padding-left: 13px; }
.master-item-title { font-size: calc(13px * var(--font-scale)); font-weight: 600; color: var(--color-text); }
.master-item-meta { font-size: calc(11px * var(--font-scale)); color: var(--color-text-muted); margin-top: 2px; }
.detail { padding: 24px; overflow-y: auto; }

/* === 複数選択時のアクションバー === */
.bulk-action-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--color-text);
  color: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-3);
  font-size: calc(13px * var(--font-scale));
}
.bulk-count { font-weight: 700; }
.bulk-action-bar .btn {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-color: rgba(255,255,255,0.2);
}
.bulk-action-bar .btn:hover { background: rgba(255,255,255,0.18); }
.bulk-action-bar .bulk-close {
  margin-left: auto;
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.7);
  font-size: calc(16px * var(--font-scale)); line-height: 1;
}

/* === カレンダー === */
.calendar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: calc(12px * var(--font-scale));
  max-width: 320px;
}
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.calendar-month { font-size: calc(13px * var(--font-scale)); font-weight: 700; }
.calendar-nav { background: none; border: none; cursor: pointer; width: 26px; height: 26px; border-radius: 50%; color: var(--color-text-sub); }
.calendar-nav:hover { background: var(--color-surface-hover); }
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}
.calendar-dow {
  font-size: calc(10.5px * var(--font-scale));
  font-weight: 700;
  color: var(--color-text-muted);
  padding: 4px 0;
  letter-spacing: 0.5px;
}
.calendar-dow.sun { color: #c5221f; }
.calendar-dow.sat { color: var(--color-primary); }
.calendar-day {
  width: 32px; height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  font-variant-numeric: tabular-nums;
}
.calendar-day:hover { background: var(--color-surface-hover); }
.calendar-day.is-today { color: var(--color-primary); font-weight: 700; }
.calendar-day.is-selected { background: var(--color-primary); color: #fff; font-weight: 700; }
.calendar-day.is-other { color: var(--color-text-faint); }
.calendar-day.has-event { position: relative; }
.calendar-day.has-event::after {
  content: ""; position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: var(--color-primary);
}
.calendar-day.is-selected.has-event::after { background: #fff; }

/* === ステータスインジケーター === */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: calc(12px * var(--font-scale));
  color: var(--color-text);
}
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--color-text-muted);
  position: relative;
}
.status-indicator.is-online .status-dot { background: #2da55b; }
.status-indicator.is-online .status-dot::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: #2da55b;
  opacity: 0;
  animation: status-pulse 1.8s ease-out infinite;
}
.status-indicator.is-warn .status-dot { background: #b06000; }
.status-indicator.is-error .status-dot { background: #c5221f; }
.status-indicator.is-offline .status-dot { background: var(--color-text-muted); }
@keyframes status-pulse {
  0% { transform: scale(0.6); opacity: 0.5; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* === コードDiff / 比較ビュー === */
.diff {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: calc(12px * var(--font-scale));
}
.diff-row {
  display: grid;
  grid-template-columns: 40px 16px 1fr;
  align-items: stretch;
}
.diff-line-no { padding: 2px 8px; text-align: right; color: var(--color-text-muted); background: var(--color-surface-2); border-right: 1px solid var(--color-border); user-select: none; }
.diff-marker { padding: 2px 0; text-align: center; font-weight: 700; }
.diff-content { padding: 2px 10px; white-space: pre; overflow-x: auto; }
.diff-row.add { background: #e6f4ea; }
.diff-row.add .diff-marker { color: #137333; }
.diff-row.remove { background: #fce8e6; }
.diff-row.remove .diff-marker { color: #c5221f; }
.diff-row.context { background: var(--color-surface); }

/* === ヒートマップ === */
.heatmap {
  display: grid;
  grid-template-columns: 30px repeat(24, 1fr);
  gap: 2px;
  font-size: calc(10px * var(--font-scale));
  color: var(--color-text-muted);
}
.heatmap-row-label,
.heatmap-col-label { text-align: center; line-height: 18px; }
.heatmap-cell {
  height: 18px;
  background: var(--color-primary);
  border-radius: 2px;
  cursor: pointer;
  transition: outline 0.12s;
}
.heatmap-cell:hover { outline: 2px solid var(--color-text); outline-offset: 1px; }
/* 本体のマスと凡例で同じ色を使う (色の定義はここ 1 か所) */
.heatmap-cell[data-level="0"], .heatmap-legend-cell[data-level="0"] { background: var(--color-bg); }
.heatmap-cell[data-level="1"], .heatmap-legend-cell[data-level="1"] { background: rgba(14, 98, 181, 0.15); }
.heatmap-cell[data-level="2"], .heatmap-legend-cell[data-level="2"] { background: rgba(14, 98, 181, 0.35); }
.heatmap-cell[data-level="3"], .heatmap-legend-cell[data-level="3"] { background: rgba(14, 98, 181, 0.55); }
.heatmap-cell[data-level="4"], .heatmap-legend-cell[data-level="4"] { background: rgba(14, 98, 181, 0.75); }
.heatmap-cell[data-level="5"], .heatmap-legend-cell[data-level="5"] { background: rgba(14, 98, 181, 1); }
.heatmap-legend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: calc(11px * var(--font-scale));
  color: var(--color-text-sub);
  margin-top: 8px;
}
.heatmap-legend-cell { width: 14px; height: 14px; border-radius: 2px; }

/* === 権限/ロール管理マトリクス === */
.permission-table .perm-row {
  display: grid;
  grid-template-columns: 200px repeat(4, 1fr);
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  font-size: calc(12px * var(--font-scale));
}
.permission-table .perm-row:last-child { border-bottom: none; }
.permission-table .perm-row.head {
  background: var(--color-surface-2);
  font-weight: 700;
  color: var(--color-text-sub);
  font-size: calc(11px * var(--font-scale));
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.permission-table .perm-row .perm-name { color: var(--color-text); }
.permission-table .perm-row .perm-desc { font-size: calc(11px * var(--font-scale)); color: var(--color-text-muted); margin-top: 2px; }
.permission-table .perm-row > div { text-align: center; }
.permission-table .perm-row > div:first-child { text-align: left; }

/* === APIキー表示（マスク + コピー） === */
.api-key {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: calc(12px * var(--font-scale));
  color: var(--color-text);
}
.api-key-mask { letter-spacing: 1px; user-select: none; }
.api-key-copy {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-sub);
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px;
}
.api-key-copy:hover { background: var(--color-surface-hover); color: var(--color-primary); }
.api-key-copy svg { width: 14px; height: 14px; stroke-width: 1.6; }

/* === 印刷用スタイル === */
@media print {
  .app-header,
  .sidebar,
  .toolbar,
  .page-actions,
  .form-actions,
  .btn,
  .icon-btn,
  .user-menu-wrap,
  .sidebar-overlay,
  .toast-stack,
  .modal-backdrop,
  .drawer-backdrop,
  .drawer { display: none !important; }
  .app { display: block; height: auto; }
  .app-body { display: block; }
  .main {
    margin: 0; border: none; box-shadow: none; border-radius: 0;
  }
  body { background: #fff; color: #000; }
  .section { page-break-inside: avoid; padding: 16px 0; border: none; }
  .info-card, .card, .table-wrap { border-color: #999; }
  a { color: #000; text-decoration: underline; }
  @page { margin: 16mm; }
}

/* オーバーレイ（モバイル時のドロワー背景） --------------------------------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: var(--header-h) 0 0 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

/* ==========================================================================
   業務アプリ実績パーツ (CRM で標準化されたデザインをブランド変数ベースで収録)
   色は全て --color-primary 系 / color-mix で導出 → --brand-h/s/l だけで追従
   ========================================================================== */

/* --- 補助ユーティリティ --- */
.text-faint { color: var(--color-text-faint); }
table.table tbody tr.clickable,
.dl-table tbody tr.clickable { cursor: pointer; }

/* --- ボタン: アウトライン / 極小 (表内・行操作用) --- */
.btn-line {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 3px 10px; font-size: calc(12px * var(--font-scale)); font-weight: 600;
  font-family: inherit; line-height: 1.5; white-space: nowrap; cursor: pointer;
  color: var(--color-primary); background: transparent;
  border: 1px solid color-mix(in srgb, var(--color-primary) 40%, transparent);
  border-radius: var(--radius-sm);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn-line:hover { background: var(--color-primary-soft); border-color: var(--color-primary); }
.btn-line-danger { color: #c5221f; border-color: rgba(197, 34, 31, 0.4); }
.btn-line-danger:hover { background: #fce8e6; border-color: #c5221f; }
.btn-xs { min-width: 0; height: auto; padding: 4px 10px; font-size: calc(11px * var(--font-scale)); line-height: 1.4; }
/* 種別指定の無いボタンは枠付きの淡い面にする (地の色が透けない) */
.btn:not(.btn-primary):not(.btn-secondary):not(.btn-neutral):not(.btn-line):not(.btn-line-danger) {
  background: var(--color-surface); color: var(--color-text); border-color: var(--color-border-strong);
}
.btn:not(.btn-primary):not(.btn-secondary):not(.btn-neutral):not(.btn-line):not(.btn-line-danger):hover {
  background: var(--color-surface-hover);
}

/* --- 検索欄 (入力+クリア+ボタンを1枠に統合) --- */
.srch {
  position: relative; display: flex; align-items: center; box-sizing: border-box;
  flex: 1 1 auto; min-width: 220px; max-width: 480px;
  background: var(--color-surface-2); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); padding: 4px 4px 4px 36px;
  transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
}
.srch:focus-within { background: var(--color-surface); border-color: var(--color-primary); box-shadow: var(--shadow-focus); }
.srch-ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--color-text-muted); pointer-events: none; }
.srch-in {
  flex: 1 1 auto; min-width: 0; padding: 6px 4px; border: none; outline: none; background: transparent;
  font: inherit; color: var(--color-text);
}
.srch-in::placeholder { color: var(--color-text-muted); }
.srch-x {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 22px; height: 22px; margin-right: 4px; border-radius: 50%;
  color: var(--color-text-muted); transition: background 0.1s, color 0.1s;
}
.srch-x:hover { background: var(--color-surface-hover); color: var(--color-text); }
.srch-btn {
  flex: none; padding: 6px 16px; border: none; border-radius: 5px; cursor: pointer; white-space: nowrap;
  font: inherit; font-weight: 600; background: var(--color-primary); color: #fff; transition: background 0.12s;
}
.srch-btn:hover { background: var(--color-primary-hover); }

/* --- 注意ボックス (警告/成功/エラー/情報。ダーク対応) --- */
.attn-box { padding: 12px 14px; border-radius: var(--radius-sm); background: #fff4e0; border: 1px solid #f4d294; }
.attn-box-title { font-weight: 700; font-size: calc(12px * var(--font-scale)); color: #b06000; margin-bottom: 6px; }
.attn-box.attn-success { background: #e6f4ea; border-color: #a8d5b5; }
.attn-box.attn-success .attn-box-title { color: #137333; }
.attn-box.attn-danger { background: #fce8e6; border-color: #f4b8b3; }
.attn-box.attn-danger .attn-box-title { color: #c5221f; }
.attn-box.attn-info { background: var(--color-primary-soft); border-color: var(--color-primary-soft-2); }
.attn-box.attn-info .attn-box-title { color: var(--color-primary); }
:root.dark .attn-box { background: rgba(214, 138, 48, 0.12); border-color: rgba(214, 138, 48, 0.40); }
:root.dark .attn-box-title { color: #f0b878; }
:root.dark .attn-box.attn-success { background: rgba(45, 165, 91, 0.12); border-color: rgba(45, 165, 91, 0.40); }
:root.dark .attn-box.attn-success .attn-box-title { color: #6fd296; }
:root.dark .attn-box.attn-danger { background: rgba(197, 34, 31, 0.14); border-color: rgba(255, 107, 105, 0.40); }
:root.dark .attn-box.attn-danger .attn-box-title { color: #ff8b89; }

/* --- 一覧ページ部品 (絞り込み枠・件数・表・並べ替え・ページ送り・空表示) --- */
.dl-filter { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 14px 16px; margin-bottom: 14px; }
.dl-filter-simple { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.dl-result-count { font-size: calc(12px * var(--font-scale)); color: var(--color-text-sub); }
.dl-result-count b { color: var(--color-text); font-variant-numeric: tabular-nums; }
.dl-table-wrap { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; margin-bottom: 14px; }
.dl-table { width: 100%; border-collapse: collapse; }
.dl-table thead th {
  background: var(--color-surface-2); color: var(--color-text-sub); font-weight: 600; letter-spacing: 0.2px;
  padding: 10px; border-bottom: 1px solid var(--color-border); white-space: nowrap;
}
.dl-table tbody tr { border-bottom: 1px solid var(--color-border); transition: background 0.08s; }
.dl-table tbody tr:hover { background: var(--color-primary-soft); }
.dl-table tbody tr:nth-child(even):not(:hover) { background: color-mix(in srgb, var(--color-text) 2%, transparent); }
.dl-table tbody tr:last-child { border-bottom: none; }
.dl-table tbody td { padding: 9px 10px; vertical-align: middle; }
.dl-th-link { display: inline-flex; align-items: center; gap: 4px; color: inherit; cursor: pointer; }
.dl-th-link:hover, .dl-th.is-active { color: var(--color-primary); }
.dl-th-icon { color: var(--color-text-muted); }
.dl-th-icon-active { color: var(--color-primary); }
.dl-date { color: var(--color-text-sub); white-space: nowrap; }
.dl-pagination { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 14px; padding: 10px; }
.dl-page-info { font-size: calc(12px * var(--font-scale)); color: var(--color-text-sub); margin: 0 8px; font-variant-numeric: tabular-nums; }
.dl-page-info b { color: var(--color-text); }
.dl-empty { background: var(--color-surface); border: 1px dashed var(--color-border-strong); border-radius: var(--radius-md); padding: 56px 24px; text-align: center; color: var(--color-text-sub); }
.dl-empty svg { color: var(--color-text-muted); margin-bottom: 14px; }
.dl-empty-title { font-size: calc(14px * var(--font-scale)); font-weight: 600; color: var(--color-text); margin-bottom: 6px; }
.dl-empty-hint { font-size: calc(12px * var(--font-scale)); color: var(--color-text-muted); }
.dl-hero-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* --- 絞り込みチップ (店舗・区分などの切替) --- */
.bs-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.bs-chip {
  display: inline-flex; align-items: center; padding: 5px 13px; font-family: inherit;
  font-size: calc(12px * var(--font-scale)); font-weight: 500; line-height: 1.4; color: var(--color-text-sub);
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 10px;
  white-space: nowrap; cursor: pointer; transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.bs-chip:hover { border-color: var(--color-border-strong); color: var(--color-text); }
.bs-chip.is-empty { background: var(--color-surface-2); color: var(--color-text-muted); }
.bs-chip.is-active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; font-weight: 600; }

/* --- ランクタグ (S/A/B…の評価ラベル) --- */
.rank-tag {
  display: inline-block; padding: 1px 8px; font-size: calc(11px * var(--font-scale)); font-weight: 700;
  border-radius: var(--radius-sm); color: #fff; background: var(--color-text-muted); letter-spacing: 0.5px;
}
.rank-tag.rank-SS { background: linear-gradient(135deg, #f4d03f 0%, #b8860b 100%); }
.rank-tag.rank-S { background: #d93025; }
.rank-tag.rank-A { background: #e8710a; }
.rank-tag.rank-B { background: #1e8e3e; }
.rank-tag.rank-C { background: var(--color-primary); }
.rank-tag.rank-D { background: #12888a; }
.rank-tag.rank-F { background: #80868b; }

/* --- 項目名/値 の定義グリッド (詳細画面) --- */
.field-grid { display: grid; grid-template-columns: 130px 1fr; gap: 8px 16px; margin: 0; }
.field-grid dt { color: var(--color-text-sub); font-weight: 500; }
.field-grid dd { margin: 0; color: var(--color-text); word-break: break-all; }

/* --- 画面下追従の保存バー (編集ページ) --- */
.sticky-actions {
  position: sticky; bottom: 0; z-index: 5; margin: 28px 0 0; padding: 14px 20px;
  display: flex; justify-content: center; gap: 12px;
  background: var(--color-surface); border-top: 1px solid var(--color-border);
  box-shadow: 0 -4px 12px rgba(15, 23, 42, 0.05); border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.sticky-actions .btn { min-width: 120px; }

/* --- 状態連動タブ (.std-tab の --tab-line で下線色を制御) --- */
.std-tabs {
  display: flex; gap: 4px; flex-wrap: wrap; margin: 12px 0 18px;
  --tab-line: var(--color-border); border-bottom: 2px solid var(--tab-line);
}
.std-tabs:has(.std-tab.is-active) { --tab-line: var(--color-primary); }
.std-tabs:has(.std-tab.is-active[data-tab-color="green"]) { --tab-line: #00796b; }
.std-tabs:has(.std-tab.is-active[data-tab-color="purple"]) { --tab-line: #7e3ed1; }
.std-tabs:has(.std-tab.is-active[data-tab-color="orange"]) { --tab-line: #b06000; }
.std-tabs:has(.std-tab.is-active[data-tab-color="red"]) { --tab-line: #c5221f; }
.std-tab {
  position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px;
  color: var(--color-text-sub); font-weight: 600; border-radius: 6px 6px 0 0; cursor: pointer; user-select: none;
  transition: background 0.15s, color 0.15s;
}
.std-tab:hover { background: var(--color-surface-2); color: var(--color-text); }
.std-tab.is-active { color: var(--color-primary); background: var(--color-primary-soft); }
.std-tab::after { content: ''; position: absolute; left: 0; right: -4px; bottom: -2px; height: 2px; background: var(--tab-line); pointer-events: none; }
.std-tab:last-child::after { right: 0; }
/* 箱型バリアント: 通常=淡いグレー / 選択=ブランド淡色 + 太い下線 */
.std-tabs.std-tabs-boxed { gap: 6px; --tab-line: var(--color-border-strong); }
.std-tabs-boxed .std-tab { background: var(--color-surface-2); border: 1px solid var(--color-border); border-bottom: none; border-radius: 8px 8px 0 0; }
.std-tabs-boxed .std-tab:hover { background: var(--color-surface-hover); }
.std-tabs-boxed .std-tab.is-active { background: var(--color-primary-soft); border-color: var(--color-primary-soft-2); }
.std-tabs-boxed .std-tab::after { right: -6px; }
.std-tabs-boxed .std-tab:last-child::after { right: 0; }
.std-tabs-boxed .std-tab.is-active::after { background: var(--color-primary); height: 3px; right: 0; }
@media (max-width: 767px) {
  /* 横送りは下の .std-tabs-wrap が持つ。.std-tabs 自身に overflow を付けると
     ::after で描く下線 (bottom:-3px) が切られ、選択タブの線が消える。 */
  .std-tabs { flex-wrap: nowrap; }
  .std-tab { white-space: nowrap; }
}

/* --- 磨き込みモーダル (グラデ見出し / 番号付きセクション / ピル型チップ) --- */
.modal-footer.modal-footer-center { justify-content: center; }
.modal-polished .nc-modal-card {
  max-width: 760px; max-height: 92vh; display: flex; flex-direction: column;
  border-radius: 18px; overflow: hidden; box-shadow: 0 24px 64px rgba(15, 23, 42, 0.22);
}
.modal-polished .nc-form { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.modal-polished .nc-modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--color-primary) 10%, var(--color-surface)) 0%, var(--color-surface) 70%);
  border-bottom: 1px solid var(--color-border); padding: 18px 22px 16px;
}
.modal-polished .nc-modal-header-text { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }
.modal-polished .modal-title { display: inline-flex; align-items: center; gap: 8px; font-size: calc(17px * var(--font-scale)); font-weight: 700; }
.modal-polished .nc-title-ic { width: 20px; height: 20px; color: var(--color-primary); stroke-width: 2; }
.modal-polished .nc-modal-subtitle { margin: 0; font-size: calc(12px * var(--font-scale)); color: var(--color-text-sub); letter-spacing: 0.2px; }
.modal-polished .nc-modal-body { overflow-y: auto; flex: 1 1 auto; padding: 24px; background: color-mix(in srgb, var(--color-bg) 60%, var(--color-surface)); }
.modal-polished .nc-section {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  padding: 20px; margin: 0 0 16px; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}
.modal-polished .nc-section:last-child { margin-bottom: 0; }
.modal-polished .nc-section-head { display: flex; align-items: baseline; gap: 10px; padding-bottom: 10px; margin-bottom: 14px; border-bottom: 1px dashed var(--color-border); }
.modal-polished .nc-section-no {
  display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; flex-shrink: 0;
  border-radius: 50%; background: var(--color-primary); color: #fff; font-size: calc(12px * var(--font-scale)); font-weight: 700;
}
.modal-polished .nc-section-title { margin: 0; font-size: calc(14px * var(--font-scale)); font-weight: 700; flex-shrink: 0; }
.modal-polished .nc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.modal-polished .nc-grid .field.full { grid-column: 1 / -1; }
.modal-polished .field-label { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; font-size: calc(12px * var(--font-scale)); font-weight: 600; }
.modal-polished .field-required { color: #dc2626; font-weight: 700; margin-left: 2px; }
.modal-polished .field-hint {
  margin-left: auto; padding: 1px 6px; border-radius: 9999px;
  font-size: calc(10px * var(--font-scale)); font-weight: 500; color: var(--color-text-muted); background: var(--color-surface-hover);
}
.modal-polished .input:focus, .modal-polished .select:focus, .modal-polished .textarea:focus {
  border-color: var(--color-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 18%, transparent);
}
.modal-polished .input[readonly], .modal-polished .input[disabled] { background: var(--color-surface-hover); color: var(--color-text-sub); cursor: default; }
.modal-polished .nc-chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.modal-polished .nc-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; cursor: pointer; user-select: none;
  border: 1px solid var(--color-border); border-radius: 9999px; background: var(--color-surface);
  font-size: calc(12px * var(--font-scale)); font-weight: 500; color: var(--color-text-sub); transition: all 0.15s;
}
.modal-polished .nc-chip:hover { border-color: color-mix(in srgb, var(--color-primary) 50%, var(--color-border)); color: var(--color-text); }
.modal-polished .nc-chip input[type="checkbox"] { width: 14px; height: 14px; margin: 0; accent-color: var(--color-primary); cursor: pointer; }
.modal-polished .nc-chip:has(input:checked) {
  background: color-mix(in srgb, var(--color-primary) 12%, var(--color-surface));
  border-color: var(--color-primary); color: var(--color-primary); font-weight: 600;
}
.modal-polished .nc-modal-footer { display: flex; justify-content: center; gap: 12px; padding: 14px 22px 18px; background: var(--color-surface); border-top: 1px solid var(--color-border); }
.modal-polished .nc-modal-footer .btn { min-width: 120px; }
.modal-polished .nc-submit { box-shadow: 0 2px 6px color-mix(in srgb, var(--color-primary) 35%, transparent); }
.modal-polished .nc-submit:hover { box-shadow: 0 4px 12px color-mix(in srgb, var(--color-primary) 45%, transparent); transform: translateY(-1px); }
@media (max-width: 767px) {
  .modal-polished .nc-grid { grid-template-columns: 1fr; }
  .modal-polished .nc-modal-body, .modal-polished .nc-section { padding: 16px; }
}

/* === レスポンシブ === */
@media (max-width: 1023px) {
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-header { grid-template-columns: minmax(200px, 280px) 1fr auto; }
  .btn-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 767px) {
  :root { --header-h: 96px; }

  .app-header {
    grid-template-columns: auto 1fr auto;
    grid-template-rows: 52px auto;
    padding: 0 8px;
    column-gap: 8px;
    row-gap: 0;
  }
  .header-center {
    grid-column: 1 / -1;
    grid-row: 2;
    padding: 0 0 8px;
  }
  .header-center .search-box { max-width: 100%; }
  .logo { font-size: calc(17px * var(--font-scale)); }
  .brand-sub { display: none; }

  .app-body,
  .app.is-collapsed .app-body { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 100;
    background: var(--color-surface);
    box-shadow: var(--shadow-3);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .app.is-drawer-open .sidebar { transform: translateX(0); }
  .app.is-drawer-open .sidebar-overlay {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  /* モバイル時のドロワー内は常に展開状態として表示 */
  .nav-label,
  .app.is-collapsed .nav-label,
  .nav-count,
  .app.is-collapsed .nav-count,
  .nav-caret,
  .app.is-collapsed .nav-caret,
  .nav-section-title,
  .app.is-collapsed .nav-section-title,
  .nav-children,
  .app.is-collapsed .nav-children { display: revert; }
  .app.is-collapsed .nav-children { display: flex; }

  .nav-item,
  .app.is-collapsed .nav-item {
    grid-template-columns: 18px 1fr auto;
    padding: 0 14px;
    justify-items: stretch;
    border-radius: var(--radius-md);
    margin: 0;
    width: auto;
    height: 30px;
  }
  .sidebar-footer,
  .app.is-collapsed .sidebar-footer {
    padding: 14px 18px 12px; text-align: left;
  }
  .credit-org, .credit-team, .credit-version,
  .app.is-collapsed .credit-org,
  .app.is-collapsed .credit-team,
  .app.is-collapsed .credit-version { display: block; }
  .credit-logo,
  .app.is-collapsed .credit-logo { display: block; }
  .credit-mini,
  .app.is-collapsed .credit-mini { display: none; }
  .sidebar-system-link,
  .app.is-collapsed .sidebar-system-link {
    grid-template-columns: 18px 1fr 12px;
    justify-items: stretch;
    padding: 10px 18px;
  }
  .sidebar-system-link .sys-label,
  .app.is-collapsed .sidebar-system-link .sys-label,
  .sidebar-system-link .sys-arrow,
  .app.is-collapsed .sidebar-system-link .sys-arrow { display: inline; }

  .main { margin: 8px; border-radius: var(--radius-md); }

  .search-box { height: 38px; padding: 0 12px; }
  .search-box input { font-size: calc(14px * var(--font-scale)); }

  .list-item {
    grid-template-columns: 28px 24px 1fr 60px;
    grid-template-rows: auto auto;
    height: auto;
    padding: 8px 12px;
    gap: 4px 8px;
  }
  .list-from { grid-row: 1; grid-column: 3 / 4; font-size: calc(13px * var(--font-scale)); }
  .list-body {
    grid-row: 2; grid-column: 3 / 4;
    white-space: normal;
    overflow: hidden; text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
  }
  .list-date { grid-row: 1; grid-column: 4 / 5; }
  .list-check, .list-star { grid-row: 1 / 3; align-self: center; }

  .user-menu .user-info,
  .user-menu .user-caret { display: none; }
  .user-menu { padding: 0; border: none; background: transparent; }

  .section { padding: 16px; }
  .btn-row { grid-template-columns: 1fr; }
  .info-grid, .form-grid, .demo-grid-2 { grid-template-columns: 1fr !important; gap: 14px; }
  .info-card { grid-template-columns: 100px 1fr; }
  .info-card .badge { grid-column: 1 / -1; justify-self: start; }
  .card-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-actions { justify-content: flex-end; }
  .toast-stack { right: 8px; bottom: 8px; left: 8px; max-width: none; }
}

@media (max-width: 380px) {
  .logo { font-size: calc(16px * var(--font-scale)); }
  .avatar { margin-left: 0; }
}

/* === ダークモード === */
:root.dark {
  /* ダーク用ブランド調整（色相は引き継ぎ、彩度↓・明度↑） */
  --brand-s: 65%;
  --brand-l: 54%;

  --color-bg: #0f1420;
  --color-surface: #1a2030;
  --color-surface-2: #222a3c;
  --color-surface-hover: #2a3447;
  --color-border: #2c3548;
  --color-border-strong: #3a4560;
  --color-text: #e6eaf2;
  --color-text-sub: #a3aab8;
  --color-text-muted: #6b7588;
  --color-text-faint: #525b6f;

  --color-primary:        hsl(var(--brand-h) var(--brand-s) var(--brand-l));
  --color-primary-hover:  hsl(var(--brand-h) var(--brand-s) calc(var(--brand-l) + 7%));
  --color-primary-active: hsl(var(--brand-h) var(--brand-s) calc(var(--brand-l) + 12%));
  --color-primary-soft:   hsl(var(--brand-h) 40% 18%);
  --color-primary-soft-2: hsl(var(--brand-h) 40% 24%);

  --color-neutral: #3a4560;
  --color-neutral-hover: #4a5670;
  --color-neutral-active: #5a6680;

  --shadow-1: 0 1px 1px rgba(0, 0, 0, 0.25);
  --shadow-2: 0 1px 3px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-3: 0 4px 12px rgba(0, 0, 0, 0.4), 0 12px 28px rgba(0, 0, 0, 0.35);
  --shadow-focus: 0 0 0 3px hsl(var(--brand-h) var(--brand-s) var(--brand-l) / 0.25);
}

/* セレクト矢印アイコンを明色に */
:root.dark .select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a3aab8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

/* アラート（背景・色を暗背景向けに） */
:root.dark .alert-success { background: rgba(45, 165, 91, 0.14); border-color: #2da55b; }
:root.dark .alert-warn    { background: rgba(176, 96, 0, 0.18); border-color: #d68a30; }
:root.dark .alert-error   { background: rgba(197, 34, 31, 0.16); border-color: #ff6b69; }
:root.dark .alert-success .alert-icon { background: #2da55b; }
:root.dark .alert-warn    .alert-icon { background: #d68a30; }
:root.dark .alert-error   .alert-icon { background: #ff6b69; }

/* バッジ */
:root.dark .badge-success { background: rgba(45, 165, 91, 0.2); color: #6fd296; }
:root.dark .badge-warn    { background: rgba(214, 138, 48, 0.2); color: #f0b878; }
:root.dark .badge-muted   { background: rgba(140, 149, 163, 0.18); color: var(--color-text-sub); }

/* チップ（success） */
:root.dark .chip.success { background: rgba(45, 165, 91, 0.18); border-color: rgba(45, 165, 91, 0.35); color: #6fd296; }

/* メトリクス変動 */
:root.dark .metric-delta.up   { color: #6fd296; }
:root.dark .metric-delta.down { color: #ff8b89; }

/* メトリクス値（稼働中表示など） */
:root.dark .metric-value[style*="#137333"] { color: #6fd296 !important; }

/* フォームエラー */
:root.dark .field-error { color: #ff8b89; }
:root.dark .field.is-error .input,
:root.dark .field.is-error .textarea,
:root.dark .field.is-error .select { border-color: #ff8b89; }
:root.dark .field.is-error .input:focus,
:root.dark .field.is-error .textarea:focus,
:root.dark .field.is-error .select:focus { box-shadow: 0 0 0 3px rgba(255, 139, 137, 0.18); }

/* 編集不可入力欄 (disabled) のダーク用背景 */
:root.dark .input:disabled,
:root.dark .textarea:disabled,
:root.dark .select:disabled {
  background: var(--color-surface-hover);
  color: var(--color-text-muted);
}

/* info-card 内の code バッジ (例: アクセスURL) のダーク用 */
:root.dark .info-value code {
  background: var(--color-primary-soft);
  color: var(--color-primary-hover);
}

/* Diff（差分） */
:root.dark .diff-row.add    { background: rgba(45, 165, 91, 0.18); }
:root.dark .diff-row.add    .diff-marker { color: #6fd296; }
:root.dark .diff-row.remove { background: rgba(197, 34, 31, 0.18); }
:root.dark .diff-row.remove .diff-marker { color: #ff8b89; }

/* スケルトン */
:root.dark .skeleton {
  background: linear-gradient(90deg, #2a3447 0%, #344057 40%, #2a3447 80%);
  background-size: 200% 100%;
}

/* 通知センター 未読 */
:root.dark .notification-item.is-unread { background: rgba(61, 139, 214, 0.14); }

/* カレンダー（曜日色） */
:root.dark .calendar-dow.sun { color: #ff8b89; }

/* タイムラインの色付きマーカー */
:root.dark .timeline-item.is-success .timeline-marker { border-color: #6fd296; }
:root.dark .timeline-item.is-warn    .timeline-marker { border-color: #f0b878; }

/* プログレスバー成功色 */
:root.dark .progress-bar.success { background: #6fd296; }
:root.dark .progress-bar.warn    { background: #f0b878; }
:root.dark .progress-bar.error   { background: #ff8b89; }

/* ヒートマップのレベル */
:root.dark .heatmap-cell { background: var(--color-bg); }
:root.dark .heatmap-cell[data-level="1"], :root.dark .heatmap-legend-cell[data-level="1"] { background: rgba(61, 139, 214, 0.18); }
:root.dark .heatmap-cell[data-level="2"], :root.dark .heatmap-legend-cell[data-level="2"] { background: rgba(61, 139, 214, 0.35); }
:root.dark .heatmap-cell[data-level="3"], :root.dark .heatmap-legend-cell[data-level="3"] { background: rgba(61, 139, 214, 0.55); }
:root.dark .heatmap-cell[data-level="4"], :root.dark .heatmap-legend-cell[data-level="4"] { background: rgba(61, 139, 214, 0.78); }
:root.dark .heatmap-cell[data-level="5"], :root.dark .heatmap-legend-cell[data-level="5"] { background: rgba(61, 139, 214, 1); }

/* ステータス */
:root.dark .status-indicator.is-online .status-dot { background: #6fd296; }
:root.dark .status-indicator.is-online .status-dot::after { background: #6fd296; }
:root.dark .status-indicator.is-warn .status-dot { background: #f0b878; }
:root.dark .status-indicator.is-error .status-dot { background: #ff8b89; }

/* バルクアクションバー（暗色固定） */
:root.dark .bulk-action-bar { background: #2a3447; color: var(--color-text); }
:root.dark .bulk-action-bar .btn { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.16); color: var(--color-text); }
:root.dark .bulk-action-bar .btn:hover { background: rgba(255,255,255,0.14); }

/* オンラインドット枠（アバター） */
:root.dark .user-status-dot { background: #6fd296; box-shadow: 0 0 0 0.5px rgba(0,0,0,0.3); }

/* テーブル ヘッダーボーダー */
:root.dark .table thead th { background: var(--color-surface-2); border-bottom-color: var(--color-border); }

/* タイポグラフィ pre は元から暗背景 → ダーク時は若干調整 */
:root.dark .typography pre { background: #0a0e16; border: 1px solid var(--color-border); }
:root.dark .typography em { background: linear-gradient(transparent 60%, rgba(240, 184, 120, 0.35) 60%); }

/* エラーページ・ログイン背景 */
:root.dark .login-page { background: linear-gradient(180deg, var(--color-bg) 0%, #1a2c44 100%); }

/* 選択 */
:root.dark ::selection { background: rgba(61, 139, 214, 0.35); }

/* スクロールバー（macOS では効かない場合あり、Chrome/Safari ではOK） */
:root.dark ::-webkit-scrollbar { width: 12px; height: 12px; }
:root.dark ::-webkit-scrollbar-track { background: var(--color-bg); }
:root.dark ::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: 6px; border: 3px solid var(--color-bg); }
:root.dark ::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* テーマ切替時のスムーズトランジション（背景・文字色のみ、既存transitionを破壊しない） */
body, .app-header, .sidebar, .main {
  transition: background-color 0.25s ease, color 0.2s ease;
}

/* ==========================================================================
   ログイン画面 (login.html の <style> から外部化)
   ========================================================================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, var(--color-bg) 0%, var(--color-primary-soft) 100%);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  box-shadow: var(--shadow-3);
  overflow: hidden;
}
.login-header {
  padding: 28px 28px 16px;
  text-align: center;
}
.login-logo {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-2);
}
.login-logo svg { width: 28px; height: 28px; stroke-width: 2; }
.login-title {
  font-size: calc(18px * var(--font-scale));
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 4px;
  letter-spacing: 0.3px;
}
.login-subtitle {
  font-size: calc(12px * var(--font-scale));
  color: var(--color-text-sub);
  margin: 0;
}
.login-body { padding: 8px 28px 24px; }
.login-field { margin-top: 14px; }
.login-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  font-size: calc(12px * var(--font-scale));
}
.login-options a { color: var(--color-primary); }
.login-options a:hover { text-decoration: underline; }
.login-submit {
  margin-top: 20px;
}
.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  font-size: calc(11px * var(--font-scale));
  color: var(--color-text-muted);
}
.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1; height: 1px;
  background: var(--color-border);
}
.login-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-2);
  text-align: center;
  font-size: calc(11px * var(--font-scale));
  color: var(--color-text-sub);
}
.login-footer-org { font-weight: 600; color: var(--color-text); margin-bottom: 2px; }

/* PC（1024px以上）はサイドバーを常に開いた状態で使うため、開閉ボタンを出さない。
   768〜1023px は既定が折り畳みで、ボタンが無いと開けなくなるので残す。 */
@media (min-width: 1024px) {
  .menu-btn { display: none; }
}

/* ページ見出しの節（パンくず＋タイトル）。区切り線は出さず、上下の余白も詰める。
   .section は 32px の余白と下線を持つが、見出しだけは 2 クラスで上書きする。 */
.section.is-page-head {
  padding: 20px 32px 12px;
  border-bottom: none;
}
@media (max-width: 767px) {
  .section.is-page-head { padding: 16px 16px 8px; }
}

/* ハンバーガーだけ左右を詰める。.icon-btn は 38px 角でアイコン 18px のため
   左右に 10px ずつ空く。ここは 28px 角にして 5px ずつにする。 */
.icon-btn.menu-btn { width: 28px; height: 28px; }

/* タブのラベルは折り返さない。収まらない幅では横に送る（縦に割れるのを防ぐ）。
   横送りは外側の包みが持つ。.tabs 自身に overflow を付けると、
   .tab の margin-bottom:-1px で重ねている 1px が切られ、下線が 2 本に見える。 */
.tabs-wrap {
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs-wrap::-webkit-scrollbar { display: none; }
.tab {
  white-space: nowrap;
  flex-shrink: 0;
}

/* 狭い画面では 2 カラムを縦に積む。横並びのままだと右側が 95px まで潰れ、
   氏名が 1 文字ずつ縦に割れる（375px のとき 375 − 280 = 95px）。 */
@media (max-width: 767px) {
  .master-detail { grid-template-columns: 1fr; }
  .master {
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    max-height: 240px;
  }
}

/* === 狭い画面で潰れる部品の手当て ===
   どれも中身の最小幅が 375px を超えるため、縦に割れたり文字が切れたりしていた。
   縦積みにできない性質（比較表・24時間の並び・操作バー）なので、
   その部品の中だけで横に送る。 */

/* 権限の比較表。インラインで持っていた見た目をここへ移した（上書きの順番を保つため） */
.permission-table {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}
.permission-table .perm-row > div { white-space: nowrap; }

/* 時間帯の図。24 列は縮められないので包みの側で送る */
.heatmap-wrap { overflow-x: auto; }

/* 一括操作バー。件数とボタンの文字を折り返さない */
.bulk-count,
.bulk-action-bar .btn { white-space: nowrap; }

@media (max-width: 767px) {
  /* 項目名 200px + 4 列 ×48px + 余白 24px = 416px */
  .permission-table { overflow-x: auto; }
  .permission-table .perm-row { min-width: 420px; }
  /* ラベル 30px + 24 列 ×14px + すき間 48px = 414px */
  .heatmap { min-width: 420px; }
  /* 件数 + ボタン 3 つ + 閉じる。収まらない分は横に送る */
  .bulk-action-bar { overflow-x: auto; gap: 10px; }
}

/* タブの下線が 2 本に見えるのを直す。
   タブ群の border-bottom（2px）と、各タブが ::after で描く線（選択時 3px・bottom -2px）が
   1px ずれて重なっていた。太さと位置を揃えて 1 本にする。 */
.std-tabs { border-bottom-width: 3px; }
.std-tab::after { height: 3px; bottom: -3px; }
.std-tabs-boxed .std-tab.is-active::after { height: 3px; bottom: -3px; }

/* === 狭い画面での はみ出し・切れ の構造的な手当て ===
   原因は 2 つ。
   (1) 横に並ぶ要素が flex の既定で縮み、枠より中身が大きくなって文字が切れる。
   (2) grid の子は既定が min-width:auto で、中身の最小幅より縮まないため
       グリッド全体が親からはみ出し、ページが横にずれる。 */

/* (1) 一括操作バー: 件数・ボタン・閉じるは縮ませない */
.bulk-count,
.bulk-action-bar .btn,
.bulk-close { flex-shrink: 0; }

/* (2) グリッドの子が縮めるようにする（はみ出しを親の中で止める） */
.card-grid > * { min-width: 0; }

/* カレンダーは日付が 32px 角の固定。入らない幅では中だけ横に送る
   （7×32 + すき間 2×6 + 内側 16×2 = 268px が最小） */
.calendar { overflow-x: auto; }

/* 2 列で見せたい並び。タグに直接書くとメディアクエリで上書きできず、
   狭い画面でも 2 列のまま中身がはみ出すため、クラスで持たせる。 */
.card-grid.card-grid-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 767px) {
  .card-grid.card-grid-2 { grid-template-columns: 1fr; }
}

/* 右をやや広く見せる 2 列。狭い画面では上の !important で 1 列に戻る。 */
.demo-grid-2.demo-grid-2-wide { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); }

/* === バグチェック 2026-10-18 の直し === */

/* No.9 箱型タブ: 横送りは包みが持つ (タブ自身に overflow を付けると下線が切れる) */
.std-tabs-wrap { overflow-x: auto; scrollbar-width: none; }
.std-tabs-wrap::-webkit-scrollbar { display: none; }

/* No.8 構成カード: 768〜1023px で値の列が 23px に潰れるため 1 列にする
   (768px のとき 1 列あたり 303px → 値に使える幅 23px だった) */
@media (max-width: 1023px) {
  .info-grid { grid-template-columns: 1fr; }
}

/* No.16 値が長い定義リスト: 区切りの無い英数字でも折り返す
   (375px のとき値に使える幅は 119px、メールアドレスは 157.5px 必要) */
.def-list dd { overflow-wrap: anywhere; }

/* No.18 小さいボタンの文字サイズ: .main .btn (13px) に負けていたので同じ強さで指定 */
.main .btn-line { font-size: calc(12px * var(--font-scale)); }
.main .btn-xs { font-size: calc(11px * var(--font-scale)); }

/* No.20 時間帯の図: 実際に描くのは 3 時間刻みの 8 列。
   30px + 8×14px + すき間 2px×8 = 158px で 375px の画面に収まるため最小幅は置かない */
@media (max-width: 767px) {
  .heatmap { min-width: 0; }
}

/* No.11 入力モーダルの必須マーク: 間隔は親の gap に任せる (margin が残ると 6px になる) */
.modal-polished .field-required { margin-left: 0; }

/* No.13 効果のない指定を、狙っていた相手へ当て直す (.avatar に margin は無い) */
@media (max-width: 380px) {
  .user-menu { margin-left: 0; }
}
