/*
 * App-shell tokens that are NOT brand values.
 *
 * app.css previously drew all 24 of its tokens from <brand>-design-system.css, which
 * made the legacy stylesheet a hard dependency of the app shell. Brand-derived values
 * now reference the chassis theme directly (hsl(var(--primary)) and friends, wrapped
 * because the chassis stores HSL triplets rather than hex). What is left below is a
 * spacing scale, an easing, three radii, two tints and two shadows — layout constants
 * that were never brand decisions and that the chassis deliberately does not own.
 *
 * Three are kept as literals rather than remapped, because the nearest chassis value
 * differs visibly and this port is a dependency change, not a redesign:
 *   --radius-lg   12px, where chassis --radius is 10px
 *   --shadow-nav  heavier and wider than the chassis nav shadow
 *   --shadow-blue no chassis equivalent at all
 */
:root {
  --space-sm:    8px;
  --space-md:    16px;
  --space-xl:    32px;
  --space-2xl:   48px;
  --radius-sm:   6px;
  --radius-lg:   12px;
  --radius-pill: 999px;
  --ease:        0.18s ease;
  --green-bg:    hsl(var(--success) / 0.14);
  --red-bg:      hsl(var(--danger) / 0.12);
  --shadow-nav:  0 2px 12px hsl(var(--foreground) / 0.25);
  --shadow-blue: 0 8px 24px hsl(var(--primary) / 0.14);
}

body {
  margin: 0;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: var(--font-sans);
}

/* ── App header (PFC-pattern sticky blue bar) ────────────────────────────── */

.app-header {
  position: sticky;
  top: 0;
  z-index: 200;
  height: 56px;
  background: hsl(var(--primary));
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-nav);
}

.app-header-brand {
  font-family: var(--font-serif);
  font-weight: 800;
  font-size: 18px;
  color: hsl(var(--card));
  letter-spacing: -0.01em;
}

.app-header-brand span {
  font-weight: 400;
  font-size: 14px;
  opacity: 0.65;
  margin-left: 4px;
  font-family: var(--font-sans);
}

.app-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-header-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-header-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  display: block;
}

.app-header-name {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}

/* ── Ghost button (light background) ────────────────────────────────────── */

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  border: 1.5px solid hsl(var(--border));
  background: transparent;
  font-weight: 600;
  font-size: 13px;
  color: hsl(var(--foreground));
  cursor: pointer;
  transition: all var(--ease);
  font-family: var(--font-sans);
}

.btn-ghost:hover {
  border-color: hsl(var(--primary));
  color: hsl(var(--primary));
}

/* Ghost on dark/blue background */
.btn-ghost-white {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  transition: all var(--ease);
  font-family: var(--font-sans);
}

.btn-ghost-white:hover {
  background: rgba(255, 255, 255, 0.15);
  color: hsl(var(--card));
  border-color: rgba(255, 255, 255, 0.6);
}

/* ── KPI trend / status indicator ───────────────────────────────────────── */

.kpi-trend {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

.kpi-trend-neutral {
  /* --text-muted (#5a6a7a) on its own 10% tint measured 4.36:1 — just under the
     floor at 13px. --text is the body ink and clears it comfortably. */
  color: hsl(var(--foreground));
  background: rgba(90, 106, 122, 0.10);
}

.kpi-trend-positive {
  color: hsl(var(--success));
  background: var(--green-bg);
}

.kpi-trend-negative {
  /* --orange (#b35c3d) on the red tint measured 3.58:1. --orange-ink is the same
     hue darkened for type; the fill keeps --red-bg. */
  color: var(--orange-ink, hsl(var(--accent)));
  background: var(--red-bg);
}

/* ── Page shell (full-height flex column) ───────────────────────────────── */

.page-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-content {
  flex: 1;
  padding: var(--space-2xl) var(--space-xl);
}

.page-inner {
  max-width: 720px;
  margin: 0 auto;
}

/* ── User greeting ──────────────────────────────────────────────────────── */

.user-greeting {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-2xl);
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid hsl(var(--border));
}

.user-greeting-name {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 2px;
}

.user-greeting-email {
  font-size: 14px;
  color: hsl(var(--muted-foreground));
}

/* ── Nav sections ───────────────────────────────────────────────────────── */

.nav-section {
  margin-bottom: var(--space-2xl);
}

.nav-section-header {
  font-size: 11px;
  font-weight: 700;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-sm);
}

.nav-item-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--surface));
  font-size: 14px;
  font-weight: 500;
  color: hsl(var(--foreground));
  cursor: pointer;
  text-align: left;
  transition: all var(--ease);
  font-family: var(--font-sans);
  box-shadow: var(--shadow-card-sm);
}

.nav-item-btn:hover {
  border-color: hsl(var(--primary));
  color: hsl(var(--primary));
  box-shadow: var(--shadow-blue);
}

.nav-item-icon {
  font-size: 12px;
  color: hsl(var(--muted-foreground));
  flex-shrink: 0;
  transition: color var(--ease);
}

.nav-item-btn:hover .nav-item-icon {
  color: hsl(var(--primary));
}

/* ── Embed page ─────────────────────────────────────────────────────────── */

.embed-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.embed-header {
  height: 48px;
  padding: 0 24px;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--surface));
  display: flex;
  align-items: center;
  gap: 12px;
}

.embed-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  transition: color var(--ease);
}

.embed-back:hover {
  color: hsl(var(--primary));
}

.embed-content {
  flex: 1;
}

.embed-error {
  padding: var(--space-xl);
  color: hsl(var(--accent));
  font-family: monospace;
  font-size: 13px;
}

/* ── Health grid ────────────────────────────────────────────────────────── */

.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  max-width: 680px;
}

/* ── Login ──────────────────────────────────────────────────────────────── */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: hsl(var(--primary));
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(0, 80, 180, 0.6) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(0, 50, 140, 0.8) 0%, transparent 50%);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: hsl(var(--card));
  border-radius: var(--radius-lg);
  padding: 48px 44px 44px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
}

.login-logo {
  width: 160px;
  height: auto;
  margin: 0 auto 32px;
  display: block;
}

.login-divider {
  width: 32px;
  height: 3px;
  background: hsl(var(--primary));
  border-radius: 2px;
  margin: 0 auto 20px;
}

.login-sub {
  color: hsl(var(--muted-foreground));
  font-size: 14px;
  margin-bottom: 32px;
  line-height: 1.5;
}

.login-platform {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  margin-bottom: 28px;
}

.google-btn-wrap {
  display: flex;
  justify-content: center;
}

.login-footer {
  margin-top: 24px;
  font-size: 11px;
  color: hsl(var(--muted-foreground));
}

/* Vendor attribution, subordinate to the customer lockup above it. Same "Powered by"
   register the app footer uses, so the front door and the shell agree.
   `--primary` is the chassis brand token (globals.css puts the active brand's tokens on
   :root app-wide), with the legacy --blue as the fallback for any surface still served
   by a design-system stylesheet alone. */
.login-vendor {
  display: block;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border, rgba(41, 57, 69, 0.1));
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  transition: color 120ms ease;
}

.login-vendor:hover,
.login-vendor:focus-visible {
  color: hsl(var(--primary, 210 49% 46%));
}

.login-vendor-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-vendor-name {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ── Form select (agent selector) ──────────────────────────────────────── */

.if {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid hsl(var(--border));
  border-radius: var(--radius-sm, 6px);
  background: hsl(var(--surface));
  color: hsl(var(--foreground));
  font-family: var(--font-sans);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s;
}

.if:focus {
  outline: none;
  border-color: hsl(var(--primary));
}

/* ── Agent platform ─────────────────────────────────────────────────────── */

.agent-wrap { max-width: 1320px; margin: 0 auto; padding: 24px; }

/* Tab bar (sticky below the app header) */
.tabs-bar {
  display: flex;
  background: hsl(var(--surface));
  border-bottom: 1px solid hsl(var(--border));
  padding: 0 8px;
  overflow-x: auto;
  position: sticky;
  top: 56px; /* height of .app-header */
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,.05);
}

.tabs-bar a {
  padding: 12px 20px;
  font-size: 12.5px;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  border-bottom: 2.5px solid transparent;
  white-space: nowrap;
  transition: color .15s;
}

.tabs-bar a:hover { color: hsl(var(--primary)); }
.tabs-bar a.active { color: hsl(var(--primary)); border-bottom-color: hsl(var(--primary)); }

/* Period filter pills */
.period-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.period-pill {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  background: hsl(var(--surface));
  transition: all .15s;
}
.period-pill:hover { border-color: hsl(var(--primary)); color: hsl(var(--primary)); }
.period-pill.active { background: hsl(var(--primary)); color: #fff; border-color: hsl(var(--primary)); }

/* Score bands */
.band-top    { background: #c8edd9; color: #1a5e3a; }
.band-above  { background: #d0e4f8; color: #003a8e; }
.band-meets  { background: #fff3cd; color: #7a5a00; }
.band-below  { background: #ffd5d3; color: #8b1a14; }

.score-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}

/* Scorecard table */
.scorecard-table { width: 100%; font-size: 12px; border-collapse: collapse; }
.scorecard-table th {
  padding: 9px 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: hsl(var(--muted-foreground));
  border-bottom: 1.5px solid hsl(var(--border));
  background: #f7f8fa;
  text-align: right;
  white-space: nowrap;
}
.scorecard-table th.left { text-align: left; }
.scorecard-table td {
  padding: 7px 10px;
  border-bottom: .5px solid hsl(var(--border));
  text-align: right;
  font-weight: 600;
  white-space: nowrap;
}
.scorecard-table td.left { text-align: left; font-weight: 500; }
.scorecard-table tr:hover td { background: rgba(0,58,142,0.03); }
.scorecard-table tr.total-row td {
  font-weight: 700;
  background: #f0f4fb;
  border-top: 1.5px solid rgba(0,58,142,.15);
  color: hsl(var(--primary));
}
.scorecard-scroll { overflow-x: auto; overflow-y: auto; max-height: 560px; }
.scorecard-scroll .scorecard-table thead th {
  /* Sticky header — opaque background (was bleeding through on scroll because
     the inherited #f7f8fa got composited under hover row tints). Solid var
     reference + a 1px shadow below the header to visually separate from rows. */
  position: sticky;
  top: 0;
  z-index: 6;
  background-color: var(--surface, #ffffff);
  background-image: linear-gradient(#f7f8fa, #f7f8fa);
  box-shadow: 0 1px 0 hsl(var(--border));
}
.scorecard-scroll .scorecard-table thead {
  background-color: var(--surface, #ffffff);
}
