/* ============ App shell ============ */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .25s var(--ease); }
.app.collapsed { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }

/* ============ Sidebar ============ */
.sidebar {
  position: sticky; top: 0; height: 100vh; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; z-index: 40; overflow: hidden;
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 18px 18px 14px; min-height: var(--header-h); }
.sidebar-brand .logo-mark { flex: 0 0 34px; }
.sidebar-brand .brand-text { line-height: 1.1; white-space: nowrap; }
.sidebar-brand .brand-text strong { color: #fff; font-size: 16px; letter-spacing: -.01em; }
.sidebar-brand .brand-text span { display: block; font-size: 11px; color: var(--sidebar-muted); margin-top: 2px; }
.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px 10px 16px; scrollbar-width: thin; scrollbar-color: #1E293B transparent; }
.nav-group { margin-top: 4px; }
.nav-group-btn {
  width: 100%; display: flex; align-items: center; gap: 11px; padding: 9px 10px; border: 0; border-radius: 9px;
  background: transparent; color: var(--sidebar-text); font-size: 13.5px; font-weight: 550; text-align: left; white-space: nowrap;
}
.nav-group-btn:hover { background: var(--sidebar-hover); color: #fff; }
.nav-group-btn .ico { flex: 0 0 18px; opacity: .85; }
.nav-group-btn .chev { margin-left: auto; transition: transform .2s; opacity: .5; }
.nav-group.open .nav-group-btn .chev { transform: rotate(90deg); }
.nav-group.has-active > .nav-group-btn { color: #fff; }
.nav-items { display: none; padding: 2px 0 6px 0; }
.nav-group.open .nav-items { display: block; animation: fadeIn .2s; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px 7px 39px; border-radius: 8px; color: var(--sidebar-text);
  font-size: 13px; white-space: nowrap; position: relative;
}
.nav-link:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--sidebar-active); color: #fff; font-weight: 550; }
.nav-link.active::before { content: ""; position: absolute; left: 22px; top: 50%; width: 5px; height: 5px; border-radius: 50%; background: #60A5FA; transform: translateY(-50%); }
.nav-link .count { margin-left: auto; font-size: 11px; background: rgba(255,255,255,.1); padding: 0 7px; border-radius: 99px; }
.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.06); }
.demo-pill { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: #FCD34D; background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.25); padding: 7px 10px; border-radius: 9px; white-space: nowrap; }
.collapse-btn { margin-top: 8px; width: 100%; display: flex; align-items: center; gap: 10px; border: 0; background: transparent; color: var(--sidebar-muted); padding: 8px 10px; border-radius: 8px; font-size: 12.5px; white-space: nowrap; }
.collapse-btn:hover { background: var(--sidebar-hover); color: #fff; }

.app.collapsed .brand-text, .app.collapsed .nav-group-btn .lbl, .app.collapsed .nav-group-btn .chev, .app.collapsed .nav-items, .app.collapsed .demo-pill span, .app.collapsed .collapse-btn .lbl { display: none !important; }
.app.collapsed .nav-group-btn { justify-content: center; padding: 10px; }
.app.collapsed .sidebar-brand { padding: 18px 19px 14px; }
.app.collapsed .demo-pill { justify-content: center; }
.app.collapsed .collapse-btn { justify-content: center; }
.app.collapsed .collapse-btn svg { transform: rotate(180deg); }

/* ============ Header ============ */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--header-h); display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.6) blur(12px); -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .menu-btn { display: none; }
.search-box { position: relative; flex: 1 1 auto; max-width: 520px; }
.search-box input {
  width: 100%; height: 40px; padding: 0 70px 0 40px; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search-box input:focus { border-color: var(--brand); box-shadow: var(--ring); }
.search-box > .ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search-box kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  max-height: 440px; overflow: auto; padding: 6px; animation: scaleIn .15s var(--ease); z-index: 60;
}
.search-results .sr-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 10px 4px; font-weight: 600; }
.search-results a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.search-results a:hover, .search-results a.kb { background: var(--surface-2); text-decoration: none; }
.search-results a .sub { margin-left: auto; color: var(--muted); font-size: 12px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.site-select { height: 38px; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 0 10px; font-size: 13px; color: var(--text-2); max-width: 200px; }
.icon-btn { position: relative; width: 38px; height: 38px; display: inline-grid; place-items: center; border: 1px solid transparent; background: transparent; border-radius: 10px; color: var(--text-2); }
.icon-btn:hover { background: var(--surface); border-color: var(--border); }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--bg); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border: 1px solid transparent; border-radius: 12px; background: transparent; text-align: left; }
.user-chip:hover { background: var(--surface); border-color: var(--border); }
.user-chip .meta { line-height: 1.15; }
.user-chip .meta strong { display: block; font-size: 13px; }
.user-chip .meta span { font-size: 11.5px; color: var(--muted); }

.demo-banner { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12px; padding: 5px 12px; background: linear-gradient(90deg, rgba(37,99,235,.08), rgba(124,58,237,.08)); color: var(--text-2); border-bottom: 1px solid var(--border); text-align: center; }
.demo-banner b { color: var(--violet); }

/* ============ Page ============ */
.content { padding: 24px 28px 48px; width: 100%; max-width: 1560px; margin: 0 auto; animation: slideUp .3s var(--ease); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -.02em; }
.page-head .desc { color: var(--muted); margin-top: 4px; max-width: 760px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumbs { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; flex-wrap: wrap; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--brand); }
.breadcrumbs .sep { opacity: .5; }

.grid { display: grid; gap: 16px; }
.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)); }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; } .span-all { grid-column: 1 / -1; }
.layout-side { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }

/* ============ Login ============ */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); background: var(--bg); }
.login-left { display: flex; flex-direction: column; padding: 36px clamp(24px, 5vw, 72px); overflow-y: auto; }
.login-form-wrap { width: 100%; max-width: 420px; margin: auto 0; padding: 40px 0 24px; }
.login-left h1 { font-size: 30px; letter-spacing: -.025em; margin: 26px 0 8px; }
.login-left .lead { color: var(--muted); font-size: 15px; }
.login-right {
  position: relative; overflow: hidden; background: radial-gradient(1200px 600px at 80% -10%, #3B2A8C 0%, transparent 60%), radial-gradient(900px 600px at -10% 110%, #1D4ED8 0%, transparent 55%), #0B1022;
  color: #fff; display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(28px, 4vw, 64px);
}
.login-right::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: 44px 44px; mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%); pointer-events: none; }
.login-right h2 { font-size: clamp(24px, 2.4vw, 34px); letter-spacing: -.025em; max-width: 560px; position: relative; z-index: 1; }
.login-right p { color: #B8C2DB; max-width: 520px; margin-top: 12px; font-size: 15px; position: relative; z-index: 1; }
.mockup { position: relative; z-index: 1; margin-top: 36px; }
.mock-window { background: rgba(255,255,255,.96); color: #0F172A; border-radius: 16px; box-shadow: 0 40px 80px -20px rgba(0,0,0,.6); overflow: hidden; transform: perspective(1600px) rotateY(-6deg) rotateX(3deg); transform-origin: left center; max-width: 640px; }
.mock-top { display: flex; align-items: center; gap: 6px; padding: 10px 14px; background: #F1F5F9; border-bottom: 1px solid #E2E8F0; }
.mock-top i { width: 9px; height: 9px; border-radius: 50%; background: #CBD5E1; display: block; }
.mock-body { display: grid; grid-template-columns: 54px 1fr; min-height: 300px; }
.mock-side { background: #0F172A; padding: 12px 0; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.mock-side b { width: 22px; height: 6px; border-radius: 4px; background: #334155; display: block; }
.mock-side b.on { background: #3B82F6; }
.mock-main { padding: 14px; display: grid; gap: 10px; }
.mock-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mock-kpi { border: 1px solid #E2E8F0; border-radius: 10px; padding: 9px 10px; }
.mock-kpi small { display: block; font-size: 9.5px; color: #64748B; }
.mock-kpi strong { font-size: 14px; }
.mock-kpi em { font-style: normal; font-size: 9.5px; color: #059669; font-weight: 600; }
.mock-charts { display: grid; grid-template-columns: 1.6fr 1fr; gap: 8px; }
.mock-card { border: 1px solid #E2E8F0; border-radius: 10px; padding: 9px 10px; font-size: 10px; color: #64748B; }
.mock-float { position: absolute; background: #fff; color: #0F172A; border-radius: 12px; box-shadow: 0 20px 40px -10px rgba(0,0,0,.5); padding: 10px 12px; font-size: 11.5px; display: flex; align-items: center; gap: 10px; animation: slideUp .6s var(--ease) both; }
.mock-float.f1 { right: 2%; top: -18px; animation-delay: .3s; }
.mock-float.f2 { left: 46%; bottom: -24px; animation-delay: .5s; }
.mock-float .fi { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff; }
.login-features { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 48px; position: relative; z-index: 1; color: #B8C2DB; font-size: 13px; }
.login-features span { display: flex; align-items: center; gap: 7px; }
.profiles-section { padding: 48px clamp(20px, 5vw, 72px) 64px; background: var(--surface); border-top: 1px solid var(--border); }
.profiles-section h2 { font-size: 24px; letter-spacing: -.02em; }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 24px; }
.profile-card { border: 1px solid var(--border); border-radius: 14px; padding: 18px; background: var(--surface); display: flex; flex-direction: column; gap: 10px; transition: transform .2s var(--ease), box-shadow .2s, border-color .2s; }
.profile-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--brand-100); }
.profile-card h3 { font-size: 15px; }
.profile-card p { font-size: 13px; color: var(--muted); flex: 1; }
.profile-card .mail { font-size: 11.5px; color: var(--faint); font-family: var(--font-mono); }

/* Overlay for mobile sidebar */
.scrim { position: fixed; inset: 0; background: var(--overlay); z-index: 35; animation: fadeIn .2s; }

/* ============ Footer ============ */
.site-footer { font-size: 12px; color: var(--muted); line-height: 1.55; display: flex; flex-direction: column; gap: 4px; }
.site-footer b { color: var(--text-2); }
.site-footer a { color: var(--brand); font-weight: 600; }
.main > .site-footer { margin-top: auto; padding: 16px 28px 22px; border-top: 1px solid var(--border); background: var(--surface); text-align: center; align-items: center; }
.login-left .site-footer { max-width: 420px; }
@media (max-width: 860px) { .main > .site-footer { padding: 14px 16px 20px; } }
