/* =========================================================================
   Nexus Affiliate — Console
   Design system premium, tema escuro padrão + tema claro opcional.
   HTML/CSS/JS puro. Zero dependência de framework.
   ========================================================================= */

:root, [data-theme="dark"] {
  --bg-app:        #0a0e1a;
  --bg-elev-1:     #11172a;
  --bg-elev-2:     #161e36;
  --bg-elev-3:     #1c2742;
  --bg-hover:      #1a233e;
  --bg-active:     #1f2a47;
  --border:        #232e4d;
  --border-strong: #2c3a5f;
  --text:          #e7ecf6;
  --text-muted:    #98a1bd;
  --text-soft:     #6b748f;
  --text-inv:      #0a0e1a;
  --brand:         #6366f1;
  --brand-strong:  #4f46e5;
  --brand-soft:    rgba(99,102,241,.14);
  --brand-glow:    rgba(99,102,241,.32);
  --accent:        #14b8a6;
  --accent-soft:   rgba(20,184,166,.14);
  --success:       #22c55e;
  --success-soft:  rgba(34,197,94,.14);
  --warning:       #f59e0b;
  --warning-soft:  rgba(245,158,11,.14);
  --danger:        #ef4444;
  --danger-soft:   rgba(239,68,68,.14);
  --info:          #38bdf8;
  --info-soft:     rgba(56,189,248,.14);
  --shadow-sm:     0 1px 2px rgba(0,0,0,.4);
  --shadow-md:     0 8px 24px rgba(0,0,0,.35);
  --shadow-lg:     0 24px 48px rgba(0,0,0,.5);
  --shadow-glow:   0 0 0 1px var(--brand-glow), 0 8px 24px var(--brand-glow);
  --grid-line:     rgba(255,255,255,.03);
  --chart-grid:    rgba(255,255,255,.07);
}

[data-theme="light"] {
  --bg-app:        #f5f7fb;
  --bg-elev-1:     #ffffff;
  --bg-elev-2:     #ffffff;
  --bg-elev-3:     #f9fafc;
  --bg-hover:      #f0f3f9;
  --bg-active:     #e8edf6;
  --border:        #e2e7ef;
  --border-strong: #d0d7e3;
  --text:          #0f172a;
  --text-muted:    #475569;
  --text-soft:     #8794ad;
  --text-inv:      #ffffff;
  --brand:         #4f46e5;
  --brand-strong:  #4338ca;
  --brand-soft:    rgba(79,70,229,.10);
  --brand-glow:    rgba(79,70,229,.18);
  --accent:        #0d9488;
  --accent-soft:   rgba(13,148,136,.12);
  --success:       #15803d;
  --success-soft:  #dcfce7;
  --warning:       #b45309;
  --warning-soft:  #fef3c7;
  --danger:        #b91c1c;
  --danger-soft:   #fee2e2;
  --info:          #0369a1;
  --info-soft:     #e0f2fe;
  --shadow-sm:     0 1px 2px rgba(15,23,42,.06);
  --shadow-md:     0 8px 24px rgba(15,23,42,.08);
  --shadow-lg:     0 24px 48px rgba(15,23,42,.14);
  --shadow-glow:   0 0 0 1px var(--brand-glow), 0 8px 24px var(--brand-glow);
  --grid-line:     rgba(15,23,42,.04);
  --chart-grid:    rgba(15,23,42,.08);
}

/* ============================== Base ============================== */
*,*::before,*::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px; line-height: 1.5; color: var(--text);
  background: var(--bg-app); -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
svg { display: block; }
::selection { background: var(--brand-soft); color: var(--text); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.num  { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ============================== Auth ============================== */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: var(--bg-app);
  position: relative;
  overflow: hidden;
}
.auth::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(700px 500px at 5% 10%, var(--brand-soft) 0, transparent 60%),
    radial-gradient(600px 500px at 100% 110%, var(--accent-soft) 0, transparent 55%);
}
.auth-aside {
  position: relative; z-index: 1;
  padding: 56px 60px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(160deg, var(--bg-elev-2) 0%, var(--bg-elev-1) 100%);
  border-right: 1px solid var(--border);
}
.auth-aside .brand { display: inline-flex; align-items: center; gap: 12px; font-weight: 600; }
.auth-aside h1 {
  font-size: 34px; line-height: 1.15; letter-spacing: -.02em; margin: 0 0 14px;
  font-weight: 700; background: linear-gradient(90deg, var(--text) 0%, var(--text-muted) 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.auth-aside .lead { color: var(--text-muted); max-width: 460px; font-size: 15px; line-height: 1.65; margin: 0; }
.auth-aside .feature-list { display: grid; gap: 12px; margin-top: 32px; }
.auth-aside .feature {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px; background: var(--bg-elev-3); border: 1px solid var(--border); border-radius: 10px;
}
.auth-aside .feature .ico {
  width: 32px; height: 32px; border-radius: 8px; background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; flex: 0 0 32px;
}
.auth-aside .feature .ti { font-weight: 600; font-size: 13.5px; }
.auth-aside .feature .sb { color: var(--text-muted); font-size: 12.5px; line-height: 1.5; margin-top: 2px; }
.auth-aside .ftr { font-size: 12px; color: var(--text-soft); }
.auth-main { position: relative; z-index: 1; display: grid; place-items: center; padding: 40px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: 22px; margin: 0 0 6px; font-weight: 600; letter-spacing: -.01em; }
.auth-card .sub { color: var(--text-muted); margin: 0 0 28px; font-size: 14px; }
.auth-error {
  background: var(--danger-soft); border: 1px solid var(--danger); color: var(--danger);
  padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px;
  display: flex; gap: 8px; align-items: flex-start;
}

/* ============================== Form fields ============================== */
.field { display: block; margin-bottom: 16px; }
.field > label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; letter-spacing: .02em; }
.input, .select, textarea.input {
  width: 100%; height: 40px; padding: 0 14px;
  background: var(--bg-elev-2); border: 1px solid var(--border-strong); border-radius: 8px;
  color: var(--text); transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea.input { height: auto; padding: 10px 14px; min-height: 80px; resize: vertical; }
.input:focus, .select:focus, textarea.input:focus {
  outline: none; border-color: var(--brand); background: var(--bg-elev-3);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.input::placeholder { color: var(--text-soft); }

/* ============================== Buttons ============================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 8px;
  border: 1px solid var(--border-strong);
  font-size: 13.5px; font-weight: 500;
  background: var(--bg-elev-2); color: var(--text);
  transition: background .15s, border-color .15s, color .15s, transform .1s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: #fff; border-color: var(--brand-strong);
  box-shadow: 0 4px 14px rgba(99,102,241,.28);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(99,102,241,.4); border-color: var(--brand-strong); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 6px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14.5px; }
.btn-block { width: 100%; }
.btn .ico { width: 16px; height: 16px; flex: 0 0 16px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px;
  background: transparent; border: 1px solid transparent;
  color: var(--text-muted); display: inline-grid; place-items: center;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border); }

/* ============================== App shell ============================== */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 64px 1fr;
  grid-template-areas: "sidebar topbar" "sidebar main";
  min-height: 100vh;
}

/* ----- Sidebar ----- */
.sidebar {
  grid-area: sidebar;
  background: linear-gradient(180deg, var(--bg-elev-1) 0%, var(--bg-app) 100%);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; z-index: 30;
}
.sb-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; height: 64px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.sb-brand .logo {
  width: 36px; height: 36px; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 50%, var(--accent) 100%);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 8px 18px var(--brand-glow);
  flex: 0 0 36px;
}
.sb-brand .name { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.sb-brand .name strong { font-size: 14.5px; font-weight: 600; }
.sb-brand .name small { font-size: 11px; color: var(--text-soft); font-weight: 400; letter-spacing: .04em; text-transform: uppercase; margin-top: 1px; }

.nav-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-soft); padding: 18px 20px 6px; font-weight: 600;
}
.nav { padding: 4px 12px 12px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; margin: 1px 0;
  border-radius: 8px; color: var(--text-muted);
  font-size: 13.5px; cursor: pointer; position: relative;
  user-select: none;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active {
  background: var(--brand-soft); color: var(--text);
}
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 3px; background: var(--brand); border-radius: 0 2px 2px 0;
}
.nav-item .ico { width: 18px; height: 18px; color: inherit; flex: 0 0 18px; opacity: .85; }
.nav-item.active .ico { color: var(--brand); opacity: 1; }

.sb-ftr { border-top: 1px solid var(--border); padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  display: grid; place-items: center; color: #fff;
  font-size: 12.5px; font-weight: 600;
  flex: 0 0 34px;
}
.sb-ftr .who { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; flex: 1; }
.sb-ftr .name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.sb-ftr .role { font-size: 11.5px; color: var(--text-soft); }

/* ----- Topbar ----- */
.topbar {
  grid-area: topbar; height: 64px;
  background: var(--bg-elev-1);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px; position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(8px);
}
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 13px; }
.crumbs strong { color: var(--text); font-weight: 600; }
.crumbs .sep { color: var(--text-soft); }
.search { flex: 1; max-width: 380px; margin: 0 auto 0 18px; position: relative; }
.search input {
  width: 100%; height: 36px; padding: 0 12px 0 36px;
  background: var(--bg-elev-3); border: 1px solid transparent;
  border-radius: 8px; color: var(--text);
}
.search input:focus {
  background: var(--bg-elev-2); border-color: var(--border-strong);
  outline: none; box-shadow: 0 0 0 3px var(--brand-soft);
}
.search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-soft); pointer-events: none; }
.topbar .actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.api-status {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 9999px;
  background: var(--bg-elev-3); border: 1px solid var(--border);
  font-size: 12px; color: var(--text-muted);
}
.api-status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-soft); }
.api-status.is-up .dot { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.api-status.is-down .dot { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.api-status.is-up { color: var(--text); }
.menu-toggle { display: none; width: 36px; height: 36px; border-radius: 8px; background: transparent; border: 1px solid var(--border-strong); color: var(--text); }

/* ----- Main ----- */
.main { grid-area: main; padding: 28px 32px 64px; max-width: 1500px; width: 100%; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; color: var(--text-muted); font-size: 14px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================== Cards & KPIs ============================== */
.grid { display: grid; gap: 18px; }
.grid-kpis { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.card {
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); gap: 12px;
}
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 600; }
.card-head .desc { color: var(--text-muted); font-size: 12.5px; margin-top: 3px; }
.card-body { padding: 20px; }

.kpi {
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 6px;
  position: relative; overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.kpi:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.kpi::before {
  content: ""; position: absolute; right: -30px; top: -30px;
  width: 100px; height: 100px; border-radius: 50%; opacity: .08;
  background: var(--brand);
}
.kpi.k-success::before { background: var(--success); }
.kpi.k-danger::before { background: var(--danger); }
.kpi.k-warning::before { background: var(--warning); }
.kpi.k-info::before { background: var(--info); }

.kpi .label { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; font-weight: 500; }
.kpi .label .ico { width: 14px; height: 14px; color: var(--text-soft); }
.kpi.k-success .label .ico { color: var(--success); }
.kpi.k-danger .label .ico { color: var(--danger); }
.kpi.k-warning .label .ico { color: var(--warning); }
.kpi.k-info .label .ico { color: var(--info); }
.kpi .value { font-size: 26px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .trend { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.kpi .trend.up { color: var(--success); }
.kpi .trend.down { color: var(--danger); }

/* ============================== Tables ============================== */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.toolbar .input-wrap { position: relative; flex: 1; max-width: 360px; min-width: 200px; }
.toolbar .input-wrap .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-soft); }
.toolbar .input-wrap input { width: 100%; height: 36px; padding: 0 12px 0 34px; }
.toolbar select { height: 36px; padding: 0 32px 0 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--bg-elev-2); color: var(--text); -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2398a1bd' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>"); background-position: right 12px center; background-repeat: no-repeat; }
.toolbar .spacer { flex: 1; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; min-width: 720px; }
.table thead th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); font-weight: 600;
  background: var(--bg-elev-3); padding: 12px 16px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0;
}
.table tbody td { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--bg-hover); }
.table .cell-strong { font-weight: 500; color: var(--text); }
.table .cell-soft { color: var(--text-muted); }
.table th.num, .table td.num { text-align: right; }

.empty {
  padding: 48px 24px; text-align: center; color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.empty .ico { width: 40px; height: 40px; color: var(--text-soft); margin-bottom: 6px; }
.empty h4 { margin: 0; color: var(--text); font-weight: 600; font-size: 14px; }
.empty p { margin: 0; font-size: 13px; }

.skel { height: 14px; border-radius: 4px; background: linear-gradient(90deg, var(--bg-elev-2) 0%, var(--bg-elev-3) 50%, var(--bg-elev-2) 100%); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============================== Badges ============================== */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; font-size: 11.5px; line-height: 1.6;
  border-radius: 9999px; font-weight: 500; border: 1px solid transparent; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-neutral { background: var(--bg-elev-3); color: var(--text-muted); border-color: var(--border); }
.badge-success { background: var(--success-soft); color: var(--success); border-color: rgba(34,197,94,.3); }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: rgba(245,158,11,.3); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: rgba(239,68,68,.3); }
.badge-info    { background: var(--info-soft);    color: var(--info);    border-color: rgba(56,189,248,.3); }
.badge-brand   { background: var(--brand-soft);   color: var(--brand);   border-color: rgba(99,102,241,.3); }

/* ============================== Pagination ============================== */
.pagination {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-muted);
}
.page-btn { min-width: 32px; height: 30px; padding: 0 10px; border: 1px solid var(--border-strong); background: var(--bg-elev-2); border-radius: 6px; color: var(--text); }
.page-btn:hover { background: var(--bg-hover); }
.page-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ============================== Drawer ============================== */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50; display: none; }
.drawer-backdrop.is-open { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(480px, 100%);
  background: var(--bg-elev-1); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg); z-index: 60;
  transform: translateX(100%); transition: transform .28s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
}
.drawer.is-open { transform: translateX(0); }
.drawer-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.drawer-head h3 { margin: 0; font-size: 15.5px; font-weight: 600; }
.drawer-body { padding: 22px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ============================== Toasts ============================== */
.toast-wrap { position: fixed; top: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.toast {
  background: var(--bg-elev-2); border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 12px 16px; box-shadow: var(--shadow-md);
  font-size: 13px; min-width: 240px;
  display: flex; gap: 11px; align-items: flex-start;
  animation: toast-in .25s ease;
}
@keyframes toast-in { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast.is-error   { border-color: var(--danger);  border-left-width: 3px; }
.toast.is-success { border-color: var(--success); border-left-width: 3px; }
.toast.is-info    { border-color: var(--info);    border-left-width: 3px; }
.toast .ico { width: 18px; height: 18px; flex: 0 0 18px; margin-top: 1px; }
.toast.is-error .ico   { color: var(--danger); }
.toast.is-success .ico { color: var(--success); }
.toast.is-info .ico    { color: var(--info); }

/* ============================== Key/value lists ============================== */
.kv { display: grid; grid-template-columns: 220px 1fr; gap: 8px 20px; font-size: 13px; }
.kv > dt { color: var(--text-muted); font-weight: 500; }
.kv > dd { margin: 0; color: var(--text); font-variant-numeric: tabular-nums; word-break: break-word; }

/* ============================== Misc utilities ============================== */
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.hr { height: 1px; background: var(--border); margin: 16px 0; }
.help { color: var(--text-muted); font-size: 12.5px; }
.copy-btn { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 500; border: 1px solid transparent; }
.copy-btn:hover { background: var(--brand-soft); border-color: var(--brand); }
.copy-btn.is-copied { background: var(--success-soft); color: var(--success); border-color: rgba(34,197,94,.3); }

/* ============================== Charts ============================== */
.chart-wrap { padding: 8px; }
.chart-svg { width: 100%; height: auto; }
.chart-legend { display: flex; gap: 16px; padding: 8px 20px 16px; font-size: 12px; color: var(--text-muted); flex-wrap: wrap; }
.chart-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .sw { width: 12px; height: 12px; border-radius: 3px; }

/* ============================== Responsive ============================== */
@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  .sidebar { position: fixed; top: 0; left: 0; width: 280px; height: 100vh; transform: translateX(-100%); transition: transform .28s cubic-bezier(.4,0,.2,1); }
  .sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .menu-toggle { display: inline-grid; }
  .main { padding: 22px 18px 64px; }
  .topbar { padding: 0 18px; }
  .search { display: none; }
}
@media (max-width: 720px) {
  .auth { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .kv { grid-template-columns: 1fr; }
  .grid-kpis { grid-template-columns: 1fr 1fr; }
  .page-head { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 480px) {
  .grid-kpis { grid-template-columns: 1fr; }
}

/* ==================== v4.6.0 — extensões para storefront ==================== */
.cur-card:hover { border-color: var(--brand-strong) !important; transform: translateY(-2px); box-shadow: 0 6px 18px rgba(15,23,42,.08); }
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; line-height: 1.5; margin-top: 8px; }
.alert-warn { background: rgba(217,119,6,.10); color: #92400e; border: 1px solid rgba(217,119,6,.25); }
.alert-info { background: rgba(2,132,199,.10); color: #075985; border: 1px solid rgba(2,132,199,.25); }
.spin { display: inline-block; width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; margin-right: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
