/* ====================================================
   CLINICAL CHECKLISTS — SHARED STYLESHEET  v2.0
   ==================================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300&display=swap');

:root {
  --navy:          #0f2744;
  --teal:          #0d9488;
  --teal-light:    #ccfbf1;
  --teal-mid:      #5eead4;
  --red:           #dc2626;
  --red-light:     #fee2e2;
  --orange:        #d97706;
  --orange-light:  #fef3c7;
  --white:         #ffffff;
  --off-white:     #f8fafc;
  --slate-50:      #f1f5f9;
  --slate-100:     #e2e8f0;
  --slate-200:     #cbd5e1;
  --slate-400:     #94a3b8;
  --slate-500:     #64748b;
  --slate-700:     #334155;
  --slate-900:     #0f172a;
  --checked-bg:    #f0fdf4;
  --checked-border:#16a34a;
  --radius-sm:     6px;
  --radius-md:     10px;
  --shadow-lg:     0 10px 30px rgba(15,39,68,.12), 0 4px 8px rgba(15,39,68,.08);
  --font-body:     'DM Sans', system-ui, sans-serif;
  --font-mono:     'IBM Plex Mono', monospace;
  --ease-out:      cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-font-smoothing: antialiased; }
html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: var(--font-body); background: var(--off-white); color: var(--slate-900); min-height: 100vh; line-height: 1.5; }

/* ─── Shell ──────────────────────────────────────── */
.app-shell {
  display: flex; flex-direction: column; min-height: 100vh;
  max-width: 480px; margin: 0 auto;
  background: var(--white); box-shadow: var(--shadow-lg);
}

/* ─── Header ─────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--navy);
  padding: 0 20px; height: 56px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 2px solid var(--teal);
}
.header-back {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border: none; background: rgba(255,255,255,.08);
  border-radius: var(--radius-sm); cursor: pointer;
  color: var(--white); transition: background .15s; flex-shrink: 0;
}
.header-back:hover { background: rgba(255,255,255,.16); }
.header-back svg { width: 18px; height: 18px; }
.header-title { font-size: 15px; font-weight: 600; color: var(--white); letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.header-brand { font-family: var(--font-mono); font-size: 11px; color: var(--teal-mid); letter-spacing: .08em; flex-shrink: 0; }

/* ─── Index header ───────────────────────────────── */
.index-header { background: var(--navy); padding: 28px 20px 24px; border-bottom: 2px solid var(--teal); }
.index-logo-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.index-logo-icon {
  width: 32px; height: 32px; background: var(--teal);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.index-logo-icon svg { width: 18px; height: 18px; color: var(--white); }
.index-wordmark { font-family: var(--font-mono); font-size: 13px; font-weight: 500; color: var(--teal-mid); letter-spacing: .10em; text-transform: uppercase; }
.index-headline { font-size: 22px; font-weight: 600; color: var(--white); line-height: 1.25; letter-spacing: -.01em; }
.index-subline { margin-top: 4px; font-size: 13px; color: var(--slate-400); font-weight: 300; }

/* ─── Search ─────────────────────────────────────── */
.search-wrap { padding: 16px 20px 8px; background: var(--white); position: sticky; top: 0; z-index: 50; border-bottom: 1px solid var(--slate-100); }
.search-wrap-inner { position: relative; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--slate-400); width: 16px; height: 16px; pointer-events: none; }
.search-input {
  width: 100%; height: 44px;
  border: 1.5px solid var(--slate-200); border-radius: var(--radius-md);
  padding: 0 12px 0 40px;
  font-family: var(--font-body); font-size: 14px; color: var(--slate-900);
  background: var(--slate-50); outline: none;
  transition: border-color .15s, background .15s;
}
.search-input::placeholder { color: var(--slate-400); }
.search-input:focus { border-color: var(--teal); background: var(--white); }

/* ─── Card List ──────────────────────────────────── */
.checklist-grid { padding: 8px 20px 32px; display: flex; flex-direction: column; }
.checklist-card {
  display: flex; align-items: center; padding: 14px 8px;
  border-bottom: 1px solid var(--slate-50);
  cursor: pointer; text-decoration: none; color: inherit;
  gap: 12px; border-radius: var(--radius-sm);
  margin: 0 -8px; transition: background .1s;
  -webkit-tap-highlight-color: transparent;
}
.checklist-card:active { background: var(--slate-50); }
.card-icon { width: 40px; height: 40px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.card-icon.red    { background: var(--red-light); }
.card-icon.orange { background: var(--orange-light); }
.card-icon.teal   { background: var(--teal-light); }
.card-icon svg { width: 18px; height: 18px; }
.card-icon.red    svg { color: var(--red); }
.card-icon.orange svg { color: var(--orange); }
.card-icon.teal   svg { color: var(--teal); }
.card-content { flex: 1; min-width: 0; }
.card-title { font-size: 15px; font-weight: 600; color: var(--slate-900); line-height: 1.2; }
.card-meta { margin-top: 2px; font-size: 12px; color: var(--slate-400); font-weight: 300; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-badge { font-family: var(--font-mono); font-size: 9px; font-weight: 500; letter-spacing: .10em; padding: 3px 7px; border-radius: 4px; flex-shrink: 0; }
.card-badge.red    { background: var(--red-light);    color: var(--red); }
.card-badge.orange { background: var(--orange-light); color: var(--orange); }
.card-badge.teal   { background: var(--teal-light);   color: var(--teal); }
.card-arrow { color: var(--slate-200); flex-shrink: 0; }
.card-arrow svg { width: 14px; height: 14px; }

/* ─── Detail hero ────────────────────────────────── */
.detail-hero { background: var(--navy); padding: 20px 20px 22px; }
.detail-badge { display: inline-block; font-family: var(--font-mono); font-size: 10px; font-weight: 500; letter-spacing: .12em; padding: 4px 8px; border-radius: 4px; margin-bottom: 10px; }
.detail-badge.red    { background: var(--red);    color: var(--white); }
.detail-badge.orange { background: var(--orange); color: var(--white); }
.detail-badge.teal   { background: var(--teal);   color: var(--white); }
.detail-title { font-size: 24px; font-weight: 600; color: var(--white); line-height: 1.2; letter-spacing: -.01em; }
.detail-when { margin-top: 10px; font-size: 13px; color: rgba(255,255,255,.65); line-height: 1.5; font-weight: 300; border-left: 2px solid var(--teal); padding-left: 10px; }

/* ─── Progress ───────────────────────────────────── */
.progress-bar-wrap { padding: 14px 20px 0; background: var(--white); }
.progress-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.progress-text { font-family: var(--font-mono); font-size: 11px; color: var(--slate-400); letter-spacing: .05em; }
.progress-count { font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--teal); }
.progress-track { height: 4px; background: var(--slate-100); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--teal); border-radius: 99px; transition: width .3s var(--ease-out); }
.progress-fill.complete { background: #16a34a; }

/* ─── Timestamp ──────────────────────────────────── */
.timestamp-row { padding: 6px 20px 0; display: flex; justify-content: flex-end; background: var(--white); }
.timestamp-text { font-family: var(--font-mono); font-size: 10px; color: var(--slate-400); letter-spacing: .04em; }

/* ─── Sections ───────────────────────────────────── */
.section { padding: 20px 20px 0; background: var(--white); }
.section-heading { display: flex; align-items: center; gap: 7px; margin-bottom: 12px; }
.section-heading svg { width: 14px; height: 14px; flex-shrink: 0; }
.section-label { font-family: var(--font-mono); font-size: 10px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; }
.section-label.steps   { color: var(--navy); }
.section-label.flags   { color: var(--red); }
.section-heading svg.steps   { color: var(--navy); }
.section-heading svg.flags   { color: var(--red); }

/* ─── Steps ──────────────────────────────────────── */
.steps-list { display: flex; flex-direction: column; gap: 6px; list-style: none; }
.step-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 14px;
  border: 1.5px solid var(--slate-100); border-radius: var(--radius-md);
  background: var(--white); cursor: pointer;
  transition: all .18s var(--ease-out);
  touch-action: manipulation; user-select: none; -webkit-tap-highlight-color: transparent;
}
.step-item:active { transform: scale(.985); }
.step-item.checked { background: var(--checked-bg); border-color: var(--checked-border); }
.step-num { font-family: var(--font-mono); font-size: 11px; color: var(--slate-400); flex-shrink: 0; margin-top: 3px; min-width: 18px; text-align: right; }
.step-item.checked .step-num { color: var(--checked-border); }
.step-check {
  width: 22px; height: 22px;
  border: 2px solid var(--slate-200); border-radius: 6px;
  flex-shrink: 0; margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  transition: all .18s var(--ease-out); background: var(--white);
}
.step-item.checked .step-check { background: var(--checked-border); border-color: var(--checked-border); }
.step-check svg { width: 12px; height: 12px; color: var(--white); opacity: 0; transform: scale(.6); transition: all .18s var(--ease-out); }
.step-item.checked .step-check svg { opacity: 1; transform: scale(1); }
.step-text { font-size: 14px; line-height: 1.45; color: var(--slate-700); flex: 1; transition: color .18s; }
.step-item.checked .step-text { color: var(--slate-400); text-decoration: line-through; text-decoration-color: var(--slate-300); }

/* ─── Red Flags ──────────────────────────────────── */
.flags-list { display: flex; flex-direction: column; gap: 6px; list-style: none; }
.flag-item { display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; background: var(--red-light); border-radius: var(--radius-md); border-left: 3px solid var(--red); }
.flag-dot { width: 6px; height: 6px; background: var(--red); border-radius: 50%; flex-shrink: 0; margin-top: 6px; }
.flag-text { font-size: 13px; line-height: 1.45; color: #991b1b; }

/* ─── Escalation ─────────────────────────────────── */
.escalation-block { margin: 16px 20px 0; padding: 16px; background: var(--orange-light); border-radius: var(--radius-md); border-left: 3px solid var(--orange); display: flex; gap: 12px; align-items: flex-start; }
.escalation-icon { flex-shrink: 0; margin-top: 1px; }
.escalation-icon svg { width: 16px; height: 16px; color: var(--orange); }
.escalation-text { font-size: 13px; line-height: 1.55; color: #92400e; }

/* ─── Complete Banner ────────────────────────────── */
.complete-banner { margin: 16px 20px 0; padding: 14px 16px; background: #f0fdf4; border: 1.5px solid #16a34a; border-radius: var(--radius-md); display: none; align-items: center; gap: 10px; }
.complete-banner.visible { display: flex; }
.complete-banner svg { width: 20px; height: 20px; color: #16a34a; flex-shrink: 0; }
.complete-banner-text { font-size: 13px; font-weight: 500; color: #14532d; }
.complete-banner-sub { font-size: 11px; font-weight: 300; color: #16a34a; margin-top: 1px; }

/* ─── Actions ────────────────────────────────────── */
.actions-row {
  padding: 16px 20px 20px; display: flex; gap: 10px;
  border-top: 1px solid var(--slate-100); background: var(--white);
  position: sticky; bottom: 0; z-index: 50;
  margin-top: 20px;
}
.btn {
  flex: 1; height: 46px; border: none; border-radius: var(--radius-md);
  font-family: var(--font-body); font-size: 14px; font-weight: 500;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  gap: 7px; transition: all .15s var(--ease-out);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.btn svg { width: 15px; height: 15px; }
.btn-reset { background: var(--slate-100); color: var(--slate-500); }
.btn-reset:hover, .btn-reset:active { background: var(--slate-200); }
.btn-complete { background: var(--teal); color: var(--white); flex: 2; }
.btn-complete:hover, .btn-complete:active { background: #0b7b72; }
.btn-complete.all-done { background: #16a34a; }

/* ─── Divider ────────────────────────────────────── */
.section-divider { height: 8px; background: var(--slate-50); border-top: 1px solid var(--slate-100); border-bottom: 1px solid var(--slate-100); margin: 20px 0 0; }

/* ─── Footer ─────────────────────────────────────── */
.index-footer { padding: 24px 20px; text-align: center; background: var(--white); border-top: 1px solid var(--slate-100); }
.footer-text { font-size: 11px; color: var(--slate-400); line-height: 1.6; font-weight: 300; }
.footer-mono { font-family: var(--font-mono); font-size: 10px; color: var(--slate-400); letter-spacing: .06em; margin-top: 4px; }

/* ─── Empty state ────────────────────────────────── */
.empty-state { padding: 40px 20px; text-align: center; display: none; }
.empty-state.visible { display: block; }
.empty-text { font-size: 14px; color: var(--slate-400); }

/* ─── Step animations ────────────────────────────── */
@keyframes fadeSlideIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
.steps-list .step-item { animation: fadeSlideIn .25s var(--ease-out) both; }
.steps-list .step-item:nth-child(1)  { animation-delay:.04s }
.steps-list .step-item:nth-child(2)  { animation-delay:.08s }
.steps-list .step-item:nth-child(3)  { animation-delay:.12s }
.steps-list .step-item:nth-child(4)  { animation-delay:.16s }
.steps-list .step-item:nth-child(5)  { animation-delay:.20s }
.steps-list .step-item:nth-child(6)  { animation-delay:.24s }
.steps-list .step-item:nth-child(7)  { animation-delay:.28s }
.steps-list .step-item:nth-child(8)  { animation-delay:.32s }
.steps-list .step-item:nth-child(9)  { animation-delay:.36s }
.steps-list .step-item:nth-child(10) { animation-delay:.40s }

/* ─── Responsive ─────────────────────────────────── */
@media (min-width: 768px) {
  body { background: var(--slate-50); display: flex; justify-content: center; }
  .app-shell { max-width: 520px; }
}
