/* ===================== 鹦鹉繁殖宝 V2.0 ===================== */
:root {
  --primary: #10b981;
  --primary-d: #059669;
  --primary-l: #d1fae5;
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #1c1c1e;
  --sub: #8a8a8e;
  --line: #ececef;
  --ok: #10b981;
  --warn: #ff9f0a;
  --danger: #ff453a;
  --blue: #0a84ff;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(0, 0, 0, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { display: none; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: linear-gradient(135deg, var(--primary), var(--primary-d));
  color: #fff; padding: 14px 18px 12px; padding-top: max(14px, env(safe-area-inset-top));
  box-shadow: var(--shadow);
}
.top-title { font-size: 19px; font-weight: 700; }
.top-sub { font-size: 12px; opacity: .8; margin-top: 2px; }
.view { flex: 1; padding: 14px 14px 90px; overflow-y: auto; }

/* ---------- 导航 ---------- */
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px;
  color: var(--sub); font-size: 14px; font-weight: 600; position: relative; transition: .15s;
}
.nav-item span { flex: 1; }
.nav-item.on { background: var(--primary-l); color: var(--primary-d); }
.nav-item .dot {
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px;
  border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px;
}
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(8px); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabbar .nav-item { flex: 1; flex-direction: column; gap: 3px; padding: 7px 2px 6px; font-size: 11px; border-radius: 0; }
.tabbar .nav-item .ic { width: 22px; height: 22px; }
.tabbar .nav-item.on { background: none; color: var(--primary-d); }

/* ---------- 卡片 / 概览 ---------- */
.page { display: flex; flex-direction: column; gap: 14px; }
.greet { display: flex; justify-content: space-between; align-items: baseline; }
.greet b { font-size: 18px; } .greet span { font-size: 12px; color: var(--sub); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.card-h { font-size: 14px; font-weight: 700; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.card-h .more { font-size: 12px; color: var(--primary-d); font-weight: 600; }
.mini-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.mini { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 8px; text-align: center; display: block; }
.mini-ic { color: var(--primary); display: flex; justify-content: center; }
.mini-v { font-size: 20px; font-weight: 800; margin: 4px 0 2px; }
.mini-v.up { color: var(--primary-d); } .mini-v.down { color: var(--danger); }
.mini-k { font-size: 11px; color: var(--sub); }
.kv { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv span { color: var(--sub); } .kv b { font-weight: 700; } .kv b.up { color: var(--ok); } .kv b.down { color: var(--danger); }

/* ---------- 列表项 ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.item { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; display: flex; align-items: center; gap: 12px; }
.item .avatar { width: 42px; height: 42px; border-radius: 12px; background: var(--primary-l); color: var(--primary-d); display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 800; flex: none; }
.item .avatar.m { background: #e6f0ff; color: var(--blue); } .item .avatar.f { background: #ffeef2; color: #ff5b7f; } .item .avatar.u { background: #f0f0f3; color: var(--sub); }
.item-m { flex: 1; min-width: 0; }
.item-m b { font-size: 15px; display: block; }
.item-m span { font-size: 12px; color: var(--sub); display: block; }
.item-m .sub { color: var(--primary-d); font-size: 12px; }
.item-r { color: var(--sub); display: flex; align-items: center; }
.item-r.price { font-weight: 800; color: var(--ok); }
.item.egg.ok .avatar { background: #e8f9ee; color: var(--ok); }
.item.egg.bad .avatar { background: #ffeaea; color: var(--danger); }
.mini-del { background: none; border: none; color: var(--danger); padding: 6px; }
.bar { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.bar b { flex: 1; font-size: 16px; }
.bar .back { background: var(--primary-l); color: var(--primary-d); border: none; width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }

/* ---------- 分段筛选 ---------- */
.seg-bar { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.seg { padding: 6px 12px; background: var(--card); border-radius: 20px; font-size: 13px; color: var(--sub); box-shadow: var(--shadow); white-space: nowrap; }
.seg.on { background: var(--primary); color: #fff; }

/* ---------- 按钮 ---------- */
.btn { background: var(--primary); color: #fff; border: none; border-radius: 10px; padding: 10px 16px; font-size: 14px; font-weight: 600; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.ghost { background: var(--bg); color: var(--text); }
.btn.danger { background: var(--danger); }
.btn:active { transform: scale(.97); }
.fab { position: fixed; right: 18px; bottom: calc(84px + var(--safe-b)); z-index: 25; width: 52px; height: 52px; border-radius: 50%; background: var(--primary); color: #fff; border: none; box-shadow: 0 6px 18px rgba(31, 157, 85, .45); display: flex; align-items: center; justify-content: center; }
.fab .ic { width: 26px; height: 26px; stroke: #fff; }

/* ---------- 快捷记一笔 ---------- */
.quick-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick { background: var(--card); border: none; border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 4px; display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--primary-d); font-size: 12px; font-weight: 600; }
.quick .ic { stroke: var(--primary); }

/* ---------- 预警 ---------- */
.alert-list { display: flex; flex-direction: column; gap: 8px; }
.alert-row { display: flex; gap: 10px; padding: 10px; border-radius: 10px; background: var(--bg); align-items: flex-start; }
.alert-row .ar-ic { color: var(--sub); margin-top: 2px; }
.alert-row.urgent { background: #ffeaea; } .alert-row.urgent .ar-ic { color: var(--danger); }
.alert-row.warn { background: #fff6e6; } .alert-row.warn .ar-ic { color: var(--warn); }
.alert-row .ar-t { flex: 1; } .alert-row .ar-t b { display: block; font-size: 14px; } .alert-row .ar-t span { font-size: 12px; color: var(--sub); }
.alerts-sec { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; }
.alerts-sec .as-h { font-weight: 700; font-size: 14px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.badge { background: var(--primary-l); color: var(--primary-d); font-size: 11px; border-radius: 10px; padding: 1px 8px; font-weight: 700; }

/* ---------- 图例 ---------- */
.legend { display: flex; gap: 14px; font-size: 12px; margin-bottom: 4px; }
.lg { display: flex; align-items: center; gap: 4px; color: var(--sub); }
.lg::before { content: ''; width: 10px; height: 10px; border-radius: 3px; background: currentColor; }
.lg.up { color: var(--primary); } .lg.down { color: var(--danger); }

/* ---------- 最近记录 / 待办 ---------- */
.rc { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.rc:last-child { border-bottom: none; }
.rc-d { color: var(--sub); font-size: 12px; min-width: 42px; }
.rc-t { flex: 1; }
.rc.task .ck { width: 18px; height: 18px; border: 2px solid var(--line); border-radius: 5px; display: flex; align-items: center; justify-content: center; color: var(--ok); }
.rc.task.done .rc-t { text-decoration: line-through; color: var(--sub); }
.rc.task.done .ck { background: var(--ok); border-color: var(--ok); color: #fff; }

/* ---------- 空态 ---------- */
.empty { text-align: center; color: var(--sub); font-size: 13px; padding: 22px 0; }

/* ---------- 表单 / 弹窗 ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--sub); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 15px; background: #fafafa; color: var(--text); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); background: #fff; }
.field textarea { min-height: 64px; resize: vertical; }
.fhint { font-size: 11px; color: var(--sub); margin-top: 4px; }
.modal-mask { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: #fff; width: 100%; max-width: 460px; border-radius: 18px 18px 0 0; max-height: 90vh; overflow-y: auto; animation: up .2s ease; }
@keyframes up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 16px; font-weight: 700; font-size: 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; }
.modal-h .x { background: none; border: none; font-size: 18px; color: var(--sub); }
.modal-b { padding: 16px; }
.modal-f { padding: 12px 16px calc(16px + var(--safe-b)); display: flex; gap: 10px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: #fff; }
.modal-f .btn { flex: 1; }
.confirm-txt { margin: 4px 0 8px; font-size: 14px; }

/* ---------- 备份 / 关于 ---------- */
.backup-btns { display: flex; flex-direction: column; gap: 10px; }
.backup-btns .btn { display: flex; align-items: center; justify-content: center; gap: 8px; }
.about { text-align: center; color: var(--sub); }
.about .sub { font-size: 12px; margin-top: 4px; }

/* ===================== PC 端 ===================== */
@media (min-width: 860px) {
  .sidebar {
    display: flex; flex-direction: column; width: 232px; flex: none; background: var(--card);
    border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh;
  }
  .sidebar .brand { display: flex; align-items: center; gap: 8px; padding: 4px 10px 16px; color: var(--primary-d); }
  .sidebar .brand b { font-size: 17px; } .sidebar .brand i { font-size: 11px; color: var(--sub); font-style: normal; }
  .sidebar .nav-item { font-size: 15px; }
  .topbar { border-radius: 0; }
  .view { padding: 22px; max-width: 1100px; margin: 0 auto; width: 100%; }
  .tabbar { display: none; }
  .fab { right: max(18px, calc((100vw - 1100px) / 2 - 60px)); bottom: 28px; }
  .mini-grid { grid-template-columns: repeat(4, 1fr); }
  .quick-row { grid-template-columns: repeat(4, 1fr); }
  .modal-mask { align-items: center; }
  .modal { border-radius: 18px; }
}

/* ===================== 登录 / 注册 ===================== */
.auth-mode .app,
.auth-mode .tabbar { display: none !important; }

.auth-screen {
  position: fixed; inset: 0; z-index: 999;
  background: linear-gradient(160deg, #ecfdf5 0%, #f4f6f5 55%, #ffffff 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px 18px calc(24px + var(--safe-b));
  overflow-y: auto;
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--card); border-radius: 18px;
  box-shadow: 0 10px 40px rgba(16, 185, 129, .12), var(--shadow);
  padding: 28px 22px 22px;
}
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-logo {
  width: 62px; height: 62px; margin: 0 auto 12px;
  border-radius: 18px; background: var(--primary-l); color: var(--primary-d);
  display: flex; align-items: center; justify-content: center;
}
.auth-logo .ic { width: 34px; height: 34px; stroke-width: 1.6; }
.auth-brand h1 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: .5px; }
.auth-brand p { margin: 6px 0 0; font-size: 12.5px; color: var(--sub); }

.auth-tabs {
  display: flex; gap: 6px; background: var(--bg);
  border-radius: 12px; padding: 4px; margin-bottom: 18px;
}
.auth-tabs button {
  flex: 1; border: none; background: transparent; color: var(--sub);
  font-size: 14px; font-weight: 600; padding: 9px 0; border-radius: 9px;
  cursor: pointer; font-family: inherit;
}
.auth-tabs button.on { background: var(--card); color: var(--primary-d); box-shadow: var(--shadow); }

.auth-form label {
  display: block; font-size: 12.5px; color: var(--sub);
  margin: 0 0 6px 2px; font-weight: 600;
}
.auth-form input {
  width: 100%; border: 1px solid var(--line); background: #fbfbfc;
  border-radius: 11px; padding: 12px 13px; font-size: 15px;
  color: var(--text); font-family: inherit; outline: none;
  margin-bottom: 14px; transition: border-color .15s, box-shadow .15s;
}
.auth-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, .14);
  background: #fff;
}

/* 确认密码（仅注册模式显示） / 记住密码（仅登录模式显示）
   默认隐藏，显隐由 auth.js 直接切换内联 display，浏览器与 jsdom 表现一致 */
.auth-pw2 { display: none; }
.auth-remember { display: none; }
.auth-remember {
  align-items: center; gap: 8px;
  margin: 0 0 12px 2px; font-size: 13.5px; color: var(--sub); font-weight: 600;
}
.auth-remember input {
  width: 17px; height: 17px; margin: 0; flex: none;
  accent-color: var(--primary); cursor: pointer;
}
.auth-remember span { user-select: none; }

.auth-tip { font-size: 13px; margin: -4px 0 10px; min-height: 18px; }
.auth-tip.bad { color: var(--danger); }
.auth-tip.ok { color: var(--primary-d); }

.btn.block { width: 100%; padding: 13px 16px; font-size: 15px; }
.btn:disabled { opacity: .6; }

.auth-foot {
  margin-top: 16px; text-align: center;
  font-size: 12px; color: var(--sub); line-height: 1.6;
}

/* 账号卡片（我的页） */
.kv .sync-ok { color: var(--primary-d); }
.kv .sync-bad { color: var(--danger); }

@media (min-width: 860px) {
  .auth-card { padding: 34px 30px 26px; }
}

/* ===================== 繁殖闭环 ===================== */
.pipeline {
  display: flex; align-items: stretch; gap: 2px; overflow-x: auto; padding: 4px 2px 6px;
}
.pipeline .pf {
  flex: 1 0 auto; min-width: 64px; text-align: center; background: var(--bg);
  border-radius: 10px; padding: 10px 6px; display: flex; flex-direction: column; gap: 3px;
  color: var(--text); text-decoration: none;
}
.pipeline .pf b { font-size: 18px; font-weight: 800; color: var(--primary-d); }
.pipeline .pf span { font-size: 11px; color: var(--sub); white-space: nowrap; }
.pipeline .pf-ar { align-self: center; color: var(--sub); font-size: 16px; flex: 0 0 auto; }
.pipeline .pf:active { transform: scale(.97); }

.hint { font-size: 12px; color: var(--sub); line-height: 1.6; margin-top: 6px; }

/* 雏鸟列表状态色 */
.item.chick.ing .avatar { background: #e0f2fe; color: #0284c7; }
.item.chick.wean .avatar { background: var(--primary-l); color: var(--primary-d); }
.item.chick.sold .avatar { background: #f1f1f4; color: var(--sub); }
.item.chick.bad .avatar { background: #ffe4e1; color: var(--danger); }
.item.chick-overview .avatar { background: var(--primary-l); color: var(--primary-d); }

/* 销售关联雏鸟多选 */
.chick-link .chick-pick { border: 1px solid var(--line); border-radius: 11px; padding: 6px; background: #fbfbfc; }
.chick-pick .cp {
  display: flex; align-items: center; gap: 8px; padding: 8px 6px; font-size: 13.5px;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.chick-pick .cp:last-child { border-bottom: none; }
.chick-pick .cp input { width: 17px; height: 17px; accent-color: var(--primary); flex: none; }
