:root {
  --navy: #1e3a8a;
  --red: #c41e3a;
  --ink: #172033;
  --muted: #667085;
  --line: #e6eaf2;
  --soft: #f5f7fb;
  --white: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--soft);
  color: var(--ink);
  font-family: Inter, Arial, sans-serif;
}

a {
  color: inherit;
}

.portal-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: var(--white);
  border-right: 1px solid var(--line);
  padding: 24px;
}

.brand {
  font-size: 22px;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 30px;
}

.nav-link {
  display: block;
  padding: 12px 14px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
}

.nav-link.active {
  background: #eaf0ff;
  color: var(--navy);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.breadcrumb a {
  color: var(--navy);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.main {
  padding: 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.05);
  padding: 22px;
  scroll-margin-top: 24px;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

label,
.label {
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  font: inherit;
}

textarea {
  min-height: 82px;
}

.button {
  border: 0;
  border-radius: 7px;
  background: var(--navy);
  color: white;
  padding: 11px 16px;
  font-weight: 800;
  cursor: pointer;
}

.button.secondary {
  background: #eef2f8;
  color: var(--ink);
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  padding: 4px 8px;
  background: #eef2f8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.badge.green {
  background: #e8f7ef;
  color: #087443;
}

.badge.orange {
  background: #fff4e5;
  color: #b54708;
}

.badge.red {
  background: #fde8ec;
  color: var(--red);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.entry-summary-table {
  overflow-x: auto;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 7px;
  padding: 7px 12px;
  background: #eaf0ff;
  color: var(--navy);
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
}

.icon-button:hover {
  background: #dbe7ff;
}

.alert-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-top: 12px;
  background: #fff;
}

.alert-head,
.alert-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.alert-date,
.alert-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.alert-patient {
  margin-top: 10px;
  font-size: 17px;
  font-weight: 900;
}

.alert-patient span {
  margin-left: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.alert-message {
  margin: 8px 0 10px;
  font-weight: 700;
}

.patient-link,
.alert-patient a,
.alert-meta a,
.back-link {
  color: var(--navy);
  font-weight: 900;
  text-decoration: none;
}

.patient-link:hover,
.alert-patient a:hover,
.alert-meta a:hover,
.back-link:hover {
  text-decoration: underline;
}

.patient-alert {
  background: #fff;
}

.alert-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.alert-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border-radius: 7px;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 800;
}

.alert-chip.red-flag {
  background: #fde8ec;
  color: var(--red);
}

.alert-chip.vital {
  background: #fff4e5;
  color: #b54708;
}

.patient-detail {
  display: grid;
  gap: 18px;
}

.patient-hero {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 20px;
  border-radius: 12px;
  padding: 28px;
  color: white;
  background:
    radial-gradient(circle at top right, rgba(196, 30, 58, 0.35), transparent 30%),
    linear-gradient(135deg, #172033 0%, #1e3a8a 100%);
  box-shadow: 0 24px 60px rgba(30, 58, 138, 0.14);
}

.patient-hero h2 {
  margin: 10px 0 6px;
  font-size: 34px;
}

.patient-hero p {
  margin: 0;
  color: rgba(255, 255, 255, 0.74);
}

.patient-hero .back-link {
  color: rgba(255, 255, 255, 0.82);
}

.detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.detail-badges .badge {
  background: rgba(255, 255, 255, 0.12);
  color: white;
}

.hero-summary {
  min-width: 210px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.1);
  display: grid;
  align-content: center;
}

.hero-summary span,
.hero-summary small {
  color: rgba(255, 255, 255, 0.72);
}

.hero-summary strong {
  margin: 6px 0;
  font-size: 24px;
}

.metric-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  background: white;
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.04);
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin: 6px 0;
  font-size: 28px;
}

.metric-card small {
  color: var(--muted);
  font-weight: 700;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-head h2 {
  margin: 0;
}

.section-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.timeline-entry {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 18px;
  margin-top: 18px;
}

.timeline-date {
  position: sticky;
  top: 92px;
  align-self: start;
  border-radius: 10px;
  padding: 12px;
  background: #eaf0ff;
  color: var(--navy);
  text-align: center;
}

.timeline-date strong {
  display: block;
  font-size: 24px;
}

.timeline-date span {
  display: block;
  font-size: 12px;
  font-weight: 900;
}

.entry-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  background: #fff;
}

.entry-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.entry-head h3 {
  margin: 0;
}

.entry-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.vital-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.vital-grid div {
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
}

.vital-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.vital-grid strong {
  display: block;
  margin: 4px 0;
  font-size: 20px;
}

.vital-grid small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.entry-alerts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.detail-grid div,
.note-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.detail-grid h4 {
  margin: 0 0 10px;
}

.detail-grid p,
.note-box p {
  margin: 6px 0;
  color: var(--muted);
  font-weight: 700;
}

.note-box {
  margin-top: 12px;
  background: var(--soft);
}

.note-box pre {
  white-space: pre-wrap;
  margin-bottom: 0;
}

.red-note {
  border-color: #f6c4ce;
  background: #fff7f8;
}

.empty-state {
  border-radius: 10px;
  border: 1px dashed var(--line);
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.flash {
  margin-bottom: 18px;
  border-radius: 8px;
  padding: 12px 14px;
  font-weight: 700;
}

.flash.success {
  background: #e8f7ef;
  color: #087443;
}

.flash.error {
  background: #fde8ec;
  color: var(--red);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.branded-login {
  align-content: center;
  gap: 26px;
  background:
    radial-gradient(circle at top left, rgba(30, 58, 138, 0.12), transparent 34%),
    linear-gradient(180deg, #f8fafc 0%, #eef3fb 100%);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.logo-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: rgba(30, 58, 138, 0.1);
  color: var(--navy);
  font-weight: 900;
}

.brand-title {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0;
}

.brand-title span {
  color: var(--navy);
}

.login-brand p,
.login-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
}

.login-card {
  width: min(460px, 100%);
  border: 0;
  padding: 34px;
  box-shadow: 0 24px 70px rgba(30, 58, 138, 0.1);
}

.login-card h1 {
  margin: 0;
  font-size: 32px;
}

.login-button {
  width: 100%;
  min-height: 52px;
  margin-top: 8px;
  font-size: 16px;
}

.password-card {
  max-width: 560px;
}

.form-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.form-actions .button {
  text-decoration: none;
}

@media (max-width: 900px) {
  .portal-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 20px;
  }

  .patient-hero,
  .entry-head,
  .alert-head,
  .alert-meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .timeline-entry {
    grid-template-columns: 1fr;
  }

  .timeline-date {
    position: static;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }

  .vital-grid,
  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .vital-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}
