/* ============ 基础 ============ */
:root {
  --bg: #f2f5f9;
  --panel: #ffffff;
  --primary: #0e7490;
  --primary-dark: #155e75;
  --primary-light: #e0f2fe;
  --accent: #0891b2;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --ok: #16a34a;
  --ok-bg: #f0fdf4;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .12);
  --radius: 14px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* ============ 侧边栏 ============ */
.sidebar {
  width: 268px;
  background: linear-gradient(180deg, #0b2a3c 0%, #0e3a4f 100%);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.logo {
  width: 44px; height: 44px; flex-shrink: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #22d3ee, #0ea5e9);
  display: grid; place-items: center;
  font-size: 22px; font-weight: 800; color: #fff;
  box-shadow: 0 4px 14px rgba(14, 165, 233, .45);
}
.brand-text h1 { font-size: 15px; color: #fff; font-weight: 700; line-height: 1.3; }
.brand-text span { font-size: 11px; color: #7dd3fc; letter-spacing: .3px; }

.nav { flex: 1; padding: 12px 10px; }
.nav-group { margin-bottom: 6px; }
.nav-title {
  font-size: 11px; color: #7c95a8; text-transform: uppercase;
  letter-spacing: 1px; padding: 10px 10px 6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 9px;
  color: #cbd5e1; text-decoration: none; cursor: pointer;
  font-size: 13.5px; transition: all .15s;
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: rgba(34, 211, 238, .16); color: #67e8f9; font-weight: 600; }
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); }
.user-chip { display: flex; gap: 10px; align-items: center; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #f472b6, #a78bfa);
  display: grid; place-items: center; color: #fff; font-weight: 700; flex-shrink: 0;
}
.u-name { font-size: 13px; color: #fff; font-weight: 600; }
.u-role { font-size: 11px; color: #7c95a8; }

/* ============ 主内容 ============ */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 62px; background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; position: sticky; top: 0; z-index: 10;
}
.page-title { font-size: 18px; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(22,163,74,.2); }

.content { padding: 26px 28px 60px; max-width: 1160px; width: 100%; }

/* ============ 通用组件 ============ */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.card h3 { font-size: 15px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card h3 .tag { margin-left: auto; }

.stat-card { padding: 20px; }
.stat-card .stat-label { color: var(--muted); font-size: 12.5px; margin-bottom: 6px; }
.stat-card .stat-value { font-size: 30px; font-weight: 800; line-height: 1; }
.stat-card .stat-sub { font-size: 12px; color: var(--muted); margin-top: 8px; }
.stat-card.blue { border-left: 4px solid #0ea5e9; }
.stat-card.red { border-left: 4px solid #ef4444; }
.stat-card.amber { border-left: 4px solid #f59e0b; }
.stat-card.green { border-left: 4px solid #10b981; }
.stat-card.purple { border-left: 4px solid #8b5cf6; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.禁用 { background: var(--danger-bg); color: var(--danger); }
.badge.慎用 { background: var(--warn-bg); color: var(--warn); }
.badge.注意 { background: var(--ok-bg); color: var(--ok); }
.badge.中药 { background: #ecfdf5; color: #059669; }
.badge.西药 { background: #eff6ff; color: #2563eb; }
.badge.中成药 { background: #faf5ff; color: #9333ea; }
.badge.处方药 { background: #fef2f2; color: #dc2626; }
.badge.OTC { background: #f0fdf4; color: #16a34a; }
.badge.毒性 { background: #fff7ed; color: #ea580c; }

.tag { font-size: 11px; color: var(--muted); background: var(--bg); padding: 2px 8px; border-radius: 6px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--primary); color: #fff; border: none;
  padding: 9px 16px; border-radius: 9px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; transition: all .15s;
}
.btn:hover { background: var(--primary-dark); }
.btn.ghost { background: var(--panel); color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--bg); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 6px 12px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 9px; font-size: 14px; font-family: inherit; color: var(--text);
  background: #fff; transition: border .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(8,145,178,.12);
}
label { font-size: 12.5px; color: var(--muted); font-weight: 600; display: block; margin-bottom: 6px; }
.field { margin-bottom: 14px; }

.search-box { position: relative; }
.search-box input { padding-left: 38px; font-size: 15px; padding-top: 12px; padding-bottom: 12px; }
.search-box .s-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 16px; opacity: .5; }

/* 自动补全 */
.suggest { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); margin-top: 4px; z-index: 30; max-height: 260px; overflow-y: auto; }
.suggest-item { padding: 10px 14px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.suggest-item:hover { background: var(--primary-light); }
.suggest-item .name { font-weight: 600; }
.suggest-item .meta { color: var(--muted); font-size: 12px; }
.suggest-empty { padding: 14px; color: var(--muted); text-align: center; }

/* 表格 */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); }
th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: .3px; }
tr:hover td { background: #f8fafc; }
.table-wrap { overflow-x: auto; }

/* 告警横幅 */
.alert {
  display: flex; gap: 12px; align-items: flex-start;
  border-radius: 12px; padding: 16px; margin-bottom: 14px; border: 1px solid;
}
.alert .alert-icon { font-size: 22px; line-height: 1.3; }
.alert strong { display: block; font-size: 14px; margin-bottom: 4px; }
.alert.danger { background: var(--danger-bg); border-color: #fecaca; color: #991b1b; }
.alert.warn { background: var(--warn-bg); border-color: #fde68a; color: #92400e; }
.alert.ok { background: var(--ok-bg); border-color: #bbf7d0; color: #166534; }
.alert.info { background: var(--primary-light); border-color: #bae6fd; color: #0c4a6e; }

/* DDI 结果卡片 */
.ddi-card { display: flex; gap: 14px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 12px; background: #fff; }
.ddi-card .ddi-main { flex: 1; }
.ddi-card .ddi-title { font-weight: 700; font-size: 14.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ddi-card .ddi-reason { color: var(--muted); font-size: 13px; margin-top: 6px; }
.ddi-card .ddi-suggestion { margin-top: 8px; font-size: 13px; background: var(--bg); border-radius: 8px; padding: 8px 12px; color: var(--text); }
.ddi-card .rule-chip { font-size: 11px; background: #f1f5f9; color: #475569; padding: 2px 8px; border-radius: 5px; }

/* 药物信息卡 */
.drug-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.drug-head .drug-ico { width: 52px; height: 52px; border-radius: 14px; background: var(--primary-light); display: grid; place-items: center; font-size: 24px; flex-shrink: 0; }
.drug-head .drug-name { font-size: 20px; font-weight: 800; }
.drug-head .drug-sub { color: var(--muted); font-size: 12.5px; }

.info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 18px; }
.info-grid .info-item { display: flex; flex-direction: column; padding: 10px 12px; background: #f8fafc; border-radius: 9px; }
.info-grid .info-item .k { font-size: 11.5px; color: var(--muted); }
.info-grid .info-item .v { font-size: 13.5px; font-weight: 600; margin-top: 2px; word-break: break-all; }

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--bg); border: 1px solid var(--border); padding: 3px 10px; border-radius: 20px; font-size: 12.5px; }

/* 流程/结构图 */
.flow { display: flex; flex-direction: column; align-items: center; gap: 0; }
.flow-root {
  background: linear-gradient(135deg, #0e7490, #0891b2); color: #fff;
  padding: 14px 26px; border-radius: 12px; font-size: 16px; font-weight: 800;
  box-shadow: 0 6px 18px rgba(14,116,144,.35);
}
.flow-line { width: 2px; height: 22px; background: #cbd5e1; }
.flow-branches { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; width: 100%; }
.flow-col { flex: 1; min-width: 220px; max-width: 280px; display: flex; flex-direction: column; align-items: center; }
.flow-node {
  width: 100%; background: var(--panel); border: 1px solid var(--border);
  border-radius: 11px; padding: 12px 14px; text-align: center; font-weight: 700;
  box-shadow: var(--shadow); color: var(--primary-dark);
  border-top: 3px solid var(--accent);
}
.flow-child {
  width: 100%; background: #f8fafc; border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; text-align: center;
  font-size: 13px; color: var(--text); margin-top: 8px;
}

/* 提醒列表 */
.reminder-item { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; }
.reminder-item .r-time { font-size: 20px; font-weight: 800; color: var(--primary); width: 74px; text-align: center; }
.reminder-item .r-body { flex: 1; }
.reminder-item .r-drug { font-weight: 700; }
.reminder-item .r-meta { color: var(--muted); font-size: 12px; }

/* 空状态 */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .e-icon { font-size: 44px; margin-bottom: 10px; }

/* 响应式 */
@media (max-width: 960px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .sidebar { width: 220px; }
}
@media (max-width: 720px) {
  .sidebar { transform: translateX(-100%); }
  .grid-3, .grid-4, .grid-2 { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .content { padding: 18px 14px 50px; }
}

/* ============ DeepSeek 药师工作台 ============ */
:root {
  --bg: #f3f6f6;
  --primary: #12786f;
  --primary-dark: #0e5e57;
  --primary-light: #e8f5f2;
  --accent: #15a595;
  --text: #17313a;
  --muted: #6a7c83;
  --border: #dfe8e7;
  --radius: 13px;
  --shadow: 0 2px 7px rgba(21, 54, 60, .025);
}

[hidden] { display: none !important; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid #55cbb9; outline-offset: 3px; }
textarea { min-height: 96px; resize: vertical; }
button { touch-action: manipulation; }
.sidebar { width: 248px; background: #103d49; scrollbar-width: thin; scrollbar-color: #42626b transparent; }
.brand { padding: 25px 18px 21px; gap: 11px; }
.logo { background: #36af9c; box-shadow: none; width: 40px; height: 40px; border-radius: 11px; }
.brand-text h1 { font-size: 14px; letter-spacing: .2px; }
.brand-text span { color: #8bc6c4; font-size: 10px; }
.nav { padding: 11px 12px; }
.nav-title { color: #87a7af; font-size: 10px; letter-spacing: 1.3px; padding-top: 14px; }
.nav-item { font-size: 12.5px; padding: 8px 12px; border-radius: 7px; }
.nav-item[hidden] { display: none !important; }
.nav-item .icon { font-size: 14px; }
.nav-item.active { background: #26565e; color: #c1f5e6; }
.avatar { background: #31656e; border: 1px solid #467780; }
.u-role { color: #a1bdc2; }
.topbar { min-height: 72px; height: auto; padding: 15px 30px; gap: 16px; }
.topbar-leading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-title { font-size: 17px; letter-spacing: -.3px; white-space: nowrap; }
.topbar-actions { gap: 11px; flex-wrap: wrap; justify-content: flex-end; }
.topbar-actions select { width: auto; max-width: 190px; font-size: 12px; padding: 7px 28px 7px 10px; background: #f8faf9; }
.status-dot { background: #15a595; box-shadow: 0 0 0 3px #e4f4ef; flex-shrink: 0; }
.mobile-menu { display: none; border: 1px solid var(--border); border-radius: 7px; background: #fff; width: 34px; height: 34px; color: var(--text); cursor: pointer; }
.content { max-width: 1420px; padding: 26px 30px 28px; flex: 1; }
.global-note { color: #819097; font-size: 11px; padding: 0 30px 24px; line-height: 1.7; }
.connection-notice { padding: 16px 30px 0; }
.connection-notice .alert { margin-bottom: 0; }
.access-token-panel { margin: 16px 30px 0; padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.access-token-panel .toolbar { margin: 12px 0 0; }
@media (max-width: 720px) { .access-token-panel { margin: 12px 14px 0; padding: 14px; } }
.topbar-actions.offline .status-dot { background: #c58b35; box-shadow: 0 0 0 3px #fff3db; }
.card { padding: 22px; }
.card h3 { font-size: 14px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.grid { align-items: stretch; }
.grid > * { min-width: 0; }
.btn { padding: 10px 17px; font-size: 13px; border-radius: 8px; justify-content: center; }
.btn.ghost { color: #4c656c; }
.btn.small { font-size: 12px; padding: 7px 11px; }
.badge.注意 { background: #fff7e7; color: #946821; }
.muted { color: var(--muted); }
.small-text { font-size: 12px; line-height: 1.7; }
.model-state { font-size: 11px; color: var(--muted); }
.workspace-hero {
  position: relative; overflow: hidden;
  background: #164c55; color: #fff; border-radius: 16px;
  padding: 32px 34px; margin-bottom: 22px;
  display: block;
}
.workspace-hero::after {
  content: "+"; position: absolute; right: 8%; top: -58px;
  font-size: 260px; font-weight: 300; line-height: 1;
  color: rgba(164, 224, 208, .06); pointer-events: none;
}
.workspace-hero > * { position: relative; z-index: 1; }
.workspace-hero h1, .workspace-hero h2 { color: #fff; font-size: clamp(23px, 2.5vw, 32px); font-weight: 650; line-height: 1.4; letter-spacing: -.6px; margin: 8px 0 10px; }
.workspace-hero p { color: #bfdbdb; max-width: 670px; font-size: 13px; line-height: 1.9; }
.workspace-hero .eyebrow { color: #89d4c2; }
.workspace-hero .btn { background: #b3ead7; color: #124a44; }
.workspace-hero .btn:hover { background: #cdf4e7; }
.workspace-hero .btn.ghost { background: transparent; color: #e2f5f1; border-color: #658c8f; }
.eyebrow { font-size: 10px; letter-spacing: 1.8px; font-weight: 700; text-transform: uppercase; color: var(--primary); }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; flex-shrink: 0; margin-top: 22px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 24px 0 14px; }
.section-heading h2, .section-heading h3 { font-size: 16px; font-weight: 650; margin: 0; }
.section-heading p { color: var(--muted); font-size: 12px; margin-top: 4px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input { flex: 1; min-width: 170px; }
.toolbar select { width: auto; min-width: 130px; }
.toolbar .btn { flex-shrink: 0; }
.notice { background: #f4f8f7; color: #526c70; border: 1px solid #dce8e4; border-radius: 9px; padding: 12px 15px; font-size: 12px; line-height: 1.8; margin: 14px 0; }
.notice.warn, .notice.warning { background: var(--warn-bg); border-color: #f3dfae; color: #8b6428; }
.notice.danger, .notice.error { background: var(--danger-bg); border-color: #f2c7c7; color: #a63d3d; }
.notice.success { background: #eff9f4; color: #376e54; border-color: #cde7d8; }
.metric-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.metric-row .card { margin: 0; }
.metric-row .stat-value { font-size: 30px; font-weight: 750; }
.stat-card { border-left: 0 !important; padding: 22px; }
.stat-card .stat-value { color: #1e4c51; margin-top: 9px; letter-spacing: -1px; }
.stat-card .stat-sub { font-size: 11px; margin-top: 10px; }
.quick-card { border: 1px solid var(--border); background: #fff; color: var(--text); border-radius: 12px; padding: 21px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 7px; transition: border-color .15s, transform .15s; text-decoration: none; }
.quick-card:hover { border-color: #83baae; transform: translateY(-2px); }
.quick-card h3, .quick-card strong { font-size: 14px; font-weight: 650; margin: 0; }
.quick-card p, .quick-card small, .quick-card > span:last-child { font-size: 12px; color: var(--muted); line-height: 1.8; }
.quick-card .icon { color: #168b7a; font-size: 22px; }
.split-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 20px; align-items: start; }
.split-layout > * { min-width: 0; }
.split-layout > .card + .card { margin-top: 0; }
.form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.checkbox-row { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; margin: 12px 0; }
.inline-check { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: #536a70; line-height: 1.6; font-weight: 400; margin-bottom: 0; cursor: pointer; }
.inline-check input, input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; padding: 0; flex-shrink: 0; accent-color: var(--primary); }
.drug-selector { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.drug-selector .search-box { flex: 1; min-width: 190px; }
.drug-selector .chip-list { width: 100%; }
.drug-selector input { flex: 1; min-width: 160px; }
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(245px, 1fr)); gap: 15px; margin-top: 17px; }
.catalog-item { display: flex; align-items: flex-start; gap: 12px; background: #fff; border: 1px solid var(--border); border-radius: 11px; padding: 18px; min-width: 0; margin-bottom: 0; cursor: pointer; }
.catalog-item:hover { border-color: #89bbaf; background: #fbfefc; }
.catalog-item:has(input:checked) { border-color: #52a58f; background: #f0faf5; }
.catalog-item input { margin-top: 3px; }
.catalog-item > span { flex: 1; min-width: 0; }
.catalog-item strong { font-size: 13px; color: var(--text); }
.catalog-item .small-text { display: block; margin-top: 6px; font-weight: 400; line-height: 1.8; }
.catalog-item h3, .catalog-item h4 { font-size: 15px; margin: 8px 0; }
.catalog-item p { font-size: 12px; line-height: 1.8; color: var(--muted); }
.catalog-item .btn { margin-top: 13px; }
.report-meta { display: flex; flex-wrap: wrap; gap: 7px 20px; color: var(--muted); font-size: 11px; border-bottom: 1px solid var(--border); padding-bottom: 13px; margin-bottom: 18px; }
.report-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.9; font-size: 13px; }
.report-text p + p { margin-top: 10px; }
.report-text ul, .report-text ol { padding-left: 20px; margin: 10px 0; }
.ai-panel { border: 1px solid #cfe4de; border-radius: 12px; padding: 21px; background: #f7fbf9; margin-top: 18px; }
.ai-panel h3, .ai-panel h4 { color: #28685f; margin-bottom: 10px; }
.ai-panel > p { font-size: 13px; line-height: 1.9; }
.ai-panel ul, .ai-panel ol { padding-left: 20px; font-size: 13px; line-height: 1.9; margin: 10px 0; }
.source-label { display: inline-block; font-size: 10px; letter-spacing: .3px; color: #748b8e; line-height: 1.7; margin-top: 9px; }
.review-status { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; background: #f5f8f7; border-radius: 9px; padding: 14px 16px; margin-bottom: 16px; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 30px; padding: 4px 10px; font-size: 11px; font-weight: 600; background: #edf3f2; color: #526f72; white-space: nowrap; }
.status-pill.ok, .status-pill.success, .status-pill.active { background: #e7f5ed; color: #2c7150; }
.status-pill.warn, .status-pill.warning, .status-pill.pending { background: #fff3d9; color: #9a6c27; }
.status-pill.danger, .status-pill.error { background: #fceaea; color: #b94d4d; }
.review-history { display: block; margin-top: 16px; border: 1px solid var(--border); border-radius: 11px; padding: 17px 18px; background: #fff; }
.review-history > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 15px; cursor: pointer; list-style: none; font-size: 13px; }
.review-history > summary::-webkit-details-marker { display: none; }
.review-history > summary::before { content: "›"; color: var(--primary); font-size: 20px; line-height: 1; font-weight: 600; }
.review-history[open] > summary::before { transform: rotate(90deg); }
.review-history > summary > .muted { margin-left: auto; font-size: 11px; }
.review-history[open] > summary { border-bottom: 1px solid var(--border); padding-bottom: 15px; margin-bottom: 17px; }
.review-history:not([open]) > :not(summary) { display: none; }
.review-history > summary:focus-visible { outline: 3px solid #55cbb9; outline-offset: 5px; border-radius: 3px; }
.review-history > article, .review-history > .card, .review-history > li { margin: 0; border: 1px solid var(--border); border-radius: 10px; padding: 17px; list-style: none; }
.review-history h4 { margin-bottom: 7px; font-size: 14px; }
.followup-item { border-bottom: 1px solid var(--border); padding: 16px 0; font-size: 13px; line-height: 1.8; }
.followup-item:last-child { border-bottom: 0; }
.followup-item p { color: var(--muted); margin-top: 5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.followup-item strong { color: #3e6265; }
.notification-banner { display: flex; align-items: center; justify-content: space-between; gap: 15px; flex-wrap: wrap; background: #eaf5f1; border: 1px solid #cce5dc; border-radius: 10px; padding: 14px 18px; margin-bottom: 16px; color: #396b5d; font-size: 12px; }
.notification-banner p { line-height: 1.8; }
.toast-stack { position: fixed; right: 24px; bottom: 24px; z-index: 100; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; max-width: min(400px, calc(100vw - 32px)); pointer-events: none; }
.toast { background: #173f48; color: #fff; border: 1px solid #416770; border-radius: 10px; padding: 14px 18px; box-shadow: 0 8px 28px rgba(15, 43, 50, .18); font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; pointer-events: auto; animation: toast-in .2s ease-out; }
.toast.error, .toast.danger { background: #8b393c; border-color: #ad5c5c; }
.empty { border: 1px dashed var(--border); border-radius: 10px; background: #fafcfb; font-size: 13px; }
.ddi-main { min-width: 0; }
.ddi-reason, .ddi-suggestion { overflow-wrap: anywhere; }
.ddi-card { box-shadow: none; }
.suggest:empty { display: none; }
.suggest-item { width: 100%; border: 0; background: #fff; color: var(--text); text-align: left; font-family: inherit; font-size: 13px; gap: 12px; border-bottom: 1px solid #f0f4f3; }
.suggest-item:hover, .suggest-item:focus-visible { background: var(--primary-light); }
.suggest-item:last-child { border-bottom: 0; }
.report-divider { height: 1px; border: 0; background: var(--border); margin: 22px 0; }
.reminder-item { flex-wrap: wrap; gap: 14px; padding: 16px; }
.reminder-item .r-time { font-size: 22px; width: 65px; }
.reminder-item .r-body { min-width: 160px; }
.reminder-item .r-meta { line-height: 1.8; }
th { background: #f5f8f7; font-size: 11px; }
td { font-size: 12px; vertical-align: top; }
th, td { padding: 12px; }
.table-wrap { border: 1px solid var(--border); border-radius: 9px; }
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap input, .table-wrap select { min-width: 120px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 1150px) {
  .workspace-hero { padding: 28px; }
  .sidebar { width: 226px; }
  .topbar { padding-left: 24px; padding-right: 24px; }
  .topbar-actions { gap: 8px; }
  .topbar-actions .model-state { max-width: 160px; }
  .content { padding-left: 24px; padding-right: 24px; }
  .split-layout { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .metric-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { align-items: flex-start; }
  .topbar-leading { padding-top: 4px; }
  .topbar-actions { max-width: 55%; }
  .topbar-actions .status-dot { display: none; }
}
@media (max-width: 720px) {
  .mobile-menu { display: inline-grid; place-items: center; }
  .sidebar { display: flex; position: fixed; left: 0; top: 0; width: 260px; height: 100dvh; z-index: 50; transition: transform .2s ease; box-shadow: 14px 0 40px rgba(16, 44, 50, .15); }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(16, 37, 43, .35); z-index: 40; pointer-events: none; }
  .topbar { padding: 13px 16px; align-items: center; flex-wrap: wrap; gap: 12px; }
  .topbar-leading { padding-top: 0; }
  .topbar-actions { max-width: none; width: 100%; justify-content: flex-start; gap: 8px; }
  .topbar-actions .model-state { max-width: none; margin-right: auto; font-size: 10px; }
  .topbar-actions select { max-width: 145px; font-size: 11px; }
  .topbar-actions #refreshStatus { padding: 6px 8px; font-size: 10px; }
  .page-title { font-size: 16px; }
  .content { padding: 18px 16px 24px; }
  .workspace-hero { padding: 25px 23px; border-radius: 12px; gap: 20px; }
  .workspace-hero h1, .workspace-hero h2 { font-size: 24px; }
  .workspace-hero p { font-size: 12px; }
  .hero-actions { width: 100%; }
  .metric-row { gap: 11px; margin-bottom: 18px; }
  .metric-row .stat-card { padding: 17px; }
  .metric-row .stat-value { font-size: 26px; }
  .stat-card .stat-label, .stat-card .stat-sub { font-size: 10px; }
  .card { padding: 18px; }
  .section-heading { margin-top: 21px; }
  .section-heading h2 { font-size: 15px; }
  .catalog-grid { grid-template-columns: 1fr; }
  .form-actions .btn { flex: 1; }
  .global-note { padding: 0 16px 24px; font-size: 10px; }
  .toast-stack { right: 16px; bottom: 16px; }
  .report-meta { gap: 6px 12px; }
  .ddi-card { padding: 13px; gap: 10px; flex-wrap: wrap; }
  .flow-col { min-width: 190px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* 手机工作台：抽屉导航、单手操作与安全区 */
.mobile-drawer-close, .nav-backdrop, .mobile-bottom-nav { display: none; }
html { -webkit-text-size-adjust: 100%; }
.content, .card, .ai-panel, .review-history, .table-wrap { min-width: 0; }

@media (max-width: 720px) {
  :root { --mobile-nav-height: 64px; }
  html { scroll-padding-top: 132px; }
  body { font-size: 14px; }
  body.nav-open { overflow: hidden; }
  body.nav-open::after { content: none; }
  .app { min-height: 100svh; width: 100%; }
  .main { width: 100%; min-width: 0; }
  .sidebar {
    width: min(304px, calc(100vw - 48px));
    height: 100vh; height: 100dvh;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: 60; visibility: hidden; overscroll-behavior: contain;
    transition: transform .2s ease, visibility 0s .2s;
  }
  body.nav-open .sidebar { visibility: visible; transition-delay: 0s; }
  .sidebar .brand { padding: 18px 14px; gap: 10px; }
  .sidebar .brand-text { flex: 1; min-width: 0; }
  .sidebar .brand-text h1 { font-size: 14px; letter-spacing: 0; }
  .sidebar .logo { width: 35px; height: 35px; font-size: 19px; border-radius: 10px; }
  .mobile-drawer-close {
    display: grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0;
    border: 0; border-radius: 10px; background: #214f5b; color: #d7eeed;
    font-size: 29px; line-height: 1; cursor: pointer;
  }
  .nav { padding: 10px; }
  .nav-title { padding-top: 13px; font-size: 11px; }
  .nav-item { min-height: 46px; padding: 11px 13px; font-size: 14px; }
  .nav-item .icon { font-size: 16px; }
  .sidebar-footer { padding: 16px; }
  .nav-backdrop {
    position: fixed; inset: 0; z-index: 50; border: 0; padding: 0;
    background: rgba(12, 34, 40, .46); cursor: pointer;
  }
  body.nav-open .nav-backdrop { display: block; }
  .topbar {
    min-height: 0; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
    gap: 8px; box-shadow: 0 2px 10px rgba(20, 52, 59, .035);
  }
  .topbar-leading { width: 100%; gap: 10px; }
  .mobile-menu { width: 44px; height: 44px; border-radius: 10px; font-size: 20px; flex-shrink: 0; }
  .page-title { white-space: normal; overflow-wrap: anywhere; font-size: 17px; line-height: 1.4; }
  .topbar-actions {
    display: grid; grid-template-columns: minmax(60px, 1fr) minmax(108px, 1.45fr) 64px;
    gap: 8px; width: 100%; align-items: center;
  }
  .topbar-actions #serviceStatus { grid-column: 1; grid-row: 1; min-width: 0; margin: 0; font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
  .topbar-actions #activeAccount { grid-column: 2; grid-row: 1; width: 100%; min-width: 0; max-width: none; min-height: 44px; font-size: 16px; padding: 8px 22px 8px 9px; }
  .topbar-actions #refreshStatus { grid-column: 3; grid-row: 1; min-height: 44px; padding: 8px 5px; font-size: 12px; line-height: 1.35; white-space: normal; }
  .content { width: 100%; max-width: 100%; padding: 16px 14px 22px; }
  .connection-notice { padding: 14px 14px 0; }
  .card { padding: 18px 16px; max-width: 100%; }
  .card h3 { flex-wrap: wrap; gap: 8px; font-size: 16px; line-height: 1.6; }
  .card h3 .tag { margin-left: 0; }
  .card h4 { font-size: 14px; line-height: 1.7; }
  .card p, .card li, .ddi-title, .report-meta { overflow-wrap: anywhere; }
  .card ul, .card ol { padding-left: 20px; line-height: 1.85; }
  .card > p.muted { font-size: 13px; line-height: 1.85; }
  .card input, .card select, .card textarea { min-width: 0; min-height: 46px; font-size: 16px; line-height: 1.5; }
  .card textarea { min-height: 112px; padding: 12px; }
  .card input[type="checkbox"], .card input[type="radio"] { min-height: 20px; width: 20px; height: 20px; }
  .card label { font-size: 13px; margin-bottom: 8px; }
  .card .btn, .card .btn.small, .connection-notice .btn { min-height: 44px; padding: 11px 14px; font-size: 14px; white-space: normal; line-height: 1.5; text-decoration: none; }
  .toolbar { align-items: stretch; gap: 10px; }
  .toolbar > input, .toolbar > select, .toolbar > .search-box, .toolbar > .btn { width: 100%; max-width: 100%; min-width: 0; flex: 1 1 100%; }
  .toolbar .search-box { min-width: 0; }
  .form-actions { width: 100%; align-items: stretch; gap: 10px; }
  .form-actions > select { flex: 1 1 100%; }
  .form-actions > .btn { flex: 1 1 125px; min-width: 0; }
  .workspace-hero { padding: 24px 20px; margin-bottom: 16px; }
  .workspace-hero h2 { font-size: 25px; letter-spacing: -.5px; }
  .workspace-hero p { font-size: 13px; }
  .workspace-hero .eyebrow { font-size: 9px; letter-spacing: 1.2px; }
  .hero-actions .btn { min-height: 46px; font-size: 14px; }
  .hero-actions .status-pill { font-size: 11px; white-space: normal; }
  .metric-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .metric-row .stat-card { padding: 18px 14px; }
  .stat-card .stat-label, .stat-card .stat-sub { font-size: 11px; line-height: 1.65; }
  .metric-row .stat-value { font-size: 28px; }
  .section-heading { flex-wrap: wrap; margin-top: 8px; gap: 10px; }
  .quick-card { min-height: 116px; padding: 19px; }
  .quick-card strong { font-size: 15px; }
  .quick-card > span:last-child { font-size: 13px; }
  .table-wrap { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
  .table-wrap table { min-width: 560px; }
  .table-wrap th, .table-wrap td { padding: 12px; font-size: 13px; line-height: 1.7; }
  .table-wrap th { white-space: nowrap; }
  .info-grid .info-item .k { font-size: 12px; }
  .info-grid .info-item .v { font-size: 14px; line-height: 1.7; word-break: normal; overflow-wrap: anywhere; }
  .alert { padding: 14px; font-size: 14px; line-height: 1.8; }
  .alert > div { min-width: 0; }
  .alert strong { font-size: 14px; }
  .notice, .source-label, .small-text { font-size: 12px; line-height: 1.85; letter-spacing: 0; }
  .source-label { max-width: 100%; }
  .ddi-card { padding: 14px; }
  .ddi-card .ddi-title { font-size: 15px; line-height: 1.7; }
  .ddi-card .ddi-reason { font-size: 14px; line-height: 1.85; }
  .ai-panel { padding: 16px; }
  .ai-panel > p, .report-text, .ai-panel ul, .ai-panel ol { font-size: 14px; line-height: 1.9; }
  .report-meta { font-size: 12px; gap: 8px; line-height: 1.8; }
  .report-meta > span { max-width: 100%; min-width: 0; }
  .status-pill { max-width: 100%; white-space: normal; line-height: 1.5; }
  .review-history { padding: 15px 13px; }
  .review-history > summary { min-height: 44px; gap: 8px; }
  .review-history > summary > b { flex: 1 1 calc(100% - 28px); font-size: 14px; overflow-wrap: anywhere; }
  .review-history > summary > .muted { margin-left: 0; font-size: 11px; }
  .review-history .form-actions { flex-direction: column; }
  .review-history .form-actions > * { flex: 0 0 auto; width: 100%; }
  .reminder-item { padding: 15px 12px; gap: 12px; }
  .reminder-item .r-time { width: 62px; flex-shrink: 0; font-size: 23px; }
  .reminder-item .r-body { min-width: 0; flex: 1; }
  .reminder-item .r-meta { font-size: 12px; overflow-wrap: anywhere; }
  .reminder-item .r-drug { font-size: 15px; overflow-wrap: anywhere; }
  .reminder-item .form-actions { flex: 1 1 100%; margin-top: 0; gap: 8px; }
  .reminder-item .form-actions .btn { flex: 1 1 0; padding: 10px 6px; font-size: 13px; }
  .catalog-item { min-height: 104px; padding: 17px; gap: 13px; }
  .catalog-item strong { font-size: 15px; }
  .catalog-item .small-text { font-size: 12px; }
  .suggest-item { min-height: 48px; font-size: 15px; padding: 12px; }
  .followup-item { font-size: 14px; }
  .flow-root { max-width: 100%; padding: 14px 18px; text-align: center; }
  .flow-col { flex: 1 1 100%; min-width: 0; max-width: 100%; }
  .flow-child { min-height: 44px; font-size: 14px; }
  .mobile-bottom-nav {
    position: fixed; inset: auto 0 0; z-index: 30;
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    min-height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px));
    padding: 5px max(8px, env(safe-area-inset-right, 0px)) calc(5px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
    border-top: 1px solid #dce8e5; background: rgba(255, 255, 255, .97);
    box-shadow: 0 -4px 20px rgba(20, 54, 57, .04);
    -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  }
  .mobile-nav-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-width: 0; min-height: 54px; gap: 4px; border-radius: 10px;
    font-size: 11px; font-weight: 500; line-height: 1.4; text-decoration: none;
    color: #718388; touch-action: manipulation;
  }
  .mobile-nav-item svg { display: block; width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
  .mobile-nav-item.active { background: #eaf6f1; color: #11766b; font-weight: 650; }
  .mobile-nav-item.active svg { stroke-width: 1.9; }
  .global-note { padding: 0 16px calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px) + 24px); font-size: 11px; }
  .toast-stack { right: 14px; left: 14px; bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px) + 12px); max-width: none; align-items: stretch; }
  .toast { padding: 13px 16px; font-size: 13px; }
}

@media (max-width: 359px) {
  .topbar { padding-left: 12px; padding-right: 12px; }
  .topbar-actions { grid-template-columns: minmax(54px, 1fr) minmax(102px, 1.35fr) 60px; gap: 6px; }
  .content { padding-left: 10px; padding-right: 10px; }
  .card { padding: 16px 13px; }
  .workspace-hero { padding: 22px 17px; }
  .workspace-hero h2 { font-size: 23px; }
  .hero-actions { gap: 10px; }
  .hero-actions .status-pill { width: 100%; justify-content: center; }
  .hero-actions .btn { width: 100%; }
  .form-actions > .btn { flex-basis: 100%; }
  .reminder-item .form-actions .btn { flex-basis: 0; }
}
@media (max-width: 720px) {
  .topbar-actions #configureAIAccess { grid-column: 1 / -1; grid-row: 2; width: 100%; min-height: 44px; font-size: 13px; }
  .access-token-panel input { min-height: 46px; font-size: 16px; }
  .access-token-panel .btn { min-height: 44px; }
}
