:root {
  --pink: #e11d6f;
  --pink-dark: #b31056;
  --pink-soft: #fff0f6;
  --purple: #7c3aed;
  --grad: linear-gradient(135deg, #e11d6f 0%, #b31056 55%, #7c3aed 100%);
  --bg: #f6f1f5;
  --card: #ffffff;
  --text: #2b1a24;
  --muted: #8a6b79;
  --border: #f0dce6;
  --green: #16a34a;
  --amber: #b45309;
  --red: #dc2626;
  --gray: #6b7280;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(225, 29, 111, 0.08);
}

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

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  overflow-x: hidden;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.error-text { color: var(--red); font-size: 13px; margin: .5rem 0 0; }
.req { color: var(--pink); }
.sub { font-size: 14px; }

/* ===== TOAST ===== */
.toast {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 100; max-width: 90vw; padding: 12px 18px; border-radius: 999px;
  background: #2b1a24; color: #fff; font-size: 14px; box-shadow: 0 4px 16px rgba(0,0,0,.25);
  animation: fadeIn .2s ease;
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
@keyframes fadeIn { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; } }

/* ===== LOGIN ===== */
.login-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-bg {
  width: 100%; min-height: 100vh; padding: 24px; display: flex; align-items: center; justify-content: center;
  background: var(--grad);
}
.login-card {
  width: 100%; max-width: 380px; background: #fff; border-radius: 24px; padding: 28px 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
}
.login-logo { font-size: 56px; text-align: center; margin-bottom: 4px; }
.login-card h1 { margin: 4px 0 2px; font-size: 24px; text-align: center; }
.login-card p { text-align: center; margin: 0 0 18px; }
.login-card label { margin-bottom: 14px; }

label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13.5px; color: var(--text); }
input, select, textarea {
  font: inherit; color: var(--text); width: 100%; padding: 11px 12px; border: 1.5px solid var(--border);
  border-radius: 12px; background: #fff; outline: none; font-size: 16px;
}
input:focus, select:focus, textarea:focus { border-color: var(--pink); box-shadow: 0 0 0 3px rgba(225,29,111,.12); }
textarea { resize: vertical; }

.btn {
  font: inherit; font-weight: 700; border: none; border-radius: 12px; padding: 12px 16px;
  cursor: pointer; transition: transform .05s, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 4px 14px rgba(225,29,111,.3); }
.btn-secondary { background: var(--pink-soft); color: var(--pink-dark); }
.btn-ghost { background: transparent; color: var(--muted); padding: 8px 12px; }
.btn-danger { background: #fde8e8; color: var(--red); }
.btn-block { width: 100%; }
.btn-circle { width: 40px; height: 40px; border-radius: 50%; font-size: 20px; background: #fff; border: 1.5px solid var(--border); color: var(--pink); }
.btn-mini { background: #fff; border: 1.5px solid var(--border); padding: 8px 10px; font-size: 13px; }
.topbar .btn-ghost { color: #fff; }

/* ===== APP ===== */
.app { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--grad); color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 12px rgba(225,29,111,.3);
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-emoji { font-size: 22px; }
.brand { font-weight: 800; font-size: 16px; letter-spacing: .2px; }

.content { flex: 1; padding: 14px 14px calc(80px + env(safe-area-inset-bottom)); max-width: 560px; width: 100%; margin: 0 auto; }

.tab-panel { display: none; animation: fadeIn .15s ease; }
.tab-panel.active { display: block; }

/* ===== AGENDA ===== */
.agenda-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.day-label { font-weight: 800; font-size: 17px; text-align: center; flex: 1; }
.day-label small { display: block; font-weight: 600; color: var(--muted); font-size: 12px; margin-top: 2px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 8px; margin: 12px 0; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; text-align: center; box-shadow: var(--shadow); }
.stat-card strong { display: block; font-size: 20px; }
.stat-card span { font-size: 11.5px; color: var(--muted); }
.stat-card.confirmed strong { color: var(--green); }
.stat-card.pending strong { color: var(--amber); }
.stat-card.total strong { color: var(--pink); }
.stat-card.money strong { color: var(--green); }
label .hint { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }

.card-list { display: flex; flex-direction: column; gap: 8px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow); cursor: pointer;
}
.appt-card { display: flex; align-items: center; gap: 12px; }
.appt-time { font-weight: 800; font-size: 17px; color: var(--pink-dark); min-width: 52px; }
.appt-info { flex: 1; min-width: 0; }
.appt-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appt-service { font-size: 13px; color: var(--muted); }
.appt-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.chip.confirmado { background: #dcfce7; color: var(--green); }
.chip.pendente { background: #fef3c7; color: var(--amber); }
.chip.cancelado { background: #fee2e2; color: var(--red); }
.chip.finalizado { background: #e5e7eb; color: var(--gray); }
.chip.lembrete { background: #e0e7ff; color: #4338ca; }
.chip.falha { background: #fee2e2; color: var(--red); }

.appt-status { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

.empty { text-align: center; color: var(--muted); padding: 28px 0; }

/* ===== FORM CARD ===== */
.form-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px;
}
.form-card h2 { margin: 0 0 12px; font-size: 18px; }
.form-card label { margin-bottom: 12px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row { display: flex; align-items: center; gap: 8px; }

.check { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: 500; }
.check input { width: 18px; height: 18px; margin-top: 2px; flex: none; }

/* ===== CLIENTES ===== */
.toolbar { margin-bottom: 10px; }

/* ===== LEMBRETES ===== */
.lembrete-card .chip-wrap { margin-left: auto; }

/* ===== BOT CARD ===== */
.bot-ok { display: flex; align-items: center; gap: 8px; color: var(--green); font-weight: 700; }
.bot-off { display: flex; align-items: center; gap: 8px; color: var(--amber); font-weight: 700; }
.bot-qr { text-align: center; margin-top: 10px; }
.bot-qr img { width: 180px; height: 180px; border-radius: 12px; border: 1px solid var(--border); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(43,26,36,.55); backdrop-filter: blur(2px);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-overlay:not(.hidden) { animation: fadeIn .15s ease; }
.modal {
  background: #fff; width: 100%; max-width: 520px; border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 90vh; overflow-y: auto; animation: slideUp .2s ease;
}
@media (min-width: 560px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: 20px; }
}
@keyframes slideUp { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
.modal h2 { margin: 0 0 10px; font-size: 18px; }
.modal label { margin-bottom: 10px; }
.modal-actions { display: flex; gap: 8px; margin-top: 12px; }
.modal-actions .btn { flex: 1; }
.modal-actions.status-actions { flex-wrap: wrap; }
.modal-actions.status-actions .btn { flex: 1 1 45%; }
.modal-status { margin-bottom: 12px; }
.modal-small { max-width: 380px; }

.hist-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.hist-item:last-child { border-bottom: none; }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: rgba(255,255,255,.96); backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-around; padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
}
.nav-item {
  background: none; border: none; font: inherit; display: flex; flex-direction: column; align-items: center;
  gap: 2px; color: var(--muted); font-size: 11px; font-weight: 600; cursor: pointer; padding: 4px 10px;
  border-radius: 12px;
}
.nav-icon { font-size: 20px; line-height: 1; }
.nav-item.active { color: var(--pink); background: var(--pink-soft); }

.no-show { background: #fff; border-color: #dc2626; color: #dc2626; font-weight: 700; }

.chip-btn {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700;
  padding: 4px 9px; border-radius: 999px; border: 1.5px solid; cursor: pointer; background: #fff; white-space: nowrap;
}
.chip-btn.ok { color: #16a34a; border-color: #16a34a; }
.chip-btn.bad { color: #dc2626; border-color: #dc2626; }

.chip.no-show-chip { background: #fee2e2; color: #dc2626; }

.config-title { margin: 16px 0 6px; font-size: 15px; }

.bot-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
  padding: 5px 10px; border-radius: 999px; border: 1px solid;
  white-space: nowrap;
}
.bot-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.bot-pill-on { color: #16a34a; border-color: #16a34a; background: #f0fdf4; }
.bot-pill-on .bot-dot { background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, .2); }
.bot-pill-off { color: #dc2626; border-color: #dc2626; background: #fef2f2; }
.bot-pill-off .bot-dot { background: #dc2626; }
.bot-pill-warn { color: #d97706; border-color: #d97706; background: #fffbeb; }
.bot-pill-warn .bot-dot { background: #d97706; }
.bot-pill-text { max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
