/* ==========================================================================
   小满 · 27 周早产儿居家护理手册
   纯静态、可离线、可打印。无外部依赖。
   ========================================================================== */

:root {
  --paper: #fbf8f3;
  --surface: #ffffff;
  --surface-2: #f4efe7;
  --ink: #1f2729;
  --ink-2: #46524f;
  --muted: #7c8580;
  --line: #e5ded3;
  --line-soft: #efe9e0;

  --brand: #2e6b5e;
  --brand-ink: #1d4d43;
  --brand-soft: #e4efea;
  --brand-line: #bcd7cd;

  --alert: #ac3a2c;
  --alert-soft: #fbeae6;
  --alert-line: #edc4bc;

  --warn: #996a12;
  --warn-soft: #fbf1da;
  --warn-line: #e8d3a5;

  --ok: #3a7355;
  --ok-soft: #e8f1ea;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(31, 39, 41, 0.05);
  --shadow: 0 2px 4px rgba(31, 39, 41, 0.04), 0 18px 32px -24px rgba(31, 39, 41, 0.35);

  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC",
    system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "Source Han Serif CN",
    Georgia, "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
  letter-spacing: 0.01em;
}

p { margin: 0 0 0.9em; }
ul, ol { margin: 0 0 0.9em; padding-left: 1.25em; }
li { margin-bottom: 0.35em; }
li::marker { color: var(--muted); }
strong { font-weight: 650; color: var(--ink); }
a { color: var(--brand-ink); text-underline-offset: 3px; }
img, svg { max-width: 100%; }
hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 28px 0;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-radius: 4px;
}

/* hidden 属性优先于任何 display 声明（.btn 等类会覆盖 UA 默认值） */
[hidden] {
  display: none !important;
}

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 999;
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip:focus { top: 12px; }

/* ============================== 顶栏 ============================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 64px;
  padding: 0 20px;
  background: rgba(251, 248, 243, 0.9);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.brand-mark {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand-soft);
  border: 1px solid var(--brand-line);
  display: grid;
  place-items: center;
  color: var(--brand-ink);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-title {
  font-family: var(--serif);
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.brand-sub {
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.age-pill {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 10px;
  border: 1px solid var(--brand-line);
  background: var(--brand-soft);
  color: var(--brand-ink);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}
.age-pill[hidden] { display: none !important; }
.age-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  flex: 0 0 auto;
}

.search-wrap {
  position: relative;
  flex: 0 1 260px;
  min-width: 0;
}

.search-wrap svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

#searchInput {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font: inherit;
  font-size: 14px;
  color: var(--ink);
}
#searchInput::placeholder { color: var(--muted); }
#searchInput:focus {
  border-color: var(--brand-line);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.search-results {
  position: absolute;
  top: 46px;
  right: 0;
  left: 0;
  min-width: 320px;
  max-height: 380px;
  overflow: auto;
  padding: 6px;
  margin: 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 70;
}
.search-results[hidden] { display: none; }
.search-results li { margin: 0; }
.search-results button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-2);
  cursor: pointer;
}
.search-results button:hover,
.search-results button.is-active { background: var(--surface-2); }
.search-results .sr-title {
  display: block;
  font-weight: 650;
  color: var(--ink);
  font-size: 13px;
}
.search-results .sr-desc {
  display: block;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-results .sr-empty {
  padding: 14px 12px;
  font-size: 13px;
  color: var(--muted);
}
mark {
  background: #f7e6b6;
  color: inherit;
  padding: 0 2px;
  border-radius: 3px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 15px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-ghost {
  background: var(--surface);
  color: var(--ink-2);
  border-color: var(--line);
}
.btn-ghost:hover { border-color: var(--brand-line); color: var(--brand-ink); background: var(--brand-soft); }
.btn-danger {
  background: var(--alert);
  color: #fff;
}
.btn-danger:hover { background: #923023; }
.btn-soft-danger {
  background: var(--alert-soft);
  color: var(--alert);
  border-color: var(--alert-line);
}
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }

.nav-toggle {
  display: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  color: var(--ink-2);
  cursor: pointer;
  place-items: center;
}

/* ============================== 布局 ============================== */

.shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: 44px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px 24px 96px;
}

.sidenav {
  position: sticky;
  top: 84px;
  align-self: start;
  max-height: calc(100vh - 108px);
  overflow: auto;
  padding-right: 6px;
  font-size: 14px;
}
.sidenav::-webkit-scrollbar { width: 5px; }
.sidenav::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.nav-group {
  margin: 0 0 20px;
}
.nav-label {
  margin: 0 0 8px;
  padding-left: 12px;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-list li { margin: 1px 0; }
.nav-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--ink-2);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-list a:hover { background: var(--surface-2); color: var(--ink); }
.nav-list a.is-current {
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-weight: 650;
}
.nav-list a.is-alert.is-current { background: var(--alert-soft); color: var(--alert); }
.nav-num {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0;
}

.nav-foot {
  margin-top: 24px;
  padding: 14px 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

main { min-width: 0; }

section {
  scroll-margin-top: 86px;
  margin-bottom: 62px;
}
section:last-of-type { margin-bottom: 24px; }

.sec-head { margin-bottom: 22px; }
.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.eyebrow::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
  max-width: 90px;
}
.sec-head h2 {
  font-size: clamp(25px, 3.2vw, 31px);
  margin-bottom: 8px;
}
.lede {
  max-width: 62ch;
  color: var(--ink-2);
  font-size: 15.5px;
  margin: 0;
}

h3 {
  font-size: 19px;
  margin: 0 0 10px;
}
h4 {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 650;
  margin: 0 0 6px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.card > :last-child { margin-bottom: 0; }
.card-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card-title h3, .card-title h4 { margin: 0; }
.card-sub { font-size: 12.5px; color: var(--muted); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(226px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); }
.stack { display: grid; gap: 16px; }

/* ============================== 提示块 ============================== */

.callout {
  position: relative;
  padding: 16px 18px 16px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 14.5px;
  line-height: 1.7;
}
.callout > :last-child { margin-bottom: 0; }
.callout .cl-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.callout::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 3px;
  background: var(--muted);
}
.callout-note { background: var(--brand-soft); border-color: var(--brand-line); }
.callout-note::before { background: var(--brand); }
.callout-note .cl-label { color: var(--brand-ink); }
.callout-warn { background: var(--warn-soft); border-color: var(--warn-line); }
.callout-warn::before { background: var(--warn); }
.callout-warn .cl-label { color: var(--warn); }
.callout-danger { background: var(--alert-soft); border-color: var(--alert-line); }
.callout-danger::before { background: var(--alert); }
.callout-danger .cl-label { color: var(--alert); }
.callout-plain { background: var(--surface); }

/* ============================== 今日看板 ============================== */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.age-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, #2e6b5e 0%, #245a4f 55%, #1d4d43 100%);
  color: #f3f8f5;
  border: 0;
  border-radius: var(--radius);
  padding: 24px 24px 20px;
  box-shadow: var(--shadow);
}
.age-card .ac-kicker {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #b9d6cc;
  margin-bottom: 8px;
  font-weight: 600;
}
.age-card .ac-big {
  font-family: var(--serif);
  font-size: clamp(32px, 5vw, 44px);
  line-height: 1.1;
  letter-spacing: 0.01em;
  margin-bottom: 4px;
}
.age-card .ac-big small {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  margin-left: 6px;
  color: #cfe3db;
}
.age-card .ac-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 13px;
  color: #cfe3db;
}
.age-card .ac-meta b { color: #fff; font-weight: 600; }
.age-card .ac-note {
  margin: 12px 0 0;
  font-size: 12.5px;
  color: #a9cbc0;
  line-height: 1.6;
}
.age-card .ac-edit {
  position: absolute;
  right: 14px;
  top: 14px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #eaf4f0;
  border-radius: 999px;
  padding: 5px 11px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.age-card .ac-edit:hover { background: rgba(255, 255, 255, 0.2); }

.setup-card {
  border: 1px dashed var(--brand-line);
  background: var(--brand-soft);
  padding: 22px;
}
.setup-card h3 { color: var(--brand-ink); font-size: 18px; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label {
  font-size: 12px;
  font-weight: 650;
  color: var(--ink-2);
  letter-spacing: 0.02em;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  font-size: 14px;
  color: var(--ink);
}
.field textarea { min-height: 86px; resize: vertical; line-height: 1.6; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand-line);
  box-shadow: 0 0 0 3px var(--brand-soft);
  outline: none;
}
.field .hint { font-size: 11.5px; color: var(--muted); }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  align-items: center;
}

/* 今日清单 */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { margin: 0; }
.check-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 2px;
  border-bottom: 1px dashed var(--line-soft);
  cursor: pointer;
}
.check-item:last-child { border-bottom: 0; }
.check-item input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.check-box {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin-top: 2px;
  border: 1.5px solid #cfc7ba;
  border-radius: 7px;
  background: var(--surface);
  display: grid;
  place-items: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.check-box svg { opacity: 0; transform: scale(0.6); transition: opacity 0.15s ease, transform 0.15s ease; color: #fff; }
.check-item input:checked + .check-box { background: var(--brand); border-color: var(--brand); }
.check-item input:checked + .check-box svg { opacity: 1; transform: scale(1); }
.check-item input:focus-visible + .check-box { outline: 2px solid var(--brand); outline-offset: 3px; }
.check-text { min-width: 0; }
.check-text .ct-main { display: block; font-size: 14.5px; line-height: 1.5; color: var(--ink); }
.check-text .ct-hint { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.check-item input:checked ~ .check-text .ct-main { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--brand-line); }

.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}
.progress {
  flex: 1;
  height: 6px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--brand);
  border-radius: 99px;
  transition: width 0.25s ease;
}
.progress-num { font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); }

/* 计数 */
.counters { display: grid; gap: 10px; grid-template-columns: repeat(3, 1fr); }
.counter {
  text-align: center;
  padding: 12px 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.counter .c-label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 2px; }
.counter .c-value {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
}
.counter .c-value small { font-size: 12px; color: var(--muted); font-weight: 400; }
.counter .c-btns { display: flex; justify-content: center; gap: 6px; margin-top: 6px; }
.counter .c-btns button {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.counter .c-btns button:hover { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand-ink); }
.counter.is-low .c-value { color: var(--warn); }

/* 奶量目标条 */
.meter { margin-top: 4px; }
.meter-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 8px;
  gap: 10px;
}
.meter-top b { font-family: var(--mono); font-size: 16px; color: var(--ink); }
.meter-bar {
  position: relative;
  height: 12px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
}
.meter-band {
  position: absolute;
  top: 0;
  bottom: 0;
  background: repeating-linear-gradient(135deg, #cfe4da 0 5px, #e4efea 5px 10px);
}
.meter-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  background: var(--brand);
  opacity: 0.9;
  border-radius: 99px;
  transition: width 0.3s ease;
}
.meter-fill.is-low { background: var(--warn); }
.meter-legend { font-size: 11.5px; color: var(--muted); margin-top: 6px; }

/* ============================== 表格 ============================== */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.6;
}
caption {
  caption-side: top;
  text-align: left;
  font-size: 12.5px;
  color: var(--muted);
  padding-bottom: 8px;
}
th, td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line-soft);
}
thead th {
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--surface);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfaf7; }
td.num, th.num { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.t-small { font-size: 13px; color: var(--ink-2); }

/* ============================== 时间线 ============================== */

.timeline { position: relative; padding-left: 26px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: var(--line);
}
.tl-item { position: relative; padding-bottom: 22px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: "";
  position: absolute;
  left: -23px;
  top: 7px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--brand);
}
.tl-when {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-ink);
  margin-bottom: 2px;
}
.tl-item h4 { margin-bottom: 6px; font-size: 15.5px; }
.tl-item p, .tl-item ul { font-size: 14.5px; }
.tl-item p:last-child, .tl-item ul:last-child { margin-bottom: 0; }

/* ============================== 数字指标 ============================== */

.stat {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: var(--surface);
}
.stat .s-label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 2px; }
.stat .s-value {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink);
}
.stat .s-value small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.stat .s-note { font-size: 12px; color: var(--muted); line-height: 1.5; margin-top: 2px; }
.stat.is-ok { background: var(--ok-soft); border-color: #cfe3d5; }
.stat.is-warn { background: var(--warn-soft); border-color: var(--warn-line); }
.stat.is-alert { background: var(--alert-soft); border-color: var(--alert-line); }

/* ============================== 危险信号 ============================== */

.flag-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

.flag-block {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
}
.flag-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  font-weight: 650;
  font-size: 14.5px;
  border-bottom: 1px solid var(--line);
}
.flag-head .fh-tag {
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 700;
}
.flag-now .flag-head { background: var(--alert-soft); color: var(--alert); border-bottom-color: var(--alert-line); }
.flag-now .fh-tag { background: var(--alert); color: #fff; }
.flag-soon .flag-head { background: var(--warn-soft); color: var(--warn); border-bottom-color: var(--warn-line); }
.flag-soon .fh-tag { background: var(--warn); color: #fff; }
.flag-cal .flag-head { background: var(--brand-soft); color: var(--brand-ink); border-bottom-color: var(--brand-line); }
.flag-cal .fh-tag { background: var(--brand); color: #fff; }

.flag-list { list-style: none; margin: 0; padding: 6px 0; }
.flag-list li {
  position: relative;
  padding: 9px 18px 9px 32px;
  font-size: 14.5px;
  line-height: 1.6;
  margin: 0;
  border-bottom: 1px dashed var(--line-soft);
}
.flag-list li:last-child { border-bottom: 0; }
.flag-list li::before {
  content: "";
  position: absolute;
  left: 17px;
  top: 17px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
}
.flag-now .flag-list li::before { background: var(--alert); }
.flag-soon .flag-list li::before { background: var(--warn); }
.flag-cal .flag-list li::before { background: var(--brand); }
.flag-list li b { color: var(--ink); }

/* ============================== 标签 / 折叠 ============================== */

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 12px;
  color: var(--ink-2);
  white-space: nowrap;
}
.chip-brand { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand-ink); }
.chip-alert { background: var(--alert-soft); border-color: var(--alert-line); color: var(--alert); }
.chip-warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }

details {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0;
  margin-bottom: 10px;
}
details > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  cursor: pointer;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  list-style: none;
  border-radius: inherit;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::after {
  content: "+";
  margin-left: auto;
  font-family: var(--mono);
  font-size: 17px;
  color: var(--muted);
  line-height: 1;
  transition: transform 0.15s ease;
}
details[open] > summary::after { content: "−"; }
details[open] > summary { border-bottom: 1px solid var(--line-soft); }
details > .details-body {
  padding: 14px 16px 16px;
  font-size: 14.5px;
}
details > .details-body > :last-child { margin-bottom: 0; }
details[open] { background: var(--surface); }

/* ============================== 记录本 ============================== */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  overflow-x: auto;
}
.tab {
  padding: 9px 14px;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--brand-ink); border-bottom-color: var(--brand); }
.tabpanel[hidden] { display: none; }

.feed-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  align-items: end;
}
.feed-form .span-2 { grid-column: span 2; }
.feed-form .form-actions { margin-top: 0; grid-column: 1 / -1; }

.entry-list { list-style: none; margin: 0; padding: 0; }
.entry {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line-soft);
  font-size: 14px;
}
.entry:last-child { border-bottom: 0; }
.entry-time {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-2);
  flex: 0 0 52px;
  padding-top: 1px;
}
.entry-main { flex: 1; min-width: 0; }
.entry-main .em-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.entry-main .em-amount { font-family: var(--mono); font-weight: 600; }
.entry-main .em-mode { font-size: 12px; color: var(--muted); }
.entry-main .em-note { font-size: 12.5px; color: var(--muted); }
.entry-del {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 6px;
}
.entry-del:hover { background: var(--alert-soft); color: var(--alert); }
.empty-state {
  padding: 22px 10px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.7;
}

.growth-chart { width: 100%; height: auto; display: block; }
.chart-empty { padding: 26px 10px; text-align: center; color: var(--muted); font-size: 13.5px; }

.data-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 12.5px;
  color: var(--muted);
}

/* ============================== 应急卡 ============================== */

.em-card {
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 20px 22px;
}
.em-card .em-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1.5px solid var(--ink);
  margin-bottom: 12px;
}
.em-card h3 { font-size: 19px; }
.em-card .em-sub { font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }
.em-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 20px;
  font-size: 13.5px;
}
.em-grid .em-k { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.em-grid .em-v { font-weight: 600; color: var(--ink); line-height: 1.5; word-break: break-all; }
.em-empty { color: var(--muted); font-weight: 400; font-style: italic; }
.em-red {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--alert-soft);
  border: 1px solid var(--alert-line);
  font-size: 12.5px;
  line-height: 1.6;
  color: #7d2a20;
}

/* ============================== 提示条 ============================== */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 200;
  max-width: min(92vw, 420px);
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-size: 13.5px;
  line-height: 1.55;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.is-in { opacity: 1; transform: translate(-50%, 0); }
.toast-warn { background: var(--warn); }
.toast-danger { background: var(--alert); }

/* ============================== 页脚 ============================== */

.foot {
  border-top: 1px solid var(--line);
  padding: 26px 0 0;
  margin-top: 20px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.7;
  max-width: 78ch;
}
.foot p { margin-bottom: 8px; }
.foot strong { color: var(--ink-2); }

/* ============================== 高亮跳转 ============================== */

.flash-target {
  animation: flash 1.6s ease;
  border-radius: var(--radius-sm);
}
@keyframes flash {
  0% { background: #f9ecc4; box-shadow: 0 0 0 6px #f9ecc4; }
  100% { background: transparent; box-shadow: 0 0 0 6px transparent; }
}

/* ============================== 响应式 ============================== */

@media (min-width: 900px) {
  .age-pill { display: inline-flex; }
}

@media (max-width: 1080px) {
  .shell { grid-template-columns: 210px minmax(0, 1fr); gap: 28px; }
  .hero { grid-template-columns: 1fr; }
}

@media (max-width: 880px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .nav-toggle { display: grid; }
  .brand-sub { display: none; }
  .search-wrap { flex: 1 1 auto; }
  #searchInput { font-size: 13px; }

  .shell { grid-template-columns: 1fr; gap: 0; padding: 18px 16px 80px; }

  .sidenav {
    position: fixed;
    z-index: 80;
    top: 0;
    left: 0;
    bottom: 0;
    width: 272px;
    max-height: none;
    padding: 78px 14px 24px;
    background: var(--paper);
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow);
    transform: translateX(-104%);
    transition: transform 0.22s ease;
    overflow: auto;
  }
  .sidenav.is-open { transform: none; }
  .nav-scrim {
    position: fixed;
    inset: 0;
    z-index: 75;
    background: rgba(31, 39, 41, 0.34);
    border: 0;
    padding: 0;
  }
  .nav-scrim[hidden] { display: none; }

  .counters { grid-template-columns: repeat(3, 1fr); }
  .feed-form .span-2 { grid-column: 1 / -1; }
  section { margin-bottom: 46px; }
}

@media (max-width: 520px) {
  body { font-size: 16px; }
  .card { padding: 17px; }
  .age-card { padding: 20px; }
  .brand-title { font-size: 14px; }
  .em-card { padding: 16px; }
  .search-wrap { flex: 1 1 130px; }
  .btn-emergency span { display: none; }
}

/* ============================== 打印 ============================== */

@media print {
  @page { margin: 14mm 13mm; size: A4; }

  :root {
    --paper: #fff;
    --surface: #fff;
    --surface-2: #f5f5f5;
    --line: #cfcfcf;
    --line-soft: #e6e6e6;
  }

  html { scroll-behavior: auto; }
  body {
    background: #fff;
    color: #111;
    font-size: 10.5pt;
    line-height: 1.55;
  }

  .topbar, .sidenav, .nav-toggle, .nav-scrim,
  .no-print, .tabs, .search-wrap, .skip { display: none !important; }

  .shell { display: block; padding: 0; max-width: none; }
  section { margin-bottom: 16pt; }

  .card, .flag-block, .stat, details, .em-card, .age-card {
    box-shadow: none !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .age-card {
    background: #fff !important;
    color: #111 !important;
    border: 1.5pt solid #111 !important;
  }
  .age-card .ac-kicker, .age-card .ac-meta, .age-card .ac-note { color: #444 !important; }
  .age-card .ac-big small { color: #444 !important; }
  .age-card .ac-meta { border-top-color: #999 !important; }
  .age-card .ac-meta b { color: #111 !important; }
  .age-card .ac-edit { display: none !important; }

  h2 { font-size: 17pt; }
  h3 { font-size: 12.5pt; }

  table { font-size: 9.5pt; }
  thead th { background: #fff; }

  a { color: #111; text-decoration: none; }
  .entry-del, .counter .c-btns, .data-tools button, .btn { display: none !important; }
  .toast { display: none !important; }

  .hero { display: block; }
  .grid, .grid-2, .grid-3, .grid-4, .flag-grid {
    display: block;
  }
  .grid > *, .flag-grid > * { margin-bottom: 8pt; }

  details > summary::after { content: ""; }
  /* JS 会在打印前展开全部折叠内容 */

  body.print-emergency .shell > main > section:not(#emergency),
  body.print-emergency .shell > main > .foot { display: none !important; }
  body.print-emergency #emergency .no-print { display: none !important; }
  body.print-emergency .em-card { border: 2pt solid #111; }

  .foot { border-top: 1px solid #ccc; }
}

/* ==========================================================================
   云端同步与登录
   ========================================================================== */

.cloud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.cloud-status { color: var(--muted); }
.cloud-status.cloud-ok { color: var(--ok); }
.cloud-status.cloud-warn { color: var(--warn); }

.cloud-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.cloud-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(31, 39, 41, 0.45);
}

.cloud-overlay[hidden] { display: none; }

.cloud-card {
  width: 100%;
  max-width: 360px;
}

.cloud-card h3 { margin-top: 0; }

@media (prefers-reduced-motion: reduce) {
  .cloud-overlay {
    scroll-behavior: auto;
    transition: none;
  }
}
