:root {
  /* Paleta Oficial BPMake (MakePro Tricolor + Makedrive Cobalt) */
  --bp-blue: #0d38f5;
  --bp-blue-dark: #051c8a;
  --bp-magenta: #de12d3;
  --bp-orange: #f96302;

  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-alt: #f8fafd;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #0d38f5;
  --accent-hover: #092ac4;
  --accent-soft: rgba(13, 56, 245, 0.09);
  --accent2: #de12d3;
  --ok: #15803d;
  --ok-soft: rgba(21, 128, 61, 0.11);
  --warn: #ea580c;
  --warn-soft: rgba(249, 99, 2, 0.12);
  --bad: #dc2626;
  --bad-soft: rgba(220, 38, 38, 0.11);
  --nubank: #7c3aed;
  --shadow: 0 4px 18px rgba(15, 23, 42, 0.05);
}

body.dark {
  --bg: #0b0f19;
  --panel: #131926;
  --panel-alt: #1a2234;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --line: #263147;
  --accent: #4d73ff;
  --accent-hover: #6989ff;
  --accent-soft: rgba(77, 115, 255, 0.16);
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.14);
  --warn: #fb923c;
  --warn-soft: rgba(251, 146, 60, 0.15);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, 0.15);
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.48 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* Barra Tricolor Oficial MakePro / BPMake */
.bpmake-tricolor-bar {
  height: 4px;
  width: 100%;
  background: linear-gradient(90deg, var(--bp-magenta) 0%, var(--bp-blue) 52%, var(--bp-orange) 100%);
}
.bpmake-tricolor-bar.side-bar {
  margin: -16px -14px 14px;
  width: calc(100% + 28px);
}

/* Branding BPMake & Makedrive */
.bpmake-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 12px;
}
.bpmake-hex {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 8px rgba(13, 56, 245, 0.16));
}
.bpmake-hex.sm { width: 36px; height: 36px; }
.bpmake-wordmark {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.10em;
  color: var(--text);
  line-height: 1.05;
}
.bpmake-wordmark.sm { font-size: 16.5px; letter-spacing: 0.09em; }
.bpmake-tagline {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 2px;
}

.ws-pill {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  border-radius: 9px;
  background: var(--panel-alt);
  border: 1px solid var(--line);
  margin-bottom: 10px;
  font-size: 12.2px;
}
.ws-pill small { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
.ws-pill b { color: var(--text); font-weight: 700; }
.ws-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bp-magenta), var(--bp-blue));
  box-shadow: 0 0 0 3px var(--accent-soft);
  flex-shrink: 0;
}

/* Auth Gate — Inspirado no Glow Azul Profundo da Makedrive */
.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 255, 255, 0.16) 0%, rgba(13, 56, 245, 0.35) 28%, transparent 65%),
    linear-gradient(155deg, #020d47 0%, #062199 52%, #041366 100%);
}
.auth-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 8, 46, 0.55);
}
.auth-card-inner { padding: 28px 30px 22px; }
.auth-brand { margin-bottom: 14px; }
.auth-ws-pill { margin-bottom: 16px; }
.auth-form { display: grid; gap: 12px; }
.auth-form label { display: grid; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.auth-form input { padding: 10px 12px; font-size: 14px; }
.auth-form button.primary { padding: 11px; font-weight: 700; font-size: 14px; }
.auth-msg {
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  background: var(--panel-alt);
}
.auth-msg.err { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.auth-msg.ok { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }

.chg-title { margin: 0 0 6px; font-size: 16px; color: var(--text); }
.chg-sub { font-size: 12.5px; margin: 0 0 14px; line-height: 1.45; }
.verify-box { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.code-inp { text-align: center; letter-spacing: 6px; font-weight: 800; font-size: 19px !important; }

.makedrive-sig {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.makedrive-sig b { color: var(--bp-blue); font-weight: 800; }
body.dark .makedrive-sig b { color: var(--accent); }
.mkd-honeycomb { color: var(--bp-blue); font-size: 12px; vertical-align: middle; margin-right: 3px; }
.makedrive-foot {
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.11em;
  color: var(--muted);
  padding-top: 4px;
}

/* App Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 266px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px 14px 12px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}

.nav-group-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 11px 8px 4px;
}
#mainNav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 9px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 500;
  font-size: 13.2px;
  margin-bottom: 2px;
  transition: all 0.14s ease;
  text-decoration: none;
}
#mainNav a:hover { background: var(--bg); color: var(--text); }
#mainNav a.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 3px 10px rgba(13, 56, 245, 0.25);
}
.nav-badge {
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}
.nav-badge.warn { background: var(--warn-soft); color: var(--warn); }
#mainNav a.active .nav-badge { background: rgba(255,255,255,0.22); color: #fff; }

.sidefoot { margin-top: auto; padding-top: 10px; display: grid; gap: 7px; }
.quick-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.user-box {
  border-top: 1px solid var(--line);
  padding-top: 9px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.user-box b { display: block; color: var(--text); }
.user-box small { display: block; color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; }

main { flex: 1; min-width: 0; padding: 0 26px 36px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 0 -26px 18px;
  padding: 14px 26px;
  position: sticky;
  top: 0;
  z-index: 25;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar h1 { font-size: 19px; margin: 0; letter-spacing: -0.01em; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Controls & Buttons */
button, select, input, textarea {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 11px;
  transition: border-color 0.14s ease, background 0.14s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
button { cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.ok-btn { background: var(--ok-soft); border-color: rgba(21,128,61,0.35); color: var(--ok); font-weight: 600; }
button.warn-btn { background: var(--warn-soft); border-color: rgba(249,99,2,0.35); color: var(--warn); font-weight: 600; }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: var(--panel); border-color: var(--line); }
button.danger { color: var(--bad); }
button.sm { padding: 4.5px 9px; font-size: 12px; border-radius: 6px; }
.icon-btn { padding: 5px 8px; }

/* Cards & Grids */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.grid { display: grid; gap: 14px; margin-bottom: 16px; }
.g6 { grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(390px, 1fr)); }
@media (max-width: 860px) { .g2, .g3 { grid-template-columns: 1fr; } }

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi small { color: var(--muted); font-size: 11.8px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.kpi b { font-size: 21px; letter-spacing: -0.02em; }
.kpi .sub { font-size: 11.8px; color: var(--muted); }
.kpi.nubank { border-left: 4px solid var(--nubank); }
.kpi.accent { border-left: 4px solid var(--bp-blue); }
.kpi.magenta { border-left: 4px solid var(--bp-magenta); }
.kpi.ok { border-left: 4px solid var(--ok); }
.kpi.warn { border-left: 4px solid var(--bp-orange); }

/* Sub-tabs & Filters */
.subtabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.subtabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 13px;
  font-size: 12.8px;
  border-radius: 7px;
  font-weight: 600;
}
.subtabs button.active {
  background: var(--accent);
  color: #fff;
}
.filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.filters input[type="search"], .filters input[type="text"] { min-width: 210px; }

/* Tables */
.tablewrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  max-height: 66vh;
}
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8.5px 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th.r, td.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
th {
  position: sticky;
  top: 0;
  background: var(--panel-alt);
  z-index: 3;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--accent-soft); }
tr.tot-row td { font-weight: 700; background: var(--panel-alt); border-top: 2px solid var(--line); }
tr.dre-sub td { font-weight: 700; background: var(--panel-alt); }
tr.dre-hi td { font-weight: 700; background: var(--accent-soft); color: var(--text); }

/* Tags & Badges */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8.5px;
  border-radius: 999px;
  font-size: 11.2px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--panel-alt);
  color: var(--text);
  white-space: nowrap;
}
.tag.ok { background: var(--ok-soft); border-color: rgba(21,128,61,0.3); color: var(--ok); }
.tag.warn { background: var(--warn-soft); border-color: rgba(249,99,2,0.3); color: var(--warn); }
.tag.bad { background: var(--bad-soft); border-color: rgba(220,38,38,0.3); color: var(--bad); }
.tag.accent { background: var(--accent-soft); border-color: rgba(13,56,245,0.3); color: var(--accent); }
.tag.nubank { background: rgba(124,58,237,0.12); border-color: rgba(124,58,237,0.3); color: var(--nubank); }

.wa-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(37, 211, 102, 0.13);
  color: #15803d;
  font-weight: 600;
  font-size: 11.5px;
  text-decoration: none;
  border: 1px solid rgba(37, 211, 102, 0.35);
}
body.dark .wa-link { color: #4ade80; }
.wa-link:hover { filter: brightness(0.95); }

/* Kanban Board */
.kanban {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 12px;
  align-items: start;
}
.kb-col {
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  display: grid;
  gap: 8px;
  max-height: 72vh;
  overflow-y: auto;
}
.kb-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 4px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 700;
}
.kb-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px;
  display: grid;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.kb-card:hover { transform: translateY(-1px); border-color: var(--accent); }
.kb-card b { font-size: 13px; line-height: 1.35; }

/* Progress Bar */
.pbar { height: 7px; background: var(--line); border-radius: 99px; overflow: hidden; min-width: 80px; }
.pbar > i { display: block; height: 100%; background: var(--bp-blue); border-radius: 99px; }

/* Modal Dialog */
dialog {
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
  color: var(--text);
  padding: 22px;
  width: min(760px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}
dialog.wide { width: min(1020px, 96vw); }
dialog::backdrop { background: rgba(8, 15, 36, 0.55); backdrop-filter: blur(2px); }
.dlg-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.dlg-head h2 { margin: 0; font-size: 17px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-grid label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.dlg-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

/* Info Tooltip */
.tip {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 700;
  font-style: normal;
  cursor: help;
}

/* Utilities */
.pos { color: var(--ok); font-weight: 600; }
.neg { color: var(--bad); font-weight: 600; }
.warn-txt { color: var(--warn); font-weight: 600; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11.5px; }

/* Toast */
.toast-box { position: fixed; bottom: 18px; right: 18px; z-index: 120; display: grid; gap: 8px; }
.toast {
  background: #0f172a;
  color: #fff;
  padding: 10px 15px;
  border-radius: 9px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

/* Responsive Sidebar */
.mobile-menu-btn { display: none; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 45; }
body.sidebar-collapsed .sidebar { display: none; }
body.sidebar-collapsed .mobile-menu-btn { display: inline-flex; }
@media (max-width: 960px) {
  .mobile-menu-btn { display: inline-flex; }
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 50;
    transform: translateX(-104%);
    transition: transform 0.2s ease;
  }
  body.mobile-open .sidebar { transform: translateX(0); }
  body.mobile-open .sidebar-backdrop { display: block; }
  main { padding: 0 14px 28px; }
  .topbar { margin: 0 -14px 14px; padding: 12px 14px; }
}
