:root{
  --paper: #F4F6F3;
  --paper-raised: #FFFFFF;
  --ink: #17231F;
  --muted: #5C6B65;
  --line: #DCE2DD;
  --teal: #1F5C52;
  --teal-ink: #163F39;
  --teal-tint: #E6EFEC;
  --amber: #B5772E;
  --amber-tint: #F6EBDB;
  --danger: #B3402F;
  --danger-tint: #FBEAE6;
  --shadow: 0 1px 2px rgba(23,35,31,.06), 0 8px 24px -12px rgba(23,35,31,.16);
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --paper: #101A17;
    --paper-raised: #16221E;
    --ink: #E7EEEA;
    --muted: #92A39C;
    --line: #26352F;
    --teal: #5FBFAC;
    --teal-ink: #BEE8DC;
    --teal-tint: #17302C;
    --amber: #E3A75E;
    --amber-tint: #2E2415;
    --danger: #E38578;
    --danger-tint: #331C18;
    --shadow: 0 1px 2px rgba(0,0,0,.35), 0 8px 24px -12px rgba(0,0,0,.55);
  }
}
:root[data-theme="dark"]{
  --paper: #101A17;
  --paper-raised: #16221E;
  --ink: #E7EEEA;
  --muted: #92A39C;
  --line: #26352F;
  --teal: #5FBFAC;
  --teal-ink: #BEE8DC;
  --teal-tint: #17302C;
  --amber: #E3A75E;
  --amber-tint: #2E2415;
  --danger: #E38578;
  --danger-tint: #331C18;
  --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{ font-family: inherit; }

.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(--teal-ink); }
.topbar .tagline{ font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.tabs{ display:flex; gap: 6px; margin-top: 14px; }
.tab-btn{
  flex: 1;
  padding: 9px 10px;
  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(--teal); border-color: var(--teal); color: #fff; }

/* ---------- Views ---------- */
.view{ display: none; flex: 1; flex-direction: column; padding: 18px 20px 100px; gap: 18px; }
.view.active{ display: flex; }

/* ---------- Date nav ---------- */
.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(--teal-ink);
  font-size: 16px;
  cursor: pointer;
}
.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; }

/* ---------- Slot grid ---------- */
.periodo-label{
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 4px 0 -6px;
}
.slots-grid{ display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.slot{
  position: relative;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--paper-raised);
  padding: 10px 6px;
  text-align: center;
  font-family: "IBM Plex Mono", monospace;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}
.slot:disabled{ color: var(--muted); background: var(--paper); cursor: not-allowed; opacity: .6; }
.slot.selecionado{ background: var(--teal); border-color: var(--teal); color: #fff; }
.slot.promo{ border-color: var(--amber); }
.slot.promo::after{
  content: "%";
  position: absolute; top: -6px; right: -6px;
  width: 18px; height: 18px;
  background: var(--amber); color: #fff;
  border-radius: 50%;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.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,.2);
}
.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;
}
.btn-primary{ background: var(--teal); color: #fff; }
.btn-primary:disabled{ background: var(--line); color: var(--muted); cursor: not-allowed; }
.btn-ghost{ background: transparent; color: var(--teal-ink); border: 1px solid var(--line); }
.btn-danger{ background: var(--danger); color: #fff; }
.btn-block{ width: 100%; }

/* ---------- Sheet (bottom panel) ---------- */
.sheet-backdrop{
  position: fixed; inset: 0;
  background: rgba(10, 16, 14, .45);
  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: 85vh;
  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(--teal); background: var(--teal-tint); }
.perfil-opt input{ accent-color: var(--teal); }

/* ---------- Cart list ---------- */
.cart-item{
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--paper-raised);
}
.cart-item .info b{ font-size: 14.5px; }
.cart-item .info div{ font-size: 12.5px; color: var(--muted); margin-top: 2px; font-family: "IBM Plex Mono", monospace; }
.cart-item button{
  border: none; background: transparent; color: var(--danger);
  font-size: 13px; font-weight: 600; cursor: pointer;
}

/* ---------- 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; }
.aviso{
  margin-top: 8px;
  font-size: 12.5px;
  background: var(--amber-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(--ink); color: var(--paper);
  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(--teal-tint); color: var(--teal-ink);
  display:flex; align-items:center; justify-content:center;
  font-size: 26px; margin: 0 auto;
}
.center{ text-align: center; }

/* ---------- My bookings ---------- */
.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); }
.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.confirmado{ background: var(--teal-tint); color: var(--teal-ink); }
.badge.atendido{ background: var(--teal); color: #fff; }
.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; } }
}
