/* Mei Controler — estilos mobile-first (tema: roxo + âmbar) */
:root {
  --bg: #f3f5f2;
  --card: #ffffff;
  --ink: #1d2420;
  --muted: #6d7a70;
  --brand: #7c3aed;
  --brand-dark: #4c1d95;
  --accent: #e8a013;
  --danger: #d64545;
  --ok: #1f9d55;
  --line: #e3e9e5;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(20, 45, 28, 0.08);
  --tabbar-h: 64px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}

/* Barra superior */
#appbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 16px 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.appbar-title { display: flex; align-items: center; gap: 10px; }
.appbar-title strong { display: block; font-size: 17px; letter-spacing: 0.2px; }
.appbar-title small { display: block; font-size: 11px; opacity: 0.85; }
.appbar-logo {
  width: 38px; height: 38px; border-radius: 12px;
  background: rgba(255,255,255,0.16);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px;
}
.appbar-right { display: flex; align-items: center; gap: 10px; }
.appbar-date { font-size: 12px; opacity: 0.9; text-align: right; line-height: 1.4; }
.manual-btn {
  background: rgba(255,255,255,0.18); color: #fff; border: none;
  border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 13px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
}
.manual-btn:active { background: rgba(255,255,255,0.30); }

/* Conteúdo */
#view { padding: 14px 14px 20px; max-width: 640px; margin: 0 auto; }
h2.page-title { font-size: 20px; margin: 4px 2px 12px; }
h3.section-title { font-size: 14px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); margin: 18px 2px 8px; }

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px;
  border: 1px solid var(--line);
}
.card.tint-warn { border-left: 4px solid var(--accent); }
.card.tint-danger { border-left: 4px solid var(--danger); }
.card.tint-ok { border-left: 4px solid var(--ok); }

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.big-number { font-size: 26px; font-weight: 800; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Estatísticas do painel */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.stat .num { font-size: 24px; font-weight: 800; }
.stat .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.warn .num { color: #b97a0a; }
.stat.danger .num { color: var(--danger); }
.stat.ok .num { color: var(--ok); }

/* Listas */
.list-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--shadow);
  width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
}
.list-item:active { background: #eef4ee; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
}
.badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px; margin: 2px 4px 2px 0;
  white-space: nowrap;
}
.badge.ok { background: #e3f5e9; color: #14663a; }
.badge.warn { background: #fff3d9; color: #8a5c00; }
.badge.danger { background: #fde7e7; color: #a02c2c; }
.badge.info { background: #e2eefb; color: #1d4f9c; }
.badge.neutral { background: #edf1ef; color: var(--muted); }

/* Botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 12px; padding: 12px 16px;
  font: inherit; font-weight: 700; font-size: 15px; cursor: pointer;
  background: var(--brand); color: #fff; box-shadow: var(--shadow);
}
.btn:active { transform: scale(0.98); }
.btn.block { display: flex; width: 100%; }
.btn.secondary { background: #e8efea; color: var(--ink); }
.btn.ghost { background: transparent; color: var(--brand); box-shadow: none; padding: 8px 10px; }
.btn.danger { background: var(--danger); }
.btn.small { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.btn-row { display: flex; gap: 8px; margin-top: 10px; }
.btn-row .btn { flex: 1; }
.btn-col { display: flex; flex-direction: column; gap: 8px; }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--brand); color: #fff; border: none;
  font-size: 30px; line-height: 1; cursor: pointer;
  box-shadow: 0 4px 14px rgba(23, 114, 69, 0.4); z-index: 15;
}

/* Formulários */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 5px; color: #33413a; }
.field input, .field select, .field textarea {
  width: 100%; font: inherit; font-size: 15px;
  padding: 11px 12px; border: 1px solid #cfd8d3; border-radius: 10px;
  background: #fff; color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand);
}
.field textarea { min-height: 90px; resize: vertical; }
.field .hint { font-size: 11px; color: var(--muted); margin-top: 4px; font-weight: 400; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
/* Alinha os controles pela base quando um rótulo quebra em 2 linhas */
.grid2 > .field { display: flex; flex-direction: column; }
.grid2 > .field > input,
.grid2 > .field > select,
.grid2 > .field > textarea { margin-top: auto; }

/* Busca e filtros */
.searchbar { display: flex; gap: 8px; margin-bottom: 10px; }
.searchbar input {
  flex: 1; font: inherit; font-size: 15px; padding: 11px 12px;
  border: 1px solid #cfd8d3; border-radius: 10px; background: #fff;
}
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 6px; }
.chip {
  flex: none; border: 1px solid #cfd8d3; background: #fff; color: var(--ink);
  border-radius: 999px; padding: 8px 13px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Overlay de detalhe */
.screen-overlay {
  position: fixed; inset: 0; z-index: 30; background: var(--bg);
  overflow-y: auto; padding-bottom: 40px;
}
.detail-head {
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand)); color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 14px 14px;
}
.detail-head .row { align-items: center; }
.back-btn {
  background: rgba(255,255,255,0.16); color: #fff; border: none;
  width: 38px; height: 38px; border-radius: 50%; font-size: 18px; cursor: pointer; flex: none;
}
.detail-body { padding: 14px; max-width: 640px; margin: 0 auto; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); }
.kv .v { text-align: right; font-weight: 600; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(12, 25, 18, 0.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
}
.modal h3 { margin: 0 0 12px; font-size: 17px; }
.modal-actions { display: flex; gap: 8px; margin-top: 14px; }
.modal-actions .btn { flex: 1; }

/* Toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  background: #1d2420; color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 14px; z-index: 60; box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  max-width: 90vw; text-align: center;
}

/* Barra de abas (construída do registry) */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff; border-top: 1px solid var(--line);
  display: flex;
}
.tab {
  flex: 1; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font: inherit;
}
.tab-icon { font-size: 19px; line-height: 1; position: relative; }
.tab-label { font-size: 11px; font-weight: 600; }
.tab.active { color: var(--brand); }
.tab-badge {
  position: absolute; top: -7px; right: -12px;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 800; line-height: 1;
  padding: 3px 6px; border-radius: 999px; min-width: 18px; text-align: center;
}

.empty { text-align: center; color: var(--muted); padding: 34px 16px; font-size: 14px; }
.divider { height: 1px; background: var(--line); margin: 12px 0; }
.link { color: var(--brand); font-weight: 700; text-decoration: none; }
pre.sheet {
  background: #f7faf8; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; white-space: pre-wrap; font: inherit; font-size: 14px; margin: 0;
}
table.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
table.mini th, table.mini td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); }
table.mini th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }

/* ---- Tela de licença (código de ativação) ---- */
.lock-screen {
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.lock-card { text-align: center; max-width: 320px; width: 100%; }
.lock-logo {
  width: 72px; height: 72px; border-radius: 20px;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  color: #fff; font-size: 28px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.lock-input {
  width: 100%; font-size: 28px; text-align: center; letter-spacing: 12px;
  text-indent: 12px; padding: 12px; border: 2px solid var(--line);
  border-radius: 12px; margin: 12px 0; background: #fff; color: var(--ink);
}
.lock-input:focus { border-color: var(--brand); outline: none; }
.lock-card .btn { width: 100%; }
.lock-card.wide { max-width: 340px; }
.promo-tag { display: inline-block; background: #ede9fe; color: #6d28d9; font-size: 11px; font-weight: 700; padding: 2px 10px; border-radius: 20px; }
.plan-card { position: relative; border: 1px solid #e2e8f0; border-radius: 12px; padding: 12px 14px; margin: 10px 0; text-align: left; background: #fff; }
.plan-card.popular { border: 2px solid var(--brand); box-shadow: 0 4px 14px rgba(0,0,0,.10); }
.badge-pop { position: absolute; top: -11px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .6px; padding: 3px 12px; border-radius: 20px; white-space: nowrap; }
.plan-price { font-size: 22px; font-weight: 800; color: var(--brand); margin: 2px 0 8px; }
.plan-note { color: #059669; font-size: 12px; font-weight: 600; margin-bottom: 8px; }
.strike { color: #94a3b8; font-size: 12px; text-decoration: line-through; }
.btn.wa { background: #25d366; color: #fff; width: 100%; }
.offer-banner { background: #fef9c3; border: 1px solid #fde68a; border-radius: 12px; padding: 12px 14px; margin: 12px 0; text-align: left; font-size: 13px; line-height: 1.5; color: #78350f; }
.offer-tag { display: inline-block; background: var(--accent); color: #fff; font-size: 10px; font-weight: 800; letter-spacing: .8px; padding: 2px 10px; border-radius: 20px; margin-bottom: 6px; }
.or-div { display: flex; align-items: center; gap: 10px; margin: 14px 2px 10px; color: #64748b; font-size: 12px; }
.or-div::before, .or-div::after { content: ''; flex: 1; height: 1px; background: #e2e8f0; }
.ref-code { font-size: 24px; font-weight: 800; letter-spacing: 2px; text-align: center; margin: 8px 0 12px; color: var(--brand); }

/* ---- Aviso de período de teste ---- */
.card.trial { border-left: 4px solid var(--accent); }

/* ---- Tela de 1º uso ---- */
.setup-screen {
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 8px;
}
.setup-card { width: 100%; max-width: 420px; text-align: center; }
.setup-card h2 { margin: 0 0 6px; }
.mode-cards { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 14px 0; }
.mode-card {
  display: flex; align-items: center; gap: 14px; text-align: left;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 14px; cursor: pointer; font: inherit; color: inherit; width: 100%;
}
.mode-card .mode-icon { font-size: 30px; flex: none; }
.mode-card strong { display: block; font-size: 16px; }
.mode-card.active { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2); }
.setup-card .field { text-align: left; }

/* ---- Seletor de modo (Ajustes) ---- */
.seg-row { display: flex; gap: 8px; }
.seg-btn {
  flex: 1; border: 1px solid #cfd8d3; background: #fff; color: var(--ink);
  border-radius: 10px; padding: 10px 6px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.seg-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---- Meios de pagamento (Ajustes) ---- */
.pay-row { padding: 9px 0; border-top: 1px solid var(--line); }
.pay-row:first-child { border-top: none; }
.taxa-wrap { display: flex; align-items: center; gap: 4px; flex: none; }
.taxa-wrap input { width: 74px; font: inherit; font-size: 14px; padding: 8px 6px; border: 1px solid #cfd8d3; border-radius: 8px; text-align: right; }

/* ---- Calendário mensal (Agenda) ---- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal-day { position: relative; width: 100%; min-width: 0; aspect-ratio: 1; border: none; background: none; font: inherit; font-size: 14px; color: var(--ink); border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-direction: column; }
.cal-day.empty { cursor: default; }
.cal-day.today { background: var(--brand); color: #fff; font-weight: 700; }
.cal-day.sel:not(.today) { outline: 2px solid var(--brand); }
.cal-dots { font-size: 8px; line-height: 1; color: var(--brand); }
.cal-day.today .cal-dots { color: #fff; }

/* ---- Checkboxes grandes ---- */
.check { display: flex; gap: 10px; align-items: flex-start; background: #eef4ee; border-radius: 10px; padding: 12px; margin: 8px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 2px; flex-shrink: 0; accent-color: var(--brand); }
.check span { font-size: 14px; font-weight: 600; }
.check small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---- Termos de Uso ---- */
.terms-screen { min-height: 100dvh; display: flex; align-items: flex-start; justify-content: center; padding: 24px 16px 40px; background: var(--bg); }
.terms-card { width: 100%; max-width: 560px; background: #fff; border-radius: 16px; padding: 24px 20px; box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.terms-card h2 { margin: 0 0 4px; }
.terms-body { max-height: 46dvh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 4px 14px 10px; margin: 12px 0 16px; background: #fafcfb; }
.terms-clause { font-size: 14px; margin: 12px 0 4px; color: var(--brand-dark); }
.terms-body p { font-size: 13px; color: var(--muted); margin: 0 0 6px; line-height: 1.55; }
.btn-link { display: block; width: 100%; background: none; border: none; color: var(--brand); font: inherit; font-weight: 700; padding: 12px; cursor: pointer; }
