:root {
  --primary: #0f4c81;
  --primary-dark: #0a3558;
  --primary-light: #e8f2fa;
  --accent: #0d9488;
  --accent-light: #ecfdf5;
  --bg: #eef2f6;
  --bg-subtle: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #475569;
  --muted: #64748b;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --ok: #059669;
  --ok-bg: #ecfdf5;
  --sidebar-w: 248px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

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

a { color: var(--primary); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--primary-dark); text-decoration: none; }

/* —— Layout —— */
.layout { display: flex; min-height: 100vh; }

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

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

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(15, 76, 129, 0.25);
}

.brand-logo::before,
.brand-logo::after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 1px;
}

.brand-logo {
  position: relative;
}

.brand-logo::before {
  width: 3px;
  height: 16px;
}

.brand-logo::after {
  width: 16px;
  height: 3px;
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }

.brand-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.02em;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

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

.sidebar nav a {
  display: block;
  padding: 9px 12px;
  margin-bottom: 2px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar nav a:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.sidebar nav a.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.nav-group {
  margin: 14px 0 6px;
}

.nav-group-title {
  padding: 6px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.nav-sub {
  padding-left: 20px !important;
  font-size: 13px !important;
  font-weight: 400 !important;
}

.sidebar nav a.nav-logout {
  margin-top: 12px;
  padding: 10px 12px;
  border-top: 1px solid var(--border-light);
  color: var(--muted);
}

.sidebar nav a.nav-logout:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 40px;
  background: var(--bg);
}

.main-inner { max-width: 1280px; margin: 0 auto; }

/* —— Page header —— */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.page-header .page-desc {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted);
  font-weight: 400;
}

.page-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.user-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-secondary);
}

.user-meta::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}

/* —— Cards —— */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.card h2 {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
}

.card-head h2 { margin: 0; }

.card-foot {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
  font-size: 13px;
}

.hint, .form-hint {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 16px;
}

/* —— Stats —— */
.grid-3, .grid-4, .stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
  align-items: stretch;
}

.stat-grid--equal > .stat-link {
  display: flex;
  min-height: 0;
}

.stat-link--static {
  cursor: default;
  text-decoration: none;
  color: inherit;
}

.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, border-color 0.2s;
  flex: 1;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.stat-grid--equal .stat {
  min-height: 118px;
}

.stat-grid--text .stat {
  min-height: 108px;
}

.stat-grid--text .stat-body .label {
  font-size: 13px;
  margin-bottom: 8px;
}

.stat-grid--text .value {
  font-size: 30px;
}

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

.stat-body .sub {
  min-height: 18px;
  line-height: 1.4;
}

a.stat-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

a.stat-link:hover .stat {
  border-color: var(--primary-light);
  box-shadow: var(--shadow);
}

.stat-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.stat-icon--blue { background: var(--primary-light); color: var(--primary); }
.stat-icon--teal { background: var(--accent-light); color: var(--accent); }
.stat-icon--amber { background: var(--warning-bg); color: var(--warning); }
.stat-icon--slate { background: var(--bg-subtle); color: var(--text-secondary); }

.stat .label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 4px;
}

.stat .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.stat .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

/* —— Quick links —— */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.quick-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}

.quick-link:hover {
  background: var(--primary-light);
  border-color: #c7d9ea;
  color: var(--primary);
}

.quick-link strong {
  font-size: 13px;
  font-weight: 600;
}

.quick-link span {
  font-size: 11px;
  color: var(--muted);
}

.quick-link:hover span { color: var(--primary); opacity: 0.8; }

/* —— Alerts —— */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  border: 1px solid transparent;
  font-size: 13px;
}

.alert-warning {
  background: var(--warning-bg);
  border-color: #fcd34d;
  color: #92400e;
}

.alert-warning h2, .alert-warning h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
}

.alert-warning ul {
  margin: 8px 0;
  padding-left: 18px;
}

.alert-warning a { color: #b45309; font-weight: 500; }

.alert-danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.alert-actions {
  margin: 12px 0 0;
}

.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  border: 1px solid transparent;
}

.flash-success {
  background: var(--ok-bg);
  color: #065f46;
  border-color: #a7f3d0;
}

.flash-error {
  background: var(--danger-bg);
  color: #991b1b;
  border-color: #fecaca;
}

/* —— 右上角统一漂浮提示 —— */
.admin-toast-root {
  position: fixed;
  top: 18px;
  right: 22px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
  max-width: min(420px, calc(100vw - 32px));
}

.admin-toast {
  pointer-events: auto;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  border: 1px solid transparent;
  opacity: 0;
  transform: translateX(12px);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.admin-toast--visible {
  opacity: 1;
  transform: translateX(0);
}

.admin-toast--success {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}

.admin-toast--error {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.admin-toast--warning {
  background: #fffbeb;
  color: #92400e;
  border-color: #fcd34d;
}

.admin-toast--info {
  background: var(--card);
  color: var(--text-secondary);
  border-color: var(--border-light);
}

/* —— Tables —— */
.table-wrap { overflow-x: auto; margin: 0 -4px; }

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

th, td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

th {
  background: var(--bg-subtle);
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

tbody tr:hover td { background: #fafbfc; }

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

td.empty, tr.empty td {
  text-align: center;
  color: var(--muted);
  padding: 32px 14px;
}

/* —— Badges —— */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--ok-bg); color: var(--ok); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-muted { background: var(--bg-subtle); color: var(--muted); }

/* —— Buttons —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  line-height: 1.4;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
}

.btn-secondary {
  background: var(--card);
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

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

.btn-danger:hover { background: #b91c1c; color: #fff; }

.btn-sm { padding: 5px 11px; font-size: 12px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* —— Forms —— */
.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
}

.form-group input,
.form-group textarea,
.form-group select,
.filter-bar input,
.filter-bar select {
  width: 100%;
  max-width: 560px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--card);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
.filter-bar input:focus,
.filter-bar select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.12);
}

.form-group textarea { min-height: 100px; resize: vertical; max-width: 100%; }

.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border-light);
}

.filter-bar input,
.filter-bar select {
  width: auto;
  min-width: 140px;
  max-width: 220px;
}

/* —— Pagination（EMR 列表底栏，始终可见） —— */
.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
  font-size: 13px;
  color: var(--muted);
}

.pagination a {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text-secondary);
}

.pagination a:hover {
  background: var(--primary-light);
  border-color: #c7d9ea;
  color: var(--primary);
}

.emr-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--border-light, #e5e8ed);
  border-radius: 10px;
  background: linear-gradient(180deg, #fafbfc 0%, #f4f6f8 100%);
  font-size: 13px;
  color: var(--text-secondary, #475569);
}

.emr-pagination-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  line-height: 1.5;
}

.emr-pagination-info strong {
  color: var(--primary, #1677a8);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.emr-pagination-sep {
  color: var(--border, #cbd5e1);
}

.emr-pagination-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.emr-pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 7px 12px;
  border: 1px solid var(--border, #d8dee6);
  border-radius: 8px;
  background: #fff;
  color: var(--text-secondary, #475569);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  user-select: none;
}

.emr-pagination-btn:hover:not(.is-disabled) {
  background: var(--primary-light, #e8f3f8);
  border-color: #b8d4e6;
  color: var(--primary, #1677a8);
}

.emr-pagination-btn.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: #f1f3f5;
  color: var(--muted, #94a3b8);
}

.emr-pagination-current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--primary, #1677a8);
  color: #fff;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 2px rgba(22, 119, 168, 0.25);
}

@media (max-width: 640px) {
  .emr-pagination {
    flex-direction: column;
    align-items: stretch;
  }

  .emr-pagination-nav {
    justify-content: center;
  }

  .emr-pagination-btn {
    min-width: 56px;
    flex: 1;
  }
}

/* —— Login —— */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #e8f2fa 0%, #eef2f6 45%, #f1f5f9 100%);
}

.login-wrap { width: 100%; max-width: 420px; }

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-brand .brand-logo {
  margin: 0 auto 14px;
  width: 52px;
  height: 52px;
  border-radius: 14px;
}

.login-brand h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}

.login-brand p {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.login-box {
  background: var(--card);
  padding: 32px 28px;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.login-box .form-group input { max-width: 100%; }

.login-foot {
  margin-top: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.login-foot a { font-weight: 500; }

/* —— Misc —— */
.upload-thumb {
  max-width: 72px;
  max-height: 72px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  object-fit: cover;
  vertical-align: middle;
}

.text-muted { color: var(--muted); }
.text-link { font-size: 13px; font-weight: 500; }
.text-warn { color: var(--warning); }

.cell-break { max-width: 280px; word-break: break-all; }
.cell-break-wide { max-width: 400px; word-break: break-word; }
.cell-id { font-size: 12px; max-width: 160px; word-break: break-all; font-family: ui-monospace, monospace; }
.cell-narrow { width: 100px; }

.inline-form { display: inline; }

.revise-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.revise-form textarea {
  flex: 1;
  min-width: 240px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}

.btn-block { width: 100%; padding: 11px; }

code {
  font-size: 12px;
  padding: 2px 6px;
  background: var(--bg-subtle);
  border-radius: 4px;
  color: var(--primary);
}

.welcome-banner {
  background: linear-gradient(135deg, var(--primary) 0%, #1565a8 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 24px;
  box-shadow: 0 8px 24px rgba(15, 76, 129, 0.2);
}

.welcome-banner h2 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 600;
}

.welcome-banner p {
  margin: 0;
  font-size: 13px;
  opacity: 0.88;
}

/* —— Session detail —— */
.meta-list { margin: 0; }
.meta-list p { margin: 0 0 8px; font-size: 13px; }
.meta-list p:last-child { margin-bottom: 0; }
.meta-list strong { color: var(--text-secondary); font-weight: 500; }

.session-messages { display: flex; flex-direction: column; gap: 16px; }

.session-msg {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: var(--bg-subtle);
}

.session-msg--user {
  background: var(--primary-light);
  border-color: #c7d9ea;
}

.session-msg--assistant { background: var(--card); }

.session-msg-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.session-msg-body,
.session-think pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.session-think { margin-bottom: 10px; }

.session-think summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.session-think pre {
  color: var(--muted);
  font-size: 12px;
  background: var(--bg-subtle);
  padding: 10px;
  border-radius: var(--radius-sm);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.detail-item {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.detail-item .label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.detail-item .value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.code-block {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-subtle);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  max-height: 360px;
  overflow: auto;
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid var(--border-light);
  font-family: inherit;
  color: var(--text-secondary);
}

.code-block--error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
  max-height: 480px;
}

.card-section-title {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 700;
  color: #1e3a5f;
}

.card--warn {
  border-color: #fecaca;
  background: linear-gradient(180deg, #fff 0%, #fffbfb 100%);
}

.session-messages--compact .session-msg {
  margin-bottom: 12px;
}

.session-messages--compact .session-msg-body {
  max-height: 240px;
  overflow: auto;
}

/* —— Analyze workspace —— */
.analyze-workspace { padding-bottom: 18px; }

.analyze-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}

.analyze-status-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.analyze-panels {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.analyze-panel summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.analyze-panel--content h2 {
  font-size: 14px;
  margin: 0 0 10px;
}

.analyze-stream {
  margin: 0;
  min-height: 120px;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.65;
  font-family: inherit;
  color: var(--text-secondary);
}

.analyze-foot {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

@media (max-width: 960px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar nav {
    padding: 8px 12px 12px;
  }
  .sidebar nav a {
    white-space: normal;
  }
  .nav-group { margin: 10px 0 4px; }
  .sidebar nav a.nav-logout { margin-top: 8px; }
  .main { padding: 20px 16px 32px; }
}

/* —— 病历档案页 —— */
.case-cover {
  background: linear-gradient(135deg, #0d9488 0%, #0891b2 55%, #0284c7 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
}

.case-cover-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.case-cover h1 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.case-cover-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  font-size: 14px;
  opacity: 0.95;
}

.case-cover-meta span strong { font-weight: 600; }

.case-status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.case-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 960px) {
  .case-grid { grid-template-columns: 1fr; }
}

.case-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}

.case-panel h2 {
  font-size: 15px;
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary-light);
  color: var(--primary);
}

.case-form .form-row {
  margin-bottom: 12px;
}

.case-form label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.case-form input,
.case-form textarea,
.case-form select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.case-form textarea { min-height: 72px; resize: vertical; }

.case-timeline { position: relative; padding-left: 4px; }

.case-doc {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
  background: var(--surface);
}

.case-doc-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-light);
}

.case-doc-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}

.case-doc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.case-doc-body { padding: 16px 18px; }

.case-doc-section {
  margin-bottom: 14px;
}

.case-doc-section:last-child { margin-bottom: 0; }

.case-doc-section h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 6px;
}

.case-doc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border-light);
  background: #fafbfc;
}

.case-reassign {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  margin-top: 8px;
}

.case-reassign select,
.case-reassign input {
  min-width: 160px;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.indicator-abnormal { color: var(--danger); font-weight: 600; }

.case-confirm-box {
  background: var(--ok-bg);
  border: 1px solid #a7f3d0;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  margin-top: 12px;
}

.case-add-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.add-doc-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  padding: 4px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.add-doc-tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.add-doc-tab:hover { color: var(--primary); }

.add-doc-tab.active {
  background: var(--card);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.add-doc-pane .admin-modal-footer.add-doc-footer {
  margin: 16px -22px 0;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-subtle);
}

.admin-form-modal .admin-modal-header .hint {
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 900px) {
  .case-add-grid { grid-template-columns: 1fr; }
}

.case-add-form {
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: var(--bg-subtle);
}

.case-add-form h3 {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--primary);
}

.case-doc-group { margin-bottom: 20px; }

.case-doc-group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
}

.case-doc-group-head--valid {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.case-doc-group-head--suspected {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.case-doc-group-head--invalid {
  background: #f3f4f6;
  color: #4b5563;
  border: 1px solid #d1d5db;
}

.case-doc--invalid {
  opacity: 0.82;
  border-color: #d1d5db;
  background: #fafafa;
}

.case-doc--suspected {
  border-color: #fcd34d;
}

.case-dup-box {
  margin-top: 10px;
  padding: 10px 12px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.65;
}

.case-dup-box a { color: #b45309; font-weight: 500; }

.admin-form-modal .admin-modal-panel--wide {
  max-width: 640px;
  width: calc(100% - 32px);
}

.admin-form-modal .admin-modal-header {
  padding: 18px 22px 0;
  border-bottom: none;
}

.admin-form-modal .admin-modal-body {
  padding: 12px 22px 0;
  max-height: min(70vh, 560px);
  overflow: auto;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}

.form-row--full { grid-column: 1 / -1; }

@media (max-width: 560px) {
  .form-grid-2 { grid-template-columns: 1fr; }
}

/* —— 统一确认弹窗 —— */
body.admin-modal-open { overflow: hidden; }

.admin-modal[hidden] { display: none !important; }

.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.admin-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.admin-modal-panel {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  animation: admin-modal-in 0.2s ease-out;
}

@keyframes admin-modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.admin-modal-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 22px 0;
}

.admin-modal-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.admin-modal-icon--primary {
  background: linear-gradient(145deg, var(--primary-light), #dbeafe);
  color: var(--primary);
}

.admin-modal-icon--accent {
  background: linear-gradient(145deg, var(--accent-light), #ccfbf1);
  color: var(--accent);
}

.admin-modal-icon--danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.admin-modal-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.admin-modal-body {
  padding: 14px 22px 20px 80px;
}

.admin-modal-body p {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-secondary);
}

.admin-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px 20px;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-light);
}

/* —— 档案查重工作台 —— */
.dup-scan-workspace { padding: 20px 22px; }

.dup-scan-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.dup-scan-status-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.dup-progress-wrap {
  height: 8px;
  background: var(--border-light);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}

.dup-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 999px;
  transition: width 0.35s ease;
  min-width: 0;
}

.dup-progress-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 20px;
}

.dup-panels { display: flex; flex-direction: column; gap: 16px; }

.dup-panel {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: var(--bg-subtle);
}

.dup-panel h2 {
  font-size: 14px;
  margin: 0 0 10px;
  color: var(--primary);
}

.dup-panel--thinking {
  border-color: #99f6e4;
  background: linear-gradient(180deg, #f0fdfa 0%, var(--bg-subtle) 100%);
}

.dup-live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-left: 6px;
  animation: dup-pulse 1.2s ease-in-out infinite;
  vertical-align: middle;
}

@keyframes dup-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.dup-thinking {
  margin: 0;
  min-height: 120px;
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.65;
  background: var(--card);
  border: 1px solid #99f6e4;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: inherit;
  color: var(--text-secondary);
}

.dup-log {
  margin: 0;
  min-height: 100px;
  max-height: 200px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.6;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: inherit;
  color: var(--text-secondary);
}

.dup-archive-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.dup-archive-item:last-child { border-bottom: none; }

.dup-foot {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.dup-error { margin-top: 14px; margin-bottom: 0; }

/* —— 医院病历首页 EMR —— */
.emr-page-header { margin-bottom: 16px; }
.emr-page-title { margin: 0; font-size: 18px; color: var(--muted); }

.emr-sheet {
  background: var(--card);
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.emr-sheet--invalid { border-color: #9ca3af; }
.emr-sheet--duplicate { border-color: #fcd34d; }

.emr-sheet-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  background: linear-gradient(90deg, #1e3a5f 0%, #2563eb 100%);
  color: #fff;
}

.emr-hospital-name { font-weight: 600; font-size: 14px; }
.emr-sheet-type { margin-left: 12px; font-size: 12px; opacity: 0.85; }
.emr-chart-no { font-size: 13px; font-weight: 600; letter-spacing: 0.02em; }

.emr-face-sheet { padding: 16px 18px 18px; }

.emr-patient-name-block {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 2px solid #1e3a5f;
}

.emr-label { font-size: 12px; color: var(--muted); }
.emr-patient-name { font-size: 22px; font-weight: 700; color: #1e3a5f; }
.emr-face-badges { display: flex; flex-wrap: wrap; gap: 6px; }

.emr-demo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.emr-demo-table th,
.emr-demo-table td {
  border: 1px solid #e2e8f0;
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}

.emr-summary-head {
  vertical-align: top;
  white-space: nowrap;
}

.emr-ai-organize-btn {
  display: block;
  margin-top: 8px;
  width: 100%;
  max-width: 120px;
}

.case-user-link {
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}

.case-user-link:hover {
  text-decoration: underline;
}

/* —— 消息校准详情 —— */
.calib-detail {
  width: 100%;
}

.calib-meta { margin-bottom: 0; }

.calib-upload-ref {
  margin-top: 14px;
  padding: 12px 14px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.calib-workspace {
  margin-bottom: 32px;
  margin-top: 18px;
  width: 100%;
}

.calib-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
}

.calib-stack .calib-panel {
  margin-bottom: 0;
}

.calib-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  width: 100%;
  box-sizing: border-box;
}

.calib-panel--highlight {
  border-color: #bfdbfe;
  box-shadow: 0 1px 4px rgba(30, 58, 95, 0.06);
}

.calib-panel__head {
  padding: 12px 16px;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.calib-panel__head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #1e3a5f;
}

.calib-panel__hint {
  font-size: 11px;
  color: var(--muted);
}

.calib-readonly {
  margin: 0;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  color: var(--text-secondary);
  background: #fff;
}

.calib-readonly--full {
  max-height: none;
  overflow: visible;
}

.calib-readonly--think {
  font-size: 12px;
  background: #f8fafc;
  color: #475569;
  border-top: 1px solid var(--border-light);
}

.calib-prompt-list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.calib-prompt-list--full {
  max-height: none;
  overflow: visible;
}

.calib-prompt-item {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.calib-prompt-item--system {
  border-left: 3px solid #1e3a5f;
}

.calib-prompt-item--user {
  border-left: 3px solid #2563eb;
}

.calib-prompt-item--assistant {
  border-left: 3px solid #059669;
}

.calib-prompt-role {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-subtle);
  color: var(--muted);
}

.calib-prompt-text {
  margin: 0;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, Consolas, monospace;
}

.calib-prompt-text--full {
  max-height: none;
  overflow: visible;
}

.calib-original-fold {
  margin: 0 16px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border-light);
}

.calib-original-fold summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 8px;
}

.calib-field-label {
  display: block;
  padding: 12px 16px 6px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}

.calib-required { color: #dc2626; }

.calib-textarea {
  display: block;
  width: calc(100% - 32px);
  margin: 0 16px 16px;
  padding: 12px 14px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.65;
  font-family: inherit;
  resize: vertical;
  min-height: 120px;
  box-sizing: border-box;
}

.calib-textarea:focus {
  outline: none;
  border-color: #1e3a5f;
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.12);
}

.calib-textarea--think {
  font-size: 13px;
  background: #f8fafc;
}

.calib-textarea--note {
  min-height: 72px;
}

.calib-form-actions {
  display: flex;
  gap: 12px;
  padding: 4px 0 8px;
}

.calib-form-actions .btn-lg {
  padding: 11px 28px;
  font-weight: 600;
}

.calib-empty { padding: 16px; }

.calib-log-table { font-size: 12px; }

/* —— AI 档案整理弹窗（医院病历风格） —— */
.organize-modal {
  padding: 20px 24px;
}

.organize-modal__panel {
  max-width: 820px;
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(30, 58, 95, 0.04);
}

.organize-modal__banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px 18px;
  background: linear-gradient(105deg, #1e3a5f 0%, #1d4ed8 52%, #2563eb 100%);
  color: #fff;
  border-bottom: 3px solid #0f2744;
}

.organize-modal__banner-main {
  flex: 1;
  min-width: 0;
}

.organize-modal__eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.88;
  margin-bottom: 6px;
}

.organize-modal__title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.organize-modal__subtitle {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  opacity: 0.92;
  max-width: 520px;
}

.organize-modal__close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.organize-modal__close:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.45);
}

.organize-modal__body {
  padding: 22px 24px 8px;
  background: #f8fafc;
  max-height: min(68vh, 560px);
  overflow-y: auto;
}

.organize-scope-card {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 22px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  border-left: 4px solid #1e3a5f;
}

.organize-scope-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.organize-scope-label {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.organize-scope-value {
  font-size: 13px;
  font-weight: 500;
  color: #1e293b;
  line-height: 1.45;
}

.organize-rule-block {
  margin-bottom: 18px;
}

.organize-rule-label {
  display: block;
  margin-bottom: 10px;
}

.organize-rule-label__title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #1e3a5f;
  margin-bottom: 2px;
}

.organize-rule-label__hint {
  display: block;
  font-size: 12px;
  color: #64748b;
  line-height: 1.45;
}

.organize-select-wrap {
  position: relative;
}

.organize-select-wrap::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -6px;
  border-right: 2px solid #475569;
  border-bottom: 2px solid #475569;
  transform: rotate(45deg);
  pointer-events: none;
}

.organize-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 13px 44px 13px 16px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  color: #0f172a;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  line-height: 1.4;
}

.organize-select:hover {
  border-color: #94a3b8;
  background: #fefefe;
}

.organize-select:focus {
  outline: none;
  border-color: #1e3a5f;
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.14);
}

.organize-select:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  background: #f1f5f9;
}

.organize-status-bar {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.55;
  background: #fff;
  border: 1px solid #e2e8f0;
  color: #475569;
}

.organize-status-bar[hidden] {
  display: none !important;
}

.organize-status-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: #94a3b8;
}

.organize-status-bar--active {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}

.organize-status-bar--active .organize-status-dot {
  background: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
  animation: organize-pulse 1.4s ease-in-out infinite;
}

.organize-status-bar--success {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}

.organize-status-bar--success .organize-status-dot {
  background: #10b981;
}

.organize-status-bar--error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.organize-status-bar--error .organize-status-dot {
  background: #ef4444;
}

@keyframes organize-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.organize-stream-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 8px;
}

.organize-stream-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  min-height: 0;
}

.organize-stream-card[hidden] {
  display: none !important;
}

.organize-stream-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid #e2e8f0;
}

.organize-stream-card__title {
  font-size: 12px;
  font-weight: 700;
  color: #1e3a5f;
  letter-spacing: 0.03em;
}

.organize-stream-card__tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #2563eb;
  background: #dbeafe;
  padding: 2px 8px;
  border-radius: 999px;
}

.organize-stream-box {
  margin: 0;
  min-height: 140px;
  max-height: 240px;
  overflow: auto;
  padding: 14px 16px;
  font-size: 12px;
  line-height: 1.65;
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", Consolas, monospace;
  color: #334155;
  background: #fff;
  white-space: pre-wrap;
  word-break: break-word;
}

.organize-modal__footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  padding: 16px 24px 20px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
}

.organize-modal__btn-cancel {
  min-width: 88px;
}

.organize-modal__btn-start {
  min-width: 120px;
  font-weight: 600;
  padding-left: 20px;
  padding-right: 20px;
  background: linear-gradient(180deg, #1d4ed8 0%, #1e3a5f 100%);
  border-color: #1e3a5f;
}

.organize-modal__btn-start:hover:not(:disabled) {
  background: linear-gradient(180deg, #2563eb 0%, #1e40af 100%);
}

.organize-modal__btn-start:disabled {
  opacity: 0.55;
}

@media (max-width: 720px) {
  .organize-modal {
    padding: 12px;
    align-items: flex-end;
  }

  .organize-modal__panel {
    max-width: 100%;
    border-radius: 12px 12px 0 0;
  }

  .organize-scope-card {
    grid-template-columns: 1fr;
  }

  .organize-stream-grid {
    grid-template-columns: 1fr;
  }

  .organize-modal__banner {
    padding: 16px 18px 14px;
  }

  .organize-modal__title {
    font-size: 17px;
  }

  .organize-modal__body {
    padding: 16px 18px 8px;
  }

  .organize-modal__footer {
    padding: 14px 18px 18px;
    flex-direction: column-reverse;
  }

  .organize-modal__footer .btn {
    width: 100%;
  }
}

.emr-demo-table th {
  width: 88px;
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  white-space: nowrap;
}

.emr-alert {
  margin: 0 18px 16px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.6;
}

.emr-alert--closed {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.emr-alert--note {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  color: #92400e;
}

.emr-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 1024px) {
  .emr-layout { grid-template-columns: 1fr; }
}

.emr-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.emr-section-head h2 {
  margin: 0;
  font-size: 15px;
  color: #1e3a5f;
}

.emr-record-group { margin-bottom: 20px; }

.emr-record-group-head {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border: 1px solid #e2e8f0;
  border-bottom: none;
}

.emr-record-group-head--valid { background: #ecfdf5; color: #065f46; }
.emr-record-group-head--suspected { background: #fffbeb; color: #92400e; }
.emr-record-group-head--invalid { background: #f3f4f6; color: #4b5563; }

.emr-record-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--card);
  border: 1px solid #e2e8f0;
}

.emr-record-table thead th {
  background: #f1f5f9;
  color: #475569;
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
}

.emr-record-table tbody td {
  padding: 10px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.emr-record-row--invalid { background: #fafafa; opacity: 0.9; }
.emr-record-row--suspected { background: #fffdf5; }

.emr-status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.emr-status-dot--valid { background: #10b981; }
.emr-status-dot--dup { background: #f59e0b; }
.emr-status-dot--invalid { background: #9ca3af; }

.emr-dup-inline {
  margin-top: 4px;
  font-size: 11px;
  color: #b45309;
  line-height: 1.4;
}

.emr-row-actions { white-space: nowrap; }
.emr-row-actions .btn { margin-right: 4px; }

.emr-detail-row td { padding: 0 !important; background: #f8fafc; }
.emr-detail-panel { padding: 12px 14px; font-size: 13px; }
.emr-detail-block { margin-bottom: 10px; }
.emr-detail-block p { margin: 4px 0 0; line-height: 1.6; }
.emr-detail-block ul { margin: 4px 0 0; padding-left: 18px; }

.emr-lab-mini {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
  font-size: 12px;
}

.emr-lab-mini th, .emr-lab-mini td {
  border: 1px solid #e2e8f0;
  padding: 4px 8px;
}

.emr-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #e2e8f0;
}

.emr-reassign-inline {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.emr-reassign-inline select,
.emr-reassign-inline input {
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.emr-aside-card {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 14px;
}

.emr-aside-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: #1e3a5f;
}

.emr-mark-summary {
  margin: 0 0 12px;
  font-size: 13px;
}

.emr-mark-summary dt {
  color: var(--muted);
  font-size: 11px;
  margin-top: 6px;
}

.emr-mark-summary dd { margin: 2px 0 0; }

.emr-empty { padding: 24px; text-align: center; }

/* —— 档案列表 · 医生习惯检索区 —— */
.emr-search-panel {
  margin-bottom: 18px;
  padding: 16px 18px 14px;
  background: linear-gradient(180deg, #f8fbff 0%, #f4f8fc 100%);
  border: 1px solid #d4e3f2;
  border-radius: var(--radius);
}

.emr-search-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 16px;
  margin-bottom: 14px;
}

.emr-search-title {
  font-size: 14px;
  font-weight: 700;
  color: #1e3a5f;
  letter-spacing: 0.02em;
}

.emr-search-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.emr-search-hint code {
  font-size: 11px;
  padding: 1px 5px;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: 4px;
}

.emr-search-grid {
  display: grid;
  gap: 12px 14px;
  margin-bottom: 14px;
}

.emr-search-grid--case {
  grid-template-columns: minmax(160px, 200px) repeat(3, minmax(0, 1fr));
}

.emr-search-grid--user {
  grid-template-columns: minmax(180px, 220px) minmax(120px, 160px) minmax(0, 1fr);
}

.emr-search-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}

.emr-search-field input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border: 1px solid #c5d5e8;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.emr-search-field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.12);
}

.emr-chart-input {
  display: flex;
  align-items: stretch;
  border: 1px solid #93b4d4;
  border-radius: var(--radius-sm);
  background: #fff;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(15, 76, 129, 0.06);
}

.emr-chart-input:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.12);
}

.emr-chart-prefix {
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 14px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #1e3a5f;
  background: #e8f0fa;
  border-right: 1px solid #c5d5e8;
  white-space: nowrap;
}

.emr-chart-input input {
  flex: 1;
  min-width: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  letter-spacing: 0.04em;
}

.emr-chart-input input:focus {
  box-shadow: none;
}

.emr-search-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px dashed #c5d5e8;
}

.emr-search-toolbar-spacer {
  flex: 1;
}

.emr-search-toolbar-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  flex: 1;
  min-width: 0;
}

.emr-search-toolbar--solo {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.emr-search-grid--inline {
  grid-template-columns: minmax(0, 1fr);
  max-width: 640px;
}

.emr-search-segments {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.emr-search-segments-label {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  margin-right: 4px;
}

.emr-search-segment {
  position: relative;
  cursor: pointer;
}

.emr-search-segment input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.emr-search-segment span {
  display: inline-block;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  background: #fff;
  border: 1px solid #c5d5e8;
  border-radius: 999px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.emr-search-segment:hover span {
  border-color: #93b4d4;
  color: var(--primary);
}

.emr-search-segment.is-active span,
.emr-search-segment input:checked + span {
  background: var(--primary-light);
  border-color: #93c5fd;
  color: var(--primary);
}

.emr-search-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.emr-chart-code {
  font-size: 12px;
  font-weight: 600;
  color: #1e3a5f;
}

@media (max-width: 960px) {
  .emr-search-grid--case,
  .emr-search-grid--user,
  .emr-search-grid--inline {
    grid-template-columns: 1fr 1fr;
  }

  .emr-search-field--chart,
  .emr-search-field--phone,
  .emr-search-field--keyword {
    grid-column: 1 / -1;
  }

  .emr-search-toolbar-filters {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .emr-search-grid--case,
  .emr-search-grid--user,
  .emr-search-grid--inline {
    grid-template-columns: 1fr;
  }

  .emr-search-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .emr-search-toolbar-filters {
    flex-direction: column;
    align-items: flex-start;
  }

  .emr-search-actions {
    justify-content: flex-end;
  }
}

/* —— 首页概览 —— */
.dash-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #0f4c81 0%, #1565a8 55%, #1e7fc4 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 28px 30px;
  margin-bottom: 24px;
  box-shadow: 0 10px 28px rgba(15, 76, 129, 0.22);
}

.dash-hero-kicker {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.75;
}

.dash-hero-main h1 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.dash-hero-desc {
  margin: 0;
  font-size: 13px;
  opacity: 0.9;
  max-width: 520px;
  line-height: 1.55;
}

.dash-hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
  max-width: 360px;
}

.dash-badge {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  white-space: nowrap;
}

a.dash-badge:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.dash-badge--ok {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
}

.dash-badge--warn {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}

.dash-badge--amber {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fdba74;
}

.dash-badge--blue {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.dash-badge--muted {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.88);
  border-color: rgba(255, 255, 255, 0.2);
}

.dash-section {
  margin-bottom: 8px;
}

.dash-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.dash-section-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.dash-section-hint {
  font-size: 12px;
  color: var(--muted);
}

.dash-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
  margin-top: 8px;
}

.dash-main {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.dash-side {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.dash-side .quick-grid {
  grid-template-columns: 1fr 1fr;
}

.dash-shortcut-group {
  padding: 0 0 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border-light);
}

.dash-shortcut-group--last {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: none;
}

.dash-shortcut-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.dash-todo-list {
  display: flex;
  flex-direction: column;
}

.dash-todo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}

.dash-todo-item:first-child {
  padding-top: 0;
}

.dash-todo-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.dash-todo-item:hover {
  color: var(--primary);
}

.dash-todo-item:hover .dash-todo-id {
  background: var(--primary-light);
  color: var(--primary);
}

.dash-todo-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.dash-todo-id {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.dash-todo-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.dash-todo-item:hover .dash-todo-text {
  color: var(--primary);
}

.dash-todo-time {
  flex-shrink: 0;
  font-size: 12px;
}

.dash-scene-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dash-scene-item {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.dash-scene-item:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.dash-scene-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.dash-scene-meta {
  font-size: 12px;
  line-height: 1.45;
  word-break: break-all;
}

.dash-scene-empty {
  font-size: 13px;
  padding: 8px 0;
}

.site-settings-form .form-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  margin-bottom: 32px;
}

/* —— 网站设置 · 左右分栏 —— */
.settings-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  min-height: 560px;
}

.settings-tabs-wrap {
  height: 560px;
  position: sticky;
  top: 16px;
  flex-shrink: 0;
}

.settings-tabs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  padding: 10px;
  box-sizing: border-box;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow-y: auto;
}

.settings-tab {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}

.settings-tab:hover {
  background: var(--bg-subtle);
  color: var(--primary);
}

.settings-tab.active {
  background: var(--primary-light);
  border-color: #bfdbfe;
  color: var(--primary);
}

.settings-panels {
  min-width: 0;
  min-height: 560px;
}

.settings-panel {
  display: none;
  margin-bottom: 0;
  min-height: 560px;
  flex-direction: column;
}

.settings-panel.active {
  display: flex;
}

.settings-panel-body {
  flex: 1;
  min-height: 0;
}

.settings-panel-foot {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.settings-options-textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
}

.form-group--checkbox .checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  cursor: pointer;
}

.form-group--checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}

.form-group--checkbox .hint {
  margin: 8px 0 0;
}

@media (max-width: 900px) {
  .settings-layout,
  .settings-panels,
  .settings-tabs-wrap {
    min-height: 0;
    height: auto;
  }

  .settings-layout {
    grid-template-columns: 1fr;
  }

  .settings-tabs-wrap {
    position: static;
    height: auto;
  }

  .settings-tabs {
    flex-direction: row;
    flex-wrap: wrap;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .settings-tab {
    width: auto;
    flex: 1 1 auto;
  }

  .settings-panel {
    min-height: 0;
  }
}

/* —— 用户档案详情 · 档案状态行底色 —— */
.archive-status-table .archive-row--active td {
  background: #fff;
}

.archive-status-table .archive-row--duplicate td {
  background: #fffbeb;
}

.archive-status-table .archive-row--invalid td {
  background: #f1f5f9;
  color: #64748b;
}

.archive-status-table .archive-row--invalid .cell-break,
.archive-status-table .archive-row--invalid td {
  border-top-color: #e2e8f0;
}

.archive-status-table tbody tr.archive-row:hover td {
  filter: brightness(0.985);
}

.archive-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 4px 4px;
  font-size: 12px;
  color: var(--muted);
}

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

.archive-legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid var(--border-light);
  font-style: normal;
}

.archive-legend-swatch--active { background: #fff; }
.archive-legend-swatch--duplicate { background: #fffbeb; border-color: #fde68a; }
.archive-legend-swatch--invalid { background: #f1f5f9; border-color: #e2e8f0; }

@media (max-width: 1100px) {
  .dash-columns {
    grid-template-columns: 1fr;
  }

  .dash-side .quick-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

/* —— LLM Token 统计页 —— */
.token-stats-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.2fr);
  gap: 20px;
  margin-bottom: 20px;
}

.token-stats-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.token-stats-panel {
  margin-bottom: 20px;
}

.token-stats-panel .card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.token-stats-panel .card-head h2 {
  margin: 0;
  font-size: 16px;
}

/* 输入 / 输出构成 */
.token-io-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.token-io-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  margin: 0 -20px 16px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(22, 119, 168, 0.08) 0%, rgba(91, 141, 239, 0.06) 100%);
  border: 1px solid rgba(22, 119, 168, 0.12);
}

.token-io-hero-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--primary, #1677a8);
  letter-spacing: -0.02em;
}

.token-io-hero-label {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted, #64748b);
}

.token-io-hero-side {
  text-align: right;
  max-width: 180px;
}

.token-io-ratio {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.token-io-ratio-label {
  font-size: 12px;
  color: var(--text-muted, #64748b);
}

.token-io-ratio strong {
  font-size: 22px;
  color: var(--text, #1e293b);
}

.token-io-ratio-hint {
  margin: 6px 0 0;
  font-size: 11px;
  line-height: 1.4;
}

.token-io-stack {
  margin-bottom: 16px;
}

.token-io-stack-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
}

.token-io-stack-title {
  font-weight: 600;
  color: var(--text, #334155);
}

.token-io-bar {
  display: flex;
  width: 100%;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--border-light, #e8ebf0);
}

.token-io-bar--lg {
  height: 18px;
}

.token-io-bar--sm {
  height: 8px;
  margin: 8px 0 6px;
}

.token-io-bar-prompt {
  background: linear-gradient(90deg, #1677a8, #3d9cc8);
}

.token-io-bar-completion {
  background: linear-gradient(90deg, #5b8def, #8eb4ff);
}

.token-io-bar-caption {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted, #64748b);
}

.token-io-bar-caption span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.token-io-period-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.token-io-period-card {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-light, #e8ebf0);
  background: var(--surface-muted, #f9fafb);
}

.token-io-period-card--today {
  border-color: rgba(22, 119, 168, 0.28);
  background: linear-gradient(180deg, #fff 0%, rgba(22, 119, 168, 0.04) 100%);
}

.token-io-period-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.token-io-period-label {
  font-size: 12px;
  color: var(--text-muted, #64748b);
}

.token-io-period-head strong {
  font-size: 15px;
  color: var(--text, #1e293b);
}

.token-io-period-meta {
  font-size: 11px;
  line-height: 1.45;
}

.token-io-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.token-io-dot--prompt { background: #1677a8; }
.token-io-dot--completion { background: #5b8def; }

.token-io-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light, #e8ebf0);
}

.token-io-metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--border-light, #eef1f5);
}

.token-io-metric .label {
  font-size: 11px;
  color: var(--text-muted, #64748b);
}

.token-io-metric .value {
  font-size: 17px;
  font-weight: 700;
  color: var(--text, #1e293b);
  font-variant-numeric: tabular-nums;
}

.token-daily-panel .token-bar-chart {
  max-height: 560px;
}

.token-bar-chart--desc {
  padding-top: 2px;
}

.token-bar-row--today {
  background: rgba(22, 119, 168, 0.05);
  border-radius: 6px;
  margin: 0 -6px;
  padding: 2px 6px;
}

.token-bar-row--today .token-bar-label {
  color: var(--primary, #1677a8);
  font-weight: 600;
}

.token-bar-today-tag {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  font-size: 10px;
  font-style: normal;
  font-weight: 600;
  line-height: 16px;
  border-radius: 4px;
  color: #1677a8;
  background: rgba(22, 119, 168, 0.12);
  vertical-align: middle;
}

.token-bar-chart {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 520px;
  overflow: auto;
  padding-right: 4px;
}

.token-bar-chart--compact .token-bar-row {
  grid-template-columns: 42px 1fr 72px;
}

.token-bar-row {
  display: grid;
  grid-template-columns: 56px 1fr 88px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.token-bar-label {
  color: var(--text-muted, #64748b);
  font-variant-numeric: tabular-nums;
}

.token-bar-track {
  height: 8px;
  border-radius: 999px;
  background: #eef1f5;
  overflow: hidden;
}

.token-bar-track--inline {
  margin: 8px 0;
}

.token-bar-track--thin {
  flex: 1;
  min-width: 60px;
  height: 6px;
}

.token-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #1677a8, #4aa3cf);
  min-width: 2px;
  transition: width 0.2s ease;
}

.token-bar-fill--daily {
  background: linear-gradient(90deg, #0f6b96, #49a9d8);
}

.token-bar-fill--scene {
  background: linear-gradient(90deg, #1677a8, #6ec2e8);
}

.token-bar-fill--provider {
  background: linear-gradient(90deg, #3b6fd8, #7aa6ff);
}

.token-bar-value {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text, #334155);
}

.token-month-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.token-month-card {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border-light, #e8ebf0);
  background: linear-gradient(180deg, #fff 0%, #f9fafb 100%);
}

.token-month-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.token-month-label {
  font-size: 13px;
  color: var(--text-muted, #64748b);
}

.token-month-meta {
  font-size: 11px;
  line-height: 1.45;
}

.token-share-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
}

.token-share-cell span:last-child {
  width: 42px;
  text-align: right;
  font-size: 12px;
  color: var(--text-muted, #64748b);
}

@media (max-width: 1100px) {
  .token-stats-layout,
  .token-stats-columns {
    grid-template-columns: 1fr;
  }

  .token-io-period-grid {
    grid-template-columns: 1fr;
  }

  .token-io-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .token-io-hero {
    flex-direction: column;
    margin-left: 0;
    margin-right: 0;
  }

  .token-io-hero-side {
    text-align: left;
    max-width: none;
  }

  .token-io-ratio {
    align-items: flex-start;
  }

  .token-io-metrics {
    grid-template-columns: 1fr;
  }
}

