/* =====================================================================
   Caderno Financeiro — design system híbrido
   Base limpa (fintech profissional) + acentos de caderno pergaminho
   - Cores principais: verde escuro empresa (BR), accent emerald
   - Cards pastel inspirados no app Android original (verde/amarelo/vermelho/azul/papel)
   - Tipografia: Inter (corpo) + Plus Jakarta Sans (UI) + Caveat (toques caligráficos)
   - Linhas pautadas SUTIS no fundo (homenagem ao caderno)
   ===================================================================== */

:root {
  /* Paleta principal */
  --c-primary:        #0f766e;   /* teal-700 — confiança, dinheiro */
  --c-primary-dark:   #134e4a;
  --c-primary-light:  #ccfbf1;
  --c-accent:         #059669;

  /* Semânticas */
  --c-success:        #16a34a;
  --c-success-bg:     #dcfce7;
  --c-warning:        #d97706;
  --c-warning-bg:     #fef3c7;
  --c-danger:         #dc2626;
  --c-danger-bg:      #fee2e2;
  --c-info:           #2563eb;
  --c-info-bg:        #dbeafe;

  /* Caderno pergaminho (cards estilo post-it) */
  --c-paper:          #fbf6ec;
  --c-paper-line:     #c8a780;
  --c-paper-red:      #b34336;
  --c-paper-ink:      #2a2018;
  --c-paper-sticky:   #fef3c7;

  /* Neutros (base da app) */
  --c-bg:             #f7f6f3;   /* fundo papel-creme bem leve */
  --c-surface:        #ffffff;
  --c-surface-alt:    #f3f2ee;
  --c-border:         #e5e3dd;
  --c-text:           #1f2937;
  --c-text-muted:     #6b7280;
  --c-text-soft:      #9ca3af;

  /* Sidebar */
  --c-side:           #1f2820;   /* verde-escuro caderno */
  --c-side-hover:     #2c382e;
  --c-side-text:      #c8cbc6;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 12px 28px -6px rgb(0 0 0 / 0.12), 0 4px 6px -4px rgb(0 0 0 / 0.07);
  --shadow-paper: 3px 4px 0 rgb(0 0 0 / 0.06); /* sombra deslocada estilo carimbo */

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --font-sans:    'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Plus Jakarta Sans', var(--font-sans);
  --font-script:  'Caveat', 'Segoe Script', cursive;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; min-width: 0; }
html, body { margin: 0; padding: 0; font-family: var(--font-sans); color: var(--c-text); background: var(--c-bg); -webkit-font-smoothing: antialiased; }
html { -webkit-text-size-adjust: 100%; }
/* UM ÚNICO ponto de bloqueio horizontal.
   'clip' (com fallback 'hidden') evita scroll lateral SEM criar contexto de rolagem
   — não quebra position: sticky nem trava o scroll vertical no iOS. */
body { overflow-x: hidden; overflow-x: clip; overflow-y: auto; }
img, svg { max-width: 100%; height: auto; display: block; }
input, button, select, textarea { font-size: 16px; /* evita zoom no iOS */ }
/* prevenção: nada deve ultrapassar a tela horizontalmente */
.main, .app-shell, .topbar, .card, .table-wrap, .filters, .kpi-grid { max-width: 100%; }
table { table-layout: auto; max-width: 100%; }
pre, code, .pix-box { overflow-wrap: anywhere; word-break: break-word; }
.card, .table-wrap.cards-mobile td { overflow-wrap: anywhere; }
a { color: var(--c-primary); }
code { font-family: ui-monospace, 'Cascadia Code', Menlo, monospace; background: var(--c-surface-alt); padding: 1px 6px; border-radius: 4px; font-size: 0.9em; }
hr.divider { height: 1px; background: var(--c-border); margin: 16px 0; border: none; }

/* ===== layout ===== */
.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; min-width: 0; }
.app-shell > main { min-width: 0; }

.sidebar {
  background: var(--c-side);
  color: var(--c-side-text);
  padding: 24px 16px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  border-right: 1px solid rgba(255,255,255,0.05);
}

/* ====== Mobile-only elements (escondidos no desktop) ====== */
.mobile-header, .bottom-nav, .drawer-backdrop, .hamburger {
  display: none;
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }

  /* Sidebar vira drawer (esconde por padrão, abre via .drawer-open) */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; height: 100vh; width: 78vw; max-width: 320px;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease-out;
    padding-top: calc(20px + env(safe-area-inset-top, 0));
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
    overflow-y: auto;
    box-shadow: 4px 0 24px rgba(0,0,0,0.25);
  }
  body.drawer-open .sidebar { transform: translateX(0); }

  /* Backdrop */
  .drawer-backdrop {
    display: block; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199; opacity: 0; pointer-events: none;
    transition: opacity 0.2s ease;
  }
  body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
  body.drawer-open { overflow: hidden; }

  /* Mobile header escondido: usuário pediu para usar só o título da página (igual ao desktop).
     Acesso ao menu continua via bottom-nav → botão "Mais". */
  .mobile-header { display: none !important; }
  .mobile-header .brand {
    flex: 1; display: flex; align-items: center; gap: 10px;
    font-family: var(--font-display); font-weight: 700; font-size: 17px; color: white;
    text-decoration: none; min-width: 0;
  }
  .mobile-header .brand span.title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-header .brand-icon {
    width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0;
    background: var(--c-paper); color: var(--c-paper-ink);
    display: grid; place-items: center;
    font-family: var(--font-script); font-weight: 700; font-size: 24px;
  }
  .hamburger {
    display: grid; place-items: center;
    width: 40px; height: 40px; border-radius: 8px; border: none;
    background: transparent; color: white; cursor: pointer; flex-shrink: 0;
  }
  .hamburger svg { width: 22px; height: 22px; }

  /* Bottom navigation (5 tabs estilo Android) */
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    background: var(--c-surface);
    border-top: 1px solid var(--c-border);
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
  }
  .bottom-nav a, .bottom-nav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    padding: 10px 4px;
    background: transparent; border: none; cursor: pointer;
    color: var(--c-text-muted); text-decoration: none;
    font-size: 11px; font-weight: 600; font-family: inherit;
    transition: color 0.15s;
    -webkit-tap-highlight-color: rgba(0,0,0,0.05);
  }
  .bottom-nav a svg, .bottom-nav button svg { width: 22px; height: 22px; stroke-width: 2; }
  .bottom-nav a.active { color: var(--c-primary); }
  .bottom-nav a.active::before {
    content: ''; position: absolute; top: 0; height: 3px; width: 36px;
    background: var(--c-primary); border-radius: 0 0 4px 4px;
  }
  .bottom-nav a, .bottom-nav button { position: relative; }

  /* main em mobile: padding-top respeita a barra de status (safe-area) já que não há mais header preto;
     padding-bottom continua deixando espaço pro bottom-nav (~60px + safe-area inferior do iPhone). */
  .main {
    padding: calc(16px + env(safe-area-inset-top, 0)) 14px calc(120px + env(safe-area-inset-bottom, 0));
    background-image: none; /* desliga linhas pautadas (visual mais limpo) */
    /* IMPORTANTE: não usar overflow aqui — quebra position:sticky e o scroll vertical do iOS Safari */
  }
  /* Redundância: garante que NADA no fim da página fique escondido pelo bottom-nav,
     mesmo elementos fora do .main (modais, footers) */
  body {
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0));
  }
  /* Reneg-bar (sticky no topo da lista de parcelas) — header mobile foi removido,
     então fica colado no topo respeitando a safe-area do iPhone. */
  #reneg-bar { top: env(safe-area-inset-top, 0) !important; }
}

/* ===== safe area iPhone ===== */
@supports (padding: max(0px)) {
  .sidebar { padding-left: max(16px, env(safe-area-inset-left, 0px)); }
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 4px; color: #fff;
  font-family: var(--font-display); font-weight: 800; font-size: 20px;
  letter-spacing: -0.02em;
}
.sidebar-brand-icon {
  width: 40px; height: 40px; border-radius: 8px;
  background: var(--c-paper); color: var(--c-paper-ink);
  display: grid; place-items: center; font-family: var(--font-script); font-weight: 700;
  font-size: 28px; line-height: 1;
  box-shadow: var(--shadow-paper);
}
.sidebar-brand .brand-meta { display:flex; flex-direction:column; line-height: 1.1; }
.sidebar-brand .brand-meta small { font-family: var(--font-script); font-weight: 400; font-size: 14px; color: rgb(255 255 255 / 0.5); }

.sidebar-tagline { font-size: 12px; color: rgb(255 255 255 / 0.4); margin: 4px 0 24px 52px; line-height: 1.4; }
.sidebar-section { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: rgb(255 255 255 / 0.4); margin: 20px 12px 8px; font-weight: 600; }
.sidebar a.nav-item, .sidebar button.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius-md);
  color: var(--c-side-text); text-decoration: none; font-size: 14px; font-weight: 500;
  transition: all 0.15s ease;
  background: transparent; border: none; cursor: pointer; width: 100%;
  font-family: inherit; text-align: left;
}
.sidebar a.nav-item:hover, .sidebar button.nav-item:hover { background: var(--c-side-hover); color: white; }
.sidebar a.nav-item.active { background: var(--c-accent); color: white; box-shadow: 0 4px 12px rgb(5 150 105 / 0.3); }
.sidebar a.nav-item svg, .sidebar button.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.main {
  padding: 28px 36px;
  max-width: 1400px; margin: 0 auto; width: 100%;
  /* linhas pautadas sutis de fundo, como um caderno */
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 31px, rgba(180,160,130,0.07) 32px);
}
@media (max-width: 768px) { .main { padding: 20px 16px; } }

.topbar { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.topbar h1 { font-family: var(--font-display); font-size: 30px; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.topbar .subtitle { color: var(--c-text-muted); font-size: 14px; margin-top: 4px; }
.topbar .script { font-family: var(--font-script); font-size: 28px; color: var(--c-paper-ink); font-weight: 700; line-height: 1; }

@media (max-width: 640px) {
  .topbar { margin-bottom: 16px; gap: 10px; }
  .topbar h1 { font-size: 22px; }
  .topbar .script { font-size: 22px; }
  .topbar .subtitle { font-size: 13px; }
  .topbar > div:first-child { flex: 1 1 100%; }
  .topbar .flex.gap-2 { width: 100%; }
  .topbar .flex.gap-2 .btn { flex: 1; justify-content: center; }
}

/* ===== buttons ===== */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: var(--radius-md); border: 1px solid transparent; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.15s ease; text-decoration: none; font-family: inherit; min-height: 40px; }
.btn-primary { background: var(--c-primary); color: white; }
.btn-primary:hover { background: var(--c-primary-dark); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn-secondary { background: var(--c-surface); color: var(--c-text); border-color: var(--c-border); }
.btn-secondary:hover { background: var(--c-surface-alt); }
.btn-danger { background: white; color: var(--c-danger); border-color: var(--c-danger); }
.btn-danger:hover { background: var(--c-danger); color: white; }
.btn-success { background: var(--c-success); color: white; }
.btn-success:hover { background: #15803d; }
.btn-whatsapp { background: #25d366; color: white; border-color: #25d366; }
.btn-whatsapp:hover { background: #1da851; }
.btn-ghost { background: transparent; color: var(--c-text-muted); }
.btn-ghost:hover { background: var(--c-surface-alt); color: var(--c-text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 14px 26px; font-size: 16px; }
.btn-block { display: flex; width: 100%; justify-content: center; }
.btn-icon { width: 36px; height: 36px; padding: 0; justify-content: center; }

/* ===== cards ===== */
.card { background: var(--c-surface); border-radius: var(--radius-lg); border: 1px solid var(--c-border); padding: 22px; box-shadow: var(--shadow-sm); }
.card-title { font-family: var(--font-display); font-size: 17px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.01em; }
.card-subtitle { color: var(--c-text-muted); font-size: 13px; margin: 0 0 16px; }

/* ===== KPI / Post-it cards (estilo app original) ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 24px; }

@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr 1fr !important; gap: 10px; margin-bottom: 16px; }
  .kpi { padding: 14px; min-height: 96px; }
  .kpi-value { font-size: 18px !important; }
  .kpi-label { font-size: 10px; }
  .kpi-delta { font-size: 11px; }
  /* Saldo atual: card principal, ocupa linha cheia */
  .kpi.saldo { grid-column: span 2; }
  .kpi.saldo .kpi-value { font-size: 24px !important; }
  /* Capital inicial: cabe em 1 coluna ao lado do Lucro (fonte caligráfica reduzida) */
  .kpi.papel { grid-column: span 1; }
  .kpi.papel .kpi-value { font-size: 22px !important; }
}
@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: 1fr !important; }
  .kpi.saldo, .kpi.papel { grid-column: span 1; }
}

.kpi {
  background: var(--c-surface); border-radius: var(--radius-lg); border: 1px solid var(--c-border);
  padding: 20px; position: relative; overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-label { font-size: 12px; color: var(--c-text-muted); margin: 0 0 6px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-family: var(--font-display); font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.kpi-delta { font-size: 12px; color: var(--c-text-muted); margin-top: 8px; }

/* variantes coloridas dos KPIs (paleta app original) */
.kpi.saldo {
  background: linear-gradient(135deg, var(--c-primary), var(--c-primary-dark));
  color: #fff; border: none;
}
.kpi.saldo .kpi-label, .kpi.saldo .kpi-delta { color: rgb(255 255 255 / 0.7); }

.kpi.recebido { background: var(--c-success-bg); border-color: #bbf7d0; }
.kpi.recebido .kpi-value { color: #065f46; }
.kpi.recebido .kpi-label { color: #047857; }

.kpi.aberto   { background: var(--c-warning-bg); border-color: #fde68a; }
.kpi.aberto .kpi-value   { color: #78350f; }
.kpi.aberto .kpi-label   { color: #92400e; }

.kpi.vencido  { background: var(--c-danger-bg); border-color: #fecaca; }
.kpi.vencido .kpi-value  { color: #7f1d1d; }
.kpi.vencido .kpi-label  { color: #991b1b; }

.kpi.proximo  { background: var(--c-info-bg); border-color: #bfdbfe; }
.kpi.proximo .kpi-value  { color: #1e3a8a; }
.kpi.proximo .kpi-label  { color: #1e40af; }

.kpi.papel    { background: var(--c-paper); border-color: #e9dcc1; box-shadow: var(--shadow-paper); }
.kpi.papel .kpi-value   { color: var(--c-paper-ink); font-family: var(--font-script); font-size: 38px; }

.kpi a.kpi-link { position: absolute; inset: 0; border-radius: inherit; }
.kpi.clickable { cursor: pointer; }

/* ===== tables ===== */
.table-wrap { background: var(--c-surface); border-radius: var(--radius-lg); border: 1px solid var(--c-border); overflow-x: auto; box-shadow: var(--shadow-sm); -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 12px 16px; font-size: 11px; font-weight: 700; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--c-border); background: var(--c-surface-alt); }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--c-border); font-size: 14px; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover { background: var(--c-surface-alt); }
.table .nowrap { white-space: nowrap; }
.table .num { font-variant-numeric: tabular-nums; text-align: right; }
.table .actions { white-space: nowrap; text-align: right; }
.row-selected { background: var(--c-primary-light) !important; }

/* Tabela cards-mode no mobile: cada <tr> vira um cartão */
@media (max-width: 640px) {
  .table-wrap.cards-mobile { background: transparent; border: none; box-shadow: none; overflow: visible; max-width: 100%; }
  .table-wrap.cards-mobile table, .table-wrap.cards-mobile thead, .table-wrap.cards-mobile tbody, .table-wrap.cards-mobile tr, .table-wrap.cards-mobile th, .table-wrap.cards-mobile td {
    display: block; width: 100%; max-width: 100%;
  }
  .table-wrap.cards-mobile thead { display: none; }
  .table-wrap.cards-mobile tr {
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg);
    padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow-sm);
  }
  .table-wrap.cards-mobile td {
    border: none !important; padding: 6px 0;
    display: flex; justify-content: space-between; align-items: center;
    font-size: 14px;
  }
  .table-wrap.cards-mobile td:first-child { font-weight: 700; font-size: 15px; padding-top: 0; }
  .table-wrap.cards-mobile td.actions, .table-wrap.cards-mobile td:last-child { padding-top: 8px; border-top: 1px solid var(--c-border) !important; margin-top: 6px; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
  .table-wrap.cards-mobile td.num { font-weight: 600; }
  /* Label sintético via atributo data-label */
  .table-wrap.cards-mobile td[data-label]::before {
    content: attr(data-label); font-size: 11px; font-weight: 600;
    color: var(--c-text-muted); text-transform: uppercase; letter-spacing: 0.04em;
  }
}

/* ===== badges ===== */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.5; }
.badge-success { background: var(--c-success-bg); color: #166534; }
.badge-warning { background: var(--c-warning-bg); color: #92400e; }
.badge-danger  { background: var(--c-danger-bg);  color: #991b1b; }
.badge-info    { background: var(--c-info-bg);    color: #1e40af; }
.badge-neutral { background: var(--c-surface-alt); color: var(--c-text-muted); }
.badge-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ===== forms ===== */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--c-text); margin-bottom: 6px; }
.form-label .required { color: var(--c-danger); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--c-border);
  border-radius: var(--radius-md); font-size: 14px; font-family: inherit;
  background: var(--c-surface); color: var(--c-text); transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgb(15 118 110 / 0.12);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-help { font-size: 12px; color: var(--c-text-muted); margin-top: 4px; }
.form-row { display: grid; gap: 14px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
@media (max-width: 640px) { .form-row.cols-2, .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr; } }

.form-radio-group { display: flex; gap: 10px; flex-wrap: wrap; }
.form-radio-group label { flex: 1; min-width: 140px; padding: 12px; border: 1.5px solid var(--c-border); border-radius: var(--radius-md); cursor: pointer; display: flex; align-items: center; gap: 10px; font-size: 14px; transition: all 0.15s; background: var(--c-surface); }
.form-radio-group label:hover { border-color: var(--c-primary); background: var(--c-primary-light); }
.form-radio-group input[type="radio"] { accent-color: var(--c-primary); width: 18px; height: 18px; }
.form-radio-group label:has(input:checked) { border-color: var(--c-primary); background: var(--c-primary-light); }

/* ===== flash ===== */
.flash-stack { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 14px 18px; border-radius: var(--radius-md); background: white; box-shadow: var(--shadow-lg); border-left: 4px solid var(--c-info); min-width: 280px; max-width: 420px; font-size: 14px; animation: slideIn 0.3s ease; }
.flash.success { border-left-color: var(--c-success); }
.flash.error   { border-left-color: var(--c-danger); }
.flash.warning { border-left-color: var(--c-warning); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== progress bar ===== */
.progress { height: 6px; background: var(--c-surface-alt); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--c-primary); transition: width 0.3s; border-radius: 999px; }
.progress.danger  > div { background: var(--c-danger); }
.progress.warning > div { background: var(--c-warning); }
.progress.success > div { background: var(--c-success); }

/* ===== avatar ===== */
.avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, var(--c-primary), var(--c-accent)); color: white; display: inline-grid; place-items: center; font-weight: 700; font-size: 14px; position: relative; }
.avatar-sm { width: 28px; height: 28px; font-size: 12px; }
.avatar-lg { width: 56px; height: 56px; font-size: 22px; }
.semaforo {
  position: absolute; bottom: -2px; right: -2px;
  width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--c-surface);
}
.semaforo.verde    { background: var(--c-success); }
.semaforo.amarelo  { background: var(--c-warning); }
.semaforo.vermelho { background: var(--c-danger); }

/* ===== empty state ===== */
.empty { text-align: center; padding: 50px 20px; color: var(--c-text-muted); }
.empty-icon { width: 56px; height: 56px; margin: 0 auto 16px; opacity: 0.4; }
.empty h3 { font-family: var(--font-display); font-size: 18px; margin: 0 0 8px; color: var(--c-text); }

/* ===== filters bar ===== */
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; padding: 16px; background: var(--c-surface); border-radius: var(--radius-lg); border: 1px solid var(--c-border); margin-bottom: 18px; }
.filters .form-group { margin: 0; }

@media (max-width: 640px) {
  .filters { padding: 12px; gap: 8px; }
  .filters .form-group { flex: 1 1 calc(50% - 4px); min-width: 0 !important; max-width: 100%; }
  .filters .btn { flex: 1; justify-content: center; min-width: calc(50% - 4px); max-width: 100%; }
  /* Garante que select/input dentro do form-group não estourem */
  .filters .form-group select, .filters .form-group input { width: 100%; max-width: 100%; }
}

/* ===== auth layout (refeito caderno) ===== */
.auth-layout { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; }
@media (max-width: 900px) { .auth-layout { grid-template-columns: 1fr; } .auth-hero { display: none; } }
@media (max-width: 640px) {
  .auth-form-wrap { padding: 24px 18px; padding-top: calc(40px + env(safe-area-inset-top, 0)); }
  .auth-form h1 { font-size: 26px; }
}
.auth-hero {
  background:
    linear-gradient(135deg, rgba(15,118,110,0.92), rgba(19,78,74,0.94)),
    repeating-linear-gradient(to bottom, transparent 0 30px, rgba(255,255,255,0.05) 30px 31px);
  color: white; padding: 56px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth-hero::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 6px;
  background: rgba(255,255,255,0.08);
}
.auth-form-wrap { display: grid; place-items: center; padding: 40px; background: var(--c-bg); }
.auth-form { width: 100%; max-width: 380px; }
.auth-form h1 { font-family: var(--font-display); font-size: 32px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 8px; }
.auth-form .greeting { font-family: var(--font-script); font-size: 28px; color: var(--c-paper-ink); margin: 0 0 4px; }
.auth-form p.subtitle { color: var(--c-text-muted); margin: 0 0 28px; }

/* ===== utilitários ===== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-6 { gap: 24px; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.text-xs { font-size: 12px; } .text-sm { font-size: 13px; } .text-lg { font-size: 16px; } .text-xl { font-size: 18px; }
.text-muted { color: var(--c-text-muted); }
.text-success { color: var(--c-success); }
.text-danger  { color: var(--c-danger); }
.text-warning { color: var(--c-warning); }
.text-primary { color: var(--c-primary); }
.font-bold { font-weight: 700; }
.font-mono { font-variant-numeric: tabular-nums; }
.font-script { font-family: var(--font-script); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 12px; } }

/* Esconde elementos por breakpoint */
.mobile-only { display: none; }
.desktop-only { display: initial; }
@media (max-width: 900px) {
  .mobile-only { display: initial; }
  .desktop-only { display: none !important; }
}

/* Form row colapsa em mobile sempre */
@media (max-width: 640px) {
  .card { padding: 16px; border-radius: 12px; }
  .card-title { font-size: 16px; }
  .form-row.cols-2, .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr !important; gap: 10px; }
  .form-radio-group { flex-direction: column; }
  .form-radio-group label { width: 100%; }
  .form-input, .form-select, .form-textarea { padding: 12px 14px; }
}

/* Sidebar drawer: ícone fechar */
.drawer-close {
  display: none; position: absolute; top: 14px; right: 14px;
  width: 36px; height: 36px; border-radius: 8px; border: none; cursor: pointer;
  background: rgba(255,255,255,0.08); color: white;
}
@media (max-width: 900px) {
  .drawer-close { display: grid; place-items: center; }
}

/* Animação suave no flash mobile (ocupa toda a largura) */
@media (max-width: 640px) {
  .flash-stack { left: 12px; right: 12px; top: 12px; }
  .flash { min-width: 0; max-width: 100%; }
}

/* Carnê responsivo: talões um por linha em mobile */
@media (max-width: 640px) {
  .carne-grid { grid-template-columns: 1fr !important; }
  .print-page { margin: 12px; padding: 18px; }
  .print-actions { padding: 0 12px; }
}
.checkbox { width: 20px; height: 20px; accent-color: var(--c-primary); cursor: pointer; }

/* PIX code box */
.pix-box {
  background: var(--c-surface-alt);
  border: 1.5px dashed var(--c-border);
  border-radius: var(--radius-md);
  padding: 12px;
  font-family: ui-monospace, monospace;
  font-size: 11px; word-break: break-all;
  color: var(--c-text);
}

/* Carnê / Comprovante (HTML print) */
.print-page {
  max-width: 800px; margin: 32px auto; background: white;
  padding: 36px; box-shadow: var(--shadow-lg); border-radius: 8px;
}
.print-page header { display: flex; justify-content: space-between; align-items: start; border-bottom: 2px solid #000; padding-bottom: 12px; margin-bottom: 18px; }
.print-page header h1 { font-family: var(--font-display); margin: 0; font-size: 22px; }
.print-page header .empresa { text-align: right; font-size: 12px; line-height: 1.4; }
.print-page h2 { font-size: 16px; margin: 20px 0 8px; }
.print-page table { width: 100%; border-collapse: collapse; font-size: 13px; }
.print-page th, .print-page td { border: 1px solid #d4d4d4; padding: 6px 10px; }
.print-page th { background: #f7f7f7; text-align: left; }
.print-page .num { text-align: right; font-variant-numeric: tabular-nums; }
.print-actions { max-width: 800px; margin: 12px auto 0; display: flex; gap: 8px; justify-content: end; }

@media print {
  body { background: white; }
  .print-actions, .sidebar, .topbar, .flash-stack { display: none !important; }
  .print-page { box-shadow: none; margin: 0; padding: 16px; max-width: 100%; }
  .main { background: white; }
}

/* Timeline de anotações */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content:''; position:absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--c-border); }
.timeline-item { position: relative; padding: 10px 0; }
.timeline-item::before { content:''; position:absolute; left: -22px; top: 16px; width: 12px; height: 12px; border-radius: 50%; background: var(--c-primary); border: 2px solid var(--c-surface); }
.timeline-item.tipo-LIGACAO::before  { background: var(--c-info); }
.timeline-item.tipo-WHATSAPP::before { background: #25d366; }
.timeline-item.tipo-PROMESSA::before { background: var(--c-warning); }

/* Responsável colorido */
.resp-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.resp-tag .dot { width: 8px; height: 8px; border-radius: 50%; }

/* ===== Tab bar (estilo chips com scroll horizontal em mobile) ===== */
.tab-bar {
  display: flex; gap: 8px; margin-bottom: 18px;
  border-bottom: 1px solid var(--c-border); padding-bottom: 0;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab-bar .tab-item {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px 10px 0 0;
  color: var(--c-text-muted); text-decoration: none;
  font-size: 14px; font-weight: 600; white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: all 0.15s;
}
.tab-bar .tab-item:hover { color: var(--c-text); background: var(--c-surface-alt); }
.tab-bar .tab-item.is-active {
  color: var(--c-primary); border-bottom-color: var(--c-primary);
  background: var(--c-surface);
}
.tab-bar .tab-item .emoji { font-size: 16px; }

@media (max-width: 640px) {
  .tab-bar { gap: 4px; }
  .tab-bar .tab-item { padding: 9px 12px; font-size: 13px; }
  .tab-bar .tab-item .emoji { font-size: 14px; }
}

/* ===== Banner de base de demonstração (modo fake) ===== */
.demo-banner {
  position: sticky; top: 0; z-index: 2000;
  background: repeating-linear-gradient(45deg, #dc2626 0 16px, #991b1b 16px 32px);
  color: #fff; text-align: center;
  font-family: var(--font-display);
  font-weight: 800; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 7px 12px; line-height: 1.3;
  border-bottom: 2px solid #fff;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.28);
  text-shadow: 0 1px 1px rgb(0 0 0 / 0.35);
}
/* Pisca discretamente pra reforçar que NÃO é a base real */
@media (prefers-reduced-motion: no-preference) {
  .demo-banner { animation: demo-pulse 2.2s ease-in-out infinite; }
}
@keyframes demo-pulse { 0%, 100% { filter: none; } 50% { filter: brightness(1.18); } }
