:root {
  --red: #C8102E;
  --navy: #13203B;
  --ink: #1b2233;
  --muted: #5b6478;
  --line: #e4e7ee;
  --bg: #f7f8fb;
  --card: #ffffff;
  --portal-tint: #fdf1f3;
  --admin-tint: #eef1f7;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }
body { margin: 0; color: var(--ink); background: var(--bg); line-height: 1.65; font-size: 16px; }
a { color: var(--red); }
a:hover { color: #9c0c23; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header { position: sticky; top: 0; z-index: 10; background: rgba(255,255,255,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.header-row { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand img { height: 40px; width: auto; display: block; }
.header-title { font-size: 14px; font-weight: 600; color: var(--muted); }

/* Hero */
.hero { padding: 48px 0 24px; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 700; color: var(--red); }
h1 { margin: 6px 0 12px; font-size: clamp(32px, 5vw, 44px); line-height: 1.15; color: var(--navy); }
.lede { max-width: 720px; font-size: 18px; color: #343c50; margin: 0 0 12px; }
.meta { color: var(--muted); font-size: 14px; margin: 0 0 24px; }

.app-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filter-label { font-size: 14px; color: var(--muted); margin-right: 4px; }
.chip { display: inline-block; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 600; }
.chip:hover { border-color: #c5cad6; color: var(--ink); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip-portal.is-active { background: var(--red); border-color: var(--red); }
.chip-admin.is-active { background: var(--navy); border-color: var(--navy); }

/* App cards */
.apps { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 8px 0 32px; }
.app-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; border-top: 4px solid var(--red); }
.app-card.admin { border-top-color: var(--navy); }
.app-card p { margin: 8px 0 0; }
.app-tag { font-weight: 800; font-size: 18px; color: var(--red); }
.app-card.admin .app-tag { color: var(--navy); }
.app-id { font-family: "JetBrains Mono", ui-monospace, Menlo, monospace; font-size: 12.5px; color: var(--muted); }

/* Tables */
.glance { margin-bottom: 40px; }
.glance h2 { margin-top: 0; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
thead th { background: #fafbfd; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
thead th.col-portal { color: var(--red); }
thead th.col-admin { color: var(--navy); }
tbody th { font-weight: 600; width: 32%; }
.perm-table td:first-child { font-weight: 600; white-space: nowrap; }

/* Layout */
.layout { display: grid; grid-template-columns: 240px 1fr; gap: 40px; align-items: start; padding-bottom: 64px; }
.toc { position: sticky; top: 88px; font-size: 14px; }
.toc-title { font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc a { display: block; padding: 5px 10px; border-left: 2px solid var(--line); color: var(--muted); text-decoration: none; }
.toc a::before { content: counter(toc) ". "; }
.toc a:hover { color: var(--ink); border-left-color: var(--red); }

.policy { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 36px 32px; min-width: 0; }
.policy section { padding-top: 24px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.policy section:last-child { border-bottom: 0; }
h2 { color: var(--navy); font-size: 24px; margin: 0 0 12px; }
h3 { font-size: 17px; margin: 20px 0 6px; color: var(--ink); }
.policy ul { padding-left: 20px; }
.policy li { margin-bottom: 6px; }

/* App-specific blocks */
.badge { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .03em; padding: 2px 8px; border-radius: 999px; vertical-align: 1px; margin-right: 4px; color: #fff; background: var(--red); white-space: nowrap; }
.badge.admin { background: var(--navy); }
.callout { border-radius: 12px; padding: 4px 20px 8px; margin: 16px 0; border-left: 4px solid var(--red); background: var(--portal-tint); }
.callout.admin { border-left-color: var(--navy); background: var(--admin-tint); }
.callout h3 { margin-top: 14px; }

/* Filter states (set on <body> by filter.js) */
body.show-portal .only-admin,
body.show-admin .only-portal { display: none !important; }
body.show-portal .col-admin,
body.show-admin .col-portal { display: none; }
body.show-portal .app-card.admin,
body.show-admin .app-card.portal { display: none; }
body.show-portal .apps,
body.show-admin .apps { grid-template-columns: 1fr; }
body.show-portal .perm-table .badge.admin,
body.show-admin .perm-table .badge.portal { display: none; }

.contact-card { font-style: normal; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; display: inline-block; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--card); color: var(--muted); font-size: 14px; padding: 20px 0; }
.site-footer p { margin: 4px 0; }

/* Responsive */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; gap: 20px; }
  .toc { position: static; }
  .toc ol { columns: 2; }
  .policy { padding: 4px 20px 24px; }
  .apps { grid-template-columns: 1fr; }
  .perm-table td:first-child { white-space: normal; }
}

/* Print */
@media print {
  .site-header { position: static; }
  .app-filter, .toc, .site-footer p:last-child { display: none; }
  .layout { display: block; }
  .policy, .table-scroll, .app-card { border: 0; padding: 0; }
  body { background: #fff; }
}
