:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e2e4e9;
  --text: #1f2430;
  --muted: #6b7280;
  --primary: #f2c811;      /* Power BI yellow */
  --primary-ink: #1f2430;
  --error-bg: #fdecea;
  --error-ink: #a1281f;
  --info-bg: #e8f1fd;
  --info-ink: #1d4e89;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; letter-spacing: 0.2px; }
.topbar-nav { display: flex; align-items: center; gap: 1rem; }
.user { color: var(--muted); font-size: 0.9rem; }
.logout-form { margin: 0; }

/* Layout */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
}

/* Buttons */
.btn {
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  cursor: pointer;
}
.btn-primary { background: var(--primary); color: var(--primary-ink); font-weight: 600; width: 100%; }
.btn-primary:hover { filter: brightness(0.96); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg); }

/* Flash messages */
.flashes { margin-bottom: 1rem; }
.flash { padding: 0.7rem 1rem; border-radius: 6px; margin-bottom: 0.5rem; font-size: 0.9rem; }
.flash-error { background: var(--error-bg); color: var(--error-ink); }
.flash-info { background: var(--info-bg); color: var(--info-ink); }

/* Login */
.login-page .content { align-items: center; justify-content: center; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2rem;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}
.login-card h1 { margin: 0 0 0.25rem; font-size: 1.4rem; }
.login-card .subtitle { margin: 0 0 1.25rem; color: var(--muted); font-size: 0.9rem; }
.login-card label { display: block; margin: 0.75rem 0 0.3rem; font-size: 0.85rem; font-weight: 600; }
.login-card input {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
}
.login-card input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.login-card button { margin-top: 1.25rem; }

/* Dashboard / report */
.dashboard-page .content { padding: 0; overflow: hidden; }
.report-head {
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;             /* fixed-height bar, never grows/shrinks */
}
.report-head .breadcrumb { margin: 0 0 0.25rem; }
.report-head .page-title { margin: 0; font-size: 1.15rem; }
/* The report fills exactly the remaining space and never overflows, so the
   report's own page-navigation tab row stays inside the viewport (otherwise
   the tabs render below the fold and clicks land outside the frame). */
.report-frame {
  flex: 1 1 auto;
  min-height: 0;             /* allow the flex item to actually shrink */
  width: 100%;
  border: none;
  overflow: hidden;
}
.report-frame iframe { width: 100%; height: 100%; border: none; display: block; }

.report-error {
  margin: 2rem auto;
  max-width: 480px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2rem;
}
.report-error h2 { margin-top: 0; }
.report-error p { color: var(--muted); }

/* Multi-report picker (tab bar) */
.report-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.5rem 1rem 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.report-tab {
  padding: 0.5rem 1rem;
  border-radius: 8px 8px 0 0;
  text-decoration: none;
  color: var(--muted);
  font-weight: 500;
  border: 1px solid transparent;
  border-bottom: none;
}
.report-tab:hover { background: var(--bg, #f3f4f6); color: inherit; }
.report-tab.active {
  color: inherit;
  background: var(--bg, #fff);
  border-color: var(--border);
}
/* When a picker is present, leave room for it (header 57px + picker ~49px). */
.report-picker + .report-frame,
.report-picker ~ .report-frame { min-height: calc(100vh - 106px); }
.report-picker ~ .report-frame iframe { min-height: calc(100vh - 106px); }

/* Reports listing page */
.reports-page .content { padding: 1.5rem; }
.page-title { margin: 0 0 0.25rem; font-size: 1.4rem; }
.page-sub { margin: 0 0 1.25rem; color: var(--muted); font-size: 0.9rem; }
.page-sub code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: auto;
}
.reports-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.reports-table th, .reports-table td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.reports-table thead th {
  color: var(--muted);
  font-weight: 600;
  background: var(--bg);
}
.reports-table tbody tr:last-child td { border-bottom: none; }
.report-row { cursor: pointer; }
.report-row:hover { background: var(--bg); }
.report-name { font-weight: 600; }
.mono { color: var(--muted); font-size: 0.82rem; }
.btn-sm { width: auto; padding: 0.35rem 0.8rem; font-size: 0.82rem; display: inline-block; }
.breadcrumb { margin: 0 0 0.5rem; font-size: 0.85rem; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); text-decoration: underline; }
