:root {
  color-scheme: light;
  --bg: #f3f6f5;
  --panel: #ffffff;
  --ink: #17211d;
  --muted: #65736d;
  --line: #dce5e1;
  --primary: #706db0;
  --primary-dark: #3e2d72;
  --accent: #9faee0;
  --soft: #f0f0fa;
  --rose: #e8d9ef;
  --warning: #f8b84e;
  --disabled: #e7ecea;
  --shadow: 0 24px 60px rgba(62, 45, 114, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(112, 109, 176, 0.12), transparent 36%),
    linear-gradient(320deg, rgba(159, 174, 224, 0.16), transparent 38%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

.shell {
  width: min(100%, 1180px);
  height: min(100vh - 48px, 900px);
  min-height: 720px;
  display: grid;
  grid-template-columns: 210px 1fr;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid rgba(23, 33, 29, 0.08);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  grid-column: 1;
  grid-row: 1;
  min-height: 86px;
  padding: 16px 20px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.topbar strong {
  color: var(--primary-dark);
  font-size: 21px;
  letter-spacing: 0;
}

.brand-logo {
  width: 54px;
  height: 54px;
  object-fit: contain;
}

.topbar span,
.eyebrow,
.meta,
.empty,
.small-note {
  color: var(--muted);
}

.screen {
  display: none;
  overflow-y: auto;
  grid-column: 2;
  grid-row: 1 / span 2;
  padding: 36px;
}

.screen.active {
  display: block;
}

.screen h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.12;
  letter-spacing: 0;
}

.screen h2 {
  margin: 0;
  font-size: 19px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.page-head p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.hero {
  display: grid;
  gap: 18px;
}

.summary-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, var(--soft), #fff 72%);
}

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

.quick-card,
.doctor-card,
.appointment-card,
.queue-card,
.profile-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
}

.quick-card {
  min-height: 110px;
  padding: 14px;
  display: grid;
  align-content: space-between;
  text-align: left;
}

.quick-card svg {
  width: 24px;
  height: 24px;
  stroke: var(--primary);
  fill: none;
  stroke-width: 2;
}

.doctor-card,
.appointment-card,
.queue-card,
.profile-panel {
  padding: 14px;
}

.doctor-card {
  min-height: 226px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.doctor-card .meta {
  margin-top: 0;
}

.doctor-card-head {
  align-items: flex-start;
}

.doctor-card-action {
  width: 100%;
  margin-top: auto;
}

.stack {
  display: grid;
  gap: 12px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.meta {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.35;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.pending {
  background: #fff4d8;
  color: #8a5a00;
}

.badge.cancelled {
  background: #f5e6ee;
  color: #7f3d65;
}

.badge.checked {
  background: #e7ecfb;
  color: #3d568d;
}

.actions,
.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.button,
.ghost,
.danger,
.icon-button,
.tab {
  border: 0;
  min-height: 42px;
  border-radius: 8px;
}

.button,
.ghost,
.danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 13px;
  font-weight: 750;
}

.compact {
  min-height: 38px;
  padding-inline: 12px;
}

.button {
  background: var(--primary);
  color: #fff;
}

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

.ghost {
  background: #f4f7f6;
  color: var(--ink);
  border: 1px solid var(--line);
}

.danger {
  background: #fae7eb;
  color: #93334b;
}

.button:disabled,
.ghost:disabled,
.danger:disabled {
  cursor: not-allowed;
  color: #8b9692;
  background: var(--disabled);
  border-color: var(--disabled);
}

.icon-button {
  width: 42px;
  display: grid;
  place-items: center;
  background: #f4f7f6;
  border: 1px solid var(--line);
}

svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.filters {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.search-field {
  position: relative;
}

.search-field svg {
  position: absolute;
  left: 12px;
  top: 50%;
  translate: 0 -50%;
  color: var(--muted);
}

.search-field input {
  padding-left: 42px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

textarea {
  min-height: 82px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(112, 109, 176, 0.18);
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.availability {
  display: grid;
  gap: 12px;
}

.doctor-detail {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  background: #fbfcfc;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 8px;
}

.date-button,
.slot-button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  min-height: 48px;
  display: grid;
  place-items: center;
  text-align: center;
  font-weight: 750;
}

.date-button span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.date-button.active,
.slot-button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.date-button.inactive,
.slot-button.booked {
  background: var(--disabled);
  color: #8b9692;
  cursor: not-allowed;
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.pill-tab {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  min-height: 36px;
  padding: 7px 12px;
  font-weight: 750;
  white-space: nowrap;
}

.pill-tab.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.queue-places {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 12px;
}

.place {
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-weight: 800;
}

.place.you {
  background: var(--rose);
  border-color: #cbb2dc;
  color: var(--primary-dark);
}

.profile-form {
  display: grid;
  gap: 10px;
}

.language-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

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

.active-option {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.field label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.tabbar {
  display: grid;
  grid-column: 1;
  grid-row: 2;
  align-content: start;
  gap: 6px;
  padding: 14px 12px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
}

.tabbar.hidden {
  display: none;
}

.tab {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: transparent;
  color: var(--muted);
}

.tab svg {
  width: 23px;
  height: 23px;
}

.tab span {
  font-size: 14px;
  font-weight: 750;
}

.tab.active {
  color: var(--primary);
  background: var(--soft);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 33, 29, 0.45);
  z-index: 10;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(100%, 390px);
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.modal h2 {
  margin: 0;
  font-size: 20px;
}

.modal p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.toast-region {
  position: fixed;
  left: 50%;
  bottom: 20px;
  translate: -50% 0;
  display: grid;
  gap: 8px;
  z-index: 20;
  width: min(390px, calc(100vw - 32px));
}

.toast {
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  font-weight: 700;
}

.empty {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
  line-height: 1.45;
}

.auth-page {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-bottom: 10px;
}

#start-screen,
#signup-screen,
#login-screen,
#forgot-screen {
  grid-column: 1 / -1;
}

.start-hero {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 18px 0 8px;
  text-align: center;
}

.start-logo {
  width: 104px;
  height: 104px;
  object-fit: contain;
}

.start-hero h1 {
  max-width: 320px;
}

.start-hero p:last-child {
  max-width: 350px;
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.feature-panel,
.auth-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(145deg, var(--soft), #fff 74%);
}

.feature-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.price {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.feature-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.feature-list li {
  position: relative;
  padding-left: 28px;
  color: var(--muted);
  line-height: 1.38;
}

.feature-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: inset 0 0 0 5px var(--soft);
}

.auth-actions,
.auth-form {
  display: grid;
  gap: 10px;
}

.contact-link {
  margin-top: auto;
  align-self: center;
}

.auth-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  margin-top: 26px;
}

.auth-logo {
  width: 82px;
  height: 82px;
  object-fit: contain;
  justify-self: center;
}

.auth-card h1,
.auth-card > .meta {
  text-align: center;
}

.auth-switch {
  margin: 0;
  color: var(--muted);
  text-align: center;
}

.link-button {
  border: 0;
  min-height: auto;
  padding: 0;
  background: transparent;
  color: var(--primary-dark);
  font-weight: 800;
}

.link-button:hover {
  text-decoration: underline;
}

[dir="rtl"] .search-field input {
  padding-right: 42px;
  padding-left: 11px;
}

[dir="rtl"] .search-field svg {
  right: 12px;
  left: auto;
}

@media (min-width: 980px) {
  .hero {
    max-width: 820px;
  }

  .summary-panel,
  .profile-panel,
  .queue-card {
    max-width: 760px;
  }

  .auth-page {
    width: min(100%, 760px);
    margin: 0 auto;
    justify-content: center;
  }

  .auth-actions {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1180px) {
  .result-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .profile-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .profile-form .field:last-of-type,
  .profile-form .button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 979px) {
  body {
    padding: 14px;
  }

  .shell {
    width: min(100%, 760px);
    height: min(100vh - 28px, 900px);
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }

  .topbar {
    grid-column: 1;
    grid-row: 1;
    justify-content: center;
    min-height: 76px;
    padding: 10px 16px 8px;
    border-right: 0;
  }

  .screen {
    grid-column: 1;
    grid-row: 2;
    padding: 24px 22px 28px;
  }

  .screen h1 {
    font-size: 28px;
  }

  .tabbar {
    grid-column: 1;
    grid-row: 3;
    grid-template-columns: repeat(5, 1fr);
    gap: 0;
    padding: 0;
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .tab {
    display: grid;
    place-items: center;
    gap: 2px;
    padding: 8px 3px 10px;
  }

  .tab span {
    font-size: 11px;
  }

  .tab.active {
    background: transparent;
  }

  .calendar-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .slot-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .quick-grid,
  .result-grid,
  .filter-row {
    grid-template-columns: 1fr;
  }

  .page-head {
    display: grid;
  }

  .actions,
  .modal-actions,
  .language-options {
    display: grid;
    grid-template-columns: 1fr;
  }

  .button,
  .ghost,
  .danger {
    width: 100%;
  }
}

@media (max-width: 460px) {
  body {
    display: block;
    padding: 0;
    background: var(--panel);
  }

  .shell {
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    border: 0;
    box-shadow: none;
  }

  .screen {
    padding: 18px 14px 22px;
  }

  .screen h1 {
    font-size: 24px;
  }

  .calendar-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .slot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
