/* 静姐视光 · 配镜登记 —— 移动端优先，无 CDN，无构建 */

:root {
  --green: #2f6f5e;
  --green-dark: #245647;
  --red: #c0392b;
  --orange: #d9822b;
  --gray: #7a8288;
  --line: #dfe4e6;
  --bg: #f4f6f6;
  --radius: 10px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #1f2529;
  background: var(--bg);
}

a { color: var(--green); }

/* ---------------------------------------------------------------- 顶栏 */

.topbar {
  background: var(--green);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brand { color: #fff; text-decoration: none; font-weight: 600; font-size: 17px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.who { font-size: 14px; opacity: .9; }
.inline-form { display: inline; margin: 0; }

.linkish {
  background: none;
  border: 1px solid rgba(255,255,255,.6);
  color: #fff;
  border-radius: 6px;
  padding: 6px 10px;
  min-height: 36px;
  font-size: 14px;
}

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

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 12px 96px;
}

.section { margin-top: 18px; }
.section-title { font-size: 16px; margin: 0 0 8px; color: #4a545a; }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.muted { color: var(--gray); }
.center-card { text-align: center; }
.block-link { display: block; text-decoration: none; }

/* ---------------------------------------------------------------- 控件 */

input[type="text"], input[type="password"], input[type="search"], input[type="number"],
input[type="date"], input[type="tel"], select, textarea {
  width: 100%;
  font-size: 16px;          /* 低于 16px 时 iOS 聚焦会自动放大 */
  font-family: inherit;
  padding: 11px 12px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: inherit;
}

textarea { min-height: 88px; }

select { appearance: none; -webkit-appearance: none; background-image: none; }

input:disabled { background: #eef1f2; color: #98a0a5; }

.field { display: block; margin-bottom: 12px; }
.field-label { display: block; font-size: 14px; color: #4a545a; margin-bottom: 4px; }
.field-hint { display: block; font-size: 13px; color: var(--gray); margin-top: 4px; }

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: 15px;
}

.checkline input[type="checkbox"] { width: 22px; height: 22px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  font-size: 16px;
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #1f2529;
  text-decoration: none;
  cursor: pointer;
}

.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:active { background: var(--green-dark); }
.btn-block { display: flex; width: 100%; }
.btn[disabled] { opacity: .6; }
.btn-sm { min-height: 40px; padding: 8px 12px; font-size: 14px; }
.btn-danger { border-color: var(--red); color: var(--red); }

.btn-new { margin-top: 12px; font-size: 18px; min-height: 52px; }

/* 性别 / 用途 等大按钮组 */
.choice-row { display: flex; gap: 8px; flex-wrap: wrap; }
.choice {
  flex: 1 1 0;
  min-width: 88px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 16px;
  cursor: pointer;
}
.choice input { position: absolute; opacity: 0; width: 0; height: 0; }
.choice.checked { border-color: var(--green); background: #e8f1ee; color: var(--green-dark); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 15px;
  cursor: pointer;
}
.chip.checked { border-color: var(--green); background: #e8f1ee; color: var(--green-dark); font-weight: 600; }

/* 开关 */
.switch { display: flex; align-items: center; justify-content: space-between; min-height: 44px; gap: 10px; }
.switch input { width: 26px; height: 26px; }

/* ---------------------------------------------------------------- 首页 */

.searchbar { display: flex; gap: 8px; }
.search-input { flex: 1 1 auto; }
.searchbar .btn { flex: 0 0 auto; }

.record-list { list-style: none; margin: 0; padding: 0; }
.record-row + .record-row { margin-top: 8px; }
.record-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  text-decoration: none;
  color: inherit;
  min-height: 60px;
}
.record-main { display: flex; flex-direction: column; min-width: 0; }
.record-name { font-weight: 600; font-size: 17px; }
.record-sub { font-size: 13px; color: var(--gray); }

.sync-tag { font-size: 13px; white-space: nowrap; padding: 3px 8px; border-radius: 999px; }
.sync-ok { color: #1e7d4f; background: #e6f4ec; }
.sync-pending { color: #6b7378; background: #eef1f2; }
.sync-failed { color: var(--red); background: #fbeae8; }
.sync-conflict { color: var(--orange); background: #fdf1e3; }
.sync-none { color: var(--gray); background: #eef1f2; }

/* ---------------------------------------------------------------- 搜索 */

.search-result-group {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}
.group-head {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 0;
  padding: 12px;
  min-height: 64px;
  font-family: inherit;
  font-size: 16px;
  cursor: pointer;
}
.group-name { font-weight: 600; font-size: 17px; }
.group-meta { font-size: 13px; color: var(--gray); }
.group-rx { font-size: 14px; color: #3c464c; margin-top: 2px; }
.group-body { border-top: 1px solid var(--line); display: none; }
.group-body.open { display: block; }
.group-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid #eef1f2;
  min-height: 56px;
}
.group-item:last-child { border-bottom: 0; }
.group-item-main { min-width: 0; }
.item-date { font-weight: 600; }
.item-sub { font-size: 13px; color: var(--gray); }

/* ---------------------------------------------------------------- 详情 */

.detail-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.detail-name { font-size: 22px; margin: 0; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }

.kv { display: grid; grid-template-columns: 34% 1fr; gap: 6px 8px; font-size: 15px; }
.kv dt { color: var(--gray); }
.kv dd { margin: 0; word-break: break-word; }

table.rx { width: 100%; border-collapse: collapse; font-size: 15px; }
table.rx th, table.rx td { border-bottom: 1px solid #eef1f2; padding: 8px 6px; text-align: left; }
table.rx th { color: var(--gray); font-weight: 500; font-size: 14px; }

.dirty { color: var(--orange); cursor: help; }

details.raw { margin-top: 12px; }
details.raw summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-size: 15px; }

.alert { border-radius: var(--radius); padding: 10px 12px; margin: 0 0 12px; font-size: 15px; }
.alert-error { background: #fbeae8; color: #8d2b20; border: 1px solid #f0c7c1; }
.alert-warn { background: #fdf5e3; color: #7a5a14; border: 1px solid #f0e0b8; }
.alert-ok { background: #e6f4ec; color: #1e7d4f; border: 1px solid #c4e3d2; }

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

details.form-section {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 12px;
}
details.form-section > summary {
  padding: 12px;
  min-height: 48px;
  display: flex;
  align-items: center;
  font-weight: 600;
  cursor: pointer;
}
.form-section-body { padding: 0 12px 12px; }

.rx-table { width: 100%; border-collapse: collapse; }
.rx-table th, .rx-table td { padding: 4px 3px; vertical-align: middle; }
.rx-table th { font-size: 13px; color: var(--gray); font-weight: 500; text-align: center; }
.rx-table td.rx-label { font-size: 14px; color: #4a545a; width: 30%; }
.rx-table select, .rx-table input { padding: 8px 6px; min-height: 44px; font-size: 16px; }
.rx-pair { display: flex; gap: 4px; align-items: center; }
.rx-pair > * { min-width: 0; }
.manual-link { font-size: 12px; }
.hidden { display: none !important; }

.amount-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.amount-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.amount-row .field-label { margin: 0; flex: 1 1 auto; }
.amount-row input { flex: 0 0 46%; }
.amount-readonly { font-size: 18px; font-weight: 600; color: var(--green-dark); }

.other-item { display: flex; gap: 6px; margin-bottom: 8px; }
.other-item input:first-child { flex: 1 1 auto; }
.other-item input:last-of-type { flex: 0 0 34%; }

.savebar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,.97);
  border-top: 1px solid var(--line);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
}
.savebar-inner { max-width: 720px; margin: 0 auto; }

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

.login-body { background: var(--green); }
.login-wrap { max-width: 380px; margin: 0 auto; padding: 40px 16px; }
.login-title { color: #fff; font-size: 20px; text-align: center; margin: 24px 0; }
.login-card { padding: 18px; }

@media (min-width: 600px) {
  .amount-grid { grid-template-columns: 1fr 1fr; }
}

.problem-card { margin-bottom: 10px; }
.form-title { font-size: 20px; margin: 4px 0 12px; }
.error-text { color: var(--red); }
.warn-text { color: #8a6412; }
.search-hint { font-size: 13px; margin: 8px 0; }
.notes-text { white-space: pre-wrap; margin: 0; }
