/* Application Workspace — light theme, security-console card chrome */
:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --ink: #1a2b4a;
  --muted: #547892;
  --slate: #3d5470;
  --line: #e3ebf0;
  --line-strong: #c5d0db;
  --primary: #586fcc;
  --primary-dark: #4558b0;
  --primary-soft: #eceffe;
  --ok: #059669;
  --err: #dc2626;
  --warn: #d97706;
  --sans: "Lato", system-ui, sans-serif;
  --display: "Poppins", "Lato", sans-serif;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(26, 43, 74, 0.04), 0 10px 28px -18px rgba(26, 43, 74, 0.22);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  color: var(--ink);
  min-height: 100vh;
  background: var(--bg);
  line-height: 1.45;
}

.shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 2.5rem;
}

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--line-strong);
}
.brand { display: flex; align-items: center; gap: 0.65rem; }
.brand-logo {
  display: block;
  height: 26px;
  width: auto;
}
.brand-sep { color: #c5d0db; font-weight: 400; }
.brand-admin {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
}
.topbar-right { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

.env-rail {
  display: inline-flex; gap: 0.3rem;
  padding: 0.25rem;
  background: #eef2f7;
  border-radius: 999px;
  border: 1px solid var(--line);
}
.env-chip {
  appearance: none; cursor: pointer;
  border: none; background: transparent;
  font: inherit; font-size: 0.8rem; font-weight: 700;
  color: var(--muted);
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  transition: background 0.18s var(--ease), color 0.18s, box-shadow 0.18s;
}
.env-chip:hover { color: var(--ink); background: rgba(255,255,255,0.7); }
.env-chip[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(26, 43, 74, 0.1);
}
.env-chip.warn[aria-pressed="true"] {
  background: #fff7ed;
  color: #c2410c;
}

.status {
  display: none;
  font-size: 0.72rem; font-weight: 700;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
}
.status.ok, .status.err, .status.busy {
  display: inline-flex;
}
.status.ok { background: #ecfdf5; border-color: #a7f3d0; color: var(--ok); }
.status.err { background: #fef2f2; border-color: #fecaca; color: var(--err); }
.status.busy { background: var(--primary-soft); border-color: #c5cef0; color: var(--primary-dark); }

.page-head { margin-bottom: 1.35rem; }
.page-head h1 {
  font-family: var(--display);
  font-size: clamp(1.55rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.page-blurb {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 36rem;
  line-height: 1.45;
}

.prd-banner {
  display: none; margin-top: 0.75rem; padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  background: #fffbeb; border: 1px solid #fcd34d;
  color: #92400e; font-size: 0.85rem; font-weight: 700;
}
.prd-banner.show { display: block; }

.test-note {
  display: none;
  margin: 0.85rem auto 0;
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  background-image:
    linear-gradient(180deg, #fff5f5 0%, #ffecec 100%),
    linear-gradient(90deg, #991b1b 0%, #ef4444 55%, #fca5a5 100%);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  color: #e11d48;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
  white-space: nowrap;
  max-width: fit-content;
  width: max-content;
}
.test-note.show { display: block; }

@media (max-width: 900px) {
  .test-note {
    white-space: normal;
    max-width: 100%;
    width: 100%;
  }
}

/* Uniform larger app tiles */
.workspace {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
  align-items: stretch;
}

.app-card {
  appearance: none; cursor: pointer;
  text-align: left; font: inherit; color: inherit;
  width: 100%;
  min-height: 148px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  transition: transform 0.2s var(--ease), box-shadow 0.2s, border-color 0.2s;
  animation: fadeUp 0.35s var(--ease) both;
}
/* Accents + stagger without inline styles (CSP style-src 'self') */
.app-accent-fleetenable { --accent: #586fcc; }
.app-accent-stackenable { --accent: #0e7490; }
.app-accent-care { --accent: #dc2626; }
.app-accent-able { --accent: #ea580c; }
.app-accent-qarto { --accent: #586fcc; }
.app-accent-insights { --accent: #059669; }
.app-accent-fleetenable-mobile { --accent: #7c3aed; }
.app-accent-stackenable-mobile { --accent: #0e7490; }
.app-delay-0 { animation-delay: 0ms; }
.app-delay-1 { animation-delay: 40ms; }
.app-delay-2 { animation-delay: 80ms; }
.app-delay-3 { animation-delay: 120ms; }
.app-delay-4 { animation-delay: 160ms; }
.app-delay-5 { animation-delay: 200ms; }
.app-delay-6 { animation-delay: 240ms; }
.app-delay-7 { animation-delay: 280ms; }
.boot-error {
  padding: 2rem;
  font-family: var(--body, Lato, sans-serif);
  color: #0f172a;
}
.app-card:hover {
  transform: translateY(-2px);
  border-color: #c5cef0;
  box-shadow: 0 12px 32px -16px rgba(88, 111, 204, 0.35);
}
.app-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.app-card-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.65rem;
}
.app-card-title-row {
  display: flex; align-items: center; gap: 0.75rem; min-width: 0;
}
.app-ico {
  width: 48px; height: 48px; border-radius: 13px; flex-shrink: 0;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent, var(--primary)) 12%, white);
  border: 1px solid color-mix(in srgb, var(--accent, var(--primary)) 22%, white);
  color: var(--accent, var(--primary));
}
.app-ico svg { width: 26px; height: 26px; }
.app-ico .app-logo {
  width: auto;
  max-width: 100%;
  max-height: 28px;
  object-fit: contain;
  display: block;
}
.app-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
  line-height: 1.25;
}

.launch-btn {
  appearance: none; pointer-events: none;
  display: inline-flex; align-items: center; gap: 0.35rem;
  align-self: flex-start;
  font-size: 0.85rem; font-weight: 700;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: none;
  background: var(--accent, var(--primary));
  color: #fff;
  white-space: nowrap;
}

.site-foot {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 2px solid var(--line-strong);
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Console strip */
.console-card {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: 1.25rem 1.35rem;
  min-height: 88px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.console-left { display: flex; align-items: center; gap: 0.95rem; min-width: 0; }
.console-ico {
  width: 48px; height: 48px; color: var(--warn);
  background: #fffbeb; border: 1px solid #fde68a;
  border-radius: 13px; padding: 10px;
}
.console-ico svg { width: 100%; height: 100%; }
.console-card strong {
  font-family: var(--display); font-weight: 600; font-size: 1.05rem; display: block;
}
.console-card p:empty { display: none; }
.console-card p { font-size: 0.9rem; color: var(--muted); margin-top: 0.2rem; }

/* Tenant context (signed-in screen) */
.tenant-context {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.tenant-context__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.65rem 1rem;
}
.tenant-context__k {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.15rem;
}
.tenant-context__v {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  word-break: break-all;
}
.tenant-context__v.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 500; }
.tenant-context__section { margin: 0.85rem 0 0.35rem; }
.tenant-context__orgs {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.82rem;
}
.tenant-context__orgs li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  padding: 0.35rem 0;
  border-top: 1px solid var(--line);
}
.tenant-context__label { font-weight: 700; color: var(--ink); }
.tenant-context__value { color: var(--muted); }

/* Product nav (cross-app SSO — matches workspace / console strip) */
.product-nav-shell { margin: 0 0 1rem; }
.product-nav__section { margin-bottom: 0.45rem; }
.product-nav {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.product-nav__row {
  display: flex;
  align-items: center;
  gap: 0.95rem;
  width: 100%;
  min-height: 72px;
  padding: 0.85rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: left;
}
.product-nav__row--current {
  border-color: color-mix(in srgb, var(--accent, var(--primary)) 35%, var(--line));
  background: color-mix(in srgb, var(--accent, var(--primary)) 4%, white);
}
.product-nav__row--link {
  appearance: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: transform 0.2s var(--ease), border-color 0.2s, box-shadow 0.2s;
}
.product-nav__row--link:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: #c5cef0;
  box-shadow: 0 12px 32px -16px rgba(88, 111, 204, 0.35);
}
.product-nav__row--link:disabled { opacity: 0.45; cursor: not-allowed; }
.product-nav__logo.app-ico { width: 52px; height: 52px; }
.product-nav__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.product-nav__body strong {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.02rem;
  color: var(--ink);
}
.product-nav__body span:last-child {
  font-size: 0.82rem;
  color: var(--muted);
}
.product-nav__badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent, var(--primary));
  background: color-mix(in srgb, var(--accent, var(--primary)) 12%, white);
  border: 1px solid color-mix(in srgb, var(--accent, var(--primary)) 22%, white);
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  flex-shrink: 0;
}
.product-nav__chev {
  font-size: 1.35rem;
  line-height: 1;
  color: var(--muted);
  flex-shrink: 0;
}
.actions-session {
  margin-top: 0.5rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

/* Buttons */
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.25rem; }
.actions-center { justify-content: center; margin-top: 1rem; }
.section-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.65rem;
}
.section-label + .console-card { margin-top: 0; }
.workspace + .section-label { margin-top: 1.35rem; }
.app-card-meta {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.3;
}
.working-hint {
  margin: 0.65rem auto 0;
  max-width: 22rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}
.btn {
  appearance: none; cursor: pointer;
  font: inherit; font-weight: 700; font-size: 0.85rem;
  padding: 0.55rem 1.05rem;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
}
.btn-primary {
  background: var(--primary); color: #fff;
  box-shadow: 0 6px 16px -8px rgba(88, 111, 204, 0.55);
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-secondary {
  background: var(--primary-soft); color: var(--primary-dark);
  border-color: #d5dcf5;
}
.btn-secondary:hover { background: #e0e5fb; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #eef2f7; color: var(--ink); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn.hidden { display: none !important; }

.panel-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.3rem;
}
.panel-card.center { text-align: center; padding: 2.5rem 1.25rem; }
.panel-card h2 {
  font-family: var(--display); font-size: 1.15rem; font-weight: 600; margin-bottom: 1rem;
}
.confirm-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; margin-bottom: 0.9rem;
}
.confirm-cell {
  padding: 0.7rem 0.8rem;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.confirm-cell.wide { grid-column: 1 / -1; }
.confirm-cell span {
  display: block; font-size: 0.62rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 0.2rem;
}
.confirm-cell strong { font-size: 0.86rem; word-break: break-all; }

.phish-note {
  font-size: 0.82rem; color: var(--muted);
  padding: 0.65rem 0.8rem; margin-bottom: 0.9rem;
  background: var(--primary-soft); border-radius: var(--radius-sm);
  border: 1px solid #d5dcf5;
}

.spinner {
  width: 40px; height: 40px; margin: 0 auto 0.85rem;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--primary);
  animation: spin 0.75s linear infinite;
}

.identity {
  display: flex; gap: 0.85rem; align-items: center;
  padding: 0.9rem; margin-bottom: 0.9rem;
  background: #f8fafc; border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #0891b2);
  color: #fff; display: grid; place-items: center;
  font-family: var(--display); font-weight: 700;
}
.identity h3 { font-family: var(--display); font-size: 1rem; }
.identity .email, .identity .meta { font-size: 0.82rem; color: var(--muted); }
.roles { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.65rem; }
.chip {
  font-size: 0.7rem; font-weight: 700; padding: 0.2rem 0.5rem;
  border-radius: 999px; background: var(--primary-soft); color: var(--primary-dark);
}
.chip.dim { opacity: 0.55; }
.azp-ok { color: var(--ok); font-size: 0.75rem; font-weight: 700; }
.azp-bad { color: var(--err); font-size: 0.75rem; font-weight: 700; }

.error {
  padding: 0.9rem; margin-bottom: 0.9rem;
  background: #fef2f2; border: 1px solid #fecaca;
  border-radius: var(--radius-sm); color: #991b1b;
}
.error strong { display: block; margin-bottom: 0.25rem; font-family: var(--display); }

details.session-details {
  margin-top: 0.9rem; padding: 0.7rem 0.85rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: #f8fafc;
}
details.session-details summary { cursor: pointer; font-weight: 700; color: var(--muted); font-size: 0.85rem; }
.jwt-box {
  margin-top: 0.55rem; font-family: ui-monospace, monospace; font-size: 0.65rem;
  background: #0f172a; color: #94a3b8; padding: 0.75rem;
  border-radius: 8px; max-height: 220px; overflow: auto;
  white-space: pre-wrap; word-break: break-all;
}

.legacy-hint { margin-top: 0.75rem; font-size: 0.82rem; color: var(--muted); }
.screen { transition: opacity 0.22s var(--ease); }
.screen.is-leaving { opacity: 0; pointer-events: none; }
.screen.is-entering { animation: fadeUp 0.3s var(--ease) both; }
.hidden { display: none !important; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .workspace { grid-template-columns: 1fr; }
  .confirm-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes spin { to { transform: rotate(360deg); } }
