:root {
  --ink: #173336;
  --muted: #667b7d;
  --teal-dark: #075653;
  --teal: #087c78;
  --teal-light: #e9f6f5;
  --coral: #d65d4f;
  --coral-dark: #b94b40;
  --gold: #f2bb48;
  --line: #d8e6e5;
  --surface: #ffffff;
  --surface-soft: #f4f9f8;
  --danger: #b42318;
  --shadow: 0 18px 48px rgba(15, 70, 70, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  background:
    radial-gradient(circle at 8% 12%, rgba(8, 124, 120, 0.11), transparent 28rem),
    var(--surface-soft);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  line-height: 1.7;
  margin: 0;
  min-height: 100vh;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.patient-header {
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px clamp(18px, 5vw, 72px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.patient-brand {
  align-items: center;
  color: var(--teal-dark);
  display: inline-flex;
  font-size: 1.05rem;
  font-weight: 900;
  gap: 10px;
  text-decoration: none;
}

.patient-brand-mark {
  align-items: center;
  background: var(--teal);
  border-radius: 50%;
  color: #fff;
  display: inline-flex;
  height: 38px;
  justify-content: center;
  width: 38px;
}

.patient-nav {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.patient-nav a,
.nav-button,
.logout-button {
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  padding: 8px 12px;
  text-decoration: none;
}

.nav-button.is-active,
.patient-nav a:hover,
.nav-button:hover {
  background: var(--teal-light);
  color: var(--teal-dark);
}

.logout-button {
  color: var(--danger);
}

main {
  margin: 0 auto;
  max-width: 1440px;
  padding: clamp(28px, 5vw, 72px) clamp(16px, 5vw, 72px) 80px;
}

.auth-shell {
  align-items: stretch;
  display: grid;
  gap: clamp(28px, 6vw, 90px);
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  min-height: calc(100vh - 180px);
}

.auth-intro {
  align-self: center;
  max-width: 680px;
}

.eyebrow {
  color: var(--coral);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  margin: 0 0 10px;
}

.auth-intro h1,
.app-welcome h1 {
  font-size: clamp(2.6rem, 7vw, 5.6rem);
  letter-spacing: -0.05em;
  line-height: 1.05;
  margin: 0;
}

.auth-intro > p:not(.eyebrow) {
  color: var(--muted);
  font-size: clamp(1.08rem, 2vw, 1.35rem);
  max-width: 620px;
}

.auth-intro ul {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 28px 0;
  padding: 0;
}

.auth-intro li::before {
  color: var(--teal);
  content: "✓";
  font-weight: 900;
  margin-left: 10px;
}

.text-link {
  color: var(--teal-dark);
  font-weight: 900;
}

.login-card {
  align-self: center;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: clamp(24px, 4vw, 48px);
}

.login-card h2,
.section-heading h2,
.dialog-heading h2 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.2;
  margin: 0;
}

.muted,
.login-card > p,
.dialog-heading > p {
  color: var(--muted);
}

.login-form,
.booking-form {
  display: grid;
  gap: 18px;
  margin-top: 26px;
}

label {
  color: var(--ink);
  display: grid;
  font-weight: 800;
  gap: 7px;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  min-height: 48px;
  padding: 11px 13px;
  width: 100%;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 124, 120, 0.13);
  outline: 0;
}

.primary-button,
.secondary-button,
.whatsapp-button {
  align-items: center;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 900;
  justify-content: center;
  min-height: 48px;
  padding: 11px 18px;
  text-decoration: none;
}

.primary-button {
  background: linear-gradient(135deg, var(--teal), #31aaa4);
  box-shadow: 0 8px 18px rgba(8, 124, 120, 0.2);
  color: #fff;
}

.primary-button:hover {
  background: var(--teal-dark);
}

.secondary-button {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--teal-dark);
}

.whatsapp-button {
  background: #e7faef;
  color: #087b39;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.divider {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: 12px;
  margin: 22px 0;
}

.divider::before,
.divider::after {
  background: var(--line);
  content: "";
  flex: 1;
  height: 1px;
}

.google-login-button {
  display: flex;
  justify-content: center;
  min-height: 44px;
  overflow: hidden;
  width: 100%;
}

.form-message {
  color: var(--teal-dark);
  font-weight: 800;
  margin: 14px 0 0;
  min-height: 1.6em;
}

.form-message.is-error {
  color: var(--danger);
}

.session-note {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 12px 0 0;
}

.patient-app {
  display: grid;
  gap: 36px;
}

.app-welcome {
  align-items: end;
  background: linear-gradient(120deg, var(--teal-dark), var(--teal));
  border-radius: 28px;
  color: #fff;
  display: flex;
  gap: 30px;
  justify-content: space-between;
  overflow: hidden;
  padding: clamp(28px, 5vw, 54px);
  position: relative;
}

.app-welcome::after {
  border: 36px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  content: "";
  height: 180px;
  left: -40px;
  position: absolute;
  top: -70px;
  width: 180px;
}

.app-welcome h1 {
  font-size: clamp(2.2rem, 5vw, 4.2rem);
}

.app-welcome .eyebrow {
  color: var(--gold);
}

.app-welcome p:not(.eyebrow) {
  color: rgba(255, 255, 255, 0.78);
  margin-bottom: 0;
}

.welcome-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  position: relative;
  z-index: 1;
}

.app-welcome .secondary-button {
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
}

.app-view {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: clamp(22px, 4vw, 38px);
}

.section-heading {
  align-items: end;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin-bottom: 28px;
}

.catalog-filters {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(240px, 1fr) minmax(180px, 0.55fr);
  width: min(620px, 100%);
}

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

.doctor-card,
.appointment-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(28, 78, 78, 0.06);
  padding: 22px;
}

.doctor-card {
  display: grid;
  gap: 16px;
}

.doctor-card-header {
  align-items: center;
  display: flex;
  gap: 14px;
}

.doctor-avatar {
  align-items: center;
  background: var(--teal-light);
  border-radius: 16px;
  color: var(--teal);
  display: flex;
  flex: 0 0 54px;
  font-size: 1.4rem;
  font-weight: 900;
  height: 54px;
  justify-content: center;
}

.doctor-card h3,
.appointment-card h3 {
  font-size: 1.12rem;
  margin: 0;
}

.doctor-card p,
.appointment-card p {
  color: var(--muted);
  margin: 3px 0 0;
}

.doctor-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 5px 10px;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.card-actions > * {
  flex: 1;
  min-width: 110px;
}

.appointment-list {
  display: grid;
  gap: 14px;
}

.appointment-card {
  align-items: center;
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr auto;
}

.appointment-card-main {
  display: grid;
  gap: 10px;
}

.appointment-details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.appointment-status {
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
  padding: 5px 10px;
}

.status-pending {
  background: #fff5d8;
  color: #8a5b00;
}

.status-confirmed,
.status-completed {
  background: #e7f8ef;
  color: #08733c;
}

.status-cancelled {
  background: #ffebe9;
  color: var(--danger);
}

.status-postponed {
  background: #edf0ff;
  color: #3645a5;
}

.loading-card,
.empty-state {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
  padding: 34px;
  text-align: center;
}

.patient-dialog {
  background: var(--surface);
  border: 0;
  border-radius: 24px;
  box-shadow: 0 25px 80px rgba(8, 48, 48, 0.28);
  color: var(--ink);
  max-height: min(88vh, 900px);
  max-width: min(760px, calc(100vw - 28px));
  overflow: auto;
  padding: clamp(24px, 4vw, 44px);
  width: 100%;
}

.confirmation-dialog {
  max-width: 480px;
}

.patient-dialog::backdrop {
  background: rgba(7, 41, 42, 0.62);
  backdrop-filter: blur(3px);
}

.dialog-close {
  background: var(--surface-soft);
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.55rem;
  height: 40px;
  left: 18px;
  line-height: 1;
  position: absolute;
  top: 18px;
  width: 40px;
}

.detail-block {
  border-top: 1px solid var(--line);
  margin-top: 22px;
  padding-top: 20px;
}

.clinic-list {
  display: grid;
  gap: 12px;
}

.clinic-item {
  background: var(--surface-soft);
  border-radius: 14px;
  padding: 16px;
}

.clinic-item h3 {
  margin: 0;
}

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

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

.time-fieldset {
  border: 1px solid var(--line);
  border-radius: 16px;
  margin: 0;
  padding: 16px;
}

.time-fieldset legend {
  font-weight: 900;
  padding: 0 6px;
}

.time-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.time-slot {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--teal-dark);
  cursor: pointer;
  font-weight: 900;
  min-height: 42px;
  padding: 8px 14px;
}

.time-slot.is-selected {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.time-slot:disabled {
  background: #eef1f1;
  color: #9aa7a8;
  cursor: not-allowed;
  text-decoration: line-through;
}

.toast {
  background: var(--ink);
  border-radius: 14px;
  bottom: 24px;
  box-shadow: var(--shadow);
  color: #fff;
  font-weight: 800;
  left: 24px;
  max-width: min(420px, calc(100vw - 48px));
  padding: 14px 18px;
  position: fixed;
  z-index: 50;
}

.toast.is-error {
  background: var(--danger);
}

.visually-hidden {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

@media (max-width: 980px) {
  .auth-shell,
  .doctor-grid {
    grid-template-columns: 1fr 1fr;
  }

  .auth-intro {
    grid-column: 1 / -1;
  }

  .login-card {
    grid-column: 1 / -1;
    justify-self: center;
    max-width: 600px;
    width: 100%;
  }

  .section-heading,
  .app-welcome {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 680px) {
  .patient-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .patient-nav {
    width: 100%;
  }

  .patient-nav > * {
    flex: 1;
    text-align: center;
  }

  main {
    padding-top: 28px;
  }

  .auth-shell,
  .doctor-grid,
  .catalog-filters,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .auth-intro h1 {
    font-size: clamp(2.4rem, 15vw, 3.6rem);
  }

  .app-welcome {
    border-radius: 20px;
  }

  .welcome-actions,
  .card-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .appointment-card {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .patient-dialog {
    border-radius: 18px;
    max-height: 92vh;
    padding-top: 58px;
  }
}
