:root {
  --dark: #2C2F38;
  --dark-soft: #39404d;
  --app-bg: #f4f5f8;
  --app-panel: #ffffff;
  --paper: #ffffff;
  --ink: #171719;
  --muted: #6f7280;
  --muted-soft: #a4a8b4;
  --line: #d8dbe2;
  --line-strong: #b8bdc9;
  --accent: #60A5FA;
  --accent-900: #1E3A8A;
  --accent-700: #2563EB;
  --accent-500: #60A5FA;
  --accent-300: #93C5FD;
  --accent-150: #DBEAFE;
  --accent-75: #EFF6FF;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

@page {
  size: A4;
  margin: 0;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--app-bg);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 400;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(360px, 420px) 1fr;
  min-height: 100vh;
}

.editor {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 28px;
  background: var(--paper);
  color: var(--ink);
  border-right: 1px solid var(--line);
}

.editor-brand {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}

.editor-brand img {
  width: 86px;
  height: auto;
}

.kicker,
legend {
  margin: 0 0 4px;
  color: var(--accent-300);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.editor h1 {
  margin: 0;
  font-size: 34px;
  font-weight: 500;
  letter-spacing: 0;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}

.storage-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.backup-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.storage-status {
  min-height: 16px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

button.secondary {
  border: 1px solid var(--line);
  background: var(--app-bg);
  color: var(--ink);
}

button.full {
  width: 100%;
}

fieldset {
  margin: 0 0 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--app-panel);
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent-300);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.22);
}

.rows-editor {
  display: grid;
  gap: 14px;
  margin-bottom: 12px;
}

.row-editor {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--app-bg);
}

.row-editor label {
  margin-bottom: 0;
}

.row-editor input,
.row-editor textarea {
  background: #fff;
}

.row-editor textarea {
  min-height: 86px;
}

.row-editor button {
  min-height: 38px;
  width: fit-content;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.preview-wrap {
  min-height: 100vh;
  padding: 34px;
  overflow: auto;
  background: var(--app-bg);
}

.preview {
  display: grid;
  gap: 24px;
  justify-content: center;
}

.sheet {
  position: relative;
  width: 210mm;
  height: 297mm;
  padding: 17mm 18mm 23mm;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  page-break-after: always;
}

.sheet::before,
.sheet::after {
  content: "";
  position: absolute;
  top: 0;
  height: 10mm;
}

.sheet::before {
  left: 0;
  width: 47mm;
  background: var(--dark);
  clip-path: polygon(0 0, 100% 0, 92% 100%, 0% 100%);
}

.sheet::after {
  right: 0;
  width: 87mm;
  background: linear-gradient(90deg, var(--accent-150), var(--accent-75));
  clip-path: polygon(7% 0, 100% 0, 100% 100%, 0 100%);
}

.doc-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 32mm;
  padding-top: 8mm;
}

.doc-logo {
  width: 34mm;
  height: auto;
  object-fit: contain;
}

.doc-kicker {
  color: var(--accent);
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-align: right;
  text-transform: uppercase;
}

.cover-title {
  margin-top: 10mm;
}

.cover-title .eyebrow,
.section-title .eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.cover-title h2 {
  max-width: 118mm;
  margin: 0;
  color: var(--ink);
  font-size: 40px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 0.96;
  overflow-wrap: anywhere;
}

.cover-title h2 span,
.section-title h2 span {
  color: var(--accent);
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
}

.cover-title h2 .project-line {
  display: block;
  color: var(--ink);
  font-family: var(--sans);
  font-style: normal;
  font-weight: 500;
}

.cover-sheet.is-dense .doc-header {
  min-height: 27mm;
}

.cover-sheet.is-dense .cover-title {
  margin-top: 6mm;
}

.cover-sheet.is-dense .cover-title h2 {
  max-width: 160mm;
  font-size: 32px;
  line-height: 1;
}

.cover-sheet.is-dense .project-meta {
  gap: 7mm;
  margin-top: 8mm;
  padding-top: 5mm;
}

.cover-sheet.is-dense .meta-block {
  min-height: 14mm;
}

.cover-sheet.is-dense .meta-value {
  font-size: 13px;
}

.cover-sheet.is-dense .cover-section {
  margin-top: 6mm;
}

.cover-sheet.is-dense .pill-list {
  gap: 5px;
}

.cover-sheet.is-dense .pill-list li {
  padding: 4px 7px;
  font-size: 11px;
}

.cover-sheet.is-dense .compact-box {
  margin-top: 5mm;
  padding: 7px 9px;
}

.cover-sheet.is-dense .compact-box p:last-child {
  font-size: 11px;
}

.cover-sheet.is-dense .important-box {
  margin-top: 5mm;
  padding: 6mm;
}

.cover-sheet.is-dense .important-box p:last-child {
  font-size: 11px;
  line-height: 1.35;
}

.project-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10mm;
  margin-top: 12mm;
  padding-top: 7mm;
  border-top: 1px solid var(--line);
}

.meta-block {
  min-height: 18mm;
}

.meta-label,
.table-label {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.meta-value {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.25;
}

.cover-section {
  margin-top: 10mm;
}

.cover-section h3 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pill-list li {
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--accent-75);
  color: var(--accent-700);
  font-size: 13px;
  font-weight: 500;
}

.compact-box {
  margin-top: 8mm;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--accent-75);
}

.compact-box .meta-label {
  color: var(--accent);
}

.compact-box p:last-child {
  margin: 0;
  color: var(--accent-700);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.35;
}

.important-box {
  margin-top: 8mm;
  padding: 8mm;
  border-radius: 5px;
  background: var(--dark);
  color: #fff;
}

.important-box .meta-label {
  color: var(--accent-300);
}

.important-box p:last-child {
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12.5px;
  line-height: 1.45;
}

.section-title {
  margin-bottom: 10mm;
}

.section-title h2 {
  margin: 0;
  color: var(--ink);
  font-size: 31px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1;
}

.schedule-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.schedule-table col:nth-child(1) {
  width: 26mm;
}

.schedule-table col:nth-child(2) {
  width: auto;
}

.schedule-table col:nth-child(3) {
  width: 48mm;
}

.schedule-table th {
  padding: 0 0 7px;
  border-bottom: 1.4px solid var(--ink);
  color: var(--ink);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
}

.schedule-table td {
  height: 25mm;
  padding: 9px 10px 9px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.38;
  vertical-align: top;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.schedule-table tr.split-row td {
  height: auto;
}

.schedule-table tr.split-start td {
  padding-bottom: 4px;
  border-bottom: 0;
}

.schedule-table tr.split-continuation td {
  padding-top: 4px;
  padding-bottom: 4px;
  border-bottom: 0;
}

.schedule-table tr.split-end td {
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.schedule-table td:first-child {
  color: var(--accent);
  font-size: 13.5px;
  font-weight: 500;
}

.doc-footer {
  position: absolute;
  right: 18mm;
  bottom: 11mm;
  left: 18mm;
}

.footer-line {
  height: 1px;
  margin-bottom: 7px;
  background: var(--line);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12mm;
  padding-bottom: 0;
}

.footer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.3;
}

.footer-dot {
  display: grid;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 999px;
  background: var(--dark);
  color: #fff;
}

.footer-dot svg {
  width: 10.5px;
  height: 10.5px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.page-number {
  position: absolute;
  right: 18mm;
  bottom: 25mm;
  color: var(--muted-soft);
  font-size: 7.5px;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .editor {
    position: relative;
    height: auto;
  }
}

@media print {
  html,
  body {
    width: 210mm;
    min-height: auto;
    background: #fff;
  }

  .editor {
    display: none;
  }

  .app-shell,
  .preview-wrap,
  .preview {
    display: block;
    width: 210mm;
    padding: 0;
    margin: 0;
    background: #fff;
  }

  .sheet {
    width: 210mm;
    height: 297mm;
    margin: 0;
    box-shadow: none;
    break-after: page;
    page-break-after: always;
  }

  .sheet:last-child {
    break-after: auto;
    page-break-after: auto;
  }
}

/* ===== Hub Tab Nav ===== */

.tab-nav {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  padding: 4px;
  background: var(--app-bg);
  border-radius: 10px;
}

.tab-btn {
  flex: 1;
  min-height: 34px;
  border-radius: 7px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.tab-btn.active {
  background: var(--accent);
  color: #fff;
}

.tab-btn:not(.active):hover {
  background: var(--line);
  color: var(--ink);
}

/* ===== Info Pages (Erstkontakt, Onboarding) ===== */

.info-sheet {
  display: flex;
  flex-direction: column;
}

.info-sheet .doc-header {
  min-height: 22mm;
}

.info-page-head {
  margin-top: 6mm;
  margin-bottom: 6mm;
}

.info-page-head h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 500;
  line-height: 1.05;
  color: var(--ink);
  letter-spacing: 0;
}

.info-page-head h2 span {
  color: var(--accent);
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
}

.info-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 6mm;
}

.info-section {
  display: flex;
  flex-direction: column;
  gap: 3mm;
}

.info-section-title {
  margin: 0;
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.info-divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 0;
}

.info-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4mm 10mm;
}

.info-fields.single {
  grid-template-columns: 1fr;
}

.info-field.wide {
  grid-column: 1 / -1;
}

.info-field-label {
  margin: 0 0 2px;
  font-size: 7.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.info-field-value {
  margin: 0;
  padding-bottom: 3px;
  font-size: 11px;
  color: var(--ink);
  line-height: 1.38;
  border-bottom: 1px solid var(--line-strong);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-height: 13px;
}

.info-field-value.placeholder {
  color: var(--muted-soft);
}

.info-static p {
  margin: 0 0 3mm;
  font-size: 10px;
  color: var(--muted);
  font-style: italic;
  line-height: 1.5;
}

.info-step-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2.5mm;
}

.info-step {
  display: flex;
  gap: 3mm;
  align-items: flex-start;
}

.info-step-num {
  flex: 0 0 8mm;
  font-size: 8.5px;
  font-weight: 600;
  color: var(--accent);
  margin: 0;
  padding-top: 1px;
}

.info-step-text {
  font-size: 9px;
  color: var(--ink);
  line-height: 1.45;
  margin: 0;
}

.info-step-text strong {
  display: block;
  font-weight: 600;
  margin-bottom: 1px;
}

.info-check-group {
  display: flex;
  flex-direction: column;
  gap: 2.5mm;
}

.info-check-item {
  display: flex;
  align-items: flex-start;
  gap: 3mm;
  font-size: 10px;
  color: var(--ink);
  line-height: 1.4;
}

.info-check-box {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  margin-top: 1px;
}

.cover-subtitle {
  margin-top: 5mm;
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
  font-family: var(--serif);
  line-height: 1.4;
}

/* Onboarding access table */
.access-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
}

.access-table th {
  text-align: left;
  font-size: 7.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 8px 4px 0;
  border-bottom: 1px solid var(--ink);
}

.access-table td {
  padding: 5px 8px 5px 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 10px;
  vertical-align: top;
}

.access-table td:first-child {
  font-weight: 500;
  color: var(--muted);
  width: 28mm;
}

.access-table td.placeholder {
  color: var(--muted-soft);
}

@media print {
  .tab-nav { display: none; }
}
