:root {
  --brand-700: #C2550B;
  --brand-600: #E4650E;
  --brand-500: #EF8438;
  --brand-100: #FCEADA;
  --brand-50: #FDF3EA;
  --ink-900: #23262B;
  --ink-700: #3A3F47;
  --slate-600: #667085;
  --slate-400: #98A2B3;
  --line: #EDEFF3;
  --surface: #FFFFFF;
  --page-bg: #FFFFFF;
  --success: #17A34A;
  --danger: #DC4747;
  --shadow-sm: 0 1px 2px rgba(35, 38, 43, 0.05);
  --shadow-md: 0 10px 28px rgba(35, 38, 43, 0.07);
  --radius-lg: 18px;
  --radius-md: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, "Segoe UI", sans-serif;
  background: var(--page-bg);
  color: var(--ink-900);
  -webkit-font-smoothing: antialiased;
}

h1, h2 { font-family: "Manrope", "Inter", sans-serif; margin: 0; }

/* ===== Sign-in gate ===== */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand-50), #ffffff);
}
.auth-gate.hidden { display: none; }

.auth-card {
  width: 340px;
  max-width: 90vw;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 36px 30px;
  text-align: center;
}

.auth-logo { height: 40px; width: auto; margin: 0 auto 22px; display: block; }
.auth-card h1 { font-size: 19px; font-weight: 800; margin-bottom: 8px; }
.auth-card p { font-size: 13.5px; color: var(--slate-600); line-height: 1.5; margin: 0 0 24px; }

.auth-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-900);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.auth-btn:hover { border-color: var(--brand-500); box-shadow: var(--shadow-sm); }
.auth-btn:disabled { opacity: 0.5; cursor: default; }

/* ===== App shell ===== */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== Sidebar ===== */
.sidebar {
  position: relative;
  width: 272px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 26px 18px 20px;
  overflow: hidden;
}

.brand {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  margin: 0 0 30px;
  cursor: pointer;
  background: none;
  border: none;
}

.brand-logo {
  height: 40px;
  width: auto;
  max-width: 100%;
  display: block;
  object-fit: contain;
}

.nav { display: flex; flex-direction: column; gap: 3px; position: relative; z-index: 1; }

.nav-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--slate-400);
  padding: 14px 12px 4px;
}

.nav-item, .logout, .quick-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border: none;
  background: none;
  color: var(--ink-700);
  text-align: left;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item .icon { width: 19px; height: 19px; flex-shrink: 0; color: var(--slate-600); transition: color 0.15s ease; }

.nav-item:hover:not(:disabled) { background: var(--brand-50); color: var(--brand-700); }
.nav-item:hover:not(:disabled) .icon { color: var(--brand-600); }

.nav-item.active { background: var(--brand-100); color: var(--brand-700); font-weight: 600; }
.nav-item.active .icon { color: var(--brand-600); }

.nav-item.is-soon, .quick-link.is-soon { cursor: default; opacity: 0.55; }

.nav-item em, .quick-link em {
  margin-left: auto;
  font-style: normal;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--slate-400);
  background: var(--line);
  padding: 2px 7px;
  border-radius: 999px;
}

.logout {
  margin-top: auto;
  color: var(--slate-600);
  position: relative;
  z-index: 1;
}
.logout .icon { width: 19px; height: 19px; }
.logout:hover { background: var(--brand-50); color: var(--brand-700); }

.watermark {
  position: absolute;
  left: -50px;
  bottom: -50px;
  width: 200px;
  height: auto;
  opacity: 0.12;
  z-index: 0;
  pointer-events: none;
}

/* ===== Main ===== */
.main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding: 18px 40px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.who { display: flex; flex-direction: column; line-height: 1.3; text-align: right; }
.who-name { font-size: 13.5px; font-weight: 700; color: var(--ink-900); }
.who-sub { font-size: 12px; color: var(--slate-400); }

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--brand-100);
  color: var(--brand-700);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Manrope", sans-serif;
  font-weight: 700;
  font-size: 14px;
}

.view-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 32px 40px 48px;
  display: flex;
  flex-direction: column;
}

.view { display: none; }
.view.active { display: flex; flex-direction: column; }

/* ===== Hero ===== */
.hero {
  position: relative;
  width: 100%;
  background: linear-gradient(135deg, var(--brand-50), #ffffff);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 26px;
  padding: 30px 36px;
}

.hero-text { position: relative; z-index: 1; max-width: 460px; }
.eyebrow { font-size: 11.5px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--brand-600); }
.hero-text h1 { font-size: 32px; font-weight: 800; margin: 8px 0 10px; color: var(--ink-900); }
.hero-text p { margin: 0; font-size: 14.5px; color: var(--slate-600); line-height: 1.55; }

.hero-mark {
  position: absolute;
  right: -30px;
  bottom: -40px;
  width: 220px;
  height: auto;
  opacity: 0.14;
  pointer-events: none;
}

/* ===== Section ===== */
.section { margin-bottom: 34px; }
.section h2 { font-size: 19px; font-weight: 800; color: var(--ink-900); margin-bottom: 16px; }

/* ===== Dashboard cards ===== */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.dash-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
  text-align: left;
  font-family: inherit;
  text-decoration: none;
  color: inherit;
  display: block;
}

.dash-card:visited, .dash-card:hover, .dash-card:active {
  text-decoration: none;
  color: inherit;
}

.dash-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--brand-500);
}

.dash-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--brand-100);
  color: var(--brand-600);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}
.dash-icon svg { width: 21px; height: 21px; }

.dash-card h3 { margin: 0 0 6px; font-family: "Manrope", sans-serif; font-size: 16.5px; font-weight: 700; color: var(--ink-900); }
.dash-card p { margin: 0 0 18px; font-size: 13.5px; color: var(--slate-600); line-height: 1.5; }

.dash-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--brand-600);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 9px;
  border: none;
}
.dash-cta svg { width: 15px; height: 15px; }
.dash-card:hover .dash-cta { background: var(--brand-700); }

/* ===== Quick links ===== */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.quick-link {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.quick-link:not(.is-soon):hover { border-color: var(--brand-500); background: var(--brand-50); }

.quick-link .icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: var(--brand-100);
  color: var(--brand-600);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  padding: 8px;
}

.quick-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.quick-text strong { font-size: 14px; color: var(--ink-900); font-weight: 700; }
.quick-text small { font-size: 12px; color: var(--slate-400); }

.chev { width: 16px; height: 16px; color: var(--slate-400); flex-shrink: 0; }

.page-footer {
  text-align: center;
  font-size: 12.5px;
  color: var(--slate-400);
  border-top: 1px solid var(--line);
  padding-top: 22px;
  margin-top: 8px;
}

/* ===== Report view ===== */
/* The report view specifically fills the full remaining height of
   view-body (rather than growing with content like Overview does),
   so the iframe-container below can flex to fill whatever real space
   is left — no guessed pixel number, self-correcting on any screen.
   Uses flex-grow rather than height:100% since flex-grow sizing is
   more consistently supported than nested percentage-height chains. */
#view-report.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.back-link {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--slate-600);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  margin-bottom: 18px;
}
.back-link svg { width: 16px; height: 16px; }
.back-link:hover { color: var(--brand-600); }

.report-header {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}
.report-header h1 { font-size: 24px; font-weight: 800; color: var(--ink-900); margin-bottom: 4px; }
.report-header p { margin: 0; font-size: 13.5px; color: var(--slate-600); }

.refresh-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--slate-600);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.refresh-btn svg { width: 16px; height: 16px; }
.refresh-btn:hover { color: var(--brand-600); border-color: var(--brand-500); }
.refresh-btn.spinning svg { animation: spin 0.6s linear; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* This container is the direct target the Power BI SDK embeds an
   iframe into — the SDK creates its own internal iframe, so we
   apply loading state to this wrapper rather than to an <iframe>.
   aspect-ratio starts as a placeholder (16/9) and gets overridden
   in app.js with the real report's own canvas ratio once it loads,
   so the container's shape always matches the report exactly —
   no scrollbar, no letterboxing, and no fixed height guess. */
.iframe-container {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.iframe-container iframe { width: 100%; height: 100%; border: none; }

.iframe-container::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #f1f2f5 25%, #f8f9fb 50%, #f1f2f5 75%);
  background-size: 400px 100%;
  animation: shimmer 1.4s infinite linear;
  z-index: 2;
}
.iframe-container.loaded::after { display: none; }
@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }

/* ===== Responsive ===== */

@media (max-width: 860px) {
  .app { flex-direction: column; height: auto; min-height: 100vh; overflow: visible; }
  .sidebar { width: auto; padding: 16px; }
  .watermark { display: none; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-label { width: 100%; }
  .logout { display: none; }
  .hero { padding: 22px 20px; }
  .hero-text { max-width: 100%; }
  .hero-mark { width: 140px; }
  .view-body { padding: 20px; }
  #view-report.active { display: block; height: auto; }
  .iframe-container { flex: none; height: 70vh; }
}

/* ===== Accessibility ===== */
button:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .iframe-container::after, .refresh-btn.spinning svg, .dash-card { animation: none !important; transition: none !important; }
}
