: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;
  --success: #2d7a54;
  --danger-ink: #93334b;
  --disabled: #e7ecea;
  --shadow: 0 24px 60px rgba(62, 45, 114, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  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;
}

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

.shell {
  width: min(100%, 1440px);
  min-height: calc(100vh - 48px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid rgba(23, 33, 29, 0.08);
  box-shadow: var(--shadow);
}

.sidebar {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  min-height: calc(100vh - 48px);
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

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

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

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

.brand span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 700;
}

.nav,
.bottom-nav {
  display: grid;
  align-content: start;
  gap: 6px;
}

.nav.hidden,
.bottom-nav.hidden,
.sidebar-logout.hidden {
  display: none;
}

.nav-item {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

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

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

.screen {
  display: none;
  min-width: 0;
  overflow-y: auto;
  padding: 32px;
}

.screen.active {
  display: block;
}

#start-screen,
#signup-screen,
#login-screen,
#forgot-screen,
#confirm-screen {
  grid-column: 2;
}

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

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

.screen h3 {
  margin: 0;
  font-size: 16px;
}

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

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

.auth-page {
  min-height: 100%;
  display: grid;
  align-content: center;
  gap: 18px;
}

.start-panel,
.auth-card,
.notice,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.start-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 18px;
  padding: 18px;
  background: linear-gradient(145deg, var(--soft), #fff 72%);
}

.start-copy,
.start-actions,
.auth-card {
  display: grid;
  gap: 14px;
}

.start-logo,
.auth-logo {
  width: 62px;
  height: 62px;
  object-fit: contain;
}

.feature-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.45;
}

.auth-card {
  width: min(100%, 460px);
  padding: 18px;
  justify-self: center;
}

.wide-card {
  width: min(100%, 980px);
}

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

.form-grid,
.stats-grid,
.dashboard-grid,
.two-grid,
.appointment-grid,
.queue-grid {
  display: grid;
  gap: 12px;
}

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

.span-2 {
  grid-column: span 2;
}

.stats-grid {
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  margin-bottom: 12px;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
}

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

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

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

.stat-card,
.appointment-card,
.queue-card,
.day-card,
.timeoff-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 13px;
}

.stat-card {
  min-height: 86px;
  display: grid;
  align-content: space-between;
}

.stat-card strong {
  font-size: 25px;
  color: var(--primary-dark);
}

.panel {
  padding: 14px;
}

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

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

.row-start {
  align-items: flex-start;
}

.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: 750;
  white-space: nowrap;
}

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

.badge.confirmed,
.badge.checked_in,
.badge.in_consultation {
  background: #e7ecfb;
  color: #3d568d;
}

.badge.completed,
.badge.checked_out,
.badge.verified {
  background: #e5f4ec;
  color: var(--success);
}

.badge.cancelled,
.badge.no_show,
.badge.unverified {
  background: #f5e6ee;
  color: var(--danger-ink);
}

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

.button,
.ghost,
.danger,
.link-button,
.pill-tab,
.icon-button {
  border: 0;
  border-radius: 8px;
}

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

.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: var(--danger-ink);
}

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

.link-button {
  display: inline;
  width: fit-content;
  padding: 0;
  background: transparent;
  color: var(--primary-dark);
  font-weight: 750;
  text-align: left;
}

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

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

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

input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
}

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

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

.check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

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

.pill-tab {
  border: 1px solid var(--line);
  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);
}

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

.appointment-card .actions {
  padding-top: 2px;
}

.compact-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.compact-table th,
.compact-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.compact-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

.notice {
  padding: 12px 14px;
  background: #fff9ea;
  color: #72500d;
}

.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%, 430px);
  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(430px, calc(100vw - 32px));
}

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

.rtl .sidebar {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.rtl .nav-item,
.rtl .page-head,
.rtl .compact-table th,
.rtl .compact-table td {
  text-align: right;
}

.rtl .row,
.rtl .page-head,
.rtl .brand,
.rtl .actions,
.rtl .modal-actions {
  direction: rtl;
}

.rtl .field label,
.rtl .check-field,
.rtl input,
.rtl select,
.rtl textarea {
  text-align: right;
}

@media (max-width: 1060px) {
  body {
    padding: 0;
  }

  .shell {
    min-height: 100vh;
    grid-template-columns: 86px minmax(0, 1fr);
    box-shadow: none;
  }

  .sidebar {
    min-height: 100vh;
  }

  .brand {
    justify-content: center;
  }

  .brand div,
  .nav .nav-item span,
  .sidebar-logout {
    display: none;
  }

  .nav-item {
    justify-content: center;
    padding: 10px;
  }

  .screen {
    padding: 24px;
  }

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

  .dashboard-grid,
  .start-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .shell {
    grid-template-columns: 1fr;
    padding-bottom: 74px;
  }

  .sidebar {
    display: none;
  }

  .screen,
  #start-screen,
  #signup-screen,
  #login-screen,
  #forgot-screen,
  #confirm-screen {
    grid-column: 1;
    padding: 20px 16px;
  }

  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 6;
    grid-template-columns: repeat(5, 1fr);
    gap: 0;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.98);
  }

  .bottom-nav .nav-item {
    min-height: 54px;
    display: grid;
    place-items: center;
    gap: 2px;
    padding: 6px;
  }

  .bottom-nav .nav-item span {
    font-size: 11px;
  }

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

  .page-head,
  .row {
    align-items: flex-start;
  }

  .page-head {
    flex-direction: column;
  }

  .form-grid,
  .stats-grid,
  .two-grid,
  .appointment-grid,
  .queue-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }

  .compact-table,
  .compact-table thead,
  .compact-table tbody,
  .compact-table tr,
  .compact-table th,
  .compact-table td {
    display: block;
  }

  .compact-table thead {
    display: none;
  }

  .compact-table tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
  }

  .compact-table td {
    border: 0;
    padding: 5px 0;
  }
}
