/* =====================================================
   書類の秘書 v1 — メインスタイルシート
   uiref.md §4 カラーパレット・タイポグラフィ・余白体系に準拠
   外部フォント・CDN 読み込みなし。文字最小 15px。
   ===================================================== */

/* ---------- カラートークン ---------- */
:root {
  --color-primary:        #1B4D89;
  --color-primary-hover:  #133863;
  --color-primary-light:  #EBF2FA;
  --color-bg-app:         #F4F6F9;
  --color-bg-card:        #FFFFFF;
  --color-bg-table-head:  #EDF1F6;
  --color-border:         #D8DEE6;
  --color-accent:         #0D9488;
  --color-accent-hover:   #0F766E;
  --status-warn-text:     #B45309;
  --status-warn-bg:       #FEF3C7;
  --status-warn-border:   #FCD34D;
  --status-danger-text:   #B91C1C;
  --status-danger-bg:     #FEE2E2;
  --status-danger-border: #FCA5A5;
  --status-success-text:  #15803D;
  --status-success-bg:    #DCFCE7;
  --status-success-border:#86EFAC;
  --status-info-text:     #1E40AF;
  --status-info-bg:       #DBEAFE;
  --status-muted-text:    #475569;
  --status-muted-bg:      #F1F5F9;
  --text-main:            #1E293B;
  --text-muted:           #64748B;
  --text-disabled:        #94A3B8;

  /* 余白トークン */
  --sp-xxs: 4px;
  --sp-xs:  8px;
  --sp-s:   12px;
  --sp-m:   16px;
  --sp-l:   24px;
  --sp-xl:  32px;

  /* サイドバー幅 */
  --sidebar-w: 220px;

  /* フォント */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Hiragino Kaku Gothic ProN", "BIZ UDPGothic", "Meiryo", sans-serif;
  font-size: 15px;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
}

*, *::before, *::after { box-sizing: inherit; margin: 0; padding: 0; }

body {
  background: var(--color-bg-app);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* =====================================================
   レイアウト
   ===================================================== */
.app-layout {
  display: flex;
  flex: 1;
  min-height: 100vh;
}

/* ---------- 上部バー ---------- */
.top-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  gap: var(--sp-m);
  padding: 0 var(--sp-m);
  z-index: 200;
  border-bottom: 1px solid var(--color-primary-hover);
}
.top-bar .brand {
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.top-bar .spacer { flex: 1; }

/* 段階バッジ */
.stage-switch {
  display: flex;
  gap: 2px;
  background: rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 3px;
}
.stage-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.85); /* 白85%（80%以上で読みやすい） */
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.stage-btn.active {
  background: #fff;
  color: var(--color-primary);
}
.stage-btn:hover:not(.active) {
  background: rgba(255,255,255,0.25);
  color: #fff;
}

/* 役割セレクタ */
.role-switch {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  font-size: 13px;
}
.role-switch label { color: rgba(255,255,255,0.9); }
.role-select {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  border-radius: 6px;
  padding: 0 10px;
  height: 38px; /* 高さ36px以上 */
  min-height: 36px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
}
.role-select option { background: var(--color-primary); color: #fff; }

/* ---------- サイドバー ---------- */
.sidebar {
  position: fixed;
  top: 52px;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--color-bg-card);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-nav { flex: 1; padding: var(--sp-s) 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  padding: 12px var(--sp-m);
  cursor: pointer;
  font-size: 15px;
  color: var(--text-muted);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: all 0.12s;
  position: relative;
  font-family: inherit;
  text-decoration: none;
}
.nav-item:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}
.nav-item.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--color-primary);
  border-radius: 0 2px 2px 0;
}
.nav-item svg { flex-shrink: 0; width: 18px; height: 18px; }
.nav-item .nav-label { flex: 1; }
.nav-item .nav-badge {
  background: var(--status-warn-bg);
  color: var(--status-warn-text);
  font-size: 13px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 9999px;
  border: 1px solid var(--status-warn-border);
}
.nav-item.nav-locked { opacity: 0.5; cursor: default; }
.nav-item.nav-locked:hover { background: transparent; color: var(--text-muted); }

.sidebar-footer {
  padding: var(--sp-m);
  border-top: 1px solid var(--color-border);
  font-size: 13px;
  color: var(--text-muted);
}
.sidebar-footer .conn-status {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
}
.conn-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}
.conn-dot.demo { background: #f59e0b; }

/* ---------- メインコンテンツ ---------- */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: 52px;
  flex: 1;
  padding: var(--sp-xl);
  min-height: calc(100vh - 52px);
}

/* 画面パネル */
.screen { display: none; }
.screen.active { display: block; }

/* =====================================================
   共通コンポーネント
   ===================================================== */

/* ---------- ページタイトル ---------- */
.page-header {
  display: flex;
  align-items: center;
  gap: var(--sp-m);
  margin-bottom: var(--sp-l);
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main);
}
.page-subtitle {
  font-size: 15px;
  color: var(--text-muted);
}

/* ---------- カード ---------- */
.card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: var(--sp-l);
}
.card + .card { margin-top: var(--sp-m); }

.metric-tiles {
  display: grid;
  gap: var(--sp-m);
  margin-bottom: var(--sp-l);
}
.metric-tiles.cols-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.metric-tiles.cols-6 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.metric-tile {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: var(--sp-m) var(--sp-l);
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
  cursor: pointer;
  transition: box-shadow 0.15s;
}
.metric-tile:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.metric-tile .tile-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  line-height: 1.3;
}
.metric-tile .tile-count {
  font-size: 32px;
  font-weight: 700;
  line-height: 36px;
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
}
.metric-tile.warn .tile-count { color: var(--status-warn-text); }
.metric-tile.danger .tile-count { color: var(--status-danger-text); }
.metric-tile.zero .tile-count { color: var(--text-disabled); }
.metric-tile .tile-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------- 状態バッジ ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge:has(.badge-shape)::before { display: none; }
.badge-shape {
  font-size: 9px;
  line-height: 1;
  flex-shrink: 0;
  opacity: 0.85;
}
.badge-warn   { color: var(--status-warn-text);    background: var(--status-warn-bg);    border-color: var(--status-warn-border); }
.badge-danger { color: var(--status-danger-text);  background: var(--status-danger-bg);  border-color: var(--status-danger-border); }
.badge-success{ color: var(--status-success-text); background: var(--status-success-bg); border-color: var(--status-success-border); }
.badge-info   { color: var(--status-info-text);    background: var(--status-info-bg); }
.badge-muted  { color: var(--status-muted-text);   background: var(--status-muted-bg); }
.badge-overdue{ color: #6B21A8; background: #F3E8FF; border-color: #D8B4FE; }
.badge-primary{ color: var(--color-primary);       background: var(--color-primary-light); }
.badge-urgent {
  color: #FFFFFF;
  background: var(--status-danger-text);
  border: 1px solid #991B1B;
  border-radius: 4px;
  font-weight: 800;
  padding: 2px 7px;
  letter-spacing: 0.03em;
}
.badge-urgent::before { display: none; }
.badge-review {
  color: #92400E;
  background: #FEF3C7;
  border: 1.5px solid #D97706;
  border-radius: 9999px;
  font-weight: 700;
  padding: 2px 8px;
}
.badge-review::before {
  content: '▲';
  font-size: 10px;
  width: auto;
  height: auto;
  border-radius: 0;
  background: transparent;
  color: #D97706;
}

/* ---------- テーブル ---------- */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}
.data-table thead th {
  background: var(--color-bg-table-head);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: var(--sp-s) var(--sp-m);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.data-table thead th.num { text-align: right; }
.data-table tbody tr {
  border-bottom: 1px solid var(--color-border);
  border-left: 5px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-left-color 0.15s;
}
.data-table tbody tr:hover { background: #F8FAFC; }
.data-table tbody tr.selected { background: var(--color-primary-light); }
.data-table tbody tr.row-urgent {
  border-left: 5px solid var(--status-danger-text);
  background: #FFF8F8;
}
.data-table tbody tr.row-urgent:hover { background: #FEE2E2; }
.data-table tbody tr.row-review {
  border-left: 5px solid #D97706;
  background: #FFFDF7;
}
.data-table tbody tr.row-review:hover { background: #FEF3C7; }
.data-table tbody tr.just-arrived {
  animation: arrivePulse 2.5s ease-out forwards;
}
@keyframes arrivePulse {
  0% { background: #FEF08A; }
  50% { background: #FEF9C3; }
  100% { background: transparent; }
}
.data-table tbody td {
  padding: 13px var(--sp-m);
  vertical-align: middle;
  line-height: 20px;
}
.data-table tbody td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.data-table tbody td.money {
  text-align: right;
  font-family: "Courier New", "Consolas", monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 15px;
}
.data-table tbody tr.overdue { background: #FFF5F5; }
.data-table tbody tr.overdue:hover { background: #FEE2E2; }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
  padding: 9px var(--sp-m);
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: inherit;
  line-height: 1;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.card h3 svg { width: 20px; height: 20px; flex-shrink: 0; }
.btn-primary {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}
.btn-primary:hover { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }
.btn-secondary {
  background: var(--color-bg-card);
  color: var(--text-main);
  border-color: var(--color-border);
}
.btn-secondary:hover { background: var(--color-bg-app); }
.btn-danger {
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
  border-color: var(--status-danger-border);
}
.btn-danger:hover { background: #FCA5A5; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- タブ ---------- */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: var(--sp-l);
  overflow-x: auto;
}
.tab-btn {
  background: transparent;
  border: none;
  padding: 10px var(--sp-l);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.12s;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
}
.tab-btn:hover { color: var(--color-primary); }
.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}
.tab-btn .tab-count {
  background: var(--color-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 9999px;
  min-width: 20px;
  text-align: center;
}
.tab-btn .tab-count.danger { background: var(--status-danger-text); }
.tab-btn .tab-count.warn { background: var(--status-warn-text); }

/* ---------- 詳細横パネル（Slide-over Drawer）---------- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 300;
  display: none;
  animation: fadeIn 0.15s;
}
.drawer-overlay.open { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.drawer {
  position: fixed;
  top: 52px;
  right: 0;
  bottom: 0;
  width: min(680px, 92vw);
  max-width: calc(100vw - 20px);
  background: var(--color-bg-card);
  box-shadow: -4px 0 24px rgba(0,0,0,0.12);
  z-index: 301;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.2s ease;
}
.drawer.open { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: center;
  gap: var(--sp-m);
  padding: var(--sp-m) var(--sp-l);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.drawer-title {
  font-size: 16px;
  font-weight: 700;
  flex: 1;
}
.drawer-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  display: flex;
}
.drawer-close:hover { color: var(--text-main); background: var(--color-bg-app); }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-l);
  word-break: break-word;
}
.drawer-body.two-pane {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-m);
  padding: var(--sp-m);
}
.drawer-footer {
  flex-shrink: 0;
  padding: var(--sp-m) var(--sp-l);
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-xs);
  align-items: center;
}

.icon-sm,
svg.badge-icon,
.text-muted svg {
  width: 14px;
  height: 14px;
  vertical-align: -2px;
  flex-shrink: 0;
}
.banner-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}
.drawer-body svg:not(.fax-preview svg):not(.fax-tools svg):not(.btn svg) {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ---------- FAX プレビュー ---------- */
.fax-preview {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.fax-preview > svg {
  width: 100%;
  height: auto;
  display: block;
}
.fax-tools {
  display: flex;
  gap: var(--sp-xs);
  padding: var(--sp-xs);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-app);
}
.fax-tools svg {
  width: 18px;
  height: 18px;
  cursor: pointer;
  color: var(--text-muted);
}

/* ---------- フォーム部品 ---------- */
.form-group { margin-bottom: var(--sp-m); }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: var(--sp-xs);
}
.form-value {
  font-size: 15px;
  color: var(--text-main);
  padding: 10px var(--sp-m);
  background: var(--color-bg-app);
  border: 1px solid var(--color-border);
  border-radius: 5px;
  display: block;
  width: 100%;
}
.form-input, .form-select, .form-textarea {
  font-size: 15px;
  color: var(--text-main);
  padding: 10px var(--sp-m);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 5px;
  display: block;
  width: 100%;
  font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.form-textarea { resize: none; min-height: 100px; }

/* ---------- トースト通知 ---------- */
.toast-container {
  position: fixed;
  bottom: var(--sp-l);
  right: var(--sp-l);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
  pointer-events: none;
}
.toast {
  background: var(--text-main);
  color: #fff;
  padding: var(--sp-s) var(--sp-m);
  border-radius: 8px;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: var(--sp-m);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  pointer-events: auto;
  animation: slideUp 0.2s ease;
  max-width: 380px;
}
@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.toast .toast-undo {
  background: none;
  border: none;
  color: #93C5FD;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
  font-family: inherit;
}
.toast .toast-undo:hover { color: #BFDBFE; }

/* ---------- 空の状態 ---------- */
.empty-state {
  text-align: center;
  padding: var(--sp-xl) var(--sp-l);
  color: var(--text-muted);
}
.empty-state svg {
  width: 48px; height: 48px;
  color: var(--color-border);
  margin: 0 auto var(--sp-m);
  display: block;
}
.empty-state h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: var(--sp-xs);
}
.empty-state p { font-size: 13px; }

/* ---------- オンボーディング ---------- */
.onboarding-overlay {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: min(390px, calc(100vw - 32px));
  z-index: 500;
  display: flex;
}
.onboarding-card {
  background: var(--color-bg-card);
  border-radius: 12px;
  border: 1px solid var(--color-border);
  padding: var(--sp-m);
  width: 100%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
}
.onboarding-card h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: var(--sp-s);
  color: var(--text-main);
}
.onboarding-line { margin: 2px 0; color: var(--text-muted); font-size: 13px; }
.onboarding-owner-line { margin: var(--sp-s) 0; font-size: 13px; font-weight: 700; line-height: 1.5; }
.onboard-compact-steps { margin: var(--sp-s) 0 var(--sp-m) 22px; color: var(--text-muted); font-size: 13px; line-height: 1.7; }
.onboarding-actions {
  display: flex;
  gap: var(--sp-xs);
  justify-content: flex-end;
}

/* ---------- 段階ロック表示 ---------- */
.tier-lock-banner {
  background: var(--color-primary-light);
  border: 1px solid var(--color-primary);
  border-radius: 8px;
  padding: var(--sp-m) var(--sp-l);
  display: flex;
  align-items: center;
  gap: var(--sp-m);
  margin-bottom: var(--sp-l);
  font-size: 15px;
}
.tier-lock-banner svg {
  width: 20px; height: 20px;
  color: var(--color-primary);
  flex-shrink: 0;
}
.tier-lock-banner strong { color: var(--color-primary); }

/* ---------- AI 注意書き ---------- */
.ai-notice {
  background: var(--status-info-bg);
  border: 1px solid #93C5FD;
  border-radius: 6px;
  padding: var(--sp-s) var(--sp-m);
  font-size: 13px;
  color: var(--status-info-text);
  display: flex;
  gap: var(--sp-xs);
  align-items: flex-start;
  margin-bottom: var(--sp-m);
}
.ai-notice svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }

/* ---------- 工程パイプライン ---------- */
.pipeline {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: var(--sp-l);
  overflow-x: auto;
}
.pipeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--sp-s) var(--sp-l);
  gap: 4px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.12s;
  color: var(--text-muted);
  white-space: nowrap;
  font-family: inherit;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
}
.pipeline-step:hover { color: var(--color-primary); }
.pipeline-step.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 700;
}
.pipeline-step .step-label { font-size: 13px; }
.pipeline-step .step-count {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.pipeline-step.active .step-count { color: var(--color-primary); }

/* ---------- 設定サブメニュー ---------- */
.settings-layout {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: var(--sp-l);
  align-items: start;
}
.settings-nav { display: flex; flex-direction: column; gap: 2px; }
.settings-nav-btn {
  background: transparent;
  border: none;
  padding: 10px var(--sp-m);
  border-radius: 6px;
  font-size: 15px;
  color: var(--text-muted);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s;
}
.settings-nav-btn:hover { background: var(--color-bg-app); color: var(--text-main); }
.settings-nav-btn.active { background: var(--color-primary-light); color: var(--color-primary); font-weight: 600; }

/* ---------- トグルスイッチ ---------- */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: var(--sp-m);
  padding: var(--sp-s) 0;
  border-bottom: 1px solid var(--color-border);
}
.toggle-wrap:last-child { border-bottom: none; }
.toggle-info { flex: 1; }
.toggle-info .toggle-name { font-size: 15px; font-weight: 600; }
.toggle-info .toggle-desc { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.toggle {
  position: relative;
  width: 44px; height: 24px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--color-border);
  border-radius: 9999px;
  cursor: pointer;
  transition: 0.2s;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle input:checked + .toggle-slider { background: var(--color-accent); }
.toggle input:checked + .toggle-slider::after { transform: translateX(20px); }

/* ---------- スマホ撮る画面 ---------- */
.camera-steps {
  max-width: 400px;
  margin: 0 auto;
}
.camera-step {
  display: flex;
  gap: var(--sp-m);
  align-items: flex-start;
  padding: var(--sp-l) 0;
  border-bottom: 1px solid var(--color-border);
}
.camera-step:last-child { border-bottom: none; }
.camera-step-num {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.camera-step-content h3 { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.camera-step-content p { font-size: 15px; color: var(--text-muted); }
.camera-btn-area {
  margin-top: var(--sp-l);
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
}
.btn-camera {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 18px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-xs);
  width: 100%;
  font-family: inherit;
  transition: background 0.15s;
}
.btn-camera:hover { background: var(--color-primary-hover); }
.btn-camera.secondary { background: var(--color-bg-card); color: var(--text-main); border: 1px solid var(--color-border); }
.btn-camera.secondary:hover { background: var(--color-bg-app); }

/* ---------- 「見本を最初に戻す」 ---------- */
.reset-demo {
  background: var(--status-warn-bg);
  border: 1px solid var(--status-warn-border);
  border-radius: 6px;
  padding: var(--sp-s) var(--sp-m);
  display: flex;
  align-items: center;
  gap: var(--sp-m);
  font-size: 13px;
  color: var(--status-warn-text);
}
.reset-demo strong { font-weight: 700; }

/* =====================================================
   各画面固有スタイル
   ===================================================== */

/* ① 今日やること */
.today-date {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: var(--sp-l);
}
.today-flow {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.flow-item {
  display: flex;
  align-items: center;
  gap: var(--sp-m);
  padding: var(--sp-s) var(--sp-m);
  border-radius: 6px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  font-size: 15px;
}
.flow-item:hover { background: var(--color-bg-app); }
.flow-time { font-size: 13px; color: var(--text-muted); width: 64px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.flow-body { flex: 1; }
.flow-body .flow-type { font-size: 13px; color: var(--text-muted); }

/* AI の朝の1枚テキスト */
.morning-text {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: var(--sp-l);
  font-size: 15px;
  line-height: 1.8;
  white-space: pre-wrap;
}

/* ② もらった書類 フィルタバー */
.filter-bar {
  display: flex;
  gap: var(--sp-xs);
  align-items: center;
  margin-bottom: var(--sp-m);
  flex-wrap: wrap;
}
.filter-bar input[type="text"] {
  font-size: 15px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  background: var(--color-bg-card);
  color: var(--text-main);
  font-family: inherit;
  min-width: 160px;
}
.filter-bar select {
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  background: var(--color-bg-card);
  color: var(--text-main);
  font-family: inherit;
}

/* 詳細パネル内フォーム */
.detail-fields { display: flex; flex-direction: column; gap: 0; }
.detail-field {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  padding: 10px 0;
}
.detail-field:first-child { padding-top: 0; }

.term-note {
  margin-bottom: var(--sp-m);
  padding: var(--sp-s) var(--sp-m);
  border-left: 4px solid var(--color-primary);
  background: var(--status-info-bg);
  color: var(--text-main);
  font-size: 13px;
  line-height: 1.6;
}

.term-help {
  display: inline-block;
  margin-left: var(--sp-xs);
  color: var(--color-primary);
  font-size: 13px;
  font-weight: 500;
  text-decoration: underline dotted;
  cursor: help;
}

.today-flow-collapsible summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--color-primary);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 16px;
  background: var(--color-bg-card);
  border: 1.5px solid var(--color-border);
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  transition: all 0.15s ease;
  list-style: none;
}

.today-flow-collapsible summary::-webkit-details-marker { display: none; }
.today-flow-collapsible summary::marker { display: none; }
.today-flow-collapsible summary::after {
  content: '▼';
  font-size: 10px;
  color: var(--color-primary);
  margin-left: 6px;
}
.today-flow-collapsible[open] summary::after {
  content: '▲';
}
.today-flow-collapsible summary:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
}
.today-flow-collapsible summary svg { width: 18px; height: 18px; flex: 0 0 18px; }

.urgent-everyone {
  margin-bottom: var(--sp-m);
  padding: var(--sp-s) var(--sp-m);
  border: 1px solid var(--status-danger-border);
  border-left: 6px solid var(--status-danger-text);
  border-radius: 6px;
  background: var(--status-danger-bg);
  color: var(--text-main);
  font-size: 15px;
  line-height: 1.7;
}

.urgent-everyone-title { margin-bottom: 2px; font-weight: 700; }

.delivery-search {
  display: flex;
  align-items: center;
  gap: var(--sp-m);
  margin-bottom: var(--sp-m);
  padding: var(--sp-m);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-card);
}

.delivery-search label { font-size: 15px; font-weight: 700; white-space: nowrap; }
.delivery-search input { min-width: 260px; min-height: 44px; font-size: 17px; }

.delivery-search-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-m);
  margin-bottom: var(--sp-m);
  padding: var(--sp-m);
  border-radius: 8px;
  font-size: 17px;
}

.delivery-search-result.found { background: var(--status-success-bg); color: var(--status-success-text); }
.delivery-search-result.not-found { background: var(--status-warn-bg); color: var(--status-warn-text); }
.delivery-search-result strong { font-size: 20px; }

.camera-fax-preview {
  position: relative;
  height: 170px;
  margin-bottom: var(--sp-m);
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #eef2f6;
}

.camera-fax-preview svg { display: block; width: 100%; height: auto; transform: translateY(-18px); }
.camera-fax-preview span {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,.92);
  color: var(--text-muted);
  font-size: 13px;
}

.camera-type-heading { margin: var(--sp-m) 0 var(--sp-xs); font-size: 15px; }
.camera-type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.camera-type-choice { min-height: 52px; justify-content: center; padding: 4px 2px; font-size: 13px; line-height: 1.35; box-sizing: border-box; text-align: center; word-break: break-all; }
.camera-other-types { margin-top: var(--sp-m); }
.camera-other-types summary { color: var(--color-primary); font-size: 15px; font-weight: 700; cursor: pointer; }

.settings-title-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-m); }

.role-stage-hint { color: rgba(255,255,255,.78); font-size: 13px; white-space: nowrap; }
.role-select:disabled { cursor: not-allowed; opacity: .72; }

.dashboard-label { margin-bottom: var(--sp-s); color: var(--text-muted); font-size: 15px; font-weight: 700; }
.ai-advisor-note { margin: 0 0 var(--sp-m); color: var(--text-muted); font-size: 13px; }
.detail-field dt {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  width: 100px;
  flex-shrink: 0;
  padding-top: 1px;
}
.detail-field dd { font-size: 15px; color: var(--text-main); flex: 1; }

/* 患者番号入力 */
.patient-code-row {
  display: flex;
  gap: var(--sp-xs);
  align-items: center;
  background: var(--color-bg-app);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: var(--sp-s) var(--sp-m);
  margin-top: var(--sp-s);
}
.patient-code-row label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
}
.patient-code-row input {
  font-size: 15px;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  font-family: monospace;
  font-variant-numeric: tabular-nums;
  background: #fff;
  color: var(--text-main);
  width: 110px;
}
td[data-label="患者番号"],
td[data-label="カルテ番号"] {
  white-space: nowrap;
}

/* =====================================================
   AI 段 非表示制御
   ===================================================== */
.tier-ai-only { display: none; }
.tier-team-only { display: none; }
body.tier-ai .tier-ai-only { display: flex; }
body.tier-ai .tier-team-only { display: flex; }
body.tier-team .tier-team-only { display: flex; }

/* =====================================================
   レスポンシブ（スマホ 390px）
   ===================================================== */
@media (max-width: 600px) {
  :root { font-size: 16px; }
  .top-bar { padding: 0 8px; gap: 8px; }
  .top-bar .brand { font-size: 15px; }
  .stage-switch { display: none; }
  .role-switch  { display: none; }
  
  /* モバイルメニューボタン（44px 四方） */
  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    border-radius: 6px;
    flex-shrink: 0;
  }
  .mobile-menu-btn:hover, .mobile-menu-btn:active {
    background: rgba(255,255,255,0.15);
  }

  /* モバイルメニューオーバーレイ */
  .mobile-menu-overlay {
    display: block;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45);
    z-index: 290;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .mobile-menu-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }

  /* 引き出しメニュー（サイドバー） */
  .sidebar {
    display: flex !important;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    max-width: 82vw;
    background: var(--color-bg-card);
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
    border-right: 1px solid var(--color-border);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .sidebar-header-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px 6px 16px;
    border-bottom: 1px solid var(--color-border);
    height: 52px;
  }
  .mobile-menu-close {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 6px;
    color: var(--text-main);
  }
  .mobile-menu-close:hover {
    background: var(--color-bg-app);
  }

  .main-content {
    margin-left: 0;
    padding: var(--sp-m);
  }
  .metric-tiles, .metric-tiles.cols-5, .metric-tiles.cols-6 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
  }
  .metric-tile {
    padding: 10px 8px;
    min-width: 0;
  }
  .metric-tile .tile-label {
    font-size: 12px;
    line-height: 1.3;
    word-break: break-word;
  }
  .metric-tile .tile-count { font-size: 24px; line-height: 28px; }
  .metric-tile .tile-sub {
    font-size: 11px;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .drawer { width: 100vw; top: 52px; }
  .drawer-body.two-pane { grid-template-columns: 1fr; }
  .data-table thead { display: none; }
  .data-table tbody tr {
    display: flex;
    flex-direction: column;
    padding: var(--sp-s) var(--sp-m);
    gap: 4px;
  }
  .data-table tbody td {
    padding: 2px 0;
    border: none;
    font-size: 15px;
  }
  .data-table tbody td::before {
    content: attr(data-label);
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 600;
    display: block;
  }
  .data-table tbody td.no-label::before { display: none; }
  .page-title { font-size: 18px; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { flex-direction: row; overflow-x: auto; }
  .tab-bar { gap: 0; }
  .tab-btn { padding: 8px var(--sp-m); font-size: 13px; }
  .pipeline-step { padding: var(--sp-xs) var(--sp-s); }
  /* スマホ専用表示 */
  .desktop-only { display: none !important; }
  .camera-steps { max-width: 100%; }
  .onboarding-overlay {
    right: 8px;
    bottom: 8px;
    width: calc(100vw - 16px);
    max-height: calc(100vh - 68px);
  }
  .onboarding-card { max-height: calc(100vh - 68px); overflow-y: auto; }
}
@media (min-width: 601px) {
  .mobile-only { display: none !important; }
  .mobile-menu-btn { display: none !important; }
  .mobile-menu-overlay { display: none !important; }
  .sidebar-header-mobile { display: none !important; }
  .screen-camera .top-mobile-nav { display: none; }
}

/* ---------- スマホ上部ナビ ---------- */
.top-mobile-nav {
  display: flex;
  gap: var(--sp-xs);
  margin-bottom: var(--sp-m);
  background: var(--color-bg-card);
  padding: var(--sp-xs);
  border-radius: 8px;
  border: 1px solid var(--color-border);
  overflow-x: auto;
}
.mobile-nav-btn {
  background: none;
  border: none;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 5px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
.mobile-nav-btn.active { background: var(--color-primary); color: #fff; }

/* ---------- ヘルパー ---------- */
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--status-danger-text); }
.text-success { color: var(--status-success-text); }
.text-warn { color: var(--status-warn-text); }
.mt-xs { margin-top: var(--sp-xs); }
.mt-s  { margin-top: var(--sp-s); }
.mt-m  { margin-top: var(--sp-m); }
.mt-l  { margin-top: var(--sp-l); }
.mb-m  { margin-bottom: var(--sp-m); }
.mb-l  { margin-bottom: var(--sp-l); }
.flex  { display: flex; }
.flex-gap-xs { gap: var(--sp-xs); }
.flex-gap-m  { gap: var(--sp-m); }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.fw-700 { font-weight: 700; }
.font-mono { font-family: "Courier New", "Consolas", monospace; font-variant-numeric: tabular-nums; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-m); }
.section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: var(--sp-m);
  color: var(--text-main);
}

/* =====================================================
   「つなぐ」画面スタイル
   ===================================================== */
.pipeline-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}
.pipeline-section-title svg {
  width: 20px;
  height: 20px;
  color: var(--color-primary);
  flex-shrink: 0;
}
.pipeline-flow-container {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: var(--sp-m);
  margin: var(--sp-m) 0;
  overflow-x: auto;
  padding-bottom: 8px;
}
.pipeline-column {
  flex: 1;
  min-width: 260px;
  background: var(--color-bg-app);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
}
.pipeline-col-header {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--color-border);
}
.pipeline-col-title {
  display: block;
  font-weight: 700;
  font-size: 14px;
  color: var(--color-primary);
}
.pipeline-col-sub {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.pipeline-nodes {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}
.pipeline-node {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
}
.pipeline-node:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.pipeline-node.node-connected {
  border-left: 4px solid var(--status-success-text);
}
.pipeline-node.node-unconfigured {
  border-left: 4px solid var(--text-disabled);
  opacity: 0.75;
}
.pipeline-node.node-output {
  border-left: 4px solid var(--color-primary);
}
.pipeline-node.node-ai {
  border-left: 4px solid #7C3AED;
}
.node-icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
  flex-shrink: 0;
}
.node-icon svg {
  width: 18px;
  height: 18px;
}
.node-info {
  flex: 1;
  min-width: 0;
}
.node-name {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-main);
  line-height: 1.35;
  word-break: keep-all;
}
.node-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}
.pipeline-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 12px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.badge-icon-symbol {
  font-size: 10px;
  font-weight: 700;
}
.badge-connected {
  background: var(--status-success-bg);
  color: var(--status-success-text);
  border: 1px solid var(--status-success-border);
}
.badge-unconfigured {
  background: var(--status-muted-bg);
  color: var(--text-disabled);
  border: 1px solid var(--color-border);
}
.badge-active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border: 1px solid #BFDBFE;
}
.badge-ai {
  background: #F3E8FF;
  color: #7C3AED;
  border: 1px solid #DDD6FE;
}

/* 凡例 */
.pipeline-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot-connected { background: var(--status-success-text); }
.dot-unconfigured { background: var(--text-disabled); }
.dot-ai { background: #7C3AED; }

/* 矢印コネクタ */
.pipeline-connector {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  flex-shrink: 0;
}

/* 中央台帳コア */
.pipeline-core-col {
  background: linear-gradient(180deg, #F0F6FF 0%, #FFFFFF 100%);
  border: 2px solid var(--color-primary);
  min-width: 270px;
}
.pipeline-core-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 8px 0;
  flex: 1;
}
.core-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.core-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.5;
}
.core-metrics {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-bottom: 14px;
}
.core-metric-item {
  flex: 1;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 8px 4px;
}
.core-metric-item.clickable-metric {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.core-metric-item.clickable-metric:hover {
  transform: translateY(-2px);
  box-shadow: 0 3px 8px rgba(0,0,0,0.08);
}
.core-metric-item.metric-warn {
  border-color: var(--status-danger-border);
  background: #FFF5F5;
  border-top: 3px solid var(--status-danger-text);
}
.metric-num {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
}
.metric-warn .metric-num {
  color: var(--status-danger-text);
}
.metric-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.metric-hint {
  display: block;
  font-size: 10px;
  color: var(--color-primary);
  margin-top: 2px;
  text-decoration: underline;
}
.core-security-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--color-primary);
  background: var(--color-primary-light);
  padding: 6px 12px;
  border-radius: 16px;
  font-weight: 600;
  border: 1px solid #BFDBFE;
}
.core-security-badge svg {
  width: 14px;
  height: 14px;
}

/* 入口ごとのカードグリッド */
.entry-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--sp-m);
}
.entry-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
}
.entry-card-muted {
  background: #FAFBFD;
  border-style: dashed;
}
.entry-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}
.entry-card-icon {
  color: var(--color-primary);
  display: flex;
  align-items: center;
}
.entry-card-icon svg {
  width: 18px;
  height: 18px;
}
.entry-card-name {
  font-weight: 700;
  font-size: 14px;
}
.entry-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.entry-stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}
.stat-label {
  color: var(--text-muted);
}
.stat-val {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.entry-card-footer {
  margin-top: auto;
}

/* 3分類タブ・テーブル */
.connect-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 16px;
  overflow-x: auto;
}
.connect-tab-btn {
  background: none;
  border: none;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  font-family: inherit;
  white-space: nowrap;
}
.connect-tab-btn:hover {
  color: var(--color-primary);
}
.connect-tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}
.tab-count-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--color-bg-app);
  color: var(--text-muted);
}
.tab-count-badge.badge-danger {
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
}
.tab-count-badge.badge-warn {
  background: var(--status-warn-bg);
  color: var(--status-warn-text);
}
.tab-warn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-danger-text);
  display: inline-block;
}
.connect-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.connect-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: 6px;
}
.clickable-row {
  cursor: pointer;
  transition: background 0.15s ease;
}
.clickable-row:hover {
  background: #F8FAFC !important;
}

/* =====================================================
   「始め方」画面スタイル
   ===================================================== */
.guide-hero-card {
  background: linear-gradient(135deg, #FFFFFF 0%, #F0F6FF 100%);
  border: 1px solid #BFDBFE;
}
.guide-tag {
  display: inline-block;
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 4px;
  margin-bottom: 8px;
}
.guide-lead-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.5;
  margin: 0;
}
.guide-summary-table th {
  background: var(--color-bg-table-head);
  font-size: 13px;
}
.guide-summary-table td {
  font-size: 14px;
  vertical-align: middle;
}
@media (max-width: 600px) {
  .guide-summary-table tbody tr {
    padding: 14px 12px;
    border-radius: 8px;
    margin-bottom: 12px;
    background: #FFFFFF;
    border: 1px solid var(--color-border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  }
  .guide-summary-table tbody td:last-child {
    margin-top: 8px;
    width: 100%;
  }
  .guide-summary-table tbody td:last-child a.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    width: 100%;
    font-size: 14px;
    font-weight: 600;
  }
}
.stage-tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.tag-0 { background: #E2E8F0; color: #334155; }
.tag-1 { background: #DCFCE7; color: #166534; }
.tag-2 { background: #DBEAFE; color: #1E40AF; }
.tag-3 { background: #FEF3C7; color: #92400E; }
.tag-4 { background: #E0E7FF; color: #3730A3; }
.tag-5 { background: #F3E8FF; color: #6B21A8; }

/* 段階カード */
.stage-detail-card {
  padding: var(--sp-l);
  border-left: 5px solid var(--color-primary);
  transition: box-shadow 0.2s ease;
}
.stage-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}
.stage-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}
.stage-num-badge {
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 4px;
}
.stage-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  color: var(--text-main);
}
.stage-rating {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}
.rating-stars {
  font-size: 16px;
  letter-spacing: 2px;
}
.rating-text {
  font-size: 12px;
  color: var(--text-muted);
}
.star-rating-cell {
  display: inline-block;
  font-size: 15px;
  letter-spacing: 2px;
  line-height: 1;
}
.star-on {
  color: #EAB308;
  font-weight: 800;
}
.star-off {
  color: #CBD5E1;
  font-weight: 800;
}
.star-sub-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.2;
}
.star-sub-label.support-label {
  color: #059669;
  font-weight: 600;
}
.support-badge {
  background: #ECFDF5;
  color: #059669;
  border: 1px solid #A7F3D0;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}
.stage-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.stage-meta-box {
  background: var(--color-bg-app);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 10px 14px;
}
.meta-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.meta-val {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}
.stage-content-section {
  margin-bottom: 16px;
}
.section-sub-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
}
.warn-section {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: 6px;
  padding: 12px 14px;
}
.notice-callout-box {
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.6;
}
.security-safe-box {
  display: flex;
  gap: 12px;
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.6;
}
.security-safe-box svg {
  width: 22px;
  height: 22px;
  color: var(--status-success-text);
  flex-shrink: 0;
  margin-top: 2px;
}
.phone-os-tabs {
  display: flex;
  gap: 8px;
}
.phone-os-btn {
  background: var(--color-bg-app);
  border: 1px solid var(--color-border);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
}
.phone-os-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}
.os-steps-box {
  background: #F8FAFC;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 14px;
}
.step-route-block strong {
  display: block;
  font-size: 13px;
  color: var(--color-primary);
  margin-bottom: 6px;
}
.numbered-steps {
  padding-left: 20px;
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
}
.numbered-steps li {
  margin-bottom: 4px;
}
.tips-box {
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  border-radius: 6px;
  padding: 12px 14px;
}
.tips-list {
  padding-left: 18px;
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
}
.stage-card-footer {
  padding-top: 14px;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  align-items: center;
}
.stage-footer-left {
  justify-content: flex-start !important;
}
.stage-footer-note {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}
.stage-soudan-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  font-size: 13px;
}
.stage-soudan-btn svg {
  width: 14px;
  height: 14px;
}

/* 画面最後：基盤 ＆ アップセル */
.guide-upsell-container {
  background: linear-gradient(180deg, #FFFFFF 0%, #F8FAFC 100%);
  border: 1px solid #CBD5E1;
}
.sub-badge-lead {
  display: inline-block;
  background: #E0E7FF;
  color: #3730A3;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 12px;
}
.upsell-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-m);
}
.upsell-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.upsell-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.upsell-card-tag {
  display: inline-block;
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  color: var(--color-primary);
  background: var(--color-primary-light);
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
}
.upsell-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 6px 0;
  line-height: 1.4;
}
.upsell-card-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--status-warn-text);
  margin-bottom: 8px;
}
.upsell-card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0 0 10px 0;
}
.upsell-security-rule {
  background: #F8FAFC;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 10px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-main);
  margin-bottom: 12px;
}
.upsell-card-list {
  padding-left: 16px;
  margin: 0 0 12px 0;
  font-size: 12px;
  color: var(--text-main);
  line-height: 1.6;
}

/* 料金ボックス */
.guide-pricing-box {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 18px;
}
.pricing-cards-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-m);
}
.price-box-item {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 20px 14px;
  text-align: center;
  position: relative;
  background: #FFFFFF;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}
.price-box-recommended {
  border: 2px solid var(--color-primary);
  background: #F8FAFC;
  box-shadow: 0 4px 12px rgba(27, 77, 137, 0.08);
  padding-top: 36px;
}
.price-box-header-band {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 26px;
  background: var(--color-primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
}
.price-box-badge {
  position: absolute;
  top: -11px;
  right: 12px;
  background: var(--color-primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}
.price-box-tier {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
}
.price-box-amount {
  font-size: 15px;
  color: var(--color-primary);
  margin-bottom: 6px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
}
.price-box-amount .price-num {
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.price-box-amount .price-unit {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}
.price-box-sub {
  font-size: 11px;
  color: var(--color-primary);
  font-weight: 600;
  margin-bottom: 6px;
}
.price-box-note {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 4px;
}
.btn-cta-prominent {
  background: #0284C7 !important;
  color: #FFFFFF !important;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3) !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease !important;
}
.btn-cta-prominent:hover {
  background: #0369A1 !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.4) !important;
}

/* 無料相談バナー */
.free-consult-banner {
  background: #F0FDF4;
  border: 2px solid #86EFAC;
  border-radius: 8px;
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-m);
  flex-wrap: wrap;
}
.consult-badge {
  display: inline-block;
  background: #DCFCE7;
  color: #15803D;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}

/* ハイライトアニメーション */
@keyframes highlightPulse {
  0% { box-shadow: 0 0 0 0 rgba(27, 77, 137, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(27, 77, 137, 0.2); }
  100% { box-shadow: 0 0 0 0 rgba(27, 77, 137, 0); }
}
.highlight-flash {
  animation: highlightPulse 1.2s ease 2;
  border-color: var(--color-primary) !important;
}

/* =====================================================
   レスポンシブ（モバイル幅 390px / 768px 以下）
   ===================================================== */
@media (max-width: 768px) {
  .mobile-flow-summary {
    display: block !important;
  }
  .mobile-flow-summary svg {
    width: 16px;
    height: 16px;
    vertical-align: -2px;
    flex-shrink: 0;
  }
  .pipeline-flow-container {
    flex-direction: column;
  }
  .pipeline-connector {
    transform: rotate(90deg);
    padding: 10px 0;
  }
  .entry-cards-grid {
    grid-template-columns: 1fr;
  }
  .stage-meta-grid {
    grid-template-columns: 1fr;
  }
  .upsell-cards-grid {
    grid-template-columns: 1fr;
  }
  .pricing-cards-row {
    grid-template-columns: 1fr;
  }
  .free-consult-banner {
    flex-direction: column;
    align-items: flex-start;
  }
  .consult-action {
    width: 100%;
  }
  .consult-action .btn {
    width: 100%;
    justify-content: center;
  }
}

