:root {
  --bg: #0b1220;
  --bg-2: #0f1830;
  --surface: rgba(255,255,255,0.04);
  --surface-2: rgba(255,255,255,0.06);
  --surface-3: rgba(255,255,255,0.09);
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.16);
  --text: #eaf0ff;
  --text-dim: #8a97b8;
  --text-soft: #b8c2d9;
  --accent: #60b6c7;
  --accent-2: #b2d8dc;
  --accent-deep: #3f8c9c;
  --teal-mint: #6ee7d8;
  --lavanda: #c1baf0;
  --warn: #f5b461;
  --danger: #ef6b6b;
  --gold: #d4b572;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --shadow: 0 10px 40px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background:
    radial-gradient(1200px 600px at 10% -10%, #133b48 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 0%, #1f2a55 0%, transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  letter-spacing: -0.005em;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence baseFrequency='0.9' numOctaves='2'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.35'/></svg>");
  opacity: 0.05; mix-blend-mode: overlay;
}
.glow { position: fixed; border-radius: 50%; filter: blur(90px); opacity: 0.32; pointer-events: none; z-index: 0; }
.glow-a { width: 520px; height: 520px; background: var(--accent); top: -200px; left: -100px; }
.glow-b { width: 420px; height: 420px; background: var(--lavanda); bottom: -150px; right: -100px; opacity: 0.22; }

/* === Topbar === */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 24px;
  padding: 14px 32px;
  background: rgba(11, 18, 32, 0.78);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  font-family: 'Fraunces', serif; font-weight: 700; font-size: 18px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--lavanda) 100%);
  color: #0b1220; border-radius: 12px;
  box-shadow: 0 6px 20px rgba(96,182,199,0.35);
  letter-spacing: -0.04em;
}
.brand-divider { width: 1px; height: 28px; background: var(--border-strong); }
.brand-name { font-family: 'Fraunces', serif; font-size: 17px; font-weight: 500; line-height: 1; }
.brand-name em { color: var(--accent); font-style: normal; }
.brand-sub { font-size: 10px; color: var(--text-dim); letter-spacing: 0.18em; text-transform: uppercase; margin-top: 4px; }

.topnav { display: flex; gap: 2px; margin-left: auto; }
.topnav a {
  padding: 8px 14px; border-radius: 8px;
  color: var(--text-dim);
  font-size: 13px; font-weight: 500;
  transition: all 0.18s;
}
.topnav a:hover { color: var(--text); background: var(--surface); }
.topnav a.active { color: var(--text); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }

.topbar-actions { display: flex; gap: 8px; align-items: center; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: 13px; cursor: pointer;
  transition: all 0.18s;
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border-strong); transform: translateY(-1px); }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 4px 4px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 12px;
}
.user-chip .avatar {
  width: 30px; height: 30px; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--lavanda));
  display: grid; place-items: center;
  font-weight: 600; color: #0b1220; font-size: 12px;
  font-family: 'Fraunces', serif;
}
.user-chip .name { color: var(--text); font-weight: 500; }
.user-chip .role { color: var(--text-dim); font-size: 11px; }

/* Mobile nav */
.nav-toggle {
  display: none;
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); cursor: pointer;
  padding: 0; align-items: center; justify-content: center;
  flex-direction: column; gap: 4px;
}
.nav-toggle span { display: block; width: 18px; height: 2px; border-radius: 2px; background: currentColor; transition: all 0.2s; }
body.nav-open .nav-toggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
body.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
body.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 980px) {
  .nav-toggle { display: inline-flex; }
  .topnav {
    position: fixed; inset: 64px 0 0 0;
    flex-direction: column; gap: 4px;
    padding: 24px;
    background: rgba(11, 18, 32, 0.96);
    backdrop-filter: blur(22px);
    transform: translateY(-12px); opacity: 0; visibility: hidden;
    transition: all 0.28s;
  }
  body.nav-open .topnav { transform: translateY(0); opacity: 1; visibility: visible; }
  .topnav a { padding: 14px 16px; font-size: 15px; }
  .user-chip .name, .user-chip .role { display: none; }
  .user-chip { padding: 4px; }
}

/* === Main === */
.main { position: relative; z-index: 1; max-width: 1480px; margin: 0 auto; padding: 32px 32px 80px; }

h1, h2, h3, h4 { font-family: 'Fraunces', serif; font-weight: 500; letter-spacing: -0.025em; color: var(--text); }
h1 { font-size: 32px; margin: 0 0 6px; }
h2 { font-size: 22px; margin: 28px 0 16px; }
h3 { font-size: 16px; margin: 0 0 12px; font-weight: 600; }
.sub { color: var(--text-dim); font-size: 14px; }

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
  margin-bottom: 28px;
}
.page-head .actions { display: flex; gap: 8px; }

.flash {
  padding: 12px 18px; border-radius: var(--r-md);
  margin-bottom: 18px;
  font-size: 13px;
  border: 1px solid var(--border);
}
.flash-ok { background: rgba(110, 231, 216, 0.08); border-color: rgba(110, 231, 216, 0.25); color: var(--teal-mint); }
.flash-erro { background: rgba(239, 107, 107, 0.08); border-color: rgba(239, 107, 107, 0.3); color: #ff8a8a; }
.flash-info { background: var(--surface); border-color: var(--border); color: var(--text-soft); }

/* === KPI === */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 22px;
  position: relative; overflow: hidden;
  transition: all 0.22s;
  display: flex; flex-direction: column; gap: 6px;
}
.kpi:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: 0 14px 36px rgba(0,0,0,0.28); }
.kpi::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--lavanda));
  opacity: 0; transition: opacity 0.22s;
}
.kpi:hover::before { opacity: 1; }
.kpi-label { font-size: 10.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.14em; font-weight: 600; }
.kpi-value { font-family: 'Fraunces', serif; font-size: clamp(20px, 2.2vw, 26px); font-weight: 500; line-height: 1.05; color: var(--text); margin-top: 2px; white-space: nowrap; }
.kpi-value small { font-size: 13px; color: var(--text-dim); font-family: 'Inter', sans-serif; margin-left: 4px; font-weight: 400; }
.kpi-foot { font-size: 11.5px; color: var(--text-dim); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-foot.up { color: var(--teal-mint); }
.kpi-foot.warn { color: var(--warn); }
.kpi-foot.down { color: var(--danger); }
.kpi.gold { background: linear-gradient(135deg, rgba(212,181,114,0.12), rgba(212,181,114,0.04)); border-color: rgba(212,181,114,0.22); }
.kpi.gold .kpi-value { color: var(--gold); }
.kpi.warn-card { border-color: rgba(245,180,97,0.3); background: rgba(245,180,97,0.05); }
a.kpi { text-decoration: none; cursor: pointer; }

/* === Panels === */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 24px;
  margin-bottom: 20px;
  position: relative;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.panel-head h3 { margin: 0; }
.panel-head .actions { display: flex; gap: 6px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }
.grid-1-2 { grid-template-columns: 1fr 2fr; }
@media (max-width: 1100px) { .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; } .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* === Tables === */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; padding: 10px 12px;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-dim); font-weight: 600;
  border-bottom: 1px solid var(--border);
}
table.tbl td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tr:hover td { background: var(--surface); }
table.tbl a:hover { color: var(--accent); }

/* === Badges === */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-soft);
}
.badge-teal { background: rgba(96,182,199,0.12); color: var(--accent); border-color: rgba(96,182,199,0.3); }
.badge-mint { background: rgba(110,231,216,0.1); color: var(--teal-mint); border-color: rgba(110,231,216,0.28); }
.badge-lav { background: rgba(193,186,240,0.1); color: var(--lavanda); border-color: rgba(193,186,240,0.28); }
.badge-gold { background: rgba(212,181,114,0.12); color: var(--gold); border-color: rgba(212,181,114,0.28); }
.badge-warn { background: rgba(245,180,97,0.12); color: var(--warn); border-color: rgba(245,180,97,0.3); }
.badge-danger { background: rgba(239,107,107,0.12); color: #ff8a8a; border-color: rgba(239,107,107,0.3); }
.badge-on { background: rgba(110,231,216,0.1); color: var(--teal-mint); border-color: rgba(110,231,216,0.28); }
.badge-off { background: rgba(138,151,184,0.08); color: var(--text-dim); border-color: var(--border); }
.dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; display: inline-block; }

/* === Forms === */
.form { display: grid; gap: 14px; }
.form-row { display: grid; gap: 6px; }
.form-row label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text);
  font-family: inherit; font-size: 14px;
  transition: all 0.18s;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none; border-color: var(--accent); background: var(--surface-2);
  box-shadow: 0 0 0 3px rgba(96,182,199,0.15);
}
.form-row textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
.form-cols { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.form-cols-3 { display: grid; gap: 14px; grid-template-columns: repeat(3, 1fr); }
@media (max-width: 700px) { .form-cols, .form-cols-3 { grid-template-columns: 1fr; } }
.form-foot { display: flex; gap: 10px; margin-top: 12px; align-items: center; flex-wrap: wrap; }
.form-foot .spacer { margin-left: auto; }

.checkrow {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); cursor: pointer;
  transition: all 0.16s;
}
.checkrow:hover { background: var(--surface-2); border-color: var(--border-strong); }
.checkrow input { width: auto; }

/* === Buttons === */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: white; font-weight: 600; font-size: 13px;
  border: 0; cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 6px 18px rgba(96,182,199,0.28);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(96,182,199,0.38); }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-danger { background: linear-gradient(135deg, #ef6b6b, #c5494b); box-shadow: 0 6px 18px rgba(239,107,107,0.25); }
.btn-icon { padding: 8px 10px; }

/* === Filtros === */
.filtros {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 22px;
}
.filtros .chip {
  padding: 6px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 12.5px; cursor: pointer;
  transition: all 0.18s;
}
.filtros .chip:hover { background: var(--surface-2); color: var(--text); }
.filtros .chip.on { background: rgba(96,182,199,0.16); color: var(--accent); border-color: var(--accent); }
.filtros input[type=search], .filtros input[type=text], .filtros input[type=date], .filtros select {
  flex: 1; min-width: 220px;
  padding: 8px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: 13px;
}

/* === Login === */
.login-page {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 40px 20px;
}
.login-card {
  width: 100%; max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 44px 40px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  position: relative; z-index: 1;
}
.login-card .brand-mark { width: 60px; height: 60px; margin: 0 auto 18px; font-size: 26px; }
.login-card .brand-name { text-align: center; font-size: 22px; font-weight: 500; }
.login-card .brand-sub { text-align: center; font-size: 11px; margin-top: 6px; }
.login-card form { margin-top: 28px; display: grid; gap: 14px; }
.login-card .btn { width: 100%; justify-content: center; padding: 14px; font-size: 14px; }

/* === Empty state === */
.empty {
  text-align: center; padding: 72px 24px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text-dim);
}
.empty h3 { color: var(--text-soft); margin-bottom: 6px; }

/* === Dashboard charts === */
.chart-wrap { position: relative; min-height: 240px; }
.chart-wrap canvas { max-width: 100%; }

/* === Mini lists === */
.mini-list { display: grid; gap: 10px; }
.mini-item { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.mini-item:last-child { border-bottom: 0; }
.mini-item .ico {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--surface-2);
  display: grid; place-items: center;
  font-family: 'Fraunces', serif; color: var(--accent);
  font-weight: 600; font-size: 14px; flex-shrink: 0;
}
.mini-item .body { flex: 1; min-width: 0; }
.mini-item .body .t { font-size: 13px; font-weight: 500; color: var(--text); }
.mini-item .body .s { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
.mini-item .right { font-family: 'Fraunces', serif; font-size: 14px; color: var(--text); text-align: right; }
.mini-item .right small { display: block; font-size: 11px; color: var(--text-dim); font-family: 'Inter', sans-serif; }

/* === Bar (proportional) === */
.bar { width: 100%; height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.bar > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--lavanda)); border-radius: 999px; }

/* === DL === */
.dl { display: grid; grid-template-columns: 180px 1fr; gap: 8px 18px; font-size: 13px; }
.dl dt { color: var(--text-dim); }
.dl dd { margin: 0; color: var(--text-soft); }

/* === Helpers === */
.text-muted { color: var(--text-dim); }
.text-soft { color: var(--text-soft); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-18 { gap: 18px; }
.mt-0 { margin-top: 0; }
.mt-12 { margin-top: 12px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-24 { margin-bottom: 24px; }
.hidden { display: none !important; }

/* === Avatar === */
.avatar-sm {
  width: 28px; height: 28px; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--lavanda));
  display: inline-grid; place-items: center;
  font-family: 'Fraunces', serif; font-weight: 600; font-size: 12px;
  color: #0b1220;
}

/* Tabela de share/rateio */
.tbl-edit { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
.tbl-edit th { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-dim); font-weight: 600; padding: 0 10px 4px; text-align: left; }
.tbl-edit td { background: var(--surface); padding: 6px 10px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.tbl-edit td:first-child { border-left: 1px solid var(--border); border-radius: 10px 0 0 10px; }
.tbl-edit td:last-child { border-right: 1px solid var(--border); border-radius: 0 10px 10px 0; }
.tbl-edit input, .tbl-edit select { padding: 8px 10px; font-size: 13px; }

/* === Kanban (leads) === */
.kanban {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 14px;
}
@media (max-width: 1100px) { .kanban { grid-template-columns: repeat(3, minmax(220px, 1fr)); } }
@media (max-width: 760px) { .kanban { grid-template-columns: repeat(2, minmax(200px, 1fr)); } }
@media (max-width: 520px) { .kanban { grid-template-columns: 1fr; } }

.kanban-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 200px;
}
.kanban-head { display: flex; align-items: center; justify-content: space-between; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.kanban-count { font-family: 'Fraunces', serif; font-size: 18px; color: var(--text-soft); }
.kanban-body { display: flex; flex-direction: column; gap: 8px; }
.kanban-empty { font-size: 12px; color: var(--text-dim); padding: 14px 6px; text-align: center; font-style: italic; }
.kanban-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  transition: all 0.18s;
  cursor: grab;
}
.kanban-card:active { cursor: grabbing; }
.kanban-card-link { display: block; text-decoration: none; color: inherit; }
.kanban-card:hover { background: var(--surface-3); border-color: var(--border-strong); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,0,0,0.22); }
.kanban-card.dragging { opacity: 0.45; transform: rotate(-1deg); }
.kanban-card.saved { border-color: var(--teal-mint); box-shadow: 0 0 0 2px rgba(110,231,216,0.35); }
.kanban-col.over { border-color: var(--accent); background: rgba(96,182,199,0.08); box-shadow: 0 0 0 2px rgba(96,182,199,0.18); }
.kanban-col { transition: all 0.16s; }
.kanban-card-name { font-weight: 600; font-size: 13.5px; color: var(--text); }
.kanban-card-line { margin-top: 3px; }
.kanban-card-foot { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.kanban-tag { font-size: 10.5px; color: var(--text-dim); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; }

/* Calculadora destaque */
.calc-card {
  background: linear-gradient(135deg, rgba(96,182,199,0.14), rgba(193,186,240,0.08));
  border: 1px solid rgba(96,182,199,0.28);
  border-radius: var(--r-md);
  padding: 18px 20px;
  margin-top: 14px;
}
.calc-card .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); font-weight: 700; }
.calc-card .value { font-family: 'Fraunces', serif; font-size: 22px; color: var(--text); margin-top: 4px; }
.calc-card .hint { font-size: 11.5px; color: var(--text-dim); margin-top: 4px; }
