/* ============================================================
   BeeControl · Design System
   "Caderno de Escala do Pizzaiolo"
   ============================================================ */

:root {
  --brand: #b91c1c;
  --brand-700: #991b1b;
  --brand-50: #fef2f2;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;

  --paid-bg: #f0fdf4;
  --paid-fg: #166534;
  --pending-bg: #fffbeb;
  --pending-fg: #92400e;
  --weekly-bg: #eff6ff;
  --weekly-fg: #1e40af;

  --r: 8px;
  --r-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* números sempre tabulares */
.num, .money, .stat-value, .cal-day, table td, .tabular { font-variant-numeric: tabular-nums; }

/* ---------- Layout ---------- */
.app-shell { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; flex: 0 0 auto;
  display: grid; place-items: center; overflow: hidden;
  background: var(--brand); color: #fff;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-name {
  font-weight: 600; font-size: 16px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

.desktop-nav { display: flex; gap: 4px; margin-left: auto; }
.desktop-nav a {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 13px; border-radius: var(--r);
  font-size: 14px; font-weight: 500; color: var(--muted);
  transition: background .16s, color .16s;
}
.desktop-nav a:hover { background: #f1f5f9; color: var(--text); }
.desktop-nav a.active { background: var(--brand-50); color: var(--brand); font-weight: 600; }

.page { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 20px 16px 96px; }

.bottom-nav { display: none; }

/* ---------- Cartões ---------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 16px; }
.anim-in { animation: fadeUp .28s cubic-bezier(.22,.8,.36,1) both; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: none; }
}
.stagger > * { animation: fadeUp .3s cubic-bezier(.22,.8,.36,1) both; }
.stagger > *:nth-child(1) { animation-delay: .01s }
.stagger > *:nth-child(2) { animation-delay: .04s }
.stagger > *:nth-child(3) { animation-delay: .07s }
.stagger > *:nth-child(4) { animation-delay: .1s }
.stagger > *:nth-child(5) { animation-delay: .13s }
.stagger > *:nth-child(6) { animation-delay: .16s }
.stagger > *:nth-child(n+7) { animation-delay: .19s }

.clickable { cursor: pointer; transition: border-color .16s, transform .16s, background .16s; }
.clickable:hover { border-color: #cbd5e1; background: #fcfdfe; }
.clickable:active { transform: scale(.995); }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: var(--r);
  border: 1px solid var(--border); background: #fff; color: var(--text);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .16s, border-color .16s, opacity .16s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-700); border-color: var(--brand-700); }
.btn-success { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; border-color: #15803d; }
.btn-danger { background: #fff; border-color: #fecaca; color: #b91c1c; }
.btn-danger:hover { background: #fef2f2; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f1f5f9; color: var(--text); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; gap: 6px; }
.btn-block { width: 100%; }
.btn-icon { width: 44px; padding: 0; flex: 0 0 auto; }

/* ---------- Formulários ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 12.5px; font-weight: 600; color: #475569; letter-spacing: .01em; }
.hint { font-size: 12px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--r);
  background: #fff; font-size: 15px; outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(185, 28, 28, .10);
}
.textarea { min-height: 76px; resize: vertical; line-height: 1.5; }
.input-error { border-color: #dc2626 !important; box-shadow: 0 0 0 3px rgba(220,38,38,.1) !important; }
.error-text { font-size: 12.5px; color: #b91c1c; font-weight: 500; }

/* ---------- Badges / status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .015em;
  white-space: nowrap;
}
.badge-paid { background: var(--paid-bg); color: var(--paid-fg); }
.badge-pending { background: var(--pending-bg); color: var(--pending-fg); }
.badge-weekly { background: var(--weekly-bg); color: var(--weekly-fg); }
.badge-cancelled { background: #f1f5f9; color: #475569; }
.badge-neutral { background: #f1f5f9; color: #475569; }

/* ---------- Avatar ---------- */
.avatar {
  width: 42px; height: 42px; border-radius: 999px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: var(--brand-50); color: var(--brand);
  font-size: 14px; font-weight: 700; letter-spacing: .02em;
}
.avatar-sm { width: 32px; height: 32px; font-size: 11.5px; }
.avatar-lg { width: 56px; height: 56px; font-size: 19px; }

/* ---------- Stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: #fff; border: 1px solid var(--border); border-radius: var(--r);
  padding: 13px 14px; box-shadow: var(--shadow-sm);
}
.stat-label { font-size: 11.5px; font-weight: 600; color: var(--muted); line-height: 1.25; }
.stat-value { font-size: 24px; font-weight: 600; margin-top: 4px; letter-spacing: -.02em; }
.stat-sub { font-size: 11.5px; color: var(--muted-2); margin-top: 2px; }

/* ---------- Cabeçalho de seção ---------- */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 22px 0 10px;
}
.section-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.section-title .count {
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  background: #f1f5f9; border-radius: 999px; padding: 1px 7px;
}
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.page-title { font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.page-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ---------- Linha de extra ---------- */
.extra-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--r);
  background: #fff; border: 1px solid var(--border);
  text-align: left; width: 100%;
}
.extra-main { flex: 1; min-width: 0; }
.extra-name { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.extra-meta { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.extra-value { font-size: 15px; font-weight: 600; white-space: nowrap; }

/* ---------- Calendário ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.cal-month { font-size: 16px; font-weight: 600; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 4px; }
.cal-weekdays span {
  text-align: center; font-size: 11px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  padding: 4px 0;
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell {
  position: relative; aspect-ratio: 1 / 1; min-height: 44px;
  border: 1px solid transparent; border-radius: var(--r);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; cursor: pointer; background: #fff; transition: background .14s, border-color .14s;
  -webkit-tap-highlight-color: transparent;
}
.cal-cell:hover { border-color: #cbd5e1; }
.cal-cell.empty { background: transparent; cursor: default; }
.cal-cell.empty:hover { border-color: transparent; }
.cal-day { font-size: 13.5px; font-weight: 500; color: var(--text); }
.cal-cell.today { outline: 2px solid var(--brand); outline-offset: -2px; }
.cal-cell.today .cal-day { color: var(--brand); font-weight: 700; }
.cal-cell.is-paid { background: var(--paid-bg); border-color: #bbf7d0; }
.cal-cell.is-paid .cal-day { color: var(--paid-fg); }
.cal-cell.is-pending { background: var(--pending-bg); border-color: #fde68a; }
.cal-cell.is-pending .cal-day { color: var(--pending-fg); }
.cal-cell.is-cancelled { background: #f8fafc; }
.cal-cell.is-cancelled .cal-day { color: var(--muted-2); text-decoration: line-through; }
.cal-dot { width: 5px; height: 5px; border-radius: 999px; background: currentColor; opacity: .55; }
.cal-cell.is-paid .cal-dot { background: var(--paid-fg); }
.cal-cell.is-pending .cal-dot { background: var(--pending-fg); }

.cal-mini-names { display: flex; flex-direction: column; gap: 1px; width: 100%; padding: 0 2px; }
.cal-mini-name {
  font-size: 8.5px; font-weight: 600; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-align: center; border-radius: 3px; padding: 0 2px;
}
.mn-paid { background: var(--paid-bg); color: var(--paid-fg); }
.mn-pending { background: var(--pending-bg); color: var(--pending-fg); }
.cal-more { font-size: 8px; color: var(--muted); font-weight: 600; }

/* ---------- Progresso ---------- */
.progress { height: 6px; border-radius: 999px; background: #f1f5f9; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 999px; background: #16a34a; transition: width .45s cubic-bezier(.22,.8,.36,1); }

/* ---------- Estrelas ---------- */
.stars { display: inline-flex; gap: 2px; }
.star { cursor: pointer; color: #cbd5e1; transition: color .12s, transform .12s; line-height: 0; }
.star.on { color: #f59e0b; }
.star:hover { transform: scale(1.12); }
.star-static { cursor: default; }
.star-static:hover { transform: none; }

/* ---------- Modal ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .18s ease both;
  padding: 0;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.sheet {
  width: 100%; max-width: 520px; max-height: 92dvh;
  background: #fff; border-radius: var(--r-lg) var(--r-lg) 0 0;
  display: flex; flex-direction: column;
  animation: sheetUp .26s cubic-bezier(.22,.9,.32,1) both;
  overflow: hidden;
}
@keyframes sheetUp { from { transform: translateY(28px); opacity: .6 } to { transform: none; opacity: 1 } }
.sheet-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px 16px 12px; border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.sheet-body { padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 12px 16px calc(12px + var(--safe-b)); border-top: 1px solid var(--border); flex: 0 0 auto; }

@media (min-width: 640px) {
  .sheet-backdrop { align-items: center; padding: 24px; }
  .sheet { border-radius: var(--r-lg); max-height: 86dvh; animation: fadeUp .2s ease both; }
}

/* ---------- Toast ---------- */
#toast-root {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translateX(-50%);
  z-index: 120; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; width: calc(100% - 32px); max-width: 420px;
}
@media (min-width: 768px) { #toast-root { bottom: 24px; } }
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  background: #0f172a; color: #fff; border-radius: var(--r);
  padding: 11px 14px; font-size: 13.5px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(15,23,42,.22);
  animation: toastIn .24s cubic-bezier(.22,.9,.32,1) both;
}
.toast.err { background: #b91c1c; }
.toast.ok { background: #166534; }
.toast.leaving { animation: toastOut .2s ease both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.97) } to { opacity: 1; transform: none } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px) scale(.98) } }

/* ---------- Vazio ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 34px 20px; text-align: center;
  border: 1px dashed var(--border); border-radius: var(--r); background: #fff;
  color: var(--muted);
}
.empty-icon { color: #cbd5e1; }
.empty-title { font-size: 13.5px; font-weight: 600; color: #475569; }
.empty-sub { font-size: 12.5px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; }
.skeleton { background: linear-gradient(90deg,#f1f5f9 25%,#e9eef5 37%,#f1f5f9 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: var(--r); }
@keyframes shimmer { 0% { background-position: 100% 50% } 100% { background-position: 0 50% } }

/* ---------- Utilitários ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); }
.muted-2 { color: var(--muted-2); }
.tiny { font-size: 11.5px; }
.small { font-size: 12.5px; }
.bold { font-weight: 600; }
.green { color: var(--paid-fg); }
.amber { color: var(--pending-fg); }
.blue { color: var(--weekly-fg); }
.red { color: var(--brand); }
.gap-4 { gap: 4px } .gap-6 { gap: 6px } .gap-8 { gap: 8px } .gap-10 { gap: 10px } .gap-12 { gap: 12px }
.mt-4 { margin-top: 4px } .mt-8 { margin-top: 8px } .mt-12 { margin-top: 12px }
.mt-16 { margin-top: 16px } .mt-20 { margin-top: 20px } .mt-24 { margin-top: 24px }
.mb-8 { margin-bottom: 8px } .mb-12 { margin-bottom: 12px } .mb-16 { margin-bottom: 16px }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

.divider { height: 1px; background: var(--border); margin: 14px 0; }

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--weekly-bg); color: var(--weekly-fg);
  border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 600;
}
.chip button {
  border: 0; background: transparent; color: inherit; cursor: pointer;
  text-decoration: underline; font-size: 11.5px; padding: 0 0 0 2px; font-weight: 600;
  min-height: 20px;
}

/* ---------- Mobile ---------- */
@media (max-width: 767px) {
  .page { padding: 16px 14px calc(88px + var(--safe-b)); }
  .page-title { font-size: 19px; }
  .desktop-nav { display: none; }
  .stat-value { font-size: 19px; }
  .stat { padding: 11px 11px; }
  .stat-label { font-size: 10.5px; }
  .cal-cell { min-height: 40px; }
  .cal-day { font-size: 12px; }
  .cal-mini-name { font-size: 7.5px; }

  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: rgba(255,255,255,.97); backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    padding: 4px 4px calc(4px + var(--safe-b));
  }
  .bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 7px 2px 5px; border-radius: var(--r);
    font-size: 10px; font-weight: 600; color: var(--muted);
    min-height: 48px; justify-content: center;
    -webkit-tap-highlight-color: transparent;
  }
  .bottom-nav a.active { color: var(--brand); background: var(--brand-50); }
}

@media (min-width: 768px) {
  .page { padding: 26px 24px 40px; }
  .stat-grid { gap: 14px; }
  .stat-value { font-size: 27px; }
}

/* Tabelas */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }

.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* gráficos */
.chart-box { position: relative; width: 100%; height: 220px; }
.chart-box-sm { height: 170px; }
