*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 0.9rem; color: #333; background: #f0f2f5; min-height: 100vh; padding-top: 50px;
}

.top-header {
  position: fixed; top:0; left:0; right:0; z-index: 200;
  height: 50px; background: #1a3c6e; display: flex; align-items: center;
  padding: 0 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.menu-btn { background: none; border: none; color: #fff; font-size: 1.4rem; cursor: pointer; padding: 6px 8px; line-height: 1; }
.header-center { flex:1; text-align: center; }
.main-title { color: #fff; font-size: 1.05rem; font-weight: 700; letter-spacing: 1px; }

.overlay { position: fixed; inset:0; background: rgba(0,0,0,0.5); z-index: 250; display: none; }
.overlay.show { display: block; }

.sidebar {
  position: fixed; top:0; left:0; bottom:0; z-index: 300;
  width: 240px; max-width: 80vw; background: #1a3c6e;
  transform: translateX(-100%); transition: transform 0.25s ease;
  overflow-y: auto; padding-top: 50px;
}
.sidebar.open { transform: translateX(0); }
.sidebar-title { color: rgba(255,255,255,0.5); font-size: 0.75rem; padding: 14px 20px 6px; text-transform: uppercase; letter-spacing: 1px; }
.sidebar-nav { display: flex; flex-direction: column; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 14px 20px;
  color: #c8d6e5; text-decoration: none; font-size: 0.95rem;
  border-left: 4px solid transparent; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover, .nav-item:active { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.12); color: #fff; border-left-color: #ffc107; font-weight: 700; }
.nav-icon { font-size: 1.1rem; }

.breadcrumb {
  display: flex; align-items: center; gap: 6px; padding: 10px 14px;
  background: #fff; border-bottom: 1px solid #e8e8e8; font-size: 0.85rem; color: #888;
}
.breadcrumb-item { color: #888; }
.breadcrumb-item.active { color: #1a3c6e; font-weight: 700; }

.main-area { padding: 12px; }
.page-content { display: none; }
.page-content.active { display: block; }

.search-section {
  background: linear-gradient(135deg, #fff8e1, #ffecb3);
  border: 1px solid #ffe082; border-radius: 10px; padding: 16px; margin-bottom: 14px;
}
.search-label { display: block; font-weight: 700; font-size: 0.95rem; color: #5d4037; margin-bottom: 10px; }
.search-row { display: flex; gap: 8px; flex-wrap: wrap; }
.search-input-wrapper { flex: 1; min-width: 0; position: relative; }
.search-input {
  width: 100%; padding: 11px 14px; font-size: 1rem;
  border: 2px solid #ffb300; border-radius: 8px; outline: none; background: #fff; -webkit-appearance: none;
}
.search-input:focus { border-color: #e65100; box-shadow: 0 0 0 3px rgba(230,81,0,0.12); }

.suggest-dropdown {
  position: absolute; top: calc(100% + 4px); left:0; right:0; background: #fff;
  border: 1px solid #ddd; border-radius: 8px; max-height: 260px; overflow-y: auto;
  z-index: 100; box-shadow: 0 6px 20px rgba(0,0,0,0.15); display: none;
}
.suggest-dropdown.show { display: block; }
.suggest-item { padding: 12px 14px; cursor: pointer; border-bottom: 1px solid #f0f0f0; }
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover, .suggest-item.active { background: #e3f2fd; }
.suggest-item .si-name { font-weight: 700; font-size: 0.95rem; color: #d32f2f; }
.suggest-item .si-detail { font-size: 0.75rem; color: #888; }
.suggest-item .si-batch { display: inline-block; background: #e8eaf6; color: #3f51b5; font-size: 0.7rem; padding: 1px 6px; border-radius: 3px; }

.info-row { display: flex; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.info-tag { font-size: 0.8rem; color: #6d4c41; background: rgba(255,255,255,0.7); padding: 4px 10px; border-radius: 12px; }
.info-tag strong { color: #d32f2f; }

.filter-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-select { flex:1; min-width: 100px; padding: 10px 10px; font-size: 0.9rem; border: 2px solid #ffb300; border-radius: 8px; background: #fff; outline: none; }
.filter-input { flex:2; min-width: 120px; padding: 10px 12px; font-size: 0.9rem; border: 2px solid #ffb300; border-radius: 8px; outline: none; }
.filter-btn { padding: 10px 20px; font-size: 0.9rem; font-weight: 700; color: #fff; background: #1a73e8; border: none; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.filter-btn:active { background: #1557b0; }

.detail-section { background: #fff; border-radius: 10px; padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 4px rgba(0,0,0,0.04); }
.section-header { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 2px solid #e8eaf6; }
.section-header h2 { font-size: 1rem; color: #1a237e; }
.section-badge { background: #1a73e8; color: #fff; font-size: 0.75rem; padding: 2px 8px; border-radius: 10px; }

.detail-card { background: #fafafa; border: 1px solid #e8e8e8; border-radius: 8px; padding: 14px; margin-bottom: 12px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.detail-item { display: flex; flex-direction: column; gap: 1px; }
.detail-item .di-label { font-size: 0.7rem; color: #999; }
.detail-item .di-value { font-size: 0.9rem; font-weight: 600; color: #333; }
.detail-item .di-value.highlight { color: #d32f2f; font-weight: 700; }

.rule-field { margin-bottom: 10px; padding: 12px 14px; background: #fff; border-left: 4px solid #ff9800; border-radius: 0 6px 6px 0; font-size: 0.85rem; line-height: 1.7; }
.rule-field .rf-label { font-size: 0.75rem; color: #888; margin-bottom: 4px; font-weight: 700; }
.rule-field .rf-value p { margin: 2px 0; }
.rule-field .rf-value b { color: #555; }

.result-section { display: flex; flex-direction: column; gap: 12px; }
.result-panel { background: #fff; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,0.04); overflow: hidden; }
.panel-header { padding: 12px 16px; font-size: 0.9rem; font-weight: 700; }
.panel-header-green { background: #e8f5e9; color: #2e7d32; }
.panel-header-blue { background: #e3f2fd; color: #1565c0; }
.panel-body { padding: 10px 14px; max-height: 300px; overflow-y: auto; }

.candidate-item { padding: 10px 0; border-bottom: 1px solid #f0f0f0; display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; }
.candidate-item .cand-name { font-weight: 600; color: #d32f2f; }
.candidate-item .cand-type { font-size: 0.7rem; background: #4caf50; color: #fff; padding: 2px 8px; border-radius: 10px; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.drug-table { width: 100%; min-width: 500px; border-collapse: collapse; font-size: 0.8rem; }
.drug-table thead { background: #e8eaf6; }
.drug-table th { padding: 8px 10px; text-align: left; font-weight: 700; color: #37474f; border-bottom: 2px solid #c5cae9; white-space: nowrap; }
.drug-table td { padding: 8px 10px; border-bottom: 1px solid #e8e8e8; }
.drug-table tbody tr:hover { background: #f5f5ff; }
.drug-table .code-highlight { color: #d32f2f; font-weight: 700; font-family: monospace; }
.drug-table .link-cell { color: #1a73e8; cursor: pointer; text-decoration: underline; font-weight: 600; }

.empty-state { text-align: center; padding: 50px 16px; color: #bbb; }
.empty-icon { font-size: 3rem; margin-bottom: 10px; }
.no-data { text-align: center; padding: 20px; color: #aaa; font-size: 0.85rem; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat-card { background: #fff; border-radius: 10px; padding: 18px 12px; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,0.04); }
.stat-num { font-size: 1.6rem; font-weight: 800; color: #1a73e8; }
.stat-label { font-size: 0.75rem; color: #888; margin-top: 4px; }

.toast {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%) translateY(-120px);
  z-index: 999; padding: 10px 24px; border-radius: 8px; color: #fff; font-weight: 600;
  font-size: 0.85rem; box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  transition: transform 0.3s ease; pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: #4caf50; }
.toast.error { background: #f44336; }

@media (min-width: 768px) {
  body { padding-top: 0; }
  .top-header { position: static; height: auto; padding: 12px 20px; justify-content: space-between; }
  .menu-btn { display: none; }
  .main-title { font-size: 1.3rem; }
  .breadcrumb { display: none; }
  .overlay { display: none !important; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; width: 200px; max-width: none; transform: none; padding-top: 70px; }
  .main-area { margin-left: 200px; padding: 20px 24px; max-width: 1200px; }
  .result-section { flex-direction: row; gap: 16px; }
  .result-panel { flex: 1; min-width: 0; }
  .stat-num { font-size: 2rem; }
  .drug-table { min-width: 0; font-size: 0.85rem; }
  .drug-table th, .drug-table td { padding: 10px 12px; }
}

@media (min-width: 1200px) {
  .sidebar { width: 220px; }
  .main-area { margin-left: 220px; }
}