/* Health Recovery Tracker — mobile-first PWA styles.
   Dark, high-contrast, large touch targets. Works on desktop too. */
:root {
  --bg: #0f172a;
  --bg-2: #1e293b;
  --card: #1e293b;
  --card-2: #273449;
  --line: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #0ea5e9;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --crisis: #ef4444;

  /* BP category colors */
  --cat-normal: #34d399;
  --cat-elevated: #fbbf24;
  --cat-stage_1: #fb923c;
  --cat-stage_2: #f87171;
  --cat-crisis_range: #ef4444;

  --radius: 16px;
  --tap: 48px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  overscroll-behavior-y: none;
}
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* Layout */
#app { max-width: 680px; margin: 0 auto; min-height: 100vh; }
.screen {
  padding: calc(var(--safe-top) + 14px) 16px calc(var(--safe-bottom) + 92px);
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.topbar h1 { font-size: 22px; margin: 0; font-weight: 700; }
.topbar .sub { color: var(--muted); font-size: 13px; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card h2 { margin: 0 0 10px; font-size: 15px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

/* Big BP hero */
.bp-hero { text-align: center; padding: 22px 16px; }
.bp-hero .reading { font-size: 56px; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.bp-hero .unit { font-size: 16px; color: var(--muted); }
.bp-hero .pulse { color: var(--muted); margin-top: 8px; }
.cat-pill {
  display: inline-block; margin-top: 12px; padding: 6px 14px; border-radius: 999px;
  font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .03em;
  color: #0b1120;
}
.cat-normal { background: var(--cat-normal); }
.cat-elevated { background: var(--cat-elevated); }
.cat-stage_1 { background: var(--cat-stage_1); }
.cat-stage_2 { background: var(--cat-stage_2); }
.cat-crisis_range { background: var(--cat-crisis_range); color: #fff; }

/* Crisis banner */
.crisis-banner {
  background: rgba(239,68,68,.15); border: 1px solid var(--crisis);
  color: #fecaca; border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px;
  font-size: 14px;
}
.crisis-banner b { color: #fff; }

/* Stat grid */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card-2); border-radius: 12px; padding: 12px; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 22px; font-weight: 700; }
.stat .value small { font-size: 13px; color: var(--muted); font-weight: 500; }

/* Progress (hydration) */
.progress { height: 12px; background: var(--card-2); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: 0; }
.item .when { color: var(--muted); font-size: 12px; }
.item .main { font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 8px; vertical-align: middle; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: 12px; border: 0;
  background: var(--accent); color: #04222e; font-weight: 700; font-size: 16px;
  cursor: pointer; width: 100%;
}
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--card-2); color: var(--text); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: var(--bad); color: #2a0a0a; }
.btn.small { min-height: 38px; font-size: 14px; width: auto; padding: 0 14px; }
.btn-row { display: flex; gap: 10px; }

/* Forms */
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 14px; font-size: 16px;
  background: var(--bg-2); color: var(--text); border: 1px solid var(--line); border-radius: 12px;
}
textarea { min-height: 90px; resize: vertical; }
.field-row { display: flex; gap: 10px; }
.field-row > div { flex: 1; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* Chips (quick add) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 14px; border-radius: 999px; background: var(--card-2);
  border: 1px solid var(--line); color: var(--text); font-size: 14px; cursor: pointer;
}
.chip.active { background: var(--accent); color: #04222e; border-color: var(--accent); font-weight: 700; }

/* Bottom nav */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around; align-items: stretch;
  background: rgba(15,23,42,.95); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
  max-width: 680px; margin: 0 auto;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; color: var(--muted); font-size: 11px; cursor: pointer; border: 0; background: none;
}
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--accent); }
.tab.fab {
  flex: 0 0 auto;
}
.tab.fab .fab-btn {
  width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #04222e;
  display: grid; place-items: center; margin-top: -22px; box-shadow: 0 6px 18px rgba(56,189,248,.4);
}
.tab.fab .fab-btn svg { width: 30px; height: 30px; }

/* Toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(100px + var(--safe-bottom));
  background: var(--card-2); color: var(--text); border: 1px solid var(--line);
  padding: 12px 18px; border-radius: 12px; z-index: 50; max-width: 90%; text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); animation: pop .2s ease;
}
.toast.err { border-color: var(--bad); color: #fecaca; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; } }

/* Login */
.login-wrap { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card { width: 100%; max-width: 380px; }
.brand { text-align: center; margin-bottom: 18px; }
.brand .logo { width: 108px; height: 108px; object-fit: contain; }
.brand h1 { margin: 8px 0 2px; font-size: 22px; }

/* Trend bars */
.trend { display: flex; align-items: flex-end; gap: 6px; height: 130px; padding-top: 10px; }
.trend .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 3px; height: 100%; }
.trend .bar .fill { width: 100%; border-radius: 6px 6px 0 0; background: var(--accent); min-height: 3px; }
.trend .bar .lbl { font-size: 9px; color: var(--muted); text-align: center; transform: rotate(-45deg); transform-origin: center; white-space: nowrap; margin-top: 4px; }

a { color: var(--accent); }
.hidden { display: none !important; }

/* Quick Log big-button grid */
.biggrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.bigbtn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 96px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer;
}
.bigbtn:active { transform: translateY(1px); background: var(--card-2); }
.bigbtn .bi { font-size: 28px; }

/* Import preview rows */
.imp-row { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.imp-head { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text); font-size: 14px; }
.imp-head input[type=checkbox] { width: auto; min-height: auto; transform: scale(1.3); }
.imp-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.imp-f { margin: 0; }
.imp-f span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.imp-f input { min-height: 38px; font-size: 14px; padding: 6px 10px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.ok { background: rgba(52,211,153,.18); color: var(--ok); }
.badge.warn { background: rgba(251,191,36,.18); color: var(--warn); }
.badge.bad { background: rgba(248,113,113,.18); color: var(--bad); }
.badge.crisis { background: var(--crisis); color: #fff; }

/* Print / PDF */
@media print {
  .tabbar, .topbar button, .no-print, .btn, .chips { display: none !important; }
  body { background: #fff; color: #000; }
  #app { max-width: none; }
  .screen { padding: 0; }
  .card { border: 1px solid #ccc; break-inside: avoid; page-break-inside: avoid; margin-bottom: 10px; }
  .card h2, .topbar h1, .stat .value, .item, .muted, .sub { color: #000 !important; }
  .stat { background: #f4f4f4; }
}
