:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --ink: #102a43;
  --muted: #627184;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --line: #dbe4ee;
  --blue: #2563eb;
  --green: #168557;
  --yellow: #b7791f;
  --orange: #c05621;
  --red: #c2413d;
  --shadow: 0 14px 34px rgba(16, 42, 67, 0.08);
  font-family: Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    linear-gradient(180deg, #eef5f7 0, var(--bg) 280px),
    var(--bg);
  color: var(--ink);
  line-height: 1.6;
}
body.modal-open {
  overflow: hidden;
}

body.registration-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 82% 6%, rgba(15, 118, 110, 0.13), transparent 28rem),
    radial-gradient(circle at 12% 18%, rgba(37, 99, 235, 0.08), transparent 24rem),
    linear-gradient(180deg, #eef6f7 0, #f7fafc 54%, #f4f7fa 100%);
}

.registration-screen {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: 28px 16px 44px;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(18px, 4vw, 56px);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(24px, 3vw, 42px); }
h2 { font-size: clamp(24px, 2.5vw, 34px); margin-bottom: 10px; }
h3 { font-size: 20px; margin-bottom: 18px; }
.eyebrow {
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 5px;
}
.main-nav { display: flex; gap: 10px; flex-wrap: wrap; }
.main-nav a, .tab, .secondary, .export-actions button, .filters button {
  color: var(--ink);
  text-decoration: none;
  background: #eef5f6;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
}
.main-nav a:hover, .tab.active, .secondary:hover { background: #dceff0; color: var(--primary-dark); }

.section { padding: 48px clamp(16px, 4vw, 56px); }
.section-intro { max-width: 780px; margin-bottom: 24px; }
.registration-layout {
  display: grid;
  grid-template-columns: minmax(240px, 0.78fr) minmax(320px, 1.22fr);
  gap: 28px;
  align-items: start;
}
.registration-only {
  display: block;
  width: min(820px, 100%);
  max-width: none;
  margin: 0 auto;
  padding: 0;
}
.registration-only .form-grid {
  margin: 0 auto;
  width: 100%;
}
.registration-page .section {
  padding: 0;
}
.registration-brand {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(219, 228, 238, 0.92);
  border-radius: 8px;
  box-shadow: 0 16px 36px rgba(16, 42, 67, 0.08);
  backdrop-filter: blur(16px);
}
.registration-logo {
  width: clamp(86px, 13vw, 124px);
  height: clamp(86px, 13vw, 124px);
  display: block;
  object-fit: contain;
}
.registration-brand-text h1 {
  font-size: clamp(23px, 3vw, 34px);
  line-height: 1.35;
}
.dashboard-link {
  align-self: center;
  color: var(--primary-dark);
  text-decoration: none;
  background: #eef5f6;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 700;
  white-space: nowrap;
}
.dashboard-link:hover {
  background: #dceff0;
}
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-panel {
  width: min(430px, 100%);
}
.login-panel h1 {
  font-size: 30px;
  margin-bottom: 18px;
}
.login-panel .primary {
  margin-top: 16px;
  width: 100%;
}
.login-back {
  display: inline-flex;
  margin-top: 16px;
  color: var(--primary-dark);
  text-decoration: none;
}
.inline-success {
  margin: 0 auto 16px;
  padding: 14px 16px;
  border: 1px solid #b9e2cf;
  border-radius: 8px;
  background: #eefaf4;
  color: #145a3c;
  box-shadow: 0 8px 20px rgba(16, 42, 67, 0.05);
}
.inline-success strong {
  display: block;
  margin-bottom: 4px;
}
.inline-success span {
  color: #28684c;
}
.inline-error {
  margin: 0 auto 16px;
  padding: 14px 16px;
  border: 1px solid #f0b7b4;
  border-radius: 8px;
  background: #fff1f1;
  color: #8f2f2b;
  box-shadow: 0 8px 20px rgba(16, 42, 67, 0.05);
}
.inline-error strong {
  display: block;
  margin-bottom: 4px;
}
.inline-error span {
  color: #9f3d39;
}
.thank-you-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 42, 67, 0.48);
  backdrop-filter: blur(8px);
}
.thank-you-card {
  width: min(520px, 100%);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 30px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(16, 42, 67, 0.22);
}
.thank-you-icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: #dff4e9;
  color: var(--green);
  font-size: 36px;
  font-weight: 700;
}
.thank-you-card h2 {
  font-size: 26px;
  margin-bottom: 10px;
}
.thank-you-card p {
  color: var(--muted);
  margin-bottom: 14px;
}
.thank-you-details {
  margin: 18px 0 22px;
  padding: 12px 14px;
  background: #f8fbfd;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--primary-dark);
}
.thank-you-card .primary {
  min-width: 150px;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.form-grid, .filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.date-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 10px;
}
.participation-date {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fbfd;
}
.capacity-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.capacity-hint.warning {
  color: var(--red);
  font-weight: 700;
}
label, .field-title, legend { color: var(--ink); font-weight: 700; }
input, select, textarea {
  width: 100%;
  margin-top: 7px;
  border: 1px solid #cfd9e3;
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(15, 118, 110, 0.14);
  border-color: var(--primary);
}
textarea { resize: vertical; }
.wide { grid-column: 1 / -1; }
.radio-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}
.radio-group label { font-weight: 500; }
.radio-group input { width: auto; margin: 0 0 0 6px; }

.primary, .form-grid button[type="submit"] {
  background: var(--primary);
  color: white;
  border-radius: 8px;
  padding: 13px 18px;
  font-weight: 700;
}
.primary:hover { background: var(--primary-dark); }
.danger { background: #fde7e7; color: var(--red); border-radius: 8px; padding: 12px 14px; }

.mini-calendar, .heat-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(42px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.day-cell {
  min-height: 54px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f8fcfc;
  display: grid;
  place-items: center;
  padding: 6px;
  color: var(--ink);
}
.day-cell.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
.heat-calendar .day-cell { min-height: 86px; place-items: stretch; align-content: space-between; }
.heat-calendar .day-cell small { color: inherit; opacity: .85; }
.heat-0 { background: #f8fcfc; }
.heat-1 { background: #e5f3f2; }
.heat-2 { background: #cce7e5; }
.heat-3 { background: #92cbc6; color: #083f3d; }
.heat-4 { background: var(--primary); color: #fff; }

.dashboard-topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 18px;
}
.top-actions {
  display: grid;
  grid-template-columns: 160px 150px 150px auto;
  gap: 10px;
  align-items: center;
}
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 22px 0; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 8px 20px rgba(16, 42, 67, 0.05);
}
.stat-card strong { display: block; font-size: 26px; color: var(--primary-dark); }
.stat-card span { color: var(--muted); }

.grid { display: grid; gap: 18px; margin-top: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
canvas { width: 100%; max-width: 100%; }

.filters {
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  margin-bottom: 16px;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1100px; }
th, td {
  text-align: right;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th { background: #f0f5f8; color: var(--primary-dark); position: sticky; top: 0; }
td select, td textarea { min-width: 130px; margin-top: 0; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 13px;
  font-weight: 700;
}
.badge.green { background: #dff4e9; color: var(--green); }
.badge.blue { background: #e4f0ff; color: var(--blue); }
.badge.yellow { background: #fff3d1; color: #9b6d00; }
.badge.orange { background: #ffe8d9; color: var(--orange); }
.badge.red { background: #ffe2e2; color: var(--red); }
.badge.gray { background: #edf1f1; color: var(--muted); }

.status-summary, .balance-list, .analysis-list, .alerts, .quality-grid, .doctor-list {
  display: grid;
  gap: 10px;
}
.summary-row, .balance-row, .analysis-row, .alert-row, .quality-card, .doctor-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: #f8fbfd;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.quality-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.quality-card { display: block; }
.quality-card strong { display: block; font-size: 24px; color: var(--primary-dark); }

.qr-grid, .public-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.qr-card, .public-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.qr-actions, .card-actions, .row-actions, .export-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.qr-actions button, .card-actions a, .row-actions button, .export-actions button {
  background: #eef5f6;
  color: var(--primary-dark);
  border-radius: 8px;
  padding: 9px 11px;
  text-decoration: none;
}
.specialty-add, .specialty-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}
.specialty-row {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfd;
}
.specialty-add button, .specialty-row button {
  border-radius: 8px;
  padding: 12px 14px;
  background: #eef5f6;
  color: var(--primary-dark);
}
.row-actions button.danger, .specialty-row button.danger {
  background: #fde7e7;
  color: var(--red);
}

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  max-width: min(520px, 92vw);
}
[hidden] {
  display: none !important;
}
dialog::backdrop { background: rgba(9, 34, 38, .45); }
.dialog-card { padding: 22px; background: white; position: relative; }
.close-dialog {
  position: absolute;
  left: 14px;
  top: 12px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #edf5f4;
  font-size: 22px;
}
.profile-card { text-align: center; }
.profile-card canvas { max-width: 220px; margin: 10px auto; display: block; }
.success-dialog {
  position: fixed;
  inset: 0;
  z-index: 100;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border: 0;
  background: rgba(9, 34, 38, .45);
  padding: 20px;
}
.success-card {
  background: #fff;
  padding: 30px;
  text-align: center;
  border-radius: 8px;
  box-shadow: var(--shadow);
  width: min(460px, 100%);
}
.success-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: #dff4e9;
  color: var(--green);
  font-size: 32px;
  font-weight: 700;
}
.success-card h2 {
  font-size: 24px;
  margin-bottom: 10px;
}
.success-card p {
  color: var(--muted);
  margin-bottom: 20px;
}
.success-card .primary {
  min-width: 150px;
}

.toast {
  position: fixed;
  left: 22px;
  bottom: 22px;
  z-index: 50;
  background: var(--primary-dark);
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  transform: translateY(120px);
  transition: .25s ease;
}
.toast.show { transform: translateY(0); }

.lock-dialog .lock-panel { min-width: min(420px, 90vw); box-shadow: none; }

@media (max-width: 1080px) {
  .registration-layout, .grid.two { grid-template-columns: 1fr; }
  .stats-grid, .qr-grid, .public-grid, .quality-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .top-actions, .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .site-header, .dashboard-topbar { align-items: stretch; flex-direction: column; }
  .form-grid, .stats-grid, .qr-grid, .public-grid, .quality-grid, .top-actions, .filters, .date-picker-grid, .specialty-add, .specialty-row { grid-template-columns: 1fr; }
  .registration-screen { padding: 16px 12px 32px; }
  .registration-brand {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 10px;
  }
  .registration-logo {
    width: 104px;
    height: 104px;
  }
  .dashboard-link {
    width: 100%;
    text-align: center;
  }
  .section { padding: 34px 14px; }
  .registration-page .section { padding: 0; }
  .panel { padding: 16px; }
  .mini-calendar, .heat-calendar { gap: 5px; }
  .day-cell { min-height: 44px; font-size: 13px; }
}
