:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #1b2430;
  --muted: #5d6b7a;
  --accent: #0b57d0;
  --accent-2: #0a3f98;
  --border: #d7dfeb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 10%, #dfe9ff 0%, transparent 35%),
    radial-gradient(circle at 80% 90%, #d5f6ff 0%, transparent 30%),
    var(--bg);
  min-height: 100vh;
}

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

.page.page-top {
  place-items: start center;
}

.card {
  width: min(980px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 15px 40px rgba(16, 44, 84, 0.08);
}

.auth-card {
  width: min(460px, 100%);
}

.auth-form {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.auth-logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}

.auth-logo {
  width: 194px;
  max-width: 100%;
  height: auto;
}

.top-right-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.top-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-right: auto;
}

.top-link {
  text-decoration: none;
  color: #2d3a47;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 12px;
  font-weight: 600;
  background: #fff;
}

.top-link.active {
  border-color: var(--accent);
  color: var(--accent);
}

.logout-btn {
  padding: 9px 14px;
  font-weight: 600;
}

.user-greeting {
  color: var(--muted);
  font-weight: 400;
  white-space: nowrap;
}

.user-greeting-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
}

.user-greeting-link:hover {
  color: var(--accent);
}

.top-nav-logo {
  width: 123px;
  height: auto;
  display: block;
}

.records-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.record-row {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f9fbff;
  overflow: hidden;
}

.record-row-summary {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(220px, 1.4fr) minmax(160px, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
}

.record-row-summary:hover {
  background: #eef4ff;
}

.record-col {
  min-width: 0;
}

.record-col-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
}

.record-col-value {
  display: block;
  margin-top: 2px;
  font-weight: 700;
  color: #1f2f3c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.record-row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.record-row-details {
  border-top: 1px dashed var(--border);
  background: #ffffff;
  padding: 10px 12px 12px;
}

.record-row-details .form-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.record-readonly-value {
  display: block;
  min-height: 0;
  padding: 2px 0 0;
  color: #2d3a47;
  font-weight: 600;
}

.hospital-toolbar {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0 14px;
}

.hospital-filters {
  margin-top: 6px;
}

.hospital-filter-field {
  min-width: 220px;
  flex: 1 1 280px;
}

#hospitalEditorPanel {
  margin-top: 4px;
}

.user-admin-field {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.user-admin-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.user-role-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.user-role-admin {
  color: #0b57d0;
  background: #e7f0ff;
}

.user-role-owner {
  color: #6d4c00;
  background: #fff3d3;
}

.user-role-manager {
  color: #0e6678;
  background: #dff5fb;
}

.user-role-user {
  color: #38623f;
  background: #e7f5ea;
}

.user-role-viewer {
  color: #48566a;
  background: #e7ebf1;
}

.user-password-label {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}

.user-password-hint {
  color: var(--muted);
  font-size: 0.9em;
}

#usersPageInfo {
  min-width: 130px;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
}

.hospital-action-btn {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
}

.hospital-action-danger {
  background: linear-gradient(135deg, #b3261e, #8e1f19);
}

.email-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.email-list {
  display: grid;
  gap: 4px;
  margin: -2px 0 6px;
}

.copy-icon-btn {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: #2d3a47;
  padding: 0;
}

.copy-icon-shape {
  display: block;
  width: 11px;
  height: 11px;
  position: relative;
}

.copy-icon-shape::before,
.copy-icon-shape::after {
  content: "";
  position: absolute;
  width: 9px;
  height: 9px;
  border: 1.5px solid #2d3a47;
  border-radius: 2px;
  background: #fff;
  box-sizing: border-box;
}

.copy-icon-shape::before {
  left: 2px;
  top: 2px;
}

.copy-icon-shape::after {
  left: 0;
  top: 0;
}

.copy-icon-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.copy-feedback {
  font-size: 0.8rem;
  font-weight: 600;
  color: #1b7f3a;
  white-space: nowrap;
}

.status-error {
  color: #b3261e;
}

h1 {
  margin: 0;
  font-size: clamp(1.4rem, 2vw, 2rem);
}

.form-section {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--border);
}

.form-section h2 {
  margin: 0 0 12px;
  font-size: 1.35rem;
  font-weight: 700;
  text-transform: uppercase;
}

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

.date-time-rows {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.date-time-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 500;
  color: #2d3a47;
}

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

input[name="labNumber"] {
  border: 3px solid #4b5563 !important;
}

input[name="labNumber"]:focus {
  border: 3px solid var(--accent) !important;
}

input,
select {
  height: 46px;
}

.file-picker-control {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.file-picker-button {
  padding: 9px 14px;
  font-weight: 600;
}

.file-picker-filename {
  color: var(--muted);
  font-size: 0.92rem;
}

.visually-hidden-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(11, 87, 208, 0.25);
  border-color: var(--accent);
}

.full-width {
  grid-column: 1 / -1;
}

.actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
}

button {
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  padding: 11px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.05);
}

button:active {
  transform: translateY(1px);
}

#status {
  margin-right: auto;
  color: var(--muted);
  font-size: 0.95rem;
}

#status.status-error {
  color: #b3261e;
}

#hospitalEditorStatus {
  margin-right: auto;
  color: var(--muted);
  font-size: 0.95rem;
}

#hospitalEditorStatus.status-error {
  color: #b3261e;
}

#userEditorStatus {
  margin-right: auto;
  color: var(--muted);
  font-size: 0.95rem;
}

#userEditorStatus.status-error {
  color: #b3261e;
}

.app-version {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.app-version-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted rgba(93, 107, 122, 0.7);
  cursor: pointer;
  pointer-events: auto;
}

.app-version-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

@media (max-width: 900px) {
  .record-row-summary {
    grid-template-columns: 1fr 1fr;
  }

  .record-row-actions {
    grid-column: span 2;
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .card {
    padding: 18px;
    border-radius: 14px;
  }

  .field-grid,
  .date-time-row {
    grid-template-columns: 1fr;
  }

  .top-right-actions {
    flex-wrap: wrap;
  }

  .hospital-filter-field {
    min-width: 100%;
  }

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

  .record-row-actions {
    grid-column: auto;
  }
}

#drugSelect,
#interpretationSelect {
  height: 46px;
}
