:root {
  --navy: #1A3A5C;
  --blue: #2B6CB0;
  --green: #38A169;
  --gold: #D69E2E;
  --red: #E53E3E;
  --ink: #1A202C;
  --muted: #718096;
  --line: #E2E8F0;
  --panel: #FFFFFF;
  --bg: #F6F8FB;
  --focus: #F6C85F;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .72; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.skip-link {
  position: fixed;
  left: 16px;
  top: -60px;
  z-index: 1000;
  background: var(--navy);
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
}
.skip-link:focus { top: 12px; }

.login-page {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
  background:
    linear-gradient(135deg, rgba(26,58,92,.94), rgba(43,108,176,.86)),
    radial-gradient(circle at 20% 20%, rgba(56,161,105,.28), transparent 34%),
    var(--navy);
}
.login-story {
  color: white;
  padding: clamp(32px, 7vw, 88px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100svh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 1.35rem;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: white;
  color: var(--blue);
  display: grid;
  place-items: center;
  font-weight: 900;
}
.login-copy h1 {
  font-size: clamp(2.3rem, 5vw, 4.8rem);
  line-height: .98;
  letter-spacing: 0;
  margin: 0 0 20px;
  max-width: 820px;
}
.login-copy p {
  color: rgba(255,255,255,.82);
  font-size: 1.08rem;
  line-height: 1.6;
  max-width: 680px;
}
.login-panel {
  background: white;
  min-height: 100svh;
  padding: 42px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-left: 1px solid rgba(255,255,255,.2);
}
.login-panel h2 { margin: 0 0 8px; font-size: 1.55rem; color: var(--navy); }
.login-panel p { margin: 0 0 24px; color: var(--muted); line-height: 1.5; }
.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field label { font-size: .78rem; font-weight: 800; text-transform: uppercase; color: #4A5568; }
.input, .select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  background: white;
  color: var(--ink);
}
.input[aria-invalid="true"] { border-color: var(--red); }
.hint, .error { font-size: .82rem; line-height: 1.35; }
.hint { color: var(--muted); }
.error { color: var(--red); min-height: 1.1rem; }
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 11px 14px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
}
.btn-primary { background: var(--blue); color: white; }
.btn-outline { background: white; border-color: var(--line); color: var(--navy); }
.btn-danger { background: #FFF5F5; border-color: #FEB2B2; color: #C53030; }
.btn-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  color: var(--navy);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.shell { min-height: 100svh; display: flex; }
.sidebar {
  width: 264px;
  background: linear-gradient(180deg, var(--navy), #12314F);
  color: white;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  transition: transform .2s ease;
}
.sidebar .brand { padding: 22px; border-bottom: 1px solid rgba(255,255,255,.1); }
.nav { padding: 14px; overflow-y: auto; flex: 1; }
.nav-section { color: rgba(255,255,255,.5); font-size: .68rem; text-transform: uppercase; font-weight: 900; margin: 20px 10px 8px; }
.nav button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.78);
  border-radius: 8px;
  padding: 11px 12px;
  text-align: left;
  font-weight: 700;
}
.nav button.active, .nav button:hover { background: rgba(255,255,255,.13); color: white; }
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,.1); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 9px; background: var(--green); color: white; display: grid; place-items: center; font-weight: 900; }
.main { margin-left: 264px; width: calc(100% - 264px); min-height: 100svh; }
.topbar {
  height: 66px;
  background: white;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title strong { display: block; color: var(--navy); }
.topbar-title span { color: var(--muted); font-size: .82rem; }
.content { padding: 24px; max-width: 1500px; margin: 0 auto; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.stat { display: flex; gap: 13px; align-items: center; }
.stat-icon { width: 46px; height: 46px; border-radius: 8px; display: grid; place-items: center; font-weight: 900; }
.stat-value { font-size: 1.8rem; line-height: 1; font-weight: 900; color: var(--navy); }
.stat-label { color: #4A5568; font-weight: 800; margin-top: 5px; }
.stat-sub { color: var(--muted); font-size: .82rem; margin-top: 3px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.toolbar .input { max-width: 420px; min-width: 220px; }
.patient-card { padding: 0; overflow: hidden; }
.patient-head { padding: 16px; display: flex; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); }
.patient-body { padding: 16px; color: var(--muted); font-size: .9rem; display: grid; gap: 8px; }
.patient-actions { padding: 12px 16px; display: flex; gap: 8px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: .75rem;
  font-weight: 900;
}
.badge-green { background: #F0FFF4; color: #276749; }
.badge-blue { background: #EBF8FF; color: #2B6CB0; }
.badge-yellow { background: #FFFFF0; color: #975A16; }
.badge-gray { background: #EDF2F7; color: #4A5568; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: white; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .76rem; text-transform: uppercase; color: var(--muted); background: #F8FAFC; }
.empty { text-align: center; color: var(--muted); padding: 42px 18px; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
}
.modal {
  background: white;
  border-radius: 8px;
  width: min(920px, 100%);
  max-height: min(760px, calc(100svh - 36px));
  overflow: auto;
}
.modal-head, .modal-foot { padding: 16px 18px; display: flex; align-items: center; gap: 10px; }
.modal-head { background: linear-gradient(135deg, var(--navy), var(--blue)); color: white; justify-content: space-between; }
.modal-body { padding: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-section {
  background: #F8FAFC;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-top: 14px;
}
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.tab-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
  padding: 10px 12px;
  border-bottom: 3px solid transparent;
}
.tab-btn.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}
.tab-panel[hidden] { display: none; }
.photo-row {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px;
  background: #EBF8FF;
  border: 1px solid #BEE3F8;
  border-radius: 8px;
  margin-bottom: 16px;
}
.photo-preview {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: #CBD5E0;
  border: 3px solid var(--blue);
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #4A5568;
  font-weight: 900;
  flex: 0 0 auto;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.checkbox-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.check-pill {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: white;
  font-weight: 700;
  font-size: .84rem;
}
.severity-option {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: white;
  cursor: pointer;
}
.severity-option:has(input:checked) { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(43,108,176,.14); }
.toast-region { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: grid; gap: 10px; }
.toast { background: white; border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 8px; padding: 12px 14px; box-shadow: 0 12px 30px rgba(15,23,42,.16); max-width: 360px; }
.overlay { display: none; }

@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .login-page { grid-template-columns: 1fr; }
  .login-story { min-height: auto; padding: 26px; }
  .login-copy h1 { font-size: 2.35rem; }
  .login-panel { min-height: auto; padding: 26px; }
  .sidebar { transform: translateX(-100%); width: min(84vw, 300px); }
  .sidebar.open { transform: translateX(0); }
  .overlay.show { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 45; }
  .main { margin-left: 0; width: 100%; }
  .content { padding: 16px; }
  .grid-4, .grid-3, .grid-2, .form-grid { grid-template-columns: 1fr; }
  .photo-row { align-items: flex-start; flex-direction: column; }
  .topbar { padding: 0 14px; }
  .topbar-title span { display: none; }
  .toolbar .input, .toolbar .select { max-width: none; width: 100%; }
}
