:root {
  --bg: #ffffff;
  --surface: #f4f4f3;
  --surface-2: #ebebea;
  --line: #dcdcda;
  --text: #1d2023;
  --muted: #62676c;
  --faint: #8b9095;
  --accent: #2c6b5f;
  --accent-ink: #ffffff;
  --accent-soft: #e3efec;
  --warn: #8a5a00;
  --warn-soft: #fbf1dc;
  --danger: #a33a2c;
  --danger-soft: #f8e6e3;
  --ok: #2c6b5f;
  --radius: 12px;
  --radius-sm: 8px;
  --gutter: 16px;
  --shadow: 0 1px 2px rgba(20, 22, 24, .06), 0 4px 16px rgba(20, 22, 24, .06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141618;
    --surface: #1d2023;
    --surface-2: #262a2e;
    --line: #33383d;
    --text: #eceeef;
    --muted: #a3a9ae;
    --faint: #7c8288;
    --accent: #6fb8a7;
    --accent-ink: #0f1a17;
    --accent-soft: #1f3330;
    --warn: #e5b45a;
    --warn-soft: #33291a;
    --danger: #f0907f;
    --danger-soft: #3a2420;
    --ok: #6fb8a7;
    --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100dvh;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* Estrutura */
.app { max-width: 1080px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 10px var(--gutter);
  display: flex; align-items: center; gap: 10px; min-height: 60px;
}
.back {
  width: 44px; height: 44px; flex: none; margin-left: -10px;
  border: 0; background: transparent; border-radius: 999px;
  display: grid; place-items: center;
}
.back:hover { background: var(--surface); }
.back[hidden] { display: none; }
.brand { min-width: 0; flex: 1; }
.brand-logo { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; flex: none; }
.brand-name { font-weight: 650; font-size: 1.02rem; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-step { color: var(--muted); font-size: .84rem; }
.tag {
  display: inline-block; font-size: .72rem; font-weight: 600; letter-spacing: .02em;
  padding: 2px 8px; border-radius: 999px; background: var(--warn-soft); color: var(--warn);
  vertical-align: 2px; margin-left: 6px;
}

.layout { flex: 1; display: grid; gap: 24px; padding: 20px var(--gutter) 0; align-content: start; }
.main { min-width: 0; }
.aside { display: none; }
@media (min-width: 1024px) {
  .layout { grid-template-columns: minmax(0, 1fr) 340px; gap: 40px; padding-top: 32px; }
  .aside { display: block; }
  .aside .summary { position: sticky; top: 92px; }
}

h1 { font-size: 1.45rem; line-height: 1.2; margin: 0 0 6px; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
.lead { color: var(--muted); margin: 0 0 18px; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }

/* Rodape de acoes */
.actions {
  position: sticky; bottom: 0; z-index: 4;
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  margin: 24px calc(-1 * var(--gutter)) 0;
  display: grid; gap: 8px;
}
.actions.inline { position: static; border-top: 0; padding-bottom: 24px; }
@media (min-width: 768px) {
  .actions { position: static; border-top: 0; margin: 28px 0 32px; padding: 0; display: flex; }
}

.btn {
  min-height: 48px; padding: 0 20px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--bg); font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; color: var(--text); width: 100%;
}
@media (min-width: 768px) { .btn { width: auto; } }
.btn:hover { background: var(--surface); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.link-btn { display: inline-flex; align-items: center; background: none; border: 0; color: var(--accent); font-weight: 600; padding: 10px 0; min-height: 44px; text-decoration: underline; text-underline-offset: 3px; }

/* Servicos */
.list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.service {
  width: 100%; text-align: left; border: 1px solid var(--line); background: var(--bg);
  border-radius: var(--radius); padding: 14px 16px; min-height: 64px;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
}
.service:hover { border-color: var(--faint); }
.service[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.service-name { font-weight: 600; }
.service-price { font-weight: 650; text-align: right; }
.service-meta { color: var(--muted); font-size: .88rem; grid-column: 1 / -1; }

/* Calendario */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-title { font-weight: 650; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg);
  display: grid; place-items: center;
}
.icon-btn[disabled] { opacity: .35; cursor: default; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.cal-dow { text-align: center; font-size: .75rem; color: var(--muted); padding: 4px 0; font-weight: 600; }
.day {
  min-height: 52px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: transparent; padding: 4px 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
}
.day .d { font-weight: 600; font-size: .98rem; line-height: 1.1; }
.day .s { font-size: .66rem; line-height: 1.1; color: var(--muted); white-space: nowrap; }
.day.disponivel, .day.poucas_vagas { border-color: var(--line); background: var(--bg); }
.day.disponivel:hover, .day.poucas_vagas:hover { border-color: var(--accent); }
.day.poucas_vagas .s { color: var(--warn); font-weight: 600; }
.day.lotado, .day.fechado, .day.encerrado, .day.fora_da_janela { color: var(--faint); cursor: default; }
.day.lotado .d { text-decoration: line-through; }
.day.fora_da_janela .s { display: none; }
.day.today .d { text-decoration: underline; text-underline-offset: 3px; }
.day[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.day[aria-pressed="true"] .s { color: var(--accent-ink); }
.day.empty { visibility: hidden; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 14px 0 0; padding: 0; list-style: none; font-size: .82rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.sw { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--line); background: var(--bg); }
.sw.few { border-color: var(--warn); }
.sw.off { background: var(--surface-2); border-color: transparent; }

/* Horarios */
.period { margin: 18px 0 8px; font-size: .82rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.slot {
  min-height: 52px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px;
}
.slot .t { font-weight: 650; font-variant-numeric: tabular-nums; }
.slot .n { font-size: .68rem; color: var(--muted); line-height: 1.1; }
.slot.disponivel:hover { border-color: var(--accent); }
.slot[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.slot.off { background: var(--surface); border-color: transparent; color: var(--faint); cursor: default; }
.slot.off .t { font-weight: 500; }
.slot.reservado .t { text-decoration: line-through; }
.slot.atual { border-style: dashed; color: var(--muted); cursor: default; }
.break { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .84rem; margin: 6px 0; }
.break::before, .break::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Formulario */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: .95rem; }
.field input, .field textarea {
  min-height: 50px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg); font-size: 16px; width: 100%;
}
.field textarea { min-height: 88px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.field .hint { color: var(--muted); font-size: .84rem; }
.field .err { color: var(--danger); font-size: .86rem; font-weight: 600; }
.field input[aria-invalid="true"] { border-color: var(--danger); }

/* Resumo */
.summary { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--surface); }
.summary h2 { font-size: .86rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 8px; }
.rows { margin: 0; display: grid; gap: 0; }
.rows > div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rows > div:last-child { border-bottom: 0; }
.rows dt { color: var(--muted); }
.rows dd { margin: 0; font-weight: 600; text-align: right; }
.rows dd.big { font-size: 1.1rem; }
.empty-sum { color: var(--muted); margin: 0; }

/* Avisos */
.notice { border-radius: var(--radius-sm); padding: 12px 14px; margin: 0 0 16px; font-size: .94rem; display: flex; gap: 10px; align-items: flex-start; }
.notice.info { background: var(--accent-soft); }
.notice.warn { background: var(--warn-soft); color: var(--text); }
.notice.error { background: var(--danger-soft); color: var(--text); }
.notice strong { display: block; }
.notice .ic { flex: none; margin-top: 2px; }

.state { text-align: center; padding: 40px 8px; color: var(--muted); }
.state h1 { color: var(--text); }
.spinner {
  width: 28px; height: 28px; border-radius: 50%; margin: 0 auto 12px;
  border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
.skeleton { background: var(--surface); border-radius: var(--radius-sm); min-height: 52px; }

.done-mark { width: 56px; height: 56px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin: 8px 0 14px; }
.linkbox { display: flex; gap: 8px; margin: 8px 0 4px; flex-wrap: wrap; }
.linkbox input { flex: 1 1 200px; min-width: 0; min-height: 48px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--bg); font-size: .9rem; color: var(--muted); }
.linkbox .btn { width: auto; flex: 0 0 auto; }
.btn-row { display: grid; gap: 8px; margin-top: 16px; }
@media (min-width: 480px) { .btn-row { grid-template-columns: 1fr 1fr; } }
.status-pill { display: inline-block; font-size: .8rem; font-weight: 650; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.status-pill.cancelado, .status-pill.nao_compareceu { background: var(--danger-soft); color: var(--danger); }
.status-pill.concluido { background: var(--surface-2); color: var(--muted); }

.footer { padding: 20px var(--gutter) 28px; color: var(--faint); font-size: .8rem; text-align: center; }
.footer a { color: inherit; display: inline-block; min-width: 44px; min-height: 44px; padding: 13px 6px; }

/* Dialogo */
dialog { border: 0; border-radius: var(--radius); padding: 0; max-width: min(440px, calc(100vw - 32px)); width: 100%; background: var(--bg); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(10, 12, 14, .45); }
.dlg { padding: 20px; }
.dlg h2 { font-size: 1.15rem; }
.dlg .btn-row { grid-template-columns: 1fr; }
@media (min-width: 480px) { .dlg .btn-row { grid-template-columns: 1fr 1fr; } }

/* Vários serviços */
.service.multi { grid-template-columns: auto 1fr auto; }
.service.multi .service-meta { grid-column: 2 / -1; }
.service .check {
  grid-row: 1 / span 2; width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line);
  display: grid; place-items: center; color: transparent;
}
.service .check svg { width: 16px; height: 16px; }
.service[aria-pressed="true"] .check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* Informações da barbearia */
.tagline { color: var(--muted); margin: 0 0 10px; font-size: .95rem; }
.shop-info { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.shop-info p { margin: 0 0 6px; }
.shop-links { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.shop-links a { color: var(--accent); font-weight: 600; text-underline-offset: 3px; display: inline-flex; align-items: center; min-height: 44px; }

/* Vagas ao vivo */
.live { display: flex; align-items: center; gap: 8px; margin: -8px 0 12px; }
.live[hidden] { display: none; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .live .dot { animation: none; } }

/* Dia lotado e lista de espera */
.full-day { margin-top: 18px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.full-day h2 { margin-bottom: 4px; }
.full-day h3 { font-size: 1rem; margin: 22px 0 4px; }
.full-day .btn { margin-top: 8px; }
.btn.full { width: 100%; }
.btn.wa { border-color: #25d366; color: var(--text); }
.periods { border: 0; padding: 0; margin: 10px 0 14px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.periods label { position: relative; display: block; }
.periods input { position: absolute; opacity: 0; inset: 0; }
.periods span { display: grid; place-items: center; min-height: 48px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: .85rem; font-weight: 600; background: var(--bg); text-align: center; padding: 0 4px; }
.periods input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.periods input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Tema azul-marinho e dourado (Júnior Barbearia) */
:root[data-theme="marinho"] {
  --bg: #0b1828;
  --surface: #11233a;
  --surface-2: #17304d;
  --line: #22406a;
  --text: #eef2f7;
  --muted: #9fb0c4;
  --faint: #6f84a0;
  --accent: #d0a64c;
  --accent-ink: #1a1408;
  --accent-soft: #2a2c24;
  --warn: #e8b85a;
  --warn-soft: #2e2817;
  --danger: #f09484;
  --danger-soft: #3a2224;
  --ok: #5fc796;
  --shadow: none;
  color-scheme: dark;
}
:root[data-theme="marinho"] .brand-name { font-family: "Cinzel", Georgia, "Times New Roman", serif; letter-spacing: .06em; text-transform: uppercase; color: #dbe4ee; }
:root[data-theme="marinho"] h1 { font-family: Georgia, "Times New Roman", serif; font-weight: 600; letter-spacing: .01em; }
:root[data-theme="marinho"] .service[aria-pressed="true"] { background: #1a2c3a; }
:root[data-theme="marinho"] .full-day { background: #0f2034; }
:root[data-theme="marinho"] .slot.disponivel,
:root[data-theme="marinho"] .day.disponivel,
:root[data-theme="marinho"] .day.poucas_vagas { background: #17304f; border-color: #2c4f7a; }
:root[data-theme="marinho"] .slot.off { background: #0e1c2e; color: #5b7090; }
:root[data-theme="marinho"] .slot[aria-pressed="true"],
:root[data-theme="marinho"] .day[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
