:root{
  --paper: #151210;
  --paper-raised: #1E1A16;
  --ink: #F1ECE3;
  --muted: #8F8577;
  --line: #332C24;
  --gold: #D6A64B;
  --gold-ink: #E8C57A;
  --gold-tint: #2E2415;
  --on-gold: #241B0E;
  --accent: #C97B3D;
  --accent-tint: #2E1F12;
  --danger: #E2695A;
  --danger-tint: #2E1512;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 8px 24px -12px rgba(0,0,0,.55);
}

*{ box-sizing: border-box; }
html,body{ height: 100%; }
body{
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3{ font-family: "Fraunces", ui-serif, Georgia, serif; margin: 0; text-wrap: balance; }
button{ font-family: inherit; }
input, select, textarea{ font-family: inherit; }
:focus-visible{ outline: 2px solid var(--gold); outline-offset: 2px; }

.app{
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  position: relative;
}

/* ---------- Top bar ---------- */
.topbar{
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar .brand{ display:flex; align-items:baseline; gap:8px; }
.topbar h1{ font-size: 1.3rem; font-weight: 600; color: var(--gold-ink); }
.topbar .tagline{ font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.topo{ display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.topo-texto{ min-width: 0; }
.topo-lado{ display: flex; flex-direction: column; align-items: center; gap: 5px; flex: none; }
.relogio{ width: 56px; height: 56px; padding: 0; border: none; background: none; border-radius: 50%; cursor: pointer; }
.relogio svg{ display: block; width: 100%; height: 100%; }
.relogio .disco{ fill: var(--gold); }
.relogio .ponteiro{ stroke: var(--on-gold); stroke-linecap: round; }
.relogio .segundos{ stroke: var(--accent); stroke-linecap: round; }
.relogio .centro{ fill: var(--accent); }
.link-sair{ padding: 0; border: none; background: none; color: var(--muted); font-size: 12.5px; line-height: 1; text-decoration: underline; cursor: pointer; }
@media (prefers-reduced-motion: reduce){
  .relogio .segundos{ display: none; }
}

.tabs{ display:flex; gap: 6px; margin-top: 14px; }
.tab-btn{
  flex: 1;
  padding: 9px 6px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper-raised);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.tab-btn.active{ background: var(--gold); border-color: var(--gold); color: var(--on-gold); }

/* ---------- Views ---------- */
.view{ display: none; flex: 1; flex-direction: column; padding: 18px 20px 100px; gap: 18px; }
.view.active{ display: flex; }
.hint{ margin: 0; font-size: 13px; color: var(--muted); }

/* ---------- Date nav (navegação de mês no relatório) ---------- */
.date-nav{
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 8px;
  box-shadow: var(--shadow);
}
.date-nav button{
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--gold-ink);
  font-size: 16px;
  cursor: pointer;
}
.date-nav button:disabled{ opacity: .35; cursor: not-allowed; }
.date-nav .date-label{ text-align: center; }
.date-nav .date-label .dow{ font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-family: "IBM Plex Mono", monospace; }
.date-nav .date-label .dm{ font-size: 15px; font-weight: 600; }

/* ---------- Date carousel (seletor de dia, agenda) ---------- */
.date-carousel{
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  padding: 2px 2px 6px;
  -webkit-overflow-scrolling: touch;
}
.date-carousel::-webkit-scrollbar{ display: none; }
.date-card{
  flex: 0 0 auto;
  scroll-snap-align: start;
  width: 58px;
  padding: 10px 4px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--paper-raised);
  color: var(--ink);
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.date-card .dow{ font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-family: "IBM Plex Mono", monospace; }
.date-card .dia{ font-size: 17px; font-weight: 700; }
.date-card .mes{ font-size: 9.5px; color: var(--muted); text-transform: uppercase; }
.date-card.hoje:not(.selecionado){ border-color: var(--gold); }
.date-card.selecionado{ background: var(--gold); border-color: var(--gold); color: var(--on-gold); }
.date-card.selecionado .dow, .date-card.selecionado .mes{ color: var(--on-gold); opacity: .8; }

/* ---------- Slot grid ---------- */
.legend{ display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend span{ display: inline-flex; align-items: center; gap: 6px; }
.legend i{ width: 10px; height: 10px; border-radius: 3px; border: 1px solid var(--line); background: var(--paper-raised); }
.legend i.indisponivel{ background: var(--paper); opacity: .6; }

.slots-grid{ display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.slot{
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--paper-raised);
  padding: 8px 6px;
  min-height: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}
.slot .off{ font-size: 10.5px; font-weight: 600; color: var(--accent); }
.slot.livre .off{ color: var(--accent); }
.slot.ocupado, .slot.indisponivel{
  color: var(--muted);
  text-decoration: line-through;
  cursor: not-allowed;
}
.slot.selecionado{ background: var(--gold); border-color: var(--gold); color: var(--on-gold); }
.slot.selecionado .off{ color: var(--on-gold); }
.empty-msg{ text-align: center; color: var(--muted); font-size: 14px; padding: 30px 10px; }

/* ---------- Cart bar ---------- */
.cart-bar{
  position: sticky;
  bottom: 0;
  margin: 0 -20px 0;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
  background: var(--paper-raised);
  border-top: 1px solid var(--line);
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 -8px 20px -12px rgba(0,0,0,.5);
}
.cart-bar.show{ display: flex; }
.cart-bar .count{ font-size: 13.5px; color: var(--muted); }
.cart-bar .count b{ color: var(--ink); }
.btn{
  border: none;
  border-radius: 9px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-block;
}
.btn-primary{ background: var(--gold); color: var(--on-gold); }
.btn-primary:disabled{ background: var(--line); color: var(--muted); cursor: not-allowed; }
.btn-ghost{ background: transparent; color: var(--gold-ink); border: 1px solid var(--line); }
.btn-danger{ background: var(--danger); color: #fff; }
.btn-danger:disabled{ opacity: .5; cursor: not-allowed; }
.btn-block{ width: 100%; display: block; }

/* ---------- Sheet (bottom panel) ---------- */
.sheet-backdrop{
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .55);
  display: none;
  z-index: 20;
}
.sheet-backdrop.show{ display: block; }
.sheet{
  position: fixed;
  left: 50%; bottom: 0;
  transform: translateX(-50%);
  width: 100%; max-width: 480px;
  background: var(--paper-raised);
  border-radius: 16px 16px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
  z-index: 21;
  max-height: 88vh;
  overflow-y: auto;
}
.sheet h2{ font-size: 1.15rem; margin-bottom: 4px; }
.sheet .sub{ font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.field{ margin-bottom: 14px; }
.field label{ display:block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.field input[type="text"], .field input[type="tel"], .field input[type="number"], .field input[type="time"], .field input[type="password"]{
  width: 100%;
  padding: 11px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
}
.perfil-list{ display:flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.perfil-opt{
  display:flex; align-items:center; gap: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 12px;
  cursor: pointer;
  font-size: 14.5px;
}
.perfil-opt.selecionado{ border-color: var(--gold); background: var(--gold-tint); }
.perfil-opt input{ accent-color: var(--gold); }

.acesso-tabs{ display: flex; gap: 6px; margin-bottom: 16px; }
.acesso-tabs button{
  flex: 1;
  padding: 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}
.acesso-tabs button.active{ border-color: var(--gold); background: var(--gold-tint); color: var(--gold-ink); font-weight: 600; }

/* ---------- Review ---------- */
.review-item{
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--paper-raised);
}
.review-item.conflito{ border-color: var(--danger); background: var(--danger-tint); }
.review-item .linha1{ display:flex; justify-content: space-between; font-size: 14.5px; font-weight: 600; }
.review-item .data-hora{ font-family: "IBM Plex Mono", monospace; font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.link-remover{ margin-top: 8px; border: none; background: transparent; color: var(--danger); font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 0; }
.aviso{
  margin-top: 8px;
  font-size: 12.5px;
  background: var(--accent-tint);
  color: var(--ink);
  border-radius: 7px;
  padding: 7px 10px;
}
.erro-msg{
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--danger);
  font-weight: 600;
}

/* ---------- Toast ---------- */
.toast{
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--gold); color: var(--on-gold);
  padding: 11px 18px; border-radius: 9px; font-size: 13.5px;
  z-index: 30; opacity: 0; pointer-events: none; transition: opacity .2s ease;
  max-width: 90%; text-align: center;
}
.toast.show{ opacity: 1; }

/* ---------- Success ---------- */
.success-icon{
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--gold-tint); color: var(--gold-ink);
  display:flex; align-items:center; justify-content:center;
  font-size: 26px; margin: 0 auto;
}
.center{ text-align: center; }
.stack{ display: flex; flex-direction: column; gap: 10px; }

/* ---------- My bookings / profile ---------- */
.section-title{ font-family: "IBM Plex Mono", monospace; font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: 6px 0 -4px; }
.booking-card{
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--paper-raised);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.booking-card .who{ font-size: 15px; font-weight: 600; }
.booking-card .when{ font-family: "IBM Plex Mono", monospace; font-size: 13px; color: var(--muted); }
.card-cta{ border: 1px dashed var(--line); border-radius: 12px; padding: 22px 18px; text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.card-cta p{ margin: 0; font-size: 14px; color: var(--muted); }
.perfil-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px;
  background: var(--paper-raised);
  font-size: 14.5px;
}
.perfil-row .tag{ font-family: "IBM Plex Mono", monospace; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-left: 8px; }
.icon-btn{ width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); color: var(--danger); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn svg{ width: 18px; height: 18px; }
.icon-btn.neutro{ color: var(--muted); }
.add-row{ display: flex; gap: 8px; }
.add-row input{ flex: 1; min-width: 0; padding: 11px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); font-size: 15px; }

.badge{
  display: inline-block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  width: fit-content;
}
.badge.pendente{ background: var(--accent-tint); color: var(--ink); border: 1px solid var(--accent); }
.badge.confirmado{ background: var(--gold-tint); color: var(--gold-ink); }
.badge.atendido{ background: var(--gold); color: var(--on-gold); }
.badge.cancelado, .badge.nao_compareceu{ background: var(--danger-tint); color: var(--danger); }

.hidden{ display: none !important; }

@media (prefers-reduced-motion: no-preference){
  .view.active{ animation: fadein .25s ease both; }
  @keyframes fadein{ from{ opacity: 0; transform: translateY(6px); } to{ opacity: 1; transform: none; } }
}
