/* BP Tracker — calm, clinical-but-friendly design language.
   Big rounded cards, generous spacing, large tappable numbers, soft accent. */

:root {
  --bg: #0b1220;
  --surface: #121b2e;
  --surface-2: #182338;
  --stroke: #26314a;
  --text: #eef2fb;
  --text-dim: #9aa7c2;
  --accent: #5aa2ff;
  --accent-dim: #315a8f;
  --danger: #ef6a6a;
  --good: #4fd18b;
  --radius: 18px;
  font-size: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; flex-direction: column;
}

button, input, select { font-family: inherit; font-size: inherit; color: inherit; }

/* --- Layout helpers --- */

.screen { flex: 1; display: flex; flex-direction: column; padding: 20px; gap: 16px; max-width: 480px; margin: 0 auto; width: 100%; }
.screen-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; padding-top: calc(14px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--stroke);
  background: var(--surface);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; }
.topbar .sub { font-size: 12px; color: var(--text-dim); }

.icon-btn {
  background: none; border: none; color: var(--text-dim);
  padding: 8px; border-radius: 10px; cursor: pointer; font-size: 14px;
}
.icon-btn:active { background: var(--surface-2); }

/* --- Cards --- */

.card {
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 18px;
}

.card + .card { margin-top: 0; }

.list { display: flex; flex-direction: column; gap: 10px; }

.list-item {
  background: var(--surface); border: 1px solid var(--stroke); border-radius: 14px;
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between;
  cursor: pointer;
}
.list-item:active { background: var(--surface-2); }
.list-item .name { font-weight: 600; font-size: 15px; }
.list-item .meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.list-item .badge {
  font-size: 11px; padding: 4px 9px; border-radius: 20px; border: 1px solid var(--stroke); color: var(--text-dim);
  white-space: nowrap;
}
.list-item .badge.login { color: var(--accent); border-color: var(--accent-dim); }

.empty-state { text-align: center; color: var(--text-dim); padding: 40px 20px; font-size: 14px; }

/* --- Forms --- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.4px; }
.field input, .field select, .field textarea {
  background: var(--surface-2); border: 1px solid var(--stroke); border-radius: 12px;
  padding: 13px 14px; color: var(--text); width: 100%;
}
.field textarea { resize: vertical; min-height: 60px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: flex; gap: 12px; }
.form-row .field { flex: 1; }

/* Large tappable number stepper for BP/HR entry */
.stepper {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface-2); border: 1px solid var(--stroke); border-radius: 16px; padding: 10px 10px;
}
.stepper .label { font-size: 13px; color: var(--text-dim); padding-left: 8px; }
.stepper .value-group { display: flex; align-items: center; gap: 6px; }
.stepper .value {
  font-size: 28px; font-weight: 700; width: 56px; min-width: 0; text-align: center;
  background: none; border: none; color: var(--text); padding: 0;
  -moz-appearance: textfield;
}
.stepper .value::-webkit-outer-spin-button,
.stepper .value::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
.stepper .unit { font-size: 11px; color: var(--text-dim); padding-right: 4px; white-space: nowrap; }
.stepper button {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 12px; border: none;
  background: var(--surface); color: var(--accent); font-size: 20px; font-weight: 600;
}
.stepper button:active { background: var(--accent-dim); color: white; }

/* --- Buttons --- */

.btn {
  display: block; width: 100%; text-align: center; padding: 15px; border-radius: 14px;
  border: none; font-weight: 600; font-size: 15px; cursor: pointer;
}
.btn-primary { background: var(--accent); color: #08111f; }
.btn-primary:active { background: #4a8ee0; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--stroke); }
.btn-secondary:active { background: var(--surface); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(239,106,106,0.4); }
.btn-danger:active { background: rgba(239,106,106,0.1); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* --- Misc --- */

.center-screen { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 20px; padding: 24px; }
.logo { font-size: 40px; }
.title { font-size: 22px; font-weight: 700; }
.subtitle { font-size: 13px; color: var(--text-dim); text-align: center; }

.error-banner {
  background: rgba(239,106,106,0.12); border: 1px solid rgba(239,106,106,0.35);
  color: var(--danger); border-radius: 12px; padding: 10px 14px; font-size: 13px;
}

.chip-row { display: flex; gap: 8px; }
.chip {
  flex: 1; text-align: center; padding: 8px; border-radius: 10px; border: 1px solid var(--stroke);
  font-size: 12px; color: var(--text-dim); cursor: pointer; background: var(--surface);
}
.chip.active { color: var(--accent); border-color: var(--accent-dim); background: var(--surface-2); }

.reading-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 4px; border-bottom: 1px solid var(--stroke); cursor: pointer;
}
.reading-row:last-child { border-bottom: none; }
.reading-row .bp { font-weight: 700; font-size: 15px; }
.reading-row .hr { color: var(--text-dim); font-size: 13px; }
.reading-row .when { font-size: 12px; color: var(--text-dim); }
.reading-row .by { font-size: 11px; color: var(--text-dim); opacity: 0.7; }

.section-label {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-dim);
  margin: 4px 2px 0;
}

.password-reveal {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--stroke); border-radius: 12px; padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, monospace; font-size: 15px;
}

a.link { color: var(--accent); text-decoration: none; font-size: 13px; }

.fab-add {
  position: fixed; right: 20px; bottom: calc(84px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #08111f;
  font-size: 28px; border: none; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4); z-index: 10;
}

/* --- Tab bar --- */

.tabbar {
  display: flex; border-top: 1px solid var(--stroke); background: var(--surface);
  padding-bottom: env(safe-area-inset-bottom); position: sticky; bottom: 0; z-index: 6;
}
.tab-btn {
  flex: 1; background: none; border: none; color: var(--text-dim);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 4px 8px; font-size: 11px; cursor: pointer;
}
.tab-btn.active { color: var(--accent); }
.tab-icon { font-size: 19px; line-height: 1; }

/* --- Standalone badge (used outside list items too, e.g. reading rows) --- */

.badge {
  font-size: 11px; padding: 4px 9px; border-radius: 20px; border: 1px solid var(--stroke);
  color: var(--text-dim); white-space: nowrap; display: inline-block;
}

/* --- Toast --- */

.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translate(-50%, 10px); background: var(--surface-2); border: 1px solid var(--stroke);
  color: var(--text); padding: 10px 18px; border-radius: 30px; font-size: 13px;
  opacity: 0; transition: opacity 0.2s ease, transform 0.2s ease; z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35); white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* --- Insights stat cards --- */

.stat-card {
  flex: 1; min-width: 100px; border: 1px solid var(--stroke); border-radius: 14px;
  padding: 14px; text-align: center; background: var(--surface);
}
.stat-num { font-size: 26px; font-weight: 700; }
.stat-label { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

/* --- Client home hero card --- */

.hero-card { display: flex; flex-direction: column; gap: 8px; }
.hero-bp { font-size: 44px; font-weight: 800; line-height: 1; }

/* --- Mini stats above the graph --- */

.mini-stat {
  flex: 1; text-align: center; background: var(--surface-2); border: 1px solid var(--stroke);
  border-radius: 10px; padding: 8px;
}
.mini-stat-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; }
.mini-stat-val { font-size: 14px; font-weight: 700; margin-top: 2px; }
