/* ATENÇÃO: design-tokens.css deve ser carregado ANTES deste arquivo. */

/* ============================================================
   P8W Contábil SST SaaS — App Layout v3 Big-Tech
   Redesign 2026-04-24 — Inspiração Linear/Vercel/Stripe
   ============================================================ */

/* ─── CSS Variables (layout-only) ── */
:root {
  --sidebar-w:         240px;
  --sidebar-collapsed: 58px;
  --topbar-h:          56px;
}

/* ─── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
body {
  font-family: var(--font);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
  overflow-x: hidden;
  letter-spacing: -0.005em;
}
a { color: var(--color-primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--color-primary-hover); }
img { max-width: 100%; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }
table { border-collapse: collapse; width: 100%; }
ul { list-style: none; }

/* ─── App Layout ── */
.app-body { display: flex; min-height: 100vh; background: var(--color-bg); }

/* ══════════════════════════════════════════════════════════
   SIDEBAR — Dark, minimalista, premium
   ══════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: #0a0a0d;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1000;
  transition: width var(--transition-base);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.06) transparent;
  border-right: 1px solid rgba(255,255,255,.05);
}
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 2px; }

/* Sidebar Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 .875rem;
  height: 56px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.sidebar-logo {
  display: flex; align-items: center; gap: .6rem;
  overflow: hidden; text-decoration: none;
  flex: 1; min-width: 0;
}
.logo-icon-img {
  height: 28px; width: auto; max-width: 110px;
  object-fit: contain; flex-shrink: 0;
  border-radius: 6px;
}
.logo-icon {
  width: 30px; height: 30px;
  background: var(--gradient-primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(59,130,246,.35);
}
.logo-text {
  font-size: .8125rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-toggle {
  color: rgba(255,255,255,.3);
  font-size: .875rem;
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: rgba(255,255,255,.08); color: rgba(255,255,255,.7); }

/* Nav Group Title */
.nav-group-title {
  font-size: .625rem;
  font-weight: 600;
  color: rgba(255,255,255,.22);
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 1.25rem .875rem .4rem;
  display: block;
  overflow: hidden;
  white-space: nowrap;
}

/* Nav Items */
.sidebar-nav { padding: .375rem 0 1rem; flex: 1; }
.nav-item { margin: 1px .5rem; }
.nav-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .46rem .65rem;
  color: rgba(255,255,255,.45);
  font-size: .8125rem;
  font-weight: 500;
  border-radius: 7px;
  transition: all var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
  letter-spacing: -0.01em;
}
.nav-link:hover {
  color: rgba(255,255,255,.85);
  background: rgba(255,255,255,.06);
}
.nav-item.active .nav-link {
  color: #fff;
  background: rgba(59,130,246,.15);
  box-shadow: inset 0 0 0 1px rgba(59,130,246,.2);
}
.nav-item.active .nav-icon { color: var(--color-primary-400); }
.nav-icon {
  font-size: .9375rem;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
  opacity: .75;
}
.nav-item.active .nav-icon { opacity: 1; }
.nav-text { flex: 1; }
.nav-link-danger { color: rgba(244,63,94,.6); }
.nav-link-danger:hover { color: #fb7185; background: rgba(244,63,94,.1); }

/* Sidebar Footer */
.sidebar-footer {
  flex-shrink: 0;
  padding: .75rem .5rem;
  border-top: 1px solid rgba(255,255,255,.05);
}

/* ══════════════════════════════════════════════════════════
   MAIN CONTENT
   ══════════════════════════════════════════════════════════ */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin var(--transition-base);
}

/* ══════════════════════════════════════════════════════════
   TOPBAR
   ══════════════════════════════════════════════════════════ */
.topbar {
  height: var(--topbar-h);
  background: var(--color-bg-card);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-xs);
}
.topbar-left  { display: flex; align-items: center; gap: .875rem; }
.topbar-right { display: flex; align-items: center; gap: .5rem; }
.topbar-toggle {
  font-size: 1rem; color: var(--color-text-secondary);
  display: none; padding: .3rem;
  border-radius: 6px; line-height: 1;
}
.topbar-toggle:hover { background: var(--color-bg-hover); color: var(--color-text); }

/* Breadcrumb */
.breadcrumb { display: flex; align-items: center; gap: .3rem; font-size: .75rem; }
.breadcrumb-link { color: var(--color-text-muted); font-weight: 400; transition: color var(--transition-fast); }
.breadcrumb-link:hover { color: var(--color-primary); }
.breadcrumb-current { color: var(--color-text); font-weight: 600; letter-spacing: -0.01em; }
.breadcrumb-sep { color: var(--color-text-disabled); font-size: .625rem; }

/* Theme Toggle */
.theme-toggle-admin {
  width: 34px; height: 34px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: .9375rem;
  color: var(--color-text-secondary);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  transition: all var(--transition-fast);
  cursor: pointer;
}
.theme-toggle-admin:hover {
  background: var(--color-bg-hover);
  color: var(--color-warning-500);
  border-color: var(--color-border-input);
}

/* Notifications */
.notif-btn {
  position: relative;
  width: 34px; height: 34px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: .9375rem;
  color: var(--color-text-secondary);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  transition: all var(--transition-fast);
  cursor: pointer;
}
.notif-btn:hover {
  background: var(--color-primary-50);
  color: var(--color-primary);
  border-color: var(--color-primary-200);
}
.notif-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--color-danger-500);
  color: #fff; font-size: .6rem; font-weight: 700;
  width: 16px; height: 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--color-bg-card);
}
.notif-dropdown {
  position: absolute;
  top: calc(var(--topbar-h) - 4px); right: 1rem;
  width: 360px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: var(--shadow-xl);
  z-index: 9990; overflow: hidden;
}
.notif-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--color-border);
  font-size: .8125rem; font-weight: 600; color: var(--color-text);
}
.notif-header button { color: var(--color-primary); font-size: .75rem; font-weight: 500; }
.notif-list { max-height: 300px; overflow-y: auto; }
.notif-item {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--color-divide);
  font-size: .8rem; cursor: pointer;
  transition: background var(--transition-fast);
}
.notif-item:hover { background: var(--color-bg-hover); }
.notif-item.unread { background: var(--color-primary-50); }
.notif-item-title { font-weight: 600; color: var(--color-text); font-size: .8125rem; }
.notif-item-body { color: var(--color-text-secondary); margin-top: .1rem; font-size: .775rem; }
.notif-item-time { color: var(--color-text-muted); font-size: .7rem; margin-top: .2rem; }
.notif-view-all {
  display: block; text-align: center; padding: .625rem;
  font-size: .775rem; border-top: 1px solid var(--color-border);
  color: var(--color-primary); font-weight: 500;
}

/* Profile Button */
.topbar-profile { position: relative; margin-left: .125rem; }
.profile-btn {
  display: flex; align-items: center; gap: .45rem;
  padding: .25rem .6rem .25rem .25rem;
  border-radius: 100px;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  cursor: pointer; transition: all var(--transition-fast);
  font-family: inherit; outline: none;
}
.profile-btn:hover {
  border-color: var(--color-primary-300);
  background: var(--color-primary-50);
  box-shadow: 0 0 0 3px var(--color-primary-100);
}
.profile-btn:focus-visible {
  box-shadow: var(--shadow-focus);
  border-color: var(--color-primary);
}
.profile-avatar-img {
  width: 28px; height: 28px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
  border: 1.5px solid var(--color-primary-200);
}
.profile-avatar-initial {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--gradient-primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .7rem; color: #fff; flex-shrink: 0;
}
.profile-name {
  font-size: .775rem; font-weight: 600;
  color: var(--color-text);
  max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  letter-spacing: -0.01em;
}
.profile-chevron {
  font-size: .45rem; color: var(--color-text-muted);
  transition: transform .2s ease;
}
#profileBtn[aria-expanded="true"] .profile-chevron { transform: rotate(180deg); }

/* Profile Dropdown */
.profile-dropdown {
  display: none; position: absolute; top: calc(100% + 8px); right: -8px;
  width: min(260px, calc(100vw - 1rem));
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: var(--shadow-xl);
  z-index: 9990; overflow: hidden;
}
.profile-dropdown.open { display: block; animation: profileSlideDown .18s ease; }
@keyframes profileSlideDown {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.profile-dropdown-header {
  display: flex; align-items: center; gap: .75rem;
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
}
.profile-dropdown-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  overflow: hidden; background: var(--gradient-primary);
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--color-primary-200);
}
.profile-dropdown-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.profile-dropdown-avatar span { font-weight: 700; font-size: .9rem; color: #fff; }
.profile-dropdown-name { font-size: .8125rem; font-weight: 700; color: var(--color-text); line-height: 1.3; }
.profile-dropdown-role { font-size: .7rem; color: var(--color-text-secondary); margin-top: 1px; font-weight: 500; }
.profile-dropdown-body { padding: .3rem 0; }
.profile-dropdown-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem 1rem; font-size: .8125rem; color: var(--color-text);
  transition: all var(--transition-fast); text-decoration: none; font-weight: 500;
}
.profile-dropdown-item:hover { background: var(--color-bg-hover); color: var(--color-primary); }
.profile-dropdown-item span { font-size: .95rem; width: 20px; text-align: center; flex-shrink: 0; }
.profile-dropdown-danger { color: var(--color-danger); }
.profile-dropdown-danger:hover { background: var(--color-danger-50); color: var(--color-danger); }
.profile-dropdown-divider { border: none; border-top: 1px solid var(--color-border); margin: .25rem .75rem; }

/* ══════════════════════════════════════════════════════════
   PAGE CONTENT
   ══════════════════════════════════════════════════════════ */
.page-content { flex: 1; padding: 1.5rem 1.375rem; }

.page-footer {
  padding: .875rem 1.375rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-card);
  color: var(--color-text-muted);
  text-align: center;
  font-size: .725rem;
  letter-spacing: .01em;
}

/* ══════════════════════════════════════════════════════════
   KPI GRID
   ══════════════════════════════════════════════════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: .875rem;
  margin-bottom: 1.25rem;
}
.kpi-card {
  background: var(--color-bg-card);
  border-radius: 10px;
  padding: 1.125rem 1.125rem 1rem;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: flex-start;
  gap: .875rem;
  transition: box-shadow var(--transition-fast), transform var(--transition-fast), border-color var(--transition-fast);
  position: relative;
  overflow: hidden;
}
.kpi-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  border-radius: 10px 10px 0 0;
}
.kpi-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-1px);
  border-color: var(--color-border-input);
}
.kpi-blue::after   { background: var(--gradient-primary); }
.kpi-green::after  { background: var(--gradient-success); }
.kpi-red::after    { background: var(--gradient-danger); }
.kpi-orange::after { background: var(--gradient-warning); }
.kpi-purple::after { background: var(--gradient-accent); }

.kpi-icon {
  font-size: 1.375rem;
  line-height: 1;
  flex-shrink: 0;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 9px;
  background: var(--color-bg-secondary);
}
.kpi-body    { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.kpi-value   { font-size: 1.5rem; font-weight: 800; color: var(--color-text); line-height: 1.1; letter-spacing: -0.04em; }
.kpi-label   { font-size: .725rem; color: var(--color-text-secondary); margin-top: .25rem; font-weight: 500; letter-spacing: .005em; }
.kpi-link    { font-size: .7rem; color: var(--color-primary); margin-top: .375rem; display: inline-flex; align-items: center; gap: .2rem; font-weight: 500; }
.kpi-link:hover { text-decoration: underline; }

/* ══════════════════════════════════════════════════════════
   CARD VARIANTS
   ══════════════════════════════════════════════════════════ */
.card-action  { font-size: .775rem; color: var(--color-primary); font-weight: 500; }
.card-ai      { border-left: 2px solid var(--color-primary); }
.card-danger  { border-left: 2px solid var(--color-danger); }
.card-success { border-left: 2px solid var(--color-success); }
.card-warning { border-left: 2px solid var(--color-warning); }

/* ══════════════════════════════════════════════════════════
   AI FEATURE CARDS
   ══════════════════════════════════════════════════════════ */
.ai-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .875rem; }
.ai-feature-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 1.25rem 1rem;
  text-align: center;
  transition: all var(--transition-base);
  color: var(--color-text);
  cursor: pointer;
}
.ai-feature-card:hover {
  background: var(--color-primary);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(59,130,246,.25);
  border-color: var(--color-primary);
}
.ai-icon  { font-size: 1.75rem; margin-bottom: .5rem; display: block; }
.ai-title { font-weight: 600; font-size: .8125rem; letter-spacing: -0.01em; }
.ai-desc  { font-size: .75rem; color: var(--color-text-secondary); margin-top: .25rem; }
.ai-feature-card:hover .ai-desc { color: rgba(255,255,255,.7); }

/* ══════════════════════════════════════════════════════════
   PAGINATION
   ══════════════════════════════════════════════════════════ */
.pagination, .pagination-wrap {
  display: flex; align-items: center; gap: .25rem;
  padding: .875rem 1.25rem;
  border-top: 1px solid var(--color-divide);
  flex-wrap: wrap;
}
.pagination-info { color: var(--color-text-secondary); margin-right: auto; font-size: .775rem; }
.page-btn, .page-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px;
  padding: 0 .5rem;
  border-radius: 7px;
  color: var(--color-text-secondary);
  font-size: .775rem; font-weight: 500;
  border: 1px solid var(--color-border);
  transition: all var(--transition-fast);
  text-decoration: none;
}
.page-btn:hover, .page-btn.active,
.page-link:hover, .page-link.active {
  background: var(--color-primary); color: #fff; border-color: var(--color-primary);
}

/* ══════════════════════════════════════════════════════════
   RISK & PROGRESS
   ══════════════════════════════════════════════════════════ */
.risk-score { display: inline-flex; align-items: center; gap: .4rem; font-weight: 700; }
.risk-bar { width: 100%; height: 4px; background: var(--color-border); border-radius: 2px; overflow: hidden; }
.risk-bar-fill { height: 100%; border-radius: 2px; transition: width .5s ease; }

/* ══════════════════════════════════════════════════════════
   TOASTS
   ══════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed; bottom: 1.25rem; right: 1.25rem;
  z-index: 9999; display: flex; flex-direction: column; gap: .4rem;
}
.toast {
  background: #18181b;
  color: #fafafa;
  padding: .75rem 1rem;
  border-radius: 9px;
  box-shadow: var(--shadow-xl);
  font-size: .8125rem; font-weight: 500;
  animation: toastIn .22s ease;
  max-width: 360px;
  display: flex; align-items: center; gap: .65rem;
  border: 1px solid rgba(255,255,255,.08);
  letter-spacing: -0.01em;
}
.toast-success { background: #052e16; border-color: rgba(16,185,129,.3); }
.toast-error   { background: #4c0519; border-color: rgba(244,63,94,.3); }
@keyframes toastIn {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ══════════════════════════════════════════════════════════
   FILTER BAR
   ══════════════════════════════════════════════════════════ */
.filter-bar {
  display: flex; gap: .625rem;
  align-items: center; flex-wrap: wrap;
}
.search-input {
  flex: 1; min-width: min(200px, 100%); max-width: 360px;
  padding: .45rem .875rem;
  border: 1px solid var(--color-border);
  border-radius: 7px;
  font-size: .8125rem; font-family: inherit;
  background: var(--color-bg-card);
  color: var(--color-text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

/* ══════════════════════════════════════════════════════════
   STAT BOXES
   ══════════════════════════════════════════════════════════ */
.stat-row { display: flex; gap: .875rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.stat-box {
  flex: 1; min-width: 110px;
  background: var(--color-bg-secondary);
  border-radius: 9px; padding: .875rem;
  text-align: center; border: 1px solid var(--color-border);
}
.stat-box-value { font-size: 1.375rem; font-weight: 800; letter-spacing: -0.04em; }
.stat-box-label { font-size: .7rem; color: var(--color-text-secondary); margin-top: .2rem; font-weight: 500; }
.stat-box-danger  { background: color-mix(in srgb, var(--color-danger-500) 8%, var(--color-bg)); border-color: color-mix(in srgb, var(--color-danger-500) 25%, transparent); }
.stat-box-warning { background: color-mix(in srgb, var(--color-warning-500) 8%, var(--color-bg)); border-color: color-mix(in srgb, var(--color-warning-500) 25%, transparent); }
.stat-val-danger  { color: var(--color-danger); }
.stat-val-warning { color: var(--color-warning); }

/* QR Frame */
.qr-frame { display: inline-block; padding: 10px; background: #fff; border-radius: 8px; border: 1px solid var(--color-border); }

/* ══════════════════════════════════════════════════════════
   GRID LAYOUTS
   ══════════════════════════════════════════════════════════ */
.row { display: grid; gap: 1.125rem; }
.row-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); margin-bottom: 1.125rem; }
.row-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); margin-bottom: 1.125rem; }
.col-md-4 { width: 100%; }
.col-md-8 { width: 100%; }
@media (min-width: 768px) {
  .row.row-cols-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .col-wrapper { display: grid; grid-template-columns: 1fr 2fr; gap: 1.375rem; }
  .col-wrapper-half { display: grid; grid-template-columns: 1fr 1fr; gap: 1.375rem; }
}

/* ══════════════════════════════════════════════════════════
   BTN AI / GRADIENT
   ══════════════════════════════════════════════════════════ */
.btn-ai {
  background: linear-gradient(135deg, var(--color-primary-600) 0%, var(--color-accent-600) 100%);
  color: #fff; border-color: transparent;
}
.btn-ai:hover {
  background: linear-gradient(135deg, var(--color-primary-700) 0%, var(--color-accent-700) 100%);
  color: #fff;
}

/* ══════════════════════════════════════════════════════════
   CODE
   ══════════════════════════════════════════════════════════ */
code {
  background: var(--color-bg-secondary);
  color: var(--color-primary);
  font-family: var(--font-mono);
  font-size: .8em;
  padding: .15em .4em;
  border-radius: 5px;
  border: 1px solid var(--color-border);
}

/* ══════════════════════════════════════════════════════════
   HR
   ══════════════════════════════════════════════════════════ */
hr { border: none; border-top: 1px solid var(--color-border); margin: 1.125rem 0; }

/* ══════════════════════════════════════════════════════════
   UTILITIES
   ══════════════════════════════════════════════════════════ */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger  { color: var(--color-danger); }
.text-muted   { color: var(--color-text-muted); }
.d-flex          { display: flex !important; }
.d-grid          { display: grid !important; }
.align-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.flex-wrap       { flex-wrap: wrap; }
.gap-1 { gap: .4rem; }
.gap-2 { gap: .75rem; }
.gap-3 { gap: 1rem; }
.h-100 { height: 100%; }
.w-100 { width: 100%; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: .25rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.p-0  { padding: 0 !important; }
.p-1  { padding: .5rem; }
.p-2  { padding: 1rem; }
.p-3  { padding: 1.5rem; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-sm  { font-size: .775rem; }

/* ══════════════════════════════════════════════════════════
   LOGIN PAGE
   ══════════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  background: #09090b;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
  position: relative;
}
.login-page::before {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 60% 50% at 20% 40%, rgba(59,130,246,.12) 0%, transparent 60%),
    radial-gradient(ellipse 40% 40% at 80% 20%, rgba(139,92,246,.08) 0%, transparent 60%);
}
.login-card {
  background: rgba(24,24,27,.95);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  padding: 2.25rem 2rem;
  width: 100%; max-width: 420px;
  box-shadow: 0 24px 64px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.04);
  position: relative; z-index: 1;
  backdrop-filter: blur(20px);
}
.login-logo { text-align: center; margin-bottom: 1.75rem; }
.login-logo-icon {
  width: 52px; height: 52px;
  background: var(--gradient-primary);
  border-radius: 13px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 8px 24px rgba(59,130,246,.4);
  margin-bottom: .75rem;
}
.login-logo h1 { font-size: 1.25rem; font-weight: 800; color: #fff; letter-spacing: -0.03em; }
.login-logo p  { font-size: .775rem; color: rgba(255,255,255,.4); margin-top: .2rem; }

/* ══════════════════════════════════════════════════════════
   SIDEBAR MOBILE
   ══════════════════════════════════════════════════════════ */
.sidebar-close {
  display: none;
  color: rgba(255,255,255,.4);
  font-size: 1rem;
  width: 28px; height: 28px;
  border-radius: 6px;
  align-items: center; justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}
.sidebar-close:hover { background: rgba(255,255,255,.08); color: rgba(255,255,255,.8); }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 999;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: opacity .25s;
}
.sidebar-overlay.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ══════════════════════════════════════════════════════════
   SIDEBAR COLLAPSED
   ══════════════════════════════════════════════════════════ */
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-group-title { display: none; }
.sidebar.collapsed + .main-content { margin-left: var(--sidebar-collapsed); }
.sidebar.collapsed .nav-link { justify-content: center; padding: .46rem; }
.sidebar.collapsed .nav-icon { width: auto; }

/* ══════════════════════════════════════════════════════════
   DARK MODE OVERRIDES (complementares)
   ══════════════════════════════════════════════════════════ */
[data-theme="dark"] .topbar {
  background: #18181b;
  border-bottom-color: #27272a;
  box-shadow: 0 1px 0 #27272a;
}
[data-theme="dark"] .notif-item.unread { background: rgba(59,130,246,.08); }
[data-theme="dark"] .notif-dropdown,
[data-theme="dark"] .profile-dropdown {
  background: #18181b;
  border-color: #27272a;
  box-shadow: var(--shadow-modal);
}
[data-theme="dark"] .profile-dropdown-header { background: #27272a; }
[data-theme="dark"] .profile-dropdown-item:hover { background: #27272a; }
[data-theme="dark"] .profile-btn { background: #27272a; border-color: #3f3f46; }
[data-theme="dark"] .profile-btn:hover { background: rgba(59,130,246,.12); border-color: rgba(59,130,246,.3); }
[data-theme="dark"] .notif-btn,
[data-theme="dark"] .theme-toggle-admin {
  background: #27272a; border-color: #3f3f46; color: #a1a1aa;
}
[data-theme="dark"] .notif-btn:hover { background: rgba(59,130,246,.12); color: var(--color-primary-400); border-color: rgba(59,130,246,.3); }
[data-theme="dark"] .theme-toggle-admin:hover { background: rgba(245,158,11,.1); color: var(--color-warning-500); border-color: rgba(245,158,11,.3); }
[data-theme="dark"] .search-input { background: #27272a; border-color: #3f3f46; color: #fafafa; }
[data-theme="dark"] .kpi-card { background: #18181b; border-color: #27272a; }
[data-theme="dark"] .kpi-icon { background: #27272a; }
[data-theme="dark"] .login-card input,
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea { background: #27272a; border-color: #3f3f46; color: #fafafa; }
[data-theme="dark"] code { background: #27272a; border-color: #3f3f46; }
[data-theme="dark"] .stat-box { background: #27272a; border-color: #3f3f46; }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .row-3 { grid-template-columns: 1fr 1fr; }
  .ai-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .col-wrapper { grid-template-columns: 1fr !important; }
  .col-wrapper-half { grid-template-columns: 1fr !important; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
    transition: transform .28s cubic-bezier(0.4,0,0.2,1);
    width: min(272px, 88vw);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0,0,0,.4);
  }
  .sidebar-close  { display: flex; }
  .sidebar-toggle { display: none; }
  .main-content   { margin-left: 0; }
  .topbar-toggle  { display: flex; }
  .row-2, .row-3  { grid-template-columns: 1fr; }
  .kpi-grid       { grid-template-columns: repeat(2, 1fr); }
  .ai-grid        { grid-template-columns: repeat(2, 1fr); }
  .notif-dropdown { right: .5rem; width: calc(100vw - 1rem); max-width: 400px; }
  .page-content   { padding: 1.125rem .875rem; }
  .app-body, .main-content, .page-content { overflow-x: hidden; max-width: 100vw; }
  .topbar   { padding: 0 .875rem; }
  .profile-name, .profile-chevron { display: none; }
  .profile-btn { padding: .2rem; border-radius: 50%; }
  .profile-dropdown { right: -8px; width: 240px; }
  .breadcrumb { font-size: .7rem; }
  .breadcrumb-current { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .filter-bar { flex-direction: row; flex-wrap: wrap; gap: .4rem; }
  .filter-bar input,
  .filter-bar select,
  .filter-bar .search-input { flex: 1 1 100%; min-width: 0; max-width: 100% !important; }
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  input[type="number"],
  input[type="tel"],
  input[type="date"],
  select, textarea { font-size: 16px !important; }
  .stat-row { gap: .625rem; }
}

@media (max-width: 480px) {
  .kpi-grid       { grid-template-columns: 1fr !important; }
  .page-content   { padding: .875rem .75rem; }
  .login-card     { padding: 1.75rem 1.125rem; }
  .login-page     { padding: .875rem; }
  .stat-row       { flex-direction: column; }
  .ai-grid        { grid-template-columns: 1fr !important; }
  .topbar-right   { gap: .35rem; }
  .notif-btn, .theme-toggle-admin { width: 30px; height: 30px; font-size: .875rem; }
  .profile-avatar-initial, .profile-avatar-img { width: 26px; height: 26px; }
  .toast-container { right: .75rem; left: .75rem; bottom: .875rem; }
  .toast { max-width: 100%; }
  .notif-dropdown { right: 0; left: 0; width: 100vw; border-radius: 0 0 12px 12px; }
  .sidebar { width: 100vw; max-width: 300px; }
  .page-btn, .page-link { min-width: 32px; height: 32px; font-size: .725rem; }
  .pagination-info { font-size: .725rem; width: 100%; text-align: center; margin-right: 0; }
}

@media (max-width: 360px) {
  .page-content { padding: .75rem .5rem; }
  .topbar { height: 50px; padding: 0 .5rem; }
  .kpi-value { font-size: 1.3rem; }
  .login-card { padding: 1.5rem .875rem; }
  .login-logo h1 { font-size: 1.1rem; }
  .profile-dropdown { width: calc(100vw - .875rem); right: 0; }
}
