* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #f4f8fb;
  color: #172033;
}
a { color: inherit; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
  background: #ffffff;
  border-bottom: 1px solid #e4edf5;
  position: sticky;
  top: 0;
  z-index: 2;
}
.brand { font-weight: 800; letter-spacing: .05em; color: #20bde7; }
.brand span { color: #6b7280; font-weight: 600; letter-spacing: 0; margin-left: 8px; }
nav { display: flex; gap: 14px; }
nav a { text-decoration: none; font-weight: 600; color: #334155; }
.container {
  width: min(980px, calc(100% - 28px));
  margin: 28px auto;
}
.auth-card, .panel {
  background: #ffffff;
  border: 1px solid #e3edf5;
  border-radius: 22px;
  padding: 28px;
  box-shadow: 0 18px 40px rgba(21, 35, 53, .08);
}
.auth-card { max-width: 440px; margin: 60px auto; }
h1 { margin: 0 0 12px; font-size: clamp(28px, 4vw, 42px); }
h2 { margin: 0 0 10px; }
p { color: #526173; line-height: 1.6; }
.form, .search-form { display: grid; gap: 12px; }
.form input, .form select, .search-form input {
  width: 100%;
  border: 1px solid #ccd9e5;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 16px;
  background: #fff;
}
.search-form { grid-template-columns: 1fr auto; margin: 22px 0; }
.btn {
  border: 0;
  border-radius: 14px;
  padding: 13px 18px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 46px;
}
.btn.primary { background: #21bfe9; color: #ffffff; }
.btn.secondary { background: #eaf2f7; color: #263344; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.alert {
  padding: 14px 16px;
  border-radius: 14px;
  margin: 14px 0;
  font-weight: 650;
}
.alert.error { background: #fee2e2; color: #991b1b; }
.alert.warning { background: #fef3c7; color: #92400e; }
.alert.success { background: #dcfce7; color: #166534; }
.patient-card {
  background: #f8fbfd;
  border: 1px solid #e0ecf4;
  border-radius: 18px;
  padding: 20px;
  margin-top: 18px;
}
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.doc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 24px 0;
}
.doc-card {
  text-align: left;
  border: 2px solid #dce8f1;
  border-radius: 20px;
  padding: 20px;
  background: #ffffff;
  cursor: pointer;
  min-height: 135px;
  transition: .15s;
}
.doc-card:hover, .doc-card.active { border-color: #20bde7; transform: translateY(-1px); }
.doc-card strong { display: block; font-size: 18px; color: #172033; margin-bottom: 10px; }
.doc-card span { color: #64748b; }
.selected-doc {
  border-top: 1px solid #e6eef5;
  margin-top: 20px;
  padding-top: 20px;
}
.hidden { display: none !important; }
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .58);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 10;
}
.modal-content {
  width: min(760px, 100%);
  background: #ffffff;
  border-radius: 22px;
  padding: 24px;
  position: relative;
}
.modal-close {
  position: absolute;
  right: 16px;
  top: 12px;
  border: 0;
  background: transparent;
  font-size: 32px;
  cursor: pointer;
}
#signaturePad {
  width: 100%;
  height: 260px;
  border: 2px dashed #9eb3c7;
  border-radius: 16px;
  background: #ffffff;
  touch-action: none;
}
@media (max-width: 760px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .search-form { grid-template-columns: 1fr; }
  .doc-grid { grid-template-columns: 1fr; }
}
