/* =====================================================================
 * Mirai Slack AI — 通信可視化コンソール（バニラJS版）
 * デザイントークンは web/src/index.css のライトテーマと同一。
 * ベース色相 245（青灰）＋アクセント 150（緑）。セマンティック色は通信状態を表す。
 * ===================================================================== */

:root {
  --bg: oklch(97.5% 0.006 250);
  --surface: oklch(100% 0 0);
  --surface-2: oklch(96.5% 0.007 250);
  --surface-3: oklch(93.5% 0.009 250);
  --fg: oklch(24% 0.02 245);
  --muted: oklch(46% 0.02 245);
  --faint: oklch(55% 0.02 245);
  --border: oklch(90% 0.009 245);
  --border-strong: oklch(82% 0.012 245);

  --accent: oklch(42% 0.12 150);
  --accent-dim: oklch(92% 0.05 150);

  --blue: oklch(50% 0.15 255);
  --blue-dim: oklch(60% 0.12 255);
  --green: oklch(46% 0.12 155);
  --green-dim: oklch(91% 0.05 155);
  --red: oklch(50% 0.19 25);
  --red-dim: oklch(92% 0.05 25);
  --amber: oklch(48% 0.13 70);
  --amber-dim: oklch(93% 0.06 75);
  --violet: oklch(50% 0.15 295);
  --violet-dim: oklch(92% 0.06 295);

  --font-body: 'Inter', 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', 'Yu Gothic UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
/* hidden 属性は display 指定より常に優先する（display 系クラスとの併用対策） */
[hidden] { display: none !important; }
html, body, #app { height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select { font-family: inherit; }
.mono { font-family: var(--font-mono); }
.tnum { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }
.faint { color: var(--faint); }
.muted { color: var(--muted); }
.is-red { color: var(--red) !important; }
.is-amber { color: var(--amber) !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

@keyframes od-spin { to { transform: rotate(360deg); } }
.is-spinning { animation: od-spin 2s linear infinite; }
@keyframes od-pulse-soft { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.od-node-running { animation: od-pulse-soft 1.6s ease-in-out infinite; }

/* =====================================================================
 * ボタン / バッジ / 入力
 * ===================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-secondary { background: var(--surface-2); border-color: var(--border-strong); color: var(--fg); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover:not(:disabled) { color: var(--fg); background: var(--surface-2); }
.btn-danger { background: var(--red-dim); border-color: oklch(80% 0.09 25); color: var(--red); }
.btn-danger:hover:not(:disabled) { filter: brightness(0.97); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 11px; }
.btn-icon { width: 30px; padding: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 18px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-success { background: var(--green-dim); color: var(--green); }
.badge-warn { background: var(--amber-dim); color: var(--amber); }
.badge-error { background: var(--red-dim); color: var(--red); }
.badge-neutral { background: var(--surface-3); color: var(--muted); }
.badge-info { background: oklch(93% 0.05 255); color: var(--blue); }
.badge-accent { background: var(--accent-dim); color: var(--accent); }

input.input, select {
  height: 30px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--fg);
  font-size: 12.5px;
  padding: 0 10px;
  outline: none;
}
input.input:focus, select:focus { border-color: var(--accent); }
select { padding: 0 8px; }

/* =====================================================================
 * ログイン画面
 * ===================================================================== */

.login-screen { height: 100%; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card {
  width: 560px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 32px;
  box-shadow: 0 24px 64px rgba(15, 30, 60, 0.14);
}
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand .brand-mark {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent-dim); color: var(--accent);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.login-brand h1 { font-size: 18px; font-weight: 600; letter-spacing: 0.01em; }
.login-brand p { font-size: 12px; color: var(--muted); }
.login-roles { margin-top: 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.role-card {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 14px;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.role-card:hover { border-color: color-mix(in oklch, var(--accent) 50%, transparent); background: var(--surface-3); }
.role-title { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 13px; font-weight: 600; letter-spacing: 0.02em; }
.role-icon { color: var(--accent); display: inline-flex; }
.role-card p { margin-top: 6px; font-size: 11.5px; line-height: 1.5; color: var(--muted); }
.login-note { margin-top: 20px; font-size: 11px; line-height: 1.6; color: var(--faint); }
.login-footer { margin-top: 16px; display: flex; justify-content: flex-end; }

/* =====================================================================
 * コンソールシェル
 * ===================================================================== */

.console { display: flex; flex-direction: column; height: 100%; }
.app-header {
  height: 52px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 0 12px;
}
.hdr-brand { display: flex; align-items: center; gap: 8px; }
.hdr-brand .brand-mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--accent-dim); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-size: 13px; font-weight: 600; letter-spacing: 0.01em; line-height: 1.25; }
.brand-sub { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); line-height: 1.25; }

.hdr-tabs { display: flex; gap: 2px; margin-left: 16px; }
.tab-btn {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}
.tab-btn:hover { background: var(--surface-2); color: var(--fg); }
.tab-btn.is-active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.tab-btn.is-disabled { opacity: 0.4; cursor: not-allowed; }
.tab-btn.is-disabled:hover { background: none; color: var(--muted); }

.hdr-sep { width: 1px; height: 20px; background: var(--border); margin: 0 8px; }
.hdr-clock { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
#hdr-clock { color: var(--fg); }

.hdr-pill {
  display: flex; align-items: center; gap: 6px;
  border-radius: 6px; border: 1px solid;
  padding: 4px 8px; font-size: 11px; white-space: nowrap;
}
.hdr-pill.is-ok { border-color: oklch(80% 0.09 155); background: oklch(93% 0.05 155); color: var(--green); }
.hdr-pill.is-bad { border-color: oklch(80% 0.09 25); background: oklch(93% 0.05 25); color: var(--red); }

.hdr-kpis { display: flex; align-items: center; gap: 8px; }
.kpi {
  display: flex; align-items: baseline; gap: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  padding: 4px 8px;
  white-space: nowrap;
}
.kpi-label { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.kpi-value { font-size: 13px; font-weight: 600; color: var(--fg); }
.kpi-suffix { font-size: 10px; color: var(--faint); }

.hdr-spacer { flex: 1; }
.hdr-autorefresh {
  display: flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  border-radius: 6px; border: 1px solid;
  font-size: 11.5px;
  transition: background 0.15s ease, color 0.15s ease;
}
.hdr-autorefresh.is-on { border-color: oklch(80% 0.09 155); background: oklch(93% 0.05 155); color: var(--green); }
.hdr-autorefresh:not(.is-on) { border-color: var(--border-strong); background: var(--surface-2); color: var(--muted); }
.hdr-autorefresh:not(.is-on):hover { color: var(--fg); }
.hdr-role { height: 28px; width: 180px; font-size: 11.5px; }
.hdr-deco { color: var(--faint); display: inline-flex; }

.main-row { display: flex; flex: 1; min-height: 0; }

/* =====================================================================
 * フィルタサイドバー
 * ===================================================================== */

.filter-sidebar {
  width: 228px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 12px;
}
.sb-label { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.sb-field { display: flex; flex-direction: column; gap: 4px; font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.sb-field select { width: 100%; height: 30px; margin-top: 2px; }
.sb-hint { font-size: 10.5px; line-height: 1.5; color: var(--faint); }

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 2px;
}
.mode-tab {
  height: 26px;
  border-radius: 5px;
  font-size: 11px;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}
.mode-tab:hover { color: var(--fg); }
.mode-tab.is-active { background: var(--surface); color: var(--fg); font-weight: 600; box-shadow: 0 1px 2px rgba(15, 30, 60, 0.08); }

.sb-trace-row { display: flex; gap: 6px; margin-top: 6px; }
.sb-trace-row .input { flex: 1; min-width: 0; height: 30px; font-size: 11px; }
.sb-trace-chip {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 4px;
  border: 1px solid color-mix(in oklch, var(--accent) 40%, transparent);
  border-radius: 6px;
  background: color-mix(in oklch, var(--accent-dim) 20%, transparent);
  padding: 6px 8px;
}
.sb-trace-chip .mono { font-size: 10.5px; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-trace-chip button { font-size: 10.5px; color: var(--muted); }
.sb-trace-chip button:hover { color: var(--fg); }

.sb-legend { margin-top: auto; border-top: 1px solid var(--border); padding-top: 10px; font-size: 10.5px; color: var(--faint); }
.sb-legend .sb-label { margin-bottom: 8px; }
.legend-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.legend-row svg { flex-shrink: 0; }
.legend-row span { color: var(--faint); }

/* =====================================================================
 * メインキャンバス / マップ
 * ===================================================================== */

.main-canvas { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.map-container {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background-image: radial-gradient(circle, var(--border) 1px, transparent 1px);
  background-size: 22px 22px;
  cursor: grab;
}
.map-container:active { cursor: grabbing; }
.map-world { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }
.map-edges { position: absolute; top: 0; left: 0; overflow: visible; }
.map-node-layer { position: absolute; inset: 0; }

.map-node {
  position: absolute;
  width: 176px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px 10px;
  box-shadow: 0 1px 3px rgba(15, 30, 60, 0.08), 0 4px 12px rgba(15, 30, 60, 0.06);
  cursor: grab;
  transition: opacity 0.15s ease;
  z-index: 5;
}
.map-node:active { cursor: grabbing; }
.map-node.is-selected { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 35%, transparent); }
.map-node.has-error { border-color: var(--red); }
.map-node.is-dimmed { opacity: 0.35; }

.node-heat { position: absolute; inset: 0; border-radius: 8px; pointer-events: none; }
.node-body { position: relative; display: flex; align-items: flex-start; gap: 8px; }
.node-icon {
  margin-top: 2px;
  width: 24px; height: 24px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; border: 1px solid;
}
.node-icon-provider { border-color: oklch(80% 0.09 295); background: oklch(92% 0.06 295); color: var(--violet); }
.node-icon-data { border-color: oklch(80% 0.09 250); background: oklch(92% 0.05 250); color: var(--blue); }
.node-icon-external, .node-icon-endpoint, .node-icon-service, .node-icon-step, .node-icon-router {
  border-color: oklch(78% 0.09 150); background: oklch(92% 0.05 150); color: var(--accent);
}
.node-text { min-width: 0; flex: 1; }
.node-label { font-size: 11.5px; font-weight: 600; line-height: 1.3; letter-spacing: 0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-icon-provider ~ .node-text .node-label { color: var(--violet); }
.node-metrics { display: flex; align-items: baseline; gap: 4px; margin-top: 2px; font-size: 10px; color: var(--faint); }
.node-metrics > span:first-child { font-weight: 600; color: var(--muted); }
.node-ok { color: var(--green); }
.node-running-dot { position: absolute; top: -2px; right: -2px; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.node-error {
  position: relative;
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 6px;
  border-radius: 4px;
  background: oklch(93% 0.05 25);
  padding: 2px 6px;
}
.node-error span { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 600; color: var(--red); }
.node-error b { font-size: 10.5px; font-weight: 600; color: var(--red); }

.edge-path { fill: none; transition: stroke 0.15s ease-out; }
.edge-hit { cursor: pointer; }
.edge-count { fill: var(--muted); font-size: 9px; font-family: var(--font-mono); }
.edge-selected { stroke: var(--accent) !important; stroke-width: 3px !important; }

@keyframes od-flow-dash { to { stroke-dashoffset: -24; } }
.edge-live { stroke-dasharray: 6 10; animation: od-flow-dash 0.9s linear infinite; }
.edge-warn { stroke-dasharray: 2 6; }

/* 矢印の流れアニメーション:
 * トラフィックのある経路に「源→先」へ粒が流れる（stroke-dashoffset を進めると
 * パス終端＝矢印方向へ移動する）。ライブ中の経路は is-fast で高速になる。 */
@keyframes od-flow-dots { to { stroke-dashoffset: -30; } }
.edge-flow {
  stroke-dasharray: 2.5 12.5;
  stroke-linecap: round;
  animation: od-flow-dots 1.3s linear infinite;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.edge-flow.is-fast { animation-duration: 0.5s; }

/* アニメーションを控える設定のユーザー向け（WCAG 2.3.3） */
@media (prefers-reduced-motion: reduce) {
  .edge-flow { animation: none; opacity: 0.5; }
  .edge-live { animation: none; }
}

.map-controls {
  position: absolute; top: 10px; left: 10px; z-index: 30;
  display: flex; flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
}
.map-control {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  color: var(--fg);
  border-bottom: 1px solid var(--border);
}
.map-control:last-child { border-bottom: none; }
.map-control:hover { background: var(--surface-3); }

.map-minimap {
  position: absolute; right: 10px; bottom: 10px; z-index: 30;
  width: 190px; height: 110px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.mm-node { stroke: none; }
.map-mm-viewport { fill: rgba(238, 243, 250, 0.78); stroke: var(--accent); stroke-width: 2; }

.map-loading {
  position: absolute; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in oklch, var(--bg) 70%, transparent);
  backdrop-filter: blur(1px);
}
.loading-pill {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--muted);
}
.spinner {
  width: 14px; height: 14px; flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: od-spin 1s linear infinite;
}
.map-error {
  position: absolute; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; color: var(--red);
}

/* ------------------------------ エッジツールチップ ------------------------------ */

.edge-tooltip {
  position: fixed;
  z-index: 50;
  width: 290px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  box-shadow: 0 14px 40px rgba(15, 30, 60, 0.16);
  pointer-events: none;
  font-size: 11px;
}
.tt-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tt-id { font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-grid { display: grid; grid-template-columns: 72px 1fr; gap: 4px 8px; margin-top: 8px; }
.tt-grid dt { color: var(--faint); }
.tt-grid dd { color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-grid dd.tt-mono { font-family: var(--font-mono); }
.tt-empty { margin-top: 8px; color: var(--faint); }
.tt-live { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 6px; color: var(--amber); font-size: 10.5px; }

/* =====================================================================
 * ライブチッカー
 * ===================================================================== */

.live-ticker {
  height: 104px;
  flex-shrink: 0;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 6px 8px;
}
.ticker-title { display: flex; align-items: center; gap: 8px; padding: 0 4px 4px; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.ticker-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); animation: od-pulse-soft 1.2s ease-in-out infinite; }
.ticker-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.ticker-row { cursor: pointer; border-top: 1px solid color-mix(in oklch, var(--border) 50%, transparent); }
.ticker-row:hover { background: var(--surface-2); }
.ticker-row td { padding: 2px 4px; }
.ticker-time { width: 86px; padding-left: 4px; font-family: var(--font-mono); color: var(--faint); }
.ticker-trace { width: 220px; }
.ticker-trace .mono { font-size: 10.5px; color: var(--muted); }
.ticker-src { color: var(--muted); }
.ticker-arrow { margin: 0 4px; color: var(--faint); }
.ticker-tgt { color: var(--fg); }
.ticker-op { margin-left: 8px; color: var(--faint); }
.ticker-lat { width: 80px; text-align: right; font-family: var(--font-mono); color: var(--faint); }
.status-dot { display: inline-flex; align-items: center; gap: 6px; color: var(--faint); }
.status-dot i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }

/* =====================================================================
 * 詳細パネル
 * ===================================================================== */

.detail-panel {
  width: 330px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  background: var(--surface);
}
.dp-header {
  height: 36px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
}
.dp-header > span { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.icon-btn {
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px;
  color: var(--faint);
}
.icon-btn:hover { color: var(--fg); background: var(--surface-2); }
.dp-footer {
  margin-top: auto;
  display: flex; align-items: center; gap: 8px;
  border-top: 1px solid var(--border);
  padding: 8px;
}
.dp-panel-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
}
.dp-panel-title { min-width: 0; }
.dp-panel-title h3 { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-panel-title p { font-size: 10.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-body { display: flex; flex-direction: column; gap: 12px; padding: 12px; }
.dp-desc { font-size: 11.5px; line-height: 1.6; color: var(--muted); }
.dp-hint { font-size: 12px; line-height: 1.6; color: var(--faint); }

.stat-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--border);
}
.stat-grid > div { background: var(--surface-2); padding: 8px 10px; }
.stat-grid dt { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.stat-grid dd { margin-top: 2px; font-size: 12.5px; color: var(--fg); }

.dp-section h4 { margin-bottom: 6px; font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); font-weight: 500; }
.dp-err-row {
  display: flex; align-items: center; justify-content: space-between;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
  padding: 4px 8px;
  margin-bottom: 4px;
}
.dp-err-row span { font-size: 10.5px; }
.dp-livebox {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  padding: 10px;
}
.dp-livebox-title { font-size: 11px; color: var(--fg); }
.dp-live-row {
  display: block; width: 100%;
  margin-top: 4px;
  text-align: left;
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dp-live-row:hover { color: var(--fg); }
.dp-livebox-empty { margin-top: 4px; font-size: 11px; color: var(--faint); }

.dp-ev-row {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  padding: 6px 8px;
  margin-bottom: 4px;
  text-align: left;
}
.dp-ev-row:hover { background: var(--surface-3); }
.dp-ev-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dp-ev-head .mono { font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-ev-meta { margin-top: 2px; font-size: 9.5px; color: var(--faint); }

.dp-trace-box {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  padding: 10px;
  font-size: 10.5px;
}
.dp-info-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 1px 0; }
.dp-info-row > span:first-child { color: var(--faint); }
.dp-info-row > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dp-badges { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dp-errbox {
  border: 1px solid oklch(80% 0.09 25);
  border-radius: 6px;
  background: oklch(93% 0.05 25);
  padding: 8px 10px;
}
.dp-errbox .mono { font-size: 11px; }
.dp-span-row {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  padding: 6px 8px;
  margin-bottom: 4px;
  text-align: left;
}
.dp-span-row:hover { background: var(--surface-3); }
.dp-span-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dp-span-head .mono { font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-span-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; font-size: 9.5px; color: var(--faint); }
.dp-span-err { margin-top: 4px; font-size: 10px; color: var(--red); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-footnote { font-size: 10px; color: var(--faint); }
.dp-empty { font-size: 11px; color: var(--faint); }
.dp-error-text { font-size: 12px; }

.detail-open-btn {
  position: absolute; right: 12px; top: 64px; z-index: 20;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface-2);
  padding: 4px 8px;
  font-size: 11px;
  color: var(--muted);
}
.detail-open-btn:hover { color: var(--fg); }

/* =====================================================================
 * Trace Explorer / Audit Log（テーブル系）
 * ===================================================================== */

.view-toolbar {
  flex-shrink: 0;
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 8px 12px;
}
.flabel { display: flex; align-items: center; gap: 6px; }
.flabel { font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.fselect { height: 28px; font-size: 11.5px; }
.search-box { position: relative; }
.search-box .search-icon { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; display: inline-flex; }
.search-box .input { width: 220px; padding-left: 28px; height: 28px; font-size: 11.5px; }
.spacer { flex: 1; }
.view-total { font-size: 11px; color: var(--faint); }

.view-table-wrap { flex: 1; min-height: 0; overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2);
  font-size: 10.5px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--faint);
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td { padding: 5px 10px; border-bottom: 1px solid color-mix(in oklch, var(--border) 60%, transparent); }
.data-table tbody tr:hover { background: color-mix(in oklch, var(--surface-2) 60%, transparent); }
.data-table .right { text-align: right; }
.data-table th.right { text-align: right; }
.trace-row { cursor: pointer; }
.trace-row.is-selected { background: color-mix(in oklch, var(--accent-dim) 55%, transparent); }
.trace-row.is-selected:hover { background: color-mix(in oklch, var(--accent-dim) 55%, transparent); }
.table-empty { padding: 24px; text-align: center; color: var(--faint); }
.trace-id-cell { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.truncate-cell { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.view-pager {
  height: 40px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 0 12px;
}
.view-pager .mono { font-size: 11px; color: var(--faint); }

/* =====================================================================
 * trace 詳細ドロワー
 * ===================================================================== */

.trace-drawer {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 30;
  width: 520px;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  background: var(--surface);
  box-shadow: -16px 0 48px rgba(15, 30, 60, 0.12);
}
.drawer-head {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 10px 16px;
}
.drawer-head-info { min-width: 0; }
.drawer-title { display: flex; align-items: center; gap: 8px; }
.drawer-traceid { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-sub { margin-top: 2px; font-size: 10.5px; color: var(--faint); }
.drawer-head-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.drawer-body { padding: 16px; }
.drawer-section-title { margin-bottom: 8px; font-size: 10.5px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.drawer-span {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  padding: 8px;
  margin-bottom: 6px;
}
.drawer-span-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.drawer-span-head .mono { font-size: 11px; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-span-bar { height: 6px; margin-top: 4px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.drawer-span-fill { height: 100%; border-radius: 999px; }
.drawer-span-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-size: 9.5px; color: var(--faint); }
.drawer-span-err {
  margin-top: 4px;
  border: 1px solid oklch(80% 0.09 25);
  border-radius: 4px;
  background: oklch(93% 0.05 25);
  padding: 4px 6px;
  font-size: 10px;
  color: var(--red);
}
.drawer-footnote { margin-top: 12px; font-size: 10px; line-height: 1.6; color: var(--faint); }
