/* Estrutura: sidebar fixa, topbar, conteúdo */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-5) var(--sp-4);
  background: var(--sidebar-bg);
  border-right: 1px solid rgba(255, 255, 255, .06);
  backdrop-filter: blur(14px);
  color: #DCE1EE;
  z-index: 40;
}
.sidebar .brand { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 6px 10px 18px; margin-bottom: 4px; border-bottom: 1px solid rgba(255, 255, 255, .06); color: #fff; }
.sidebar .brand:hover { text-decoration: none; }
.sidebar .brand img { width: 150px; height: auto; display: block; }
.sidebar .brand .product { font-size: var(--fs-xs); letter-spacing: .14em; text-transform: uppercase; color: var(--brand-300); font-weight: 600; }
.nav-section { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .09em; color: #8C96AE; padding: 14px 10px 6px; font-weight: 600; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 10px;
  color: #C9CFDD; font-weight: 500;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.nav-link svg { width: 18px; height: 18px; opacity: .85; }
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-link.active { background: linear-gradient(90deg, rgba(10, 120, 210, .28), rgba(10, 120, 210, .05)); color: #FFFFFF; box-shadow: inset 3px 0 0 var(--brand-400); }
.nav-link.active svg { opacity: 1; color: var(--brand-400); }
.sidebar-foot { margin-top: auto; padding: 12px 10px 0; font-size: var(--fs-xs); color: #7F89A3; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 0 var(--sp-8);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .menu-toggle { display: none; }
.global-search { position: relative; flex: 1; max-width: 520px; }
.global-search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-faint); pointer-events: none; }
.global-search input { padding-left: 38px; background: var(--surface-2); border-color: transparent; }
.global-search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }

.content { padding: var(--sp-6) var(--sp-8) var(--sp-10); width: 100%; max-width: 1480px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-6); }
.page-head h1 { margin: 2px 0 0; }
.page-head .subtitle { color: var(--text-muted); margin: 4px 0 0; }
.page-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.breadcrumb { display: flex; gap: 6px; align-items: center; font-size: var(--fs-sm); color: var(--text-faint); list-style: none; padding: 0; margin: 0; flex-wrap: wrap; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb li + li::before { content: "/"; margin-right: 6px; color: var(--text-faint); }

.grid { display: grid; gap: var(--sp-5); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: var(--sp-5); }
.row { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.overlay { display: none; }

/* Auth (login) */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero {
  position: relative; overflow: hidden; padding: 56px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: #08111F;
  background-image: radial-gradient(800px 500px at 20% 10%, rgba(10, 120, 210, .28), transparent 60%),
                    radial-gradient(700px 500px at 90% 100%, rgba(10, 155, 240, .22), transparent 60%);
  color: #E7EAF3;
}
.auth-hero::after {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 48px 48px; mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
  pointer-events: none;
}
.auth-hero h2 { font-size: 2.25rem; max-width: 460px; letter-spacing: -0.03em; position: relative; z-index: 1; }
.auth-hero p { color: #A3ACC2; max-width: 440px; position: relative; z-index: 1; }
.auth-hero .brand img { width: 260px; height: auto; position: relative; z-index: 1; }
.auth-hero .brand .product { display: block; margin-top: 10px; position: relative; z-index: 1; font-size: var(--fs-sm); letter-spacing: .16em; text-transform: uppercase; color: var(--brand-300); font-weight: 600; }
.auth-card .brand-mobile img { width: 180px; height: auto; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: var(--fs-xl); margin-bottom: 4px; }
.auth-card .brand-mobile { display: none; margin-bottom: 28px; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform var(--t-slow) var(--ease); box-shadow: var(--shadow-lg); background: #0B1020; }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .overlay { display: block; position: fixed; inset: 0; background: rgba(5, 8, 18, .55); z-index: 35; }
  .topbar { padding: 0 var(--sp-4); }
  .topbar .menu-toggle { display: inline-flex; }
  .content { padding: var(--sp-5) var(--sp-4) var(--sp-8); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-card .brand-mobile { display: block; }
  .global-search kbd { display: none; }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: 1fr; }
  .user-menu .user-name { display: none; }
}

.when-light { display: none; }
:root[data-theme="light"] .when-light { display: inline-flex; }
:root[data-theme="light"] .when-dark { display: none; }

/* Rodapé */
.app-footer { margin-top: auto; display: flex; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; padding: var(--sp-5) var(--sp-8); border-top: 1px solid var(--border); font-size: var(--fs-xs); color: var(--text-faint); }
.app-footer strong { color: var(--text-muted); font-weight: 600; }
.auth-credit { margin: 32px 0 0; text-align: center; font-size: var(--fs-xs); color: var(--text-faint); }
.auth-credit strong { color: var(--text-muted); font-weight: 600; }
@media (max-width: 900px) { .app-footer { padding: var(--sp-4); justify-content: center; text-align: center; } }
@media (min-width: 901px) { .auth-credit { display: none; } }
