/* casapp — design system limpo e profissional, mobile-first com sidebar desktop */

:root {
  color-scheme: light;

  /* Neutros (slate) */
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #334155;
  --text-dim: #64748b;
  --text-muted: #94a3b8;

  /* Marca casapp — gradiente lavanda + coral (extraído da logo) */
  --brand-violet: #9b8ec3;
  --brand-violet-hover: #8576b3;
  --brand-violet-soft: #f3f0fa;
  --brand-violet-border: #d4cce5;
  --brand-coral: #e09b9b;
  --brand-coral-hover: #cf8585;
  --brand-coral-soft: #fbeeee;
  --brand-coral-border: #ecc8c8;
  --brand-gradient: linear-gradient(135deg, #9b8ec3 0%, #e09b9b 100%);
  --brand-gradient-soft: linear-gradient(135deg, #f3f0fa 0%, #fbeeee 100%);

  /* Cores funcionais — primário usa a cor lavanda da marca */
  --primary: var(--brand-violet);
  --primary-hover: var(--brand-violet-hover);
  --primary-soft: var(--brand-violet-soft);
  --primary-border: var(--brand-violet-border);

  --success: #16a34a;
  --success-soft: #f0fdf4;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;

  /* Cores complementares pros cards de configurações */
  --c-blue: #2563eb;       --c-blue-soft: #eff6ff;
  --c-violet: #7c3aed;     --c-violet-soft: #f5f3ff;
  --c-emerald: #059669;    --c-emerald-soft: #ecfdf5;
  --c-amber: #d97706;      --c-amber-soft: #fffbeb;
  --c-rose: #e11d48;       --c-rose-soft: #fff1f2;
  --c-cyan: #0891b2;       --c-cyan-soft: #ecfeff;
  --c-pink: #db2777;       --c-pink-soft: #fdf2f8;
  --c-slate: #475569;      --c-slate-soft: #f1f5f9;

  /* Sombras */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.1), 0 4px 6px -4px rgba(15, 23, 42, 0.08);

  /* Raios */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 10px;
  --r-xl: 14px;
  --r-pill: 999px;

  --gap: 12px;
  --safe-top: env(safe-area-inset-top, 0);
  --safe-bottom: env(safe-area-inset-bottom, 0);

  --sidebar-w: 248px;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html {
  /* impede toque-duplo-zoom em iOS standalone (PWA) */
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11", "ss01";
  background: var(--surface-2);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14.5px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  /* Comportamentos nativos: sem flash cinza, sem callout, sem seleção em UI */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  /* Sem pull-to-refresh do navegador, sem bounce branco no topo */
  overscroll-behavior-y: none;
  overflow-x: hidden;
}
/* Permitir seleção de texto onde faz sentido (campos, conteúdo selecionável) */
input, textarea, [contenteditable], .seletivel, .toast, .meta, .titulo, .nome, .login {
  -webkit-user-select: text; user-select: text;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; touch-action: manipulation; }
button, .item-usuario, .config-card, .sidebar-link, .bottom-nav .tab, .icon-btn, .fab {
  -webkit-tap-highlight-color: transparent;
}

/* Tipografia */
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.02em; color: var(--text); }
h1 { font-size: 22px; line-height: 1.25; }
h2 { font-size: 17px; line-height: 1.3; font-weight: 600; }
h3 { font-size: 14px; color: var(--text-dim); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }

.dim { color: var(--text-dim); }
.muted { color: var(--text-muted); }
.strong { color: var(--text); font-weight: 500; }
.right { text-align: right; }
.center { text-align: center; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }

/* ========== Layout principal (sidebar + main) ========== */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
.main-area {
  display: flex; flex-direction: column;
  min-height: 100vh;
  min-width: 0; /* impede overflow horizontal */
}
.container {
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
  padding: 22px 24px 40px;
}

/* ========== Sidebar (desktop) ========== */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100vh;
  position: sticky; top: 0;
  overflow-y: auto;
}
.sidebar-header {
  padding: 18px 18px 14px;
  display: flex; align-items: center; gap: 10px;
}
.sidebar-header .logo-icon {
  width: 38px; height: 38px;
  flex-shrink: 0;
  display: block;
}
.sidebar-header .titulo { font-weight: 600; font-size: 15px; letter-spacing: -0.02em; line-height: 1.2; }
.sidebar-header .subt { font-size: 11.5px; color: var(--text-dim); letter-spacing: -0.005em; }
.sidebar-header .dot { color: var(--primary); }

.sidebar-nav {
  flex: 1;
  padding: 8px 10px 14px;
  overflow-y: auto;
}
.sidebar-section {
  margin-top: 14px;
}
.sidebar-section:first-child { margin-top: 4px; }
.sidebar-section-title {
  padding: 6px 10px 4px;
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text-muted);
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin: 1px 0;
  border-radius: var(--r-md);
  color: var(--text-2); font-size: 14px; font-weight: 500;
  background: transparent; border: none; width: 100%;
  cursor: pointer; text-align: left;
  transition: background 0.12s, color 0.12s;
}
.sidebar-link:hover { background: var(--surface-2); color: var(--text); }
.sidebar-link.active {
  background: var(--primary-soft); color: var(--primary);
}
.sidebar-link.active svg { color: var(--primary); }
.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--text-dim); }
.sidebar-link .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-link .badge-mini {
  font-size: 11px; padding: 1px 7px; border-radius: var(--r-pill);
  background: var(--surface-3); color: var(--text-dim);
}

.sidebar-footer {
  padding: 12px 14px 16px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-footer .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: grid; place-items: center;
  font-weight: 600; font-size: 13px;
  flex-shrink: 0;
}
.sidebar-footer .info { flex: 1; min-width: 0; }
.sidebar-footer .nome {
  font-weight: 600; font-size: 13.5px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-footer .perfil {
  font-size: 11.5px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-footer .sair {
  background: transparent; border: none;
  color: var(--danger); padding: 6px;
  border-radius: var(--r-md); cursor: pointer;
  display: grid; place-items: center;
}
.sidebar-footer .sair:hover { background: var(--danger-soft); }
.sidebar-footer .sair svg { width: 16px; height: 16px; }

/* ========== Top bar (mobile) ========== */
.toolbar {
  display: none; /* só aparece em mobile */
  align-items: center; gap: 10px;
  padding: 10px 14px;
  padding-top: calc(10px + var(--safe-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.toolbar .brand-icon {
  width: 28px; height: 28px;
  flex-shrink: 0;
  display: block;
}
.toolbar .brand {
  font-weight: 600; font-size: 16px; letter-spacing: -0.025em; color: var(--text);
}
.toolbar .brand .dot { color: var(--primary); }
.spacer { flex: 1; }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px; border-radius: var(--r-pill);
  background: var(--surface-2); font-size: 13px; color: var(--text-2);
  border: 1px solid var(--border);
}
.user-chip .avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 11px;
}

/* ========== Bottom navigation (mobile only) ========== */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 4px 4px calc(4px + var(--safe-bottom)) 4px;
  z-index: 40;
}
.bottom-nav .tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px 6px; border-radius: var(--r-md);
  background: transparent; border: none; color: var(--text-muted);
  font-size: 11px; font-weight: 500; cursor: pointer;
  transition: color 0.15s;
}
.bottom-nav .tab:hover { color: var(--text-2); }
.bottom-nav .tab.active { color: var(--primary); }
.bottom-nav .tab svg { width: 22px; height: 22px; }
.bottom-nav .tab .lbl { font-size: 11px; letter-spacing: -0.005em; }

/* ========== Drawer mobile ========== */
.drawer-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 90;
}
.drawer-overlay.show { display: block; animation: fadeIn 0.18s; }
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: 280px; max-width: 85vw;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 100;
  transform: translateX(-100%);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.drawer.show { transform: translateX(0); }

button.icon-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-dim);
  width: 40px; height: 40px; min-height: 40px; padding: 0;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.05s;
}
button.icon-btn:hover { background: var(--surface-2); color: var(--text); }
button.icon-btn:active { transform: scale(0.95); }
button.icon-btn svg { width: 18px; height: 18px; }

/* Refresh: estado armado (aguardando 2º toque) e spinning (recarregando) */
button.refresh-btn.armado {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}
button.refresh-btn.spinning svg {
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
/* No sidebar desktop, o botão fica menorzinho e discreto */
.sidebar-header button.refresh-btn {
  width: 32px; height: 32px; min-height: 32px;
  border-color: transparent;
}
.sidebar-header button.refresh-btn:hover { border-color: var(--border); }
.sidebar-header button.refresh-btn svg { width: 16px; height: 16px; }

/* ========== Page header (dentro do main) ========== */
.page-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 22px;
}
.page-head .back {
  width: 34px; height: 34px; padding: 0;
  background: var(--surface); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: var(--r-md);
  display: grid; place-items: center; cursor: pointer;
  flex-shrink: 0;
}
.page-head .back:hover { background: var(--surface-2); color: var(--text); }
.page-head .back svg { width: 16px; height: 16px; }
.page-head h1 { flex: 1; min-width: 0; }
.page-head .titulo-box .subt { font-size: 13px; color: var(--text-dim); margin-top: 2px; font-weight: 400; }
.page-head .acoes { display: flex; gap: 8px; flex-shrink: 0; }

/* ========== Cards ========== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: var(--gap);
  box-shadow: var(--shadow-xs);
}
.card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-header h2 { margin: 0; flex: 1; }

/* ========== Config grid (estilo MBM) ========== */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.config-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 22px 18px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  display: flex; flex-direction: column;
  gap: 12px;
  text-align: left;
  font-family: inherit;
  width: 100%;
  color: var(--text);
}
.config-card:hover {
  border-color: var(--primary-border);
  box-shadow: var(--shadow-md);
}
.config-card:active { transform: scale(0.99); }
.config-card .ico-wrap {
  width: 48px; height: 48px; border-radius: var(--r-lg);
  display: grid; place-items: center;
}
.config-card .ico-wrap svg { width: 22px; height: 22px; stroke-width: 1.75; }
.config-card .titulo {
  font-size: 16px; font-weight: 600; letter-spacing: -0.015em;
  color: var(--text);
}
.config-card .subt {
  font-size: 13px; color: var(--text-dim);
  font-weight: 400;
}
.config-card.disabled {
  opacity: 0.55; cursor: not-allowed;
}
.config-card .badge-em-breve {
  display: inline-flex; align-items: center;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em;
  padding: 2px 8px; border-radius: var(--r-pill);
  background: var(--surface-3); color: var(--text-dim);
  text-transform: uppercase;
  margin-left: 6px; vertical-align: middle;
}

/* Ícones coloridos dos config-cards */
.ico-wrap.c-blue    { background: var(--c-blue-soft);    color: var(--c-blue); }
.ico-wrap.c-violet  { background: var(--c-violet-soft);  color: var(--c-violet); }
.ico-wrap.c-emerald { background: var(--c-emerald-soft); color: var(--c-emerald); }
.ico-wrap.c-amber   { background: var(--c-amber-soft);   color: var(--c-amber); }
.ico-wrap.c-rose    { background: var(--c-rose-soft);    color: var(--c-rose); }
.ico-wrap.c-cyan    { background: var(--c-cyan-soft);    color: var(--c-cyan); }
.ico-wrap.c-pink    { background: var(--c-pink-soft);    color: var(--c-pink); }
.ico-wrap.c-slate   { background: var(--c-slate-soft);   color: var(--c-slate); }

/* ========== Inputs ========== */
label {
  display: block; font-size: 13px; color: var(--text-2);
  margin: 12px 0 5px 0; font-weight: 500;
}
input, select, textarea {
  font-family: inherit; font-size: 14.5px;
  padding: 10px 12px; border-radius: var(--r-md);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); width: 100%; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
@media (max-width: 600px) {
  input, select, textarea { font-size: 16px; padding: 11px 12px; min-height: 44px; }
  /* time/date inputs no iOS ficam exagerados — apertar */
  input[type="time"], input[type="date"], input[type="month"] {
    max-width: 180px; padding: 9px 12px; min-height: 40px;
  }
}

/* Compactar formulário dentro do modal — menos respiro vertical */
.modal label {
  margin: 12px 0 4px;
  font-size: 13px;
}
.modal label:first-of-type,
.modal-body label:first-of-type { margin-top: 0; }
.modal textarea { min-height: 56px; }
.modal .form-secao { margin: 14px 0 4px; }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
input:disabled, select:disabled { background: var(--surface-2); color: var(--text-dim); cursor: not-allowed; }
textarea { resize: vertical; min-height: 60px; font-family: inherit; }

/* Input com prefixo (ex.: R$ no valor) */
.input-prefix { position: relative; display: block; }
.input-prefix .prefix {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-dim); font-weight: 600; font-size: 14px; pointer-events: none;
}
.input-prefix input { padding-left: 36px; }

/* ========== Botões ========== */
button {
  cursor: pointer;
  font-size: 14px; font-weight: 500; letter-spacing: -0.005em;
  padding: 9px 14px; border-radius: var(--r-md);
  background: var(--primary); color: #fff; border: 1px solid var(--primary);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s, transform 0.05s;
  min-height: 38px;
}
button:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
button:active { transform: scale(0.98); }
button.secondary {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong);
}
button.secondary:hover { background: var(--surface-2); }
button.danger { background: var(--danger); border-color: var(--danger); }
button.danger:hover { background: #b91c1c; border-color: #b91c1c; }
button.ghost {
  background: transparent; color: var(--text-dim);
  padding: 6px 10px; min-height: 32px; border: none;
}
button.ghost:hover { background: var(--surface-2); color: var(--text); }
button.icon {
  padding: 0; width: 32px; min-width: 32px; min-height: 32px; border-radius: var(--r-md);
  background: var(--surface); color: var(--text-dim);
  border: 1px solid var(--border);
}
button.icon:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
button.icon svg { width: 14px; height: 14px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.big { width: 100%; padding: 12px 16px; font-size: 15px; min-height: 46px; }

button.primary-soft {
  background: var(--primary-soft); color: var(--primary); border: 1px solid var(--primary-border);
}
button.primary-soft:hover { background: var(--primary-border); }

/* ========== FAB ========== */
.fab {
  position: fixed; right: 20px; bottom: calc(20px + var(--safe-bottom));
  width: 50px; height: 50px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; cursor: pointer; border: none;
  box-shadow: var(--shadow-lg);
  z-index: 30; transition: transform 0.15s, background 0.15s;
}
.fab:hover { background: var(--primary-hover); }
.fab:active { transform: scale(0.95); }
.fab svg { width: 20px; height: 20px; }

/* ========== Item rows (lista densa estilo Linear) ========== */
.item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; margin-bottom: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: border-color 0.15s, background 0.15s, transform 0.2s, opacity 0.2s;
}
.item:hover { border-color: var(--border-strong); background: var(--surface-2); }
.item.clicavel { cursor: pointer; }
.item.clicavel:active { transform: scale(0.99); background: var(--surface-2); }
.item .leading {
  width: 22px; height: 22px; display: grid; place-items: center;
  color: var(--text-muted); flex-shrink: 0;
}
.item .leading svg { width: 18px; height: 18px; }
.item .info { flex: 1; min-width: 0; }
.item .titulo {
  font-weight: 500; font-size: 14.5px; color: var(--text);
  word-break: break-word;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.item .meta {
  font-size: 13px; color: var(--text-dim);
  display: flex; gap: 4px; flex-wrap: wrap; align-items: center;
  margin-top: 2px;
}
.item .meta .sep { color: var(--text-muted); }
.item .acoes { display: flex; gap: 4px; flex-shrink: 0; align-items: center; }

.item.atrasada { border-left: 3px solid var(--warning); }
.item.atrasada .meta { color: var(--warning); font-weight: 500; }
.item.concluida { opacity: 0.55; background: var(--surface-2); }
.item.concluida .titulo { text-decoration: line-through; color: var(--text-dim); }

.item.concluindo { transform: scale(0.97); opacity: 0; pointer-events: none; }

.prio-alta { border-left: 3px solid var(--danger); }
.prio-media { border-left: 3px solid var(--warning); }
.prio-baixa { border-left: 3px solid var(--text-muted); }

/* ========== Section title ========== */
.section-title {
  display: flex; align-items: center; gap: 8px;
  margin: 22px 4px 10px 4px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  color: var(--text-dim); text-transform: uppercase;
}
.section-title .count {
  font-size: 11px; padding: 1px 7px; border-radius: var(--r-pill);
  background: var(--surface-3); color: var(--text-dim); border: 1px solid var(--border);
  letter-spacing: 0; font-weight: 500;
}
.section-title.warn { color: var(--warning); }
.section-title.warn .count { background: var(--warning-soft); color: var(--warning); border-color: rgba(217, 119, 6, 0.2); }

/* ========== Badge ========== */
.badge {
  display: inline-flex; align-items: center; padding: 1px 8px; border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 500; letter-spacing: 0.005em;
  background: var(--surface-3); color: var(--text-dim); border: 1px solid var(--border);
}
.badge.ok { background: var(--success-soft); color: var(--success); border-color: rgba(22, 163, 74, 0.2); }
.badge.warn { background: var(--warning-soft); color: var(--warning); border-color: rgba(217, 119, 6, 0.2); }
.badge.err { background: var(--danger-soft); color: var(--danger); border-color: rgba(220, 38, 38, 0.2); }
.badge.primary { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-border); }
.badge.prov { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-border); }
.badge.canc { background: var(--surface-3); color: var(--text-dim); border-color: var(--border); text-decoration: line-through; }

.item.prio-prov { border-left: 3px solid var(--primary); }

/* Despesas — pills de filtro + barra flutuante de borderô */
.filtros-despesas { margin: 10px 0 8px; }
.filtros-despesas .pills { display: flex; flex-wrap: wrap; gap: 6px; }
.filtros-despesas .pill {
  padding: 6px 12px; border-radius: var(--r-pill); border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); font-size: 13px; cursor: pointer;
}
.filtros-despesas .pill:hover { border-color: var(--border-strong); }
.filtros-despesas .pill.active {
  background: var(--primary); color: white; border-color: var(--primary);
}

.resumo-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 600px) {
  .resumo-stats { grid-template-columns: repeat(2, 1fr); }
}

.barra-bordereau {
  position: sticky; bottom: 12px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  margin: 12px 0;
  padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--primary-border);
  border-radius: 12px; box-shadow: var(--shadow-md);
  z-index: 10;
}

.chk-bdr { width: 18px; height: 18px; cursor: pointer; }

/* ========== Empty state ========== */
.empty {
  text-align: center; padding: 32px 16px; color: var(--text-dim);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.empty svg { width: 28px; height: 28px; color: var(--text-muted); margin-bottom: 4px; }
.empty .texto { font-size: 13.5px; }

/* ========== Skeletons ========== */
@keyframes shimmer { 0% { background-position: -240px 0; } 100% { background-position: 240px 0; } }
.skeleton {
  height: 56px; margin-bottom: 6px;
  background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3));
  background-size: 480px 100%; animation: shimmer 1.4s linear infinite;
  border-radius: var(--r-lg); border: 1px solid var(--border);
}

/* ========== Hero (dashboard top) ========== */
.hero {
  padding: 22px 22px 20px; margin-bottom: 16px;
  background:
    linear-gradient(135deg, rgba(155, 142, 195, 0.10) 0%, rgba(224, 155, 155, 0.10) 100%),
    var(--surface);
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--brand-gradient);
}
.hero .titulo {
  font-size: 22px; font-weight: 600; letter-spacing: -0.025em; color: var(--text);
  margin-bottom: 4px;
}
.hero .data { font-size: 13.5px; color: var(--text-dim); text-transform: capitalize; }
.hero .stats {
  margin-top: 16px; display: flex; gap: 6px; flex-wrap: wrap;
}
.hero .stat {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 13px; color: var(--text-2);
}
.hero .stat strong { color: var(--text); font-weight: 600; }
.hero .stat.warn { background: var(--warning-soft); border-color: rgba(217, 119, 6, 0.2); color: var(--warning); }
.hero .stat.warn strong { color: var(--warning); }
.hero .stat.ok { background: var(--success-soft); border-color: rgba(22, 163, 74, 0.2); color: var(--success); }
.hero .stat.ok strong { color: var(--success); }

/* KPIs do dashboard (Sequência, Esta semana) */
.kpi-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.kpi-card {
  position: relative;
  padding: 16px 16px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.kpi-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--brand-violet);
}
.kpi-card.coral::before { background: var(--brand-coral); }
.kpi-card .kpi-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.kpi-card .kpi-icon {
  width: 28px; height: 28px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-violet-soft); color: var(--brand-violet);
  flex-shrink: 0;
}
.kpi-card.coral .kpi-icon {
  background: var(--brand-coral-soft); color: var(--brand-coral-hover);
}
.kpi-card .kpi-icon svg { width: 16px; height: 16px; }
.kpi-card .kpi-label {
  font-size: 11px; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
.kpi-card .kpi-valor {
  font-size: 28px; font-weight: 700; letter-spacing: -0.03em; color: var(--text);
  line-height: 1.1;
}
.kpi-card .kpi-valor .unidade {
  font-size: 14px; font-weight: 500; color: var(--text-dim); margin-left: 5px;
}
.kpi-card .kpi-delta {
  font-size: 12px; margin-top: 4px;
}

/* ========== Agenda — toolbar + tabs ========== */
.agenda-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.agenda-acoes {
  display: flex; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0;
}
button.agenda-novo {
  background: var(--brand-violet); border-color: var(--brand-violet); color: #fff;
  font-weight: 500; padding: 9px 16px;
}
button.agenda-novo:hover { background: var(--brand-violet-hover); border-color: var(--brand-violet-hover); }
button.agenda-novo.coral { background: var(--brand-coral); border-color: var(--brand-coral); }
button.agenda-novo.coral:hover { background: var(--brand-coral-hover); border-color: var(--brand-coral-hover); }
.agenda-filtro {
  min-width: 180px; max-width: 240px;
  padding: 8px 12px; border-radius: var(--r-md);
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: 14px; color: var(--text); cursor: pointer;
}
.agenda-filtro:focus { outline: none; border-color: var(--primary); }

.agenda-tabs {
  display: inline-flex; padding: 4px;
  background: var(--surface-3); border-radius: var(--r-pill);
  margin-bottom: 16px;
}
button.agenda-tab {
  background: transparent; color: var(--text-dim);
  border: none; padding: 7px 16px; min-height: 0;
  border-radius: var(--r-pill);
  font-size: 13.5px; font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
button.agenda-tab:hover { color: var(--text); background: transparent; }
button.agenda-tab.active {
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-xs);
  font-weight: 600;
}
@media (max-width: 600px) {
  .agenda-filtro { width: 100%; max-width: none; }
  .agenda-acoes { width: 100%; }
  .agenda-tabs { width: 100%; display: flex; }
  button.agenda-tab { flex: 1; }
}

/* Navegação de data + toggle visão Dia/Semana */
.agenda-navdata {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.agenda-navdata-esq {
  display: flex; align-items: center; gap: 8px;
}
.agenda-data-label {
  font-size: 14px; font-weight: 500; color: var(--text);
  min-width: 180px;
  text-transform: capitalize;
}
.agenda-visao-toggle {
  display: inline-flex; padding: 3px;
  background: var(--surface-3); border-radius: var(--r-pill);
}
button.agenda-visao {
  background: transparent; color: var(--text-dim);
  border: none; padding: 6px 14px; min-height: 0;
  border-radius: var(--r-pill);
  font-size: 13px; font-weight: 500;
}
button.agenda-visao.active {
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-xs); font-weight: 600;
}

/* Visão Semana — blocos por dia */
.agenda-semana { display: flex; flex-direction: column; gap: 14px; }
.dia-bloco {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 12px 14px;
}
.dia-bloco.hoje {
  border-color: var(--brand-violet);
  box-shadow: 0 0 0 1px var(--brand-violet-soft);
}
.dia-titulo {
  font-size: 13.5px; font-weight: 600;
  color: var(--text); margin-bottom: 8px;
  text-transform: capitalize;
}

/* ========== Toast ========== */
.toast {
  position: fixed; bottom: 24px;
  left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff;
  padding: 10px 16px; border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); z-index: 100;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.25s;
  max-width: 90vw; font-size: 13.5px; font-weight: 500;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--success); }

/* ========== Banner de nova versão ========== */
.banner-nova-versao {
  position: fixed;
  /* fica acima do bottom-nav (~64px) + safe-area do iPhone */
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  left: 12px; right: 12px;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--primary); color: #fff;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  z-index: 90;
  font-size: 14px; font-weight: 500;
  animation: slideUpBanner 0.25s ease-out;
}
.banner-nova-versao .banner-texto { flex: 1; }
.banner-nova-versao .banner-acao {
  background: #fff; color: var(--primary);
  border: 0; padding: 8px 14px;
  border-radius: var(--r-sm); font-weight: 600;
  cursor: pointer; font-size: 13.5px;
}
.banner-nova-versao .banner-acao:hover { opacity: 0.9; }

@keyframes slideUpBanner {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ========== Modal ========== */
.modal-bg {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4);
  display: none; align-items: flex-end; justify-content: center; z-index: 80;
}
.modal-bg.show { display: flex; animation: fadeIn 0.18s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); width: 100%; max-width: 520px;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 20px 20px calc(20px + var(--safe-bottom));
  max-height: 92vh; overflow-y: auto;
  overflow-x: hidden;  /* sem arrastar pro lado */
  /* impede que o scroll do modal "vaze" pro body — corrige travamento ao arrastar pra cima/baixo no iOS */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  animation: slideUp 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-lg);
  position: relative;
}

/* Botão X universal pra fechar qualquer modal — sticky no canto sup. dir. */
.modal-fechar {
  position: sticky;
  top: 4px;
  float: right;
  margin: -8px -8px 0 0;
  width: 34px; height: 34px; min-height: 34px; padding: 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  display: grid; place-items: center;
  cursor: pointer;
  z-index: 20;
  transition: background 0.15s, transform 0.05s;
}
.modal-fechar:hover { background: var(--surface-2); }
.modal-fechar:active { transform: scale(0.92); }

/* Em telas com modal-header colorido (tarefa/pendencia/lista), o X fica sobre o header — vira branco translúcido */
.modal:has(.modal-header) .modal-fechar {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
}
.modal:has(.modal-header) .modal-fechar:hover { background: rgba(255, 255, 255, 0.4); }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0.5; } to { transform: translateY(0); opacity: 1; } }
.modal h2 { margin-top: 4px; margin-bottom: 4px; }
.modal::before {
  content: ''; display: block; width: 36px; height: 4px;
  background: var(--border-strong); border-radius: 2px;
  margin: 0 auto 14px; opacity: 0.6;
}
@media (min-width: 600px) {
  .modal-bg { align-items: center; }
  .modal { border-radius: var(--r-xl); padding: 22px; }
  .modal::before { display: none; }
}

/* ========== Segmented control de tipo de frequência ========== */
.freq-tipo {
  display: flex; padding: 3px;
  background: var(--surface-3); border-radius: var(--r-pill);
  margin-bottom: 10px;
}
.freq-tipo button {
  flex: 1; min-height: 36px;
  background: transparent; color: var(--text-dim);
  border: none; padding: 7px 12px;
  border-radius: var(--r-pill);
  font-size: 13.5px; font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.freq-tipo button.active {
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-xs); font-weight: 600;
}

/* Rótulo dinâmico que mostra o estado atual da seleção (ex.: "✓ Todo dia") */
.freq-rotulo {
  font-size: 12.5px; color: var(--text-dim);
  margin: 8px 0 0; text-align: center;
  font-weight: 500;
}

/* ========== Escala: calendário mensal ========== */
.escala-navmes {
  display: flex; align-items: center; justify-content: space-between;
  margin: 4px 0 14px;
}
.escala-mestitulo {
  font-size: 17px; font-weight: 600;
  text-transform: capitalize;
  color: var(--text);
}
.cal-grade {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 18px;
}
.cal-cab {
  text-align: center; padding: 6px 0;
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.cal-celula {
  aspect-ratio: 1 / 1.15;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 4px;
  display: flex; flex-direction: column; gap: 3px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-family: inherit;
  text-align: left;
  min-height: 64px;
}
.cal-celula.vazia { background: transparent; border-color: transparent; cursor: default; pointer-events: none; }
.cal-celula:hover { border-color: var(--primary-border); background: var(--surface-2); }
.cal-celula.hoje {
  border-color: var(--brand-violet);
  box-shadow: 0 0 0 1px var(--brand-violet-soft);
}
.cal-num {
  font-size: 12px; font-weight: 600; color: var(--text);
  line-height: 1;
}
.cal-celula.hoje .cal-num { color: var(--brand-violet); }
.cal-avatares {
  display: flex; flex-wrap: wrap; gap: 2px;
  flex: 1;
  align-content: flex-start;
}
.cal-avatar {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  color: #fff; font-size: 11px; font-weight: 600;
  flex-shrink: 0;
}
.cal-eventos {
  display: flex; gap: 2px; flex-wrap: wrap;
  font-size: 11px;
  margin-top: auto;
}
.cal-evento { line-height: 1; }

/* Resumo mensal por funcionária */
.cal-resumo {
  display: flex; flex-direction: column; gap: 6px;
}
.resumo-linha {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.resumo-nome {
  display: flex; align-items: center; gap: 8px;
  flex: 1; font-weight: 500;
}
.resumo-stats {
  display: flex; gap: 12px; flex-wrap: wrap;
  font-size: 13px; color: var(--text-2);
}

/* Modal do dia */
.dia-funcs { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.dia-func {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--r-md);
}

/* Cards de configuração de escala */
.card-config-escala {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 12px 14px;
  margin-bottom: 8px;
}
.card-config-escala.sem-config {
  border-color: var(--brand-violet-border);
  background: var(--brand-violet-soft);
}
.cfg-head {
  display: flex; align-items: center; gap: 10px;
}
.cfg-nome { flex: 1; min-width: 0; }
.cfg-corpo { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.cfg-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.cfg-grid label { margin-top: 0; }

.escala-cfg-intro {
  margin: 0 0 12px; padding: 8px 12px;
  font-size: 12.5px; line-height: 1.45;
  background: var(--brand-violet-soft);
  border-left: 3px solid var(--brand-violet);
  border-radius: var(--r-sm);
  color: var(--text-2);
}

/* Tabs no topo da tela (Escala, Catálogo) — sticky pra ficar fácil voltar */
.screen > .freq-tipo {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface-2);
  padding: 6px 0;
  margin-bottom: 12px;
}
@media (max-width: 1023px) {
  /* No mobile a toolbar é sticky no topo — empurra os tabs pra baixo dela */
  .screen > .freq-tipo {
    top: calc(52px + var(--safe-top));
  }
}

@media (max-width: 600px) {
  .cal-celula { padding: 3px; min-height: 56px; }
  .cal-num { font-size: 11px; }
  .cal-avatar { width: 18px; height: 18px; font-size: 10px; }
  .cal-grade { gap: 3px; }
  .cal-celula { aspect-ratio: 1 / 1.3; }
}

/* Grid 2 colunas que vira 1 coluna no mobile (datas, CPF/nascimento, etc) */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.grid-2col label { margin-top: 0; }
@media (max-width: 600px) {
  .grid-2col { grid-template-columns: 1fr; gap: 0; }
}

/* Ajuste em bloco da escala */
.ajuste-dia {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.ajuste-dia.hoje { border-color: var(--brand-violet); box-shadow: 0 0 0 1px var(--brand-violet-soft); }
.ajuste-dia-cab {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.ajuste-data {
  font-weight: 600; font-size: 13px;
  text-transform: capitalize;
}
.ajuste-chips {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.chip-pessoa {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 4px; min-height: 30px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  font-size: 12.5px; font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}
.chip-pessoa.removido {
  opacity: 0.45;
  text-decoration: line-through;
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}
.chip-pessoa.adicionado {
  background: var(--success-soft);
  border-color: var(--success);
  color: var(--success);
  font-weight: 600;
}
.chip-x { color: inherit; opacity: 0.6; font-size: 14px; line-height: 1; }
.ajuste-add-sel {
  flex: 0 0 auto;
  font-size: 12.5px; padding: 6px 10px;
  min-height: 30px; min-width: 130px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  color: var(--text-dim);
  border-radius: var(--r-pill);
}

/* Explicação contextual do tipo de evento */
.evento-expl {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 8px 0 4px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-left: 3px solid var(--text-dim);
  border-radius: var(--r-sm);
  font-size: 12.5px; line-height: 1.45;
  color: var(--text-2);
}
.evento-expl-ico { font-size: 16px; flex-shrink: 0; line-height: 1.2; }

/* Card de aniversariantes na agenda */
.card-aniversarios {
  background: linear-gradient(135deg, var(--brand-coral-soft), var(--brand-violet-soft));
  border: 1px solid var(--brand-coral-border);
  border-radius: var(--r-lg);
  padding: 14px;
  margin-bottom: 14px;
}
.card-aniv-titulo {
  font-size: 14px; font-weight: 600;
  color: var(--text); margin-bottom: 10px;
  letter-spacing: -0.01em;
}
.aniv-linha {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  border-top: 1px solid rgba(255,255,255,0.6);
}
.aniv-linha:first-of-type { border-top: none; }
.aniv-linha.hoje { font-weight: 600; }
.aniv-ico { font-size: 22px; flex-shrink: 0; line-height: 1; }
.aniv-info { flex: 1; min-width: 0; }
.aniv-nome { font-size: 14px; color: var(--text); }
.aniv-data { font-size: 12px; color: var(--text-dim); margin-top: 1px; }
.aniv-linha.hoje .aniv-data { color: var(--brand-coral-hover); font-weight: 600; }

/* Documentos do funcionário */
.docs-novo {
  display: flex; gap: 8px; align-items: center;
  margin-top: 10px;
}
.docs-novo select { flex: 1; }
.doc-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 6px;
}
.doc-ico { font-size: 20px; flex-shrink: 0; }
.doc-info { flex: 1; min-width: 0; }
.doc-tipo { font-weight: 500; font-size: 14px; color: var(--text); }
.doc-meta {
  font-size: 12px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.doc-link {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: var(--r-md);
  flex-shrink: 0;
}
.doc-link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }

/* Upload de foto (Equipe) */
.foto-upload {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 4px;
}
.foto-preview {
  width: 88px; height: 88px;
  border-radius: 50%;
  background: var(--surface-2) center/cover no-repeat;
  border: 2px solid var(--border-strong);
  display: grid; place-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Catálogo de produtos como chips dentro do modal de lista (tap-to-add) */
.catalogo-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 8px;
}
.chip-produto {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; min-height: 36px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.chip-produto:hover { background: var(--surface-2); border-color: var(--primary-border); }
.chip-produto:active { transform: scale(0.97); }
.chip-produto .nome { color: var(--text); font-weight: 500; }
.chip-produto .qtd {
  font-size: 11.5px; color: var(--text-dim);
  background: var(--surface-3); padding: 2px 8px;
  border-radius: var(--r-pill); margin-left: 2px;
}

/* Segmented control de prioridade (Baixa | Média | Alta) — cores semânticas */
.prio-tipo {
  display: flex; padding: 3px;
  background: var(--surface-3); border-radius: var(--r-pill);
}
.prio-tipo button {
  flex: 1; min-height: 36px;
  background: transparent; color: var(--text-dim);
  border: none; padding: 7px 12px;
  border-radius: var(--r-pill);
  font-size: 13.5px; font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.prio-tipo button[data-prio="baixa"].active  { background: var(--success-soft); color: var(--success);  font-weight: 600; box-shadow: var(--shadow-xs); }
.prio-tipo button[data-prio="media"].active  { background: var(--warning-soft); color: var(--warning);  font-weight: 600; box-shadow: var(--shadow-xs); }
.prio-tipo button[data-prio="alta"].active   { background: var(--danger-soft);  color: var(--danger);   font-weight: 600; box-shadow: var(--shadow-xs); }

/* ========== Dias da semana ========== */
.dias-semana {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
}
.dias-semana label { margin: 0; padding: 0; cursor: pointer; user-select: none; }
.dias-semana input { display: none; }
.dias-semana span {
  display: block; padding: 8px 4px; text-align: center;
  font-size: 12.5px; font-weight: 500;
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--text-dim);
  transition: all 0.12s;
}
.dias-semana input:checked + span {
  background: var(--primary); color: #fff; border-color: var(--primary);
}

/* Grade de dias do mês (1–31) — pra mensal multi-dia */
.dias-mes-grade {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
  margin-top: 4px;
}
button.dia-mes {
  padding: 8px 0; min-height: 36px;
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.12s;
}
button.dia-mes:hover { background: var(--surface-2); color: var(--text); }
button.dia-mes.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
button.dia-mes.active:hover { background: var(--primary-hover); }

/* ========== Checklist no modal de conclusão ========== */
.checklist-conclusao {
  margin: 4px 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}
.checklist-conclusao .check-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}
.checklist-conclusao .check-item:last-child { border-bottom: none; }
.checklist-conclusao .check-item:hover { background: var(--surface-2); }
.checklist-conclusao .check-item input { width: 18px; height: 18px; cursor: pointer; flex-shrink: 0; }
.checklist-conclusao .check-item input:checked + span {
  text-decoration: line-through; color: var(--text-dim);
}
.checklist-conclusao .check-item span { font-size: 14px; color: var(--text); }

/* ========== Modal — header colorido + dica + ações secundárias ========== */
.modal-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 22px;
  padding-top: max(16px, calc(env(safe-area-inset-top) + 4px));
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  margin: -22px -22px 16px;
  color: #fff;
  font-weight: 600; font-size: 16px;
  letter-spacing: -0.015em;
}
.modal-header.tarefa { background: var(--brand-violet); }
.modal-header.pendencia { background: var(--brand-coral); }
.modal-header svg { color: #fff; flex-shrink: 0; }
.modal-titulo { flex: 1; }
.modal-body { padding-top: 18px; }
.modal-dica {
  font-size: 13px; color: var(--text-2);
  background: var(--surface-2);
  border-left: 3px solid var(--brand-violet);
  padding: 10px 12px;
  border-radius: var(--r-sm);
  margin: 0 0 16px;
  line-height: 1.5;
}
.modal-header.pendencia ~ * .modal-dica,
.modal-body .modal-dica.pendencia { border-left-color: var(--brand-coral); }
.modal-acoes-secundarias {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ========== Seções dentro de modal de formulário ========== */
.form-secao {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--brand-violet);
  margin: 18px 0 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--brand-violet-soft);
}
.form-secao:first-child { margin-top: 6px; }
.form-secao svg { color: var(--brand-violet); }

/* ========== Seletor de múltiplos responsáveis ========== */
.resp-selector { margin-top: 4px; }
.resp-selector .resp-me {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border: 2px solid var(--brand-violet);
  background: var(--brand-violet-soft);
  border-radius: var(--r-md);
  cursor: pointer;
  user-select: none;
}
.resp-selector .resp-me input { width: 18px; height: 18px; cursor: pointer; }
.resp-selector .resp-me span { font-size: 14px; color: var(--text); }
.resp-outros-titulo {
  font-size: 12.5px; margin: 12px 0 6px; color: var(--text-dim);
}
.resp-outros {
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface);
  max-height: 220px; overflow-y: auto;
}
.resp-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}
.resp-item:last-child { border-bottom: none; }
.resp-item:hover { background: var(--surface-2); }
.resp-item input { width: 16px; height: 16px; cursor: pointer; }
.resp-item span { font-size: 14px; color: var(--text); }

/* ========== Permissões grid (Perfis de Acesso) ========== */
.perms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px 14px;
}
.perms-grid .dom-grupo {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  background: var(--surface-2);
}
.perms-grid .dom-grupo h4 {
  font-size: 11.5px; font-weight: 600;
  color: var(--text-dim); text-transform: uppercase;
  letter-spacing: 0.05em; margin-bottom: 8px;
}
.perms-grid label.perm {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 0; font-size: 13px; color: var(--text-2);
  font-weight: 400; margin: 0; cursor: pointer;
}
.perms-grid label.perm input[type="checkbox"] {
  width: auto; margin: 0;
}

/* ========== Helpers ========== */
.row { display: flex; gap: var(--gap); align-items: center; flex-wrap: wrap; }
.row > * { flex: 1 1 auto; min-width: 0; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 6px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13.5px; }
th { color: var(--text-dim); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; }

.tabela-rolavel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.tabela-rolavel > .scroll { overflow-x: auto; }
.tabela-rolavel table { min-width: 600px; }
.tabela-rolavel th, .tabela-rolavel td { padding: 10px 14px; }
.tabela-rolavel tbody tr:last-child td { border-bottom: none; }
.tabela-rolavel tbody tr:hover { background: var(--surface-2); }

/* ========== Tela: Usuários (lista) ========== */
.item-usuario {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  width: 100%;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
  min-height: 64px;
}
.item-usuario:hover { border-color: var(--primary-border); background: var(--surface-2); }
.item-usuario:active { transform: scale(0.995); }
.item-usuario.inativo { opacity: 0.6; }
.item-usuario .avatar-usuario {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: grid; place-items: center;
  font-weight: 600; font-size: 15px;
  flex-shrink: 0;
}
.item-usuario .info-usuario {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.item-usuario .linha-1 {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 15px; font-weight: 600; color: var(--text);
}
.item-usuario .linha-1 .nome {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}
.item-usuario .linha-2 {
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--text-dim);
}
.item-usuario .linha-2 .login {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--text-2);
  font-size: 12px;
}
.item-usuario .linha-2 .sep { color: var(--text-muted); }
.item-usuario .linha-2 .tg-ok {
  color: var(--c-cyan); display: inline-flex; align-items: center; gap: 3px;
}
.item-usuario .acoes-usuario {
  display: flex; gap: 4px; flex-shrink: 0; align-items: center;
}

/* Linha de checkbox padronizada */
.check-linha {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  cursor: pointer;
  user-select: none;
}
.check-linha input[type="checkbox"] {
  width: 18px; height: 18px; flex-shrink: 0; cursor: pointer; accent-color: var(--primary);
}

/* Ações de formulário (Cancelar / Salvar) */
.acoes-form {
  display: flex; gap: 10px;
  margin-top: 22px; padding-top: 16px;
  border-top: 1px solid var(--border);
}
.acoes-form button {
  flex: 1; min-height: 44px;
}

/* ========== Login screen ========== */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(ellipse at top left, rgba(155, 142, 195, 0.18), transparent 55%),
    radial-gradient(ellipse at bottom right, rgba(224, 155, 155, 0.18), transparent 55%),
    var(--surface-2);
  position: relative;
}
.login-card {
  width: 100%; max-width: 400px; padding: 36px 32px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 20px 50px -20px rgba(155, 142, 195, 0.35), 0 8px 16px -8px rgba(15, 23, 42, 0.08);
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--brand-gradient);
}
.login-card .logo-marca {
  display: block;
  width: 220px; height: auto;
  margin: 8px auto 4px;
  user-select: none;
  -webkit-user-drag: none;
}
.login-card .subt {
  text-align: center; color: var(--text-dim); font-size: 14px; margin-bottom: 24px;
}
.login-card input {
  font-size: 16px; /* impede zoom no iOS ao focar */
  padding: 12px 14px;
  min-height: 48px;
}
.login-card button.big {
  margin-top: 20px;
  background: var(--brand-gradient);
  border: none;
  color: #fff;
  font-weight: 600;
  height: 50px;
  font-size: 16px;
  width: 100%;
  box-shadow: 0 4px 12px -2px rgba(155, 142, 195, 0.4);
  transition: box-shadow 0.2s, transform 0.05s;
}
.login-card button.big:hover { box-shadow: 0 6px 18px -2px rgba(155, 142, 195, 0.55); }
.login-card button.big:active { transform: scale(0.99); }
.login-card .erro { text-align: center; margin-top: 12px; color: var(--danger); font-size: 13px; min-height: 18px; }

@media (max-width: 600px) {
  .login-wrap { padding: 16px; align-items: flex-start; padding-top: max(40px, env(safe-area-inset-top)); }
  .login-card { padding: 28px 22px 26px; border-radius: 18px; }
  .login-card .logo-marca { width: 180px; margin-top: 0; }
  .login-card .subt { margin-bottom: 18px; }
}

/* ========== Responsive ========== */
@media (max-width: 1023px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .toolbar { display: flex; }
  .bottom-nav { display: flex; }
  .container { padding: 14px 14px 88px; }
  .fab { bottom: calc(72px + var(--safe-bottom)); right: 16px; }
  .toast { bottom: calc(82px + var(--safe-bottom)); }
  .page-head { margin-bottom: 14px; }
}

@media (max-width: 600px) {
  .row { flex-direction: column; align-items: stretch; }
  .toolbar { padding: 9px 12px; padding-top: calc(9px + var(--safe-top)); gap: 8px; }
  .toolbar .brand { font-size: 15px; }
  .toolbar .brand-icon { width: 26px; height: 26px; }
  .toolbar .user-chip { padding: 3px 8px 3px 3px; font-size: 12px; max-width: 130px; overflow: hidden; }
  .toolbar .user-chip span:not(.avatar) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .config-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .config-card { padding: 14px 12px; }
  .config-card .ico-wrap { width: 38px; height: 38px; }
  .config-card .ico-wrap svg { width: 18px; height: 18px; }
  .config-card .titulo { font-size: 14.5px; }
  .config-card .subt { font-size: 12px; }

  /* KPIs do dashboard cabem em 2 colunas em qualquer celular */
  .kpi-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-card { padding: 12px 12px 10px; }
  .kpi-card .kpi-valor { font-size: 24px; }
  .kpi-card .kpi-delta { font-size: 11px; line-height: 1.35; }

  /* Navegação de data: empilha pra evitar corte */
  .agenda-navdata { gap: 8px; }
  .agenda-navdata-esq { flex: 1; min-width: 0; }
  .agenda-data-label { min-width: 0; flex: 1; font-size: 13.5px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
  .agenda-visao-toggle { width: 100%; justify-content: stretch; }
  button.agenda-visao { flex: 1; padding: 7px 12px; }
}

/* iPhones bem estreitos (SE/8) — ajustes finos */
@media (max-width: 380px) {
  .container { padding: 12px 10px 88px; }
  .toolbar .user-chip span:not(.avatar) { display: none; }
  .config-grid { grid-template-columns: repeat(2, 1fr); }
}

/* SVG inline default */
svg { stroke-width: 1.75; }

/* ========== Transições de tela (feel nativo) ========== */
.screen.active {
  animation: fadeInScreen 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes fadeInScreen {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Modal: feel mais "iOS" — fundo com leve blur (só desktop, no mobile pesa demais a GPU) */
@media (min-width: 600px) {
  .modal-bg.show {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }
}

/* Botões: pressionar mais responsivo (escala mais visível no toque) */
@media (hover: none) {
  button:active,
  .item-usuario:active,
  .config-card:active,
  .sidebar-link:active,
  .bottom-nav .tab:active {
    transform: scale(0.97);
    transition: transform 0.04s;
  }
  /* Sem hover em telas de toque (não trava o estado depois do toque) */
  button:hover,
  .item:hover,
  .item-usuario:hover,
  .config-card:hover,
  .sidebar-link:hover,
  .bottom-nav .tab:hover {
    background: inherit;
    border-color: inherit;
    color: inherit;
    box-shadow: inherit;
  }
}
