/* ============================================================
   苗医平台 · 总部后台样式（左导航 + 右内容）
   ============================================================ */
:root {
  --brand: #0e3b2e;
  --brand-2: #1c6b52;
  --gold: #c9a227;
  --ink: #16221c;
  --text: #2a332c;
  --muted: #7b857d;
  --line: #e7e3d8;
  --bg: #f4f6f4;
  --danger: #c0392b;
  --ok: #1e7b45;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--brand-2); text-decoration: none; }
img { max-width: 100%; }

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

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: 218px;
  background: var(--brand);
  color: #fff;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar .brand .t { font-size: 16px; font-weight: 700; letter-spacing: 0.5px; }
.sidebar .brand .s { font-size: 11px; color: rgba(255, 255, 255, 0.55); margin-top: 3px; }
.sidebar .brand .line { width: 26px; height: 2px; background: var(--gold); margin-top: 9px; border-radius: 2px; }
.sidebar nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar nav a.on {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-left-color: var(--gold);
  font-weight: 600;
}
.sidebar nav a .ico { width: 16px; text-align: center; opacity: 0.9; }
.sidebar .sidefoot {
  padding: 14px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}
.sidebar .sidefoot a { color: rgba(255, 255, 255, 0.8); }
.sidebar .sidefoot .who { color: #fff; }

/* ---------- 主区域 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.headbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}
.headbar h1 { font-size: 17px; margin: 0; color: var(--ink); font-weight: 600; }
.headbar .actions { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); }

.content { padding: 22px 24px 40px; }

/* ---------- 卡片 ---------- */
.panel {
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--line);
  margin-bottom: 18px;
  overflow: hidden;
}
.panel-hd {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  color: var(--ink);
  font-size: 14px;
}
.panel-bd { padding: 18px; }
.panel-bd.flush { padding: 0; }

/* ---------- 数据卡 ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.kpi::after {
  content: "";
  position: absolute;
  right: -18px;
  bottom: -18px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(201, 162, 39, 0.08);
}
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .n { font-size: 26px; font-weight: 700; color: var(--brand); line-height: 1.4; }
.kpi .n small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 2px; }

/* ---------- 表格 ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left;
  padding: 11px 14px;
  background: #fafaf7;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td { padding: 12px 14px; border-bottom: 1px solid #f3f1ea; vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #fbfbf8; }
table.data .num { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
table.data .act { white-space: nowrap; }
table.data .act a { margin-right: 8px; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.fld label { display: block; font-size: 13px; color: var(--ink); margin-bottom: 6px; font-weight: 500; }
.fld .hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
input[type="text"], input[type="password"], input[type="number"], input[type="tel"], select, textarea {
  width: 100%;
  border: 1px solid #dcdfd8;
  border-radius: 7px;
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(28, 107, 82, 0.08); }
textarea { min-height: 90px; resize: vertical; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-block;
  border: none;
  border-radius: 7px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  line-height: 1.4;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-outline { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-plain { background: #eef0ee; color: var(--text); }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 5px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------- 标记 ---------- */
.tag { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 12px; line-height: 1.7; white-space: nowrap; }
.tag-green { background: #eaf6ee; color: var(--ok); }
.tag-gold { background: #fbf3dc; color: #8a6d12; }
.tag-red { background: #fdecea; color: var(--danger); }
.tag-gray { background: #eef0ee; color: #666; }
.tag-blue { background: #eaf2fb; color: #2b6cb0; }

/* ---------- 提示 ---------- */
.alert { padding: 11px 14px; border-radius: 7px; font-size: 13px; margin-bottom: 16px; }
.alert-ok { background: #eaf6ee; color: var(--ok); border: 1px solid #cfe8d8; }
.alert-err { background: #fdecea; color: var(--danger); border: 1px solid #f5cdc7; }
.alert-info { background: #eff5f1; color: var(--brand); border: 1px solid #d9e7df; }
.alert-warn { background: #fdf6e3; color: #8a6d12; border: 1px solid #f0e0b0; }

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

/* ---------- 分页 ---------- */
.pager { display: flex; gap: 6px; padding: 14px 18px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.pager a, .pager span {
  min-width: 30px;
  text-align: center;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  background: #fff;
}
.pager .on { background: var(--brand); color: #fff; border-color: var(--brand); }
.pager .gap { border: none; background: transparent; }
.pager .tot { border: none; background: transparent; color: var(--muted); margin-left: auto; }

/* ---------- 详情键值 ---------- */
.dl { display: grid; grid-template-columns: 130px 1fr; gap: 10px 16px; font-size: 13px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; color: var(--text); word-break: break-all; }

.mats { display: flex; flex-wrap: wrap; gap: 10px; }
.mats a { display: block; }
.mats img { width: 116px; height: 116px; object-fit: cover; border-radius: 7px; border: 1px solid var(--line); }

/* ---------- 登录页 ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0e3b2e 0%, #1e5a48 55%, #0e3b2e 100%);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 12px;
  padding: 30px 26px 26px;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.25);
}
.login-card h1 { font-size: 19px; margin: 0 0 4px; color: var(--ink); }
.login-card .sub { font-size: 12px; color: var(--muted); margin-bottom: 22px; }
.login-card .gold { width: 30px; height: 2px; background: var(--gold); margin-bottom: 14px; border-radius: 2px; }

.qr-mini { width: 150px; height: 150px; border: 1px solid var(--line); border-radius: 8px; }

.bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.bar form { display: flex; gap: 8px; align-items: center; }

.hint-box {
  background: #fafaf7;
  border: 1px dashed var(--line);
  border-radius: 7px;
  padding: 12px 14px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.8;
}

/* ================= 手机 / 窄屏适配（2026-11-09 补） ================= */
.hb-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hb-left h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-toggle { display: none; }
.side-mask { display: none; }

@media (max-width: 900px) {
  /* 侧栏改为抽屉：默认收起，点左上角 ☰ 展开，不再挤压内容区 */
  .layout { display: block; }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 236px;
    height: 100%;
    z-index: 80;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: none;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 8px 0 26px rgba(0, 0, 0, 0.25); }

  .side-mask {
    display: block;
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.38);
    z-index: 70;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s;
  }
  .side-mask.show { opacity: 1; visibility: visible; }

  .main { width: 100%; }

  .headbar { height: 54px; padding: 0 12px; gap: 10px; }
  .headbar h1 { font-size: 15px; }
  .headbar .actions { font-size: 12px; gap: 6px; white-space: nowrap; }
  .headbar .actions .hide-sm { display: none; }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border: none;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
  }

  .content { padding: 14px 12px 60px; }

  .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi .l { font-size: 11px; }
  .kpi .n { font-size: 21px; }

  /* 表格：整表左右滑动，不再把文字挤成一列一个字 */
  table.data {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  table.data th, table.data td { padding: 10px 12px; }
  table.data .act { white-space: nowrap; }

  .panel-bd { padding: 14px; }
  .panel-bd.flush { padding: 0; }
  .panel-hd { padding: 12px 14px; font-size: 13px; }
  .panel { margin-bottom: 12px; }

  /* 表单：16px 防止 iOS 自动放大 */
  .fld input,
  .fld select,
  .fld textarea { font-size: 16px; }
  .btn { padding: 10px 16px; }

  /* 筛选 / 标签栏换行，不横向挤爆 */
  .filters, .tabs, .filter-bar { flex-wrap: wrap; }

  /* 详情定义列表在窄屏改为上下堆叠 */
  .dl { display: block; }
  .dl dt, .dl dd { display: block; width: auto; }
  .dl dt { margin-top: 10px; }
}

/* 响应式两栏容器（替换模板里的内联 grid） */
.cols { display: grid; gap: 18px; align-items: start; }
.cols-14 { grid-template-columns: 1.4fr 1fr; }
.cols-15 { grid-template-columns: 1.5fr 1fr; }
.cols-11 { grid-template-columns: 1fr 1fr; }

@media (max-width: 900px) {
  .cols, .cols-14, .cols-15, .cols-11 { grid-template-columns: 1fr; gap: 12px; }
}

/* 表格内文字按钮（启停/删除） */
.lnk {
  background: none;
  border: none;
  padding: 0;
  margin: 0 0 0 8px;
  color: #1c6b52;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
}
.lnk.danger { color: #c0392b; }
