/* =====================================================================
   MDL Marketing v2 — Multi-page Admin UI (Light theme)
   ===================================================================== */

:root {
  --bg: #fafbfc;
  --bg-1: #ffffff;
  --bg-2: #f4f6f9;
  --bg-3: #eaeef3;
  --bg-4: #d9dee6;
  --border: #e5e9f0;
  --border-2: #cdd4df;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --primary: #4f46e5;
  --primary-2: #6366f1;
  --primary-glow: rgba(79, 70, 229, 0.16);
  --accent: #7c3aed;
  --success: #047857;
  --success-bg: rgba(4, 120, 87, 0.08);
  --warn: #b45309;
  --warn-bg: rgba(180, 83, 9, 0.08);
  --danger: #b91c1c;
  --danger-bg: rgba(185, 28, 28, 0.08);
  --info-bg: rgba(79, 70, 229, 0.06);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 24px 56px rgba(15, 23, 42, 0.10), 0 2px 6px rgba(15, 23, 42, 0.05);
  --easing: cubic-bezier(0.32, 0.72, 0, 1);
  --duration-fast: 120ms;
  --duration: 200ms;
  --duration-slow: 360ms;
  --mono: 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;

  /* ===== Pro tokens (= モック準拠、 段階的に既存 token を移行) ===== */
  /* Typography scale — 8 段固定 */
  --fs-11: 11px; --fs-12: 12px; --fs-13: 13px; --fs-14: 14px;
  --fs-16: 16px; --fs-20: 20px; --fs-28: 28px; --fs-36: 36px;
  --lh-tight: 1.2; --lh-base: 1.5; --lh-loose: 1.7;
  /* Spacing scale — 4 / 8 / 12 / 16 / 24 / 32 / 48 / 64 */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px;
  --s-6: 24px; --s-8: 32px; --s-12: 48px; --s-16: 64px;
  /* Semantic surface / text */
  --c-canvas: #f8f9fc;
  --c-surface: #ffffff;
  --c-surface-2: #f4f6fa;
  --c-surface-3: #ebeef4;
  --c-border-light: #e3e7ee;
  --c-border-strong: #ccd2dc;
  --c-text-strong: #0b1220;
  --c-text-muted: #5a6478;
  --c-text-soft: #98a1b3;
  /* Pro primary */
  --c-primary-main: #5b5bf2;
  --c-primary-hover: #4848e0;
  --c-primary-soft: #ecedfd;
  --c-accent: #7c5cff;
  /* Pro feedback */
  --c-success-main: #0f9d62;
  --c-success-soft: #e3f7ee;
  --c-warn-main: #b56b04;
  --c-warn-soft: #fdf3e0;
  --c-danger-main: #c2362b;
  --c-danger-soft: #fce8e6;
  /* Chart palette — categorical 6 */
  --c-chart-1: #5b5bf2;
  --c-chart-2: #0f9d62;
  --c-chart-3: #d77a00;
  --c-chart-4: #b73d83;
  --c-chart-5: #0e80b8;
  --c-chart-6: #6b6b6b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Hiragino Sans',
               'Noto Sans JP', 'Yu Gothic', sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 背景に超うっすらグラデーション */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 600px at 0% 0%, rgba(79, 70, 229, 0.04), transparent 60%),
    radial-gradient(900px 500px at 100% 100%, rgba(124, 58, 237, 0.04), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-2); }

button { font-family: inherit; }

/* =====================================================================
   View Transitions
   ===================================================================== */
@view-transition { navigation: auto; }
::view-transition-old(root) {
  animation: vto var(--duration) var(--easing) both;
}
::view-transition-new(root) {
  animation: vtn var(--duration) var(--easing) both;
}
@keyframes vto {
  to { opacity: 0; transform: translateY(-4px); }
}
@keyframes vtn {
  from { opacity: 0; transform: translateY(8px); }
}

/* =====================================================================
   Layout shell
   ===================================================================== */
.shell {
  display: grid;
  grid-template-columns: 256px 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 22px 16px;
  background: linear-gradient(180deg, #ffffff, #f7f9fc);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 4px 14px var(--primary-glow);
}
.brand-mark svg { width: 18px; height: 18px; color: #fff; }

.brand-logo {
  height: 30px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  display: block;
}
.brand-only-logo {
  justify-content: flex-start;
}
.login-logo {
  height: 44px;
  width: auto;
  max-width: 240px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}
.brand-name {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
}
.brand-sub {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 1px;
}

.nav-section { margin-top: 14px; }
.nav-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-3);
  margin: 0 8px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--duration-fast) var(--easing),
              color var(--duration-fast) var(--easing),
              transform var(--duration-fast) var(--easing);
  cursor: pointer;
}
.nav-item:hover {
  background: var(--bg-2);
  color: var(--text);
}
.nav-item.is-active {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.10), rgba(124, 58, 237, 0.06));
  color: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(79, 70, 229, 0.18);
}
.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.85;
}
.nav-spacer { flex: 1; }
.nav-foot {
  margin-top: 12px;
  padding: 10px 8px;
  font-size: 11px;
  color: var(--text-3);
  border-top: 1px solid var(--border);
}

/* =====================================================================
   Main content
   ===================================================================== */
.main {
  padding: 32px 40px 64px;
  max-width: 1200px;
  width: 100%;
}

.page-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

/* Top bar (multi-shop switcher) */
.top-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 8px 0;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.shop-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
}
.shop-label {
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 500;
}
.crumb {
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.crumb a { color: var(--text-2); }
.crumb svg { width: 12px; height: 12px; opacity: 0.5; }
.page-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--text);
}
.page-desc {
  color: var(--text-2);
  margin: 0;
  font-size: 14px;
}

.page-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

/* about-this-page panel */
.about-panel {
  margin: 24px 0 28px;
  padding: 18px 22px;
  background: linear-gradient(135deg, var(--info-bg), transparent);
  border: 1px solid rgba(79, 70, 229, 0.16);
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: start;
  animation: fadeUp 360ms var(--easing) both;
}
.about-panel-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px var(--primary-glow);
}
.about-panel-icon svg { width: 18px; height: 18px; color: #fff; }
.about-panel-title {
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--text);
}
.about-panel-body {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.7;
}
.about-panel-body ul {
  margin: 6px 0 0;
  padding-left: 20px;
}
.about-panel-body li { margin-bottom: 3px; }
.about-panel-body strong { color: var(--text); }
.about-panel-body code {
  font-family: var(--mono);
  background: var(--bg-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--primary);
  border: 1px solid var(--border);
}

/* リッチな about-panel: セクション分け */
.about-rich {
  display: grid;
  gap: 14px;
  margin: 20px 0 26px;
}
.about-rich .ar-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: flex-start;
  animation: fadeUp 360ms var(--easing) both;
}
.about-rich .ar-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.about-rich .ar-icon svg { width: 16px; height: 16px; }
.about-rich .ar-icon.ar-purpose { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; }
.about-rich .ar-icon.ar-howto { background: var(--info-bg); color: var(--primary); border: 1px solid rgba(79,70,229,0.18); }
.about-rich .ar-icon.ar-tips { background: var(--warn-bg); color: var(--warn); border: 1px solid rgba(180,83,9,0.18); }
.about-rich .ar-icon.ar-related { background: var(--success-bg); color: var(--success); border: 1px solid rgba(4,120,87,0.18); }
.about-rich .ar-icon.ar-playbook { background: rgba(16, 185, 129, 0.12); color: var(--success); border: 1px solid rgba(4,120,87,0.18); }
.about-rich .ar-icon.ar-faq { background: var(--bg-3); color: var(--text-2); border: 1px solid var(--border); }
.about-rich .ar-icon.ar-glossary { background: rgba(139, 92, 246, 0.12); color: var(--accent); border: 1px solid rgba(139,92,246,0.20); }
.about-rich .ar-icon.ar-warn { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(185,28,28,0.18); }
.about-rich .ar-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin: 0 0 6px;
}
.about-rich .ar-body {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.7;
  margin: 0;
}
.about-rich .ar-body strong { color: var(--text); }
.about-rich .ar-body code {
  font-family: var(--mono);
  background: var(--bg-2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--primary);
  border: 1px solid var(--border);
}
.about-rich .ar-body ol, .about-rich .ar-body ul {
  margin: 6px 0 0;
  padding-left: 20px;
}
.about-rich .ar-body li { margin-bottom: 4px; }
.about-rich .ar-body a { color: var(--primary); }
.about-rich .ar-related-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.about-rich .ar-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--text-2);
  text-decoration: none;
  transition: all var(--duration-fast) var(--easing);
}
.about-rich .ar-chip:hover {
  background: var(--info-bg);
  border-color: rgba(79,70,229,0.25);
  color: var(--primary);
}
.about-rich .ar-chip svg { width: 11px; height: 11px; }

/* 使い方ステップ列 (about内で番号付き) */
.steps-inline {
  display: grid;
  gap: 6px;
  margin: 6px 0 0;
}
.steps-inline .si-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  align-items: start;
  font-size: 13px;
  color: var(--text-2);
}
.steps-inline .si-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  margin-top: 2px;
}
.steps-inline .si-row strong { color: var(--text); }

/* シナリオ/レシピ用カード */
.recipe {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: flex-start;
}
.recipe-tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--success);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
  height: fit-content;
}
.recipe-tag.tag-bronze { background: var(--bg-3); color: var(--text-2); }
.recipe-tag.tag-silver { background: var(--info-bg); color: var(--primary); }
.recipe-tag.tag-gold { background: rgba(180,83,9,0.10); color: var(--warn); }
.recipe-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
}
.recipe-body { font-size: 12.5px; color: var(--text-2); line-height: 1.65; }
.recipe-body code {
  font-family: var(--mono);
  background: var(--bg-1);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--primary);
  border: 1px solid var(--border);
}

/* FAQ details list */
.faq-list { display: grid; gap: 6px; }
.faq-item {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before {
  content: '+';
  font-size: 14px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--info-bg);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 700;
  flex-shrink: 0;
  transition: transform var(--duration-fast) var(--easing);
}
.faq-item[open] summary::before { content: '−'; }
.faq-item-body {
  margin: 8px 0 4px 26px;
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.7;
}
.faq-item-body code {
  font-family: var(--mono);
  background: var(--bg-2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--primary);
  border: 1px solid var(--border);
}

/* ref table — small reference table inside about */
.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 4px;
}
.ref-table th, .ref-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.ref-table th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  background: var(--bg-2);
}
.ref-table td code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--primary);
  background: var(--bg-2);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* 用語チップ - 用語の説明を inline で表示 */
.kterm {
  display: inline-block;
  font-size: 11.5px;
  background: var(--info-bg);
  color: var(--primary);
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid rgba(79,70,229,0.18);
  font-weight: 600;
  margin: 0 2px;
}

/* =====================================================================
   Cards & sections
   ===================================================================== */
.section {
  margin-top: 28px;
}
.section-title {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.section-title svg { width: 14px; height: 14px; opacity: 0.7; }

.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--duration) var(--easing);
}
.card.hoverable { cursor: pointer; }
.card.hoverable:hover {
  border-color: var(--border-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
.kpi {
  position: relative;
  padding: 18px 20px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform var(--duration) var(--easing),
              border-color var(--duration) var(--easing),
              box-shadow var(--duration) var(--easing);
  animation: fadeUp 320ms var(--easing) both;
  box-shadow: var(--shadow-sm);
}
.kpi:hover {
  transform: translateY(-1px);
  border-color: var(--border-2);
  box-shadow: var(--shadow);
}
.kpi::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  opacity: 0;
  transition: opacity var(--duration) var(--easing);
}
.kpi:hover::before { opacity: 0.7; }
.kpi-label {
  font-size: 12px;
  color: var(--text-3);
  margin: 0 0 8px;
}
.kpi-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.kpi-sub {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* =====================================================================
   Buttons
   ===================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--duration-fast) var(--easing),
              background var(--duration-fast) var(--easing),
              border-color var(--duration-fast) var(--easing),
              box-shadow var(--duration-fast) var(--easing);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}
.btn-primary:hover {
  filter: brightness(1.05);
  box-shadow: 0 6px 20px var(--primary-glow);
}
.btn-ghost {
  background: var(--bg-1);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-ghost:hover { background: var(--bg-2); border-color: var(--border-2); }
.btn-danger {
  background: var(--bg-1);
  color: var(--danger);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; }

/* =====================================================================
   Forms
   ===================================================================== */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.field-hint {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 400;
}
.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color var(--duration-fast) var(--easing),
              box-shadow var(--duration-fast) var(--easing);
  box-shadow: var(--shadow-sm);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.input.mono, .textarea.mono { font-family: var(--mono); font-size: 12px; }
.textarea { resize: vertical; min-height: 84px; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.form-row.two { grid-template-columns: 1fr 1fr; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-2);
}
.checkbox-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

/* =====================================================================
   Tables
   ===================================================================== */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th, .table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.table th {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--bg-2);
}
.table tr { transition: background var(--duration-fast) var(--easing); }
.table tbody tr:hover { background: var(--bg-2); }
.table .mono { font-family: var(--mono); font-size: 12px; color: var(--text-2); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-muted { background: var(--bg-3); color: var(--text-2); }
.badge-info { background: var(--info-bg); color: var(--primary); }

/* =====================================================================
   Empty state
   ===================================================================== */
.empty {
  padding: 48px 24px;
  text-align: center;
  background: var(--bg-1);
  border: 1px dashed var(--border-2);
  border-radius: var(--radius);
  color: var(--text-2);
  animation: fadeUp 360ms var(--easing) both;
}
.empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  background: var(--bg-2);
  border-radius: 12px;
  color: var(--primary);
}
.empty-icon svg { width: 22px; height: 22px; }
.empty-title { font-weight: 600; color: var(--text); margin: 0 0 6px; }
.empty-text { font-size: 13px; margin: 0 auto; max-width: 420px; }

/* =====================================================================
   Skeleton
   ===================================================================== */
.skeleton {
  position: relative;
  background: var(--bg-2);
  border-radius: 6px;
  overflow: hidden;
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(15, 23, 42, 0.04), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

/* =====================================================================
   Toast
   ===================================================================== */
.toast-wrap {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  animation: slideIn 280ms var(--easing) both;
  min-width: 280px;
  color: var(--text);
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast.success svg { color: var(--success); }
.toast.error svg { color: var(--danger); }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* =====================================================================
   Dialog (modal)
   ===================================================================== */
.dialog-bg {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.32);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 9000;
  animation: fadeIn 200ms var(--easing) both;
}
.dialog {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  max-width: 520px;
  width: 92vw;
  box-shadow: var(--shadow-lg);
  animation: dialogIn 280ms var(--easing) both;
  max-height: 90vh;
  overflow-y: auto;
}
.dialog h3 { margin: 0 0 14px; font-size: 16px; font-weight: 700; color: var(--text); }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes dialogIn {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* =====================================================================
   Login
   ===================================================================== */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  z-index: 1;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 32px 28px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 360ms var(--easing) both;
}
.login-card .brand-mark { width: 40px; height: 40px; }
.login-card h1 { font-size: 20px; font-weight: 700; margin: 14px 0 6px; color: var(--text); }
.login-card p { color: var(--text-2); margin: 0 0 22px; font-size: 13px; }
.login-card .field-hint a { color: var(--primary); }

/* =====================================================================
   Dashboard / Quickstart cards
   ===================================================================== */
.quickstart {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}
.qs-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color var(--duration) var(--easing),
              transform var(--duration) var(--easing),
              box-shadow var(--duration) var(--easing);
  text-decoration: none;
  color: var(--text);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.qs-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--primary-glow), transparent);
  opacity: 0;
  transition: opacity var(--duration) var(--easing);
  pointer-events: none;
}
.qs-card:hover::after { opacity: 0.5; }
.qs-card:hover {
  border-color: var(--border-2);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.qs-card .qs-step {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--primary);
  font-weight: 700;
}
.qs-card .qs-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}
.qs-card .qs-text {
  font-size: 12px;
  color: var(--text-2);
  margin: 0;
}
.qs-card .qs-cta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* =====================================================================
   Status row / connection test panel
   ===================================================================== */
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.status-row:last-child { border-bottom: 0; }
.status-row > div:first-child { font-size: 13px; }
.status-row > div:first-child small { display: block; color: var(--text-3); margin-top: 2px; font-size: 11px; }
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
  background: var(--text-3);
}
.dot.ok { background: var(--success); box-shadow: 0 0 8px rgba(4, 120, 87, 0.5); animation: pulse 1.6s infinite; }
.dot.bad { background: var(--danger); }
.dot.pending { background: var(--warn); animation: pulse 1.6s infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* =====================================================================
   Code snippet block
   ===================================================================== */
.snippet {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  overflow-x: auto;
  white-space: pre;
}
.snippet-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  transition: all var(--duration-fast) var(--easing);
  box-shadow: var(--shadow-sm);
}
.snippet-copy:hover { color: var(--text); background: var(--bg-3); }
.snippet-copy.copied { color: var(--success); border-color: var(--success); }

/* =====================================================================
   Animations
   ===================================================================== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.stagger > * { animation: fadeUp 360ms var(--easing) both; }
.stagger > *:nth-child(1) { animation-delay: 40ms; }
.stagger > *:nth-child(2) { animation-delay: 80ms; }
.stagger > *:nth-child(3) { animation-delay: 120ms; }
.stagger > *:nth-child(4) { animation-delay: 160ms; }
.stagger > *:nth-child(5) { animation-delay: 200ms; }
.stagger > *:nth-child(6) { animation-delay: 240ms; }
.stagger > *:nth-child(7) { animation-delay: 280ms; }
.stagger > *:nth-child(8) { animation-delay: 320ms; }

/* =====================================================================
   Misc
   ===================================================================== */
.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.mono-text { font-family: var(--mono); font-size: 12px; }
.step-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--bg-1);
}
.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

/* =====================================================================
   Pro SaaS — saas-mode 内で適用する 強化スタイル一式
   (= モックの design tokens 準拠、 typography / spacing / motion 統一)
   ===================================================================== */
body.saas-mode { background: var(--c-canvas); color: var(--c-text-strong); }

/* App layout */
body.saas-mode .pro-app {
  display: grid;
  grid-template-columns: 224px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas: 'logo header' 'sidebar main';
  min-height: 100vh;
}
body.saas-mode .pro-logo-area {
  grid-area: logo;
  border-right: 1px solid var(--c-border-light);
  border-bottom: 1px solid var(--c-border-light);
  display: flex; align-items: center; padding: 0 var(--s-4);
  background: var(--c-surface);
}
body.saas-mode .pro-logo {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-weight: 700; font-size: var(--fs-14); color: var(--c-text-strong);
  text-decoration: none; letter-spacing: -0.01em;
}
body.saas-mode .pro-logo-mark {
  width: 26px; height: 26px; border-radius: 6px;
  background: linear-gradient(135deg, var(--c-primary-main), var(--c-accent));
  color: #fff; font-weight: 800; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(91,91,242,0.35);
  transition: transform var(--duration) var(--easing);
}
body.saas-mode .pro-logo:hover .pro-logo-mark { transform: rotate(-6deg) scale(1.05); }

body.saas-mode .pro-header {
  grid-area: header;
  border-bottom: 1px solid var(--c-border-light);
  background: var(--c-surface);
  display: flex; align-items: center;
  padding: 0 var(--s-6); gap: var(--s-4);
}
body.saas-mode .pro-search { flex: 1; max-width: 480px; position: relative; }
body.saas-mode .pro-search input {
  width: 100%; height: 34px; padding: 0 var(--s-3) 0 36px;
  font-size: var(--fs-13); font-family: inherit;
  background: var(--c-surface-2); border: 1px solid transparent;
  border-radius: 8px; color: var(--c-text-strong);
  transition: all var(--duration-fast) var(--easing);
}
body.saas-mode .pro-search input:focus {
  outline: none; background: var(--c-surface);
  border-color: var(--c-primary-main);
  box-shadow: 0 0 0 3px var(--c-primary-soft);
}
body.saas-mode .pro-search .pro-search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--c-text-soft);
}
body.saas-mode .pro-search kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 10px; padding: 2px 5px; background: var(--c-surface-3);
  color: var(--c-text-muted); border-radius: 4px; font-family: inherit;
}
body.saas-mode .pro-header-spacer { flex: 1; }
body.saas-mode .pro-header-actions { display: flex; align-items: center; gap: var(--s-2); }
body.saas-mode .pro-icon-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; background: transparent; border: 0;
  color: var(--c-text-muted);
  transition: all var(--duration-fast) var(--easing);
  cursor: pointer;
}
body.saas-mode .pro-icon-btn:hover { background: var(--c-surface-2); color: var(--c-text-strong); }
body.saas-mode .pro-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #ec4899);
  color: #fff; font-weight: 600; font-size: var(--fs-12);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}

body.saas-mode .pro-sidebar {
  grid-area: sidebar;
  border-right: 1px solid var(--c-border-light);
  background: var(--c-surface);
  padding: var(--s-3) var(--s-2);
  overflow-y: auto;
}
body.saas-mode .pro-nav-section { margin-bottom: var(--s-4); }
body.saas-mode .pro-nav-title {
  font-size: var(--fs-11); font-weight: 600;
  color: var(--c-text-soft);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: var(--s-1) var(--s-3); margin-bottom: var(--s-1);
}
body.saas-mode .pro-nav-item {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 6px var(--s-3);
  border-radius: 6px;
  font-size: var(--fs-13); font-weight: 500;
  color: var(--c-text-muted); text-decoration: none;
  transition: all var(--duration-fast) var(--easing);
}
body.saas-mode .pro-nav-item:hover { background: var(--c-surface-2); color: var(--c-text-strong); }
body.saas-mode .pro-nav-item.is-active {
  background: var(--c-primary-soft); color: var(--c-primary-main); font-weight: 600;
}
body.saas-mode .pro-nav-item .pro-ico { font-size: 14px; opacity: 0.8; display: inline-flex; }
body.saas-mode .pro-nav-item.is-active .pro-ico { opacity: 1; }
body.saas-mode .pro-nav-item .pro-badge {
  margin-left: auto; font-size: var(--fs-11); padding: 1px 6px;
  background: var(--c-surface-3); color: var(--c-text-muted); border-radius: 999px;
}
body.saas-mode .pro-nav-caret {
  margin-left: auto; font-size: 10px; opacity: 0.5; transition: transform 160ms;
}
body.saas-mode .pro-nav-item.is-open .pro-nav-caret { transform: rotate(180deg); opacity: 1; }
body.saas-mode .pro-nav-item.is-active .pro-nav-caret { transform: rotate(180deg); opacity: 1; }
body.saas-mode .pro-nav-sub {
  margin: 2px 0 8px 22px;
  padding-left: 10px;
  border-left: 1px dashed var(--c-border-light);
  display: flex; flex-direction: column; gap: 1px;
}
body.saas-mode .pro-nav-sub-item {
  display: block;
  font-size: var(--fs-12);
  padding: 5px 10px;
  color: var(--c-text-muted);
  text-decoration: none;
  border-radius: 5px;
  transition: background var(--duration-fast) var(--easing), color var(--duration-fast) var(--easing);
}
body.saas-mode .pro-nav-sub-item:hover { background: var(--c-surface-2); color: var(--c-text-strong); }
body.saas-mode .pro-nav-sub-item.is-active {
  background: var(--c-primary-soft); color: var(--c-primary-main); font-weight: 600;
}

body.saas-mode .pro-main {
  grid-area: main;
  padding: var(--s-6) var(--s-8);
  overflow-y: auto;
}
body.saas-mode .pro-page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: var(--s-4); gap: var(--s-4);
}
body.saas-mode .pro-page-title {
  font-size: var(--fs-28); font-weight: 700; line-height: var(--lh-tight);
  letter-spacing: -0.015em; margin: 0; color: var(--c-text-strong);
}
body.saas-mode .pro-page-subtitle {
  font-size: var(--fs-13); color: var(--c-text-muted); margin: 4px 0 0;
}

/* Toolbar */
body.saas-mode .pro-toolbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-2);
  background: var(--c-surface); border: 1px solid var(--c-border-light);
  border-radius: 8px; padding: var(--s-2); margin-bottom: var(--s-4);
}
body.saas-mode .pro-pill {
  display: inline-flex; align-items: center; gap: var(--s-1);
  padding: 5px 10px;
  background: var(--c-surface-2); border: 1px solid var(--c-border-light);
  border-radius: 999px;
  font-size: var(--fs-12); font-weight: 500; color: var(--c-text-strong);
  transition: all var(--duration-fast) var(--easing);
  cursor: pointer; font-family: inherit;
}
body.saas-mode .pro-pill:hover { background: var(--c-surface-3); }
body.saas-mode .pro-pill .pro-pill-key { color: var(--c-text-muted); font-weight: 500; }
body.saas-mode .pro-pill .pro-pill-val { color: var(--c-text-strong); font-weight: 600; }
body.saas-mode .pro-pill .pro-pill-x {
  width: 14px; height: 14px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; color: var(--c-text-soft);
  font-size: 11px; line-height: 1; padding: 0; margin-left: 2px; cursor: pointer;
}
body.saas-mode .pro-pill .pro-pill-x:hover { background: var(--c-danger-soft); color: var(--c-danger-main); }
body.saas-mode .pro-pill-add {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px;
  background: transparent; border: 1px dashed var(--c-border-strong);
  border-radius: 999px;
  font-size: var(--fs-12); font-weight: 500; color: var(--c-text-muted);
  cursor: pointer; font-family: inherit;
  transition: all var(--duration-fast) var(--easing);
}
body.saas-mode .pro-pill-add:hover {
  border-color: var(--c-primary-main); color: var(--c-primary-main); background: var(--c-primary-soft);
}
body.saas-mode .pro-toolbar-spacer { flex: 1; }
body.saas-mode .pro-seg {
  display: inline-flex; background: var(--c-surface-2);
  border-radius: 6px; padding: 2px;
}
body.saas-mode .pro-seg button {
  background: transparent; border: 0;
  padding: 4px 12px; font-size: var(--fs-12); font-weight: 500;
  color: var(--c-text-muted); border-radius: 4px;
  transition: all var(--duration-fast) var(--easing);
  font-family: inherit; cursor: pointer;
}
body.saas-mode .pro-seg button.is-active {
  background: var(--c-surface); color: var(--c-text-strong);
  box-shadow: 0 1px 2px rgba(15,22,35,0.06);
}
body.saas-mode .pro-seg button:hover:not(.is-active) { color: var(--c-text-strong); }

/* Pro button */
body.saas-mode .pro-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  font-size: var(--fs-12); font-weight: 600;
  border-radius: 6px; border: 1px solid transparent;
  transition: all var(--duration-fast) var(--easing);
  font-family: inherit; cursor: pointer;
}
body.saas-mode .pro-btn-primary {
  background: var(--c-primary-main); color: #fff;
  box-shadow: 0 2px 8px rgba(91,91,242,0.28);
}
body.saas-mode .pro-btn-primary:hover {
  background: var(--c-primary-hover);
  box-shadow: 0 4px 14px rgba(91,91,242,0.4); transform: translateY(-1px);
}
body.saas-mode .pro-btn-primary:active { transform: scale(0.97); }
body.saas-mode .pro-btn-ghost {
  background: transparent; color: var(--c-text-strong);
  border-color: var(--c-border-light);
}
body.saas-mode .pro-btn-ghost:hover { background: var(--c-surface-2); border-color: var(--c-border-strong); }

/* KPI grid */
body.saas-mode .pro-kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: var(--s-3); margin-bottom: var(--s-4);
}
body.saas-mode .pro-kpi {
  background: var(--c-surface);
  border: 1px solid var(--c-border-light);
  border-radius: 8px; padding: var(--s-4); position: relative;
  transition: transform var(--duration) var(--easing), box-shadow var(--duration) var(--easing), border-color var(--duration-fast) var(--easing);
}
body.saas-mode .pro-kpi:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(15,22,35,0.08);
  border-color: var(--c-border-strong);
}
body.saas-mode .pro-kpi-label {
  font-size: var(--fs-12); color: var(--c-text-muted);
  font-weight: 500; letter-spacing: 0.01em;
  margin-bottom: var(--s-2);
  display: flex; align-items: center; gap: 4px;
}
body.saas-mode .pro-kpi-help {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--c-surface-3); color: var(--c-text-muted);
  font-size: 10px; cursor: help;
}
body.saas-mode .pro-kpi-value {
  font-size: var(--fs-28); font-weight: 700; line-height: 1.1;
  letter-spacing: -0.02em; color: var(--c-text-strong);
  font-variant-numeric: tabular-nums;
}
body.saas-mode .pro-kpi-delta {
  font-size: var(--fs-12); font-weight: 600; margin-top: 4px;
  font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: center; gap: 4px;
}
body.saas-mode .pro-kpi-delta.up { color: var(--c-success-main); }
body.saas-mode .pro-kpi-delta.down { color: var(--c-danger-main); }
body.saas-mode .pro-kpi-delta .pro-kpi-delta-base {
  font-weight: 500; color: var(--c-text-soft);
}
body.saas-mode .pro-kpi-spark {
  position: absolute; right: var(--s-4); bottom: var(--s-4);
  width: 80px; height: 28px; opacity: 0.7;
}

/* 3 ペイン */
body.saas-mode .pro-three-pane {
  display: grid; grid-template-columns: 240px 1fr 280px;
  gap: var(--s-3); margin-bottom: var(--s-4);
}
body.saas-mode .pro-pane {
  background: var(--c-surface); border: 1px solid var(--c-border-light);
  border-radius: 8px; overflow: hidden;
  transition: box-shadow var(--duration) var(--easing);
}
body.saas-mode .pro-pane-head {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--c-border-light);
  font-size: var(--fs-11); font-weight: 600;
  color: var(--c-text-soft);
  text-transform: uppercase; letter-spacing: 0.08em;
}
body.saas-mode .pro-pane-body { padding: var(--s-3) var(--s-4); }

/* Chart */
body.saas-mode .pro-chart-area { padding: var(--s-4); height: 320px; position: relative; }
body.saas-mode .pro-chart-legend {
  display: flex; gap: var(--s-3);
  margin-bottom: var(--s-3); flex-wrap: wrap;
  font-size: var(--fs-12);
}
body.saas-mode .pro-chart-legend span {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--c-text-muted);
}
body.saas-mode .pro-chart-legend i {
  width: 10px; height: 10px; border-radius: 2px; display: inline-block;
}

/* Card */
body.saas-mode .pro-card {
  background: var(--c-surface); border: 1px solid var(--c-border-light);
  border-radius: 8px; overflow: hidden;
  transition: box-shadow var(--duration) var(--easing);
}
body.saas-mode .pro-card:hover { box-shadow: 0 1px 2px rgba(15,22,35,0.06); }
body.saas-mode .pro-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--c-border-light);
}
body.saas-mode .pro-card-title { font-size: var(--fs-14); font-weight: 600; margin: 0; color: var(--c-text-strong); }
body.saas-mode .pro-card-subtitle { font-size: var(--fs-12); color: var(--c-text-muted); margin: 2px 0 0; }

/* Pro table */
body.saas-mode .pro-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: var(--fs-13);
}
body.saas-mode .pro-table thead th {
  text-align: left; padding: var(--s-2) var(--s-4);
  font-size: var(--fs-11); font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--c-surface-2);
  border-bottom: 1px solid var(--c-border-light);
  white-space: nowrap;
}
body.saas-mode .pro-table tbody td {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--c-border-light);
  font-variant-numeric: tabular-nums;
}
body.saas-mode .pro-table tbody tr { transition: background var(--duration-fast) var(--easing); }
body.saas-mode .pro-table tbody tr:hover { background: var(--c-surface-2); }
body.saas-mode .pro-table tbody tr:last-child td { border-bottom: 0; }
body.saas-mode .pro-table .num { text-align: right; }

/* List item */
body.saas-mode .pro-list-item {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 6px var(--s-2);
  border-radius: 6px;
  font-size: var(--fs-13); color: var(--c-text-strong);
  cursor: pointer;
  transition: background var(--duration-fast) var(--easing);
}
body.saas-mode .pro-list-item:hover { background: var(--c-surface-2); }
body.saas-mode .pro-list-item .pro-ico { color: var(--c-text-soft); font-size: 14px; }
body.saas-mode .pro-list-item .pro-meta {
  margin-left: auto; font-size: var(--fs-11); color: var(--c-text-soft);
}

/* Field */
body.saas-mode .pro-field { margin-bottom: var(--s-3); }
body.saas-mode .pro-field-label {
  display: block; font-size: var(--fs-11); font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 4px;
}
body.saas-mode .pro-field select,
body.saas-mode .pro-field input[type="text"] {
  width: 100%; height: 30px; padding: 0 8px;
  font-size: var(--fs-13); font-family: inherit;
  background: var(--c-surface); border: 1px solid var(--c-border-light);
  border-radius: 6px; color: var(--c-text-strong);
  transition: all var(--duration-fast) var(--easing);
}
body.saas-mode .pro-field select:focus,
body.saas-mode .pro-field input:focus {
  outline: none; border-color: var(--c-primary-main);
  box-shadow: 0 0 0 3px var(--c-primary-soft);
}

/* Mobile overlay */
body.saas-mode .pro-mobile-toggle { display: none; }
body.saas-mode .pro-mobile-overlay { display: none; }

/* Animations: page entrance */
@keyframes proFadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes proFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes proDrawLine {
  from { stroke-dashoffset: var(--len, 1000); }
  to { stroke-dashoffset: 0; }
}

body.saas-mode .pro-page-head { animation: proFadeUp 400ms var(--easing) both; }
body.saas-mode .pro-toolbar { animation: proFadeUp 400ms 60ms var(--easing) both; }
body.saas-mode .pro-kpi-grid > .pro-kpi:nth-child(1) { animation: proFadeUp 420ms 120ms var(--easing) both; }
body.saas-mode .pro-kpi-grid > .pro-kpi:nth-child(2) { animation: proFadeUp 420ms 180ms var(--easing) both; }
body.saas-mode .pro-kpi-grid > .pro-kpi:nth-child(3) { animation: proFadeUp 420ms 240ms var(--easing) both; }
body.saas-mode .pro-kpi-grid > .pro-kpi:nth-child(4) { animation: proFadeUp 420ms 300ms var(--easing) both; }
body.saas-mode .pro-three-pane > .pro-pane:nth-child(1) { animation: proFadeUp 460ms 340ms var(--easing) both; }
body.saas-mode .pro-three-pane > .pro-pane:nth-child(2) { animation: proFadeUp 460ms 380ms var(--easing) both; }
body.saas-mode .pro-three-pane > .pro-pane:nth-child(3) { animation: proFadeUp 460ms 420ms var(--easing) both; }
body.saas-mode .pro-card { animation: proFadeUp 480ms 460ms var(--easing) both; }
body.saas-mode .pro-chart-area polyline,
body.saas-mode .pro-kpi-spark polyline {
  stroke-dasharray: 1000; stroke-dashoffset: 1000;
  animation: proDrawLine 1.4s 400ms var(--easing) forwards;
}
body.saas-mode .pro-kpi-spark polyline {
  animation-delay: 600ms; animation-duration: 1s;
}
body.saas-mode .pro-chart-area polyline:nth-of-type(1) { animation-delay: 500ms; }
body.saas-mode .pro-chart-area polyline:nth-of-type(2) { animation-delay: 700ms; }
body.saas-mode .pro-chart-area polyline:nth-of-type(3) { animation-delay: 900ms; }

/* Responsive */
@media (max-width: 1100px) {
  body.saas-mode .pro-three-pane { grid-template-columns: 1fr 280px; }
  body.saas-mode .pro-three-pane > .pro-pane:nth-child(1) { display: none; }
  body.saas-mode .pro-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  body.saas-mode .pro-app {
    grid-template-columns: 1fr;
    grid-template-rows: 56px 1fr;
    grid-template-areas: 'header' 'main';
  }
  body.saas-mode .pro-logo-area { display: none; }
  body.saas-mode .pro-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 264px; z-index: 200;
    transform: translateX(-100%);
    transition: transform var(--duration) var(--easing);
    box-shadow: var(--shadow-lg); padding-top: 56px;
  }
  body.saas-mode .pro-sidebar.is-open { transform: translateX(0); }
  body.saas-mode .pro-mobile-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15,22,35,0.4);
    z-index: 190;
    opacity: 0; transition: opacity var(--duration) var(--easing);
  }
  body.saas-mode .pro-mobile-overlay.is-open { display: block; opacity: 1; }
  body.saas-mode .pro-header { padding: 0 var(--s-3); gap: var(--s-2); }
  body.saas-mode .pro-mobile-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 6px;
    background: transparent; border: 0; color: var(--c-text-strong);
    cursor: pointer;
  }
  body.saas-mode .pro-mobile-toggle:hover { background: var(--c-surface-2); }
  body.saas-mode .pro-search { max-width: none; }
  body.saas-mode .pro-search kbd { display: none; }
  body.saas-mode .pro-main { padding: var(--s-4) var(--s-3); }
  body.saas-mode .pro-page-head { flex-direction: column; align-items: flex-start; gap: var(--s-3); }
  body.saas-mode .pro-page-head > div:last-child { width: 100%; }
  body.saas-mode .pro-page-head .pro-btn { flex: 1; justify-content: center; }
  body.saas-mode .pro-page-title { font-size: var(--fs-20); }
  body.saas-mode .pro-three-pane { grid-template-columns: 1fr; }
  body.saas-mode .pro-three-pane > .pro-pane:nth-child(1) { display: block; order: 3; }
  body.saas-mode .pro-three-pane > .pro-pane:nth-child(2) { order: 1; }
  body.saas-mode .pro-three-pane > .pro-pane:nth-child(3) { order: 2; }
  body.saas-mode .pro-chart-area { height: 240px; }
  body.saas-mode .pro-toolbar { padding: var(--s-2); gap: 6px; }
  body.saas-mode .pro-toolbar-spacer { width: 100%; height: 0; }
  body.saas-mode .pro-seg button { padding: 4px 8px; font-size: var(--fs-11); }
  body.saas-mode .pro-table { font-size: var(--fs-12); }
  body.saas-mode .pro-table thead th,
  body.saas-mode .pro-table tbody td { padding: var(--s-2) var(--s-3); }
  body.saas-mode .pro-card > .pro-table {
    display: block; overflow-x: auto; white-space: nowrap;
  }
  body.saas-mode .pro-header-actions select { display: none; }
  body.saas-mode .pro-avatar { width: 28px; height: 28px; font-size: var(--fs-11); }
}
@media (max-width: 480px) {
  body.saas-mode .pro-kpi-grid { grid-template-columns: 1fr; }
  body.saas-mode .pro-kpi-value { font-size: var(--fs-20); }
  body.saas-mode .pro-kpi-spark { width: 60px; height: 22px; }
  body.saas-mode .pro-header-actions .pro-icon-btn:not(:last-child) { display: none; }
}
@media (hover: none) {
  body.saas-mode .pro-kpi:hover { transform: none; box-shadow: none; }
  body.saas-mode .pro-btn-primary:hover { transform: none; }
}

/* =====================================================================
   SaaS モード (= 旧 / 段階移行中)
   ===================================================================== */
body.saas-mode {
  background: linear-gradient(180deg, #fafbff 0%, #f4f6f9 100%);
}
.saas-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0;
}
.saas-header-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; align-items: center; gap: 24px;
  padding: 12px 28px;
}
.saas-brand {
  display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--text);
  font-weight: 700;
}
.saas-brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; border-radius: 8px;
  font-size: 15px; font-weight: 800; letter-spacing: -0.02em;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}
.saas-brand-text { font-size: 15px; letter-spacing: -0.01em; }
.saas-nav {
  display: flex; gap: 4px; flex: 1;
}
.saas-nav-item {
  padding: 6px 14px; border-radius: 8px;
  color: var(--text-2); text-decoration: none;
  font-size: 13px; font-weight: 500;
  transition: all var(--duration-fast) var(--easing);
}
.saas-nav-item:hover { background: var(--bg-2); color: var(--text); }
.saas-nav-item.is-active { background: #eef2ff; color: #4f46e5; font-weight: 600; }
.saas-actions {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px;
}
.saas-action-link { font-size: 11.5px; opacity: 0.7; text-decoration: none; }
.saas-action-link:hover { opacity: 1; }

body.saas-mode .shell-saas { display: block; grid-template-columns: none; }
body.saas-mode .main-saas {
  max-width: 1400px; margin: 0 auto;
  padding: 28px 28px 64px;
}
body.saas-mode .page-head { margin-bottom: 8px; }
body.saas-mode .page-title { font-size: 24px; letter-spacing: -0.01em; }
body.saas-mode .crumb { display: none; } /* SaaS モードでは breadcrumb 不要 */
body.saas-mode .about-rich { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 18px 22px; }

@media (max-width: 720px) {
  .saas-header-inner { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .saas-nav { width: 100%; order: 3; overflow-x: auto; }
  .saas-actions { margin-left: auto; }
  body.saas-mode .main-saas { padding: 18px 14px 48px; }
  body.saas-mode .page-title { font-size: 20px; }
}

/* =====================================================================
   コンテキストヘルプ ツールチップ
   ===================================================================== */
.mdl-help {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--bg-3); color: var(--text-2);
  font-size: 10px; font-weight: 700; line-height: 1;
  margin-left: 4px; cursor: help; vertical-align: middle;
  transition: background var(--duration-fast) var(--easing);
}
.mdl-help:hover, .mdl-help:focus { background: var(--primary); color: #fff; outline: none; }
.mdl-help-tip {
  background: #1e293b; color: #fff;
  padding: 8px 12px; border-radius: 6px;
  font-size: 11.5px; line-height: 1.55;
  max-width: 300px; min-width: 150px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
  pointer-events: none;
  animation: mdlHelpIn 120ms var(--easing);
}
@keyframes mdlHelpIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; max-height: none; border-right: 0; border-bottom: 1px solid var(--border); }
  .main { padding: 24px 14px 48px; }
  /* テーブルを横スクロール可能に (= データ見切れ対策) */
  .card:has(> table.table) { overflow-x: auto; padding: 0; }
  .table { min-width: 560px; font-size: 12px; }
  /* KPI grid を 2 列に */
  .ah-kpi-grid { grid-template-columns: 1fr 1fr !important; }
  /* タブを コンパクトに */
  .ah-tab { padding: 4px 10px; font-size: 11px; }
  /* page-head の文字を縮小 */
  .page-title { font-size: 18px; }
}
@media (max-width: 480px) {
  .ah-kpi-grid { grid-template-columns: 1fr !important; }
  .filter-bar { flex-wrap: wrap; }
}
