/* AtendeZap — painel da barbearia */
:root {
  --bg: #f6f4f0;
  --card: #ffffff;
  --soft: #efece6;
  --ink: #1b1915;
  --muted: #6f6a61;
  --line: #e4dfd6;
  --brand: #16130f;          /* carvão */
  --brand-ink: #f6efe2;
  --gold: #b07d1e;           /* latão */
  --gold-soft: #f5ead2;
  --ok: #1d7a4a; --ok-soft: #e1f3e8;
  --bad: #b8382c; --bad-soft: #fbe9e6;
  --info: #2f5fa8; --info-soft: #e5edf9;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(22,19,15,.05), 0 4px 16px rgba(22,19,15,.05);
  --side: 248px;
  --tab: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11100e; --card: #1a1815; --soft: #24211d; --ink: #f1ece3; --muted: #a39d92; --line: #2e2a25;
    --brand: #0b0a08; --brand-ink: #f1ece3; --gold: #d9a441; --gold-soft: #2d2415;
    --ok: #5fcf8f; --ok-soft: #14271c; --bad: #ff8e80; --bad-soft: #2e1916; --info: #8db4f5; --info-soft: #18233a;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15.5px/1.45 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
a { color: var(--gold); }
h1, h2, h3 { letter-spacing: -.015em; margin: 0; }
svg.i { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- botões e campos ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
       min-height: 42px; padding: 0 16px; border-radius: 11px; font-weight: 600; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { background: var(--soft); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { background: #2a251e; }
@media (prefers-color-scheme: dark) { .btn.primary { background: var(--gold); color: #1a1205; border-color: var(--gold); } .btn.primary:hover { background: #e6b459; } }
.btn.gold { background: var(--gold); color: #fff; border-color: var(--gold); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn.ghost:hover { background: var(--soft); color: var(--ink); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 9px; }
.btn.icon { padding: 0; width: 42px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }

label.f { display: block; margin-bottom: 14px; }
label.f > span { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; }
label.f > small, .hint { display: block; color: var(--muted); font-size: 13px; margin-top: 5px; }
.inp { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--card); outline: none; transition: border-color .15s, box-shadow .15s; }
.inp:focus { border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 22%, transparent); }
textarea.inp { min-height: 120px; resize: vertical; line-height: 1.5; }
textarea.inp.big { min-height: 340px; font-size: 14.5px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 14px; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.switch:last-child { border-bottom: 0; }
.switch b { display: block; font-weight: 600; }
.switch small { color: var(--muted); font-size: 13.5px; }
.switch input { appearance: none; width: 46px; height: 28px; border-radius: 999px; background: var(--line); position: relative; flex: none; cursor: pointer; transition: background .2s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { transform: translateX(18px); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 13px; font-size: 14px; font-weight: 600; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
@media (prefers-color-scheme: dark) { .chip[aria-pressed="true"] { background: var(--gold); color: #1a1205; border-color: var(--gold); } }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.gold { background: var(--gold-soft); color: var(--gold); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.card h2 { font-size: 17px; margin-bottom: 4px; }
.card > p.sub { color: var(--muted); margin: 0 0 16px; font-size: 14px; }
.note { background: var(--gold-soft); color: var(--ink); border-radius: 12px; padding: 12px 14px; font-size: 14px; margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; }
.note svg { color: var(--gold); margin-top: 1px; }
.note.bad { background: var(--bad-soft); }
.note.bad svg { color: var(--bad); }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

/* ---------- login ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
         background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--gold) 18%, transparent), transparent 60%), var(--bg); }
.login .box { width: 100%; max-width: 380px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { width: 44px; height: 44px; border-radius: 12px; background: var(--brand); display: grid; place-items: center; color: #d9a441; flex: none; }
.brand .logo svg { width: 26px; height: 26px; }
.brand b { font-size: 20px; letter-spacing: -.02em; display: block; line-height: 1.1; }
.brand small { color: var(--muted); font-size: 13px; }
.login .card { padding: 26px; margin-top: 22px; }
.login h1 { font-size: 22px; margin-bottom: 4px; }
.login p.sub { color: var(--muted); margin: 0 0 20px; font-size: 14.5px; }
.err { color: var(--bad); font-size: 14px; margin: -4px 0 12px; min-height: 1px; }

/* ---------- estrutura ---------- */
.shell { min-height: 100vh; min-height: 100dvh; }
.side { display: none; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 12px;
          padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar .brand .logo { width: 34px; height: 34px; border-radius: 10px; }
.topbar .brand .logo svg { width: 20px; height: 20px; }
.topbar .brand b { font-size: 16px; }
.main { padding: 18px 16px calc(var(--tab) + 28px + env(safe-area-inset-bottom)); max-width: 1120px; margin: 0 auto; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
        background: color-mix(in srgb, var(--card) 94%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--line);
        padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px; border-radius: 12px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600; }
.tabs a svg { width: 23px; height: 23px; }
.tabs a[aria-current="page"] { color: var(--ink); }
.tabs a[aria-current="page"] svg { color: var(--gold); }

.page-h { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-h h1 { font-size: 24px; }
.page-h p { margin: 2px 0 0; color: var(--muted); font-size: 14.5px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.back:hover { color: var(--ink); }

.subtabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 18px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.subtabs::-webkit-scrollbar { display: none; }
.subtabs a { flex: none; padding: 10px 12px 12px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14.5px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subtabs a[aria-current="page"] { color: var(--ink); border-color: var(--gold); }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: var(--side) 1fr; }
  .topbar, .tabs { display: none; }
  .side { display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 22px 14px; background: var(--brand); color: var(--brand-ink); }
  .side .brand { padding: 0 8px 22px; }
  .side .brand .logo { background: #262019; }
  .side .brand small { color: #a79d8c; }
  .side nav { display: flex; flex-direction: column; gap: 2px; }
  .side nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; color: #c9bfae; text-decoration: none; font-weight: 600; }
  .side nav a:hover { background: #221d17; color: #fff; }
  .side nav a[aria-current="page"] { background: #2a231b; color: #fff; }
  .side nav a[aria-current="page"] svg { color: #d9a441; }
  .side .nav-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: #8a8070; padding: 16px 12px 6px; font-weight: 700; }
  .side .me { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid #2a241d; display: flex; align-items: center; gap: 10px; }
  .side .me .who { flex: 1; min-width: 0; }
  .side .me b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .side .me small { color: #a79d8c; font-size: 12.5px; }
  .side .me .btn { color: #c9bfae; }
  .side .me .btn:hover { background: #221d17; color: #fff; }
  .main { padding: 32px 36px 48px; }
  .page-h h1 { font-size: 28px; }
  .subtabs { margin: 0 0 22px; padding: 0; }
}

.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 15px; background: var(--gold-soft); color: var(--gold); flex: none; }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }

/* ---------- agenda (planilha) ---------- */
.agenda-top { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.days { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; flex: 1; scroll-snap-type: x proximity; }
.days::-webkit-scrollbar { display: none; }
.day { flex: none; width: 62px; scroll-snap-align: start; border: 1px solid var(--line); background: var(--card); border-radius: 13px; padding: 8px 0 7px; text-align: center; transition: border-color .15s, background .15s; }
.day small { display: block; font-size: 11.5px; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
.day b { display: block; font-size: 20px; line-height: 1.25; font-variant-numeric: tabular-nums; }
.day i { display: block; font-style: normal; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.day.fechado { opacity: .5; }
.day[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.day[aria-pressed="true"] small, .day[aria-pressed="true"] i { color: #cbbfa9; }
@media (prefers-color-scheme: dark) { .day[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: #1a1205; } .day[aria-pressed="true"] small, .day[aria-pressed="true"] i { color: #3d2c0b; } }
.datepick { position: relative; }
.datepick input { position: absolute; inset: 0; opacity: 0; width: 100%; pointer-events: none; }

.agenda-wrap { display: grid; gap: 18px; }
@media (min-width: 1100px) { .agenda-wrap { grid-template-columns: 1fr 280px; align-items: start; } }
.sheet { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.sheet-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.sheet-h h2 { font-size: 16px; }
.sheet-h .badge { font-size: 12.5px; }
.slot { display: grid; grid-template-columns: 66px 1fr auto; align-items: center; gap: 10px; padding: 0 12px 0 16px; min-height: 54px; border-bottom: 1px solid var(--line); }
.slot:last-child { border-bottom: 0; }
.slot .t { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15.5px; }
.slot input { width: 100%; border: 1px solid transparent; background: transparent; border-radius: 9px; padding: 9px 10px; min-height: 40px; outline: none; font-weight: 600; transition: background .15s, border-color .15s; }
.slot input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); font-weight: 500; }
@media (hover: hover) { .slot input:hover { background: var(--soft); } }
.slot input:focus { background: var(--card); border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 20%, transparent); }
.slot.ocupado { background: color-mix(in srgb, var(--gold-soft) 55%, transparent); }
.slot.ocupado .t { color: var(--gold); }
.slot.passado { opacity: .5; }
.slot.salvando input { opacity: .6; }
.slot .acts { display: flex; align-items: center; gap: 6px; min-width: 64px; justify-content: flex-end; }
.slot .x { border: 0; background: none; color: var(--muted); width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; }
.slot .x:hover { background: var(--bad-soft); color: var(--bad); }
.legend { font-size: 13.5px; color: var(--muted); }
.legend h2 { color: var(--ink); }
@media (max-width: 560px) { .agenda-top .seta { display: none; } }
.legend ul { margin: 8px 0 0; padding-left: 18px; }
.legend li { margin-bottom: 6px; }
.stat { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--line); }
.stat:last-of-type { border-bottom: 0; }
.stat b { font-size: 22px; font-variant-numeric: tabular-nums; }

/* ---------- whatsapp ---------- */
.wa { display: grid; gap: 22px; align-items: center; }
@media (min-width: 760px) { .wa.qr { grid-template-columns: 300px 1fr; } }
.qrbox { background: #fff; border-radius: 16px; padding: 14px; border: 1px solid var(--line); width: 100%; max-width: 300px; aspect-ratio: 1; display: grid; place-items: center; margin: 0 auto; }
.qrbox img { width: 100%; height: auto; image-rendering: pixelated; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; display: flex; gap: 12px; padding: 9px 0; align-items: flex-start; }
.steps li::before { content: counter(s); width: 26px; height: 26px; border-radius: 50%; background: var(--gold-soft); color: var(--gold); font-weight: 700; font-size: 13.5px; display: grid; place-items: center; flex: none; }
.status-big { display: flex; align-items: center; gap: 16px; }
.status-big .ic { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; flex: none; }
.status-big .ic svg { width: 28px; height: 28px; }
.status-big .ic.ok { background: var(--ok-soft); color: var(--ok); }
.status-big .ic.bad { background: var(--bad-soft); color: var(--bad); }
.status-big .ic.wait { background: var(--soft); color: var(--muted); }
.status-big h2 { font-size: 19px; }
.status-big p { margin: 3px 0 0; color: var(--muted); }
.spin { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- barbeiros (admin) ---------- */
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.bcard { display: block; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; transition: border-color .15s, transform .15s; }
.bcard:hover { border-color: color-mix(in srgb, var(--gold) 55%, var(--line)); transform: translateY(-1px); }
.bcard .head { display: flex; align-items: center; gap: 12px; }
.bcard .head b { font-size: 16.5px; display: block; }
.bcard .head small { color: var(--muted); }
.bcard .nums { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0 14px; }
.bcard .nums div { background: var(--soft); border-radius: 11px; padding: 10px 12px; }
.bcard .nums b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.bcard .nums small { color: var(--muted); font-size: 12.5px; }
.bcard .foot { display: flex; gap: 6px; flex-wrap: wrap; }
.bcard.add { display: grid; place-items: center; text-align: center; border-style: dashed; box-shadow: none; color: var(--muted); min-height: 190px; background: transparent; }
.bcard.add svg { width: 30px; height: 30px; margin-bottom: 6px; }

.bhead { display: flex; align-items: center; gap: 14px; }
.resp { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; background: var(--card); }
.resp .row { align-items: flex-start; }

/* ---------- conversas ---------- */
.clist { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.citem { display: flex; gap: 12px; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--line); width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-top: 0; }
.citem:last-child { border-bottom: 0; }
.citem:hover { background: var(--soft); }
.citem .m { flex: 1; min-width: 0; }
.citem .m b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.citem .m span { display: block; color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.citem time { color: var(--muted); font-size: 12.5px; flex: none; }

.chat { display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
.msg { max-width: 82%; padding: 9px 13px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; font-size: 15px; }
.msg small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.msg.cliente { align-self: flex-start; background: var(--soft); border-bottom-left-radius: 5px; }
.msg.ia, .msg.barbeiro { align-self: flex-end; border-bottom-right-radius: 5px; }
.msg.ia { background: var(--info-soft); }
.msg.barbeiro { background: var(--gold-soft); }
.sim { display: flex; flex-direction: column; height: min(640px, calc(100dvh - 260px)); min-height: 380px; }
.sim .chat { flex: 1; overflow-y: auto; padding: 4px 2px 12px; }
.sim form { display: flex; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }

/* ---------- janela (modal) ---------- */
.ov { position: fixed; inset: 0; z-index: 60; background: rgba(15,12,8,.5); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.dlg { background: var(--card); width: 100%; max-height: 92dvh; overflow: auto; border-radius: 20px 20px 0 0; padding: 20px 18px calc(18px + env(safe-area-inset-bottom)); animation: up .2s ease-out; }
.dlg-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.dlg-h h2 { font-size: 18px; }
.dlg-f { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }
@media (min-width: 640px) { .ov { align-items: center; padding: 24px; } .dlg { max-width: 520px; border-radius: 18px; padding: 24px; } .dlg.wide { max-width: 680px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }

/* ---------- avisos ---------- */
#toasts { position: fixed; z-index: 90; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab) + 18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; align-items: center; width: max-content; max-width: calc(100vw - 32px); pointer-events: none; }
@media (min-width: 900px) { #toasts { bottom: 28px; } }
.toast { background: var(--brand); color: var(--brand-ink); padding: 11px 16px; border-radius: 12px; font-weight: 600; font-size: 14.5px; box-shadow: 0 8px 28px rgba(0,0,0,.25); animation: up .2s; }
.toast.bad { background: var(--bad); color: #fff; }

.skel { color: var(--muted); padding: 40px 0; text-align: center; }
.mt { margin-top: 16px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

.mostrar { display: block; width: 100%; border: 0; border-bottom: 1px solid var(--line); background: var(--soft); color: var(--muted); font-size: 13.5px; font-weight: 600; padding: 10px; }
.mostrar:hover { color: var(--ink); }
