/* 药说 · 后台管理系统样式。配色与小程序端保持一致。 */

:root {
  --primary: #2e7d63;
  --primary-dark: #1f5c48;
  --primary-light: #e8f3ee;
  --tcm: #8a6a3b;
  --tcm-light: #fbf6ec;
  --west: #2b6cb0;
  --west-light: #edf3fb;
  --danger: #c0392b;
  --danger-light: #fdedeb;
  --warn: #b7791f;
  --warn-light: #fdf7e8;
  --text-1: #1a1d1f;
  --text-2: #5a6169;
  --text-3: #98a0a8;
  --bg: #f4f6f5;
  --card: #ffffff;
  --line: #ecf0f0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(26, 29, 31, 0.05), 0 8px 24px rgba(26, 29, 31, 0.05);
}

* {
  box-sizing: border-box;
}

/* 兜底：hidden 属性优先级需高于类选择器上的 display */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
}

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

code {
  background: var(--primary-light);
  border-radius: 4px;
  color: var(--primary-dark);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  padding: 1px 5px;
}

h1,
h2,
h3,
h4 {
  margin: 0;
}

/* ---------------- 登录页 ---------------- */

.login-page {
  align-items: center;
  background: linear-gradient(150deg, #e8f3ee 0%, #f4f6f5 55%, #eef2f7 100%);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 36px 34px 28px;
  width: 400px;
}

.login-brand {
  align-items: center;
  display: flex;
  gap: 14px;
  margin-bottom: 4px;
}

.login-brand h1 {
  font-size: 20px;
  font-weight: 600;
}

.login-brand p {
  color: var(--text-3);
  font-size: 12px;
  margin: 2px 0 0;
}

.brand-mark {
  align-items: center;
  background: var(--primary);
  border-radius: 12px;
  color: #fff;
  display: flex;
  flex: none;
  font-size: 24px;
  font-weight: 600;
  height: 48px;
  justify-content: center;
  width: 48px;
}

.brand-mark-sm {
  border-radius: 9px;
  font-size: 17px;
  height: 34px;
  width: 34px;
}

.login-error {
  background: var(--danger-light);
  border-radius: 8px;
  color: var(--danger);
  font-size: 13px;
  padding: 9px 12px;
}

.login-tip {
  border-top: 1px solid var(--line);
  color: var(--text-3);
  font-size: 12px;
  margin: 2px 0 0;
  padding-top: 14px;
}

/* ---------------- 布局 ---------------- */

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  background: var(--card);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  flex: none;
  position: sticky;
  top: 0;
  height: 100vh;
  width: 224px;
}

.sidebar-brand {
  align-items: center;
  display: flex;
  gap: 10px;
  padding: 18px 18px 16px;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.sidebar-brand-text strong {
  font-size: 15px;
}

.sidebar-brand-text span {
  color: var(--text-3);
  font-size: 11px;
}

.nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  padding: 6px 12px;
}

.nav-item {
  align-items: center;
  background: none;
  border: 0;
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  font-family: inherit;
  font-size: 13.5px;
  gap: 9px;
  padding: 9px 12px;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  width: 100%;
}

.nav-item:hover {
  background: var(--bg);
  color: var(--text-1);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

.nav-count {
  background: var(--bg);
  border-radius: 20px;
  color: var(--text-3);
  font-size: 11px;
  margin-left: auto;
  padding: 0 7px;
}

.nav-item.active .nav-count {
  background: #fff;
  color: var(--primary-dark);
}

.nav-count.alert {
  background: var(--danger-light);
  color: var(--danger);
  font-weight: 600;
}

.sidebar-foot {
  padding: 12px;
}

.compliance-note {
  background: var(--warn-light);
  border-radius: 8px;
  padding: 10px 12px;
}

.compliance-note strong {
  color: var(--warn);
  font-size: 12px;
}

.compliance-note p {
  color: var(--text-2);
  font-size: 11.5px;
  line-height: 1.5;
  margin: 3px 0 0;
}

.main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  height: 58px;
  z-index: 8;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
}

.topbar-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.account {
  color: var(--text-2);
  font-size: 13px;
  margin-right: 4px;
}

.content {
  flex: 1;
  padding: 22px 24px 48px;
}

/* ---------------- 通用组件 ---------------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 16px;
  padding: 18px;
}

.card-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card-title {
  font-size: 14.5px;
  font-weight: 600;
}

.card-sub {
  color: var(--text-3);
  font-size: 12px;
  margin-top: 2px;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 1080px) {
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-3,
  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.stat-label {
  color: var(--text-3);
  font-size: 12.5px;
}

.stat-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.5px;
  margin-top: 4px;
}

.stat-foot {
  color: var(--text-3);
  font-size: 11.5px;
  margin-top: 2px;
}

.btn {
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-1);
  cursor: pointer;
  display: inline-flex;
  font-family: inherit;
  font-size: 13px;
  gap: 5px;
  justify-content: center;
  padding: 7px 13px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn:hover {
  border-color: #d8dedd;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

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

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}

.btn-ghost:hover {
  background: var(--bg);
  border-color: transparent;
  color: var(--text-1);
}

.btn-danger {
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-light);
  border-color: var(--danger-light);
}

.btn-sm {
  font-size: 12.5px;
  padding: 4px 9px;
}

.btn-block {
  width: 100%;
}

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

.toolbar-spacer {
  flex: 1;
}

.input,
.textarea,
.select {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-1);
  font-family: inherit;
  font-size: 13px;
  padding: 7px 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(46, 125, 99, 0.12);
  outline: none;
}

.input[readonly] {
  background: var(--bg);
  color: var(--text-3);
}

.textarea {
  line-height: 1.65;
  min-height: 76px;
  resize: vertical;
}

.search-input {
  max-width: 240px;
}

/* ---------------- 表格 ---------------- */

.table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.table th,
.table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
  text-align: left;
  vertical-align: middle;
}

.table th {
  background: #fafbfb;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover {
  background: #fbfcfc;
}

.table .num {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.table .name-cell {
  font-weight: 600;
}

.table .sub {
  color: var(--text-3);
  font-size: 11.5px;
  font-weight: 400;
}

.row-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.pager {
  align-items: center;
  color: var(--text-3);
  display: flex;
  font-size: 12.5px;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 12px;
}

/* ---------------- 标签 ---------------- */

.badge {
  border-radius: 5px;
  display: inline-block;
  font-size: 11.5px;
  line-height: 1.7;
  padding: 0 7px;
  white-space: nowrap;
}

.badge-tcm {
  background: var(--tcm-light);
  color: var(--tcm);
}

.badge-west {
  background: var(--west-light);
  color: var(--west);
}

.badge-otc {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.badge-rx {
  background: var(--danger-light);
  color: var(--danger);
}

.badge-on {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.badge-off {
  background: #eef0f1;
  color: var(--text-3);
}

.badge-plain {
  background: var(--bg);
  color: var(--text-2);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ---------------- 表单 ---------------- */

.form-section {
  border-top: 1px solid var(--line);
  padding: 18px 0 4px;
}

.form-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.form-section-title {
  align-items: center;
  display: flex;
  font-size: 13.5px;
  font-weight: 600;
  gap: 8px;
  margin-bottom: 12px;
}

.form-section-title .hint {
  color: var(--text-3);
  font-size: 11.5px;
  font-weight: 400;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field-label {
  color: var(--text-2);
  display: block;
  font-size: 12.5px;
  margin-bottom: 5px;
}

.field-label .req {
  color: var(--danger);
  margin-left: 3px;
}

.field-hint {
  color: var(--text-3);
  font-size: 11.5px;
  margin-top: 4px;
}

.field-row {
  display: grid;
  gap: 14px;
}

.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.radio-chip {
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  font-size: 13px;
  gap: 6px;
  padding: 6px 12px;
}

.radio-chip input {
  accent-color: var(--primary);
  margin: 0;
}

.radio-chip.checked {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 500;
}

.sub-list-row {
  align-items: flex-start;
  background: #fafbfb;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
  padding: 12px;
}

.sub-list-row .row-del {
  justify-self: end;
}

.tag-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-pill {
  align-items: center;
  background: var(--primary-light);
  border-radius: 6px;
  color: var(--primary-dark);
  display: inline-flex;
  font-size: 12.5px;
  gap: 6px;
  padding: 2px 6px 2px 9px;
}

.tag-pill button {
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: 0.6;
  padding: 0 2px;
}

.tag-pill button:hover {
  opacity: 1;
}

.picker {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  height: 264px;
  overflow: hidden;
}

.picker-head {
  background: #fafbfb;
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
}

.picker-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.picker-item {
  align-items: center;
  border-radius: 6px;
  /* 西药库已达上万条，勾选列表只渲染可视区域，避免打开抽屉时明显卡顿 */
  content-visibility: auto;
  contain-intrinsic-size: auto 30px;
  cursor: pointer;
  display: flex;
  font-size: 12.5px;
  gap: 8px;
  padding: 5px 8px;
}

.picker-item:hover {
  background: var(--bg);
}

.picker-item.checked {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.picker-item input {
  accent-color: var(--primary);
  margin: 0;
}

.picker-foot {
  border-top: 1px solid var(--line);
  color: var(--text-3);
  font-size: 11.5px;
  padding: 6px 10px;
}

/* ---------------- 抽屉 / 弹窗 ---------------- */

.drawer,
.modal {
  inset: 0;
  position: fixed;
  z-index: 40;
}

.drawer-mask,
.modal-mask {
  background: rgba(26, 29, 31, 0.35);
  inset: 0;
  position: absolute;
}

.drawer-panel {
  background: var(--card);
  bottom: 0;
  display: flex;
  flex-direction: column;
  position: absolute;
  right: 0;
  top: 0;
  width: min(760px, 94vw);
}

.drawer-head,
.modal-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 10px;
  justify-content: space-between;
  padding: 15px 20px;
}

.drawer-head h3,
.modal-head h3 {
  font-size: 15px;
  font-weight: 600;
}

.drawer-head .sub {
  color: var(--text-3);
  font-size: 12px;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
}

.drawer-foot,
.modal-foot {
  align-items: center;
  background: #fafbfb;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 12px 20px;
}

.drawer-foot .left,
.modal-foot .left {
  margin-right: auto;
}

.modal-panel {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  left: 50%;
  max-width: 520px;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 92vw;
}

.modal-body {
  padding: 18px 20px;
}

/* ---------------- 合规提示 ---------------- */

.alert {
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.6;
  margin-bottom: 14px;
  padding: 10px 12px;
}

.alert-warn {
  background: var(--warn-light);
  color: #7a5312;
}

.alert-error {
  background: var(--danger-light);
  color: var(--danger);
}

.alert-ok {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.alert ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

/* ---------------- 图表 ---------------- */

.chart {
  align-items: flex-end;
  display: flex;
  gap: 10px;
  height: 168px;
  padding-top: 8px;
}

.chart-col {
  align-items: center;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.chart-value {
  color: var(--text-2);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.chart-bar {
  background: linear-gradient(180deg, #4a9d7e 0%, var(--primary) 100%);
  border-radius: 5px 5px 0 0;
  min-height: 2px;
  transition: height 0.3s ease;
  width: 100%;
}

.chart-label {
  color: var(--text-3);
  font-size: 11px;
}

/* ---------------- 反馈卡片 ---------------- */

.fb-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fb-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.fb-head {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.fb-meta {
  color: var(--text-3);
  font-size: 11.5px;
  margin-left: auto;
}

.fb-content {
  color: var(--text-1);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.fb-foot {
  align-items: center;
  border-top: 1px solid var(--line);
  color: var(--text-3);
  display: flex;
  font-size: 11.5px;
  gap: 10px;
  margin-top: 12px;
  padding-top: 10px;
}

.fb-foot .note {
  color: var(--text-2);
}

.tabs {
  display: flex;
  gap: 6px;
}

.tab {
  background: none;
  border: 1px solid transparent;
  border-radius: 20px;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  padding: 4px 13px;
}

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

.tab.active {
  background: var(--primary-light);
  border-color: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

/* ---------------- 其它 ---------------- */

.empty {
  color: var(--text-3);
  padding: 46px 0;
  text-align: center;
}

.loading {
  color: var(--text-3);
  padding: 40px 0;
  text-align: center;
}

.toast-wrap {
  bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: fixed;
  right: 22px;
  z-index: 60;
}

.toast {
  animation: toast-in 0.18s ease;
  background: #23282b;
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: #fff;
  font-size: 13px;
  max-width: 380px;
  padding: 10px 14px;
  white-space: pre-wrap;
}

.toast.ok {
  background: var(--primary-dark);
}

.toast.error {
  background: var(--danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.muted {
  color: var(--text-3);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
}

.nowrap {
  white-space: nowrap;
}
