/* ============================================================
   NINERUNS — Commercial Operating System Assessment
   Design System
   ============================================================ */

:root {
  --navy:        #233769;
  --navy-dark:   #111c3a;
  --navy-mid:    #1a2a50;
  --navy-tint:   #e8ecf4;
  --green:       #79a944;
  --green-dark:  #5c8333;
  --green-light: #a9cc75;
  --green-tint:  #f4f9ee;
  --ink:         #172033;
  --muted:       #667085;
  --subtle:      #94a3b8;
  --bg:          #f0f3f8;
  --surface:     #ffffff;
  --border:      #dfe4ea;
  --border-light:#eef1f5;
  --shadow-xs:   0 1px 2px rgba(23,32,51,.06);
  --shadow-sm:   0 1px 4px rgba(23,32,51,.08), 0 1px 3px rgba(23,32,51,.06);
  --shadow-md:   0 4px 18px rgba(23,32,51,.09);
  --shadow-lg:   0 8px 32px rgba(23,32,51,.13);
  --r-sm:        8px;
  --r:           14px;
  --r-lg:        20px;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   HEADER
   ============================================================ */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 max(24px, calc((100% - 1100px) / 2));
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow-xs);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  color: var(--navy);
  text-decoration: none;
}

.brand-logo {
  height: 54px;
  width: auto;
  display: block;
  object-fit: contain;
}

/* ============================================================
   MAIN
   ============================================================ */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

/* ============================================================
   HERO BANNER
   ============================================================ */
.hero {
  background: linear-gradient(140deg, var(--navy-dark) 0%, var(--navy) 55%, #2d4f92 100%);
  color: #fff;
  padding: 58px 52px;
  border-radius: var(--r-lg);
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: '';
  position: absolute;
  top: -100px;
  right: -80px;
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, rgba(121,169,68,.18) 0%, transparent 68%);
  pointer-events: none;
}

.hero.compact { padding: 36px 48px; }

.eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--green-light);
  margin-bottom: 14px;
}

.hero h1 {
  font-size: 44px;
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.5px;
  margin: 0 0 18px;
}

.hero p {
  font-size: 17px;
  color: #c5d2e8;
  max-width: 760px;
  margin: 0;
  line-height: 1.65;
}

/* Stats row */
.stats {
  display: flex;
  gap: 12px;
  margin-top: 36px;
  flex-wrap: wrap;
}

.stat-box {
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(6px);
  padding: 16px 24px;
  border-radius: var(--r);
  min-width: 130px;
}

.stat-box b {
  display: block;
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 5px;
}

.stat-box span {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: rgba(255,255,255,.6);
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 32px;
  margin: 24px 0;
  box-shadow: var(--shadow-sm);
}

.card h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
  margin: 0 0 22px;
}

/* ============================================================
   FORM
   ============================================================ */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.form-grid .full { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 6px; }

.field label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink);
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  background: #fafbfc;
  transition: border-color .15s, box-shadow .15s, background .15s;
  outline: none;
  -webkit-appearance: none;
}

.field input:focus {
  border-color: var(--navy);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(35,55,105,.10);
}

.field input::placeholder { color: var(--subtle); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 26px;
  border-radius: var(--r-sm);
  border: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  letter-spacing: 0.1px;
  transition: background .15s, transform .12s, box-shadow .15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--green);
  color: #fff;
}

.btn-primary:hover {
  background: var(--green-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(121,169,68,.35);
}

.btn-primary:active { transform: translateY(0); }

.btn-outline {
  background: transparent;
  color: var(--navy);
  border: 1.5px solid var(--border);
}

.btn-outline:hover {
  background: var(--navy-tint);
  border-color: var(--navy);
  box-shadow: none;
  transform: none;
}

/* ============================================================
   SYSTEMS GRID (start page)
   ============================================================ */
.phase-section { margin: 28px 0 0; }

.phase-label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.phase-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 4px 13px;
  border-radius: 99px;
  white-space: nowrap;
}

.phase-badge.think  { background: var(--navy-tint); color: var(--navy); }
.phase-badge.build  { background: var(--green-tint); color: var(--green-dark); }
.phase-badge.scale  { background: #f0f3f8; color: var(--muted); }

.phase-rule { flex: 1; height: 1px; background: var(--border); }

.systems {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.system-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  display: flex;
  gap: 13px;
  align-items: flex-start;
  transition: border-color .15s, box-shadow .15s;
}

.system-card:hover {
  border-color: var(--navy);
  box-shadow: var(--shadow-md);
}

.sys-num {
  background: var(--navy);
  color: #fff;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}

.system-card b {
  display: block;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 3px;
}

.system-card small {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

/* ============================================================
   PROGRESS BAR (assessment page)
   ============================================================ */
.progress-wrap {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px max(24px, calc((100% - 1100px) / 2));
  position: sticky;
  top: 64px;
  z-index: 100;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.progress-meta .prog-count { color: var(--navy); font-weight: 700; }

.progress-track {
  height: 5px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--navy), var(--green));
  border-radius: 99px;
  width: 0%;
  transition: width .3s ease;
}

/* ============================================================
   SCALE KEY
   ============================================================ */
.scale-key {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 0 0 28px;
}

.scale-item {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 8px;
  text-align: center;
}

.scale-num {
  display: block;
  font-size: 20px;
  font-weight: 900;
  color: var(--navy);
  line-height: 1;
  margin-bottom: 4px;
}

.scale-lbl {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 2px;
}

.scale-desc {
  display: block;
  font-size: 10px;
  color: var(--muted);
  line-height: 1.35;
}

/* ============================================================
   ASSESSMENT — Layer Cards
   ============================================================ */
.layer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin: 20px 0;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.layer-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--border-light);
  background: linear-gradient(to right, #f8fafc, #fff);
}

.layer-num {
  background: var(--navy);
  color: #fff;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 16px;
  flex-shrink: 0;
}

.layer-meta { min-width: 0; }

.layer-phase {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--green-dark);
  margin-bottom: 2px;
}

.layer-header h2 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.2px;
  margin: 0 0 2px;
}

.layer-header p {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

/* ---- Questions ---- */
.layer-body { padding: 4px 0; }

.question {
  padding: 22px 28px;
  border-bottom: 1px solid var(--border-light);
}

.question:last-child { border-bottom: none; }

.question-text {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.6;
  margin: 0 0 16px;
}

.q-num {
  font-weight: 800;
  color: var(--navy);
}

/* ---- Choices ---- */
.choices {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.choice-lbl {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 6px;
  cursor: pointer;
  background: #fafbfc;
  text-align: center;
  transition: border-color .14s, background .14s, transform .1s;
  user-select: none;
}

.choice-lbl:hover {
  border-color: var(--navy);
  background: var(--navy-tint);
  transform: translateY(-1px);
}

.choice-lbl input[type=radio] { display: none; }

.choice-val {
  display: block;
  font-size: 22px;
  font-weight: 900;
  color: var(--navy);
  line-height: 1;
}

.choice-tag {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.3;
}

/* Checked state */
.choice-lbl:has(input:checked) {
  border: 2px solid var(--green);
  background: var(--green-tint);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(121,169,68,.20);
}

.choice-lbl:has(input:checked) .choice-val { color: var(--green-dark); }
.choice-lbl:has(input:checked) .choice-tag { color: var(--green-dark); }

/* ============================================================
   SUBMIT BAR
   ============================================================ */
.submit-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 32px;
  margin-top: 24px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.submit-bar p {
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}

/* ============================================================
   ERROR
   ============================================================ */
.error-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-left: 4px solid #dc2626;
  color: #991b1b;
  padding: 14px 18px;
  border-radius: var(--r-sm);
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 500;
}

/* ============================================================
   RESULTS — Overall Score Card
   ============================================================ */
.overall-card {
  border-radius: var(--r-lg);
  color: #fff;
  padding: 52px 48px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  text-align: center;
}

.overall-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 25% 60%, rgba(255,255,255,.07) 0%, transparent 60%);
}

.overall-card .eyebrow { color: rgba(255,255,255,.55); margin-bottom: 20px; }

.big-score {
  font-size: 88px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -3px;
  margin-bottom: 10px;
}

.big-score .denom {
  font-size: 30px;
  font-weight: 600;
  opacity: .5;
  letter-spacing: 0;
}

.band-label {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.band-sub {
  font-size: 14px;
  opacity: .65;
}

/* Band colour tokens */
.band-reactive     { background: linear-gradient(135deg, #7f1d1d, #b91c1c); }
.band-emerging     { background: linear-gradient(135deg, #78350f, #b45309); }
.band-intentional  { background: linear-gradient(135deg, #14532d, #16a34a); }
.band-predictable  { background: linear-gradient(135deg, #1e3a8a, #2563eb); }
.band-optimized    { background: linear-gradient(135deg, var(--navy-dark), var(--navy)); }

/* ---- Score list ---- */
.score-section { margin: 24px 0; }

.score-list { display: flex; flex-direction: column; }

.score-row {
  display: grid;
  grid-template-columns: 220px 1fr 64px;
  gap: 18px;
  align-items: center;
  padding: 15px 0;
  border-bottom: 1px solid var(--border-light);
}

.score-row:last-child { border-bottom: none; }

.score-row-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 2px;
}

.score-row-tag {
  font-size: 11px;
  color: var(--muted);
  display: block;
  margin-bottom: 8px;
}

.bar-track {
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--navy);
  width: 0%;
  transition: width .9s cubic-bezier(.4,0,.2,1);
}

.bar-fill.red    { background: #b91c1c; }
.bar-fill.yellow { background: #b45309; }
.bar-fill.green  { background: #16a34a; }
.bar-fill.blue   { background: var(--navy); }
.bar-fill.s1     { background: #dc2626; }
.bar-fill.s2     { background: #ea580c; }
.bar-fill.s3     { background: #ca8a04; }
.bar-fill.s4     { background: #1d4ed8; }
.bar-fill.s5     { background: #16a34a; }

.score-badge {
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  text-align: center;
  min-width: 54px;
}

.score-badge.red    { background: #b91c1c; }
.score-badge.yellow { background: #b45309; }
.score-badge.green  { background: #16a34a; }
.score-badge.blue   { background: var(--navy); }
.score-badge.s1     { background: #dc2626; }
.score-badge.s2     { background: #ea580c; }
.score-badge.s3     { background: #ca8a04; }
.score-badge.s4     { background: #1d4ed8; }
.score-badge.s5     { background: #16a34a; }

/* ---- Radar chart ---- */
.results-viz {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 32px;
  align-items: start;
}

#radar-chart {
  width: 100%;
  height: auto;
}

/* ---- Two-col (strengths / priorities) ---- */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.sp-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border-light);
}

.sp-item:last-child { border-bottom: none; }

.sp-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 12px;
  flex-shrink: 0;
  margin-top: 1px;
}

.sp-dot.strength { background: var(--green-tint); color: var(--green-dark); }
.sp-dot.priority { background: #fef2f2; color: #991b1b; }

.sp-name {
  font-size: 14px;
  font-weight: 700;
  display: block;
  margin-bottom: 1px;
}

.sp-score {
  font-size: 12px;
  color: var(--muted);
}

/* ---- CTA card ---- */
.cta-card {
  background: linear-gradient(140deg, var(--navy-dark) 0%, var(--navy) 60%, #2d4f92 100%);
  color: #fff;
  border-radius: var(--r-lg);
  padding: 52px;
  margin: 24px 0;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.cta-card::after {
  content: '';
  position: absolute;
  bottom: -80px;
  right: -80px;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(121,169,68,.18), transparent 68%);
  pointer-events: none;
}

.cta-card .eyebrow { color: var(--green-light); margin-bottom: 16px; }

.cta-card h2 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.3px;
  margin-bottom: 16px;
  line-height: 1.2;
}

.cta-card p {
  font-size: 16px;
  color: #c2d2e8;
  max-width: 620px;
  margin: 0 auto;
  line-height: 1.65;
}

/* ============================================================
   ADMIN
   ============================================================ */
.admin-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
}

.tablewrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

tbody tr:hover td { background: #f8fafc; }

.admin-band {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 99px;
  white-space: nowrap;
}

.admin-band.Reactive    { background: #fef2f2; color: #991b1b; }
.admin-band.Emerging    { background: #fffbeb; color: #92400e; }
.admin-band.Intentional { background: #f0fdf4; color: #14532d; }
.admin-band.Predictable { background: #eff6ff; color: #1e3a8a; }
.admin-band.Optimized   { background: var(--navy-tint); color: var(--navy); }

.score-num {
  font-weight: 700;
  color: var(--navy);
}

/* ============================================================
   PRINT ACTION BAR
   ============================================================ */
.print-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-xs);
}

.print-bar-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

/* ============================================================
   FOOTER
   ============================================================ */
footer {
  text-align: center;
  color: var(--subtle);
  padding: 32px 24px;
  font-size: 13px;
  border-top: 1px solid var(--border-light);
  margin-top: 40px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .results-viz {
    grid-template-columns: 1fr;
  }
  #radar-chart { max-width: 340px; margin: 0 auto; display: block; }
}

@media (max-width: 768px) {
  main { padding: 20px 16px 60px; }

  .hero { padding: 32px 24px; }
  .hero h1 { font-size: 30px; }
  .hero.compact { padding: 26px 24px; }

  .stats { gap: 8px; }
  .stat-box { min-width: unset; flex: 1; }

  .form-grid { grid-template-columns: 1fr; }

  .systems { grid-template-columns: 1fr 1fr; }

  .scale-key { gap: 5px; }
  .scale-item { padding: 9px 4px; }
  .scale-num { font-size: 17px; }
  .scale-desc { display: none; }

  .layer-header { padding: 18px 20px; }
  .question { padding: 18px 20px; }

  .choices { gap: 5px; }
  .choice-lbl { padding: 10px 3px; }
  .choice-val { font-size: 18px; }
  .choice-tag { font-size: 9px; }

  .score-row { grid-template-columns: 1fr auto; }
  .score-row .bar-track { grid-column: 1 / -1; margin-top: 4px; }

  .two-col { grid-template-columns: 1fr; }

  .big-score { font-size: 64px; }
  .overall-card { padding: 36px 24px; }

  .cta-card { padding: 36px 24px; }
  .cta-card h2 { font-size: 22px; }

  .progress-wrap { top: 56px; }
}

@media (max-width: 500px) {
  .systems { grid-template-columns: 1fr; }
  .hero h1 { font-size: 24px; }
}

/* ============================================================
   PRINT / PDF
   ============================================================ */
@media print {
  /* Hide chrome */
  header,
  footer,
  .no-print,
  .progress-wrap {
    display: none !important;
  }

  /* Remove page background, let cards show on white */
  body {
    background: #fff;
    color: #172033;
    font-size: 12pt;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  main {
    max-width: 100%;
    padding: 0;
    margin: 0;
  }

  /* Avoid breaking cards across pages */
  .card,
  .overall-card,
  .cta-card,
  .two-col,
  .score-section {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* Radar + scores: stack vertically so both fit */
  .results-viz {
    grid-template-columns: 1fr;
  }

  #radar-chart {
    max-width: 320px;
    margin: 0 auto 24px;
    display: block;
  }

  /* Two-col strengths/priorities: keep side by side if space, else stack */
  .two-col {
    grid-template-columns: 1fr 1fr;
  }

  /* Ensure bar fills are visible in print (they default to 0 without JS animation) */
  .bar-fill {
    transition: none;
  }

  /* Ensure background gradients (band colours) print */
  .band-reactive,
  .band-emerging,
  .band-intentional,
  .band-predictable,
  .band-optimized,
  .hero,
  .cta-card {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Subtle shadow reduction for print */
  .card {
    box-shadow: none;
    border: 1px solid #dfe4ea;
  }

  a { text-decoration: none; color: inherit; }
}
