/* ============================================================
   红房子医院数据中台 · 原型设计系统（shadcn 风格）
   - 中性色板 + 单一主色（专业医疗感，避免"AI 化"渐变/玻璃拟态）
   - 细边框 / 小圆角 / 克制的阴影 / 清晰层级
   - 类名尽量贴近 shadcn/Tailwind 语义
   ============================================================ */

:root {
  /* 色板（HSL，与 shadcn zinc 基座一致） */
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --primary: 221 83% 53%;
  --primary-foreground: 0 0% 98%;
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 221 83% 53%;
  --destructive: 0 72% 51%;
  --destructive-foreground: 0 0% 98%;
  --success: 142 64% 24%;
  --success-bg: 142 69% 94%;
  --warning: 32 95% 44%;
  --warning-bg: 48 96% 92%;
  --info: 217 91% 60%;
  --info-bg: 214 100% 96%;
  --radius: 0.5rem;
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.08);
  --font: -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", Inter, Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* 图标默认尺寸兜底：所有 data-icon 注入的 svg 默认 16px，
   防止无尺寸约束的图标（上传区/空态等）渲染得过大；各容器特化规则（nav/icon-btn/stat 等）在其后定义并覆盖 */
i[data-icon] svg { width: 16px; height: 16px; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

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

/* ---------- 布局 ---------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: hsl(var(--card));
  border-right: 1px solid hsl(var(--border));
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid hsl(var(--border));
}

.sidebar-brand .logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: hsl(352 74% 44%);            /* 红房子品牌红 */
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 15px; flex-shrink: 0;
}

.sidebar-brand .brand-name { font-weight: 600; font-size: 14px; }
.sidebar-brand .brand-sub { font-size: 11px; color: hsl(var(--muted-foreground)); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 8px; }

.nav-group-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: hsl(var(--muted-foreground));
  padding: 14px 10px 6px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px;
  color: hsl(var(--muted-foreground));
  font-size: 13.5px; cursor: pointer;
  transition: background .12s, color .12s;
  margin-bottom: 2px;
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.nav-item:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }

.nav-item.active {
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
  font-weight: 500;
}

.sidebar-footer {
  padding: 12px 14px; border-top: 1px solid hsl(var(--border));
  display: flex; align-items: center; gap: 10px; font-size: 13px;
}

.sidebar-footer .avatar { width: 30px; height: 30px; border-radius: 999px; background: hsl(221 83% 53% / .15); color: hsl(var(--primary)); display: grid; place-items: center; font-weight: 600; font-size: 12px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h); flex-shrink: 0;
  background: hsl(var(--card));
  border-bottom: 1px solid hsl(var(--border));
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; gap: 16px;
  position: sticky; top: 0; z-index: 20;
}

.topbar-title { font-size: 15px; font-weight: 600; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.content { padding: 24px; flex: 1; max-width: 1440px; width: 100%; margin: 0 auto; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }

.page-head h1 { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.page-head .desc { color: hsl(var(--muted-foreground)); font-size: 13px; margin-top: 2px; }

/* ---------- 组件：按钮 ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border-radius: 6px; border: 1px solid transparent;
  font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
  background: transparent; color: hsl(var(--foreground));
}

.btn svg { width: 15px; height: 15px; }

.btn-primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn-primary:hover { background: hsl(var(--primary) / .9); }

.btn-outline { border-color: hsl(var(--border)); background: hsl(var(--card)); }
.btn-outline:hover { background: hsl(var(--accent)); }

.btn-ghost { color: hsl(var(--muted-foreground)); }
.btn-ghost:hover { background: hsl(var(--accent)); color: hsl(var(--foreground)); }

.btn-secondary { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.btn-secondary:hover { background: hsl(var(--secondary) / .8); }

.btn-destructive { background: hsl(var(--destructive)); color: #fff; }
.btn-destructive:hover { background: hsl(var(--destructive) / .9); }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-lg { height: 40px; padding: 0 20px; font-size: 14px; }

.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 组件：表单 ---------- */

.input, .select, .textarea {
  height: 34px; width: 100%;
  border: 1px solid hsl(var(--input)); border-radius: 6px;
  padding: 0 10px; font-size: 13px; font-family: inherit;
  background: hsl(var(--card)); color: hsl(var(--foreground));
  transition: border-color .12s, box-shadow .12s;
}

.textarea { height: auto; padding: 8px 10px; resize: vertical; }

.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / .15);
}

.input::placeholder { color: hsl(var(--muted-foreground) / .7); }

.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }

.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12.5px; font-weight: 500; margin-bottom: 6px; color: hsl(var(--foreground)); }
.field .hint { font-size: 12px; color: hsl(var(--muted-foreground)); margin-top: 4px; }

.search-box { position: relative; }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: hsl(var(--muted-foreground)); }
.search-box .input { padding-left: 32px; width: 260px; }

/* 侧边栏角色切换：分段控件 */
.seg-switch {
  display: flex; gap: 2px;
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border));
  border-radius: 8px; padding: 2px;
}
.seg-item {
  flex: 1; height: 28px; border: none; border-radius: 6px;
  background: transparent; color: hsl(var(--muted-foreground));
  font-size: 12.5px; font-weight: 500; cursor: pointer;
  transition: background .12s, color .12s;
}
.seg-item:hover { color: hsl(var(--foreground)); }
.seg-item.active { background: hsl(var(--foreground)); color: #fff; }
body.ink .seg-switch { border-radius: 2px; }
body.ink .seg-item { border-radius: 1px; }

/* 右上角主题切换 */
.theme-switch-wrap { position: relative; display: inline-flex; }
.theme-menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: hsl(var(--card)); border: 1px solid hsl(var(--border));
  border-radius: 8px; box-shadow: var(--shadow-lg);
  padding: 4px; min-width: 190px; z-index: 80;
  display: none;
}
.theme-menu.open { display: block; }
.theme-opt {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
  font-size: 13px; color: hsl(var(--foreground));
}
.theme-opt:hover { background: hsl(var(--accent)); }
.theme-opt.active { background: hsl(var(--accent)); font-weight: 500; }
.theme-opt .swatch { width: 15px; height: 15px; border-radius: 999px; flex-shrink: 0; border: 1px solid hsl(var(--border)); }
.theme-opt .check svg { width: 14px; height: 14px; color: hsl(var(--primary)); }
body.ink .theme-menu { border-radius: 2px; }
body.ink .theme-opt { border-radius: 2px; }
body.ink .theme-opt .check svg { color: hsl(var(--foreground)); }

/* ---------- 组件：卡片 ---------- */

.card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 2px);
  box-shadow: var(--shadow-sm);
}

.card-header { padding: 16px 18px; border-bottom: 1px solid hsl(var(--border)); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title { font-size: 14.5px; font-weight: 600; }
.card-desc { font-size: 12.5px; color: hsl(var(--muted-foreground)); }
.card-body { padding: 18px; }
.card-footer { padding: 12px 18px; border-top: 1px solid hsl(var(--border)); display: flex; align-items: center; justify-content: flex-end; gap: 8px; }

/* ---------- 组件：统计卡 ---------- */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 22px; }

.stat-card { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.stat-card .label { font-size: 12.5px; color: hsl(var(--muted-foreground)); display: flex; align-items: center; gap: 6px; }
.stat-card .label svg { width: 14px; height: 14px; }
.stat-card .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-card .trend { font-size: 12px; display: flex; align-items: center; gap: 4px; }
.trend-up { color: hsl(var(--success)); }
.trend-down { color: hsl(var(--destructive)); }

/* ---------- 组件：徽标 ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground));
  border: 1px solid transparent;
}

.badge .dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }

.badge-success { background: var(--success-bg); color: hsl(var(--success)); }
.badge-warning { background: var(--warning-bg); color: hsl(var(--warning)); }
.badge-destructive { background: hsl(var(--destructive) / .1); color: hsl(var(--destructive)); }
.badge-info { background: var(--info-bg); color: hsl(var(--info)); }
.badge-primary { background: hsl(var(--primary) / .1); color: hsl(var(--primary)); }
.badge-outline { background: transparent; border-color: hsl(var(--border)); color: hsl(var(--muted-foreground)); }

/* ---------- 组件：表格 ---------- */

.table-wrap { overflow-x: auto; }

table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.table th {
  text-align: left; font-weight: 500; font-size: 12px; color: hsl(var(--muted-foreground));
  padding: 10px 14px; border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / .5); white-space: nowrap;
}

/* 表格贴卡片顶部时：首行表头圆角匹配卡片圆角（避免方角盖住卡片左上/右上） */
.card > .table-wrap:first-child thead th:first-child { border-top-left-radius: 10px; }
.card > .table-wrap:first-child thead th:last-child { border-top-right-radius: 10px; }
body.ink .card > .table-wrap:first-child thead th:first-child { border-top-left-radius: 12px; }
body.ink .card > .table-wrap:first-child thead th:last-child { border-top-right-radius: 12px; }

.table td { padding: 11px 14px; vertical-align: middle; }

.table tbody tr { border-bottom: 1px solid hsl(var(--border)); transition: background .1s; }
.table tbody tr:hover { background: hsl(var(--muted) / .4); }
.table tbody tr:last-child { border-bottom: none; }

.table .num { font-variant-numeric: tabular-nums; }
.table .mono { font-family: var(--mono); font-size: 12.5px; }

.td-actions { display: flex; gap: 2px; justify-content: flex-end; align-items: center; }
.td-actions .btn-sm { height: 30px; }
.td-actions .icon-btn { flex-shrink: 0; }

/* ---------- 组件：Tabs ---------- */

.tabs { display: flex; gap: 2px; border-bottom: 1px solid hsl(var(--border)); margin-bottom: 18px; }

.tab {
  padding: 9px 14px; font-size: 13.5px; font-weight: 500; cursor: pointer;
  color: hsl(var(--muted-foreground)); border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color .12s, border-color .12s;
  display: inline-flex; align-items: center; gap: 6px; background: none; border-top: none; border-left: none; border-right: none;
}

.tab svg { width: 14px; height: 14px; }

.tab:hover { color: hsl(var(--foreground)); }
.tab.active { color: hsl(var(--primary)); border-bottom-color: hsl(var(--primary)); }
.tab .count { background: hsl(var(--muted)); border-radius: 999px; font-size: 11px; padding: 1px 7px; color: hsl(var(--muted-foreground)); }
.tab.active .count { background: hsl(var(--primary) / .12); color: hsl(var(--primary)); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- 组件：对话框 ---------- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgb(0 0 0 / .45); z-index: 100;
  display: none; align-items: flex-start; justify-content: center;
  padding: 8vh 16px 16px; overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-backdrop.open { display: flex; }

.modal {
  background: hsl(var(--card)); border-radius: 10px; width: 100%;
  max-width: 560px; box-shadow: var(--shadow-lg);
  animation: modal-in .16s ease-out;
}

.modal.lg { max-width: 780px; }
.modal.xl { max-width: 980px; }

@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

.modal-header { padding: 16px 20px; border-bottom: 1px solid hsl(var(--border)); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 15px; font-weight: 600; }
.modal-body { padding: 20px; max-height: 65vh; overflow-y: auto; }
.modal-footer { padding: 14px 20px; border-top: 1px solid hsl(var(--border)); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- 组件：Drawer（侧滑详情） ---------- */

.drawer-backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / .4); z-index: 90; display: none; }
.drawer-backdrop.open { display: block; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%);
  background: hsl(var(--card)); z-index: 95; box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .22s ease;
  display: flex; flex-direction: column;
  overscroll-behavior: contain;
}

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

.drawer-header { padding: 16px 20px; border-bottom: 1px solid hsl(var(--border)); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.drawer-body { padding: 20px; flex: 1; overflow-y: auto; }
.drawer-footer { padding: 14px 20px; border-top: 1px solid hsl(var(--border)); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- 组件：Toast ---------- */

.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }

/* Toast 样式统一在「提示柔和化」区块定义 */

/* ---------- 组件：进度条 ---------- */

.progress { height: 6px; background: hsl(var(--secondary)); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: hsl(var(--primary)); border-radius: 999px; }

/* ---------- 组件：列表行 ---------- */

.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid hsl(var(--border)); }
.list-item:last-child { border-bottom: none; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-size: 13.5px; font-weight: 500; }
.list-item .sub { font-size: 12.5px; color: hsl(var(--muted-foreground)); }

.icon-btn {
  width: 30px; height: 30px; border-radius: 6px; border: 1px solid transparent;
  display: inline-grid; place-items: center; cursor: pointer;
  color: hsl(var(--muted-foreground)); background: transparent;
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: hsl(var(--accent)); color: hsl(var(--foreground)); }
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn.danger:hover { background: hsl(var(--destructive) / .1); color: hsl(var(--destructive)); }

/* ---------- 组件：分页 ---------- */

.pagination { display: flex; align-items: center; gap: 6px; justify-content: flex-end; margin-top: 14px; font-size: 13px; }
.pagination .page-btn { min-width: 30px; height: 30px; padding: 0 8px; border-radius: 6px; border: 1px solid hsl(var(--border)); background: hsl(var(--card)); cursor: pointer; font-size: 13px; }
.pagination .page-btn.active { background: hsl(var(--primary)); color: #fff; border-color: transparent; }
.pagination .page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- 工具类 ---------- */

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.grow { flex: 1; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.muted { color: hsl(var(--muted-foreground)); }
.small { font-size: 12.5px; }
.smaller { font-size: 12px; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-primary { color: hsl(var(--primary)); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.divider { height: 1px; background: hsl(var(--border)); margin: 14px 0; }

.avatar {
  width: 28px; height: 28px; border-radius: 999px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 11.5px; font-weight: 600;
  background: hsl(221 83% 53% / .12); color: hsl(var(--primary));
}

.avatar.teal { background: hsl(174 60% 40% / .12); color: hsl(174 60% 32%); }
.avatar.amber { background: hsl(32 95% 44% / .12); color: hsl(var(--warning)); }
.avatar.rose { background: hsl(352 74% 44% / .12); color: hsl(352 74% 44%); }

.kbd { font-family: var(--mono); font-size: 11px; border: 1px solid hsl(var(--border)); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; background: hsl(var(--muted) / .6); }

/* 卡片网格（AI 工作台等通用） */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }

.agent-card-body { padding: 16px; }
.agent-card-body .agent-icon {
  width: 40px; height: 40px; border-radius: 8px; flex-shrink: 0;
  display: grid; place-items: center; background: hsl(var(--secondary));
  color: hsl(var(--foreground));
}
.agent-card-body .agent-icon svg { width: 19px; height: 19px; }
.agent-card-footer { padding: 10px 16px; border-top: 1px solid hsl(var(--border)); display: flex; align-items: center; gap: 8px; }

/* 空状态 */
.empty { text-align: center; padding: 48px 20px; color: hsl(var(--muted-foreground)); }
.empty svg { width: 36px; height: 36px; color: hsl(var(--border)); margin-bottom: 10px; }

/* 全局 Tooltip */
.g-tooltip {
  position: fixed; z-index: 300; pointer-events: none;
  max-width: 280px; padding: 10px 13px;
  font-size: 12.5px; line-height: 1.7;
  background: hsl(240 8% 13%); color: #f5f5f5;
  border: 1px solid rgb(255 255 255 / 0.08);
  border-radius: 10px; box-shadow: 0 10px 30px rgb(0 0 0 / 0.22), 0 2px 8px rgb(0 0 0 / 0.12);
  white-space: normal;
  opacity: 0; visibility: hidden;
  transition: opacity .18s ease, visibility .18s ease;
}
.g-tooltip.show { opacity: 1; visibility: visible; }
body.ink .g-tooltip {
  background: hsl(0 0% 11%); color: #fff;
  border: 1px solid hsl(0 0% 24%);
  border-radius: 10px;
}
/* 彩色主题 tooltip 品牌边框定义于 styles-themes.css（需在其后加载才生效） */

/* Toast：柔和呈现 */
.toast {
  background: linear-gradient(180deg, hsl(240 8% 17%), hsl(240 8% 12%));
  color: #fff; font-size: 13px;
  padding: 11px 16px; border-radius: 10px;
  border: 1px solid rgb(255 255 255 / 0.08);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.22), 0 2px 8px rgb(0 0 0 / 0.12);
  display: flex; align-items: center; gap: 8px;
  animation: toast-in .25s cubic-bezier(.2, .8, .3, 1);
}
.toast svg { width: 15px; height: 15px; color: hsl(142 71% 60%); flex-shrink: 0; }
.toast.error svg { color: hsl(0 84% 70%); }

@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }

/* ---------- 原型专用：ETL 画布 ---------- */

.canvas-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid hsl(var(--border)); background: hsl(var(--card)); }

.etl-layout { display: grid; grid-template-columns: 220px 1fr 260px; gap: 0; min-height: 520px; }

.node-palette { border-right: 1px solid hsl(var(--border)); background: hsl(var(--card)); padding: 12px; overflow-y: auto; }

.palette-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border: 1px solid hsl(var(--border)); border-radius: 6px; margin-bottom: 8px;
  font-size: 13px; cursor: grab; background: hsl(var(--card));
  transition: border-color .12s, box-shadow .12s;
}
.palette-item:hover { border-color: hsl(var(--ring)); box-shadow: var(--shadow-sm); }
.palette-item svg { width: 15px; height: 15px; color: hsl(var(--muted-foreground)); }

.canvas-area { background: hsl(var(--muted) / .4); position: relative; padding: 20px; }

.flow-node {
  position: absolute; width: 176px;
  background: hsl(var(--card)); border: 1.5px solid hsl(var(--border));
  border-radius: 8px; box-shadow: var(--shadow-sm); cursor: move;
  font-size: 13px; user-select: none;
}
.flow-node.selected { border-color: hsl(var(--ring)); box-shadow: 0 0 0 3px hsl(var(--ring) / .15); }
.flow-node .node-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid hsl(var(--border)); font-weight: 500; }
.flow-node .node-head svg { width: 14px; height: 14px; color: hsl(var(--primary)); }
.flow-node .node-body { padding: 7px 12px; font-size: 12px; color: hsl(var(--muted-foreground)); }
.flow-node .port { position: absolute; width: 12px; height: 12px; border-radius: 999px; background: hsl(var(--card)); border: 2px solid hsl(var(--muted-foreground)); cursor: crosshair; z-index: 3; }
.flow-node .port.out { bottom: -7px; top: auto; left: 50%; transform: translateX(-50%); }
.flow-node .port.in { top: -7px; bottom: auto; left: 50%; transform: translateX(-50%); }
.flow-node .port:hover { border-color: hsl(var(--primary)); background: hsl(var(--primary)); }
.flow-node.dragging { opacity: .6; }
.flow-node.dragging .port { pointer-events: none; }

.node-prop { padding: 12px; overflow-y: auto; border-left: 1px solid hsl(var(--border)); background: hsl(var(--card)); }

/* 状态条（报告流程） */
.steps { display: flex; align-items: center; gap: 0; margin: 6px 0 2px; }
.step { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: hsl(var(--muted-foreground)); }
.step .step-dot { width: 22px; height: 22px; border-radius: 999px; border: 1.5px solid hsl(var(--border)); display: grid; place-items: center; background: hsl(var(--card)); font-size: 11px; flex-shrink: 0; }
.step.done .step-dot { background: hsl(var(--primary)); border-color: hsl(var(--primary)); color: #fff; }
.step.active .step-dot { border-color: hsl(var(--primary)); color: hsl(var(--primary)); }
.step-line { width: 34px; height: 1.5px; background: hsl(var(--border)); margin: 0 6px; }
.step-line.done { background: hsl(var(--primary)); }

/* 对话（AI 平台） */
.chat-layout { display: grid; grid-template-columns: 280px 1fr 300px; gap: 16px; min-height: 640px; }

.chat-msg { display: flex; gap: 10px; margin-bottom: 18px; }
.chat-msg .bubble { background: hsl(var(--muted) / .6); border-radius: 10px; padding: 10px 14px; font-size: 13.5px; max-width: 78%; }
.chat-msg.user { flex-direction: row-reverse; }
.chat-msg.user .bubble { background: hsl(var(--primary)); color: #fff; }
.chat-msg .bubble .ref { font-size: 12px; color: hsl(var(--muted-foreground)); border-top: 1px solid hsl(var(--border)); margin-top: 8px; padding-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.chat-msg .bubble .ref a { color: hsl(var(--primary)); cursor: pointer; }
.chat-msg .bubble .tool-call { font-size: 12px; font-family: var(--mono); background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: 6px; padding: 6px 10px; margin-top: 8px; color: hsl(var(--muted-foreground)); }

.chat-input { display: flex; gap: 8px; align-items: flex-end; }
.chat-input .textarea { flex: 1; min-height: 44px; }

.agent-card { cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.agent-card:hover { border-color: hsl(var(--ring) / .6); box-shadow: var(--shadow-md); }
.agent-card.selected { border-color: hsl(var(--ring)); box-shadow: 0 0 0 3px hsl(var(--ring) / .12); }

/* 字段权限矩阵 */
.perm-matrix th, .perm-matrix td { text-align: center; }
.perm-matrix td:first-child, .perm-matrix th:first-child { text-align: left; }
.perm-tag { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.perm-hidden { background: hsl(0 72% 51% / .1); color: hsl(var(--destructive)); }
.perm-readonly { background: hsl(217 91% 60% / .1); color: hsl(var(--info)); }
.perm-editable { background: hsl(142 69% 94%); color: hsl(var(--success)); }
.perm-masked { background: hsl(32 95% 44% / .12); color: hsl(var(--warning)); }

/* 尊重系统减弱动态偏好：禁用装饰性动画 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 侧边栏折叠/展开 */
.sidebar { transition: width .2s ease; }
body.sb-collapsed .sidebar { width: 64px; }
body.sb-collapsed .sidebar-brand { justify-content: center; gap: 0; padding: 14px 10px 12px; }
body.sb-collapsed .sidebar-brand .brand-name { display: none; }
body.sb-collapsed .sidebar-brand img { height: 30px; }
body.sb-collapsed .sidebar-collapse { margin-left: 0 !important; }
body.sb-collapsed .nav-item { justify-content: center; padding: 9px 0; }
body.sb-collapsed .nav-item .nav-label,
body.sb-collapsed .nav-group-label { display: none; }
body.sb-collapsed .sidebar-footer { align-items: center !important; gap: 6px !important; }
body.sb-collapsed .sidebar-footer .grow { display: none; }
body.sb-collapsed .seg-switch { display: none; }   /* 折叠时隐藏角色切换，展开恢复 */

/* 响应式 */
@media (max-width: 1100px) {
  .chat-layout { grid-template-columns: 1fr; }
  .etl-layout { grid-template-columns: 1fr; }
  .node-prop { border-left: none; border-top: 1px solid hsl(var(--border)); }
}

@media (max-width: 900px) {
  .sidebar { display: none; }
  .content { padding: 16px; }
}
