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

:root {
  --bg: #090b10;
  --bg-card: #12151e;
  --bg-elevated: #181c28;
  --bg-hover: #1f2433;
  --border: #262b3d;
  --border-light: #323a52;
  --text: #eef0f6;
  --text-muted: #8b93a8;
  --primary: #1e3a8a;
  --primary-hover: #172554;
  --primary-soft: rgba(30,58,138,.12);
  --success: #22c55e;
  --success-bg: rgba(34,197,94,.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245,158,11,.1);
  --danger: #ef4444;
  --danger-bg: rgba(239,68,68,.1);
  --info: #3b82f6;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0,0,0,.35);
  --sidebar-w: 272px;
  --transition: .2s cubic-bezier(.4,0,.2,1);
}

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* Icons */
svg.lucide { stroke-width: 2; flex-shrink: 0; }

.brand-icon {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, #172554, #1e3a8a);
  display: flex; align-items: center; justify-content: center;
  color: #fff; box-shadow: 0 4px 16px rgba(23,37,84,.35);
}
.brand-icon svg { width: 20px; height: 20px; }
.brand-icon-lg { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 16px; }
.brand-icon-lg svg { width: 28px; height: 28px; }

/* Login */
.login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(30,58,138,.18), transparent),
    var(--bg);
}
.login-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 20px; padding: 44px 36px; width: 100%; max-width: 420px;
  text-align: center; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 1.55rem; font-weight: 700; margin-bottom: 4px; letter-spacing: -.02em; }
.login-card > p { color: var(--text-muted); margin-bottom: 28px; font-size: .92rem; }
.input-wrap {
  position: relative; margin-bottom: 16px;
}
.input-wrap svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--text-muted); pointer-events: none;
}
.input-wrap input {
  width: 100%; padding: 14px 16px 14px 44px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-size: .95rem; outline: none; transition: border var(--transition);
}
.input-wrap input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-edit-cobranca { display: flex; flex-direction: column; gap: 14px; }
.edit-hint {
  font-size: .78rem; color: var(--text-muted); line-height: 1.5;
  display: flex; align-items: flex-start; gap: 6px; margin-top: 4px;
}
.edit-hint svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 2px; }
.edit-hint strong { color: var(--text); }

/* Layout */
.app { display: flex; min-height: 100vh; }

.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  z-index: 90; backdrop-filter: blur(2px);
  transition: opacity var(--transition);
}
.sidebar-overlay.hidden { opacity: 0; pointer-events: none; }

.sidebar {
  width: var(--sidebar-w); background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.sidebar-header {
  padding: 22px 20px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border);
}
.logo-text { font-weight: 700; font-size: 1.05rem; display: block; letter-spacing: -.01em; }
.logo-sub { font-size: .72rem; color: var(--text-muted); font-weight: 500; }

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  color: var(--text-muted); text-decoration: none;
  font-weight: 500; font-size: .9rem; transition: all var(--transition);
}
.nav-item svg { width: 18px; height: 18px; opacity: .75; }
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item:hover svg { opacity: 1; }
.nav-item.active {
  background: var(--primary-soft); color: var(--primary);
  border: 1px solid rgba(30,58,138,.2);
}
.nav-item.active svg { opacity: 1; color: var(--primary); }
.sidebar-footer { padding: 16px 12px; border-top: 1px solid var(--border); }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: rgba(18,21,30,.85); backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 50;
}
.topbar h2 { font-size: 1.15rem; font-weight: 600; flex: 1; letter-spacing: -.02em; }
.menu-toggle {
  display: none; background: var(--bg-hover); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px;
  color: var(--text); cursor: pointer; line-height: 0;
}
.menu-toggle svg { width: 20px; height: 20px; }
.content { padding: 24px; flex: 1; width: 100%; max-width: none; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm); border: none;
  font-size: .88rem; font-weight: 600; cursor: pointer;
  transition: all var(--transition); font-family: inherit; white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.05); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-light); }
.btn-sm { padding: 7px 12px; font-size: .8rem; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-icon { padding: 7px 10px; }
.btn-block { width: 100%; }

/* Cards */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.card-header h3 {
  font-size: .95rem; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.card-header h3 svg { width: 18px; height: 18px; color: var(--text-muted); }
.card-body { padding: 20px 22px; }
.card-form .card-body { padding: 26px 22px; }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; margin-bottom: 22px;
}
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
  display: flex; align-items: flex-start; gap: 14px;
  transition: border-color var(--transition), transform var(--transition);
}
.stat-card:hover { border-color: var(--border-light); transform: translateY(-2px); }
.stat-card.highlight { border-color: rgba(30,58,138,.35); background: linear-gradient(135deg, var(--bg-card), rgba(30,58,138,.04)); }
.stat-icon-wrap {
  width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon-wrap svg { width: 20px; height: 20px; }
.stat-icon-wrap.blue { background: var(--primary-soft); color: var(--primary); }
.stat-icon-wrap.green { background: var(--success-bg); color: var(--success); }
.stat-icon-wrap.yellow { background: var(--warning-bg); color: var(--warning); }
.stat-icon-wrap.red { background: rgba(239,68,68,.15); color: #fca5a5; }
.stat-icon-wrap.gray { background: var(--bg-hover); color: var(--text-muted); }
.stat-info { min-width: 0; }
.stat-card .stat-label { font-size: .78rem; color: var(--text-muted); margin-bottom: 4px; font-weight: 500; }
.stat-card .stat-value { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.form-group { display: flex; flex-direction: column; gap: 7px; }
.form-group label {
  font-size: .82rem; font-weight: 500; color: var(--text-muted);
  display: flex; align-items: center; gap: 6px;
}
.form-group label svg { width: 14px; height: 14px; opacity: .7; }
.form-group input, .form-group select, .form-group textarea {
  padding: 11px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-size: .92rem; outline: none;
  font-family: inherit; transition: border var(--transition), box-shadow var(--transition);
}
.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.form-group-full { grid-column: 1 / -1; }
.calc-parcelas {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 18px; margin-bottom: 4px;
}
.calc-parcelas-head {
  display: flex; align-items: center; gap: 8px;
  font-size: .82rem; font-weight: 600; color: var(--primary);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 14px;
}
.calc-parcelas-head svg { width: 16px; height: 16px; }
.calc-parcelas-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
}
.calc-hint {
  font-size: .74rem; color: var(--text-muted); margin-top: 2px; line-height: 1.4;
}
.form-preview {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px 18px; margin-bottom: 20px;
  font-size: .88rem; color: var(--text-muted); line-height: 1.6;
}
.form-preview strong { color: var(--text); }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* Lists */
.list-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item-avatar {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.list-item-avatar svg { width: 18px; height: 18px; }
.list-item-info { flex: 1; min-width: 0; }
.list-item-info .name { font-weight: 600; font-size: .9rem; }
.list-item-info .detail { font-size: .8rem; color: var(--text-muted); margin-top: 3px; }
.list-item-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 20px;
  font-size: .7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; white-space: nowrap;
}
.badge-pendente { background: rgba(220,38,38,.15); color: #fca5a5; font-weight: 800; border: 1px solid rgba(220,38,38,.3); }
.badge-atrasada {
  background: var(--danger); color: #fff; font-weight: 900;
  animation: pulse-red 2s infinite; letter-spacing: .06em;
}
.badge-vence-hoje { background: rgba(234,88,12,.2); color: #fb923c; font-weight: 800; }
.badge-aguardando { background: var(--warning-bg); color: var(--warning); font-weight: 700; }
.badge-aprovado { background: var(--success-bg); color: var(--success); font-weight: 700; }
.badge-previsao { background: rgba(37,99,235,.1); color: #2563eb; font-weight: 700; text-transform: none; letter-spacing: 0; }

@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.5); }
  50% { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}

.card-atrasadas { border-color: rgba(239,68,68,.5); background: linear-gradient(135deg, var(--bg-card), rgba(239,68,68,.06)); }
.card-atrasadas .card-header h3 { color: #fca5a5; }
.card-atrasadas .card-header h3 svg { color: var(--danger); }

.list-item.atrasada-item { background: rgba(239,68,68,.06); border-radius: var(--radius-sm); padding: 14px 12px !important; margin-bottom: 8px; border: 1px solid rgba(239,68,68,.25); }
.list-item.atrasada-item .name { color: #fca5a5; font-weight: 800; }
.list-item.atrasada-item .detail { color: var(--danger); font-weight: 700; }

.stat-card.danger { border-color: rgba(239,68,68,.4); background: linear-gradient(135deg, var(--bg-card), rgba(239,68,68,.08)); }
.stat-card.danger .stat-value { color: var(--danger); font-weight: 900; }

.parcela-dot.atrasada { background: rgba(239,68,68,.2); border-color: var(--danger); color: var(--danger); font-weight: 900; }
.cal-event.atrasada { background: rgba(239,68,68,.2); color: #fca5a5; font-weight: 800; }
.dot-atrasada { background: var(--danger); }

/* Cobrança card */
.cobranca-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 20px; margin-bottom: 12px;
  transition: border-color var(--transition);
}
.cobranca-card:hover { border-color: var(--border-light); }
.cobranca-card-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; margin-bottom: 14px;
}
.cobranca-card-header h4 { font-size: .98rem; font-weight: 600; }
.cobranca-card-header .detail { font-size: .8rem; color: var(--text-muted); margin-top: 3px; }
.cobranca-progress { margin: 12px 0; }
.progress-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), #4ade80);
  border-radius: 3px; transition: width .4s ease;
}
.progress-label { font-size: .76rem; color: var(--text-muted); margin-top: 5px; }
.link-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px; margin-top: 14px;
}
.link-box input {
  flex: 1; background: none; border: none; color: var(--primary);
  font-size: .78rem; outline: none; font-family: 'SF Mono', 'Consolas', monospace;
  min-width: 0;
}
.link-box button { flex-shrink: 0; }

.slug-input {
  display: flex; align-items: stretch;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
  transition: border-color var(--transition);
}
.slug-input:focus-within { border-color: var(--primary); }
.slug-prefix {
  display: flex; align-items: center; padding: 0 12px;
  background: rgba(255,255,255,.03); color: var(--text-muted);
  font-size: .82rem; font-family: 'SF Mono', 'Consolas', monospace;
  border-right: 1px solid var(--border); white-space: nowrap;
}
.slug-input input {
  flex: 1; min-width: 0; border: none; background: none;
  padding: 11px 12px; color: var(--text); font-size: .9rem; outline: none;
  font-family: 'SF Mono', 'Consolas', monospace;
}

.parcelas-mini { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.parcela-dot {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: .68rem; font-weight: 700;
  border: 1px solid var(--border); color: var(--text-muted);
  transition: transform var(--transition);
}
.parcela-dot:hover { transform: scale(1.08); }
.parcela-dot.aprovado { background: var(--success-bg); border-color: rgba(34,197,94,.4); color: var(--success); }
.parcela-dot.aguardando { background: var(--warning-bg); border-color: rgba(245,158,11,.4); color: var(--warning); }
.parcela-dot.pendente { background: var(--bg-hover); }

/* Calendar */
.cal-nav { display: flex; align-items: center; gap: 8px; }
#cal-month-label { font-weight: 600; min-width: 150px; text-align: center; font-size: .9rem; }
.calendar-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(90px, 1fr)); gap: 5px; min-width: 640px; }
.cal-day-name {
  text-align: center; font-size: .72rem; font-weight: 600;
  color: var(--text-muted); padding: 8px 0; text-transform: uppercase;
  letter-spacing: .05em;
}
.cal-day {
  min-height: 88px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px; background: var(--bg);
  font-size: .76rem; transition: border-color var(--transition);
}
.cal-day.other-month { opacity: .25; }
.cal-day.today { border-color: var(--primary); background: rgba(30,58,138,.04); }
.cal-day-num { font-weight: 600; margin-bottom: 5px; font-size: .8rem; }
.cal-event {
  padding: 3px 6px; border-radius: 5px; margin-bottom: 3px;
  font-size: .65rem; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.cal-event.pendente { background: var(--bg-hover); color: var(--text-muted); }
.cal-event.aguardando { background: var(--warning-bg); color: var(--warning); }
.cal-event.aprovado { background: var(--success-bg); color: var(--success); }
.cal-legend {
  display: flex; flex-wrap: wrap; gap: 16px; margin-top: 16px;
  font-size: .8rem; color: var(--text-muted);
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-pendente { background: var(--text-muted); }
.dot-aguardando { background: var(--warning); }
.dot-aprovado { background: var(--success); }

/* Notifications */
.notif-btn {
  position: relative; background: var(--bg-hover); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 11px; cursor: pointer;
  color: var(--text); line-height: 0; transition: all var(--transition);
}
.notif-btn:hover { border-color: var(--border-light); background: var(--bg-elevated); }
.notif-btn svg { width: 18px; height: 18px; }
.notif-badge {
  position: absolute; top: -5px; right: -5px;
  background: var(--danger); color: #fff;
  font-size: .62rem; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px; border: 2px solid var(--bg-card);
}

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px; backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 18px; width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow);
  animation: modalIn .25s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(.96) translateY(8px); } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 22px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg-card); z-index: 1;
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close {
  background: var(--bg-hover); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-muted);
  cursor: pointer; padding: 6px; line-height: 0;
  transition: all var(--transition);
}
.modal-close:hover { color: var(--text); border-color: var(--border-light); }
.modal-close svg { width: 18px; height: 18px; }
.modal-body { padding: 22px; }
.modal-footer {
  padding: 16px 22px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap;
}
.comprovante-img {
  width: 100%; max-height: 420px; object-fit: contain;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}

/* Toast */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 18px;
  box-shadow: var(--shadow); font-size: .88rem; font-weight: 500;
  animation: slideIn .3s ease; max-width: 360px;
  display: flex; align-items: center; gap: 10px;
}
.toast.success { border-color: rgba(34,197,94,.4); }
.toast.error { border-color: rgba(239,68,68,.4); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } }

/* Empty state */
.empty-state {
  text-align: center; padding: 32px 20px; color: var(--text-muted);
}
.empty-state svg { width: 40px; height: 40px; opacity: .35; margin-bottom: 12px; }
.empty-state p { font-size: .88rem; }

.page { display: none; }
.page.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } }

/* Dashboard layout */
.dashboard-layout {
  display: grid; grid-template-columns: 1fr 340px; gap: 22px; align-items: start;
}
.dashboard-main { min-width: 0; }
.dashboard-sidebar {
  display: flex; flex-direction: column; gap: 16px;
  position: sticky; top: calc(68px + 16px);
}

.alert-banner {
  background: linear-gradient(135deg, rgba(245,158,11,.15), rgba(239,68,68,.08));
  border: 1px solid rgba(245,158,11,.35); border-radius: var(--radius-sm);
  padding: 14px 18px; margin-bottom: 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.alert-banner p { font-size: .88rem; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.alert-banner p svg { width: 18px; height: 18px; color: var(--warning); }

.quick-actions { display: flex; flex-direction: column; gap: 8px; }
.quick-action-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-size: .85rem; font-weight: 600;
  cursor: pointer; transition: all var(--transition); font-family: inherit; width: 100%;
  text-align: left;
}
.quick-action-btn:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.quick-action-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

/* Compact calendar sidebar */
.cal-card-compact .card-body { padding: 12px 16px 16px; }
.cal-nav-compact {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.cal-nav-compact span { font-weight: 700; font-size: .85rem; }
.cal-nav-compact .btns { display: flex; gap: 4px; }
.cal-nav-btn {
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-card);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted); transition: all var(--transition);
}
.cal-nav-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.calendar-compact { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.calendar-compact .cal-dow {
  text-align: center; font-size: .6rem; font-weight: 700;
  color: var(--text-muted); padding: 4px 0;
}
.calendar-compact .cal-day {
  aspect-ratio: 1; min-height: 34px; border-radius: 8px;
  border: 1px solid transparent; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: .72rem;
  font-weight: 600; cursor: default; position: relative; padding: 2px;
}
.calendar-compact .cal-day.has-event { cursor: pointer; }
.calendar-compact .cal-day.has-event:hover { background: var(--primary-soft); border-color: rgba(30,58,138,.2); }
.calendar-compact .cal-day.today { background: var(--primary-soft); color: var(--primary); }
.calendar-compact .cal-day.selected { background: var(--primary); color: #fff; }
.calendar-compact .cal-dots { display: flex; gap: 2px; margin-top: 1px; }
.calendar-compact .cal-dot { width: 4px; height: 4px; border-radius: 50%; }
.cal-legend.compact { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); gap: 8px; font-size: .68rem; }

.desktop-only { display: block; }
.mobile-only { display: none; }

/* Mobile bar */
.mobile-bar {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-card); border-top: 1px solid var(--border);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  z-index: 60; box-shadow: 0 -4px 24px rgba(0,0,0,.25);
}
.mobile-bar-inner { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.mobile-bar-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px; border: none; background: none;
  color: var(--text-muted); font-size: .62rem; font-weight: 600;
  cursor: pointer; border-radius: 10px; font-family: inherit;
  position: relative; transition: all .15s;
}
.mobile-bar-btn svg { width: 20px; height: 20px; }
.mobile-bar-btn.active, .mobile-bar-btn:hover { color: var(--primary); background: var(--primary-soft); }
.mb-badge {
  position: absolute; top: 2px; right: calc(50% - 22px);
  background: var(--danger); color: #fff; font-size: .55rem; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; border: 2px solid var(--bg-card);
}

.pendencia-banner {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-radius: var(--radius-sm); margin-bottom: 14px; font-size: .84rem; font-weight: 600;
}
.pendencia-banner.comprovante { background: rgba(234,179,8,.12); color: #b45309; border: 1px solid rgba(234,179,8,.25); }
.pendencia-banner.previsao { background: rgba(37,99,235,.1); color: #1d4ed8; border: 1px solid rgba(37,99,235,.2); }
.pendencia-banner.adiantamento { background: rgba(168,85,247,.1); color: #7c3aed; border: 1px solid rgba(168,85,247,.22); }
.pendencia-contador {
  font-size: .72rem; font-weight: 700; color: var(--text-muted);
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 999px; margin-left: 8px;
}
.pendencia-fila-hint {
  margin-top: 12px; font-size: .78rem; color: var(--text-muted);
  display: flex; align-items: center; gap: 6px;
}
.quitar-opcional {
  margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border);
}
.quitar-label {
  display: flex; align-items: center; gap: 6px; font-size: .8rem;
  color: var(--text-muted); margin-bottom: 8px;
}
.quitar-file {
  width: 100%; font-size: .78rem; color: var(--text-muted);
}

.modal-handle {
  width: 40px; height: 4px; background: var(--border-light);
  border-radius: 2px; margin: 10px auto 0; flex-shrink: 0;
}

/* Event detail in modal */
.event-detail-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px; margin-bottom: 12px;
}
.event-detail-card .valor { font-size: 1.4rem; font-weight: 800; color: var(--primary); margin: 8px 0; }
.detail-row {
  display: flex; justify-content: space-between; padding: 8px 0;
  border-bottom: 1px solid var(--border); font-size: .85rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-row .lbl { color: var(--text-muted); }

/* Responsive */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-layout { grid-template-columns: 1fr 300px; }
}

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .calc-parcelas-grid { grid-template-columns: 1fr; }
  .desktop-only { display: none !important; }
  .mobile-only { display: block !important; }
  .mobile-bar { display: block; }
  .dashboard-layout { grid-template-columns: 1fr; }
  .content { padding: 16px 16px calc(72px + 16px); }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-overlay.center-mobile { align-items: center; padding: 16px; }
  .modal { border-radius: 20px 20px 0 0; max-height: 92vh; animation: slideUp .3s ease; }
  .modal-overlay.center-mobile .modal { border-radius: var(--radius); animation: modalIn .25s ease; }
  @keyframes slideUp { from { transform: translateY(100%); } }
  .modal-footer { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: flex; }
  .topbar { padding: 12px 16px; }
  .stat-card .stat-value { font-size: 1.15rem; }
  .list-item { flex-wrap: wrap; }
  .list-item-actions { width: 100%; justify-content: flex-end; }
  .cobranca-card-header { flex-direction: column; }
  .link-box { flex-direction: column; align-items: stretch; }
  .link-box button { width: 100%; }
  .modal-footer { flex-direction: column; }
  .modal-footer .btn { width: 100%; }
  .toast-container { left: 16px; right: 16px; bottom: calc(72px + 12px); }
  .toast { max-width: none; }
}

@media (min-width: 901px) {
  .modal-overlay { align-items: center; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .cal-day { min-height: 72px; }
  .card-header { padding: 14px 16px; }
  .card-body { padding: 16px; }
}