:root {
  --pink: #d6457a;
  --pink-dark: #b8325f;
  --pink-soft: #fdf1f5;
  --pink-line: #f6d5e1;

  --outer-bg: #f3f3f6;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-alt: #f8f8fa;
  --surface-hover: #fcfcfd;
  --header-bg: rgba(255, 255, 255, 0.94);
  --nav-bg: rgba(255, 255, 255, 0.97);
  --line: #ececf0;
  --text: #1c1c22;
  --text-2: #5c5c68;
  --text-3: #9a9aa6;

  --green: #2f9e6b;
  --green-soft: #eaf7f0;
  --red: #d14343;
  --red-soft: #fcefef;
  --amber: #b7791f;
  --amber-soft: #fdf6e7;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.04), 0 4px 16px rgba(20, 20, 30, 0.05);
  --nav-h: 64px;
}

[data-theme="dark"] {
  --pink: #e55b8d;
  --pink-dark: #f073a0;
  --pink-soft: rgba(229, 91, 141, 0.16);
  --pink-line: rgba(229, 91, 141, 0.35);

  --outer-bg: #0b0b0f;
  --bg: #121218;
  --surface: #1a1a22;
  --surface-alt: #22222c;
  --surface-hover: #1f1f29;
  --header-bg: rgba(18, 18, 24, 0.94);
  --nav-bg: rgba(18, 18, 24, 0.97);
  --line: #2a2a36;
  --text: #f3f3f7;
  --text-2: #b0b0be;
  --text-3: #78788a;

  --green: #4ade80;
  --green-soft: rgba(74, 222, 128, 0.14);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.14);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.14);

  --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background: var(--outer-bg);
  height: 100%;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

button { font-family: inherit; cursor: pointer; touch-action: manipulation; }
input, select, textarea {
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
  -webkit-user-select: text;
  user-select: text;
}
.hidden { display: none !important; }

/* Ícones */
[data-icon] { display: inline-flex; width: 20px; height: 20px; flex-shrink: 0; }
[data-icon] svg { width: 100%; height: 100%; }

/* Tela de Autenticação */
.auth-shell {
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  background: var(--outer-bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 22px;
}

.brand-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  border: 1.5px solid var(--pink);
  color: var(--pink);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; letter-spacing: 0.04em;
}
.brand-mark.lg {
  width: 52px; height: 52px;
  border-radius: 14px;
  font-size: 18px;
  margin-bottom: 10px;
}

.auth-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.auth-subtitle { font-size: 13px; color: var(--text-3); margin-top: 2px; }

.form-error {
  font-size: 13px;
  color: var(--red);
  background: var(--red-soft);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
}

.auth-demo {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.auth-demo-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 10px;
}
.auth-demo-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.demo-account-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  text-align: left;
  transition: border-color 0.15s;
}
.demo-account-btn:hover { border-color: var(--pink); }
.demo-account-sub { font-size: 12px; color: var(--text-3); }

/* Estrutura do app (largura de celular, travado como app nativo) */
.app {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.app-header {
  flex-shrink: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 20px 14px;
  background: var(--header-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--text-3); }

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 2px 0;
}
.header-user-text { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.header-user-name { font-size: 13px; font-weight: 600; }
.header-user-role { font-size: 11px; color: var(--text-3); }

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--pink-soft);
  color: var(--pink-dark);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.xl { width: 84px; height: 84px; font-size: 26px; }

.app-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding: 20px 20px calc(var(--nav-h) + env(safe-area-inset-bottom) + 84px);
}

/* Cabeçalho de página */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.eyebrow { font-size: 13px; color: var(--text-3); text-transform: capitalize; margin-bottom: 2px; }
.page-title { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 26px 0 12px;
}
.section-title { font-size: 16px; font-weight: 600; }
.section-meta { font-size: 13px; color: var(--text-3); }
.section-help { font-size: 13px; color: var(--text-2); margin: -6px 0 12px; }

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn [data-icon] { width: 18px; height: 18px; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-xs { padding: 5px 11px; font-size: 12px; }
.btn-block { width: 100%; padding: 13px; }
.btn-primary { background: var(--pink); color: #fff; }
.btn-primary:hover { background: var(--pink-dark); }
.btn-outline { background: var(--surface); border-color: var(--line); color: var(--text); }
.btn-outline:hover { border-color: var(--pink-line); color: var(--pink-dark); }
.btn-outline [data-icon] { color: var(--pink); }
.btn-ghost { background: transparent; color: var(--pink-dark); }
.btn-ghost:hover { background: var(--pink-soft); }
.btn-danger-text { background: transparent; color: var(--red); padding-left: 4px; padding-right: 4px; }

.icon-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--surface-alt); }

/* Chips de filtro por profissional */
.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
  scrollbar-width: none;
}
.chip-row:empty { display: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
.chip:hover { border-color: var(--pink-line); }
.chip.active { border-color: var(--pink); color: var(--pink-dark); background: var(--pink-soft); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* Resumo rápido */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.stat {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.stat-value { font-size: 20px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* Próximo atendimento */
.next-card {
  border: 1px solid var(--line);
  border-left: 3px solid var(--pink);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.next-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--pink);
  margin-bottom: 10px;
}
.next-main { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.next-time { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.next-when { font-size: 13px; color: var(--text-3); margin-top: 4px; }
.next-client { font-size: 16px; font-weight: 600; margin-top: 12px; }
.next-proc { font-size: 14px; color: var(--text-2); margin-top: 2px; }
.next-meta { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--text-2); }
.next-actions { display: flex; gap: 8px; margin-top: 16px; }
.next-actions .btn { flex: 1; }
.next-price { font-size: 15px; font-weight: 600; }

/* Grupos por dia */
.day-groups { display: flex; flex-direction: column; gap: 22px; }
.day-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}
.day-group-title { font-size: 13px; font-weight: 600; color: var(--text); }
.day-group-title .muted { color: var(--text-3); font-weight: 500; margin-left: 6px; text-transform: capitalize; }
.day-group-meta { font-size: 12px; color: var(--text-3); }

.list { display: flex; flex-direction: column; }
.list-card { overflow: hidden; }

/* Linha de agendamento */
.apt {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  width: 100%;
  text-align: left;
  border-left: none; border-right: none; border-top: none;
}
.apt:last-child { border-bottom: none; }
.apt:hover { background: var(--surface-hover); }
.apt-time {
  width: 52px;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--pink-dark);
}
.apt-time.muted { color: var(--text-3); }
.apt-body { flex: 1; min-width: 0; }
.apt-client { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.apt-sub { font-size: 13px; color: var(--text-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.apt-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.apt-price { font-size: 14px; font-weight: 600; }

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}
.badge-done { background: var(--green-soft); color: var(--green); }
.badge-cancel { background: var(--red-soft); color: var(--red); }
.badge-pending { background: var(--amber-soft); color: var(--amber); }
.badge-pink { background: var(--pink-soft); color: var(--pink-dark); }

/* Calendário */
.calendar { padding: 14px; }
.calendar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.calendar-month { font-weight: 600; text-transform: capitalize; }
.calendar-weekdays, .calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
}
.calendar-weekdays span { font-size: 11px; color: var(--text-3); font-weight: 500; padding: 6px 0; }
.cal-day {
  position: relative;
  aspect-ratio: 1;
  max-height: 52px;
  border: none;
  background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 14px;
  color: var(--text);
  border-radius: 50%;
  margin: 2px auto;
  width: 100%;
  max-width: 44px;
}
.cal-day:hover { background: var(--surface-alt); }
.cal-day.outside { visibility: hidden; }
.cal-day.today { color: var(--pink-dark); font-weight: 700; }
.cal-day.selected { background: var(--pink); color: #fff; font-weight: 600; }
.cal-dot {
  position: absolute;
  bottom: 6px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--pink);
}
.cal-day.selected .cal-dot { background: #fff; }

/* Busca */
.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 0 14px;
  margin-bottom: 14px;
  color: var(--text-3);
}
.search-field input { flex: 1; border: none; outline: none; padding: 11px 0; background: transparent; }

/* Painel */
.segmented {
  display: flex;
  background: var(--surface-alt);
  border-radius: 999px;
  padding: 3px;
  margin-bottom: 16px;
}
.segmented button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 0;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
.segmented button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
}
.kpi.wide { grid-column: span 2; }
.kpi-label { font-size: 12px; color: var(--text-3); }
.kpi-value { font-size: 22px; font-weight: 700; margin-top: 4px; letter-spacing: -0.01em; }
.kpi.wide .kpi-value { font-size: 28px; color: var(--pink-dark); }
.kpi-sub { font-size: 12px; color: var(--text-2); margin-top: 4px; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  width: 100%;
  text-align: left;
  border-left: none; border-right: none; border-top: none;
}
.row:last-child { border-bottom: none; }
.row-clickable:hover { background: var(--surface-hover); }
.row-icon { color: var(--text-2); }
.row-chevron { color: var(--text-3); }
.row-body { flex: 1; min-width: 0; }
.row-title { font-size: 14px; font-weight: 600; }
.row-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; word-break: break-word; }
.row-value { font-size: 14px; font-weight: 600; text-align: right; }
.bar { height: 4px; background: var(--surface-alt); border-radius: 999px; margin-top: 8px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--pink); border-radius: 999px; }
.tag { font-size: 11px; color: var(--text-3); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }

/* Switch Tema Escuro */
.switch { position: relative; display: inline-flex; width: 44px; height: 26px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute; inset: 0;
  background: var(--line);
  border-radius: 999px;
  transition: background 0.2s;
}
.switch-track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch input:checked + .switch-track { background: var(--pink); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }

/* Tela de Perfil */
.profile-photo-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px 16px;
  margin-bottom: 14px;
}
.profile-photo-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.profile-form {
  padding: 18px;
}
.profile-footer, .settings-footer {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* Formulários inline (Ajustes) */
.inline-form { display: flex; gap: 8px; padding: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.inline-form input {
  flex: 1; min-width: 110px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  outline: none;
}
.inline-form input:focus { border-color: var(--pink); }

/* Estado vazio */
.empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-3);
  font-size: 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty strong { display: block; color: var(--text); font-weight: 600; margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

.link-btn {
  background: none; border: none;
  color: var(--pink-dark);
  font-size: 13px; font-weight: 500;
  padding: 10px 0;
}

/* Botão flutuante */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 18px);
  left: 50%;
  transform: translateX(calc(240px - 100% - 20px));
  width: 54px; height: 54px;
  border-radius: 50%;
  border: none;
  background: var(--pink);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(214, 69, 122, 0.35);
  z-index: 30;
}
.fab [data-icon] { width: 24px; height: 24px; }
.fab:hover { background: var(--pink-dark); }
@media (max-width: 480px) {
  .app { border-left: none; border-right: none; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 28px); }
  .fab { left: auto; right: 18px; transform: none; }
}

/* Navegação inferior */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  min-height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  background: var(--nav-bg);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: 8px 4px calc(10px + env(safe-area-inset-bottom));
  z-index: 25;
}
.bottom-nav button {
  flex: 1;
  border: none;
  background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  padding: 2px 0;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
}
.bottom-nav button [data-icon] { width: 22px; height: 22px; }
.bottom-nav button.active { color: var(--pink); }

/* Folha (bottom sheet) */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 10, 18, 0.5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 50;
}
.sheet {
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  padding: 8px 20px 24px;
  animation: sheet-up 0.22s ease-out;
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head h3 { font-size: 18px; font-weight: 700; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.field > span { font-size: 12px; font-weight: 500; color: var(--text-2); }
.field input, .field select {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  width: 100%;
}
.field input:disabled { opacity: 0.65; cursor: not-allowed; }
.field input:focus, .field select:focus { border-color: var(--pink); box-shadow: 0 0 0 3px var(--pink-soft); }
.field-row { display: flex; gap: 10px; }
.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 4px; }

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 86px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 999px;
  z-index: 60;
}
