/* ============ 基础 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #f3f5fa;
  --card: #ffffff;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --line: #e9edf4;
  --primary: #4f46e5;
  --primary-d: #4338ca;
  --primary-soft: #eef0ff;
  --red: #e11d48;
  --red-d: #be123c;
  --red-soft: #fff1f2;
  --green: #059669;
  --green-soft: #ecfdf5;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --shadow: 0 10px 30px rgba(16, 24, 40, .07);
  --shadow-lg: 0 20px 50px rgba(16, 24, 40, .16);
  --radius: 18px;
}

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

/* 任何带 hidden 属性的元素都必须隐藏（避免 display:flex 等覆盖原生 hidden） */
[hidden] { display: none !important; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB",
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  padding-bottom: 64px;
  line-height: 1.5;
}

.container { max-width: 960px; margin: 0 auto; padding: 0 20px; }

h2 { font-size: 19px; font-weight: 700; letter-spacing: .2px; }
h3 { font-size: 18px; font-weight: 700; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; cursor: pointer; white-space: nowrap;
  font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 10px 18px; border-radius: 12px;
  transition: transform .12s ease, box-shadow .12s ease, background .15s ease, color .15s ease;
  user-select: none;
}
.btn:active { transform: scale(.97); }
.btn-lg { padding: 12px 22px; font-size: 15px; border-radius: 13px; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }

.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(79, 70, 229, .28); }
.btn-primary:hover { background: var(--primary-d); }

.btn-ghost { background: #f2f4f8; color: var(--ink-2); }
.btn-ghost:hover { background: #e7eaf1; }

.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-soft:hover { background: #e2e5ff; }

.btn-danger { background: #fee4e2; color: #c01024; }
.btn-danger:hover { background: #fecdca; }

.btn-green { background: var(--green); color: #fff; box-shadow: 0 6px 16px rgba(5, 150, 105, .25); }
.btn-green:hover { background: #047857; }

.icon-btn {
  border: none; background: transparent; cursor: pointer;
  width: 34px; height: 34px; border-radius: 9px;
  color: var(--muted); font-size: 15px; transition: background .15s;
}
.icon-btn:hover { background: #f2f4f8; color: var(--ink); }

/* ============ 顶部导航 ============ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(233, 237, 244, .8);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 62px; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 18px; font-weight: 800; letter-spacing: .3px; }
.brand-logo { font-size: 22px; }
.topbar-actions { display: flex; gap: 10px; }
.topbar-actions .btn { padding: 8px 14px; font-size: 13px; }

/* ============ 红色警示横幅 ============ */
.alert-banner {
  position: fixed; top: 76px; left: 50%; transform: translateX(-50%);
  z-index: 100; width: calc(100% - 32px); max-width: 920px;
  border-radius: 18px; overflow: hidden;
  background: linear-gradient(135deg, #f43f5e 0%, var(--red-d) 100%);
  color: #fff; box-shadow: 0 22px 55px rgba(190, 18, 60, .42);
  animation: bannerIn .35s cubic-bezier(.2, .9, .3, 1.25);
}
.alert-banner::after {
  content: ""; position: absolute; inset: 0;
  border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .35);
  animation: redPulse 1.4s ease-in-out infinite;
}
@keyframes bannerIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-18px) scale(.97); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
@keyframes redPulse {
  0%, 100% { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .15); }
  50%      { box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .65); }
}
.alert-inner {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 22px; flex-wrap: wrap;
}
.alert-icon {
  flex: none; width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  border: 2px solid rgba(255, 255, 255, .85);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 900;
  animation: iconBlink 1s ease-in-out infinite;
}
@keyframes iconBlink { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.alert-body { flex: 1; min-width: 200px; }
.alert-title { font-size: 18px; font-weight: 800; margin-bottom: 3px; }
.alert-list { font-size: 14px; opacity: .95; }
.alert-list b { font-weight: 700; }
.alert-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-light { background: #fff; color: var(--red-d); }
.btn-light:hover { background: #ffe4e6; }
.btn-outline-light { background: transparent; color: #fff; box-shadow: inset 0 0 0 1.6px rgba(255,255,255,.8); }
.btn-outline-light:hover { background: rgba(255, 255, 255, .14); }

/* ============ Hero 时钟 ============ */
.hero {
  margin: 26px 0 20px;
  border-radius: 24px;
  background: linear-gradient(125deg, #4f46e5 0%, #6d5df0 52%, #8b5cf6 100%);
  color: #fff; padding: 30px 34px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  flex-wrap: wrap;
  box-shadow: 0 18px 44px rgba(79, 70, 229, .30);
  position: relative; overflow: hidden;
}
.hero::before {
  content: ""; position: absolute; right: -60px; top: -70px;
  width: 240px; height: 240px; border-radius: 50%;
  background: rgba(255, 255, 255, .09);
}
.hero::after {
  content: ""; position: absolute; right: 70px; bottom: -90px;
  width: 170px; height: 170px; border-radius: 50%;
  background: rgba(255, 255, 255, .07);
}
.hero-text { position: relative; z-index: 1; }
.hero-greeting { font-size: 21px; font-weight: 800; margin-bottom: 6px; }
.hero-date { font-size: 14px; opacity: .88; }
.hero-clock {
  position: relative; z-index: 1;
  font-size: 46px; font-weight: 800; letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
}

/* ============ 卡片 ============ */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 26px; margin-top: 18px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
}
.card-sub { font-size: 13px; color: var(--muted); font-weight: 500; }

/* ============ 今日服药列表 ============ */
.dose-list { display: flex; flex-direction: column; gap: 10px; }
.dose-row {
  display: flex; align-items: center; gap: 16px;
  padding: 15px 18px; border-radius: 14px;
  border: 1px solid var(--line); background: #fcfcfe;
  transition: background .15s, border-color .15s;
}
.dose-time {
  flex: none; width: 64px; text-align: center;
  font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.dose-info { flex: 1; min-width: 0; }
.dose-name { font-size: 15.5px; font-weight: 700; }
.dose-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.dose-actions { flex: none; display: flex; align-items: center; gap: 10px; }

.chip {
  flex: none; font-size: 12.5px; font-weight: 700;
  padding: 5px 12px; border-radius: 999px;
}
.chip-pending { background: #f2f4f8; color: var(--muted); }
.chip-taken   { background: var(--green-soft); color: var(--green); }
.chip-missed  { background: var(--amber-soft); color: var(--amber); }
.chip-due {
  background: var(--red); color: #fff;
  display: inline-flex; align-items: center; gap: 6px;
  animation: chipPulse 1.1s ease-in-out infinite;
}
.chip-due::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: #fff; animation: iconBlink .8s infinite;
}
@keyframes chipPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(225, 29, 72, .45); }
  50%      { box-shadow: 0 0 0 7px rgba(225, 29, 72, 0); }
}

/* 到点 / 漏服 行的红色警示 */
.dose-row.is-due {
  background: var(--red-soft);
  border-color: #fda4af;
  box-shadow: inset 4px 0 0 var(--red);
  animation: rowGlow 1.3s ease-in-out infinite;
}
@keyframes rowGlow {
  0%, 100% { box-shadow: inset 4px 0 0 var(--red), 0 0 0 0 rgba(225,29,72,.0); }
  50%      { box-shadow: inset 4px 0 0 var(--red), 0 0 22px rgba(225,29,72,.18); }
}
.dose-row.is-due .dose-time { color: var(--red-d); }
.dose-row.is-taken { background: #fafbfc; }
.dose-row.is-taken .dose-time,
.dose-row.is-taken .dose-name { color: var(--muted); }
.dose-row.is-taken .dose-name { text-decoration: line-through; text-decoration-color: #c3c9d4; }
.dose-row.is-missed { border-color: #fde68a; background: var(--amber-soft); }
.dose-row.is-missed .dose-time { color: var(--amber); }

.empty {
  text-align: center; color: var(--muted);
  font-size: 14px; padding: 34px 12px;
}
.empty .empty-icon { display: block; font-size: 38px; margin-bottom: 10px; opacity: .8; }

/* ============ 药品网格 ============ */
.med-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(264px, 1fr));
}
.med-card {
  border: 1px solid var(--line); border-radius: 16px;
  padding: 18px; background: #fcfcfe;
  display: flex; flex-direction: column; gap: 10px;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s;
}
.med-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #dde3ee; }
.med-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.med-name { font-size: 16px; font-weight: 700; word-break: break-word; }
.med-dose { font-size: 13px; color: var(--primary); font-weight: 600; margin-top: 2px; }
.med-note { font-size: 13px; color: var(--muted); }
.med-times { display: flex; flex-wrap: wrap; gap: 7px; }
.med-time-chip {
  font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--primary-soft); color: var(--primary);
  padding: 4px 11px; border-radius: 999px;
}
.med-card-actions { display: flex; gap: 6px; flex: none; }

/* ============ 历史记录 ============ */
.history-group + .history-group { margin-top: 18px; }
.history-date {
  font-size: 13px; font-weight: 700; color: var(--muted);
  margin-bottom: 8px; padding-left: 2px;
}
.history-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; border-radius: 12px;
}
.history-row:nth-child(odd) { background: #fafbfd; }
.history-dot {
  flex: none; width: 10px; height: 10px; border-radius: 50%;
  background: var(--green);
}
.history-info { flex: 1; min-width: 0; }
.history-name { font-size: 14.5px; font-weight: 600; }
.history-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.history-del { flex: none; }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(16, 24, 40, .46);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: 20px; width: 100%; max-width: 460px;
  box-shadow: var(--shadow-lg);
  animation: modalIn .22s cubic-bezier(.2, .9, .3, 1.2);
  max-height: calc(100vh - 40px); display: flex; flex-direction: column;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 22px 8px;
}
.modal-body { padding: 10px 22px; overflow-y: auto; }
.modal-foot {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 16px 22px 22px;
}
.modal-foot .btn-danger { margin-right: auto; }

.field { display: block; margin: 12px 0; }
.field > span {
  display: block; font-size: 13.5px; font-weight: 600;
  color: var(--ink-2); margin-bottom: 7px;
}
.field input[type="text"] {
  width: 100%; padding: 11px 14px; font-size: 14.5px;
  font-family: inherit; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 12px;
  background: #fcfcfe; outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input[type="text"]:focus {
  border-color: var(--primary); background: #fff;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, .12);
}
.time-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 9px; }
.time-row { display: flex; gap: 8px; align-items: center; }
.time-row input[type="time"] {
  flex: 1; padding: 10px 13px; font-size: 15px; font-family: inherit;
  border: 1.5px solid var(--line); border-radius: 12px;
  background: #fcfcfe; color: var(--ink); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.time-row input[type="time"]:focus {
  border-color: var(--primary); background: #fff;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, .12);
}

/* ============ Toast ============ */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  z-index: 300; background: #101828; color: #fff;
  padding: 12px 22px; border-radius: 999px;
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============ 页脚 ============ */
.footer {
  text-align: center; color: #98a2b3; font-size: 12.5px;
  margin-top: 34px; padding: 0 20px;
}

/* ============ 响应式 ============ */
@media (max-width: 640px) {
  .hero { padding: 24px 22px; border-radius: 20px; }
  .hero-greeting { font-size: 18px; }
  .hero-clock { font-size: 36px; letter-spacing: 1px; }
  .card { padding: 20px 18px; }
  .dose-row { flex-wrap: wrap; padding: 14px; gap: 10px; }
  .dose-time { width: auto; text-align: left; }
  .dose-info { flex-basis: calc(100% - 80px); }
  .dose-actions { width: 100%; justify-content: flex-end; }
  .alert-inner { padding: 16px; gap: 12px; }
  .alert-actions { width: 100%; }
  .alert-actions .btn { flex: 1; }
}
