/* ==========================================================================
   UDP Flow - Design System
   Identidade: verde (crescimento, confiança, modernidade e eficiência)
   ========================================================================== */
:root {
  --ink-950: #021a0f;
  --ink-900: #052e1a;
  --ink-800: #0a4026;
  --ink-700: #0f5733;
  --brand-50: #f0fdf4;
  --brand-100: #dcfce7;
  --brand-200: #bbf7d0;
  --brand-300: #86efac;
  --brand-400: #4ade80;
  --brand-500: #22c55e;
  --brand-600: #16a34a;
  --brand-700: #15803d;
  --brand-800: #166534;
  --lime: #bef264;
  --brand: #16a34a;
  --pos: #16a34a;
  --pos-dark: #15803d;
  --neg: #dc2626;

  --bg: #f3f8f5;
  --surface: #ffffff;
  --surface-2: #f8fbf9;
  --line: #e2ebe5;
  --line-strong: #cddad2;
  --text: #0e1f16;
  --muted: #5e7066;
  --faint: #8a9a90;

  --red: #dc2626;
  --red-bg: #fee2e2;
  --amber: #d97706;
  --blue: #0369a1;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(5, 46, 26, .05);
  --shadow: 0 1px 2px rgba(5, 46, 26, .04), 0 10px 28px -14px rgba(5, 46, 26, .18);
  --shadow-lg: 0 24px 60px -20px rgba(2, 26, 15, .45);
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --sidebar-w: 268px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.5; color: var(--text);
  background: var(--bg); -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
img, svg { max-width: 100%; }
.icon { width: 1.15em; height: 1.15em; flex-shrink: 0; vertical-align: -.2em; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }

/* ---------- Identidade visual da empresa (cor primária personalizada) ----------
   Basta definir --brand; o restante da paleta é derivado dele. */
:root.branded {
  --brand-600: var(--brand);
  --brand-700: color-mix(in srgb, var(--brand) 82%, #000);
  --brand-800: color-mix(in srgb, var(--brand) 66%, #000);
  --brand-500: color-mix(in srgb, var(--brand) 86%, #fff);
  --brand-400: color-mix(in srgb, var(--brand) 68%, #fff);
  --brand-300: color-mix(in srgb, var(--brand) 46%, #fff);
  --brand-200: color-mix(in srgb, var(--brand) 28%, #fff);
  --brand-100: color-mix(in srgb, var(--brand) 16%, #fff);
  --brand-50: color-mix(in srgb, var(--brand) 7%, #fff);
  --ink-950: color-mix(in srgb, var(--brand) 14%, #000);
  --ink-900: color-mix(in srgb, var(--brand) 24%, #000);
  --ink-800: color-mix(in srgb, var(--brand) 38%, #000);
  --ink-700: color-mix(in srgb, var(--brand) 50%, #000);
  --lime: color-mix(in srgb, var(--brand) 40%, #fff);
  --bg: color-mix(in srgb, var(--brand) 4%, #f6f7f7);
  --surface-2: color-mix(in srgb, var(--brand) 3%, #fafbfb);
  --line: color-mix(in srgb, var(--brand) 8%, #e4e7e5);
}

/* Cor do menu lateral / painel de login (independe da cor principal) */
:root.menu-custom {
  --ink-950: color-mix(in srgb, var(--menu) 14%, #000);
  --ink-900: color-mix(in srgb, var(--menu) 24%, #000);
  --ink-800: color-mix(in srgb, var(--menu) 38%, #000);
  --ink-700: color-mix(in srgb, var(--menu) 50%, #000);
}
:root.pos-custom { --pos-dark: color-mix(in srgb, var(--pos) 82%, #000); }
:root.neg-custom { --red: var(--neg); --red-bg: color-mix(in srgb, var(--neg) 14%, #fff); }

/* Menu claro: sidebar, painel de login e topo do portal embutido em tons claros */
:root.menu-light .sidebar { color: var(--muted); border-right: 1px solid var(--line);
  background: radial-gradient(520px 320px at -10% -8%, color-mix(in srgb, var(--brand-500) 12%, transparent), transparent 60%),
              linear-gradient(180deg, color-mix(in srgb, var(--menu, var(--brand)) 4%, #fff), color-mix(in srgb, var(--menu, var(--brand)) 9%, #fff)); }
:root.menu-light .brand { color: var(--text); }
:root.menu-light .brand-text b { color: var(--ink-950); }
:root.menu-light .nav a { color: color-mix(in srgb, var(--ink-900) 75%, #fff); }
:root.menu-light .nav a:hover { background: color-mix(in srgb, var(--brand-600) 8%, transparent); color: var(--ink-950); }
:root.menu-light .nav a.active { background: color-mix(in srgb, var(--brand-600) 13%, transparent); color: var(--brand-700); }
:root.menu-light .nav a.active .icon { color: var(--brand-700); }
:root.menu-light .nav a.active::before { background: var(--brand-600); }
:root.menu-light .nav-label { color: var(--faint); }
:root.menu-light .side-foot { border-top-color: var(--line); }
:root.menu-light .side-user { color: var(--text); }
:root.menu-light .side-user:hover { background: color-mix(in srgb, var(--brand-600) 8%, transparent); }
:root.menu-light .side-user .who span { color: var(--muted); }
:root.menu-light .auth-side { color: var(--text);
  background: radial-gradient(700px 420px at 0% 0%, color-mix(in srgb, var(--brand-500) 18%, transparent), transparent 60%),
              linear-gradient(160deg, color-mix(in srgb, var(--menu, var(--brand)) 7%, #fff), color-mix(in srgb, var(--menu, var(--brand)) 16%, #fff) 80%); }
:root.menu-light .auth-side::before { border-color: rgba(0,0,0,.05); box-shadow: 0 0 0 90px rgba(0,0,0,.02), 0 0 0 180px rgba(0,0,0,.015); }
:root.menu-light .auth-side .brand-text b { color: var(--ink-950); }
:root.menu-light .auth-side h2 { color: var(--ink-950); }
:root.menu-light .auth-side h2 span { color: var(--brand-600); }
:root.menu-light .auth-side p.lead { color: var(--muted); }
:root.menu-light .auth-pill { background: rgba(255,255,255,.7); border-color: var(--line); color: var(--ink-900); }
:root.menu-light .auth-pill .icon { color: var(--brand-600); }
:root.menu-light .auth-foot { color: var(--faint); }
:root.menu-light .embed-top { background: #fff; color: var(--text); border-bottom: 1px solid var(--line); }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 50; display: flex; flex-direction: column;
  color: rgba(255,255,255,.78); padding: 20px 14px 14px;
  background:
    radial-gradient(520px 320px at -10% -8%, color-mix(in srgb, var(--brand-500) 22%, transparent), transparent 60%),
    radial-gradient(420px 300px at 120% 105%, rgba(190, 242, 100, .10), transparent 60%),
    linear-gradient(180deg, var(--ink-900), var(--ink-950));
  transition: transform .25s ease;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 18px; color: #fff; text-decoration: none !important; }
.brand img { width: 40px; height: 36px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: .95; font-weight: 800; letter-spacing: -.03em; }
.brand-text b { font-size: 20px; color: #fff; }
.brand-text em { font-style: normal; font-size: 20px; background: linear-gradient(90deg, var(--brand-400), var(--brand-500)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-plate { display: inline-flex; align-items: center; justify-content: center; max-width: 100%; }
.brand-plate.on { padding: 7px 12px; border-radius: 12px; background: rgba(255,255,255,.96); box-shadow: 0 6px 18px -8px rgba(0,0,0,.45); }
.brand-dark .brand-plate.on { background: transparent; box-shadow: none; padding: 0; }
.brand-logo { width: auto !important; height: auto !important; max-width: 100%; max-height: 44px; object-fit: contain; }
.brand-lg .brand-plate.on { padding: 12px 20px; border-radius: 16px; }
.brand-lg .brand-logo { max-height: 64px; max-width: 300px; }
.brand-initial { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 20px; color: #fff; flex-shrink: 0; background: linear-gradient(135deg, var(--brand-500), var(--brand-700)); box-shadow: 0 1px 0 rgba(255,255,255,.25) inset; }
.brand-name b { font-size: 17px; line-height: 1.15; letter-spacing: -.02em; }
.brand-lg .brand-initial { width: 64px; height: 64px; font-size: 32px; border-radius: 18px; }
.brand-lg .brand-name b { font-size: 30px; }
.brand-lg img { width: 74px; height: 68px; }
.brand-lg .brand-text b, .brand-lg .brand-text em { font-size: 40px; }
.brand-dark .brand-text b { color: var(--ink-950); }

.nav { flex: 1; overflow-y: auto; margin: 0 -6px; padding: 0 6px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.nav-group { margin-bottom: 18px; }
.nav-label { font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: rgba(255,255,255,.42); padding: 0 12px 6px; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px; margin-bottom: 2px;
  color: #b8d3c3; font-weight: 600; font-size: 14px; text-decoration: none; transition: background .15s, color .15s;
}
.nav a .icon { width: 19px; height: 19px; opacity: .85; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.active { background: linear-gradient(90deg, color-mix(in srgb, var(--brand-500) 22%, transparent), color-mix(in srgb, var(--brand-500) 6%, transparent)); color: #fff; }
.nav a.active::before { content: ''; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--brand-400); }
.nav a.active .icon { color: var(--brand-300); opacity: 1; }

.side-foot { border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 14px; margin-top: 10px; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 12px; color: #fff; text-decoration: none !important; }
.side-user:hover { background: rgba(255, 255, 255, .06); }
.side-user .who { min-width: 0; line-height: 1.25; }
.side-user .who b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .who span { font-size: 11.5px; color: rgba(255,255,255,.55); }

.avatar {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0; display: grid; place-items: center; font-weight: 800; font-size: 13px;
  color: var(--ink-900); background: linear-gradient(135deg, var(--brand-300), var(--lime));
}
.avatar-sm { width: 30px; height: 30px; border-radius: 10px; font-size: 11px; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 14px; padding: 14px 32px;
  background: rgba(243, 248, 245, .82); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid rgba(205, 218, 210, .6);
}
.topbar .crumb { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar .crumb b { color: var(--text); font-weight: 700; }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; }
.tenant-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--ink-800); }
.tenant-chip .icon { color: var(--brand-600); }
.page { padding: 28px 32px 56px; width: 100%; max-width: 1360px; margin: 0 auto; flex: 1; }
.impersonate-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 32px; font-size: 13px; font-weight: 600;
  background: linear-gradient(90deg, var(--ink-900), var(--ink-700)); color: #fff;
}
.impersonate-bar .btn { margin-left: auto; }
.scrim { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 26px; font-weight: 800; }
.page-head p { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { font-size: 16px; font-weight: 800; }
.card-head .sub { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.card-body { padding: 22px; }
.grid { display: grid; gap: 20px; }
.grid > *, .stack, .card { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.mt { margin-top: 20px; } .mt-sm { margin-top: 10px; } .mb { margin-bottom: 20px; }

.kpi { padding: 20px; display: flex; flex-direction: column; gap: 14px; position: relative; overflow: hidden; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.kpi-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-100); color: var(--brand-700); }
.kpi-icon.amber { background: #fef3c7; color: #b45309; }
.kpi-icon.red { background: var(--red-bg); color: #b91c1c; }
.kpi-icon.blue { background: #e0f2fe; color: var(--blue); }
.kpi-icon.violet { background: #ede9fe; color: #6d28d9; }
.kpi-value { font-size: 28px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.kpi-foot { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.kpi.accent { background: linear-gradient(135deg, var(--brand-600), var(--brand-800)); border-color: transparent; color: #fff; box-shadow: 0 14px 30px -16px color-mix(in srgb, var(--brand-700) 70%, transparent); }
.kpi.accent .kpi-label, .kpi.accent .kpi-foot { color: rgba(255,255,255,.82); }
.kpi.accent .kpi-icon { background: rgba(255,255,255,.18); color: #fff; }
.kpi.accent::after { content: ''; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .22), transparent 70%); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 11px; border: 1px solid transparent;
  font-size: 14px; font-weight: 700; cursor: pointer; text-decoration: none !important; line-height: 1.2; white-space: nowrap;
  color: #fff; background: linear-gradient(180deg, var(--brand-600), var(--brand-700)); box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 6px 14px -6px color-mix(in srgb, var(--brand-700) 55%, transparent);
  transition: transform .12s, box-shadow .15s, filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.06); box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 10px 20px -8px rgba(21, 128, 61, .6); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-loading { opacity: .7; cursor: not-allowed; pointer-events: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--brand-50); border-color: var(--brand-300); filter: none; box-shadow: var(--shadow-sm); }
.btn-ghost { background: transparent; color: var(--muted); box-shadow: none; }
.btn-ghost:hover { background: rgba(5, 46, 26, .06); color: var(--text); filter: none; box-shadow: none; }
.btn-danger { background: linear-gradient(180deg, #ef4444, #dc2626); box-shadow: 0 6px 14px -6px rgba(220, 38, 38, .55); }
.btn-soft-danger { background: var(--red-bg); color: #b91c1c; box-shadow: none; }
.btn-soft-danger:hover { background: #fecaca; filter: none; box-shadow: none; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; width: 34px; height: 34px; border-radius: 10px; }
.btn-lg { padding: 13px 22px; font-size: 15px; border-radius: 13px; }
.btn .spinner, .spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.btn-secondary .spinner, .btn-ghost .spinner { border-color: rgba(0,0,0,.15); border-top-color: var(--brand-700); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 700; color: var(--text); }
.field > label .req { color: var(--red); margin-left: 2px; }
.field .hint { font-size: 12px; color: var(--faint); }
.input, .select, .textarea {
  width: 100%; padding: 11px 14px; font: inherit; font-size: 14.5px; color: var(--text); background: var(--surface);
  border: 1.5px solid var(--line-strong); border-radius: 11px; transition: border-color .15s, box-shadow .15s, background .15s;
}
.input::placeholder, .textarea::placeholder { color: #9fb0a5; }
.input:hover, .select:hover, .textarea:hover { border-color: #b4c7ba; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-500) 16%, transparent); }
.textarea { resize: vertical; min-height: 96px; }
.select { appearance: none; padding-right: 38px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235e7066' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; }
.input[readonly], .input:disabled, .select:disabled { background: var(--surface-2); color: var(--muted); }
.has-error .input, .has-error .select, .has-error .textarea, .input.is-invalid { border-color: var(--red); background: #fffafa; }
.has-error .input:focus, .has-error .select:focus, .has-error .textarea:focus { box-shadow: 0 0 0 4px rgba(220, 38, 38, .14); }
.field-error { display: flex; align-items: center; gap: 6px; color: #b91c1c; font-size: 12.5px; font-weight: 600; animation: fadeDown .2s ease; }
.field-error .icon { width: 14px; height: 14px; }
.has-error.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
@keyframes fadeDown { from { opacity: 0; transform: translateY(-3px); } }
.input-icon { position: relative; }
.input-icon > .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.input-icon > .input { padding-left: 40px; }
.input-icon .toggle-pass { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 14px; font-weight: 600; }
.check input { position: absolute; opacity: 0; }
.check .box { width: 20px; height: 20px; border: 1.5px solid var(--line-strong); border-radius: 6px; display: grid; place-items: center; flex-shrink: 0; margin-top: 1px; transition: .15s; background: #fff; color: transparent; }
.check .box .icon { width: 14px; height: 14px; stroke-width: 3; }
.check input:checked + .box { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.check input:focus-visible + .box { box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-500) 20%, transparent); }
.check small { display: block; font-weight: 500; color: var(--muted); font-size: 12.5px; }
.password-meter { height: 5px; border-radius: 4px; background: var(--line); overflow: hidden; }
.password-meter i { display: block; height: 100%; width: 0; border-radius: 4px; transition: width .25s, background .25s; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 22px; border-bottom: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.filters .input, .filters .select { width: auto; min-width: 150px; padding: 9px 12px; font-size: 13.5px; border-radius: 10px; }
.filters > .field { min-width: 0; }
.filters .field .input, .filters .field .select { width: 100%; min-width: 0; }
.filters .input-icon .input { padding-left: 40px; }
.filters .search { flex: 1; min-width: 220px; max-width: 380px; }
.filters .search .input { width: 100%; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 12px 18px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 14px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #f7fbf8; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn + .btn, .table .actions form + .btn { margin-left: 4px; }
.cell-main { font-weight: 700; color: var(--text); }
.cell-sub { font-size: 12.5px; color: var(--muted); }
.cell-user { display: flex; align-items: center; gap: 12px; min-width: 0; }
.link { color: inherit; font-weight: 700; }
a.link:hover { color: var(--brand-700); }
.table tr.row-muted td { opacity: .55; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge-blue { background: #e0f2fe; color: #075985; }
.badge-violet { background: #ede9fe; color: #5b21b6; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-teal { background: #ccfbf1; color: #115e59; }
.badge-gray { background: #eaf0ec; color: #475569; }
.badge-red { background: #fee2e2; color: #991b1b; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 22px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.pages { display: flex; gap: 4px; }
.pages a, .pages span { min-width: 34px; height: 34px; padding: 0 8px; display: grid; place-items: center; border-radius: 9px; font-weight: 700; color: var(--text); text-decoration: none !important; }
.pages a:hover { background: var(--brand-100); }
.pages .current { background: var(--ink-900); color: #fff; }
.pages .disabled { opacity: .35; }

.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty .empty-ico { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; margin: 0 auto 16px; background: var(--brand-100); color: var(--brand-700); }
.empty .empty-ico .icon { width: 28px; height: 28px; }
.empty h3 { color: var(--text); font-size: 16px; margin-bottom: 4px; }

.muted { color: var(--muted); } .faint { color: var(--faint); }
.text-right { text-align: right; } .text-center { text-align: center; }
.text-red { color: var(--neg); } .text-green { color: var(--pos-dark); } .text-amber { color: var(--amber); }
.fw { font-weight: 700; } .small { font-size: 12.5px; }
.flex { display: flex; } .items-center { align-items: center; } .between { justify-content: space-between; } .wrap { flex-wrap: wrap; }
.gap { gap: 12px; } .gap-sm { gap: 6px; } .gap-lg { gap: 20px; }
.mono { font-variant-numeric: tabular-nums; }

/* Sub navegação (segmented) */
.segmented { display: inline-flex; background: color-mix(in srgb, var(--brand-600) 10%, var(--surface-2)); padding: 4px; border-radius: 12px; gap: 2px; margin-bottom: 20px; flex-wrap: wrap; }
.segmented a { padding: 8px 16px; border-radius: 9px; font-size: 13.5px; font-weight: 700; color: var(--muted); text-decoration: none !important; }
.segmented a.active { background: #fff; color: var(--ink-900); box-shadow: var(--shadow-sm); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; font-weight: 700; color: var(--muted); text-decoration: none !important; transition: .15s; }
.chip b { color: var(--text); font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--brand-300); background: var(--brand-50); }
.chip.active { background: var(--brand-700); border-color: var(--brand-700); color: rgba(255,255,255,.88); }
.chip.active b { color: #fff; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 200; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2, 26, 15, .55); backdrop-filter: blur(5px); animation: fadeIn .2s; }
.modal-panel {
  position: relative; width: 100%; max-width: 560px; max-height: calc(100vh - 40px); display: flex; flex-direction: column;
  background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg); animation: pop .22s cubic-bezier(.2, .9, .3, 1.15);
}
.modal-lg .modal-panel { max-width: 760px; }
.modal-sm .modal-panel { max-width: 440px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 24px 4px; }
.modal-head h3 { font-size: 18px; font-weight: 800; }
.modal-head p { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.modal-body { padding: 18px 24px 8px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px 22px; }
.modal form { display: contents; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.confirm-ico { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; margin-bottom: 14px; background: var(--brand-100); color: var(--brand-700); }
.confirm-ico.danger { background: var(--red-bg); color: #b91c1c; }
.confirm-ico .icon { width: 26px; height: 26px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; top: 18px; right: 18px; z-index: 400; display: flex; flex-direction: column; gap: 10px; width: min(392px, calc(100vw - 28px)); pointer-events: none; }
.toast {
  pointer-events: auto; position: relative; display: flex; gap: 12px; align-items: flex-start; padding: 14px 14px 14px 14px; border-radius: 16px; overflow: hidden;
  background: #fff; border: 1px solid var(--line); box-shadow: 0 18px 40px -16px rgba(2, 26, 15, .35), 0 2px 6px rgba(2, 26, 15, .06);
  animation: toastIn .35s cubic-bezier(.2, .9, .3, 1.1); --tc: var(--pos); --tb: color-mix(in srgb, var(--pos) 14%, #fff);
}
.toast.out { animation: toastOut .25s forwards; }
.toast-ico { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; background: var(--tb); color: var(--tc); }
.toast-ico .icon { width: 20px; height: 20px; }
.toast-body { flex: 1; min-width: 0; padding-top: 1px; }
.toast-title { font-weight: 800; font-size: 14px; }
.toast-msg { font-size: 13.5px; color: var(--muted); margin-top: 1px; overflow-wrap: anywhere; }
.toast-x { background: none; border: 0; color: var(--faint); cursor: pointer; padding: 4px; border-radius: 8px; line-height: 0; }
.toast-x:hover { background: var(--surface-2); color: var(--text); }
.toast-bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--tc); width: 100%; transform-origin: left; animation: bar linear forwards; opacity: .75; }
.toast.error { --tc: #dc2626; --tb: #fee2e2; }
.toast.warning { --tc: #d97706; --tb: #fef3c7; }
.toast.info { --tc: #0369a1; --tb: #e0f2fe; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px) scale(.96); } }
@keyframes bar { to { transform: scaleX(0); } }

.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; font-size: 13.5px; background: var(--brand-50); border: 1px solid var(--brand-200); color: var(--brand-800); }
.alert.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert .icon { margin-top: 2px; }

/* ---------- Dropdown / Combobox ---------- */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 60; }
.dropdown.open .dropdown-menu { display: block; animation: fadeDown .15s; }
.dropdown-menu a, .dropdown-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 9px; color: var(--text); font: inherit; font-weight: 600; font-size: 13.5px; background: none; border: 0; cursor: pointer; text-decoration: none !important; text-align: left; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--brand-50); }
.dropdown-menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.user-btn { display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); cursor: pointer; font: inherit; }
.user-btn .who { text-align: left; line-height: 1.2; }
.user-btn .who b { display: block; font-size: 13px; }
.user-btn .who span { font-size: 11.5px; color: var(--muted); }

.combo { position: relative; }
.combo-list { position: absolute; z-index: 90; left: 0; right: 0; top: calc(100% + 6px); max-height: 250px; overflow-y: auto; background: #fff; border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 5px; display: none; }
.combo.open .combo-list { display: block; }
.combo-opt { padding: 9px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; display: flex; justify-content: space-between; gap: 10px; }
.combo-opt small { color: var(--faint); }
.combo-opt:hover, .combo-opt.hl { background: var(--brand-100); }
.combo-opt.sel { font-weight: 800; }
.combo-empty { padding: 12px; color: var(--muted); font-size: 13px; text-align: center; }

/* ---------- Timeline ---------- */
.timeline { display: flex; flex-direction: column; gap: 0; position: relative; }
.event { display: flex; gap: 14px; position: relative; padding-bottom: 20px; }
.event:not(:last-child)::before { content: ''; position: absolute; left: 17px; top: 38px; bottom: 0; width: 2px; background: var(--line); }
.event-ico { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; background: var(--brand-100); color: var(--brand-700); z-index: 1; }
.event-ico .icon { width: 18px; height: 18px; }
.event.ev-client .event-ico { background: #fef3c7; color: #b45309; }
.event.ev-internal .event-ico { background: #eaf0ec; color: #64748b; }
.event.ev-system .event-ico { background: #e0f2fe; color: var(--blue); }
.event-body { flex: 1; min-width: 0; }
.event-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.event-meta b { color: var(--text); font-size: 13.5px; }
.event-text { margin-top: 5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.event.ev-internal .event-text { background: #f3f6f4; border: 1px dashed var(--line-strong); padding: 10px 12px; border-radius: 10px; }
.event.ev-client .event-text, .event.ev-staff-msg .event-text { background: var(--surface-2); border: 1px solid var(--line); padding: 10px 14px; border-radius: 4px 14px 14px 14px; }
.event.ev-new { animation: flash 1.8s; }
@keyframes flash { 0% { background: color-mix(in srgb, var(--brand-500) 18%, transparent); } 100% { background: transparent; } }
.tag-private { display: inline-flex; gap: 4px; align-items: center; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #eaf0ec; color: #475569; }
.tag-private .icon { width: 11px; height: 11px; }

.detail-list { display: grid; gap: 14px; }
.detail-item { display: flex; gap: 12px; align-items: flex-start; }
.detail-item .di-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--brand-700); border: 1px solid var(--line); flex-shrink: 0; }
.detail-item small { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.detail-item span.v { font-weight: 700; }
.totals { display: grid; gap: 8px; font-size: 14px; }
.totals div { display: flex; justify-content: space-between; }
.totals .grand { border-top: 1px dashed var(--line-strong); padding-top: 12px; margin-top: 4px; font-size: 18px; font-weight: 800; }

/* ---------- Charts ---------- */
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font); fill: var(--muted); font-size: 11px; font-weight: 600; }
.chart .grid-line { stroke: var(--line); stroke-dasharray: 3 4; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.donut-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.donut-wrap .chart { width: 170px; flex-shrink: 0; }
.donut-legend { flex: 1; min-width: 150px; display: grid; gap: 9px; font-size: 13px; }
.donut-legend div { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.donut-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 8px; }
.chart-tip { position: fixed; z-index: 500; pointer-events: none; background: var(--ink-950); color: #fff; font-size: 12px; font-weight: 600; padding: 7px 10px; border-radius: 9px; box-shadow: var(--shadow-lg); display: none; line-height: 1.5; }
.bar-list { display: grid; gap: 14px; }
.bar-row .top { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.bar-row .track { height: 8px; background: var(--line); border-radius: 6px; overflow: hidden; }
.bar-row .track i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--brand-500), var(--brand-300)); }
.progress { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--brand-500); }

.ext-card { padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.ext-card .kpi-icon { width: 46px; height: 46px; }
.ext-card h3 { font-size: 16px; }
.ext-card p { color: var(--muted); font-size: 13.5px; flex: 1; }
.ext-card.soon { background: var(--surface-2); border-style: dashed; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--surface); }
.auth-side {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: 48px 56px; color: #fff;
  background:
    radial-gradient(700px 420px at 0% 0%, color-mix(in srgb, var(--brand-500) 30%, transparent), transparent 60%),
    radial-gradient(600px 420px at 100% 100%, rgba(190, 242, 100, .14), transparent 60%),
    linear-gradient(160deg, var(--ink-800), var(--ink-950) 70%);
}
.auth-side::before { content: ''; position: absolute; width: 640px; height: 640px; border-radius: 50%; right: -260px; top: -180px; border: 1px solid rgba(255, 255, 255, .06); box-shadow: 0 0 0 90px rgba(255, 255, 255, .015), 0 0 0 180px rgba(255, 255, 255, .012); }
.auth-side > * { position: relative; }
.auth-side h2 { font-size: 34px; font-weight: 800; line-height: 1.15; max-width: 460px; }
.auth-side h2 span { color: var(--brand-400); }
.auth-side p.lead { color: rgba(255,255,255,.74); margin-top: 14px; max-width: 440px; font-size: 15.5px; }
.auth-pills { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-width: 460px; margin-top: 32px; }
.auth-pill { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .09); font-weight: 700; font-size: 13.5px; }
.auth-pill .icon { color: var(--brand-400); width: 20px; height: 20px; }
.auth-foot { font-size: 12.5px; color: rgba(255,255,255,.5); }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 28px; }
.auth-card { width: 100%; max-width: 410px; }
.auth-card h1 { font-size: 28px; font-weight: 800; }
.auth-card .lead { color: var(--muted); margin: 6px 0 26px; }
.auth-card .brand-mobile { display: none; margin-bottom: 26px; }
.error-page { max-width: 480px; text-align: center; margin: 0 auto; }
.error-page .code { font-size: 86px; font-weight: 800; letter-spacing: -.05em; line-height: 1; background: linear-gradient(135deg, var(--brand-500), var(--ink-800)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Responsivo ---------- */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(2, 26, 15, .5); z-index: 45; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .topbar, .impersonate-bar { padding-left: 18px; padding-right: 18px; }
  .page { padding: 22px 18px 48px; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-card .brand-mobile { display: flex; }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
  .page-head h1 { font-size: 22px; }
  .user-btn .who, .topbar .crumb .hide-sm { display: none; }
  .tenant-chip { display: none; }
  .filters .input, .filters .select { width: 100%; }
  .filters .search { max-width: none; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-panel { border-radius: 20px 20px 0 0; max-height: 92vh; }
  .table th, .table td { padding: 12px 12px; }
  .toasts { right: 14px; left: 14px; width: auto; }
}
@media print {
  .sidebar, .topbar, .page-actions, .filters, .btn, .toasts, .impersonate-bar, .no-print { display: none !important; }
  .main { margin: 0; }
  .page { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }


/* ---------- Portal incorporado (iframe) ---------- */
.auth-embed { min-height: 100vh; }
.auth-embed .auth-side { display: none; }
.auth-embed .auth-main { width: 100%; padding: 24px 16px; }
.auth-embed .brand-mobile { display: flex; }
.embed-top { display: flex; align-items: center; gap: 14px; padding: 12px 20px; background: linear-gradient(135deg, var(--ink-900), var(--ink-800)); color: #fff; }
.embed-top .brand { padding: 0; }
.embed-top .spacer { flex: 1; }
.embed-top .who { font-size: 13px; opacity: .85; }
.embed-page { max-width: 1080px; margin: 0 auto; padding: 22px 18px 40px; }

/* ---------- Configuração de marca ---------- */
.brand-pick { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.brand-pick input[type=color] { width: 52px; height: 44px; padding: 3px; border: 1px solid var(--line-strong); border-radius: 12px; background: #fff; cursor: pointer; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line-strong); cursor: pointer; padding: 0; }
.swatch:hover { transform: scale(1.1); }
.logo-drop { display: flex; align-items: center; gap: 16px; padding: 16px; border: 1.5px dashed var(--line-strong); border-radius: 14px; background: var(--surface-2); }
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.preset { display: flex; flex-direction: column; gap: 7px; align-items: stretch; padding: 8px; border-radius: 12px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 12px; font-weight: 700; color: var(--text); text-align: left; }
.preset:hover { border-color: var(--brand-400); box-shadow: var(--shadow-sm); }
.preset-mini { display: flex; height: 44px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #f3f6f4; }
.preset-mini i { width: 32%; background: var(--pm); }
.preset-mini.light i { background: color-mix(in srgb, var(--pm) 10%, #fff); border-right: 1px solid var(--line); }
.preset-mini b { flex: 1; position: relative; }
.preset-mini b::after { content: ''; position: absolute; left: 22%; top: 30%; width: 48%; height: 40%; border-radius: 5px; background: var(--pc); }
.seg-radio { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.seg-radio label { cursor: pointer; }
.seg-radio input { position: absolute; opacity: 0; pointer-events: none; }
.seg-radio span { display: block; padding: 8px 18px; border-radius: 9px; font-weight: 700; font-size: 13px; color: var(--muted); }
.seg-radio input:checked + span { background: #fff; color: var(--ink-900); box-shadow: var(--shadow-sm); }
.seg-radio input:focus-visible + span { outline: 2px solid var(--brand-500); }
.logo-drop { flex-wrap: wrap; align-items: flex-start; }
.logo-prevs { display: grid; gap: 8px; }
.logo-preview.dark { background: #0f1512; border-color: #1f2a24; }
.logo-tools { flex: 1; min-width: 240px; }
.logo-slider { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.logo-slider input { flex: 1; max-width: 220px; accent-color: var(--brand-600); }
.logo-preview { width: 150px; height: 64px; display: grid; place-items: center; border-radius: 10px; background: repeating-conic-gradient(#eef2ef 0 25%, #fff 0 50%) 50% / 14px 14px; border: 1px solid var(--line); overflow: hidden; flex-shrink: 0; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.snippet { position: relative; }
.snippet pre { margin: 0; padding: 44px 16px 14px; border-radius: 12px; background: var(--ink-950); color: #e6efe9; font-size: 12.5px; line-height: 1.55; overflow: auto; white-space: pre-wrap; word-break: break-all; }
.snippet .btn { position: absolute; top: 8px; right: 8px; }
.nowrap { white-space: nowrap; }
