body { font-family: -apple-system, sans-serif; font-size: 18px; margin: 0; background: #f7f7f7; color: #222; }
.topbar { background: #2e7d32; color: white; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; }
.brand { font-weight: bold; font-size: 20px; text-decoration: none; color: inherit; }
.topbar-link { color: white; }
main { padding: 16px; max-width: 480px; margin: 0 auto; }
.flash { background: #fff3cd; padding: 10px; border-radius: 6px; margin: 8px 0; }
.btn { display: block; width: 100%; padding: 16px; font-size: 20px; text-align: center; border-radius: 10px; border: none; margin: 10px 0; text-decoration: none; box-sizing: border-box; color: #222; background: #e0e0e0; }
.btn-primary { background: #2e7d32; color: white; }
.btn-danger { background: #c62828; color: white; }
.card { background: white; border-radius: 10px; padding: 14px; margin: 10px 0; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.card.due { border-left: 6px solid #c62828; }
.card.tracking { border-left: 6px solid #f9a825; }
.card.estrus { border-left: 6px solid #ef6c00; }
.cow-name.sold { color: #c62828; }
.cow-name { color: #1565c0; font-weight: bold; }
.card-link { display: block; text-decoration: none; color: inherit; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 10px 0; }
.photo-thumb { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; cursor: pointer; }
.lightbox { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 100; flex-direction: column; align-items: center; justify-content: center; padding: 20px; box-sizing: border-box; }
.lightbox img { max-width: 100%; max-height: 70vh; border-radius: 8px; }
.lightbox form { margin-top: 16px; width: 200px; }
.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }
.home-tile { aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: white; border-radius: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); text-decoration: none; color: #222; font-size: 22px; font-weight: bold; }
.home-tile-icon { font-size: 48px; }
.home-tile { position: relative; }
.tile-badge { position: absolute; top: 8px; right: 8px; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 17px; background: #c62828; color: white; font-size: 20px; line-height: 34px; text-align: center; box-sizing: border-box; }
input, select { width: 100%; padding: 12px; font-size: 18px; margin: 6px 0 14px; box-sizing: border-box; }
label { font-size: 16px; color: #444; display: block; }
table { width: 100%; border-collapse: collapse; background: white; }
td, th { padding: 8px; border-bottom: 1px solid #ddd; text-align: left; font-size: 15px; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.page-head h1 {
  margin: 0;
}

/* 拍照按钮做得跟其它大按钮一样醒目，别让老人找 */
.photo-pick {
  display: block;
  text-align: center;
  padding: 24px;
  margin: 16px 0;
  border: 2px dashed #999;
  border-radius: 8px;
  font-size: 20px;
}

.row-warn {
  color: #c00;
  margin: 4px 0 0;
}
.row-hint {
  color: #777;
  margin: 4px 0 0;
}

/* 逾期（超过 OVERDUE_DAYS 天还没标已产）。前台不单开区块，只把卡片压深一档，
   .card.due.overdue 三个类，盖得过上面 .card.due 的边框色。 */
.card.due.overdue {
  border-left-color: #7f0000;
  background: #fff5f5;
}

/* ── 管理后台 ──────────────────────────────────────────────
   后台是管理员一个人在电脑上看的，跟前台老人页的取向正好相反：
   信息密度优先，字号压小、放开宽度。所有规则都挂在 .admin-* 或 main.wide
   下面，碰不到前台。 */
main.wide {
  max-width: 1100px;
  font-size: 15px;
}
main.wide h1 { font-size: 22px; margin: 0; }
main.wide h2 { font-size: 16px; margin: 0 0 2px; }

.admin-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.admin-nav { display: flex; gap: 10px; font-size: 14px; }
.admin-nav a { color: #1565c0; }
.admin-nav-here { color: #666; font-weight: bold; }
.admin-date { margin-left: auto; color: #777; font-size: 14px; }

.admin-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
  font-size: 14px;
}
.admin-stat {
  background: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 4px 10px;
}
.admin-stat b { font-size: 16px; }
.admin-stat.s-overdue  { border-color: #7f0000; color: #7f0000; }
.admin-stat.s-due      { border-color: #c62828; color: #c62828; }
.admin-stat.s-estrus   { border-color: #ef6c00; color: #ef6c00; }
.admin-stat.s-tracking { border-color: #999;    color: #666; }

.admin-group { margin: 0 0 22px; }
.admin-group h2 { padding-left: 8px; border-left: 4px solid #999; }
.admin-group h2.g-overdue  { border-left-color: #7f0000; color: #7f0000; }
.admin-group h2.g-due      { border-left-color: #c62828; color: #c62828; }
.admin-group h2.g-estrus   { border-left-color: #ef6c00; color: #ef6c00; }
.admin-group h2.g-tracking { border-left-color: #999;    color: #555; }
.admin-group-n {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: #eee;
  color: #444;
  font-size: 13px;
  text-align: center;
}
.admin-group-note { margin: 0 0 8px 12px; color: #888; font-size: 13px; }
.admin-empty { margin: 0 0 0 12px; color: #aaa; font-size: 14px; }

/* 表格按内容宽度收拢，不拉满 1100px——拉满之后"配种日"和"天数"之间空一大片，
   眼睛横着跳容易串行。 */
main.wide table { width: auto; min-width: 560px; }
main.wide td, main.wide th { padding: 5px 22px 5px 8px; font-size: 14px; }
main.wide th { background: #f0f0f0; color: #555; font-weight: normal; }
.c-owner { font-weight: bold; }
/* 牛名不用链接蓝——后台这些名字点不动，蓝色是个假的可点暗示。 */
.c-cow { color: #333; font-weight: bold; }
.c-dim { color: #777; }
.c-num { text-align: right; font-variant-numeric: tabular-nums; }

#cow-search {
  width: 320px;
  max-width: 100%;
  padding: 6px 10px;
  font-size: 15px;
  margin: 0 0 10px;
}
tr[hidden] { display: none; }
.admin-kicker {
  background: #2e7d32;
  color: white;
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 12px;
}

/* 代操作横幅。故意做得刺眼——最怕的是忘了自己正在代谁录，
   把张姐的牛记到李家头上。退出按钮就在横幅里，不用去别处找。 */
.acting-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: #c62828;
  color: white;
  padding: 10px 16px;
  font-size: 16px;
}
.acting-bar b { font-size: 18px; }
.acting-bar form { margin: 0; }
.acting-bar button {
  background: white;
  color: #c62828;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 15px;
  font-weight: bold;
}

.act-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; }
.act-bar-label { color: #777; font-size: 14px; }
.act-form { margin: 0; }
.act-form button {
  background: #2e7d32;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 14px;
}

.phone-number { font-size: 22px; font-weight: bold; margin: 0 0 8px; letter-spacing: 1px; }
.phone-label-form { display: flex; gap: 8px; align-items: center; }
.phone-label-form input { margin: 0; }
.phone-label-form .btn { width: auto; padding: 12px 18px; margin: 0; flex: 0 0 auto; }
.no-phone { color: #c62828; font-weight: bold; }
.phone-line { white-space: nowrap; }
#member-search {
  width: 320px;
  max-width: 100%;
  padding: 6px 10px;
  font-size: 15px;
  margin: 0 0 10px;
}

/* 删号码是次要动作，不该跟「添加」一样醒目——手机号现在是登录凭据，
   老人一巴掌拍下去删掉自己唯一的号，就只剩记不住的用户名了。
   压小 + 加 confirm，两道都要。 */
.btn-plain-danger {
  display: inline-block;
  width: auto;
  padding: 8px 14px;
  font-size: 15px;
  background: none;
  border: 1px solid #c62828;
  color: #c62828;
  border-radius: 6px;
  margin: 10px 0 0;
}

/* 按住说话。touch-action:none 挡住按住时页面跟着滚；user-select 和
   touch-callout 挡住长按弹出的选择菜单和放大镜——这三条少一条，
   手势在手机上就会被浏览器截胡。 */
.hold-btn {
  display: block;
  width: 100%;
  padding: 40px 16px;
  font-size: 26px;
  font-weight: bold;
  color: white;
  background: #2e7d32;
  border: none;
  border-radius: 14px;
  margin: 16px 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.hold-btn.recording { background: #c62828; }
.hold-btn:disabled { background: #9e9e9e; }

/* 提醒页上那家的电话。这页是照着打电话用的，号码得跟"谁家该盯什么"在同一行。
   tel: 链接在手机上点了直接拨，电脑上无害。 */
.call { display: block; font-weight: normal; font-size: 13px; color: #1565c0; }
.call + .call { margin-top: 1px; }
.c-owner .no-phone { display: block; font-size: 13px; font-weight: normal; }
