:root {
  --surface: #f8fafb;
  --surface-card: #ffffff;
  --surface-soft: #eef5f5;
  --surface-line: #dce8ea;
  --text: #191c1d;
  --muted: #566266;
  --primary: #005264;
  --primary-strong: #1e6b7f;
  --primary-light: #b3ebff;
  --coral: #914a3b;
  --coral-soft: #ffdad3;
  --green: #2d9d78;
  --yellow: #f5a623;
  --red: #ba1a1a;
  --blue: #2f54eb;
  --shadow: 0 18px 40px rgba(0, 82, 100, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--surface);
  font-family: "Plus Jakarta Sans", "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: rgba(248, 250, 251, 0.92);
  border-bottom: 1px solid var(--surface-line);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--primary);
  font-family: Manrope, Inter, system-ui, sans-serif;
  font-size: 21px;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  color: white;
  background: var(--primary);
  font-weight: 800;
}

.container {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 80px;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 78px;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--surface-line);
  border-radius: 8px;
  background: var(--surface-card);
}

.nav-button,
.icon-button,
.button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  transition: transform 0.15s ease, background 0.15s ease, border 0.15s ease;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  color: white;
  background: var(--primary);
  font-weight: 700;
}

.button.secondary {
  color: var(--primary);
  background: transparent;
  border: 1px solid var(--primary);
}

.button.coral {
  color: white;
  background: var(--coral);
}

.button:active,
.nav-button:active,
.icon-button:active {
  transform: translateY(1px);
}

.nav-button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-weight: 700;
}

.nav-button.active,
.nav-button:hover {
  color: white;
  background: var(--primary);
}

.icon-button {
  display: grid;
  width: 48px;
  place-items: center;
  color: var(--primary);
  background: var(--surface-soft);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr);
  gap: 24px;
  align-items: center;
  padding: 28px;
  overflow: hidden;
  color: white;
  background: linear-gradient(135deg, #005264 0%, #176d6e 100%);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero h1,
.section-title h2,
.metric-value,
.card h3 {
  font-family: Manrope, Inter, system-ui, sans-serif;
}

.hero h1 {
  margin: 10px 0;
  font-size: clamp(32px, 6vw, 52px);
  line-height: 1;
  letter-spacing: 0;
}

.hero p {
  max-width: 620px;
  margin: 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 17px;
  line-height: 1.55;
}

.hero-panel {
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
}

.badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--primary);
  background: var(--primary-light);
  font-size: 13px;
  font-weight: 800;
}

.badge.success {
  color: white;
  background: var(--green);
}

.badge.warning {
  color: #3f2600;
  background: var(--yellow);
}

.badge.danger {
  color: white;
  background: var(--red);
}

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

.span-3 {
  grid-column: span 3;
}

.span-4 {
  grid-column: span 4;
}

.span-5 {
  grid-column: span 5;
}

.span-6 {
  grid-column: span 6;
}

.span-7 {
  grid-column: span 7;
}

.span-8 {
  grid-column: span 8;
}

.span-12 {
  grid-column: span 12;
}

.card {
  padding: 18px;
  border: 1px solid var(--surface-line);
  border-radius: 8px;
  background: var(--surface-card);
  min-width: 0;
}

.card.elevated {
  box-shadow: var(--shadow);
}

.card h3,
.card p {
  margin-top: 0;
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: 28px 0 14px;
}

.section-title h2 {
  margin: 0;
  color: var(--primary);
  font-size: 24px;
}

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

.metric-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric-value {
  margin: 8px 0 0;
  color: var(--primary);
  font-size: 34px;
  font-weight: 800;
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.progress > span.warning {
  background: var(--yellow);
}

.progress > span.danger {
  background: var(--red);
}

.stack {
  display: grid;
  gap: 12px;
}

.patient-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 120px 140px 120px;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--surface-line);
  border-radius: 8px;
  background: white;
}

.patient-select {
  width: 100%;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.patient-select:hover,
.patient-select.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 82, 100, 0.1);
}

.patient-select.selected {
  background: #f3fbfb;
}

.patient-select-card {
  display: grid;
  width: 100%;
  gap: 12px;
  min-height: 112px;
  padding: 16px;
  color: var(--text);
  text-align: left;
  border: 1px solid var(--surface-line);
  border-radius: 8px;
  background: white;
}

.patient-select-card strong,
.patient-select-card small {
  display: block;
}

.patient-select-card strong {
  font-size: 20px;
  line-height: 1.2;
}

.patient-select-card small {
  color: var(--muted);
  line-height: 1.3;
}

.patient-status-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.patient-status-line small {
  overflow-wrap: anywhere;
}

.patient-select-card:hover,
.patient-select-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 82, 100, 0.1);
}

.patient-select-card.selected {
  background: #f3fbfb;
}

.patient-row button {
  justify-self: end;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.wide-field {
  grid-column: span 2;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.field input,
.field select,
.field textarea {
  min-height: 48px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--surface-line);
  border-radius: 8px;
  background: white;
  color: var(--text);
}

.field input[type="checkbox"],
.field input[type="radio"],
.choice-grid input[type="checkbox"],
.choice-grid input[type="radio"] {
  min-height: 18px;
  width: 18px;
  flex: 0 0 18px;
  padding: 0;
  accent-color: var(--primary);
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

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

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

.choice-grid label {
  display: flex;
  min-height: 56px;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--surface-line);
  border-radius: 8px;
  background: white;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
}

.choice-grid label:has(input:checked) {
  color: var(--primary);
  border-color: var(--primary);
  background: #f3fbfb;
  box-shadow: 0 0 0 3px rgba(0, 82, 100, 0.08);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.info-grid div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--surface-line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.info-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.callout {
  margin: 14px 0 0;
  padding: 14px;
  color: var(--primary);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: var(--surface-soft);
}

.daily-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.daily-card-head h3,
.daily-card-head p {
  margin: 0;
}

.daily-card-head h3 {
  margin-bottom: 4px;
}

.daily-wizard {
  min-height: 500px;
  align-content: start;
}

.wizard-progress {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--surface-line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.wizard-progress > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.wizard-progress > strong {
  color: var(--primary);
  font-family: Manrope, Inter, system-ui, sans-serif;
}

.wizard-progress .progress {
  grid-column: 1 / -1;
  background: white;
}

.wizard-step {
  display: none;
  min-height: 300px;
  padding: 18px;
  border: 1px solid var(--surface-line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, var(--surface-soft));
}

.wizard-step.active {
  display: grid;
  gap: 14px;
  align-content: start;
}

.wizard-step h4 {
  margin: 0;
  color: var(--text);
  font-family: Manrope, Inter, system-ui, sans-serif;
  font-size: 24px;
  line-height: 1.15;
}

.question-kicker {
  width: fit-content;
  padding: 6px 10px;
  color: var(--primary);
  border-radius: 999px;
  background: #e9f5f5;
  font-size: 12px;
  font-weight: 900;
}

.wizard-actions {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.wizard-actions [data-wizard-submit] {
  grid-column: 2;
}

.wizard-actions [hidden] {
  display: none;
}

.activity-ai {
  display: grid;
  gap: 12px;
}

.activity-ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.activity-ai-head strong {
  color: var(--primary);
  font-family: Manrope, Inter, system-ui, sans-serif;
  font-size: 30px;
}

.activity-ai p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

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

.activity-components div {
  display: grid;
  gap: 2px;
  padding: 12px;
  border: 1px solid var(--surface-line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.activity-components span,
.activity-components small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.activity-components strong {
  color: var(--primary);
  font-size: 20px;
}

.ai-control-panel {
  display: grid;
  gap: 16px;
}

.ai-question-list {
  display: grid;
  gap: 10px;
}

.ai-question-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--surface-line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.ai-question-row strong {
  display: block;
  overflow-wrap: anywhere;
}

.ai-question-row .button {
  min-width: 128px;
}

.compact-row {
  grid-template-columns: 1fr 150px;
}

.focus-panel {
  position: sticky;
  top: 92px;
  max-height: calc(100dvh - 112px);
  overflow: auto;
}

.focus-tabs {
  margin: 8px 0 14px;
}

.focus-section {
  display: none;
}

.focus-section.active {
  display: grid;
  gap: 12px;
}

.login {
  display: grid;
  min-height: 100dvh;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
}

.login-visual {
  display: grid;
  align-content: end;
  padding: 48px;
  color: white;
  background:
    linear-gradient(rgba(0, 82, 100, 0.72), rgba(0, 84, 84, 0.78)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='900' viewBox='0 0 1200 900'%3E%3Crect width='1200' height='900' fill='%23b3ebff'/%3E%3Cpath d='M0 690c140-80 236-62 368-20 166 52 272 68 448-20 118-58 224-74 384-24v274H0z' fill='%23ffdad3'/%3E%3Ccircle cx='780' cy='265' r='150' fill='%23ffffff' fill-opacity='.38'/%3E%3Cpath d='M680 460c-38-94 18-202 112-240 96 36 150 146 108 240-30 68-86 112-110 158-26-46-80-90-110-158z' fill='%23005264' fill-opacity='.36'/%3E%3C/svg%3E");
  background-size: cover;
  background-position: center;
}

.login-visual h1 {
  max-width: 700px;
  margin: 0 0 12px;
  font-family: Manrope, Inter, system-ui, sans-serif;
  font-size: clamp(40px, 7vw, 76px);
  line-height: 0.98;
  letter-spacing: 0;
}

.login-card {
  display: grid;
  align-content: center;
  gap: 20px;
  padding: 32px;
  background: white;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 8px;
  background: var(--surface-soft);
}

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

.auth-links button {
  min-height: 38px;
  padding: 6px 8px;
  color: var(--primary);
  border: 1px solid var(--surface-line);
  border-radius: 8px;
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 800;
}

.role-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.role-switch button {
  min-height: 46px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.role-switch button.active {
  color: var(--primary);
  background: white;
  box-shadow: 0 4px 12px rgba(0, 82, 100, 0.08);
}

.auth-secondary-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.auth-secondary-links button,
.link-button {
  min-height: 36px;
  padding: 0;
  color: var(--primary);
  border: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-button {
  justify-self: start;
}

.tabs button {
  flex: 1;
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.tabs button.active {
  color: var(--primary);
  background: white;
  box-shadow: 0 4px 12px rgba(0, 82, 100, 0.08);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  max-width: 420px;
  padding: 14px 16px;
  color: white;
  background: var(--primary);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.empty {
  display: grid;
  min-height: 160px;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--surface-line);
  border-radius: 8px;
}

@media (max-width: 900px) {
  .layout,
  .hero,
  .login {
    grid-template-columns: 1fr;
  }

  .login-visual {
    min-height: 42dvh;
    padding: 32px 24px;
  }

  .sidebar {
    position: static;
    grid-template-columns: repeat(2, 1fr);
  }

  .span-3,
  .span-4,
  .span-5,
  .span-6,
  .span-7,
  .span-8 {
    grid-column: span 12;
  }

  .patient-row {
    grid-template-columns: 1fr;
  }

  .focus-panel {
    position: static;
    max-height: none;
  }

  .patient-row button {
    justify-self: stretch;
  }
}

@media (max-width: 620px) {
  .container {
    width: min(100% - 24px, 1180px);
    padding-top: 16px;
  }

  .topbar {
    padding-inline: 12px;
  }

  .brand {
    font-size: 18px;
  }

  .hero {
    padding: 20px;
  }

  .hero h1 {
    font-size: 34px;
  }

  .form-grid,
  .choice-grid,
  .info-grid,
  .activity-components,
  .ai-question-row,
  .wizard-actions,
  .auth-links,
  .sidebar {
    grid-template-columns: 1fr;
  }

  .wide-field {
    grid-column: span 1;
  }

  .ai-question-row .button {
    width: 100%;
  }

  .wizard-actions [data-wizard-submit] {
    grid-column: 1;
  }

  .metric-value {
    font-size: 30px;
  }
}
