﻿/* ============================================================
   SAP B1 鎶ヨ〃鏌ヨ Agent 鈥?浼佷笟 BI 椋庢牸
   Design Language: SAP Fiori + Linear + Carbon Design
   Version: 3.0 Enterprise
   ============================================================ */

/* ----------------------------------------------------------
   Design Tokens
   ---------------------------------------------------------- */
:root {
  /* SAP Brand Colors */
  --brand-primary: #0070f3;        /* SAP Blue */
  --brand-primary-hover: #0061d5;
  --brand-primary-active: #0052b4;
  --brand-primary-soft: rgba(0, 112, 243, 0.08);
  --brand-primary-border: rgba(0, 112, 243, 0.3);

  /* Semantic Colors */
  --color-success: #10b981;
  --color-success-soft: rgba(16, 185, 129, 0.1);
  --color-warning: #f59e0b;
  --color-warning-soft: rgba(245, 158, 11, 0.1);
  --color-danger: #ef4444;
  --color-danger-soft: rgba(239, 68, 68, 0.1);
  --color-info: #60a5fa;
  --color-info-soft: rgba(96, 165, 250, 0.1);

  /* Surface (Light Theme — SAP Fiori) */
  --bg-base: #f5f7fa;
  --bg-surface: #ffffff;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f3f4f6;
  --bg-active: #e5e7eb;
  --bg-input: #ffffff;
  --bg-tooltip: #1f2937;

  /* Borders */
  --border-subtle: #f3f4f6;
  --border-default: #e5e7eb;
  --border-strong: #d1d5db;
  --border-focus: var(--brand-primary);

  /* Text */
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-tertiary: #6b7280;
  --text-disabled: #9ca3af;
  --text-inverse: #ffffff;

  /* Chart Colors */
  --chart-1: #0070f3;
  --chart-2: #10b981;
  --chart-3: #f59e0b;
  --chart-4: #8b5cf6;
  --chart-5: #ec4899;
  --chart-6: #06b6d4;

  /* Typography */
  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont,
               'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei',
               'Source Han Sans SC', sans-serif;
  --font-mono: 'IBM Plex Mono', 'JetBrains Mono', 'SF Mono',
               Menlo, Consolas, monospace;
  --font-display: 'IBM Plex Sans', sans-serif;

  /* Type Scale (1.250 Major Third) */
  --text-xs: 11px;
  --text-sm: 12px;
  --text-base: 13px;
  --text-md: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 32px;
  --text-4xl: 42px;
  --text-display: 56px;

  /* Spacing (4px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Radius 鈥?SAP uses subtle 4-8px */
  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --radius-xl: 8px;
  --radius-pill: 999px;

  /* Shadows 鈥?Minimal, functional */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  --shadow-focus: 0 0 0 2px rgba(0, 112, 243, 0.4);

  /* Animation */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 120ms;
  --duration-base: 200ms;
  --duration-slow: 320ms;

  /* Layout */
  --header-height: 48px;
  --status-bar-height: 28px;
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 56px;
  --inspector-width: 360px;
  --content-max-width: 920px;
}

/* ----------------------------------------------------------
   Reset & Base
   ---------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-base);
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

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

code, kbd, pre, samp {
  font-family: var(--font-mono);
}

/* Tabular numerals for data */
.tabular-nums, .num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

/* ----------------------------------------------------------
   Scrollbar (Minimal)
   ---------------------------------------------------------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ----------------------------------------------------------
   App Shell: Header / Sidebar / Main / Status
   ---------------------------------------------------------- */
.app {
  display: grid;
  grid-template-rows: var(--header-height) 1fr var(--status-bar-height);
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-areas:
    "header header"
    "sidebar main"
    "status status";
  height: 100vh;
  background: var(--bg-base);
}

.app[data-sidebar="collapsed"] {
  grid-template-columns: var(--sidebar-collapsed-width) 1fr;
}

/* ----------------------------------------------------------
   Header 鈥?SAP-style minimal bar
   ---------------------------------------------------------- */
.header {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-4);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  height: var(--header-height);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-right: var(--space-4);
  border-right: 1px solid var(--border-subtle);
  height: 100%;
}

.brand-mark {
  width: 24px;
  height: 24px;
  background: var(--brand-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 13px;
  font-family: var(--font-mono);
}

.brand-name {
  font-size: var(--text-md);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.brand-sub {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-left: var(--space-1);
  font-family: var(--font-mono);
}

.header-search {
  flex: 1;
  max-width: 480px;
  position: relative;
  margin-left: var(--space-2);
}

.header-search-input {
  width: 100%;
  height: 32px;
  padding: 0 var(--space-3) 0 32px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-base);
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.header-search-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

.header-search-input::placeholder {
  color: var(--text-tertiary);
}

.header-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}

.header-search-kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 2px;
  pointer-events: none;
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tertiary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-left: auto;
}

.header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 32px;
  padding: 0 var(--space-3);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-base);
  transition: all var(--duration-fast) var(--ease-out);
}

.header-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.header-btn-icon {
  width: 32px;
  padding: 0;
}

.model-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 28px;
  padding: 0 var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.model-badge:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.model-badge-dot {
  width: 6px;
  height: 6px;
  background: var(--color-success);
  border-radius: 50%;
}

.model-badge-dot.disconnected {
  background: var(--text-tertiary);
}

/* ----------------------------------------------------------
   Sidebar 鈥?Report Navigation
   ---------------------------------------------------------- */
.sidebar {
  grid-area: sidebar;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--duration-base) var(--ease-out);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  height: 44px;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}

.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: var(--text-tertiary);
  border-radius: var(--radius-sm);
}

.sidebar-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) 0;
}

.nav-section {
  margin-bottom: var(--space-4);
}

.nav-section-title {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: 32px;
  padding: 0 var(--space-4);
  color: var(--text-secondary);
  font-size: var(--text-base);
  cursor: pointer;
  position: relative;
  user-select: none;
  transition: background var(--duration-fast) var(--ease-out);
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--brand-primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.nav-item-icon {
  flex-shrink: 0;
  color: var(--text-tertiary);
}

.nav-item.active .nav-item-icon {
  color: var(--brand-primary);
}

.nav-item-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item-badge {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  background: var(--bg-elevated);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}

.nav-item-badge.active {
  color: var(--brand-primary);
  background: var(--brand-primary-soft);
}

.sidebar-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.sidebar-footer-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.sidebar-footer-row:last-child {
  margin-bottom: 0;
}

/* Sidebar collapsed state */
.app[data-sidebar="collapsed"] .sidebar {
  width: var(--sidebar-collapsed-width);
}

.app[data-sidebar="collapsed"] .nav-item-text,
.app[data-sidebar="collapsed"] .nav-item-badge,
.app[data-sidebar="collapsed"] .nav-section-title,
.app[data-sidebar="collapsed"] .sidebar-title,
.app[data-sidebar="collapsed"] .sidebar-footer {
  display: none;
}

.app[data-sidebar="collapsed"] .nav-item {
  justify-content: center;
  padding: 0;
}

/* ----------------------------------------------------------
   Main Content Area
   ---------------------------------------------------------- */
.main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-base);
}

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  min-height: 48px;
}

.main-header-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-md);
  font-weight: 600;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

.breadcrumb-item {
  color: var(--text-secondary);
}

.breadcrumb-item.active {
  color: var(--text-primary);
}

.breadcrumb-sep {
  color: var(--text-tertiary);
}

.main-header-actions {
  display: flex;
  gap: var(--space-2);
}

.main-content {
  flex: 1;
  min-height: 0;            /* grid 子项防内容撑爆 */
  overflow-y: auto;
  padding: var(--space-6);
  padding-bottom: 160px;    /* 留出 composer + 呼吸空间 */
}

/* ----------------------------------------------------------
   数据源 banner
   ---------------------------------------------------------- */
.data-source-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px var(--space-6);
  font-size: 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  color: var(--text-secondary);
}
.data-source-banner[hidden] { display: none; }
.data-source-banner.demo {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.10), rgba(245, 158, 11, 0.02));
  color: var(--color-warning, #d97706);
}
.data-source-banner.live {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.08), rgba(16, 185, 129, 0.02));
  color: var(--color-success, #059669);
}
.data-source-banner.offline {
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.08), rgba(239, 68, 68, 0.02));
  color: var(--color-danger, #dc2626);
}
.dsb-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.dsb-label { font-weight: 500; color: var(--text-primary); }
.dsb-details { font-family: var(--font-mono); font-size: 11px; opacity: 0.85; }
.dsb-time { margin-left: auto; font-size: 11px; opacity: 0.7; }

/* ----------------------------------------------------------
   Composer 工具下拉（template / view picker）
   ---------------------------------------------------------- */
.tool-picker {
  width: 320px;
  max-width: calc(100vw - 24px);
  max-height: 360px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: tool-picker-fade 120ms ease-out;
}
@keyframes tool-picker-fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.tool-picker-list {
  max-height: 360px;
  overflow-y: auto;
  padding: 4px;
}
.tool-picker-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  text-align: left;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}
.tool-picker-item:hover {
  background: var(--bg-surface);
}
.tool-picker-title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tool-picker-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----------------------------------------------------------
   Welcome / Empty State
   ---------------------------------------------------------- */
.welcome {
  max-width: var(--content-max-width);
  margin: 0 auto;
}

.welcome-hero {
  margin-bottom: var(--space-8);
}

.welcome-eyebrow {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand-primary);
  margin-bottom: var(--space-3);
  padding: 4px var(--space-3);
  background: var(--brand-primary-soft);
  border-radius: var(--radius-sm);
}

.welcome-title {
  font-size: var(--text-3xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: var(--space-3);
  line-height: 1.2;
}

.welcome-subtitle {
  font-size: var(--text-md);
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 640px;
}

/* Metric Cards 鈥?SAP Fiori KPI Tile Style */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  transition: all var(--duration-fast) var(--ease-out);
}

.metric-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}

.metric-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  margin-bottom: var(--space-3);
}

.metric-label-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
}

.metric-card.primary .metric-label-dot { background: var(--brand-primary); }
.metric-card.success .metric-label-dot { background: var(--color-success); }
.metric-card.warning .metric-label-dot { background: var(--color-warning); }
.metric-card.danger .metric-label-dot { background: var(--color-danger); }

.metric-value {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  margin-bottom: var(--space-2);
  line-height: 1.1;
}

.metric-unit {
  font-size: var(--text-md);
  font-weight: 400;
  color: var(--text-tertiary);
}

.metric-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
}

.metric-trend.up { color: var(--color-success); }
.metric-trend.down { color: var(--color-danger); }
.metric-trend.neutral { color: var(--text-tertiary); }

/* Quick Reports Section */
.quick-section {
  margin-bottom: var(--space-8);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.section-title-text {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text-primary);
}

.section-title-meta {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-3);
}

.report-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-align: left;
  transition: all var(--duration-fast) var(--ease-out);
  position: relative;
}

.report-card:hover {
  border-color: var(--brand-primary-border);
  background: var(--bg-elevated);
  transform: translateY(-1px);
}

.report-card-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  border-radius: var(--radius-md);
}

.report-card.success .report-card-icon {
  background: var(--color-success-soft);
  color: var(--color-success);
}

.report-card.warning .report-card-icon {
  background: var(--color-warning-soft);
  color: var(--color-warning);
}

.report-card.danger .report-card-icon {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.report-card-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.report-card-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

.report-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.report-card-tag {
  font-family: var(--font-mono);
  padding: 2px 6px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}

/* ----------------------------------------------------------
   Chat / Conversation
   ---------------------------------------------------------- */
.conversation {
  max-width: var(--content-max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding-bottom: 120px;
}

.message {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}

.message-avatar {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 600;
  font-family: var(--font-mono);
}

.message.user .message-avatar {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

.message.assistant .message-avatar {
  background: var(--brand-primary);
  color: white;
}

.message-body {
  flex: 1;
  min-width: 0;
}

.message-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.message-author {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.message-time {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.message-content {
  font-size: var(--text-base);
  line-height: 1.65;
  color: var(--text-primary);
  word-break: break-word;
}

.message-content p { margin-bottom: var(--space-3); }
.message-content p:last-child { margin-bottom: 0; }

.message-content strong {
  font-weight: 600;
  color: var(--text-primary);
}

.message-content code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  color: var(--brand-primary);
}

.message-content pre {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  overflow-x: auto;
  margin: var(--space-3) 0;
}

.message-content pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: 13px;
  line-height: 1.55;
  display: block;
  white-space: pre;
  overflow-x: auto;
}

/* ----------------------------------------------------------
   Markdown 表格（GFM）—— 必须带线
   ---------------------------------------------------------- */
.md-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  margin: var(--space-3) 0;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}
.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.5;
}
.md-table thead {
  background: var(--bg-surface);
}
.md-table th,
.md-table td {
  padding: 8px 12px;
  border: 1px solid var(--border-default);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}
.md-table th {
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-surface);
  position: sticky;
  top: 0;
}
.md-table tbody tr:nth-child(even) td {
  background: rgba(127, 127, 127, 0.04);
}
.md-table tbody tr:hover td {
  background: rgba(127, 127, 127, 0.08);
}
.md-table code {
  font-size: 12px;
}
  padding: 0;
  color: var(--text-primary);
  font-size: var(--text-sm);
}

/* Tool Call Item */
.tool-call {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  margin: var(--space-3) 0;
  overflow: hidden;
}

.tool-call-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  user-select: none;
}

.tool-call-header:hover {
  background: var(--bg-hover);
}

.tool-call-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
}

.tool-call-name {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-weight: 500;
}

.tool-call-status {
  margin-left: auto;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  padding: 2px 6px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}

.tool-call-status.running { color: var(--color-info); }
.tool-call-status.success { color: var(--color-success); }
.tool-call-status.error { color: var(--color-danger); }

.tool-call-body {
  border-top: 1px solid var(--border-subtle);
  padding: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  display: none;
}

.tool-call.expanded .tool-call-body {
  display: block;
}

/* Data Table 鈥?SAP Fiori List Report style */
.data-table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: var(--space-3) 0;
}

.data-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-elevated);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.data-table thead th {
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-default);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  position: sticky;
  top: 0;
  white-space: nowrap;
}

.data-table tbody td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.data-table tbody tr:hover {
  background: var(--bg-hover);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table .num,
.data-table td.num {
  text-align: right;
  font-family: var(--font-mono);
}

.data-table .empty {
  text-align: center;
  padding: var(--space-8);
  color: var(--text-tertiary);
  font-size: var(--text-sm);
}

/* Action Bar under assistant message */
.action-bar {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-top: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-subtle);
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 var(--space-2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  transition: all var(--duration-fast) var(--ease-out);
}

.action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-default);
}

/* ---- chat action-bar 内的导出下拉菜单 ---- */
.action-export-wrap {
  position: relative;
  display: inline-flex;
}

.action-export-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 200;
  min-width: 180px;
  background: #ffffff;
  border: 1px solid var(--border-default, #e5e7eb);
  border-radius: 8px;
  box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.12), 0 -2px 4px rgba(15, 23, 42, 0.06);
  padding: 4px;
  display: none;
  flex-direction: column;
  gap: 2px;
}
.action-export-menu.open { display: flex; }

.action-export-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: none;
  background: transparent;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary, #1f2937);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease;
}
.action-export-item:hover {
  background: #f3f4f6;
}
.action-export-item:focus {
  outline: 2px solid var(--brand-primary, #3b82f6);
  outline-offset: -2px;
}
.action-btn[aria-expanded="true"] {
  background: #eff6ff;
  color: var(--brand-primary, #3b82f6);
  border-color: var(--brand-primary, #3b82f6);
}
.action-btn:disabled,
.action-btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Streaming Cursor */
.streaming-cursor-span {
  display: inline-block;
  width: 7px;
  height: 14px;
  background: var(--brand-primary);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: blink 1.1s steps(1) infinite;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* ----------------------------------------------------------
   Composer 鈥?Query Input (SAP Fiori style)
   ---------------------------------------------------------- */
.composer-wrapper {
  position: fixed;
  bottom: var(--status-bar-height);
  left: var(--sidebar-width);
  right: 0;
  padding: var(--space-4) var(--space-6);
  background: linear-gradient(to top, var(--bg-base) 70%, transparent);
  pointer-events: none;
  transition: left var(--duration-base) var(--ease-out);
}

.app[data-sidebar="collapsed"] .composer-wrapper {
  left: var(--sidebar-collapsed-width);
}

.composer {
  max-width: var(--content-max-width);
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  pointer-events: auto;
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.composer:focus-within {
  border-color: var(--brand-primary-border);
  box-shadow: var(--shadow-focus);
}

.composer-textarea {
  width: 100%;
  min-height: 56px;
  max-height: 240px;
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: var(--text-md);
  line-height: 1.5;
  resize: none;
  outline: none;
}

.composer-textarea::placeholder {
  color: var(--text-tertiary);
}

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.composer-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 var(--space-2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  transition: all var(--duration-fast) var(--ease-out);
}

.composer-tool-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.composer-tool-btn.active {
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
}

.composer-send {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 28px;
  padding: 0 var(--space-3);
  background: var(--brand-primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--duration-fast) var(--ease-out);
}

.composer-send:hover {
  background: var(--brand-primary-hover);
}

.composer-send:disabled {
  background: var(--bg-hover);
  color: var(--text-disabled);
  cursor: not-allowed;
}

.composer-send svg {
  width: 14px;
  height: 14px;
}

/* ----------------------------------------------------------
   Status Bar 鈥?Bottom Strip (SAP style)
   ---------------------------------------------------------- */
.status-bar {
  grid-area: status;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-3);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-default);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  height: var(--status-bar-height);
}

.status-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
}

.status-dot.online { background: var(--color-success); }
.status-dot.offline { background: var(--text-tertiary); }
.status-dot.busy { background: var(--color-warning); }

.status-item code {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
}

.status-spacer {
  flex: 1;
}

/* ----------------------------------------------------------
   Drawer (Settings) 鈥?Right-side slide-in
   ---------------------------------------------------------- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-base) var(--ease-out);
  z-index: 90;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 720px;
  max-width: 90vw;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-default);
  transform: translateX(100%);
  transition: transform var(--duration-base) var(--ease-out);
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border-default);
  height: 56px;
  flex-shrink: 0;
}

.drawer-title {
  font-size: var(--text-md);
  font-weight: 600;
}

.drawer-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.drawer-tabs {
  width: 200px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-default);
  padding: var(--space-3) 0;
  overflow-y: auto;
  flex-shrink: 0;
}

.drawer-tab {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: 36px;
  padding: 0 var(--space-4);
  color: var(--text-secondary);
  font-size: var(--text-base);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  border-left: 2px solid transparent;
}

.drawer-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.drawer-tab.active {
  background: var(--bg-card);
  color: var(--brand-primary);
  border-left-color: var(--brand-primary);
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
}

.drawer-section {
  margin-bottom: var(--space-6);
}

.drawer-section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: var(--space-3);
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-base);
  transition: all var(--duration-fast) var(--ease-out);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

.form-help {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.form-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 32px;
  padding: 0 var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-base);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn-primary {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: white;
}

.btn-primary:hover {
  background: var(--brand-primary-hover);
  border-color: var(--brand-primary-hover);
}

.btn-danger {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: white;
}

.btn-sm {
  height: 26px;
  padding: 0 var(--space-2);
  font-size: var(--text-sm);
}

/* Provider list */
.provider-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.provider-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.provider-card:hover {
  border-color: var(--border-strong);
}

.provider-card.active {
  border-color: var(--brand-primary);
  background: var(--brand-primary-soft);
}

.provider-card-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
}

.provider-card.active .provider-card-icon {
  background: var(--brand-primary);
  color: white;
}

.provider-card-body {
  flex: 1;
}

.provider-card-name {
  font-size: var(--text-base);
  font-weight: 500;
}

.provider-card-meta {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

/* ----------------------------------------------------------
   Command Palette (鈱楰)
   ---------------------------------------------------------- */
.cmdk-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-fast) var(--ease-out);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}

.cmdk-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.cmdk {
  width: 560px;
  max-width: 92vw;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: scale(0.98) translateY(-8px);
  opacity: 0;
  transition: all var(--duration-fast) var(--ease-out);
}

.cmdk-backdrop.open .cmdk {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.cmdk-input {
  width: 100%;
  padding: var(--space-4);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-default);
  color: var(--text-primary);
  font-size: var(--text-md);
  outline: none;
}

.cmdk-input::placeholder {
  color: var(--text-tertiary);
}

.cmdk-list {
  max-height: 400px;
  overflow-y: auto;
  padding: var(--space-2);
}

.cmdk-group-title {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}

.cmdk-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--text-base);
  color: var(--text-primary);
}

.cmdk-item:hover,
.cmdk-item.selected {
  background: var(--bg-hover);
}

.cmdk-item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--text-tertiary);
}

.cmdk-item-text {
  flex: 1;
}

.cmdk-item-hint {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.cmdk-empty {
  padding: var(--space-6);
  text-align: center;
  color: var(--text-tertiary);
  font-size: var(--text-sm);
}

/* ----------------------------------------------------------
   Toast
   ---------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: calc(var(--status-bar-height) + 16px);
  right: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 300;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
  color: var(--text-primary);
  min-width: 280px;
  pointer-events: auto;
  animation: toastIn 0.24s var(--ease-out);
}

@keyframes toastIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast.success { border-left: 3px solid var(--color-success); }
.toast.error { border-left: 3px solid var(--color-danger); }
.toast.warning { border-left: 3px solid var(--color-warning); }
.toast.info { border-left: 3px solid var(--brand-primary); }

.toast-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
}

.toast.success .toast-icon { color: var(--color-success); }
.toast.error .toast-icon { color: var(--color-danger); }
.toast.warning .toast-icon { color: var(--color-warning); }
.toast.info .toast-icon { color: var(--brand-primary); }

/* ----------------------------------------------------------
   Utility 鈥?Loading
   ---------------------------------------------------------- */
.loading-dots {
  display: inline-flex;
  gap: 3px;
}

.loading-dots span {
  width: 5px;
  height: 5px;
  background: var(--text-tertiary);
  border-radius: 50%;
  animation: dotPulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes dotPulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ----------------------------------------------------------
   Responsive
   ---------------------------------------------------------- */
@media (max-width: 1024px) {
  .app {
    grid-template-columns: var(--sidebar-collapsed-width) 1fr;
  }
  .sidebar {
    width: var(--sidebar-collapsed-width);
  }
  .nav-item-text,
  .nav-section-title,
  .sidebar-title,
  .sidebar-footer {
    display: none;
  }
  .drawer-tab { padding: 0 var(--space-2); }
}

@media (max-width: 768px) {
  .main-content { padding: var(--space-3); }
  .composer-wrapper {
    left: 0 !important;
    padding: var(--space-3);
  }
  .drawer-tabs {
    width: 60px;
  }
  .drawer-tab span:not(.drawer-tab-icon) {
    display: none;
  }
  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .metric-grid { grid-template-columns: 1fr; }
  .header-search { display: none; }
}

/* ----------------------------------------------------------
   Highlight.js 鈥?Atom One Dark adapted
   ---------------------------------------------------------- */
.hljs { background: transparent; color: #abb2bf; }
.hljs-comment, .hljs-quote { color: #5c6370; font-style: italic; }
.hljs-doctag, .hljs-keyword, .hljs-formula { color: #c678dd; }
.hljs-section, .hljs-name, .hljs-selector-tag, .hljs-deletion, .hljs-subst { color: #e06c75; }
.hljs-literal { color: #56b6c2; }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-attribute, .hljs-meta .hljs-string { color: #98c379; }
.hljs-attr, .hljs-variable, .hljs-template-variable, .hljs-type, .hljs-selector-class, .hljs-selector-attr, .hljs-selector-pseudo, .hljs-number { color: #d19a66; }
.hljs-symbol, .hljs-bullet, .hljs-link, .hljs-meta, .hljs-selector-id, .hljs-title { color: #61aeee; }
.hljs-built_in, .hljs-title.class_, .hljs-class .hljs-title { color: #e6c07b; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: bold; }
.hljs-link { text-decoration: underline; }

/* ============================================================
   Provider 配置（v2 重写）
   ============================================================ */

.drawer-wide { width: 560px; max-width: 90vw; }

.drawer-subtitle {
  font-size: 12px;
  color: var(--text-tertiary, #8b96a3);
  margin-top: 4px;
  font-family: var(--font-mono, monospace);
}

.provider-section {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
}
.provider-section:last-of-type { border-bottom: none; padding-bottom: 0; }

.provider-section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #f0f4f8);
  margin-bottom: 14px;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
}

.vendor-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.vendor-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px 12px;
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.08));
  border-radius: 10px;
  background: var(--bg-secondary, #1a1f2e);
  color: var(--text-secondary, #b0bac8);
  cursor: pointer;
  transition: all 180ms cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
}
.vendor-card:hover {
  border-color: rgba(59, 130, 246, 0.4);
  background: rgba(59, 130, 246, 0.06);
  transform: translateY(-1px);
}
.vendor-card.active {
  border-color: #3b82f6;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(139, 92, 246, 0.08));
  color: var(--text-primary, #f0f4f8);
  box-shadow: 0 4px 12px -4px rgba(59, 130, 246, 0.3);
}
.vendor-card.active .vendor-name { color: #fff; font-weight: 600; }

.vendor-icon { font-size: 22px; line-height: 1; margin-bottom: 2px; }
.vendor-name { font-size: 13px; font-weight: 500; }
.vendor-hint { font-size: 10px; color: var(--text-tertiary, #8b96a3); font-family: var(--font-mono, monospace); }

.form-required {
  color: #ef4444;
  font-weight: 700;
  margin-left: 2px;
}

.input-with-action {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.input-with-action .form-input { flex: 1; min-width: 0; }
.input-action-btn {
  flex-shrink: 0;
  width: 38px;
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.08));
  border-radius: 6px;
  background: var(--bg-secondary, #1a1f2e);
  color: var(--text-secondary, #b0bac8);
  cursor: pointer;
  font-size: 14px;
  transition: all 150ms;
}
.input-action-btn:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
}

.test-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-secondary, #1a1f2e);
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.08));
  border-radius: 10px;
}

.btn-test {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.08);
  color: #93c5fd;
  font-size: 13px;
  cursor: pointer;
  transition: all 180ms;
}
.btn-test:hover {
  background: rgba(59, 130, 246, 0.15);
  transform: translateY(-1px);
}
.btn-test:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.test-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary, #b0bac8);
  font-family: var(--font-mono, monospace);
}

.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.pending { background: #8b96a3; box-shadow: 0 0 6px rgba(139, 150, 163, 0.3); }
.status-dot.testing { background: #fbbf24; animation: pulse 1.2s ease-in-out infinite; }
.status-dot.success { background: #10b981; box-shadow: 0 0 8px rgba(16, 185, 129, 0.4); }
.status-dot.error { background: #ef4444; box-shadow: 0 0 8px rgba(239, 68, 68, 0.4); }
.status-dot.success + .status-text { color: #10b981; font-weight: 600; }
.status-dot.error + .status-text { color: #fca5a5; }

.test-result-detail {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-tertiary, #8b96a3);
  font-family: var(--font-mono, monospace);
  padding-left: 14px;
  border-left: 2px solid rgba(255,255,255,0.06);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.15); }
}

.drawer-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
  background: var(--bg-secondary, #1a1f2e);
}
.btn-ghost {
  background: transparent;
  color: var(--text-secondary, #b0bac8);
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.08));
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.04);
}
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ============================================================
   Provider 列表卡片
   ============================================================ */

.provider-card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.provider-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-secondary, #1a1f2e);
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
  border-radius: 10px;
  transition: all 180ms;
  cursor: pointer;
}
.provider-card:hover {
  border-color: rgba(59, 130, 246, 0.3);
  background: rgba(59, 130, 246, 0.04);
}
.provider-card.active {
  border-color: #10b981;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.06), rgba(16, 185, 129, 0.02));
  box-shadow: 0 2px 8px -2px rgba(16, 185, 129, 0.2);
}

.provider-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
}

.provider-card-info {
  flex: 1;
  min-width: 0;
}
.provider-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #f0f4f8);
  display: flex;
  align-items: center;
  gap: 6px;
}
.provider-card-active-badge {
  font-size: 9px;
  padding: 1px 5px;
  background: #10b981;
  color: #fff;
  border-radius: 4px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.provider-card-detail {
  font-size: 11px;
  color: var(--text-tertiary, #8b96a3);
  font-family: var(--font-mono, monospace);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.provider-card-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.provider-card-btn {
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-tertiary, #8b96a3);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms;
  font-size: 12px;
}
.provider-card-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary, #f0f4f8);
}
.provider-card-btn.danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
}

.empty-state {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-tertiary, #8b96a3);
  font-size: 13px;
}
.empty-state-icon {
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.5;
}

/* 数据库/Service Layer 字段显示控制 */
.db-field-real { display: none; }
.db-field-sqlite { display: none; }

/* ============================================================
   Views + Templates 管理页
   ============================================================ */

.manage-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.manage-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-secondary, #1a1f2e);
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
  border-radius: 10px;
  transition: all 180ms;
}
.manage-item:hover {
  border-color: rgba(59, 130, 246, 0.3);
}
.manage-item-info {
  flex: 1;
  min-width: 0;
}
.manage-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #f0f4f8);
  display: flex;
  align-items: center;
  gap: 6px;
}
.manage-item-meta {
  font-size: 11px;
  color: var(--text-tertiary, #8b96a3);
  font-family: var(--font-mono, monospace);
  margin-top: 2px;
}
.manage-item-badge {
  font-size: 9px;
  padding: 1px 6px;
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.manage-item-badge.source-json {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}

.manage-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.manage-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-tertiary, #8b96a3);
  font-size: 13px;
  background: var(--bg-elevated);
  border: 1px dashed var(--border-default);
  border-radius: 8px;
}

/* 方言 tab */
.sql-dialect-tabs {
  display: flex;
  gap: 4px;
  margin: 10px 0 6px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0;
}
.dialect-tab {
  padding: 6px 14px;
  background: transparent;
  color: var(--text-tertiary, #8b96a3);
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-mono, monospace);
  font-weight: 500;
  transition: all 150ms;
}
.dialect-tab:hover {
  color: var(--text-secondary);
}
.dialect-tab.active {
  color: #3b82f6;
  border-bottom-color: #3b82f6;
}

.tpl-var-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 2px;
  padding: 3px 8px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  color: #93c5fd;
  border-radius: 5px;
  font-size: 11px;
  font-family: var(--font-mono, monospace);
}
.tpl-var-chip .var-type {
  font-size: 9px;
  opacity: 0.7;
  background: rgba(0,0,0,0.2);
  padding: 0 4px;
  border-radius: 3px;
}

.tpl-test-var-row {
  display: flex;
  gap: 6px;
  margin: 4px 0;
  align-items: center;
}
.tpl-test-var-row label {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--font-mono, monospace);
  width: 120px;
}
.tpl-test-var-row input {
  flex: 1;
  padding: 4px 8px;
  background: var(--bg-elevated, #131825);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font-mono, monospace);
}