/* ============================================================================
   PORTAL HUB ERP — Design System (identidade Andersen Consulting)
   Inspiração de experiência: Dynamics 365, SAP Fiori, Azure Portal, Stripe,
   GitHub, Linear, Vercel — sem copiar. Construído sobre o grid do Bootstrap,
   sobrescrevendo toda a aparência dos componentes. Light/Dark via [data-theme].
   ========================================================================== */

/* ---------------------------------------------------------------- TOKENS -- */
:root {
  /* marca — Azul, Branco e Vermelho (cores ajustáveis em Configurações) */
  --brand-navy: #0b2f5e;   /* azul profundo */
  --brand-blue: #1560bd;   /* azul primário  */
  --brand-red:  #d42836;   /* vermelho de acento */
  --grad-angle: 135deg;
  /* gradiente da marca: Azul → Vermelho (botões primários, marca, destaques) */
  --brand-grad-btn: linear-gradient(var(--grad-angle), var(--brand-blue) 0%, var(--brand-red) 100%);
  /* sidebar/hero: navy → azul → vermelho, sempre escuro (color-mix) */
  --brand-grad: linear-gradient(168deg, #0a2246 0%,
                 color-mix(in srgb, var(--brand-blue) 72%, #060c1c) 52%,
                 color-mix(in srgb, var(--brand-red) 60%, #0b0712) 132%);

  /* superfícies (light) — branco + azul muito claro */
  --bg: #eef4fb;
  --surface: #ffffff;
  --surface-2: #f4f8fd;
  --surface-3: #e7eff9;
  --sidebar-ink: #c6d5ee;
  --sidebar-ink-dim: #8aa0c4;

  /* texto */
  --ink: #142033;
  --ink-2: #40506a;
  --muted: #64748b;
  --line: #e2e8f2;
  --line-2: #cfd8e6;

  /* acento (azul da marca) e estados */
  --accent: #1560bd;
  --accent-strong: #0d4a97;
  --accent-ink: #ffffff;
  --accent-soft: #e6f0fb;
  --ring: rgba(21, 96, 189, .22);

  --success: #15925a;  --success-soft: #e3f4ec;  --success-ink: #0d6b42;
  --warning: #b7791f;  --warning-soft: #fbf0da;  --warning-ink: #8a5a12;
  --danger:  #d42836;  --danger-soft:  #fce7e8;  --danger-ink:  #a51f2c;
  --info:    #0e8fbf;  --info-soft:    #e0f3fa;  --info-ink:    #0a6d92;
  --neutral-soft: #eaf0f8; --neutral-ink: #4a5b76;

  /* forma */
  --r-sm: 7px; --r: 11px; --r-lg: 16px; --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.04);
  --shadow: 0 2px 6px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.06);
  --shadow-lg: 0 12px 40px rgba(16,24,40,.16);

  --sidebar-w: 250px;
  --topbar-h: 62px;

  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --bs-primary: #8a1c3f;
  --bs-body-font-family: var(--sans);
  --bs-body-color: var(--ink);
  --bs-border-radius: var(--r);
}

:root[data-theme="dark"] {
  --bg: #0a111f;
  --surface: #121a2b;
  --surface-2: #172136;
  --surface-3: #1e2a42;
  --sidebar-ink: #c2d2ec;
  --sidebar-ink-dim: #86a0c6;

  --ink: #e8eefb;
  --ink-2: #b7c3d8;
  --muted: #8493ab;
  --line: #232e46;
  --line-2: #31405e;

  /* azul mais claro para contraste no escuro; vermelho da marca preservado */
  --brand-navy: #2f6fb2;
  --brand-blue: #4f93e8;
  --brand-red:  #ef4b57;

  --accent: #5b9bf0;
  --accent-strong: #7cb2f5;
  --accent-soft: #15233b;
  --ring: rgba(91, 155, 240, .30);

  --success-soft: #123024; --success-ink: #6fd6a2;
  --warning-soft: #33280f; --warning-ink: #e7b567;
  --danger-soft:  #351a1d; --danger-ink:  #f1a3a3;
  --info-soft:    #0c2b39; --info-ink:    #63c3e6;
  --neutral-soft: #1e2a42; --neutral-ink: #9aa8c2;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 2px 8px rgba(0,0,0,.4);
  --shadow-lg: 0 16px 44px rgba(0,0,0,.55);
}

/* --------------------------------------------------------------- BASE ----- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans); background: var(--bg); color: var(--ink);
  font-size: 14.5px; line-height: 1.55; margin: 0;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }
h1,h2,h3,h4,h5 { color: var(--ink); font-weight: 700; letter-spacing: -.01em; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 1px; border-radius: 6px; }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 20px; border: 3px solid var(--bg); }

/* ============================================================ APP SHELL === */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
/* backdrop é só do mobile; fora dele não pode ocupar célula do grid (empurraria o conteúdo) */
.sb-backdrop { display: none; }

.app-sidebar {
  background-image: var(--brand-grad); color: var(--sidebar-ink);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  border-right: 1px solid rgba(255,255,255,.06); z-index: 40;
}
.sb-brand {
  display: flex; align-items: center; gap: 11px; padding: 0 20px; height: var(--topbar-h);
  flex: none; color: #fff; font-weight: 800; font-size: 16px; letter-spacing: -.02em;
  border-bottom: 1px solid rgba(255,255,255,.09);
}
.sb-brand .logo {
  width: 32px; height: 32px; border-radius: 9px; flex: none; background: rgba(255,255,255,.14);
  display: grid; place-items: center; color: #fff; font-size: 15px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.sb-nav { padding: 12px 12px; overflow-y: auto; flex: 1; }
.sb-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .13em; color: var(--sidebar-ink-dim);
  font-weight: 700; padding: 14px 12px 7px; }
.sb-link {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; margin: 2px 0; border-radius: 9px;
  color: var(--sidebar-ink); font-weight: 500; font-size: 14px; transition: background .14s, color .14s; position: relative;
}
.sb-link i { width: 18px; text-align: center; font-size: 15px; opacity: .92; }
.sb-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sb-link.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.sb-link.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  background: var(--brand-red); border-radius: 0 3px 3px 0; }
.sb-badge { margin-left: auto; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: var(--r-pill);
  background: rgba(255,255,255,.18); color: #fff; }
.sb-foot { padding: 12px 16px; flex: none; border-top: 1px solid rgba(255,255,255,.09);
  font-size: 11.5px; color: var(--sidebar-ink-dim); }

.app-main { display: flex; flex-direction: column; min-width: 0; }

.app-topbar {
  height: var(--topbar-h); flex: none; background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 22px; position: sticky; top: 0; z-index: 30;
}
.tb-toggle { display: none; background: none; border: 0; color: var(--ink); font-size: 20px; cursor: pointer; }
.tb-titles { min-width: 0; }
.tb-crumb { font-size: 11.5px; color: var(--muted); font-weight: 500; display: flex; gap: 7px; align-items: center; }
.tb-crumb i { font-size: 8px; opacity: .6; }
.tb-title { font-size: 16px; font-weight: 700; line-height: 1.1; margin-top: 1px; letter-spacing: -.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.tenant-chip {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; background: var(--surface-3);
  border: 1px solid var(--line); border-radius: var(--r-pill); font-size: 12.5px; font-weight: 600; color: var(--ink-2); max-width: 220px;
}
.tenant-chip i { color: var(--accent); }
.tenant-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.icon-btn { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); display: grid; place-items: center; cursor: pointer; transition: .14s; font-size: 15px; }
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }

.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 9px; height: 40px; padding: 0 6px 0 4px; background: none; border: 0;
  cursor: pointer; border-radius: var(--r-pill); }
.user-btn:hover { background: var(--surface-3); }
.avatar { width: 32px; height: 32px; border-radius: 50%; flex: none; background: var(--brand-grad-btn); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.user-meta { text-align: left; line-height: 1.15; }
.user-meta .nm { font-size: 13px; font-weight: 600; color: var(--ink); }
.user-meta .rl { font-size: 11px; color: var(--muted); }
.user-drop { position: absolute; right: 0; top: 46px; min-width: 210px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 7px; display: none; z-index: 60; }
.user-drop.open { display: block; animation: pop .13s ease; }
.user-drop a, .user-drop button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 11px; border-radius: 8px; color: var(--ink-2); font-size: 13.5px; background: none; border: 0; cursor: pointer; }
.user-drop a:hover, .user-drop button:hover { background: var(--surface-3); color: var(--ink); }
.user-drop .sep { height: 1px; background: var(--line); margin: 6px 4px; }

.app-content { padding: 24px 26px 40px; flex: 1; min-width: 0; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .ph-txt { min-width: 0; }
.page-title { font-size: 22px; font-weight: 800; letter-spacing: -.025em; margin: 0; }
.page-title .sub { color: var(--muted); font-weight: 400; font-size: .95rem; }
.page-sub { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.page-head .ph-actions { margin-left: auto; display: flex; gap: 9px; flex-wrap: wrap; }

/* ============================================================= CARDS ====== */
.card { background: var(--surface) !important; border: 1px solid var(--line) !important; border-radius: var(--r-lg) !important;
  box-shadow: var(--shadow-sm) !important; color: var(--ink); }
.card-header { background: transparent !important; border-bottom: 1px solid var(--line) !important; padding: 15px 20px !important;
  font-weight: 700; color: var(--ink) !important; display: flex; align-items: center; gap: 9px; }
.card-body { padding: 20px !important; }
.card-header.bg-dark, .card-header.bg-info, .card-header.bg-primary { background: var(--surface-2) !important; color: var(--ink) !important; }
.card-header.bg-dark .btn-outline-light { border-color: var(--line-2); color: var(--ink-2); }
.card-header.bg-dark .btn-outline-light:hover { background: var(--surface-3); color: var(--ink); }

/* KPI legacy stat cards (Sync usa stat-card + stat-red/navy/purple/teal) */
.stat-card { border: none !important; border-radius: var(--r-lg) !important; color: #fff; box-shadow: var(--shadow) !important; }
.stat-card .card-body { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stat-card .stat-value { font-size: 30px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-card .stat-label { opacity: .92; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.stat-card i { opacity: .4; font-size: 34px; }
.stat-red { background: linear-gradient(135deg, #d42836, #a51f2c) !important; }
.stat-navy { background: linear-gradient(135deg, #0b2f5e, #123f7a) !important; }
.stat-purple { background: linear-gradient(135deg, #1560bd, #0d4a97) !important; }
.stat-teal { background: linear-gradient(135deg, #1b6ec2, #2f8fd6) !important; }

/* KPI moderno (superfície clara, para o dashboard novo) */
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px;
  display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow-sm); transition: transform .12s, box-shadow .12s; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi .kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi .kpi-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-size: 17px;
  background: var(--accent-soft); color: var(--accent-strong); }
.kpi .kpi-icon.g { background: var(--success-soft); color: var(--success-ink); }
.kpi .kpi-icon.o { background: var(--warning-soft); color: var(--warning-ink); }
.kpi .kpi-icon.r { background: var(--danger-soft); color: var(--danger-ink); }
.kpi .kpi-icon.b { background: var(--info-soft); color: var(--info-ink); }
.kpi .kpi-icon.n { background: var(--neutral-soft); color: var(--neutral-ink); }
.kpi .kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi .kpi-value { font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; color: var(--ink); }
.kpi .kpi-foot { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }

/* ============================================================ BUTTONS ===== */
.btn { font-weight: 600 !important; border-radius: var(--r) !important; font-size: 14px !important; padding: 9px 16px !important;
  border: 1px solid transparent !important; display: inline-flex !important; align-items: center; justify-content: center; gap: 8px;
  transition: background .14s, box-shadow .14s, transform .06s, border-color .14s, filter .14s !important; line-height: 1.2 !important; }
.btn:active { transform: translateY(1px); }
.btn-lg { padding: 12px 20px !important; font-size: 15px !important; }
.btn-sm { padding: 6px 11px !important; font-size: 12.5px !important; }

.btn-primary { background: var(--brand-grad-btn) !important; border: none !important; color: #fff !important;
  box-shadow: 0 1px 2px rgba(138,28,63,.3); }
.btn-primary:hover, .btn-primary:focus { filter: brightness(1.07); color: #fff !important; }
.btn-dark { background: var(--brand-navy) !important; border-color: var(--brand-navy) !important; color: #fff !important; }
.btn-dark:hover { background: #141d3d !important; }

.btn-outline-secondary, .btn-outline-primary, .btn-outline-success, .btn-outline-warning,
.btn-outline-danger, .btn-outline-info {
  background: var(--surface) !important; color: var(--ink-2) !important; border-color: var(--line-2) !important; }
.btn-outline-secondary:hover, .btn-outline-primary:hover, .btn-outline-success:hover,
.btn-outline-warning:hover, .btn-outline-danger:hover, .btn-outline-info:hover {
  background: var(--surface-3) !important; color: var(--ink) !important; border-color: var(--line-2) !important; }
.btn-outline-primary::before,.btn-outline-success::before,.btn-outline-warning::before,
.btn-outline-danger::before,.btn-outline-info::before { content:""; width:7px; height:7px; border-radius:50%; flex:none; }
.btn-outline-primary::before { background: var(--accent); }
.btn-outline-success::before { background: var(--success); }
.btn-outline-warning::before { background: var(--warning); }
.btn-outline-danger::before  { background: var(--danger); }
.btn-outline-info::before    { background: var(--info); }

.btn-info { background: var(--info) !important; border-color: var(--info) !important; color: #fff !important; }
.btn-info:hover { filter: brightness(.94); }
.btn-ghost { background: transparent !important; color: var(--ink-2) !important; border-color: transparent !important; }
.btn-ghost:hover { background: var(--surface-3) !important; }
.btn-outline-light { color:#fff !important; border-color: rgba(255,255,255,.5) !important; }

.btn.is-loading { pointer-events: none; opacity: .9; position: relative; }
.btn.is-loading .btn-label { visibility: hidden; }
.btn.is-loading::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; animation: spin .6s linear infinite; }
.btn-outline-secondary.is-loading::after, .btn-outline-primary.is-loading::after, .btn-outline-success.is-loading::after,
.btn-outline-warning.is-loading::after, .btn-outline-danger.is-loading::after, .btn-outline-info.is-loading::after,
.btn-ghost.is-loading::after { border-color: rgba(138,28,63,.3); border-top-color: var(--accent); }

/* ============================================================= TABLES ===== */
.table { color: var(--ink) !important; margin: 0 !important; --bs-table-bg: transparent; border-color: var(--line) !important; }
.table > thead th { background: var(--surface-2); color: var(--muted) !important; font-weight: 700 !important; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--line) !important; padding: 12px 16px !important; white-space: nowrap; }
.table > tbody td { padding: 13px 16px !important; border-color: var(--line) !important; vertical-align: middle; color: var(--ink-2); }
.table-hover > tbody > tr:hover > * { background: var(--surface-2) !important; }
.data-card { overflow: hidden; }
.table-toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.table-toolbar .count { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.search-box { position: relative; margin-left: auto; }
.search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; }
.search-box input { height: 38px; padding: 0 14px 0 34px; border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--surface); color: var(--ink); font-size: 13.5px; min-width: 230px; }
.search-box input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

/* =========================================================== BADGES ======= */
.badge-soft, .badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px !important; font-weight: 700 !important;
  padding: 4px 10px !important; border-radius: var(--r-pill) !important; background: var(--neutral-soft); color: var(--neutral-ink);
  letter-spacing: .01em; line-height: 1.4; }
.badge-soft::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.b-success, .badge-soft.b-success { background: var(--success-soft); color: var(--success-ink); }
.badge.b-warning, .badge-soft.b-warning { background: var(--warning-soft); color: var(--warning-ink); }
.badge.b-danger,  .badge-soft.b-danger  { background: var(--danger-soft);  color: var(--danger-ink); }
.badge.b-info,    .badge-soft.b-info    { background: var(--info-soft);    color: var(--info-ink); }
.badge.b-accent,  .badge-soft.b-accent  { background: var(--accent-soft);  color: var(--accent-strong); }

.status { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); position: relative; }
.status.online .dot { background: var(--success); }
.status.offline .dot { background: var(--danger); }
.status.warn .dot { background: var(--warning); }
.status.online .dot::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--success);
  opacity: .35; animation: ping 1.8s ease-out infinite; }

/* =========================================================== FORMS ======== */
.form-control, .form-select { border: 1px solid var(--line-2) !important; border-radius: var(--r) !important; background: var(--surface) !important;
  color: var(--ink) !important; padding: 9px 13px !important; font-size: 14px !important; min-height: 42px;
  transition: border-color .14s, box-shadow .14s !important; }
.form-control::placeholder { color: var(--muted); }
.form-control:focus, .form-select:focus { border-color: var(--accent) !important; box-shadow: 0 0 0 3px var(--ring) !important; background: var(--surface) !important; }
.form-label, .field-label { font-size: 12.5px !important; font-weight: 600 !important; color: var(--ink-2) !important; margin-bottom: 6px !important; text-transform: none; letter-spacing: 0; }
.input-group-text { background: var(--surface-3) !important; border: 1px solid var(--line-2) !important; color: var(--muted) !important; }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-switch .form-check-input { width: 2.4em; height: 1.3em; cursor: pointer; }

/* login: campo unificado (ícone + input) — sem emendas nem recorte do ícone.
   A borda/raio fica no .input-group; ícone e input ficam sem borda/raio próprios. */
.login-card .input-group {
  border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface);
  overflow: hidden; transition: border-color .14s, box-shadow .14s;
}
.login-card .input-group-text {
  background: transparent !important; border: none !important; border-radius: 0 !important;
  color: var(--muted) !important; width: 46px; justify-content: center; padding: 0;
}
.login-card .form-control, .login-card .form-select {
  border: none !important; border-radius: 0 !important; background-color: transparent !important;
  padding-left: 2px !important; min-height: 46px; flex: 1 1 auto; width: auto;
}
.login-card .form-control:focus, .login-card .form-select:focus { box-shadow: none !important; }
.login-card .input-group:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

/* ============================================================ TOASTS ======= */
#toast-stack { position: fixed; top: 18px; right: 18px; z-index: 1080; display: flex; flex-direction: column; gap: 10px; max-width: 380px; }
.toast-item { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--muted); border-radius: var(--r);
  box-shadow: var(--shadow-lg); padding: 13px 15px; display: flex; align-items: flex-start; gap: 11px; animation: slidein .22s cubic-bezier(.2,.9,.3,1); }
.toast-item.out { animation: slideout .2s forwards; }
.toast-item .ti-icon { font-size: 17px; margin-top: 1px; }
.toast-item .ti-body { flex: 1; min-width: 0; }
.toast-item .ti-title { font-weight: 700; font-size: 13.5px; }
.toast-item .ti-msg { font-size: 12.5px; color: var(--ink-2); margin-top: 1px; word-break: break-word; }
.toast-item .ti-close { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; }
.toast-item.t-success { border-left-color: var(--success); } .toast-item.t-success .ti-icon { color: var(--success); }
.toast-item.t-danger  { border-left-color: var(--danger); }  .toast-item.t-danger .ti-icon  { color: var(--danger); }
.toast-item.t-warning { border-left-color: var(--warning); } .toast-item.t-warning .ti-icon { color: var(--warning); }
.toast-item.t-info    { border-left-color: var(--info); }    .toast-item.t-info .ti-icon    { color: var(--info); }

/* ==================================================== LOADING / SKELETON == */
#global-loader { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 72%, transparent); backdrop-filter: blur(2px);
  z-index: 1090; display: none; place-items: center; }
#global-loader.show { display: grid; }
.loader-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  padding: 22px 28px; display: flex; align-items: center; gap: 15px; font-weight: 600; color: var(--ink); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--accent);
  animation: spin .7s linear infinite; flex: none; }
.skeleton { background: linear-gradient(100deg, var(--surface-3) 30%, var(--surface-2) 50%, var(--surface-3) 70%); background-size: 200% 100%;
  animation: shimmer 1.3s infinite; border-radius: 6px; }
.sk-row { height: 16px; margin: 12px 16px; }

/* ========================================================= EMPTY STATE ==== */
.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty .ic { width: 60px; height: 60px; border-radius: 16px; background: var(--surface-3); color: var(--muted); display: grid;
  place-items: center; font-size: 24px; margin: 0 auto 14px; }
.empty h4 { font-size: 15.5px; color: var(--ink); margin: 0 0 4px; }
.empty p { font-size: 13px; margin: 0 0 16px; }

/* =========================================================== ALERTS ======= */
.alert { border: 1px solid var(--line) !important; border-radius: var(--r) !important; padding: 12px 15px !important; display: flex;
  align-items: center; gap: 9px; font-size: 13.5px; font-weight: 500; }
.alert-success { background: var(--success-soft) !important; color: var(--success-ink) !important; border-color: transparent !important; }
.alert-danger  { background: var(--danger-soft) !important;  color: var(--danger-ink) !important;  border-color: transparent !important; }

/* ============================================================= LOGIN ======= */
.login-wrap { display: grid; grid-template-columns: 1.05fr .95fr; min-height: 100vh; background: var(--bg); }
.login-hero { background: var(--brand-grad); color: #fff; padding: 4vw 4.5vw; display: flex; flex-direction: column; justify-content: center;
  position: relative; overflow: hidden; }
.login-hero::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 380px; height: 380px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.13), transparent 70%); }
.login-hero .eyebrow { text-transform: uppercase; letter-spacing: .18em; font-size: 12px; font-weight: 700; opacity: .82; }
.login-hero h1 { color: #fff; font-size: clamp(28px, 3.4vw, 44px); font-weight: 800; margin: 12px 0 14px; letter-spacing: -.03em; }
.login-hero .lead { color: rgba(255,255,255,.82); font-size: 15.5px; max-width: 46ch; }
.hero-features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 34px; max-width: 440px; }
.hero-features .feat { background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.14); border-radius: var(--r); padding: 13px;
  display: flex; flex-direction: column; gap: 7px; font-size: 12.5px; font-weight: 600; align-items: flex-start; }
.hero-features .feat i { font-size: 17px; opacity: .95; }
.login-panel { display: grid; place-items: center; padding: 30px; background: var(--surface); }
.login-card { width: 100%; max-width: 400px; }
.login-brand .mark { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 17px; color: var(--ink); }
.login-brand .mark .dot { width: 26px; height: 26px; border-radius: 8px; background: var(--brand-grad-btn); }
.login-card h2 { font-size: 25px; font-weight: 800; margin: 26px 0 4px; letter-spacing: -.02em; }
.login-card .subtitle { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.steps { display: flex; gap: 6px; margin-bottom: 22px; }
.steps .step { height: 4px; flex: 1; border-radius: 4px; background: var(--line-2); }
.steps .step.active { background: var(--brand-grad-btn); }
.login-footer { text-align: center; margin-top: 26px; font-size: 12px; color: var(--muted); }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: 11.5px; font-weight: 700; color: var(--accent); }

/* ============================================================ UTILITIES === */
.text-muted { color: var(--muted) !important; }
.fw-semibold { font-weight: 600 !important; }
.grid-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.soft-divider { height: 1px; background: var(--line); border: 0; margin: 18px 0; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: var(--r-pill); background: var(--surface-3);
  border: 1px solid var(--line); font-size: 11.5px; font-weight: 600; color: var(--ink-2); }

/* mini gráfico de barras (CSS puro, sem libs) */
.bar-wrap { display: flex; flex-direction: column; }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 130px; padding-top: 18px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.bars .col > b { font-size: 11px; font-weight: 700; color: var(--ink-2); margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.bars .col > i { width: 100%; max-width: 46px; background: var(--brand-grad-btn); border-radius: 6px 6px 0 0; display: block; min-height: 4px; }
.bars .col > span { font-size: 10.5px; color: var(--muted); margin-top: 7px; font-weight: 600; text-align: center; }

/* ========================================================= ANIMATIONS ===== */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }
@keyframes slideout { to { transform: translateX(30px); opacity: 0; } }
@keyframes pop { from { transform: translateY(-4px) scale(.98); opacity: 0; } }
@keyframes ping { 75%, 100% { transform: scale(1.7); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ========================================================= RESPONSIVE ===== */
@media (max-width: 992px) {
  :root { --sidebar-w: 0px; }
  .app-shell { grid-template-columns: 1fr; }
  .app-sidebar { position: fixed; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .app-sidebar.open { transform: translateX(0); }
  .tb-toggle { display: block; }
  .sb-backdrop { position: fixed; inset: 0; background: rgba(10,12,24,.5); z-index: 39; display: none; }
  .sb-backdrop.show { display: block; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .app-content { padding: 16px 14px 32px; }
  .user-meta { display: none; }
  .tenant-chip { max-width: 130px; }
}
