@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap");

:root {
  /* Industrial clean documentation theme */
  --ui-bg: #f8fafc;
  --ui-surface: #ffffff;
  --ui-surface-soft: #f8fafc;
  --ui-line: #e2e8f0;
  --ui-line-strong: #cbd5e1;
  --ui-text: #0f172a;
  --ui-muted: #0f172a;
  --ui-accent-strong: #800020;
  --ui-accent: var(--ui-accent-strong);
  --ui-accent-soft: #f4e8ec;
  --ui-accent2-strong: #00700D;
  --ui-accent2: var(--ui-accent2-strong);
  --ui-accent2-soft: #e6efe9;
  --ui-table-line: #e2e8f0;
  --ui-table-line-strong: #cbd5e1;
  --ui-ok: #0f8c6f;
  --ui-warn: #7c5a00;

  /* Shared role palette */
  --role-backoffice-strong: #00700D;
  --role-backoffice: var(--role-backoffice-strong);
  --role-backoffice-bg: #e6efe9;
  --role-mechanic-strong: #ff8000;
  --role-mechanic: var(--role-mechanic-strong);
  --role-mechanic-bg: #fff2e6;
  --role-customer-strong: #77a2d1;
  --role-customer: var(--role-customer-strong);
  --role-customer-bg: #eaf1f8;

  --ui-radius-sm: 10px;
  --ui-radius-md: 12px;
  --ui-radius-lg: 14px;

  --ui-space-1: 8px;
  --ui-space-2: 12px;
  --ui-space-3: 16px;
  --ui-space-4: 24px;
  --ui-space-5: 32px;
  --ui-doc-min-width: 944px;

  /* Typography scale */
  --ui-fs-body: 16px;
  --ui-fs-h1: clamp(32px, 4.3vw, 48px);
  --ui-fs-h2: clamp(22px, 2.6vw, 30px);
  --ui-fs-h3: clamp(18px, 1.8vw, 22px);

  /* Compatibility aliases for existing per-page CSS */
  --bg: var(--ui-bg);
  --surface: var(--ui-surface);
  --surface-soft: var(--ui-surface-soft);
  --line: var(--ui-line);
  --text: var(--ui-text);
  --muted: var(--ui-muted);
  --accent: var(--ui-accent);
  --accent-strong: var(--ui-accent-strong);
  --accent-soft: var(--ui-accent-soft);
  --table-line: var(--ui-table-line);
  --table-line-strong: var(--ui-table-line-strong);
  --ok: var(--ui-ok);
  --warn: var(--ui-warn);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  background: var(--ui-bg);
}

body {
  margin: 0;
  color: var(--ui-text);
  font-family: "Manrope", "Aptos", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: var(--ui-fs-body);
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  background: var(--ui-bg);
}

body:not(.app-shell) {
  background: #ffffff;
}

:where(body:not(.app-shell) main, .chapter-doc) {
  width: 100%;
  max-width: 1180px;
  min-width: var(--ui-doc-min-width);
  margin: 0;
  background: #ffffff;
  padding: 34px 18px 46px !important;
}

.page-head {
  margin-bottom: 24px !important;
}

.page-head .intro {
  margin: 8px 0 0 !important;
  font-size: 16px;
  line-height: 1.5;
}

/* Guardrail: keep content-page header/intro contract stable against local CSS drift. */
:where(body:not(.app-shell) main, .chapter-doc) header.page-head.page-head.page-head {
  margin-bottom: 24px !important;
}

:where(body:not(.app-shell) main, .chapter-doc) header.page-head.page-head.page-head h1 {
  display: none !important;
}

:where(body:not(.app-shell) main, .chapter-doc) header.page-head.page-head.page-head .intro {
  margin: 0 !important;
  font-size: 16px !important;
  line-height: 1.5 !important;
  color: var(--ui-muted) !important;
}

h1,
h2,
h3 {
  margin-top: 0;
  color: var(--ui-accent-strong);
  letter-spacing: -0.025em;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.03;
}

h2 {
  font-size: var(--ui-fs-h2);
  line-height: 1.12;
}

h3 {
  font-size: var(--ui-fs-h3);
  line-height: 1.2;
}

.section-title {
  margin: 0 0 16px !important;
  line-height: 1.2;
  color: var(--ui-accent-strong);
}

.card > h2,
.panel > h2,
.ui-card > h2,
.prototype-core > h2 {
  font-size: clamp(18px, 1.9vw, 22px) !important;
  line-height: 1.18;
  letter-spacing: -0.015em;
}

p,
li,
td,
th {
  line-height: 1.45;
}

:where(body:not(.app-shell) main, .chapter-doc) li::marker,
:where(body:not(.app-shell) main, .chapter-doc) ol li::marker,
:where(body:not(.app-shell) main, .chapter-doc) ul li::marker {
  color: var(--ui-accent-strong) !important;
}

.intro,
.hint,
.legend-note {
  color: var(--ui-muted) !important;
}

:where(body:not(.app-shell) main, .chapter-doc) .card ul,
:where(body:not(.app-shell) main, .chapter-doc) .card ol,
:where(body:not(.app-shell) main, .chapter-doc) .lead-card ul,
:where(body:not(.app-shell) main, .chapter-doc) .lead-card ol {
  margin: 0 !important;
  padding-left: 18px !important;
}

:where(body:not(.app-shell) main, .chapter-doc) .card,
:where(body:not(.app-shell) main, .chapter-doc) .ui-card,
:where(body:not(.app-shell) main, .chapter-doc) .lead-card {
  padding: 16px;
}

:where(body:not(.app-shell) main, .chapter-doc) .card > h2,
:where(body:not(.app-shell) main, .chapter-doc) .ui-card > h2,
:where(body:not(.app-shell) main, .chapter-doc) .lead-card > h2 {
  margin: 0 0 10px;
}

:where(body:not(.app-shell) main, .chapter-doc) .lead-card > h2,
:where(body:not(.app-shell) main, .chapter-doc) .lead-card > .section-title {
  font-size: clamp(18px, 1.9vw, 22px) !important;
  line-height: 1.18 !important;
  letter-spacing: -0.015em;
}

/* Keep content-card copy sizing consistent across pages. */
:where(body:not(.app-shell) main, .chapter-doc) .card p,
:where(body:not(.app-shell) main, .chapter-doc) .card li,
:where(body:not(.app-shell) main, .chapter-doc) .lead-card p,
:where(body:not(.app-shell) main, .chapter-doc) .touch-list,
:where(body:not(.app-shell) main, .chapter-doc) .touch-list li {
  font-size: 15px !important;
  line-height: 1.5 !important;
}

:where(body:not(.app-shell) main, .chapter-doc) .roadmap-head p:not(.eyebrow),
:where(body:not(.app-shell) main, .chapter-doc) .core-item p,
:where(body:not(.app-shell) main, .chapter-doc) .roadmap-card p,
:where(body:not(.app-shell) main, .chapter-doc) .roadmap-card li {
  color: var(--ui-muted) !important;
  font-size: 15px !important;
  line-height: 1.5 !important;
}

:where(body:not(.app-shell) main, .chapter-doc) .core-item strong {
  color: var(--ui-text) !important;
  font-size: 14px !important;
  line-height: 1.35 !important;
}

:where(body:not(.app-shell) main, .chapter-doc) .roadmap-card h3 {
  margin: 0 0 10px !important;
  color: var(--ui-accent-strong) !important;
  font-size: 16px !important;
  line-height: 1.3 !important;
}

:where(body:not(.app-shell) main, .chapter-doc) .roadmap-card ul,
:where(body:not(.app-shell) main, .chapter-doc) .roadmap-card ol {
  margin: 0 !important;
  padding-left: 18px !important;
}

:where(body:not(.app-shell) main, .chapter-doc) .roadmap-card li {
  margin-bottom: 6px !important;
}

:where(body:not(.app-shell) main, .chapter-doc) .roadmap-card li:last-child {
  margin-bottom: 0 !important;
}

:where(body:not(.app-shell) main, .chapter-doc) .touch-list {
  margin: 0 0 10px !important;
  padding-left: 18px !important;
  line-height: 1.5 !important;
}

:where(body:not(.app-shell) main, .chapter-doc) .touch-list li + li {
  margin-top: 6px;
}

:where(body:not(.app-shell) main, .chapter-doc) .touch-list:last-child {
  margin-bottom: 0 !important;
}

:where(body:not(.app-shell) main, .chapter-doc) .core-box-head {
  color: var(--ui-accent-strong) !important;
  background: var(--ui-accent-soft);
  border-bottom: 1px solid var(--ui-accent);
  font-size: 13px !important;
  font-weight: 700 !important;
  letter-spacing: .01em !important;
  line-height: 1.25 !important;
  text-rendering: optimizeLegibility;
}

:where(body:not(.app-shell) main, .chapter-doc) .core-box-head.backoffice {
  color: #ffffff !important;
  background: var(--role-backoffice-strong) !important;
  border-bottom: 1px solid var(--role-backoffice-strong) !important;
}

:where(body:not(.app-shell) main, .chapter-doc) .core-box-head.mechanic {
  color: #ffffff !important;
  background: var(--role-mechanic-strong) !important;
  border-bottom: 1px solid var(--role-mechanic-strong) !important;
}

:where(body:not(.app-shell) main, .chapter-doc) .core-box-head.customer {
  color: #ffffff !important;
  background: var(--role-customer-strong) !important;
  border-bottom: 1px solid var(--role-customer-strong) !important;
}

:where(body:not(.app-shell) main, .chapter-doc) .core-box-head .core-app-pill {
  color: inherit !important;
  border-color: rgba(255, 255, 255, 0.7) !important;
  background: rgba(255, 255, 255, 0.16) !important;
}

:where(body:not(.app-shell) main, .chapter-doc) .core-box-body strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ui-text) !important;
  font-size: 14px !important;
  font-weight: 600;
  letter-spacing: .005em;
  text-rendering: optimizeLegibility;
}

:where(body:not(.app-shell) main, .chapter-doc) .eyebrow {
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

:where(body:not(.app-shell) main, .chapter-doc) .phase-label,
:where(body:not(.app-shell) main, .chapter-doc) .phase small {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

:where(body:not(.app-shell) main, .chapter-doc) .phase-label {
  letter-spacing: .09em;
}

:where(body:not(.app-shell) main, .chapter-doc) .phase small {
  letter-spacing: .04em;
}

:where(body:not(.app-shell) main, .chapter-doc) .phase strong {
  font-size: 14px;
  line-height: 1.3;
  letter-spacing: -.01em;
  color: var(--ui-accent-strong) !important;
}

:where(body:not(.app-shell) main, .chapter-doc) .role strong {
  font-size: 12px;
  letter-spacing: .09em;
  text-transform: uppercase;
}

:where(body:not(.app-shell) main, .chapter-doc) .role small {
  color: var(--ui-muted);
  font-size: 11px;
  line-height: 1.3;
}

:where(body:not(.app-shell) main, .chapter-doc) .touchpoint {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

:where(body:not(.app-shell) main, .chapter-doc) .lane-row .cell:first-of-type .touchpoint {
  font-size: 16px;
  line-height: 1.3;
}

:where(body:not(.app-shell) main, .chapter-doc) .feature-flag {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
}

:where(body:not(.app-shell) main, .chapter-doc) .roadmap-stage {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .01em;
  text-transform: uppercase;
  line-height: 1.2;
  text-rendering: optimizeLegibility;
}

:where(body:not(.app-shell) main, .chapter-doc) .stage-priority {
  font-size: 12px;
  letter-spacing: .03em;
  line-height: 1.2;
  text-rendering: optimizeLegibility;
}

:where(body:not(.app-shell) main, .chapter-doc) .show-in-process {
  font-size: 11px;
  font-weight: 700;
}

:where(body:not(.app-shell) main, .chapter-doc) table tbody td.a,
:where(body:not(.app-shell) main, .chapter-doc) table tbody td.c,
:where(body:not(.app-shell) main, .chapter-doc) table tbody td.i,
:where(body:not(.app-shell) main, .chapter-doc) table tbody td.r {
  font-size: 15px;
}

.legend--inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 12px;
}

.legend--inline .legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ui-text);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.legend--inline .legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  flex: 0 0 auto;
}

.sw-backoffice {
  background: var(--role-backoffice);
  border-color: var(--role-backoffice-strong);
}

.sw-mechanic {
  background: var(--role-mechanic);
  border-color: var(--role-mechanic-strong);
}

.sw-customer {
  background: var(--role-customer);
  border-color: var(--role-customer-strong);
}

.sw-event {
  background: var(--accent);
  border-color: var(--accent-strong);
}

.sw-data {
  background: var(--ui-line-strong);
  border-color: var(--ui-muted);
}

/* Card variants */
.ui-card,
.panel,
.card,
.lead-card,
.process-card,
.prototype-core,
.roadmap-card,
.core-item,
.legend,
.meta,
.box {
  background: var(--ui-surface-soft) !important;
  border: 1px solid var(--ui-line) !important;
  border-radius: var(--ui-radius-lg) !important;
  box-shadow: none !important;
}

.ui-card--soft {
  background: var(--ui-surface-soft) !important;
  border-color: var(--ui-line) !important;
}

.ui-card--outline {
  background: transparent !important;
  border-color: var(--ui-line-strong) !important;
}

/* Keep MVP core boxes aligned with the process diagram role styling. */
.core-item.mobile {
  border-color: var(--role-mechanic-strong) !important;
  border-left: 4px solid var(--role-mechanic) !important;
  background: var(--role-mechanic-bg) !important;
}

.core-item.web {
  border-color: var(--role-backoffice-strong) !important;
  border-left: 4px solid var(--role-backoffice) !important;
  background: var(--role-backoffice-bg) !important;
}

.core-item.customer {
  border-color: var(--role-customer-strong) !important;
  border-left: 4px solid var(--role-customer) !important;
  background: var(--role-customer-bg) !important;
}

/* Stable interaction styling */
button,
.interactive {
  min-height: 44px;
  touch-action: manipulation;
  transition: border-color .16s ease, background-color .16s ease, color .16s ease;
}

input[type="button"],
input[type="submit"],
input[type="reset"] {
  min-height: 44px;
  touch-action: manipulation;
}

button:hover,
.interactive:hover {
  border-color: var(--ui-line-strong);
}

/* Standalone auth and redirect pages */
body.auth-page,
body.redirect-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

body.auth-page {
  background:
    radial-gradient(circle at 12% -8%, #ffffff 0%, #f9f4f6 42%, #f8f6f4 76%),
    var(--ui-bg);
}

body.auth-page .card {
  width: min(440px, 100%);
  border-radius: 18px !important;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(31, 36, 45, 0.08);
}

body.auth-page h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

body.auth-page p {
  margin: 10px 0 0;
  color: var(--ui-muted);
  line-height: 1.45;
  font-size: 14px;
}

body.auth-page .field {
  margin-top: 16px;
  display: grid;
  gap: 6px;
}

body.auth-page label {
  font-size: 13px;
  color: var(--ui-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

body.auth-page input[type="password"] {
  width: 100%;
  border: 1px solid var(--ui-line);
  border-radius: 12px;
  padding: 12px;
  font-size: 16px;
  color: var(--ui-text);
  background: #ffffff;
}

body.auth-page input[type="password"]:focus {
  outline: 0;
  border-color: var(--ui-accent);
  box-shadow: 0 0 0 3px var(--ui-accent-soft);
}

body.auth-page button {
  margin-top: 14px;
  width: 100%;
  border: 1px solid var(--ui-accent);
  border-radius: 12px;
  padding: 12px;
  color: #ffffff;
  background: linear-gradient(180deg, var(--ui-accent) 0%, var(--ui-accent-strong) 100%);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

body.auth-page button:disabled {
  opacity: 0.7;
  cursor: progress;
}

body.auth-page .error {
  margin-top: 10px;
  min-height: 20px;
  color: var(--ui-accent-strong);
  font-size: 13px;
  font-weight: 700;
}

body.auth-page .note {
  margin-top: 14px;
  border: 1px dashed var(--ui-line-strong);
  background: var(--ui-surface-soft);
  border-radius: var(--ui-radius-md);
  padding: 10px 12px;
  color: var(--ui-text);
  font-size: 13px;
  line-height: 1.4;
}

body.redirect-page {
  background: var(--ui-bg);
}

body.redirect-page .redirect-card {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius-md);
  background: var(--ui-surface);
  color: var(--ui-text);
}

body.redirect-page a {
  color: var(--ui-accent);
}

/* Global minimalist clean-up for page-local components */
.core-box,
.touchpoint,
.roadmap-card,
.feature-flag,
.drawio-embed,
.process-card,
.approach-table,
table {
  border-radius: var(--ui-radius-md) !important;
}

.phase,
.phase-label,
.phase-row {
  background: var(--ui-surface-soft) !important;
  border-color: var(--ui-line) !important;
  color: var(--ui-text) !important;
}

.roadmap-card-head {
  background: var(--ui-accent-soft) !important;
  border-color: var(--ui-accent-soft) !important;
  color: var(--ui-accent-strong) !important;
}

.nav button.active,
button.active {
  box-shadow: inset 0 0 0 1px var(--ui-accent) !important;
}

.meta,
.legend {
  background: var(--ui-surface-soft) !important;
  border: 1px dashed var(--ui-line-strong) !important;
  border-radius: var(--ui-radius-md) !important;
  color: var(--ui-muted) !important;
  font-size: 13px !important;
  line-height: 1.45 !important;
  padding: 12px 14px !important;
}

/* Tables */
table,
.approach-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: var(--ui-surface-soft);
}

table th,
table td,
.approach-table th,
.approach-table td {
  border-top: 0 !important;
  border-left: 0 !important;
  border-right: 1px solid var(--table-line) !important;
  border-bottom: 1px solid var(--table-line) !important;
  padding: 12px 13px !important;
  text-align: left;
  font-size: 14px;
  line-height: 1.42;
  vertical-align: top;
  font-variant-numeric: tabular-nums;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: manual;
}

table tr > *:last-child,
.approach-table tr > *:last-child {
  border-right: 0 !important;
}

table thead th,
.approach-table thead th {
  background: var(--ui-accent-soft);
  border-bottom: 1px solid var(--ui-accent-soft) !important;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: 12px;
  color: var(--ui-accent-strong);
  font-weight: 700;
}

table tbody tr:last-child td {
  border-bottom: 0 !important;
}

.approach-table tbody tr:last-child td {
  border-bottom: 0 !important;
}

.diagram,
.diagram-scroll {
  background: transparent;
}

/* Shell-specific stability */
body.app-shell .content {
  padding: 0;
  gap: 0;
}

body.app-shell .viewer-card {
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  overflow: visible;
}

body.app-shell .viewer-head {
  padding: 16px;
  border-bottom: 1px solid var(--ui-accent-soft);
  background: var(--ui-accent-soft);
}

body.app-shell .viewer-head-title {
  margin: 0;
  color: var(--ui-accent-strong);
  font-size: clamp(28px, 3.8vw, 40px) !important;
  line-height: 1.04 !important;
  font-weight: 800;
  letter-spacing: -0.03em;
}

body.app-shell .chapter-host {
  background: #ffffff !important;
}

body.app-shell .brand-note {
  font-size: 12px;
  letter-spacing: .11em;
  text-transform: uppercase;
  font-weight: 700;
}

body.app-shell .nav-group-title {
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ui-accent-strong);
}

body.app-shell .logout-btn,
body.app-shell .chapter-btn {
  font-size: 12px;
}

body.app-shell .chapter-title {
  font-size: 14px;
  line-height: 1.2;
}
