:root {
  color-scheme: light;
  --purple: #8e44ad;
  --purple-dark: #763691;
  --purple-soft: #f5ebfb;
  --pink: #f2577f;
  --green: #45b767;
  --yellow: #f7b731;
  --gray: #8f969e;
  --ink: #26212a;
  --muted: #817989;
  --line: #ece5f0;
  --bg: #faf7fc;
  --card: #ffffff;
  --shadow: 0 16px 32px rgba(69, 40, 83, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.phone-shell {
  position: relative;
  width: min(100%, 430px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  box-shadow: 0 0 0 1px rgba(142, 68, 173, 0.08);
}

.phone-shell.is-auth .bottom-nav {
  display: none;
}

.phone-shell.is-auth .screens {
  padding-bottom: 22px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  min-height: 58px;
  padding: max(8px, env(safe-area-inset-top)) 10px 8px;
  background: var(--purple);
  color: #fff;
}

.topbar h1 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  text-align: center;
}

.topbar img {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
  background: #fff;
}

.topbar small {
  font-size: 0.62rem;
  font-weight: 900;
  opacity: 0.78;
}

.top-icon,
.ghost-button {
  border: 0;
  background: transparent;
}

.top-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  font-size: 1.55rem;
  line-height: 1;
}

.top-icon:disabled,
.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.screens {
  padding: 14px 14px 84px;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.date-row,
.summary-grid,
.timeline-row,
.split-fields,
.form-actions,
.client-row,
.bottom-nav,
.settings-group button {
  display: flex;
}

.date-row {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}

.date-row div {
  display: grid;
  gap: 2px;
  text-align: center;
}

.date-row strong {
  font-size: 0.96rem;
}

.date-row span,
.summary-grid span,
.client-row small,
.profile-card p,
.history-card span,
.settings-group p,
.settings-group span {
  color: var(--muted);
  font-size: 0.78rem;
}

.ghost-button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--purple);
  font-size: 1.35rem;
}

.summary-grid {
  gap: 10px;
  margin-bottom: 12px;
}

.agenda-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.agenda-filters button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.agenda-filters button.active {
  border-color: var(--purple);
  background: var(--purple-soft);
  color: var(--purple);
}

.summary-grid article {
  flex: 1;
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.summary-grid strong {
  display: block;
  margin-bottom: 4px;
  color: var(--purple-dark);
  font-size: 1.2rem;
}

.timeline {
  display: grid;
  gap: 8px;
}

.day-divider {
  margin: 12px 0 2px;
  color: var(--purple-dark);
  font-size: 0.86rem;
}

.timeline-row {
  align-items: stretch;
  gap: 10px;
}

.timeline-row time {
  flex: 0 0 50px;
  padding-top: 12px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.appointment-pill {
  position: relative;
  display: grid;
  flex: 1;
  min-height: 58px;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--gray);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  text-align: left;
}

.appointment-pill strong,
.appointment-pill span,
.appointment-pill em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  color: var(--purple);
  font-size: 0.72rem;
  font-weight: 900;
}

.pill-actions span {
  padding: 5px 7px;
  border-radius: 8px;
  background: var(--purple-soft);
}

.appointment-pill span {
  color: var(--muted);
  font-size: 0.76rem;
}

.appointment-pill em {
  position: absolute;
  top: 10px;
  right: 10px;
  color: var(--green);
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 800;
}

.appointment-pill.waiting {
  border-left-color: var(--yellow);
}

.appointment-pill.waiting em {
  color: #bd7b05;
}

.appointment-pill.confirmed {
  border-left-color: var(--green);
}

.appointment-pill.free {
  justify-content: center;
  border-style: dashed;
  color: var(--muted);
  text-align: center;
}

.appointment-pill.free::after {
  content: "Toque para agendar";
  color: var(--purple);
  font-size: 0.7rem;
  font-weight: 900;
}

.fab {
  position: fixed;
  right: max(20px, calc((100vw - 430px) / 2 + 20px));
  bottom: 90px;
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--purple);
  color: #fff;
  box-shadow: 0 16px 28px rgba(142, 68, 173, 0.34);
  font-size: 1.8rem;
}

.form-card,
.search-box,
.profile-card,
.history-card,
.settings-group {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.auth-card {
  margin-top: 18px;
}

.auth-card h2 {
  margin: 0;
  font-size: 1.25rem;
}

.auth-card p,
.auth-message {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.auth-message {
  min-height: 18px;
  color: var(--purple-dark);
  font-weight: 800;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

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

textarea {
  min-height: 78px;
  padding-top: 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(142, 68, 173, 0.14);
}

.split-fields,
.form-actions {
  gap: 10px;
}

.split-fields label,
.form-actions button {
  flex: 1;
  min-width: 0;
}

.primary-button,
.secondary-button,
.whatsapp-button,
.outline-button {
  display: grid;
  place-items: center;
  min-height: 48px;
  border-radius: 8px;
  font-weight: 850;
  text-decoration: none;
}

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

.secondary-button,
.outline-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--purple);
}

.whatsapp-button {
  border: 0;
  background: #36b36b;
  color: #fff;
}

.client-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.client-row {
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 70px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  text-align: left;
}

.client-row > span:nth-child(2) {
  display: grid;
  flex: 1;
  min-width: 0;
  gap: 3px;
}

.client-row strong,
.client-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  display: grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 900;
}

.avatar.large {
  width: 72px;
  height: 72px;
  margin: 4px auto 0;
  font-size: 1.1rem;
}

.chevron {
  color: var(--muted);
  font-size: 1.3rem;
}

.profile-card {
  margin-bottom: 12px;
  text-align: center;
}

.profile-card h2 {
  margin: 0;
  font-size: 1.15rem;
}

.history-card h3 {
  margin: 0;
  font-size: 0.95rem;
}

.history-card article {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  border-bottom: 1px solid var(--line);
}

.history-card article:last-child {
  border-bottom: 0;
}

.message-grid {
  display: grid;
  gap: 8px;
}

.message-grid a {
  display: grid;
  min-height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--purple-soft);
  color: var(--purple);
  font-size: 0.82rem;
  font-weight: 900;
  text-decoration: none;
}

.empty-state {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

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

.template-actions button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--purple-soft);
  color: var(--purple);
  font-size: 0.72rem;
  font-weight: 900;
}

.template-actions button[type="submit"] {
  background: var(--purple);
  color: #fff;
}

.settings-service-list {
  display: grid;
  gap: 10px;
  padding: 10px 0;
}

.service-editor {
  display: grid;
  grid-template-columns: 1fr 72px 62px;
  gap: 10px;
  align-items: end;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.service-editor input {
  min-height: 40px;
  padding: 0 9px;
  font-size: 0.82rem;
}

.service-editor label {
  min-width: 0;
}

.logo-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 54px;
  padding: 8px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

.logo-preview img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
}

.logo-preview button {
  border: 0;
  background: transparent;
  color: var(--purple);
  font-size: 0.78rem;
  font-weight: 900;
}

.settings-group {
  margin-bottom: 12px;
  gap: 0;
  padding: 0 14px;
  overflow: hidden;
}

.settings-group p {
  margin: 0;
  padding: 14px 0 8px;
  font-weight: 900;
  text-transform: uppercase;
}

.settings-group button {
  align-items: center;
  justify-content: space-between;
  min-height: 50px;
  gap: 12px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.settings-group button > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-group strong {
  font-size: 0.8rem;
  white-space: nowrap;
}

.cloud-status strong::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--gray);
}

.cloud-status.is-online strong {
  color: var(--green);
}

.cloud-status.is-online strong::before {
  background: var(--green);
}

.cloud-status.is-syncing strong,
.cloud-status.is-checking strong {
  color: var(--yellow);
}

.cloud-status.is-syncing strong::before,
.cloud-status.is-checking strong::before {
  background: var(--yellow);
}

.cloud-status.is-error strong {
  color: var(--pink);
}

.cloud-status.is-error strong::before {
  background: var(--pink);
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 12;
  width: min(100%, 430px);
  margin: 0 auto;
  align-items: center;
  justify-content: space-around;
  min-height: 66px;
  padding: 6px 8px max(6px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(18px);
}

.bottom-nav button {
  display: grid;
  min-width: 64px;
  place-items: center;
  gap: 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.bottom-nav span {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 8px;
  font-size: 0.74rem;
}

.bottom-nav button.active {
  color: var(--purple);
}

.bottom-nav button.active span {
  background: var(--purple-soft);
}

@media (min-width: 760px) {
  body {
    display: grid;
    place-items: start center;
    padding: 22px;
  }

  .phone-shell {
    min-height: calc(100vh - 44px);
    border-radius: 20px;
    overflow: hidden;
  }

  .topbar {
    position: relative;
  }

  .bottom-nav {
    position: sticky;
    border-radius: 0 0 20px 20px;
  }
}
