:root {
  --ink: #172522;
  --muted: #6d7f79;
  --line: #d7e3df;
  --green: #236b5b;
  --green-dark: #184e43;
  --soft: #eaf3f0;
  --page: #eef4f1;
  --orange: #c8792c;
  --orange-soft: #fff5e6;
  --danger: #a93f3a;
  --white: #fff;
  --shadow: 0 10px 30px rgba(31, 71, 61, .08);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--page); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--green); text-decoration: none; }

.appbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 66px;
  padding: 9px max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .97);
  backdrop-filter: blur(12px);
}
.brand { display: flex; min-width: 0; align-items: center; gap: 9px; color: var(--ink); }
.brand > span:last-child { min-width: 0; }
.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border-radius: 11px;
  color: #fff;
  background: var(--green);
  font-weight: 900;
}
.brand strong, .brand small { display: block; overflow: hidden; max-width: 44vw; white-space: nowrap; text-overflow: ellipsis; }
.brand strong { font-size: 13px; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.header-actions { display: flex; align-items: center; gap: 11px; font-size: 12px; font-weight: 700; }
.header-actions form { margin: 0; }
.link-button { padding: 0; border: 0; color: var(--green); background: none; cursor: pointer; }

.page-shell { width: min(100%, 920px); margin: 0 auto; padding: 18px 16px 100px; }
.flash-stack { position: fixed; z-index: 50; top: 76px; right: 14px; left: 14px; display: grid; gap: 6px; max-width: 520px; margin: 0 auto; }
.flash { padding: 11px 14px; border: 1px solid #b9d9ce; border-radius: 12px; color: var(--green-dark); background: #ecf8f3; box-shadow: var(--shadow); font-size: 13px; }
.flash.error { border-color: #efc3bf; color: var(--danger); background: #fff1f0; }

.screen-heading { margin: 6px 0 18px; }
.screen-heading.compact { margin-bottom: 12px; }
.screen-heading h1 { margin: 4px 0 5px; font-size: clamp(24px, 7vw, 32px); line-height: 1.2; }
.screen-heading p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.eyebrow { color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .08em; }

.panel, .auth-card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--white);
  box-shadow: var(--shadow);
}
.card-stack { display: grid; gap: 11px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.panel-title strong { font-size: 14px; }
.panel-title span { color: var(--muted); font-size: 11px; }
.panel-title.sub-title { margin-top: 13px; }

label { display: grid; gap: 6px; color: #40564f; font-size: 12px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid #c8d8d3;
  border-radius: 11px;
  outline: none;
  color: var(--ink);
  background: #fbfcfc;
}
input, select { min-height: 43px; padding: 9px 11px; }
textarea { padding: 11px 12px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(35, 107, 91, .1); }
label small { color: var(--muted); font-weight: 400; }
.check-row { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check-row input { width: 18px; min-height: 18px; }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 10px; }
.form-stack, .inline-form { display: grid; gap: 11px; }
.auth-card { width: min(100%, 450px); margin: 7vh auto 0; padding: 24px; }
.auth-card h1 { margin: 7px 0; font-size: 25px; }
.auth-card > p { margin: 0 0 20px; color: var(--muted); font-size: 13px; line-height: 1.7; }

.primary-button, .secondary-button {
  min-height: 48px;
  border: 0;
  border-radius: 13px;
  cursor: pointer;
  font-weight: 900;
}
.primary-button { color: #fff; background: var(--green); box-shadow: 0 8px 20px rgba(35, 107, 91, .18); }
.primary-button:active { background: var(--green-dark); transform: translateY(1px); }
.secondary-button { padding: 10px 14px; border: 1px solid var(--green); color: var(--green); background: #fff; }
.sticky-submit { position: sticky; z-index: 10; bottom: 12px; width: 100%; }
.safety-note { padding: 11px 13px; border: 1px solid #eccb9d; border-radius: 12px; color: #79501c; background: var(--orange-soft); font-size: 12px; line-height: 1.6; }
.empty-note { margin: 5px 0; color: var(--muted); font-size: 12px; line-height: 1.6; }

.check-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.choice-chip { display: block; }
.choice-chip input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.choice-chip { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; color: #466158; background: #f6f9f8; }
.choice-chip:has(input:checked) { border-color: #9dc8bb; color: var(--green); background: #e7f3ef; }

.quick-context { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.context-button { min-height: 51px; padding: 7px 10px; border: 1px solid #cbdcd6; border-radius: 12px; text-align: left; background: #fff; }
.context-button small, .context-button strong { display: block; }
.context-button small { margin-bottom: 3px; color: var(--muted); font-size: 10px; }
.context-button strong { overflow: hidden; color: var(--green); font-size: 13px; white-space: nowrap; text-overflow: ellipsis; }
.period-strip { display: flex; align-items: center; justify-content: space-between; margin: 9px 0; padding: 9px 10px; border-radius: 10px; color: #5c7069; background: #e7efec; font-size: 11px; }
.period-strip b { color: var(--green); }
.sync-status { padding: 5px 8px; border: 0; border-radius: 99px; color: var(--green); background: #dcece7; font-size: 10px; font-weight: 900; }
.sync-status.pending { color: #84521d; background: #ffefd8; }
.sync-status.failed { color: var(--danger); background: #fde8e6; }
.record-types { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin: 0 0 9px; padding: 0; border: 0; }
.record-types input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.record-types span { display: grid; min-height: 39px; place-items: center; border: 1px solid var(--line); border-radius: 10px; color: #60736c; background: #fff; font-size: 12px; font-weight: 800; }
.record-types input:checked + span { border-color: var(--green); color: #fff; background: var(--green); }
.marker-button { display: flex; width: 100%; min-height: 53px; align-items: center; justify-content: center; gap: 9px; margin-bottom: 9px; border: 1px solid #e3b77f; border-radius: 13px; color: #7b4b17; background: var(--orange-soft); }
.marker-button strong { font-size: 15px; }
.marker-button span { color: #93652d; font-size: 10px; }
.record-panel { padding: 13px; }
.record-panel textarea { min-height: 112px; }
.time-options { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 9px; }
.time-options > span { color: var(--muted); font-size: 10px; }
.time-options label { display: block; }
.time-options input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.time-options label span { display: block; padding: 6px 8px; border-radius: 8px; color: #61726d; background: #edf1f0; font-size: 10px; }
.time-options input:checked + span { color: #fff; background: var(--green); }
.record-links { display: grid; gap: 9px; margin-top: 11px; }
.attachment-box { display: grid; gap: 7px; margin-top: 11px; padding: 10px; border: 1px dashed #b9cbc5; border-radius: 11px; }
.attachment-box > small { color: var(--muted); font-size: 9px; line-height: 1.5; }
.file-button { display: grid; min-height: 39px; place-items: center; border: 1px solid var(--line); border-radius: 10px; color: var(--green); background: #fff; font-size: 11px; font-weight: 900; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.attachment-queue { display: grid; gap: 6px; }
.attachment-task { display: grid; grid-template-columns: 42px 1fr auto; gap: 8px; align-items: center; padding: 7px; border-radius: 9px; background: #f0f4f2; }
.attachment-task img { width: 42px; height: 42px; border-radius: 7px; object-fit: cover; }
.attachment-task .file-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 7px; color: var(--green); background: #dfece8; font-size: 10px; font-weight: 900; }
.attachment-task b, .attachment-task small { display: block; overflow: hidden; max-width: 180px; white-space: nowrap; text-overflow: ellipsis; }
.attachment-task b { font-size: 10px; }
.attachment-task small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.attachment-task button { border: 0; color: var(--danger); background: none; font-size: 10px; }
.pending-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; color: var(--muted); font-size: 10px; }
.recent-section { margin-top: 16px; }
.recent-list { display: grid; gap: 6px; }
.recent-item { display: grid; grid-template-columns: 44px 1fr auto; gap: 7px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 11px; color: #42574f; background: #fff; font-size: 11px; }
.recent-item time { color: var(--green); font-weight: 900; }
.recent-item span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.recent-item em { color: var(--green); font-size: 10px; font-style: normal; }
.bottom-nav { position: fixed; z-index: 15; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(3, 1fr); padding: 8px max(12px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(255, 255, 255, .98); }
.bottom-nav a { padding: 8px 3px; color: var(--muted); text-align: center; font-size: 11px; font-weight: 700; }
.bottom-nav a.active { color: var(--green); }

.sheet-dialog { width: min(100% - 18px, 520px); max-height: 84vh; margin: auto auto 0; padding: 20px 16px calc(25px + env(safe-area-inset-bottom)); border: 0; border-radius: 22px 22px 0 0; background: #fff; }
.sheet-dialog::backdrop { background: rgba(23, 37, 34, .42); }
.sheet-dialog h2 { margin: 0; font-size: 21px; }
.sheet-dialog > p { margin: 5px 0 15px; color: var(--muted); font-size: 12px; }
.dialog-close { position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border: 0; border-radius: 50%; color: #60706b; background: #eef2f1; font-size: 20px; }
.space-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; overflow-y: auto; }
.sheet-choice { min-height: 42px; padding: 7px; border: 1px solid var(--line); border-radius: 10px; color: #3f5e55; background: #f7faf9; font-size: 11px; }
.sync-details { display: grid; gap: 8px; margin: 15px 0; }
.sync-details div { display: flex; justify-content: space-between; padding: 10px; border-radius: 9px; background: #f1f5f3; font-size: 12px; }

.review-reminder { display: flex; justify-content: space-between; margin-bottom: 12px; padding: 10px 12px; border: 1px solid #edcc9b; border-radius: 11px; color: #80511d; background: #fff2df; font-size: 12px; font-weight: 800; }
.linked-records { display: grid; gap: 6px; }
.linked-records a { display: grid; grid-template-columns: 43px 1fr; gap: 7px; padding: 8px; border-radius: 9px; color: #40564f; background: #f1f5f3; font-size: 11px; }
.linked-records time { color: var(--green); font-weight: 900; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.info-chip { padding: 6px 8px; border-radius: 8px; color: #3f6258; background: #e7f2ee; font-size: 10px; font-weight: 800; }
.info-chip.light { color: var(--muted); background: #f0f3f2; }
.people-facts { display: grid; gap: 6px; }
.people-facts > div { display: grid; grid-template-columns: 42px 1fr; gap: 7px; padding: 8px; border-radius: 9px; background: #f2f5f4; }
.people-facts b { color: var(--green); font-size: 11px; }
.people-facts span { color: #40544e; font-size: 11px; line-height: 1.5; }
.floating-add { position: fixed; right: max(18px, calc((100vw - 850px) / 2)); bottom: 24px; display: grid; width: 52px; height: 52px; place-items: center; border: 3px solid #fff; border-radius: 50%; color: #fff; background: var(--orange); box-shadow: 0 8px 20px rgba(88, 54, 20, .25); font-size: 24px; }

.feedback-panel { border-color: #ebcd9f; background: #fffaf3; }
.record-list-page { display: grid; gap: 9px; }
.record-card { display: grid; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: #fff; box-shadow: 0 5px 15px rgba(35, 73, 64, .04); }
.record-card > div { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; }
.record-card em { margin-left: auto; font-style: normal; }
.record-card strong { font-size: 13px; line-height: 1.6; }
.record-card small { color: var(--muted); }
.type-badge { padding: 4px 6px; border-radius: 7px; color: var(--green); background: var(--soft); font-weight: 900; }
.detail-panel dl { display: grid; gap: 7px; margin: 0; }
.detail-panel dl > div { display: grid; grid-template-columns: 80px 1fr; gap: 10px; }
.detail-panel dt { color: var(--muted); font-size: 11px; }
.detail-panel dd { margin: 0; font-size: 12px; }
.detail-panel h2 { margin: 18px 0 6px; font-size: 14px; }
.fact-content { margin: 0; font-size: 14px; line-height: 1.8; white-space: pre-wrap; }
.comment-list { display: grid; gap: 8px; margin-bottom: 12px; }
.comment-list > div { padding: 9px; border-radius: 9px; background: #f2f5f4; }
.comment-list b { color: var(--green); font-size: 11px; }
.comment-list time { margin-left: 8px; color: var(--muted); font-size: 9px; }
.comment-list p { margin: 5px 0 0; font-size: 12px; line-height: 1.6; }
.stored-attachments { display: grid; gap: 7px; }
.stored-attachments > a, .stored-attachments > div { display: flex; justify-content: space-between; gap: 10px; padding: 9px; border-radius: 9px; color: var(--ink); background: #f1f5f3; }
.stored-attachments b { overflow: hidden; font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.stored-attachments small { flex: 0 0 auto; color: var(--muted); font-size: 9px; }
details { margin-top: 7px; padding: 8px; border-radius: 8px; background: #f3f5f4; font-size: 11px; }
pre { white-space: pre-wrap; word-break: break-word; }

.management-grid { display: grid; gap: 12px; }
.export-panel { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.export-panel strong { font-size: 14px; }
.export-panel p { margin: 4px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.export-panel .secondary-button { display: grid; min-width: 92px; place-items: center; }
.inline-form { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); align-items: end; }
.inline-form .secondary-button { min-height: 43px; }
.simple-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.simple-list span { padding: 6px 8px; border-radius: 8px; color: #4d625c; background: #eef3f1; font-size: 10px; }
.simple-list b { margin-right: 5px; color: var(--green); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@media (min-width: 760px) {
  .page-shell { padding-top: 28px; }
  .management-grid { grid-template-columns: 1fr 1fr; }
  .management-grid article:last-child { grid-column: 1 / -1; }
  .bottom-nav { right: 50%; left: auto; width: 460px; transform: translateX(50%); border: 1px solid var(--line); border-bottom: 0; border-radius: 16px 16px 0 0; }
}
