/* ============================================================
   草龟饲养记录助手 —— 设计系统
   主色 #789988（低饱和灰绿） / 背景 #f3f7f4 / 卡片 #fff
   正文 #333 / 次要 #666 / 警示 #b87164
   圆角 12px、柔和阴影、留白充足、动效克制
   移动端单列 + 底部 Tab；≥768px 多列 + 左侧导航
   ============================================================ */

:root {
  --brand: #789988;
  --brand-dark: #5f7d6d;
  --brand-soft: #e8efe9;
  --brand-soft-2: #f0f5f1;
  --bg: #f3f7f4;
  --card: #ffffff;
  --text: #333333;
  --text-2: #666666;
  --text-3: #96a09a;
  --line: #e6ece7;
  --danger: #b87164;
  --danger-soft: #f7ece9;
  --warn: #c69a5c;
  --ok: #6f9c84;
  --radius: 12px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(63, 87, 74, .045), 0 6px 20px rgba(63, 87, 74, .055);
  --shadow-lg: 0 12px 40px rgba(48, 68, 57, .16);
  --tab-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC",
          "Source Han Sans SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  padding-bottom: calc(var(--tab-h) + var(--safe-b) + 14px);
  overscroll-behavior-y: none;
}

a { color: var(--brand-dark); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }

/* ---------------- 布局骨架 ---------------- */
.app { min-height: 100vh; }

.page-head {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(var(--safe-t) + 12px) 16px 12px;
  background: rgba(243, 247, 244, .92);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid rgba(230, 236, 231, .8);
}
.page-head h1 {
  flex: 1;
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-head .sub {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-2);
  margin-top: 2px;
}

.wrap { padding: 14px 14px 8px; max-width: 1180px; margin: 0 auto; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}
.card.tight { padding: 12px 14px; }
.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
}
.card-title .more { font-size: 12.5px; font-weight: 400; color: var(--brand-dark); }

.section-label {
  margin: 18px 4px 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: .4px;
}

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  transition: background .15s, transform .12s;
}
.btn:active { transform: scale(.985); background: var(--brand-dark); }
.btn.block { display: flex; width: 100%; }
.btn.ghost {
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.btn.ghost:active { background: #dfe9e2; }
.btn.line {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--line);
}
.btn.danger { background: var(--danger); }
.btn.danger:active { background: #a4615a; }
.btn.danger-line {
  background: transparent;
  color: var(--danger);
  border: 1px solid #e5cfc9;
}
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 8px; }
.btn:disabled { opacity: .55; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--text-2);
}
.icon-btn:active { background: var(--brand-soft); }

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 14px; }
.field > label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
.field .hint { margin-top: 5px; font-size: 12px; color: var(--text-3); }
.input, .select, .textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdfb;
  outline: none;
  transition: border-color .15s, background .15s;
  font-size: 15px;   /* ≥16px 可避免 iOS 聚焦缩放；此处 15px 配合 viewport 使用 */
}
.textarea { min-height: 92px; resize: vertical; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); background: #fff; }
.input.err, .select.err { border-color: var(--danger); background: #fdf8f7; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.err-msg { margin-top: 5px; font-size: 12px; color: var(--danger); }

.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: #eef3ef;
  gap: 2px;
}
.seg button {
  padding: 6px 13px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-2);
  transition: background .15s, color .15s;
}
.seg button.on { background: #fff; color: var(--brand-dark); font-weight: 600; box-shadow: 0 1px 3px rgba(63,87,74,.1); }

/* ---------------- 列表行 ---------------- */
.list { border-radius: var(--radius); overflow: hidden; background: var(--card); box-shadow: var(--shadow); }
.list .row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}
.list .row:last-child { border-bottom: 0; }
.list .row:active { background: #f7faf8; }
.row .grow { flex: 1; min-width: 0; }
.row .t1 { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .t2 { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.row .val { font-size: 15px; font-variant-numeric: tabular-nums; }

/* ---------------- 统计卡 ---------------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 12px;
  text-align: center;
}
.stat .n {
  font-size: 24px;
  font-weight: 600;
  color: var(--brand-dark);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.stat .n small { font-size: 13px; font-weight: 400; color: var(--text-2); margin-left: 2px; }
.stat .l { margin-top: 4px; font-size: 12px; color: var(--text-2); }

/* ---------------- 快捷按钮 ---------------- */
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.quick button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 13px 4px 11px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 12px;
  color: var(--text-2);
  transition: transform .12s;
}
.quick button:active { transform: scale(.97); }
.quick .qi {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--brand-soft); color: var(--brand-dark);
}

/* ---------------- 徽章 / 标签 ---------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  line-height: 1.6;
  background: var(--brand-soft);
  color: var(--brand-dark);
  white-space: nowrap;
}
.badge.gray { background: #f0f2f0; color: var(--text-2); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: #f8f1e4; color: var(--warn); }
.tag-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 12px; background: var(--brand-soft); color: var(--brand-dark);
}

/* ---------------- 空状态 ---------------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 34px 18px;
  color: var(--text-3);
  font-size: 13.5px;
  text-align: center;
}
.empty svg { opacity: .5; }

/* ---------------- 底部 Tab（移动端） ---------------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: flex;
  justify-content: space-around;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid rgba(230, 236, 231, .9);
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10.5px;
  color: var(--text-3);
  transition: color .15s;
}
.tabbar a.on { color: var(--brand-dark); }
.tabbar a.on .ti { background: var(--brand-soft); }
.tabbar .ti {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 24px; border-radius: 8px;
}

/* ---------------- 侧边导航（PC） ---------------- */
.sidebar { display: none; }
.pc-top { display: none; }

/* ---------------- 弹层：移动端底部抽屉 / PC 居中弹窗 ---------------- */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(38, 52, 44, .34);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-mask.on { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 91;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 18px 18px 0 0;
  transform: translateY(102%);
  transition: transform .26s cubic-bezier(.22, .8, .3, 1);
  box-shadow: var(--shadow-lg);
}
.sheet.on { transform: translateY(0); }
.sheet-head {
  position: relative;
  padding: 16px 18px 10px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.sheet-head::before {
  content: "";
  position: absolute;
  top: 7px; left: 50%;
  width: 38px; height: 4px;
  margin-left: -19px;
  border-radius: 999px;
  background: #e2e8e3;
}
.sheet-head h3 { margin: 0; font-size: 16px; font-weight: 600; text-align: center; }
.sheet-body { padding: 16px 18px 4px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-foot {
  display: flex;
  gap: 10px;
  padding: 12px 18px calc(14px + var(--safe-b));
  border-top: 1px solid var(--line);
  flex: 0 0 auto;
}
.sheet-foot .btn { flex: 1; }

/* ---------------- Toast ---------------- */
#toast {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--tab-h) + var(--safe-b) + 22px);
  z-index: 120;
  display: flex;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  transform: translateY(6px);
}
#toast.on { opacity: 1; transform: translateY(0); }
#toast .bubble {
  max-width: 78vw;
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(46, 60, 52, .93);
  color: #fff;
  font-size: 13.5px;
  line-height: 1.5;
  text-align: center;
  box-shadow: 0 8px 24px rgba(38, 52, 44, .25);
}
#toast.err .bubble { background: rgba(160, 86, 76, .95); }

/* ---------------- 登录页 ---------------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px calc(24px + var(--safe-b));
  background:
    radial-gradient(900px 420px at 50% -8%, #e4ede6 0%, rgba(243, 247, 244, 0) 62%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 392px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 10px 44px rgba(60, 84, 70, .1);
  padding: 26px 22px 22px;
}
.login-brand { text-align: center; margin-bottom: 20px; }
.login-brand .logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px; height: 54px;
  border-radius: 15px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  margin-bottom: 10px;
}
.login-brand h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: .3px; }
.login-brand p { margin: 5px 0 0; font-size: 12.5px; color: var(--text-2); }

.captcha-row { display: flex; gap: 10px; align-items: stretch; }
.captcha-row .input { flex: 1; }
.captcha-img {
  width: 132px; height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f6faf7;
  object-fit: cover;
  cursor: pointer;
  flex: 0 0 auto;
}
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-2); }
.check-row input { width: 17px; height: 17px; accent-color: var(--brand); }

.notice-bar {
  margin-bottom: 14px;
  padding: 10px 13px;
  border-radius: 10px;
  background: var(--brand-soft-2);
  border: 1px solid #e2ebe4;
  font-size: 13px;
  color: var(--brand-dark);
}

/* ---------------- 图表 ---------------- */
.chart-box { position: relative; height: 230px; }
.chart-box canvas { width: 100% !important; height: 100% !important; }
.chart-legend-note { margin-top: 8px; font-size: 12px; color: var(--text-3); }

/* ---------------- 数据表（PC 表格 / 移动卡片） ---------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.data th, table.data td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data th { font-size: 12px; font-weight: 600; color: var(--text-2); background: #fafcfa; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num { font-variant-numeric: tabular-nums; }

/* ---------------- 用户菜单 ---------------- */
.usermenu {
  position: fixed;
  top: calc(var(--safe-t) + 56px);
  right: 14px;
  z-index: 95;
  min-width: 186px;
  padding: 6px;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(-6px) scale(.98);
  pointer-events: none;
  transition: opacity .16s, transform .16s;
}
.usermenu.on { opacity: 1; transform: none; pointer-events: auto; }
.usermenu .who { padding: 9px 12px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.usermenu .who b { display: block; font-size: 14px; font-weight: 600; }
.usermenu .who span { font-size: 12px; color: var(--text-3); }
.usermenu a, .usermenu button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 14px;
  color: var(--text);
  text-align: left;
}
.usermenu a:active, .usermenu button:active { background: var(--brand-soft-2); }
.usermenu .danger { color: var(--danger); }

/* ---------------- 搜索结果 ---------------- */
.res-item { padding: 12px 15px; border-bottom: 1px solid var(--line); }
.res-item:last-child { border-bottom: 0; }
.res-item .kind { font-size: 11.5px; color: var(--text-3); }

/* ---------------- 状态点 ---------------- */
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-right: 5px; vertical-align: 1px; }
.dot.warn { background: var(--warn); }
.dot.danger { background: var(--danger); }
.dot.gray { background: #c3ccc6; }

/* ---------------- 403 / 404 ---------------- */
.state-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
}
.state-page .code { font-size: 46px; font-weight: 700; color: #d7e2da; line-height: 1; }
.state-page h1 { margin: 0; font-size: 18px; }
.state-page p { margin: 0; font-size: 13.5px; color: var(--text-2); }

/* ============================================================
   ≥768px：平板 / PC
   ============================================================ */
@media (min-width: 768px) {
  body {
    padding-bottom: 0;
    padding-left: 218px;
    padding-top: 0;
  }
  .tabbar { display: none; }
  .page-head { display: none; }
  .wrap { padding: 26px 26px 30px; }

  /* 左侧导航 */
  .sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 218px;
    padding: 20px 14px;
    background: #fff;
    border-right: 1px solid var(--line);
    z-index: 45;
  }
  .sidebar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 18px;
    font-size: 15.5px;
    font-weight: 600;
  }
  .sidebar .brand .logo {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 10px;
    background: var(--brand-soft); color: var(--brand-dark);
    flex: 0 0 auto;
  }
  .sidebar nav { display: flex; flex-direction: column; gap: 2px; }
  .sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14.5px;
    color: var(--text-2);
    transition: background .15s, color .15s;
  }
  .sidebar nav a:hover { background: var(--brand-soft-2); }
  .sidebar nav a.on { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
  .sidebar .side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 10px; }
  .sidebar .side-foot a, .sidebar .side-foot button {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 9px 12px; border-radius: 10px;
    font-size: 13.5px; color: var(--text-2); text-align: left;
  }
  .sidebar .side-foot a:hover, .sidebar .side-foot button:hover { background: var(--brand-soft-2); }

  /* 顶栏：搜索 + 用户 */
  .pc-top {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 0 18px;
  }
  .pc-top h1 { margin: 0; font-size: 23px; font-weight: 600; flex: 0 0 auto; }
  .pc-search { position: relative; flex: 1; max-width: 380px; margin-left: auto; }
  .pc-search input {
    width: 100%;
    height: 40px;
    padding: 0 12px 0 36px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
    outline: none;
  }
  .pc-search input:focus { border-color: var(--brand); }
  .pc-search svg { position: absolute; left: 11px; top: 12px; color: var(--text-3); }
  .pc-user {
    display: flex; align-items: center; gap: 9px;
    padding: 6px 12px 6px 7px; border-radius: 999px;
    border: 1px solid var(--line); background: #fff;
    font-size: 13.5px; color: var(--text-2);
  }
  .pc-user .avatar {
    display: flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--brand-soft); color: var(--brand-dark);
    font-size: 12.5px; font-weight: 600;
  }

  /* 多列流式 */
  .cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
  .cols-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
  .cols-side { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 14px; align-items: start; }
  .card { padding: 18px 20px; margin-bottom: 14px; }
  .quick { grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .stats { gap: 14px; }
  .stat { padding: 18px 12px; }
  .stat .n { font-size: 27px; }
  .chart-box { height: 280px; }

  /* PC 居中弹窗 */
  .sheet {
    left: 50%;
    bottom: auto;
    top: 50%;
    right: auto;
    width: 520px;
    max-width: calc(100vw - 48px);
    max-height: 86vh;
    border-radius: 16px;
    transform: translate(-50%, -46%) scale(.98);
    opacity: 0;
    transition: transform .2s cubic-bezier(.22,.8,.3,1), opacity .18s;
  }
  .sheet.on { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  .sheet-head { border-radius: 16px 16px 0 0; padding: 18px 22px 12px; }
  .sheet-head::before { display: none; }
  .sheet-head h3 { text-align: left; }
  .sheet-body { padding: 18px 22px 4px; }
  .sheet-foot { padding: 14px 22px 18px; }
  .sheet.wide { width: 700px; }

  #toast { bottom: 34px; }
  .usermenu { top: 74px; right: 26px; }
  .login-card { padding: 32px 28px 26px; }
}

@media (min-width: 768px) and (max-width: 1024px) {
  body { padding-left: 200px; }
  .sidebar { width: 200px; }
  .cols-3 { grid-template-columns: 1fr 1fr; }
}

/* 极窄屏 */
@media (max-width: 359px) {
  .quick { grid-template-columns: repeat(2, 1fr); }
  .stat .n { font-size: 21px; }
  .row-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 420px) {
  .row-3 { grid-template-columns: 1fr 1fr; }
}

/* 减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
