* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #6366f1;
  --primary-light: #eef2ff;
  --primary-dark: #312e81;
  --accent: #06b6d4;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-light: #6b7280;
  --text-muted: #9ca3af;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.06);
  --gradient: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  padding-bottom: 56px;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

.tela { max-width: 100%; margin: 0 auto; padding: 10px 8px; }

/* === TABS === */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 5px;
  margin-bottom: 0;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.tab {
  flex: 1;
  padding: 12px 8px;
  border: none;
  background: transparent;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 12px;
  color: var(--text-light);
  text-align: center;
  transition: all 0.25s;
}

.tab-ativo {
  background: var(--gradient);
  color: white;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.aba-conteudo { display: none; }
.aba-visivel { display: block; }

.tabela-header-fixo {
  position: sticky;
  top: 52px;
  z-index: 20;
}

.tabela-header-fixo table {
  margin-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
}

.tabela-body-scroll table {
  border-radius: 0 0 var(--radius) var(--radius);
  border-top: none;
}

/* === TABELA MOBILE === */
.tabela-mobile {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.76rem;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.tabela-mobile thead th {
  background: var(--gradient);
  color: white;
  padding: 13px 6px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  text-align: center;
}

.tabela-mobile tbody tr {
  border-bottom: 2px solid var(--border);
  transition: background 0.15s;
}

.tabela-mobile tbody tr:last-child { border-bottom: none; }

.tabela-mobile td {
  padding: 11px 6px;
  text-align: center;
  vertical-align: middle;
}

.cel-data-mob {
  font-size: 0.72rem;
  color: var(--text-light);
  white-space: nowrap;
  min-width: 42px;
  background: #fafbfc;
  border-right: 1px solid var(--border);
}

.cel-data-mob b {
  font-size: 0.92rem;
  color: var(--text);
  display: block;
  line-height: 1.2;
}

.cel-turno-mob {
  cursor: pointer;
  font-size: 0.66rem;
  line-height: 1.35;
  color: var(--text);
  min-width: 78px;
  transition: all 0.15s;
  border-radius: 8px;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.cel-turno-mob:active { background: var(--primary-light); transform: scale(0.96); }

.tabela-mobile tr.row-fds td { background: #f0f0f0; color: #bbb; font-size: 0.65rem; padding: 4px; }

/* === TABELA DESKTOP === */
.desktop-only { display: none; }
.mobile-only { display: block; }

@media (min-width: 768px) {
  .mobile-only { display: none !important; }
  .desktop-only { display: block !important; }
  .tela { max-width: 1100px; padding: 24px; }
  /* Telas com tabela de escala precisam de mais largura (3+ carrinhos) */
  #tela-calendario.tela, #tela-admin.tela { max-width: 1400px; }
}

.tabela-container {
  background: var(--card);
  border-radius: var(--radius);
  max-width: 100%;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.tabela-scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.escala {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8rem;
}

table.escala th {
  background: #f9fafb;
  padding: 12px 5px;
  font-weight: 700;
  font-size: 0.7rem;
  text-align: center;
  color: var(--text);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

table.escala th.th-carrinho {
  background: var(--gradient);
  color: white;
  font-size: 0.74rem;
  padding: 13px 6px;
  letter-spacing: 0.2px;
  position: sticky;
  top: 0;
  z-index: 10;
}

table.escala thead tr:first-child th { top: 0; }
table.escala thead tr:nth-child(2) th { top: 44px; }

table.escala td {
  border-bottom: 1px solid var(--border);
  padding: 10px 5px;
  text-align: center;
  vertical-align: middle;
  min-width: 82px;
  transition: background 0.15s;
}

table.escala td.col-data {
  font-weight: 700;
  font-size: 0.82rem;
  background: #fafbfc;
  min-width: 60px;
  color: var(--text);
}

table.escala td.col-dia {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: #fafbfc;
  min-width: 36px;
  font-weight: 500;
}

table.escala td.col-turno { cursor: pointer; }
table.escala td.col-turno:hover { background: var(--primary-light); }
table.escala tr.row-fds td { background: #f9fafb; color: var(--text-muted); }

.nomes-celula { font-size: 0.74rem; color: var(--text); line-height: 1.5; }

/* === MODAL === */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
}

.modal-content {
  background: var(--card);
  border-radius: 24px 24px 0 0;
  padding: 30px 24px 36px;
  width: 100%;
  max-width: 440px;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-lg);
}

@media (min-width: 768px) {
  .modal { align-items: center; }
  .modal-content { border-radius: var(--radius); }
}

@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal-content h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: 16px; color: var(--text); }

.troca-info {
  background: var(--primary-light);
  border: 1px solid #c7d2fe;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.85rem;
  margin-bottom: 20px;
  color: var(--primary-dark);
  font-weight: 500;
}

.troca-info.ocupado {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

/* === NAV INFERIOR === */
#nav-inferior {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
  padding: 10px 16px;
  z-index: 100;
}

#nav-inferior button {
  background: var(--primary-light);
  border: 1px solid #c7d2fe;
  font-size: 0.8rem;
  color: var(--primary);
  cursor: pointer;
  padding: 8px 24px;
  border-radius: 10px;
  min-height: 40px;
  font-weight: 600;
  transition: all 0.15s;
}

#nav-inferior button:active { background: var(--primary); color: white; }

/* === ADMIN NAV === */
.admin-nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.admin-nav button {
  padding: 12px 4px 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 70px;
  transition: all 0.2s;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  position: relative;
}

.admin-nav button:hover { border-color: var(--primary); background: var(--primary-light); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.admin-nav button:active { transform: translateY(0) scale(0.95); }

.nav-icon { font-size: 1.4rem; display: block; }
.nav-label { font-size: 0.62rem; color: var(--text-light); font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }

#badge-pedidos {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--danger);
  color: white;
  font-size: 0.55rem;
  padding: 2px 5px;
  border-radius: 8px;
  font-weight: 700;
  min-width: 16px;
  text-align: center;
}

.cel-admin { cursor: pointer; }
.cel-admin:hover { background: var(--primary-light) !important; }

/* === FORMS === */
.form-grupo { margin-bottom: 16px; }
.form-grupo label { display: block; font-size: 0.78rem; color: var(--text-light); margin-bottom: 6px; font-weight: 600; }
.form-grupo input, .form-grupo select {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  min-height: 50px;
  background: var(--card);
  transition: all 0.2s;
}
/* Caixas de marcar: tamanho normal, ao lado do texto (não herdam o estilo dos campos de texto) */
.form-grupo input[type="checkbox"] {
  width: 20px; height: 20px; min-height: 0; padding: 0; margin: 0 8px 0 0;
  vertical-align: middle; accent-color: var(--primary); cursor: pointer;
}
.form-grupo label:has(> input[type="checkbox"]) {
  font-size: 0.9rem; font-weight: 500; color: var(--text); cursor: pointer; margin-bottom: 8px;
}
.form-grupo input:focus, .form-grupo select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.btn {
  display: block; width: 100%; padding: 14px; border: none; border-radius: 12px;
  font-size: 1rem; cursor: pointer; min-height: 50px; font-weight: 700; text-align: center;
  transition: all 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--gradient); color: white; box-shadow: 0 4px 14px rgba(99,102,241,0.3); }
.btn-secondary { background: #f3f4f6; color: var(--text-light); margin-top: 10px; border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: white; margin-top: 10px; box-shadow: 0 4px 14px rgba(239,68,68,0.2); }
.btn-sm { display: inline-block; width: auto; padding: 8px 16px; font-size: 0.8rem; min-height: 38px; border-radius: 8px; }

.msg-vazio { text-align: center; color: var(--text-muted); padding: 48px 16px; font-size: 0.9rem; }

.login-box { max-width: 340px; margin: 0 auto; }

.header { text-align: center; padding: 20px 8px 12px; }
.header h1 { font-size: 1.3rem; font-weight: 800; color: var(--primary-dark); }
.header p { color: var(--text-light); font-size: 0.85rem; margin-top: 4px; }

/* === PEDIDOS === */
.card-pedido {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 10px; box-shadow: var(--shadow);
  transition: all 0.15s;
}
.card-pedido:hover { box-shadow: var(--shadow-lg); }
.card-pedido.novo { border-left: 4px solid var(--warning); }
.card-pedido.lido { opacity: 0.5; }
.pedido-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.pedido-header strong { font-size: 0.9rem; }
.badge-novo { background: linear-gradient(135deg, #f59e0b, #ef4444); color: white; font-size: 0.6rem; padding: 3px 8px; border-radius: 6px; font-weight: 700; text-transform: uppercase; }
.pedido-detalhe { font-size: 0.8rem; color: var(--text-light); margin-bottom: 4px; }
.pedido-acoes { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

/* === EDIT BOX === */
.edit-box {
  margin-top: 16px; padding: 20px; background: var(--card);
  border-radius: var(--radius); border: 2px solid var(--primary);
  box-shadow: var(--shadow-lg);
}
.edit-box h3 { font-size: 0.9rem; margin-bottom: 14px; color: var(--primary-dark); font-weight: 700; }

/* === PARTICIPANTES === */
.item-participante {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; margin-bottom: 8px; box-shadow: var(--shadow);
  transition: all 0.15s;
}
.item-participante:hover { box-shadow: var(--shadow-lg); }
.item-participante .nome { font-weight: 600; font-size: 0.9rem; }
.item-participante .telefone { font-size: 0.72rem; color: var(--text-muted); margin-left: 8px; }
.secao-titulo { font-size: 0.82rem; font-weight: 700; color: var(--text-light); margin: 20px 0 10px; text-transform: uppercase; letter-spacing: 0.5px; }

/* === RASCUNHO / DESATIVADO === */
.cel-rascunho { background: #fef9c3 !important; border-left: 3px solid var(--warning) !important; }
.cel-desativado { opacity: 0.3; text-decoration: line-through; }

/* === TOAST === */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 380px;
}

.toast {
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 0.88rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.3s ease-out;
  pointer-events: auto;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  backdrop-filter: blur(10px);
}

.toast-success { background: rgba(16, 185, 129, 0.95); color: white; }
.toast-error { background: rgba(239, 68, 68, 0.95); color: white; }
.toast-warning { background: rgba(245, 158, 11, 0.95); color: white; }
.toast-info { background: rgba(99, 102, 241, 0.95); color: white; }
.toast-icon { font-size: 1.2rem; }
.toast-exit { animation: toastOut 0.3s ease-in forwards; }

@keyframes toastIn { from { opacity: 0; transform: translateY(-20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { from { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(-20px) scale(0.95); } }

/* ============================================ */
/* === MODO ESCURO === */
/* ============================================ */
body.dark {
  --bg: #0f172a; --card: #1e293b; --border: #334155;
  --text: #f1f5f9; --text-light: #94a3b8; --text-muted: #64748b;
  --primary-light: #1e1b4b;
}
body.dark { background: var(--bg); color: var(--text); }
body.dark .header h1 { color: #a5b4fc; }

body.dark #nav-inferior { background: rgba(30,41,59,0.9); border-color: var(--border); }
body.dark #nav-inferior button { background: #1e1b4b; border-color: #4338ca; color: #a5b4fc; }

body.dark .tabs { background: var(--card); border-color: var(--border); }
body.dark .tab { color: var(--text-muted); }
body.dark .tab-ativo { color: white; }

body.dark .tabela-mobile { background: var(--card); border-color: var(--border); }
body.dark .tabela-mobile td { border-color: var(--border); }
body.dark .cel-data-mob { background: #1a2332; border-color: var(--border); }
body.dark .cel-data-mob b { color: var(--text); }
body.dark .cel-turno-mob { color: var(--text); }
body.dark .cel-turno-mob:active { background: #1e1b4b; }
body.dark .tabela-mobile tr.row-fds td { background: #0c1322; color: var(--text-muted); }

body.dark .tabela-container { background: var(--card); border-color: var(--border); }
body.dark table.escala th { background: #1a2332; border-color: var(--border); color: var(--text); }
body.dark table.escala td { border-color: var(--border); color: var(--text); }
body.dark table.escala td.col-data { background: #1a2332; }
body.dark table.escala td.col-dia { background: #1a2332; color: var(--text-muted); }
body.dark table.escala td.col-turno:hover { background: #1e1b4b; }
body.dark table.escala tr.row-fds td { background: #0c1322; color: var(--text-muted); }
body.dark .nomes-celula { color: var(--text); }

body.dark .modal-content { background: var(--card); color: var(--text); }
body.dark .troca-info { background: #1e1b4b; border-color: #4338ca; color: #a5b4fc; }
body.dark .troca-info.ocupado { background: #451a03; border-color: #92400e; color: #fbbf24; }
body.dark .form-grupo label { color: var(--text-light); }
body.dark .form-grupo input, body.dark .form-grupo select { background: #0f172a; border-color: var(--border); color: var(--text); }

body.dark .admin-nav button { background: var(--card); border-color: var(--border); color: var(--text); }
body.dark .admin-nav button:hover { border-color: var(--primary); background: #1e1b4b; }
body.dark .nav-label { color: var(--text-muted); }
body.dark .edit-box { background: var(--card); border-color: var(--primary); }
body.dark .edit-box h3 { color: #a5b4fc; }
body.dark .cel-admin:hover { background: #1e1b4b !important; }

body.dark .card-pedido { background: var(--card); border-color: var(--border); }
body.dark .pedido-detalhe { color: var(--text-light); }
body.dark .btn-secondary { background: #334155; color: var(--text); border-color: var(--border); }
body.dark .item-participante { background: var(--card); border-color: var(--border); }
body.dark .cel-rascunho { background: #451a03 !important; }


/* === Banner confirmação === */
.banner-conf {
  background: var(--card);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.banner-conf.bloqueio {
  margin: 20vh auto 0;
  max-width: 360px;
  padding: 24px;
  border-width: 3px;
}

body.dark .banner-conf { background: var(--card); border-color: #6366f1; }
