/* 医疗器械 GMP 全流程管理系统 - 卡片式响应式主题 */
:root {
  --brand: #0E9E8E;
  --brand-dark: #0B8174;
  --brand-light: #E6F6F3;
  --bg: #F4F6F8;
  --card: #FFFFFF;
  --text: #1f2d3d;
  --muted: #6b7a8d;
  --border: #e3e8ee;
  --danger: #e74c3c;
  --warn: #f39c12;
  --ok: #27ae60;
  --shadow: 0 2px 8px rgba(16,40,60,.06);
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 顶栏 */
.topbar {
  height: 56px; background: var(--brand); color: #fff; display: flex;
  align-items: center; padding: 0 16px; position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
}
.topbar .brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.topbar .brand .logo { width: 28px; height: 28px; background: #fff; color: var(--brand);
  border-radius: 7px; display: grid; place-items: center; font-weight: 800; }
.topbar .spacer { flex: 1; }
.topbar .user { display: flex; align-items: center; gap: 10px; }
.topbar .user .avatar { width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,.25);
  display: grid; place-items: center; font-weight: 700; }
.menu-toggle { display: none; background: none; border: none; color: #fff; font-size: 22px; cursor: pointer; margin-right: 10px; }

/* 侧边栏 */
.sidebar {
  position: fixed; top: 56px; bottom: 0; left: 0; width: 220px; background: #fff;
  border-right: 1px solid var(--border); overflow-y: auto; padding: 10px 10px 24px; z-index: 90;
  box-shadow: 2px 0 10px rgba(16,40,60,.04);
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #dbe3ea; border-radius: 3px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: #c6d1db; }

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

/* 分组标题（手风琴折叠头） */
.sidebar .nav-group > .label {
  cursor: pointer; user-select: none;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; font-weight: 600; letter-spacing: .3px;
  color: var(--muted); padding: 8px 10px; margin: 2px 0; border-radius: 8px;
  transition: background .15s ease, color .15s ease;
}
.sidebar .nav-group > .label:hover { background: var(--brand-light); color: var(--brand-dark); }
.sidebar .nav-group.expanded > .label { color: var(--brand-dark); }
.sidebar .nav-group > .label .chev {
  font-size: 10px; line-height: 1; color: var(--muted);
  transition: transform .18s ease; transform: rotate(0deg);
}
.sidebar .nav-group.expanded > .label .chev { transform: rotate(90deg); color: var(--brand); }

/* 子项 */
.sidebar a.item {
  position: relative; display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; border-radius: 8px; margin: 1px 0;
  color: var(--text); font-size: 13.5px; line-height: 1.2;
  transition: background .15s ease, color .15s ease;
}
.sidebar a.item:hover { background: var(--brand-light); text-decoration: none; color: var(--brand-dark); }
.sidebar a.item.active { background: var(--brand-light); color: var(--brand-dark); font-weight: 600; }
.sidebar a.item.active::before {
  content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px;
  background: var(--brand); border-radius: 0 3px 3px 0;
}

/* 折叠容器：平滑展开 */
.sidebar .nav-group-body {
  max-height: 0; overflow: hidden; margin: 0 0 4px 12px; padding-left: 8px;
  border-left: 2px solid var(--border); transition: max-height .25s ease;
}
.sidebar .nav-group.expanded .nav-group-body { max-height: 800px; }

.content { margin-left: 220px; margin-top: 56px; padding: 20px; }
.page-title { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 18px; }

/* 卡片 */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px;
}
.card h3 { margin: 0 0 12px; font-size: 15px; }
.card .card-title-row { display: flex; justify-content: space-between; align-items: center; }

/* 统计卡 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat-card .num { font-size: 28px; font-weight: 800; color: var(--brand); }
.stat-card .lbl { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat-card .bar { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--brand); }

/* 栅格 */
.row { display: flex; flex-wrap: wrap; gap: 16px; }
.row > .col { flex: 1 1 320px; }

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

/* 按钮 */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--brand); background: var(--brand); color: #fff; cursor: pointer; font-size: 13px; }
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--brand); }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

/* 徽章 */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.badge.ok { background: #e7f7ee; color: var(--ok); }
.badge.warn { background: #fdf3e0; color: var(--warn); }
.badge.danger { background: #fdecea; color: var(--danger); }
.badge.info { background: var(--brand-light); color: var(--brand-dark); }

/* 表单 */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
  font-family: inherit; background: #fff;
}
.field textarea { min-height: 70px; resize: vertical; }
.field .req { color: var(--danger); }

/* 模块入口卡 */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.module-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  box-shadow: var(--shadow); text-align: center; transition: .15s; }
.module-card:hover { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(16,40,60,.12); text-decoration: none; }
.module-card .ic { width: 44px; height: 44px; border-radius: 12px; background: var(--brand-light); color: var(--brand);
  display: grid; place-items: center; margin: 0 auto 10px; font-size: 20px; }
.module-card .nm { font-weight: 600; font-size: 13.5px; color: var(--text); }

/* 移动端 */
@media (max-width: 768px) {
  .menu-toggle { display: block; }
  .sidebar { transform: translateX(-100%); transition: .2s; box-shadow: 4px 0 16px rgba(0,0,0,.15); }
  .sidebar.open { transform: translateX(0); }
  .content { margin-left: 0; padding: 14px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .module-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
}

/* 详情键值网格 */
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px 20px; }
.kv-k { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.kv-v { font-size: 15px; color: var(--text); font-weight: 500; }
.card-subtitle { font-size: 15px; font-weight: 600; color: var(--text); margin: 0 0 12px; padding-left: 9px; border-left: 3px solid var(--primary); }
td.ops { white-space: nowrap; }
td.ops .btn { margin-right: 4px; }

/* 移动端专用 */
.m-wrap { max-width: 520px; margin: 0 auto; }
.m-card { background: #fff; border-radius: 14px; padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.m-btn { display: block; width: 100%; text-align: center; padding: 14px; border-radius: 12px; font-size: 16px;
  font-weight: 700; margin-bottom: 12px; }
.m-nav { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--border);
  display: flex; z-index: 100; }
.m-nav a { flex: 1; text-align: center; padding: 10px 0; font-size: 12px; color: var(--muted); }
.m-nav a.active { color: var(--brand); }
.m-nav a .ic { font-size: 20px; display: block; }
.m-content { padding-bottom: 70px; }

.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.alert.danger { background: #fdecea; color: #b03a2e; }
.alert.warn { background: #fdf3e0; color: #b9770e; }
.alert.ok { background: #e7f7ee; color: #1e8449; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.flash.success { background: #e7f7ee; color: #1e8449; }
.flash.danger { background: #fdecea; color: #b03a2e; }
.flash.warning { background: #fdf3e0; color: #b9770e; }
