/* Visn AI · Digital Readiness — brand theme
   Font: Manrope. Navy = structure, Cyan = focused accent (actions, progress, selection).
   Primary buttons use navy text on cyan: #00AEEF + white fails WCAG AA (~2.4:1),
   #00AEEF + #000A19 passes (~8:1). */

:root {
  --color-navy-950: #000A19;
  --color-navy-800: #112333;
  --color-cyan-500: #00AEEF;
  --color-cyan-600: #008FC4;
  --color-background: #F4F7FA;
  --color-surface: #FFFFFF;
  --color-text-primary: #102333;
  --color-text-secondary: #5F7182;
  --color-border: #DCE5EC;
  --color-border-input: #CBD8E2;
  --color-accent-soft: #EAF7FC;
  --color-success: #16875D;
  --color-success-bg: #E8F6F0;
  --color-error: #C53D4A;
  --color-error-bg: #FBEDEF;
  --radius-card: 14px;
  --radius-control: 9px;
  --focus-ring: 0 0 0 3px rgba(0, 174, 239, 0.15);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }

body {
  margin: 0;
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  color: var(--color-text-primary);
  background: var(--color-background);
  line-height: 1.55;
}

h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.015em; margin: 0 0 .5rem; color: var(--color-navy-800); }
h2 { font-size: 20px; font-weight: 600; margin: 2rem 0 .5rem; color: var(--color-navy-800); }
a { color: var(--color-cyan-600); }
a:hover { color: var(--color-cyan-500); }
.muted { color: var(--color-text-secondary); }
.small { font-size: 13px; }
.center { text-align: center; }
.right { text-align: right; }

.eyebrow {
  font-size: 12px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--color-cyan-600); font-weight: 700; margin: 0 0 1rem;
}

.narrow { max-width: 480px; margin: 12vh auto 0; padding: 0 1.25rem; }
.wide   { max-width: 1040px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 1.1rem;
  border: 1px solid var(--color-border);
  background: var(--color-surface); color: var(--color-navy-800);
  border-radius: var(--radius-control);
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { border-color: var(--color-cyan-500); color: var(--color-cyan-600); }
.btn:active { background: var(--color-accent-soft); }

.btn.primary {
  background: var(--color-cyan-500); border-color: var(--color-cyan-500);
  color: var(--color-navy-950); min-height: 50px; padding: 0 1.8rem; font-weight: 700;
}
.btn.primary:hover { background: var(--color-cyan-600); border-color: var(--color-cyan-600); color: #fff; }
.btn.primary:active { background: #007DAB; }
.btn.primary:disabled { opacity: .55; cursor: default; background: var(--color-cyan-500); color: var(--color-navy-950); }

.btn.secondary { background: var(--color-navy-800); border-color: var(--color-navy-800); color: #fff; }
.btn.secondary:hover { background: var(--color-navy-950); color: #fff; }

.btn.destructive { background: var(--color-error); border-color: var(--color-error); color: #fff; }
.btn.destructive:hover { background: #A93140; }

.btn.small { min-height: 34px; padding: 0 .7rem; font-size: 13px; }
.btn.ghost { background: transparent; }

/* ---------- Inputs ---------- */
input[type=text], input[type=email], input[type=password], input[type=date] {
  font: inherit; min-height: 46px;
  border: 1px solid var(--color-border-input); border-radius: var(--radius-control);
  padding: 0 14px; background: var(--color-surface); color: var(--color-text-primary);
  width: 100%;
}
input:focus-visible {
  outline: none; border-color: var(--color-cyan-500); box-shadow: var(--focus-ring);
}
.btn:focus-visible {
  outline: none; box-shadow: var(--focus-ring), 0 0 0 1px var(--color-cyan-500);
}

.stack { display: flex; flex-direction: column; gap: 1rem; text-align: left; margin-top: 1.5rem; }
.stack label { display: flex; flex-direction: column; gap: .35rem; font-size: 14px; font-weight: 600; color: var(--color-navy-800); }
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.inline-form input { width: auto; flex: 1 1 180px; }
.inline { display: inline; }

.error {
  color: var(--color-error); background: var(--color-error-bg);
  border-radius: var(--radius-control); padding: .6rem .9rem; font-weight: 600; font-size: 14px;
}

/* ---------- Login page ---------- */
.login-split { display: flex; min-height: 100vh; }
.login-brand {
  flex: 0 0 45%; background: var(--color-navy-950); color: #fff;
  display: flex; flex-direction: column; justify-content: center;
  padding: 4rem 3.5rem; position: relative; overflow: hidden;
}
.login-brand::before { /* subtle data grid */
  content: ''; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(0,174,239,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,174,239,.06) 1px, transparent 1px);
  background-size: 44px 44px;
}
.login-brand::after { /* soft cyan glow */
  content: ''; position: absolute; width: 480px; height: 480px;
  right: -180px; bottom: -180px; border-radius: 50%;
  background: radial-gradient(circle, rgba(0,174,239,.16), transparent 65%);
}
.login-brand > * { position: relative; z-index: 1; }
.login-brand .brand-mark { font-size: 20px; font-weight: 800; letter-spacing: -.01em; margin: 0 0 3rem; }
.login-brand .brand-mark span { color: var(--color-cyan-500); }
.login-brand h2 { color: #fff; font-size: 32px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 1rem; line-height: 1.2; }
.login-brand p { color: rgba(255,255,255,.72); font-size: 16px; line-height: 1.65; max-width: 42ch; margin: 0; }

.login-panel {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem 1.5rem;
}
.login-card {
  width: 100%; max-width: 440px;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: 16px; padding: 40px;
  box-shadow: 0 16px 45px rgba(8, 35, 55, 0.08);
}
.login-card h1 { font-size: 26px; margin-bottom: .25rem; }
.login-card .sub { color: var(--color-text-secondary); font-size: 14px; margin: 0 0 .5rem; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 64px; }
.pw-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font: inherit; font-size: 13px; font-weight: 600; color: var(--color-cyan-600);
  background: none; border: none; cursor: pointer; padding: 6px 8px; border-radius: 6px;
}
.pw-toggle:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ---------- Respondent form ---------- */
.form-page { max-width: 760px; margin: 0 auto; padding: 2.5rem 1.25rem 5rem; }
.form-head { margin-bottom: 1.5rem; }
.form-head h1 { font-size: 28px; }

.progress-block {
  position: sticky; top: 0; z-index: 5;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-card); padding: 14px 18px; margin: 1.25rem 0;
  box-shadow: 0 2px 10px rgba(8,35,55,.04);
}
.progress-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.progress-meta .plabel { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--color-text-secondary); }
.progress-meta .pcount { font-size: 14px; font-weight: 700; color: var(--color-navy-800); font-variant-numeric: tabular-nums; }
.progress-track { height: 8px; background: var(--color-accent-soft); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--color-cyan-500); border-radius: 4px; transition: width .25s ease; }
.save-status { font-size: 13px; color: var(--color-text-secondary); margin-top: 6px; min-height: 1.2em; }
.save-status.saved { color: var(--color-success); font-weight: 600; }
.save-status.error { background: none; padding: 0; color: var(--color-error); font-weight: 600; }

.q-section { margin-top: 2.25rem; }
.q-section > h2 { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.section-tag {
  display: inline-block; font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  background: var(--color-navy-800); color: #fff; border-radius: 999px;
  padding: .2rem .7rem; font-weight: 700;
}

.question {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-card); padding: 24px; margin: 0 0 16px;
}
.question.missing { border-color: var(--color-error); box-shadow: 0 0 0 3px rgba(197,61,74,.12); }

.q-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 6px; }
.q-num {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--color-accent-soft); color: var(--color-cyan-600);
  font-size: 12px; font-weight: 800;
}
.q-title { font-size: 16px; font-weight: 700; color: var(--color-navy-800); padding-top: 3px; }
.q-text { font-size: 15px; line-height: 1.6; color: var(--color-text-primary); margin: 0 0 4px 40px; }

.scale { display: flex; gap: 8px; margin: 14px 0 0 40px; }
.scale-opt { flex: 1; min-width: 0; }
.scale-opt input { position: absolute; opacity: 0; pointer-events: none; }
.scale-opt span {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  min-height: 44px; border: 1px solid var(--color-border-input); border-radius: var(--radius-control);
  font-weight: 700; cursor: pointer; user-select: none;
  background: var(--color-surface); color: var(--color-navy-800);
  transition: background .12s, border-color .12s, color .12s;
}
.scale-opt:hover span { border-color: var(--color-cyan-500); background: var(--color-accent-soft); }
.scale-opt input:checked + span {
  background: var(--color-cyan-500); border-color: var(--color-cyan-600); color: var(--color-navy-950);
}
.scale-opt input:checked + span::after { /* non-color selection cue */
  content: '✓'; position: absolute; top: 2px; right: 5px; font-size: 10px; line-height: 1;
}
.scale-opt input:focus-visible + span { box-shadow: var(--focus-ring), 0 0 0 1px var(--color-cyan-500); }
.scale-ends {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--color-text-secondary); margin: 6px 0 0 40px;
}
.scale-ends .mid { position: absolute; left: 50%; transform: translateX(-50%); }
.scale-ends { position: relative; }

.restore-note {
  background: var(--color-accent-soft); border-left: 3px solid var(--color-cyan-500);
  padding: .6rem .9rem; border-radius: 6px; font-size: 14px;
}

.submit-row { margin-top: 2.5rem; text-align: center; display: flex; flex-direction: column; gap: .8rem; align-items: center; }
.submit-row .btn.primary { width: min(100%, 320px); }

.check {
  width: 3.2rem; height: 3.2rem; margin: 0 auto 1rem; border-radius: 50%;
  background: var(--color-success); color: #fff; font-size: 1.6rem;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Admin chrome ---------- */
.topnav {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .8rem 1.25rem; background: var(--color-navy-950); color: #fff;
}
.brand { color: #fff; text-decoration: none; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand span { font-weight: 400; opacity: .65; }
.topnav .btn.ghost { color: #fff; border-color: rgba(255,255,255,.28); min-height: 36px; }
.topnav .btn.ghost:hover { border-color: var(--color-cyan-500); color: var(--color-cyan-500); }

.breadcrumb { font-size: 13px; color: var(--color-text-secondary); margin: 0 0 .25rem; overflow-wrap: anywhere; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.panel { margin-top: 2.5rem; }

.table-scroll { overflow-x: auto; border-radius: var(--radius-card); }
table.data {
  width: 100%; border-collapse: collapse; background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: var(--radius-card); overflow: hidden;
}
table.data th, table.data td {
  text-align: left; padding: .7rem .9rem; border-bottom: 1px solid var(--color-border); font-size: 14px;
  overflow-wrap: anywhere;
}
table.data th {
  background: var(--color-navy-800); color: #fff;
  font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  white-space: nowrap;
}
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover td { background: var(--color-accent-soft); }
tr.inactive td { opacity: .5; }

.badge {
  display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; border-radius: 999px; padding: .18rem .65rem; white-space: nowrap;
}
.badge.open, .badge.done { background: var(--color-success-bg); color: var(--color-success); }
.badge.closed { background: #ECF1F5; color: var(--color-text-secondary); }
.badge.pending { background: var(--color-accent-soft); color: var(--color-cyan-600); }

.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; margin: 1.25rem 0 2rem; }
.stat {
  flex: 1; min-width: 160px; background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-card); padding: 1rem 1.2rem;
  display: flex; flex-direction: column; gap: .2rem;
}
.stat-num { font-size: 30px; font-weight: 800; color: var(--color-navy-800); font-variant-numeric: tabular-nums; }
.stat-num.small-text { font-size: 16px; line-height: 1.35; padding-top: .4rem; }
.stat-label { font-size: 12px; color: var(--color-text-secondary); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }

.score-chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.1rem; height: 2.1rem; border-radius: var(--radius-control); font-weight: 800; color: #fff;
}
.s1, .s2 { background: var(--color-error); }
.s3 { background: #D98E32; }
.s4 { background: #7C8B99; }
.s5 { background: var(--color-cyan-600); }
.s6, .s7 { background: var(--color-navy-800); }

/* ---------- Charts & quadrants ---------- */
.chart-box { height: 320px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-card); padding: 1rem; }
.quadrant-row { display: flex; gap: 1.5rem; flex-wrap: wrap; margin: 1.5rem 0; }
.quadrant {
  flex: 1; min-width: 300px; max-width: 490px; margin: 0;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-card); padding: 1rem;
}
.quadrant figcaption { font-weight: 700; font-size: 15px; margin-bottom: .5rem; color: var(--color-navy-800); }
.quadrant svg { width: 100%; height: auto; }
.quadrant .qlabel { font: 700 10px 'Manrope', sans-serif; fill: var(--color-text-secondary); text-anchor: middle; text-transform: uppercase; letter-spacing: .06em; }
.quadrant .qlabel.strong { fill: var(--color-success); }
.quadrant .tick { font: 10px 'Manrope', sans-serif; fill: var(--color-text-secondary); text-anchor: middle; }
.quadrant .tick.end { text-anchor: end; }
.quadrant .axis { font: 700 11px 'Manrope', sans-serif; fill: var(--color-navy-800); text-anchor: middle; }
.quadrant .ptlabel { font: 700 11px 'Manrope', sans-serif; fill: var(--color-cyan-600); text-anchor: middle; }
.avg-row td { background: var(--color-accent-soft); }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .wide { padding: 1.25rem 1rem 3.5rem; }
  .login-brand { flex-basis: 42%; padding: 3rem 2.25rem; }
}

@media (max-width: 768px) {
  .login-split { flex-direction: column; }
  .login-brand {
    flex: 0 0 auto; padding: 1.75rem 1.5rem; justify-content: flex-start;
  }
  .login-brand .brand-mark { margin-bottom: .75rem; }
  .login-brand h2 { font-size: 22px; margin-bottom: .4rem; }
  .login-brand p { font-size: 14px; }
  .login-panel { padding: 1.5rem 1rem 3rem; align-items: flex-start; }
  .login-card { padding: 28px 22px; }
}

@media (max-width: 640px) {
  h1 { font-size: 24px; }
  .form-page { padding: 1.75rem 1rem 4rem; }
  .q-text, .scale, .scale-ends { margin-left: 0; }
  .question { padding: 18px 16px; }
  .scale { gap: 5px; flex-wrap: wrap; }
  .scale-opt { flex: 1 1 calc(25% - 5px); }
  .scale-opt span { min-height: 42px; }
  .progress-block { padding: 12px 14px; border-radius: 10px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .btn, .inline-form .btn { width: 100%; }
  .inline-form input { flex-basis: 100%; }
  .stat-row { flex-direction: column; }
  .topnav .brand span { display: none; }
  table.data th, table.data td { padding: .55rem .6rem; font-size: 13px; }
}

/* ---------- Admin management ---------- */
.nav-actions { display: flex; gap: .5rem; align-items: center; }
.notice.success {
  color: var(--color-success); background: var(--color-success-bg);
  border-radius: var(--radius-control); padding: .6rem .9rem; font-weight: 600; font-size: 14px;
}
.inline-form.compact input { min-height: 36px; flex: 1 1 140px; font-size: 13px; }
.actions { white-space: nowrap; }
.actions form { margin-left: .25rem; }
