:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --elev: #ffffff;
  --muted: #6b7280;
  --text: #1f2937;
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --accent: #7c3aed;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #E66C37;
  --border: #e5e7eb;
  --chip: #f3f4f6;
  --shadow: 0 4px 6px rgba(0,0,0,.08);
  --radius-lg: 10px;
  --radius-md: 6px;
  --radius-sm: 4px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg);
  color: var(--text); font: 400 15px/1.5 "Fira Sans", system-ui, -apple-system, Segoe UI, Roboto, Arial;
  letter-spacing:.2px;
}
a { color: var(--primary); text-decoration: none; }

.app {
  display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; gap: 0;
}

/* Sidebar */
.sidebar { 
  position: sticky; top: 0; align-self: start; height: 100vh; overflow: auto;
  background: var(--surface); border-right: 1px solid var(--border); 
}
.brand { 
  display: flex; align-items: center; gap: 12px; padding: 22px 22px; border-bottom: 1px solid var(--border); 
}
.logo { 
  display:grid; place-items:center; width: 36px; height: 36px; border-radius: 10px; 
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%); 
  box-shadow: var(--shadow); font-weight: 800; color: white; 
}
.brand h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: .5px; }
.sidebar .search { padding: 14px 18px 8px; }
.input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 12px; padding: 10px 12px; outline: none; transition:.2s border;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
nav { padding: 10px 10px 22px; }
.menu-group { 
  color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .8px; padding: 12px 12px 6px; 
}
details.menu { margin: 2px 8px; border-radius: 12px; overflow: hidden; }
details.menu > summary {
  list-style: none; cursor: pointer; padding: 12px 14px; display: flex; align-items:center; gap: 10px; border-radius: 12px;
  color: var(--text); background: transparent; transition: .15s background; outline: none;
}
details.menu[open] > summary, details.menu > summary:hover { background: var(--chip); }
details.menu[open] > summary .chev { transform: rotate(90deg); }
.chev { margin-left: auto; opacity:.5; transition: transform .2s ease; }
.submenu { padding: 6px 8px 10px; }
.submenu a {
  display: block; padding: 9px 12px 9px 36px; color: var(--muted); border-radius: 10px; margin: 2px 0; 
  transition: .15s background, .2s color;
}
.submenu a:hover { background: var(--chip); color: var(--text); }
.submenu a.active { background: var(--primary); color: white; }
.menu .badge { 
  margin-left: 8px; padding: 2px 8px; font-size: 11px; border-radius: 999px; 
  background: var(--chip); color: var(--muted); border: 1px solid var(--border); 
}

/* Main */
.main { display:flex; flex-direction: column; }
.topbar { 
  position: sticky; top: 0; z-index: 5; backdrop-filter: saturate(120%) blur(8px);
  background: rgba(255,255,255,.85); border-bottom: 1px solid var(--border); 
}
.topbar-inner { display:flex; align-items:center; gap: 14px; padding: 12px 20px; }
.crumbs { color: var(--muted); font-size: 13px; }
.spacer { flex: 1; }
.chip { 
  display:inline-flex; align-items:center; gap:8px; background: var(--chip); border:1px solid var(--border); color: var(--text);
  padding: 6px 10px; border-radius: 999px; font-size: 12px; 
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.btn { 
  background: var(--primary); color: white; padding: 10px 14px; border:0;
  border-radius: 12px; font-weight:600; cursor: pointer; box-shadow: 0 2px 8px rgba(37,99,235,.2); transition: .2s all; 
}
.btn:hover { background: var(--primary-600); box-shadow: 0 4px 12px rgba(37,99,235,.3); }

.page { padding: 22px 24px 40px; display: grid; gap: 22px; }

/* Sections */
.panel { 
  background: var(--surface);
  border:1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); 
}
.panel-header { 
  display:flex; align-items:center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); 
}
.panel-title { font-size: 16px; font-weight: 600; letter-spacing:.3px; }
.panel-body { padding: 14px 18px 18px; }

/* Power BI Embed */
.powerbi-container {
  width: 100%;
  min-height: 1200px;
  height: auto;
  position: relative;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  overflow: visible;
}

.powerbi-container iframe {
  width: 100%;
  height: 100%;
  min-height: 1200px;
  border: none;
}

.embed-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 600px;
  color: var(--muted);
  gap: 12px;
}

.embed-placeholder svg {
  width: 64px;
  height: 64px;
  opacity: 0.3;
}

/* Report Grid */
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  transition: all 0.2s;
  cursor: pointer;
}

.report-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.report-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
}

.report-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
th { 
  color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing:.6px; 
}
tr:hover td { background: var(--chip); }
.pill { 
  padding: 2px 8px; border-radius: 999px; font-size: 12px; border:1px solid var(--border);
  background: var(--chip); color: var(--text); 
}
.pill.low { color:#0369a1; border-color:#e0f2fe; background:#f0f9ff; }
.pill.medium { color:#d97706; border-color:#fed7aa; background:#fef3c7; }
.pill.high { color:#dc2626; border-color:#fecaca; background:#fee2e2; }

.legend { 
  display:flex; gap:12px; align-items:center; font-size:12px; color:var(--muted); 
}
.legend .l { width: 10px; height: 10px; border-radius: 2px; }

/* Loading State */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 1200px) {
  .app { grid-template-columns: 84px 1fr; }
  .brand h1 { display:none; }
  .submenu a { padding-left: 22px; }
}

@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: relative; }
  .report-grid { grid-template-columns: 1fr; }
}
