/* Global token layer. Django-served (not in React bundle) because login.html
   needs CSS vars and shared primitives without loading app.css. */

@font-face {
  font-family: "Manrope";
  src: url("../fonts/Manrope-400.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Manrope";
  src: url("../fonts/Manrope-500.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Manrope";
  src: url("../fonts/Manrope-600.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Manrope";
  src: url("../fonts/Manrope-700.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Manrope";
  src: url("../fonts/Manrope-800.ttf") format("truetype");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

:root {
  /* ── Colour tokens ── */
  --bg-primary: #ffffff;
  --bg-secondary: #ffffff;
  --bg-surface: #efede8;
  --border-color: #e7e5e0;
  --text-primary: #191714;
  --text-secondary: #78716c;
  --accent: #44403c;
  --accent-hover: #292524;
  --accent-alt: #78716c;
  --accent-light: rgba(68, 64, 60, 0.08);

  /* ── Accent colour aliases (change these to retheme the whole platform) ── */
  --accent-border:          #93c5fd;
  --accent-border-hover:    #60a5fa;
  --accent-bg:              #dbeafe;
  --accent-bg-hover:        #bfdbfe;
  --accent-text:            #1e3a8a;
  --accent-text-dark:       #172554;
  --accent-eyebrow:         #1d4ed8;
  --accent-eyebrow-summary: #3b82f6;

  /* Opacity variants */
  --accent-border-subtle:   rgba(59, 130, 246, 0.28);
  --accent-border-medium:   rgba(59, 130, 246, 0.42);
  --accent-border-faint:    rgba(59, 130, 246, 0.22);
  --accent-border-hair:     rgba(59, 130, 246, 0.08);
  --accent-border-pill:     rgba(147, 197, 253, 0.72);
  --accent-progress-bg:     rgba(59, 130, 246, 0.20);
  --accent-wash-soft:       rgba(239, 246, 255, 0.90);
  --accent-wash-softer:     rgba(239, 246, 255, 0.75);
  --accent-option-bg:       rgba(248, 250, 255, 0.92);

  /* Gradient surfaces */
  --accent-pale-wash-bg:    linear-gradient(180deg, rgba(248, 250, 255, 0.99) 0%, rgba(239, 246, 255, 0.97) 100%);
  --accent-warm-wash-bg:    linear-gradient(180deg, rgba(219, 234, 254, 0.98) 0%, rgba(191, 219, 254, 0.94) 100%);
  --accent-phase-card-bg:   linear-gradient(180deg, rgba(248, 250, 255, 0.98) 0%, rgba(239, 246, 255, 0.94) 100%);
  --accent-debrief-bar-risk: linear-gradient(90deg, #60a5fa 0%, #2563eb 100%);
  --challenge-warm-edge: rgba(212, 171, 86, 0.34);
  --challenge-warm-bg: linear-gradient(180deg, rgba(255, 248, 234, 0.96) 0%, rgba(255, 253, 247, 0.98) 100%);
  --amber-line: #d4ab56;
  --amber-fill: #f2d58c;
  --success: #16803c;
  --warning: #b36b00;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(28, 25, 23, 0.06);
  --shadow-md: 0 24px 80px rgba(28, 25, 23, 0.08);
  --transition: all 0.2s ease;
  --radius-lg: 14px;
  --radius-md: 10px;
  --hero-gradient: linear-gradient(135deg, #0a2b63, #1854b5 55%, #4994ff);

  /* ── Typography scale ── */
  /* xs  → 12px  labels, eyebrows, badges, table headers  */
  /* sm  → 14px  button text, meta, captions, nav links   */
  /* base→ 16px  body copy, descriptions, option text     */
  /* md  → 20px  card titles, question prompts            */
  /* lg  → 24px  subheadings, stat numbers                */
  /* xl  → 32px  page headings, KPI numbers               */
  /* 2xl → 48px  hero titles (use with clamp)             */
  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-md:   1.25rem;
  --text-lg:   1.5rem;
  --text-xl:   2rem;
  --text-2xl:  3rem;
}

html {
  background: #f0f5ff;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f0f5ff;
  color: var(--text-primary);
  font-family: "Manrope", "Segoe UI", Arial, sans-serif;
  font-size: var(--text-base);
  line-height: 1.5;
  transition: var(--transition);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

textarea,
input[type="text"],
input[type="password"],
input[type="email"],
select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
}

input[type="radio"] {
  accent-color: var(--accent);
}

.page-shell {
  max-width: 1640px;
  margin: 0 auto;
  padding: 18px 32px 56px;
}

.platform-body {
  background: linear-gradient(160deg, #eaf2ff 0%, #f0f5ff 40%, #eef3ff 100%);
  color: #1c1917;
}

.platform-app {
  min-height: 100vh;
}

.platform-shell {
  max-width: none;
  margin: 0;
  padding: 0;
}

.page-header {
  margin-bottom: 24px;
}

.alert-card {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(68, 64, 60, 0.12);
  background: rgba(255, 255, 255, 0.92);
}

.alert-card--warning {
  background: #fffbeb;
  border-color: #fde68a;
}

.alert-card--warning .alert-card__text {
  color: #92400e;
}

.alert-card--danger {
  background: #fff1f2;
  border-color: #fecaca;
}

.alert-card--danger .alert-card__text {
  color: #9f1239;
}

.alert-card__text {
  font-weight: 800;
}

/* Outer centering/padding wrapper — use with platform-shell */
.ui-page-wrap {
  max-width: 1720px;
  margin: 0 auto;
  padding: 12px 16px;
  min-height: 100vh;
}

.ui-page-frame {
  border-radius: 36px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: 24px;
}

.ui-page-inner {
  display: grid;
  gap: 24px;
}

.ui-page-intro {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ui-page-inner directly inside ui-page-wrap (no frame) gets the frame's
   equivalent inner padding as top offset, so title position matches framed pages */
.ui-page-wrap > .ui-page-inner {
  padding-top: 24px;
}

@media (min-width: 640px) {
  .ui-page-wrap > .ui-page-inner { padding-top: 32px; }
}

@media (min-width: 1024px) {
  .ui-page-wrap > .ui-page-inner { padding-top: 40px; }
}

.ui-page-title {
  max-width: none;
  margin: 0;
  font-size: clamp(1.875rem, 4vw, 2.8rem);
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.04em;
  color: var(--text-primary);
}

.ui-page-subtitle {
  max-width: 44rem;
  margin: 0;
  color: var(--text-secondary);
  font-size: var(--text-base);
  line-height: 1.6;
}

.ui-section-stack {
  display: grid;
  gap: 16px;
}

.ui-section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.ui-section-title {
  margin: 0;
  font-size: var(--text-lg);
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.ui-section-meta {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.ui-switcher {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.ui-switcher__tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid #ddd6cb;
  border-radius: 18px;
  background: #ffffff;
  color: #57534e;
  font-size: var(--text-sm);
  font-weight: 700;
  transition: var(--transition);
  cursor: pointer;
}

.ui-switcher__tab:hover,
.ui-switcher__tab.is-active {
  border-color: var(--accent-border);
  background: var(--accent-bg);
  color: var(--accent-text);
}

.ui-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.ui-kpi-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 92px;
  padding: 15px 16px 14px;
  border-radius: 20px;
  border: 1px solid var(--accent-border-subtle);
  background: var(--accent-wash-soft);
}

.ui-kpi-card--soft {
  background: var(--accent-warm-wash-bg);
}

.ui-kpi-label {
  margin: 0 0 8px;
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ui-kpi-value {
  color: var(--text-primary);
  font-size: var(--text-lg);
  line-height: 1.15;
  font-weight: 800;
}

.ui-card-soft {
  background: linear-gradient(180deg, rgba(250, 248, 244, 0.98) 0%, rgba(255, 255, 255, 1) 100%);
}

.ui-card-wash {
  border-color: var(--accent-border-medium);
  background: var(--accent-warm-wash-bg);
}

.ui-empty-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 24px;
  border: 1px dashed var(--border-color);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(250, 248, 244, 0.9) 0%, rgba(245, 243, 239, 0.95) 100%);
  text-align: center;
}

.ui-empty-state__title {
  margin: 0;
  font-size: var(--text-lg);
  color: var(--text-primary);
}

.ui-empty-state__copy {
  margin: 10px auto 0;
  max-width: 38ch;
  color: var(--text-secondary);
}

.page-actions,
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.content-flow > * {
  margin-top: 0;
  margin-bottom: 0;
}

.content-flow > * + * {
  margin-top: 18px;
}

.btn,
button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 700;
  transition: var(--transition);
}

.btn:hover,
button.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-primary {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent-text);
}

.btn-primary:hover {
  background: var(--accent-bg-hover);
  border-color: var(--accent-border-hover);
  color: var(--accent-text-dark);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.btn-danger:hover {
  filter: brightness(0.94);
}

.btn-secondary {
  background: var(--bg-primary);
  border-color: #ddd6cb;
  color: #57534e;
}

.btn-secondary:hover {
  border-color: #cfc7bc;
  color: var(--text-primary);
}

.card,
.stat-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.card {
  padding: 22px;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.stat-card {
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.card-title,
.section-title,
h2,
h3 {
  margin: 0;
  font-size: var(--text-md);
  line-height: 1.2;
  font-weight: 800;
}

.card-subtitle,
.muted {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid #ece5da;
  background: #fcfaf6;
  color: #7b7165;
  font-size: var(--text-xs);
  font-weight: 800;
}

.divider {
  height: 1px;
  margin: 16px 0;
  background: var(--border-color);
}

.grid {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.col-6 {
  flex: 1 1 460px;
}

.col-12 {
  flex: 1 1 100%;
}

.kpi {
  font-size: var(--text-xl);
  line-height: 1.1;
  font-weight: 900;
}

.page-title {
  margin: 10px 0 6px;
  font-size: clamp(var(--text-xl), 4vw, var(--text-2xl));
  line-height: 1.08;
  font-weight: 900;
}

.greeting {
  margin: 0;
  font-size: clamp(var(--text-xl), 4vw, var(--text-2xl));
  line-height: 1.05;
  font-weight: 900;
}

.greeting-sub {
  margin: 10px 0 0;
  max-width: 720px;
  color: var(--text-secondary);
  font-size: var(--text-base);
}

.stat-label {
  color: var(--text-secondary);
  font-size: var(--text-xs);
  margin-bottom: 10px;
}

.stat-value {
  font-size: var(--text-xl);
  line-height: 1;
  font-weight: 900;
}

.stat-note {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.side-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.side-item {
  padding: 16px;
  border-radius: 16px;
  background: var(--bg-surface);
}

.side-item strong {
  display: block;
  margin-bottom: 6px;
}

.progress-bar,
.bar {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg-surface);
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-alt));
}

.mt-6 {
  margin-top: 6px;
}

.mt-8 {
  margin-top: 8px;
}

.mt-10 {
  margin-top: 10px;
}

.mt-12 {
  margin-top: 12px;
}

.m-0 {
  margin: 0;
}

.hidden {
  display: none !important;
}

@media (min-width: 640px) {
  .ui-page-wrap { padding: 12px 24px; }
  .ui-page-frame { padding: 32px; }
}

@media (min-width: 1024px) {
  .ui-page-wrap { padding: 16px 32px; }
  .ui-page-frame { padding: 40px; }
}

@media (max-width: 900px) {
  .page-shell {
    padding-left: 24px;
    padding-right: 24px;
  }

  .ui-page-frame {
    padding: 22px;
  }

  .ui-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .page-shell {
    padding-left: 18px;
    padding-right: 18px;
    padding-top: 14px;
  }

  .ui-page-frame {
    border-radius: 28px;
    padding: 20px;
  }

  .ui-kpi-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .page-actions,
  .row {
    align-items: stretch;
  }
}
