/* ========== 智慧中药房 - 全局样式 ========== */
:root {
  --primary: #1a6b3c;
  --primary-dark: #0f4d2a;
  --primary-light: #e8f5ee;
  --accent: #c9a96e;
  --accent-light: #f5eddf;
  --danger: #e74c3c;
  --warning: #f39c12;
  --info: #3498db;
  --success: #27ae60;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --bg: #f0f2f5;
  --card: #ffffff;
  --border: #e0e0e0;
  --sidebar-width: 240px;
  --header-height: 60px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 8px;
}

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

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

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

/* ========== 布局 ========== */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #fff;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: width 0.3s;
}

.sidebar-logo {
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
}

.sidebar-logo p {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 4px;
}

.sidebar-nav { padding: 10px 0; }

.nav-group-title {
  padding: 12px 20px 6px;
  font-size: 11px;
  text-transform: uppercase;
  opacity: 0.5;
  letter-spacing: 1px;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  transition: all 0.2s;
  border-left: 3px solid transparent;
  font-size: 14px;
}

.nav-item:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.nav-item.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-left-color: var(--accent);
}

.nav-item .icon {
  width: 20px;
  margin-right: 10px;
  text-align: center;
  font-size: 16px;
}

.nav-item .badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

/* ========== 顶部栏 ========== */
.header {
  height: var(--header-height);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-left h3 { font-size: 16px; font-weight: 600; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-light);
}

.breadcrumb span::after { content: " / "; opacity: 0.5; }
.breadcrumb span:last-child::after { content: ""; }
.breadcrumb span:last-child { color: var(--text); }

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  position: relative;
  transition: background 0.2s;
}

.header-btn:hover { background: var(--primary-light); }

.header-btn .dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--card);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

/* ========== 内容区 ========== */
.page-content {
  padding: 24px;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

.page-desc {
  color: var(--text-light);
  font-size: 13px;
  margin-bottom: 20px;
}

/* ========== 统计卡片 ========== */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  transition: transform 0.2s;
  border-left: 4px solid var(--primary);
}

.stat-card:hover { transform: translateY(-2px); }

.stat-card.accent { border-left-color: var(--accent); }
.stat-card.info { border-left-color: var(--info); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger { border-left-color: var(--danger); }
.stat-card.success { border-left-color: var(--success); }

.stat-card .stat-info h4 {
  font-size: 13px;
  color: var(--text-light);
  font-weight: 400;
  margin-bottom: 8px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.stat-card .stat-change {
  font-size: 12px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.green { background: var(--primary-light); color: var(--primary); }
.stat-icon.gold { background: var(--accent-light); color: var(--accent); }
.stat-icon.blue { background: #ebf5fb; color: var(--info); }
.stat-icon.orange { background: #fef5e7; color: var(--warning); }
.stat-icon.red { background: #fdedec; color: var(--danger); }

/* ========== 卡片/面板 ========== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.card-body { padding: 20px; }

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
  text-align: center;
}

/* ========== 网格布局 ========== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 20px; }

/* ========== 表格 ========== */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

table th, table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

table th {
  background: #f8f9fa;
  font-weight: 600;
  color: var(--text-light);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

table tbody tr:hover { background: #f8fffe; }

/* ========== 标签/徽章 ========== */
.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.tag-green { background: #e8f5ee; color: #1a6b3c; }
.tag-blue { background: #ebf5fb; color: #2980b9; }
.tag-orange { background: #fef5e7; color: #e67e22; }
.tag-red { background: #fdedec; color: #c0392b; }
.tag-gray { background: #f0f0f0; color: #666; }
.tag-gold { background: var(--accent-light); color: #8b6914; }

/* ========== 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
  font-family: inherit;
}

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

.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-accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }

/* ========== 表单 ========== */
.form-group {
  margin-bottom: 16px;
}

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

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
  background: #fff;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,107,60,0.1);
}

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
  display: flex;
  gap: 16px;
}

.form-row .form-group { flex: 1; }

.form-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ========== 进度条 ========== */
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

.progress-fill.green { background: var(--success); }
.progress-fill.blue { background: var(--info); }
.progress-fill.orange { background: var(--warning); }
.progress-fill.red { background: var(--danger); }
.progress-fill.primary { background: var(--primary); }

/* ========== 图表占位 ========== */
.chart-placeholder {
  height: 300px;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* 简易柱状图 */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 200px;
  padding: 0 20px;
}

.bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.bar {
  width: 100%;
  max-width: 40px;
  border-radius: 4px 4px 0 0;
  transition: height 0.6s ease;
  min-width: 24px;
}

.bar-label {
  font-size: 11px;
  color: var(--text-light);
  white-space: nowrap;
}

.bar-value {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}

/* 简易环形图 */
.donut-chart {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut-center {
  width: 100px;
  height: 100px;
  background: var(--card);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: absolute;
}

.donut-center .value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.donut-center .label {
  font-size: 11px;
  color: var(--text-light);
}

/* ========== 时间线 ========== */
.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 20px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -20px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--card);
  box-shadow: 0 0 0 2px var(--primary);
}

.timeline-item.warning::before { background: var(--warning); box-shadow: 0 0 0 2px var(--warning); }
.timeline-item.danger::before { background: var(--danger); box-shadow: 0 0 0 2px var(--danger); }

.timeline-time {
  font-size: 11px;
  color: var(--text-light);
}

.timeline-content {
  font-size: 13px;
  margin-top: 2px;
}

/* ========== 标签页 ========== */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.tab-item {
  padding: 10px 20px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-light);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

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

.tab-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ========== 搜索/过滤栏 ========== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 320px;
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}

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

.search-box::before {
  content: "🔍";
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: 0.5;
}

/* ========== 列表 ========== */
.list-item {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

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

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

.list-info { flex: 1; }
.list-info h4 { font-size: 14px; margin-bottom: 2px; }
.list-info p { font-size: 12px; color: var(--text-light); }

/* ========== 告警 ========== */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-warning { background: #fef9e7; border-left: 4px solid var(--warning); }
.alert-danger { background: #fdedec; border-left: 4px solid var(--danger); }
.alert-info { background: #ebf5fb; border-left: 4px solid var(--info); }
.alert-success { background: #e8f8f0; border-left: 4px solid var(--success); }

/* ========== 模态框 ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: var(--card);
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-size: 16px; }

.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: none;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover { background: var(--bg); }

.modal-body { padding: 20px; }

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ========== 流程步骤 ========== */
.steps {
  display: flex;
  align-items: center;
  margin-bottom: 24px;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.step::after {
  content: "";
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 12px;
}

.step:last-child::after { display: none; }

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.step.active .step-num { background: var(--primary); color: #fff; }
.step.done .step-num { background: var(--success); color: #fff; }

.step-label { font-size: 13px; white-space: nowrap; }

/* ========== 登录页 ========== */
.login-page {
  min-height: 100vh;
  display: flex;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, #2d8659 100%);
}

.login-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  padding: 40px;
}

.login-left h1 {
  font-size: 36px;
  margin-bottom: 12px;
}

.login-left p {
  font-size: 16px;
  opacity: 0.8;
  max-width: 400px;
  text-align: center;
  line-height: 1.8;
}

.login-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 40px;
  max-width: 500px;
}

.login-feature {
  background: rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  backdrop-filter: blur(10px);
}

.login-feature .lf-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.login-feature h4 {
  font-size: 14px;
  margin-bottom: 4px;
}

.login-feature p {
  font-size: 12px;
  opacity: 0.7;
}

.login-right {
  width: 480px;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.login-form {
  width: 100%;
  max-width: 360px;
}

.login-form h2 {
  font-size: 24px;
  margin-bottom: 8px;
  color: var(--text);
}

.login-form .subtitle {
  color: var(--text-light);
  font-size: 14px;
  margin-bottom: 32px;
}

.login-form .form-group { margin-bottom: 20px; }

.login-form .form-control {
  padding: 12px 14px;
  font-size: 15px;
}

.login-form .btn-primary {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  margin-top: 8px;
}

.login-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  font-size: 13px;
}

/* ========== 看板大屏 ========== */
.dashboard-header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  padding: 24px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dashboard-header h2 { font-size: 22px; }
.dashboard-header p { opacity: 0.8; font-size: 14px; margin-top: 4px; }

.dashboard-time {
  text-align: right;
  font-size: 20px;
  font-weight: 600;
}

.dashboard-time .date {
  font-size: 13px;
  font-weight: 400;
  opacity: 0.8;
}

/* ========== 处方流转状态 ========== */
.flow-status {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 20px;
}

.flow-node {
  text-align: center;
  flex: 1;
}

.flow-node .node-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
}

.flow-node .node-label {
  font-size: 12px;
  color: var(--text-light);
}

.flow-node .node-value {
  font-size: 16px;
  font-weight: 700;
}

.flow-arrow {
  font-size: 20px;
  color: var(--border);
  flex-shrink: 0;
}

.node-circle.green { background: var(--primary-light); color: var(--primary); }
.node-circle.blue { background: #ebf5fb; color: var(--info); }
.node-circle.orange { background: #fef5e7; color: var(--warning); }
.node-circle.gold { background: var(--accent-light); color: #8b6914; }
.node-circle.red { background: #fdedec; color: var(--danger); }

/* ========== 响应式 ========== */
@media (max-width: 1200px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .grid-2, .grid-3, .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .login-page { flex-direction: column; }
  .login-right { width: 100%; }
  .login-left { padding: 30px 20px; }
  .login-features { grid-template-columns: 1fr; }
}

/* ========== 动画 ========== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.4s ease forwards; }

/* 辅助 */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-light); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.hidden { display: none; }
