/* ============================================================================
   Insight Solutions — "Navy" portal stylesheet
   ----------------------------------------------------------------------------
   The complementary counterpart to the public marketing site's light theme:
   the site is white/light, the portal is deliberately navy-forward (Ren,
   2026-08-01). Derived from 00_Shared/Brand/portal-theme.css — keep the two
   in sync when tokens change.

   Tenant branding contract: base.html injects a per-tenant
   :root { --navy: accent; --red: primary; } override AFTER this file loads.
   Every component below must key off the custom properties — no hardcoded
   navy/red hexes outside :root — so CCI (or any tenant) survives untouched.
   ============================================================================ */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/Inter-Variable.woff2') format('woff2');
}

:root {
  --navy:        #0B3956;
  --navy-dark:   #072538;
  --navy-light:  #1A5C86;
  --red:         #DE1515;
  --red-dark:    #B31010;
  --blue:        #146B9E;
  --blue-tint:   #5CAEDB;

  --white:       #FFFFFF;
  --off-white:   #F5F7FA;
  --light-grey:  #E8ECF1;
  --mid-grey:    #8A95A3;
  --text:        #1C2535;
  --text-light:  #4A5568;
  --border:      #D1D9E0;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;

  --max-width:   1100px;
  --radius:      6px;
  --radius-lg:   12px;
  --shadow:      0 2px 12px rgba(11,57,86,.10);
  --shadow-hover: 0 6px 24px rgba(11,57,86,.16);
  --transition:  .2s ease;
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--off-white);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; min-height: 100vh;
}
img { max-width: 100%; }
a { text-decoration: none; color: var(--red); transition: color var(--transition); }

h1, h2, h3, h4 { color: var(--navy); line-height: 1.25; font-weight: 700; letter-spacing: -.015em; margin: 0 0 .5rem; }
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); }
h2 { font-size: clamp(1.45rem, 2.6vw, 1.9rem); }
h3 { font-size: 1.05rem; margin-top: 1.4rem; }

main { flex: 1; width: 100%; max-width: var(--max-width); margin: 0 auto; padding: 2.5rem 24px 4rem; }
body.wide main { max-width: 1400px; }

/* ---- Accent vocabulary (shared signature with the marketing site) ---- */
.eyebrow {
  display: block; font-size: .72rem; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--red); margin-bottom: 6px;
}
.red-bar { width: 48px; height: 4px; background: var(--red); border-radius: 2px; margin-bottom: 20px; }

/* ---- Buttons ---- */
.btn {
  display: inline-block; font-family: inherit; font-size: .9rem; font-weight: 600;
  letter-spacing: .01em; padding: 10px 22px; border-radius: var(--radius);
  border: none; cursor: pointer; text-align: center; text-decoration: none;
  background: var(--red); color: #fff;
  transition: background var(--transition), border-color var(--transition),
              box-shadow var(--transition), transform var(--transition), color var(--transition);
}
.btn:hover { background: var(--red-dark); box-shadow: 0 4px 16px rgba(222,21,21,.28); transform: translateY(-1px); }
.btn-secondary { background: #fff; color: var(--navy); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--off-white); border-color: var(--navy); box-shadow: none; transform: none; }
.btn-danger { background: #fff; color: var(--red); border: 1px solid var(--red); }
.btn-danger:hover { background: #FDECEB; box-shadow: none; transform: none; }
.btn-outline { background: transparent; color: var(--white); border: 2px solid rgba(255,255,255,.5); }
.btn-outline:hover { background: rgba(255,255,255,.12); border-color: var(--white); box-shadow: none; transform: none; }
.btn-sm { padding: 7px 16px; font-size: .84rem; border-width: 1px; }
.btn-lg { padding: 14px 32px; font-size: .95rem; }
.btn-block { width: 100%; }

/* ---- Forms ---- */
label { font-weight: 600; font-size: .84rem; color: var(--navy); letter-spacing: .02em; }
input, select {
  width: 100%; padding: 12px 14px; margin: .3rem 0 .95rem;
  font-family: inherit; font-size: .95rem; color: var(--text);
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  outline: none; transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(11,57,86,.10); }
input::placeholder { color: var(--mid-grey); }

.flash {
  background: #FDECEB; color: var(--red-dark); border: 1px solid #F6CFCD;
  border-radius: var(--radius); padding: .7rem 1rem; margin-bottom: 1.1rem; font-size: .9rem;
}

/* ============================================================================
   NAVY HEADER — navy bar, reversed (white-ringed) icon, white wordmark.
   On tenant-branded pages the bar takes the tenant accent via the --navy
   override and shows the tenant's own logo.
   ============================================================================ */
.site-header {
  background: var(--navy);
  border-bottom: 1px solid rgba(255,255,255,.10);
  box-shadow: 0 1px 8px rgba(4,20,32,.25);
}
.nav-inner {
  max-width: var(--max-width); margin: 0 auto; min-height: 68px; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
body.wide .nav-inner { max-width: 1400px; }
.lockup { display: inline-flex; align-items: center; gap: .6rem; }
.lockup svg { display: block; width: 32px; height: 32px; }
.lockup img { display: block; height: 34px; width: auto; }
.lockup .wordmark { font-weight: 600; color: var(--white); font-size: 1.15rem; white-space: nowrap; }

.nav-right { display: flex; align-items: center; gap: 1.1rem; }
.nav-right form { margin: 0; }
.nav-user { font-size: .86rem; color: rgba(255,255,255,.65); }
.nav-user b { color: var(--white); font-weight: 600; }
nav.admin-nav { display: flex; gap: 1.1rem; }
nav.admin-nav a { color: rgba(255,255,255,.72); font-size: .88rem; font-weight: 500; }
nav.admin-nav a:hover { color: var(--white); }

/* ============================================================================
   TENANT-BRANDED HEADER — light ground (INT-PORT-019). Tenant logo assets are
   supplied for white backgrounds and brand_accent may be arbitrarily dark
   (CCI: #000000), so filling the bar with the accent makes the logo and
   wordmark illegible. On branded pages the bar is white with a tenant-accent
   underline; tenant colors still key everything below via the --navy/--red
   overrides. The Insight-default (unbranded) navy header above is unchanged.
   ============================================================================ */
body.branded .site-header {
  background: var(--white);
  border-bottom: 3px solid var(--navy);
  box-shadow: 0 1px 8px rgba(11,57,86,.08);
}
body.branded .site-header .wordmark { color: var(--navy); }
body.branded .nav-user { color: var(--text-light); }
body.branded .nav-user b { color: var(--text); }
body.branded nav.admin-nav a { color: var(--text-light); }
body.branded nav.admin-nav a:hover { color: var(--navy); }
body.branded .site-header .btn-outline { color: var(--navy); border-color: var(--border); }
body.branded .site-header .btn-outline:hover { background: var(--off-white); border-color: var(--navy); }

/* ---- Navy footer (darker band, structured) ---- */
.site-footer { background: var(--navy-dark); color: rgba(255,255,255,.75); padding: 48px 24px 28px; }
.footer-inner { max-width: var(--max-width); margin: 0 auto; }
.footer-grid {
  display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 40px;
  padding-bottom: 32px; border-bottom: 1px solid rgba(255,255,255,.10); margin-bottom: 22px;
}
.footer-brand .lockup svg { width: 28px; height: 28px; }
.footer-brand .lockup .wordmark { font-size: 1.05rem; }
.footer-brand p { font-size: .85rem; color: rgba(255,255,255,.55); max-width: 270px; margin: 14px 0 0; }
.footer-col h4 {
  font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: rgba(255,255,255,.45); margin: 0 0 14px;
}
.footer-col ul { list-style: none; margin: 0; padding: 0; }
.footer-col li { margin-bottom: 9px; }
.footer-col a, .footer-col p { color: rgba(255,255,255,.75); font-size: .88rem; margin: 0 0 9px; }
.footer-col a:hover { color: #fff; }
.footer-bottom {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: .78rem; color: rgba(255,255,255,.40);
}

/* ============================================================================
   LOGIN — full navy gradient page, white card floating on it. The login page
   never carries a tenant brand (anonymous → Insight default), so the fixed
   navy-dark/navy-light gradient tokens are safe here.
   ============================================================================ */
body.login main { max-width: none; padding: 0; display: flex; flex-direction: column; }
.login-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 64px 24px;
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 62%, var(--navy-light) 100%);
  position: relative; overflow: hidden;
}
.login-wrap::before {
  content: ''; position: absolute; top: -45%; right: -12%; width: 640px; height: 640px;
  background: radial-gradient(circle, rgba(222,21,21,.13) 0%, transparent 70%); pointer-events: none;
}
.login-stack { position: relative; z-index: 1; width: 100%; max-width: 440px; text-align: center; }
.login-stack .lockup { margin-bottom: 14px; justify-content: center; }
.login-stack .lockup svg { width: 44px; height: 44px; }
.login-stack .lockup .wordmark { font-size: 1.6rem; }
.login-kicker {
  color: rgba(255,255,255,.72); font-size: .78rem; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; margin-bottom: 34px;
}
.login-card {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 40px 36px 34px; box-shadow: 0 18px 48px rgba(4,20,32,.28); text-align: left;
}
.login-card h1 { font-size: 1.5rem; margin-bottom: 4px; }
.login-card .sub { font-size: .9rem; color: var(--text-light); margin: 0 0 26px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; font-size: .8rem; }
.form-group input { margin: 0; padding: 13px 16px; }
.login-card .btn { margin-top: 6px; }
.login-notice { margin: 14px 0 0; font-size: .78rem; color: var(--mid-grey); text-align: center; }
.login-help { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--light-grey); font-size: .83rem; color: var(--mid-grey); text-align: center; }
.login-help a { color: var(--navy); font-weight: 600; }
.login-foot { margin-top: 26px; font-size: .78rem; color: rgba(255,255,255,.55); text-align: center; }

/* ============================================================================
   REPORT LANDING — structure unchanged (it was already good); re-dressed in
   the tokens. Runs on the off-white surface below the navy header.
   ============================================================================ */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1.5rem; flex-wrap: wrap; margin: 0 0 1.8rem; }
.page-head h2 { margin-bottom: 0; }
.page-sub { margin: .3rem 0 0; color: var(--text-light); font-size: .92rem; }
.meta { color: var(--mid-grey); font-size: .8rem; margin-top: .25rem; }
.empty { background: #fff; border: 1px dashed var(--border); border-radius: var(--radius-lg); padding: 2.4rem 1.6rem; text-align: center; }
.empty p { margin: 0 0 .35rem; }

.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 1.15rem 1.35rem; margin-bottom: .95rem; }
.card a { color: var(--navy); font-weight: 600; font-size: 1.05rem; }

.tenant-block { margin-bottom: 2.75rem; }
.tenant-block:last-child { margin-bottom: 0; }
.tenant-head {
  --accent: var(--navy);
  display: flex; align-items: center; gap: .95rem;
  background: #fff; border: 1px solid var(--border);
  border-left: 4px solid var(--accent); border-radius: var(--radius-lg);
  padding: .95rem 1.2rem; box-shadow: var(--shadow);
}
.tenant-logo { height: 32px; width: auto; display: block; }
.tenant-mark {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 10px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: .95rem;
  display: flex; align-items: center; justify-content: center; letter-spacing: .02em;
}
.tenant-id { flex: 1; min-width: 0; }
.tenant-id h3 { margin: 0; font-size: 1.05rem; font-weight: 650; color: var(--text); letter-spacing: -.01em; }
.tenant-id .meta { margin: 0; }
.tenant-open {
  color: var(--accent); font-size: .83rem; font-weight: 600; white-space: nowrap;
  border: 1px solid var(--border); border-radius: var(--radius); padding: .45rem .85rem;
  transition: border-color var(--transition), background var(--transition);
}
.tenant-open:hover { border-color: var(--accent); background: var(--off-white); color: var(--accent); }

.cat { margin-top: 1.6rem; }
.cat-head { display: flex; align-items: center; gap: .8rem; margin-bottom: .85rem; }
.cat-name {
  font-size: .72rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--mid-grey);
}
.cat-rule { flex: 1; height: 1px; background: var(--light-grey); }

.report-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.report-card {
  display: flex; flex-direction: column; gap: .3rem; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.15rem 1.25rem 1rem; color: inherit; box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.report-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: #B9C6D3; }
.report-title { font-weight: 650; font-size: 1rem; color: var(--navy); line-height: 1.35; letter-spacing: -.01em; }
.report-blurb { font-style: italic; color: var(--text-light); font-size: .85rem; line-height: 1.4; }
.report-meta { color: var(--text-light); font-size: .82rem; }
/* INT-PORT-031: card_size >= 2 spans every column the grid currently has --
   robust across viewport widths, so the card is genuinely alone on its row
   (not just "2 of however-many-columns-exist" on a wide monitor) with the
   standard cards flowing onto the next row beneath it. Requires the wide
   report to sort first (display_order), which is the existing convention. */
.report-card-wide { grid-column: 1 / -1; }
.report-card-wide .report-title { font-size: 1.3rem; }
@media (max-width: 640px) { .report-grid { grid-template-columns: 1fr; } }
.report-foot { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-top: .55rem; }
.report-date { color: var(--mid-grey); font-size: .76rem; }
.chip {
  display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .68rem;
  font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  background: var(--off-white); color: var(--blue); border: 1px solid var(--light-grey);
}
/* Staff-only: report_list() includes inactive reports for is_insight_staff so
   Ren can confirm a deactivated report still exists without it being visible
   to any tenant/demo user (see views.py report_list comment). */
.report-card-inactive { opacity: .6; }
.chip-inactive { background: #FCEBEB; color: var(--red-dark); border-color: #F3C6C6; }

/* ---- Report frame chrome (document header + sandboxed iframe) ---- */
.report-frame-bar { display: flex; align-items: center; gap: 1.1rem; margin-bottom: 1.1rem; }
.report-frame-id { min-width: 0; }
.report-frame-title { font-size: 1.05rem; font-weight: 650; color: var(--navy); letter-spacing: -.01em; margin: 0; }
.report-frame-meta { margin: 0; font-size: .78rem; color: var(--mid-grey); }
.report-frame { width: 100%; height: calc(100vh - 220px); min-height: 520px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: #fff; }

/* ---- Admin ---- */
.admin-table { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); }
.admin-table th {
  background: var(--off-white); text-align: left; padding: .8rem 1rem;
  font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--mid-grey);
  border-bottom: 1px solid var(--border);
}
.admin-table td { text-align: left; padding: .8rem 1rem; border-bottom: 1px solid var(--light-grey); font-size: .9rem; }
.admin-table tr:last-child td { border-bottom: none; }
.badge { display: inline-block; padding: .18rem .65rem; border-radius: 999px; font-size: .74rem; font-weight: 700; margin-right: .3rem; }
.badge-active { background: #E6F4EA; color: #1E7E34; }
.badge-inactive { background: var(--light-grey); color: var(--mid-grey); }
.badge-staff { background: #FDECEC; color: #B3261E; }
.badge-org-admin { background: #FFF4E0; color: #9A5B00; }
.badge-admin-legacy { background: #FDECEC; color: #B3261E; }
.sort-link { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: .3rem; }
.sort-link:hover { text-decoration: underline; }
.sort-arrow { font-size: .7rem; }
.membership-row { display: flex; gap: .6rem; }
.membership-row select { flex: 1; }
.credentials {
  font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--off-white);
  border: 1px dashed var(--border); border-radius: var(--radius); padding: .9rem 1rem; margin-top: .6rem;
}

.tenant-section h3 { margin: 1.6rem 0 .6rem; font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--mid-grey); }

/* ---- Stage 4v: viewer facility lanes (spec §3.8) ---- */
.facility-band { margin-bottom: 2rem; }
.facility-band-head { display: flex; align-items: center; gap: .7rem; padding-bottom: .5rem; margin-bottom: 1rem; border-bottom: 3px solid var(--fb, var(--navy)); }
.facility-band-logo { height: 22px; width: auto; }
.facility-band-head h3 { margin: 0; font-size: 1rem; color: var(--navy); }
.facility-band-count { color: var(--mid-grey); font-size: .8rem; margin-left: auto; }

/* ---- Stage 4: tenant identity banner (spec §3.2) ---- */
.tenant-banner {
  display: flex; align-items: center; gap: .6rem; background: #fff;
  border: 1px solid var(--border); border-left: 5px solid var(--tb, var(--navy));
  border-radius: var(--radius); padding: .6rem 1rem; margin-bottom: 1.1rem; font-size: .9rem;
}
.tenant-banner-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--tb, var(--navy)); flex: none; }
.tenant-banner-label { color: var(--mid-grey); font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.tenant-banner strong { color: var(--navy); }
.tenant-banner-slug { color: var(--mid-grey); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; }

/* ---- Stage 4: access matrix (spec §3.6-i) ---- */
table.matrix { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 1rem; }
table.matrix th { background: var(--off-white); text-align: center; padding: .6rem .7rem; font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--mid-grey); border-bottom: 1px solid var(--border); }
table.matrix th.matrix-corner { background: #fff; border-bottom: none; }
table.matrix th.matrix-roworg { text-align: left; text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--navy); font-size: .88rem; white-space: nowrap; }
table.matrix td.matrix-cell { text-align: center; padding: .5rem; border-bottom: 1px solid var(--light-grey); vertical-align: top; }
table.matrix tr:last-child td { border-bottom: none; }
.matrix-toggle {
  width: 34px; height: 34px; border-radius: var(--radius); border: 1.5px solid var(--border); background: #fff;
  color: transparent; font-weight: 800; font-size: 1rem; cursor: pointer; transition: background var(--transition), border-color var(--transition);
}
.matrix-toggle:hover { border-color: var(--navy); background: var(--off-white); }
.matrix-toggle.checked { background: var(--navy); border-color: var(--navy); color: #fff; }
.matrix-toggle.checked.via-pattern { background: var(--red); border-color: var(--red); }
.matrix-provenance { font-size: .66rem; color: var(--mid-grey); margin-top: .2rem; max-width: 90px; }
.matrix-reveal { margin: .8rem 0 1rem; }
.matrix-reveal summary { cursor: pointer; color: var(--navy); font-weight: 600; font-size: .85rem; padding: .4rem 0; }
.matrix-reveal table.matrix { margin-top: .5rem; }

/* ---- Stage 4: guided granting ---- */
.pattern-nudge { background: #FFF8E8; border: 1px solid #F0DFAE; border-radius: var(--radius-lg); padding: .9rem 1.1rem; margin-bottom: 1rem; }
.pattern-nudge-row { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; font-size: .87rem; }
.pattern-nudge-row + .pattern-nudge-row { margin-top: .5rem; padding-top: .5rem; border-top: 1px dashed #F0DFAE; }
.pattern-forms { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem; }
.pattern-forms .card label { display: block; margin-bottom: .35rem; }
.pattern-forms .card select, .pattern-forms .card input[type=text] { margin-bottom: .5rem; }

/* ---- Responsive ---- */
@media (max-width: 820px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .nav-user { display: none; }
}
@media (max-width: 560px) {
  .footer-grid { grid-template-columns: 1fr; }
  .nav-inner .wordmark { font-size: 1.05rem; }
  .page-head { align-items: flex-start; }
}
