:root {
  --crimson: #e62945;
  --vibrant: #ff4057;
  --coral: #ff7b87;
  --blush: #ffe3e6;
  --ivory: #fff7f3;
  --beige: #e8cfc0;
  --white: #ffffff;
  --charcoal: #302326;
  --terracotta: #c45c4a;
  --muted: #6b575c;
  --line: #ead8cc;
  --shadow: 0 10px 30px rgba(48, 35, 38, 0.08);
  --radius: 16px;
  --sidebar: 250px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--ivory);
  color: var(--charcoal);
  line-height: 1.5;
  min-height: 100vh;
}

img { max-width: 100%; }
a { color: var(--crimson); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
h1, h2, h3, h4 { margin: 0 0 0.4rem; letter-spacing: -0.02em; }
p { margin: 0 0 0.8rem; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--white);
  border-right: 1px solid var(--line);
  padding: 1.25rem 0.9rem;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.2rem 0.5rem 1rem;
  color: var(--charcoal);
  text-decoration: none;
}
.brand img { width: 40px; height: 40px; }
.brand strong { display: block; font-size: 1.05rem; }
.brand span { display: block; font-size: 0.75rem; color: var(--muted); }

.nav-list { list-style: none; margin: 0; padding: 0; flex: 1; }
.nav-list a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  color: var(--charcoal);
  text-decoration: none;
  margin-bottom: 0.2rem;
}
.nav-list a:hover { background: var(--blush); text-decoration: none; }
.nav-list a.active {
  background: var(--crimson);
  color: var(--white);
}
.nav-list .nav-note {
  font-size: 0.7rem;
  opacity: 0.8;
  margin-left: auto;
}

.sidebar-foot {
  padding: 0.8rem 0.5rem 0;
  border-top: 1px solid var(--line);
}
.sidebar-foot button {
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem 0;
}
.menu-btn {
  display: none;
  background: var(--white);
  border: 1px solid var(--beige);
  border-radius: 10px;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
}

.page {
  padding: 0 1.5rem 2rem;
}
.page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin: 1rem 0 1.25rem;
}
.ecg-strip {
  height: 36px;
  background: url("../assets/images/ecg-wave.svg") center / cover no-repeat;
  opacity: 0.55;
  margin: 0 1.5rem 0.5rem;
  border-radius: 8px;
}

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.25rem;
}

.grid {
  display: grid;
  gap: 1rem;
}
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.stat-card .label { color: var(--muted); font-size: 0.82rem; }
.stat-card .value { font-size: 1.8rem; font-weight: 700; }
.stat-card.highlight { background: var(--blush); border-color: #f3c3c8; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 12px;
  padding: 0.7rem 1.05rem;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--crimson); color: var(--white); }
.btn-primary:hover { background: var(--vibrant); }
.btn-secondary {
  background: var(--white);
  color: var(--charcoal);
  border: 1px solid var(--beige);
}
.btn-ghost { background: transparent; color: var(--crimson); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-block { width: 100%; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.15rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.badge-high { background: #fde2e6; color: #b0122a; }
.badge-moderate { background: #ffe9d6; color: #9a4b16; }
.badge-low { background: #e4f4ea; color: #1f6b3a; }
.badge-unknown { background: var(--blush); color: var(--muted); }
.badge-soft { background: var(--blush); color: var(--crimson); }

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
th, td {
  text-align: left;
  padding: 0.75rem 0.6rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem 1rem;
}
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 0.85rem; font-weight: 600; }
.field input, .field select, .field textarea {
  border: 1px solid var(--beige);
  background: var(--white);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  color: var(--charcoal);
}
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid #ffb3bc;
  border-color: var(--coral);
}
.checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem 1rem;
}
.checks label { font-weight: 500; display: flex; gap: 0.45rem; align-items: center; }

.alert {
  border-radius: 12px;
  padding: 0.8rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid;
}
.alert-error { background: #fff1f2; border-color: #f3b0b8; color: #8d1428; }
.alert-info { background: var(--blush); border-color: #f3c3c8; }
.alert-warn { background: #fff6ea; border-color: #efd0a8; }
.hidden { display: none !important; }

.disclaimer {
  background: #fff;
  border: 1px dashed var(--beige);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.auth-page, .landing {
  min-height: 100vh;
  background:
    radial-gradient(1200px 420px at 90% -10%, #ffe3e6 0%, transparent 55%),
    linear-gradient(180deg, #fff7f3 0%, #fff7f3 70%, #ffe9e4 100%);
}
.auth-wrap, .landing-wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem;
}
.landing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0 1.5rem;
}
.landing-brand { padding: 0; }
.landing-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.landing-nav a {
  color: var(--charcoal);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--beige);
  background: var(--white);
}
.landing-nav a:hover {
  text-decoration: none;
  border-color: var(--coral);
  color: var(--crimson);
}
.landing-nav .nav-quiet {
  background: transparent;
  border-color: transparent;
}
.landing-hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 2.4rem;
  align-items: center;
  margin: 1.5rem 0 2.2rem;
  min-height: 52vh;
}
.hero-copy h1 {
  font-size: clamp(2rem, 4.5vw, 3.35rem);
  line-height: 1.12;
  margin: 0.35rem 0 0.9rem;
  max-width: 14ch;
}
.eyebrow {
  display: inline-block;
  margin: 0;
  color: var(--crimson);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.lede {
  font-size: 1.08rem;
  color: var(--muted);
  max-width: 38rem;
  margin-bottom: 1rem;
}
.health-line { margin-top: 0.4rem; }
.monitor {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem 1.2rem;
}
.monitor-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}
.monitor-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--crimson);
  box-shadow: 0 0 0 6px var(--blush);
}
.monitor-wave {
  width: 100%;
  height: 128px;
  margin: 0.6rem 0 0.4rem;
  background: linear-gradient(#fff7f3, #ffffff);
  border-radius: 12px;
}
.monitor-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}
.monitor-stats span {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.monitor-stats strong {
  font-size: 1.35rem;
}
.landing-points {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.landing-points article {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.15rem 1.2rem;
}
.landing-points h2 {
  font-size: 1rem;
  margin-bottom: 0.35rem;
}
.landing-points p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.hero-card {
  background: var(--white);
  border-radius: 24px;
  border: 1px solid var(--line);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.pulse-ring {
  width: 180px;
  height: 180px;
  margin: 1rem auto;
  border-radius: 50%;
  border: 8px solid var(--blush);
  display: grid;
  place-items: center;
  position: relative;
}
.pulse-ring::after {
  content: "";
  position: absolute;
  inset: -14px;
  border: 2px solid #ffc1c8;
  border-radius: 50%;
}
.heart {
  font-size: 4rem;
  color: var(--crimson);
  line-height: 1;
}

.landing-links {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 1.15rem;
  font-size: 0.95rem;
}
.landing-links span { color: var(--beige); }

.auth-card {
  max-width: 460px;
  margin: 2.5rem auto;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1.6rem;
  box-shadow: var(--shadow);
}
.tabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; }
.tabs button {
  flex: 1;
  border: 1px solid var(--beige);
  background: var(--ivory);
  border-radius: 10px;
  padding: 0.55rem;
  cursor: pointer;
}
.tabs button.active { background: var(--crimson); color: #fff; border-color: var(--crimson); }

.shap-row { margin-bottom: 0.7rem; }
.shap-row .meta { display: flex; justify-content: space-between; font-size: 0.85rem; }
.bar {
  height: 8px;
  background: var(--blush);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 0.3rem;
}
.bar > span {
  display: block;
  height: 100%;
  background: var(--vibrant);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 0.4rem;
}
.status-dot.online { background: #2d9a55; }
.status-dot.offline { background: var(--crimson); }

.empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
}
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(48, 35, 38, 0.35);
  z-index: 20;
}
.overlay.show { display: block; }

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  background: var(--charcoal);
  color: #fff;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  z-index: 50;
}

.unavailable {
  opacity: 0.92;
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(84vw, 280px);
    transform: translateX(-105%);
    z-index: 30;
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .grid-4, .grid-3, .grid-2, .form-grid, .landing-hero, .landing-points, .checks {
    grid-template-columns: 1fr;
  }
  .landing-header { flex-wrap: wrap; }
  .hero-copy h1 { max-width: none; }
  .ecg-strip { margin: 0 1rem; }
  .page { padding: 0 1rem 2rem; }
}
