/* ===== 生物实验室管理平台 设计系统（自包含，无外部依赖） ===== */
:root {
  --primary: #0e9f6e;
  --primary-dark: #0b7d57;
  --primary-light: #e6f6f0;
  --sidebar-bg: #12312a;
  --sidebar-active: rgba(14, 159, 110, .25);
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #2563eb;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { text-decoration: none; color: inherit; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--sidebar-bg); color: #d1d5db; flex-shrink: 0; position: fixed; top: 0; bottom: 0; left: 0; overflow-y: auto; z-index: 20; }
.sidebar .logo { padding: 20px 18px; font-size: 17px; font-weight: 700; color: #fff; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .logo .logo-icon { width: 34px; height: 34px; border-radius: 8px; background: var(--primary); display: inline-flex; align-items: center; justify-content: center; font-size: 18px; }
.nav { padding: 12px 10px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 8px; margin-bottom: 2px; cursor: pointer; transition: background .15s, color .15s; font-size: 14px; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #6ee7b7; font-weight: 600; }
.nav-item .nav-ico { width: 20px; text-align: center; }
.nav-section { padding: 14px 14px 6px; font-size: 12px; color: #6b7f78; letter-spacing: 1px; }

.main { flex: 1; margin-left: 220px; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 58px; 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: 10; }
.topbar .page-title { font-size: 16px; font-weight: 600; }
.topbar .user-box { display: flex; align-items: center; gap: 12px; }
.topbar .user-name { font-weight: 600; }
.topbar .user-role { font-size: 12px; color: var(--primary); background: var(--primary-light); padding: 2px 8px; border-radius: 10px; }
.content { padding: 22px 24px; flex: 1; }

/* ---------- 卡片 ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }

/* ---------- 统计卡片 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; border-left: 4px solid var(--primary); }
.stat-card .stat-label { color: var(--text-muted); font-size: 13px; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat-card.warn { border-left-color: var(--warning); }
.stat-card.danger { border-left-color: var(--danger); }
.stat-card.info { border-left-color: var(--info); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th { text-align: left; padding: 10px 12px; background: #f9fafb; color: var(--text-muted); font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:hover { background: #f9fafb; }
.empty-tip { text-align: center; color: var(--text-muted); padding: 40px 0; }

/* ---------- 按钮 ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 7px; border: 1px solid transparent; cursor: pointer; font-size: 13.5px; transition: all .15s; background: #fff; touch-action: manipulation; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-warning { background: #f59e0b; color: #fff; border-color: #f59e0b; }
.btn-warning:hover { background: #d97706; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 徽章 ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #e5e7eb; color: #374151; }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* ---------- 班级标签与选择 ---------- */
.class-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.class-tag { display: inline-flex; align-items: center; gap: 2px; background: #dbeafe; color: #1e40af; border-radius: 20px; padding: 2px 4px 2px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.class-tag-x { border: none; background: transparent; color: #1e40af; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 4px; }
.class-tag-x:hover { color: var(--danger); }
.class-picker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px 12px; max-height: 260px; overflow-y: auto; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; }
.class-check { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
@media (max-width: 768px) { .class-picker { grid-template-columns: repeat(3, 1fr); } }

/* ---------- 表单 ---------- */
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.form-group label { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.form-group label .req { color: var(--danger); }
input[type=text], input[type=password], input[type=number], input[type=datetime-local], input[type=date], select, textarea {
  padding: 8px 11px; border: 1px solid var(--border); border-radius: 7px; font-size: 13.5px; font-family: inherit; background: #fff; color: var(--text); outline: none; transition: border .15s; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 72px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; min-width: 140px; }
.toolbar .spacer { flex: 1; }

/* ---------- 学科切换 Tab ---------- */
.subject-tabs { display: flex; gap: 6px; margin-bottom: 14px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.subject-tabs .tab { border: 1px solid var(--border); background: #fff; color: var(--text); padding: 6px 18px; border-radius: 6px; cursor: pointer; font-size: 14px; transition: all .15s; }
.subject-tabs .tab:hover { border-color: var(--primary); color: var(--primary); }
.subject-tabs .tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- 仪器名称自动补全 ---------- */
.ac-wrap { position: relative; }
.ac-list { position: absolute; top: calc(100% + 4px); left: 0; right: 0; display: none; max-height: 260px; overflow-y: auto; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 120; }
.ac-list.show { display: block; }
.ac-item { padding: 8px 11px; cursor: pointer; border-bottom: 1px solid #f1f3f5; }
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.active { background: #f0faf6; }
.ac-name { font-size: 13.5px; font-weight: 600; }
.ac-meta { margin-top: 2px; font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-code { margin-top: 2px; font-size: 12px; color: var(--primary); }
.ac-empty { padding: 10px 11px; font-size: 12.5px; color: var(--text-muted); }
.form-hint { font-size: 12px; line-height: 1.5; color: var(--text-muted); }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 12px; width: 560px; max-width: 100%; max-height: 90vh; overflow-y: auto; padding: 22px 24px; animation: pop .18s ease; }
.modal.modal-lg { width: 760px; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- Toast ---------- */
#toast-box { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 11px 18px; border-radius: 8px; color: #fff; font-size: 13.5px; box-shadow: 0 4px 12px rgba(0,0,0,.18); animation: slidein .2s ease; max-width: 340px; }
.toast.success { background: var(--primary); }
.toast.error { background: var(--danger); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 登录页 ---------- */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0b3d2e 0%, #0e9f6e 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 40px 38px; width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-card h1 { font-size: 22px; text-align: center; margin-bottom: 6px; }
.login-card .sub { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 26px; }
.login-logo { width: 60px; height: 60px; border-radius: 14px; background: var(--primary); color: #fff; font-size: 30px; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.login-btn { width: 100%; padding: 11px; font-size: 15px; justify-content: center; margin-top: 6px; }
.login-tip { margin-top: 16px; font-size: 12px; color: var(--text-muted); background: #f9fafb; border-radius: 8px; padding: 10px 12px; line-height: 1.7; }

/* ---------- 日历 ---------- */
.calendar { width: 100%; border-collapse: collapse; }
.calendar th { padding: 8px; text-align: center; color: var(--text-muted); font-size: 13px; }
.calendar td { border: 1px solid var(--border); height: 92px; vertical-align: top; padding: 6px; width: 14.28%; }
.calendar .day-num { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.calendar .today .day-num { background: var(--primary); color: #fff; border-radius: 50%; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; }
.cal-event { font-size: 11.5px; background: var(--primary-light); border-left: 3px solid var(--primary); padding: 3px 6px; border-radius: 4px; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.cal-head { display: flex; align-items: center; gap: 12px; }
.cal-head h3 { min-width: 110px; text-align: center; }

/* ---------- 图表 ---------- */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; }
.chart-box { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.chart-box h4 { font-size: 14px; margin-bottom: 14px; color: var(--text-muted); }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.chart-head h4 { margin-bottom: 0; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-row .bar-label { width: 90px; font-size: 12.5px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bar-track { flex: 1; background: #f3f4f6; border-radius: 5px; height: 18px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: var(--primary); border-radius: 5px; min-width: 2px; transition: width .4s; }
.bar-row .bar-val { width: 46px; font-size: 12.5px; font-weight: 600; }

/* ---------- 描述列表（详情弹窗） ---------- */
.desc-list { display: grid; grid-template-columns: 96px 1fr; row-gap: 10px; column-gap: 12px; font-size: 13.5px; }
.desc-list dt { color: var(--text-muted); }
.desc-list dd { word-break: break-all; white-space: pre-wrap; }

.notice-card { border-left: 4px solid var(--info); }
.notice-card .notice-meta { color: var(--text-muted); font-size: 12.5px; margin: 6px 0 10px; display: flex; gap: 16px; flex-wrap: wrap; }
.notice-card .notice-content { white-space: pre-wrap; line-height: 1.7; }

.overdue-row { background: #fff7ed !important; }

/* ---------- 平板适配：侧边栏收缩为图标 ---------- */
@media (max-width: 1024px) and (min-width: 769px) {
  .sidebar { width: 64px; }
  .sidebar .logo span, .nav-item span.nav-text, .nav-section { display: none; }
  .main { margin-left: 64px; }
}

/* ---------- 手机适配（≤768px）：抽屉式导航 ---------- */
.menu-btn { display: none; }
.drawer-mask { display: none; }

@media (max-width: 768px) {
  /* 布局：隐藏侧边栏，改为抽屉 */
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: none; background: none; font-size: 20px; cursor: pointer; border-radius: 8px; margin-right: 6px; flex-shrink: 0; }
  .menu-btn:active { background: #f3f4f6; }
  .sidebar { width: 240px; transform: translateX(-100%); transition: transform .25s ease; box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,.3); }
  .main { margin-left: 0; }
  .drawer-mask { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 15; opacity: 0; pointer-events: none; transition: opacity .25s; }
  .drawer-mask.show { opacity: 1; pointer-events: auto; }

  /* 顶栏紧凑 */
  .topbar { padding: 0 10px; height: 52px; }
  .topbar .page-title { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .user-box { gap: 6px; flex-shrink: 0; }
  .topbar .user-name { display: none; }
  .topbar .user-role { font-size: 11px; padding: 2px 6px; }
  .topbar .user-box .btn { padding: 4px 8px; font-size: 12px; }

  /* 内容区 */
  .content { padding: 12px 10px; }
  .card { padding: 14px 12px; border-radius: 8px; }

  /* 统计卡片：一行两个 */
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 12px 14px; }
  .stat-card .stat-value { font-size: 22px; }

  /* 工具栏：控件占满整行 */
  .toolbar { gap: 8px; }
  .toolbar input, .toolbar select { min-width: 0; flex: 1 1 100%; }
  .toolbar .btn { flex: 0 0 auto; }
  .toolbar > span { flex: 1 1 100%; }

  /* 表格：保持横向滑动，字号略小 */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  table.data-table { font-size: 12.5px; }
  .data-table th, .data-table td { padding: 8px 8px; }

  /* 表单：一行一列 */
  .form-row { flex-direction: column; align-items: stretch; gap: 0; }
  .form-row .form-group { flex: 1 1 100% !important; }

  /* 弹窗：接近全屏 */
  .modal-mask { padding: 10px; align-items: flex-end; }
  .modal, .modal.modal-lg { width: 100%; max-height: 92vh; padding: 16px 14px; border-radius: 12px 12px 0 0; }
  .modal-footer .btn { flex: 1; justify-content: center; }

  /* Toast：顶部居中 */
  #toast-box { left: 12px; right: 12px; top: 12px; align-items: center; }
  .toast { max-width: 100%; }

  /* 日历：降低单元格高度 */
  .calendar td { height: 56px; padding: 3px; }
  .cal-event { font-size: 10.5px; padding: 2px 4px; }

  /* 图表：一行一个 */
  .chart-grid { grid-template-columns: 1fr; }

  /* 描述列表：标签内容上下排 */
  .desc-list { grid-template-columns: 1fr; row-gap: 4px; }
  .desc-list dt { margin-top: 6px; font-size: 12px; }

  /* 通知元信息换行 */
  .notice-card .notice-meta { gap: 8px; }

  /* 登录页 */
  .login-card { width: auto; margin: 0 16px; padding: 30px 24px; flex: 1; max-width: 400px; }
}
