:root {
  --sidebar-width: 268px;
  --ink: #0f172a;
  --muted: #64748b;
  --line: rgba(15, 23, 42, 0.08);
  --surface: #ffffff;
  --canvas: #eef1f7;
  --accent: #4f46e5;
  --accent-2: #6366f1;
  --sidebar: #0b1220;
  --radius: 0.9rem;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  --font: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;

  --bs-primary: #4f46e5;
  --bs-primary-rgb: 79, 70, 229;
  --bs-link-color: #4f46e5;
  --bs-link-hover-color: #4338ca;
  --bs-body-font-family: var(--font);
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--canvas);
  --bs-border-radius: 0.75rem;
  --bs-border-radius-sm: 0.55rem;
  --bs-border-radius-lg: 1rem;
  --bs-border-color: var(--line);
  --bs-tertiary-bg: #f8fafc;
  --bs-secondary-rgb: 100, 116, 139;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body,
.app-body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--canvas);
  letter-spacing: -0.01em;
}

h1, h2, h3, h4, .h1, .h2, .h3, .h4 {
  letter-spacing: -0.04em;
  font-weight: 700;
}

.app-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

.app-main {
  flex: 1;
  min-width: 0;
}

.app-content {
  flex: 1;
  padding: 1.15rem 1.15rem 2rem;
}

@media (min-width: 768px) {
  .app-content {
    padding: 1.6rem 1.85rem 2.4rem;
  }
}

.sidebar,
.sidebar-offcanvas {
  width: var(--sidebar-width);
  background:
    radial-gradient(1200px 400px at -10% -10%, rgba(79, 70, 229, 0.28), transparent 50%),
    linear-gradient(180deg, #111827 0%, var(--sidebar) 100%);
  color: #e2e8f0;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 1.15rem 1.1rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #fff;
  text-decoration: none;
}

.brand-mark {
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 0.7rem;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 8px 16px rgba(79, 70, 229, 0.35);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text small {
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 500;
}

.sidebar-nav {
  padding: 0.85rem 0.7rem 1rem;
  overflow-y: auto;
}

.sidebar .nav-link,
.sidebar-offcanvas .nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  border-radius: 0.7rem;
  padding: 0.58rem 0.75rem;
  color: #cbd5e1;
  font-size: 0.9rem;
  font-weight: 500;
  min-height: 42px;
}

.sidebar .nav-link i,
.sidebar-offcanvas .nav-link i {
  width: 1.1rem;
  text-align: center;
  opacity: 0.9;
}

.sidebar .nav-link:hover,
.sidebar-offcanvas .nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.sidebar .nav-link.active,
.sidebar-offcanvas .nav-link.active {
  background: rgba(79, 70, 229, 0.28);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(165, 180, 252, 0.25);
}

.nav-section {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7c8aa0;
  padding: 0.95rem 0.75rem 0.3rem;
  font-weight: 700;
}

.sidebar-footer {
  padding: 0.9rem 1.1rem 1.1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-tenant {
  font-size: 0.75rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-offcanvas {
  --bs-offcanvas-width: min(86vw, 300px);
  --bs-offcanvas-bg: var(--sidebar);
  --bs-offcanvas-color: #e2e8f0;
}

.sidebar-offcanvas .offcanvas-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-title {
  font-weight: 650;
  font-size: 0.95rem;
}

.empresa-switch {
  min-width: 0;
}

.empresa-switch .form-select {
  max-width: min(52vw, 280px);
  border: 1px solid var(--line);
  background-color: #fff;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 0.7rem;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 0.25rem 0.7rem 0.25rem 0.28rem;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.86rem;
}

.user-chip::after {
  margin-left: 0.15rem;
}

.user-avatar {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
  margin-bottom: 1.15rem;
}

.page-header h1,
.app-content > h1.h4,
.app-content > .h4 {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.045em;
  margin: 0;
}

.page-header .text-muted,
.page-lede {
  color: var(--muted) !important;
  font-size: 0.9rem;
}

.filter-bar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--surface);
}

.card-header {
  background: transparent;
  border-bottom-color: var(--line);
  font-weight: 650;
}

.card-footer {
  background: #fbfcfe;
  border-top-color: var(--line);
}

.table {
  --bs-table-bg: transparent;
  --bs-table-hover-bg: #f8fafc;
}

.table thead th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
  border-bottom-width: 1px;
  white-space: nowrap;
}

.table td {
  vertical-align: middle;
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}

.badge {
  font-weight: 650;
  letter-spacing: 0.01em;
  border-radius: 999px;
  padding: 0.4em 0.7em;
}

.btn {
  font-weight: 650;
  letter-spacing: -0.01em;
  border-radius: 0.7rem;
}

.btn-primary {
  background: linear-gradient(180deg, #6366f1, #4f46e5);
  border-color: #4338ca;
  box-shadow: 0 8px 16px rgba(79, 70, 229, 0.22);
}

.btn-primary:hover,
.btn-primary:focus {
  background: #4338ca;
  border-color: #3730a3;
}

.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-danger {
  background: #fff;
}

.form-control,
.form-select {
  border-color: #e2e8f0;
  border-radius: 0.7rem;
  min-height: 42px;
  box-shadow: none;
}

.form-control:focus,
.form-select:focus {
  border-color: #a5b4fc;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

label,
.form-label {
  font-size: 0.8rem;
  font-weight: 650;
  color: #475569;
  margin-bottom: 0.35rem;
}

.errorlist {
  list-style: none;
  padding: 0;
  margin: 0.3rem 0 0;
  color: #dc2626;
  font-size: 0.8rem;
}

.pagination {
  --bs-pagination-border-radius: 0.6rem;
  --bs-pagination-color: var(--ink);
  --bs-pagination-active-bg: var(--accent);
  --bs-pagination-active-border-color: var(--accent);
}

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

@media (min-width: 576px) {
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 992px) {
  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .kpi-grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.kpi-card {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.05rem 1.1rem;
  box-shadow: var(--shadow);
  min-height: 108px;
}

.kpi-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.8rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 1.15rem;
}

.kpi-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
}

.kpi-value {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.2;
  margin-top: 0.15rem;
}

.kpi-indigo .kpi-icon { background: #eef2ff; color: #4f46e5; }
.kpi-sky .kpi-icon { background: #e0f2fe; color: #0284c7; }
.kpi-emerald .kpi-icon { background: #ecfdf5; color: #059669; }
.kpi-amber .kpi-icon { background: #fffbeb; color: #d97706; }
.kpi-rose .kpi-icon { background: #fff1f2; color: #e11d48; }
.kpi-slate .kpi-icon { background: #f1f5f9; color: #475569; }

.status-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
}

.auth-body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(900px 420px at 10% 10%, rgba(99, 102, 241, 0.28), transparent 55%),
    radial-gradient(700px 380px at 90% 90%, rgba(14, 165, 233, 0.16), transparent 50%),
    linear-gradient(160deg, #0b1220, #111827 55%, #0f172a);
  color: var(--ink);
}

.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
}

.auth-brand {
  display: none;
  color: #e2e8f0;
  padding: 3rem;
}

.auth-brand h1 {
  color: #fff;
  font-size: 2.1rem;
  max-width: 12ch;
}

.auth-brand p {
  color: #94a3b8;
  max-width: 36ch;
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.login-card,
.onboarding-card,
.auth-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 1.15rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.login-card {
  max-width: 420px;
}

.onboarding-card {
  max-width: 860px;
}

.auth-card .card-body,
.login-card .card-body,
.onboarding-card .card-body {
  padding: 1.6rem;
}

@media (min-width: 992px) {
  .auth-shell {
    grid-template-columns: 1fr 1fr;
  }

  .auth-brand {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .auth-panel {
    padding: 2rem;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(8px);
  }
}

@media (max-width: 575.98px) {
  .page-header .btn {
    width: 100%;
  }

  .table td,
  .table th {
    font-size: 0.9rem;
  }

  .kpi-value {
    font-size: 1.28rem;
  }
}

.toast-container {
  z-index: 1100;
}

.toast {
  border-radius: 0.85rem;
}
