/* =========================================================
   山医大二院 · 诊疗服务管理后台  —— 样式
   主题：医疗绿（主）/ 红（辅）/ 白（底）
   ========================================================= */

:root {
  --primary: #1C9C6B;          /* 医疗绿 - 主色 */
  --primary-dark: #157A53;
  --primary-light: #E8F5EF;
  --accent: #E0533D;           /* 红 - 警示/重要 */
  --accent-light: #FCEDEA;
  --bg: #F4F6F5;
  --card: #FFFFFF;
  --text: #1F2D28;
  --text-2: #6B7C75;
  --border: #E3E9E6;
  --font-size: 14px;

  --shadow-sm: 0 1px 3px rgba(31,45,40,0.06);
  --shadow: 0 4px 16px rgba(31,45,40,0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 232px;
}

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

html, body { height: 100%; }

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

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

/* ---------------- 登录界面 ---------------- */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  padding: 16px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  padding: 32px 28px;
}
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-logo h1 { font-size: 22px; color: var(--primary-dark); }
.login-logo p { font-size: 13px; color: var(--text-2); }
.login-form .form-group { margin-bottom: 16px; }
.login-error {
  background: var(--accent-light); color: var(--accent);
  padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 12px;
}
.login-hint { text-align: center; color: var(--text-2); font-size: 12px; margin-top: 14px; }

.logo-badge {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 20px; flex: none;
  box-shadow: var(--shadow-sm);
}

/* ---------------- 主框架 ---------------- */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w); flex: none;
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: transform .25s ease;
  z-index: 30;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px; border-bottom: 1px solid var(--border);
}
.sidebar-brand .brand-text { font-weight: 700; color: var(--primary-dark); font-size: 15px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); margin-bottom: 2px; cursor: pointer;
  font-size: 14px; transition: all .15s;
}
.nav-item:hover { background: var(--primary-light); color: var(--primary-dark); }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.nav-item .nav-icon { width: 20px; text-align: center; font-size: 16px; }
.sidebar-footer {
  padding: 12px 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  color: var(--text-2); font-size: 13px;
}

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: 56px; flex: none;
  background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 18px;
  box-shadow: var(--shadow-sm);
}
.topbar-title { font-weight: 700; font-size: 16px; }
.topbar-right { margin-left: auto; }
.topbar-badge {
  background: var(--primary-light); color: var(--primary-dark);
  padding: 6px 12px; border-radius: 20px; font-size: 13px; font-weight: 600;
}
.menu-toggle {
  display: none; background: none; border: none; font-size: 22px; color: var(--text);
}

.content { flex: 1; overflow-y: auto; padding: 22px; }

/* ---------------- 卡片 & 通用 ---------------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px;
}
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; flex-wrap: wrap; gap: 12px;
}
.page-head h2 { font-size: 19px; }
.page-head .sub { color: var(--text-2); font-size: 13px; margin-top: 2px; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.spacer { flex: 1; }

/* ---------------- 按钮 ---------------- */
.btn {
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 8px 16px; font-size: 14px; background: #fff; color: var(--text);
  transition: all .15s;
}
.btn:hover { filter: brightness(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--accent-light); color: var(--accent); border-color: var(--accent-light); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; padding: 11px; font-size: 15px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------------- 表单 ---------------- */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-2); font-weight: 600; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; background: #fff; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
.form-group textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
.form-row { display: flex; gap: 14px; }
.form-row .form-group { flex: 1; }
.form-hint { font-size: 12px; color: var(--text-2); margin-top: 4px; }
.checkbox-inline { display: flex; align-items: center; gap: 8px; }
.checkbox-inline input { width: auto; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: #fff; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px;
}
table.data th, table.data td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); }
table.data th { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; white-space: nowrap; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #FAFCFB; }
.cell-actions { white-space: nowrap; }
.cell-actions .btn { margin-right: 6px; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------------- 徽标/标签 ---------------- */
.tag {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600; line-height: 1.8;
}
.tag-green { background: var(--primary-light); color: var(--primary-dark); }
.tag-red { background: var(--accent-light); color: var(--accent); }
.tag-gray { background: #EEF1F0; color: var(--text-2); }
.tag-blue { background: #E7F0FB; color: #2F6BD0; }

.status-pending { color: var(--accent); font-weight: 600; }
.status-done { color: var(--primary); font-weight: 600; }
.status-over { color: var(--accent); font-weight: 600; }

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

/* ---------------- 仪表盘 ---------------- */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 22px;
}
.stat-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat-card .stat-icon {
  position: absolute; right: 14px; top: 14px; font-size: 26px; opacity: .18;
}
.stat-card .stat-value { font-size: 30px; font-weight: 700; color: var(--primary-dark); }
.stat-card .stat-label { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.stat-card.accent .stat-value { color: var(--accent); }

.dash-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 880px) { .dash-row { grid-template-columns: 1fr; } }

/* 纯 CSS 柱状图 */
.bar-chart { display: flex; align-items: flex-end; gap: 16px; height: 200px; padding: 10px 4px 0; }
.bar-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-fill {
  width: 60%; max-width: 46px; background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  border-radius: 8px 8px 0 0; transition: height .4s ease; min-height: 4px;
}
.bar-label { font-size: 12px; color: var(--text-2); margin-top: 8px; text-align: center; }
.bar-value { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 4px; }

/* ---------------- 弹窗 ---------------- */
.modal-root { position: fixed; inset: 0; z-index: 50; display: none; }
.modal-root.open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(31,45,40,.45); }
.modal {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: #fff; border-radius: 14px; box-shadow: 0 24px 70px rgba(0,0,0,.3);
  padding: 22px; animation: pop .18s ease;
}
.modal.wide { max-width: 680px; }
@keyframes pop { from { transform: translate(-50%, -46%) scale(.97); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h3 { font-size: 17px; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--text-2); line-height: 1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------------- Tabs ---------------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 9px 16px; font-size: 14px; color: var(--text-2);
  border-bottom: 2px solid transparent; cursor: pointer; font-weight: 600;
}
.tab:hover { color: var(--primary-dark); }
.tab.active { color: var(--primary-dark); border-bottom-color: var(--primary); }

/* ---------------- 详情块 ---------------- */
.detail-block { background: var(--bg); border-radius: var(--radius-sm); padding: 14px; white-space: pre-wrap; color: var(--text); font-size: 14px; }

/* ---------------- 空状态 ---------------- */
.empty { text-align: center; color: var(--text-2); padding: 40px 0; }

/* ---------------- 提示条 ---------------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 10px 20px; border-radius: 24px;
  font-size: 14px; z-index: 80; box-shadow: var(--shadow); opacity: 0; transition: opacity .2s;
}
.toast.show { opacity: 1; }

/* ---------------- 移动端 ---------------- */
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 25; }
@media (max-width: 820px) {
  .sidebar { position: fixed; top: 0; left: 0; height: 100%; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: block; }
  .overlay.show { display: block; }
  .content { padding: 14px; }
  .brand-text { display: none; }
}
