:root {
  --page-bg: #eef1f3;
  --ink: #202528;
  --muted: #697176;
  --line: #d9dee1;
  --paper: #ffffff;
  --gmbh: #078276;
  --gmbh-soft: #e7f3f1;
  --immo: #be1e4a;
  --immo-soft: #f7e7ed;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

a {
  color: inherit;
}

button {
  font: inherit;
}

input {
  font: inherit;
}

.app {
  min-height: 100vh;
  padding: 24px;
}

.workspace {
  display: grid;
  grid-template-columns: 220px minmax(320px, 794px);
  gap: 24px;
  align-items: start;
  justify-content: center;
}

.controls {
  position: sticky;
  top: 24px;
  display: grid;
  gap: 18px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.control-group {
  display: grid;
  gap: 8px;
}

.label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.db-status {
  min-height: 34px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.db-status[data-state="ok"] {
  border-color: rgba(7, 130, 118, 0.32);
  background: #eef8f6;
  color: #076d64;
  font-weight: 700;
}

.db-status[data-state="error"] {
  border-color: rgba(190, 30, 74, 0.28);
  background: #fff2f5;
  color: #a0143c;
  font-weight: 700;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.segment {
  min-height: 38px;
  border: 0;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.segment + .segment {
  border-left: 1px solid var(--line);
}

.segment.active {
  background: var(--gmbh);
  color: #fff;
  font-weight: 700;
}

.sheet {
  position: relative;
  width: min(100%, 794px);
  min-height: 1123px;
  padding: 58px 64px 48px;
  background: var(--paper);
  box-shadow: 0 18px 55px rgba(22, 31, 37, 0.16);
  overflow: hidden;
}

.watermark-logo {
  display: none;
}

.letterpaper-bg {
  display: none;
}

.sheet::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 13px;
  background: var(--gmbh);
}

.letterhead {
  display: grid;
  grid-template-columns: minmax(240px, 390px) 1fr;
  gap: 28px;
  align-items: start;
}

.brand-block {
  display: grid;
  gap: 18px;
}

.company-logo {
  width: 278px;
  max-width: 100%;
  height: auto;
  display: block;
}

.brand-line {
  width: 100%;
  height: 5px;
  background: var(--gmbh);
}

.logo-claim {
  display: none;
}

.company-meta {
  display: grid;
  gap: 4px;
  justify-items: end;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-align: right;
}

.company-meta strong {
  color: var(--ink);
  font-size: 14px;
}

.address-row {
  display: grid;
  grid-template-columns: minmax(250px, 1fr) 220px;
  gap: 36px;
  margin-top: 58px;
}

.recipient,
.document-box {
  display: grid;
  align-content: start;
  gap: 4px;
  font-size: 15px;
  line-height: 1.32;
}

.sender-line {
  margin-bottom: 13px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}

.document-box {
  padding: 17px 18px;
  background: var(--gmbh-soft);
  border-left: 5px solid var(--gmbh);
}

.doc-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.document-box strong {
  margin-bottom: 8px;
  font-size: 19px;
}

.tax-line {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid rgba(0, 0, 0, 0.12);
  color: var(--muted);
  font-size: 11px;
}

.title-row {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  align-items: end;
  margin-top: 46px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--ink);
}

h1 {
  margin: 0 0 10px;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0;
}

p {
  margin: 0;
}

.status-mark {
  display: none;
  min-width: 82px;
  padding: 8px 12px;
  color: var(--gmbh);
  border: 1px solid currentColor;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
}

.positions {
  width: 100%;
  margin-top: 28px;
  border-collapse: collapse;
  font-size: 14px;
}

.positions th {
  padding: 10px 8px;
  color: var(--muted);
  border-bottom: 1px solid var(--ink);
  font-size: 12px;
  text-align: left;
  text-transform: uppercase;
}

.positions td {
  padding: 13px 8px;
  border-bottom: 1px solid var(--line);
}

.positions th:nth-child(5),
.positions td:nth-child(5) {
  text-align: right;
}

.positions th:nth-child(2),
.positions td:nth-child(2),
.positions th:nth-child(3),
.positions td:nth-child(3),
.positions th:nth-child(4),
.positions td:nth-child(4) {
  text-align: left;
}

.totals {
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
}

.totals dl {
  width: 310px;
  margin: 0;
}

.totals div {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.totals dt,
.totals dd {
  margin: 0;
}

.totals dd {
  text-align: right;
}

.grand-total {
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
}

.payment-note {
  margin-top: 34px;
  padding: 15px 17px;
  background: #f6f8f8;
  border-left: 5px solid var(--gmbh);
  color: #3b4246;
  font-size: 13px;
  line-height: 1.45;
}

.footer {
  position: absolute;
  right: 64px;
  bottom: 34px;
  left: 64px;
  display: grid;
  grid-template-columns: 1.3fr 1.15fr 0.9fr;
  gap: 22px;
  padding-top: 17px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.footer div {
  display: grid;
  gap: 2px;
  align-content: start;
}

.footer strong {
  color: var(--ink);
}

.company-gmbh::before {
  inset: 0 0 auto 0;
  width: auto;
  height: 10px;
}

.company-gmbh .letterhead {
  grid-template-columns: 1fr minmax(300px, 360px);
  min-height: 96px;
  align-items: start;
  padding-bottom: 14px;
  border-bottom: 2px solid rgba(7, 130, 118, 0.72);
}

.company-gmbh .brand-block {
  grid-column: 2;
  justify-items: end;
}

.company-gmbh .company-logo {
  width: 340px;
}

.company-gmbh .brand-line {
  display: none;
}

.company-gmbh .company-meta {
  display: none;
}

.company-gmbh .address-row {
  margin-top: 34px;
}

.company-gmbh .recipient,
.company-gmbh .sender-line {
  font-family: "Courier New", Courier, monospace;
}

.company-gmbh .document-box {
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
  padding: 0 0 13px;
  background: transparent;
  border-left: 0;
  border-bottom: 1px solid var(--line);
  font-family: "Courier New", Courier, monospace;
  font-size: 12px;
}

.company-gmbh .document-box .doc-label,
.company-gmbh .document-box strong {
  grid-column: 1 / -1;
}

.company-gmbh .document-box strong {
  margin-bottom: 4px;
  font-family: inherit;
  font-size: 24px;
}

.company-gmbh .tax-line {
  display: none;
}

.company-gmbh .title-row {
  display: block;
  margin-top: 34px;
  padding: 14px 18px;
  background: #f5f8f7;
  border-bottom: 0;
  border-left: 4px solid var(--gmbh);
  font-family: "Courier New", Courier, monospace;
}

.company-gmbh .title-row h1 {
  margin-bottom: 6px;
  font-family: inherit;
  font-size: 30px;
}

.company-gmbh .positions {
  margin-top: 24px;
  border-collapse: separate;
  border-spacing: 0 6px;
  font-family: "Courier New", Courier, monospace;
  font-size: 13px;
}

.company-gmbh .positions thead th {
  border-bottom: 0;
  color: #365a57;
  font-size: 11px;
}

.company-gmbh .positions tbody {
  counter-reset: gmbh-position;
}

.company-gmbh .positions tbody tr {
  counter-increment: gmbh-position;
}

.company-gmbh .positions td {
  padding-top: 12px;
  padding-bottom: 12px;
  background: #f7f9f9;
  border-bottom: 0;
  border-top: 1px solid #e1e6e5;
}

.company-gmbh .positions td:first-child {
  border-left: 3px solid var(--gmbh);
}

.company-gmbh .positions td:first-child::before {
  content: counter(gmbh-position, decimal-leading-zero);
  display: inline-block;
  min-width: 22px;
  margin-right: 10px;
  color: var(--gmbh);
  font-size: 11px;
  font-weight: 700;
}

.company-gmbh .payment-note {
  background: #f8faf9;
  border-left-color: var(--gmbh);
  border-left-width: 3px;
  font-family: "Courier New", Courier, monospace;
  font-size: 12px;
}

.company-gmbh .totals dl {
  width: 330px;
  padding: 10px 14px 12px;
  background: #fbfcfc;
  border-top: 1.5px solid rgba(7, 130, 118, 0.7);
  font-family: "Courier New", Courier, monospace;
}

.company-gmbh .grand-total {
  color: var(--gmbh);
}

.company-gmbh .footer {
  bottom: 16px;
  grid-template-columns: 1.35fr 1fr 1.25fr;
  font-family: "Courier New", Courier, monospace;
  font-size: 9.5px;
}

.company-gmbh .footer div:nth-child(3) {
  margin-left: 24px;
  justify-items: start;
  text-align: left;
}

.gmbh-letterhead-concept .company-gmbh {
  padding-top: 46px;
}

.gmbh-letterhead-concept .company-gmbh::before {
  height: 14px;
}

.gmbh-letterhead-concept .company-gmbh::after {
  content: "";
  position: absolute;
  top: 14px;
  right: 0;
  left: 0;
  height: 92px;
  background:
    linear-gradient(90deg, rgba(7, 130, 118, 0.1), rgba(7, 130, 118, 0.02) 52%, transparent),
    linear-gradient(180deg, #f6faf9, rgba(255, 255, 255, 0));
  z-index: 0;
}

.gmbh-letterhead-concept .company-gmbh .letterhead,
.gmbh-letterhead-concept .company-gmbh .address-row,
.gmbh-letterhead-concept .company-gmbh .title-row,
.gmbh-letterhead-concept .company-gmbh .positions,
.gmbh-letterhead-concept .company-gmbh .totals,
.gmbh-letterhead-concept .company-gmbh .payment-note,
.gmbh-letterhead-concept .company-gmbh .footer {
  position: relative;
  z-index: 1;
}

.gmbh-letterhead-concept .company-gmbh .letterhead {
  grid-template-columns: 360px 1fr;
  min-height: 136px;
  padding: 24px 0 16px;
  border-bottom: 0;
}

.gmbh-letterhead-concept .company-gmbh .company-logo {
  width: 340px;
}

.gmbh-letterhead-concept .company-gmbh .brand-block {
  align-content: start;
}

.gmbh-letterhead-concept .company-gmbh .company-meta {
  display: grid;
  justify-items: end;
  align-self: start;
  padding-top: 8px;
  color: #4f5e60;
  font-size: 11px;
  line-height: 1.35;
  text-align: right;
}

.gmbh-letterhead-concept .company-gmbh .company-meta strong {
  display: none;
}

.gmbh-letterhead-concept .company-gmbh .address-row {
  margin-top: 32px;
}

.gmbh-letterhead-concept .company-gmbh .document-box {
  padding: 14px 16px;
  background: #f5f8f7;
  border: 1px solid rgba(7, 130, 118, 0.18);
  border-top: 4px solid rgba(7, 130, 118, 0.72);
}

.gmbh-letterhead-concept .company-gmbh .title-row {
  margin-top: 38px;
  background: transparent;
  border-left: 0;
  border-bottom: 2px solid rgba(7, 130, 118, 0.72);
  padding: 0 0 14px;
}

.gmbh-letterhead-concept .company-gmbh .positions th {
  padding-bottom: 8px;
  border-bottom: 1px solid #bac8c6;
}

.gmbh-letterhead-concept .company-gmbh .positions td {
  background: #fbfcfc;
}

.gmbh-letterhead-concept .company-gmbh .positions td:first-child {
  border-left-color: rgba(7, 130, 118, 0.72);
}

.gmbh-letterhead-concept .company-gmbh .payment-note {
  background: #fff;
  border: 1px solid #dbe4e2;
  border-left: 3px solid rgba(7, 130, 118, 0.72);
}

.gmbh-letterhead-concept .company-gmbh .footer {
  border-top: 2px solid rgba(7, 130, 118, 0.55);
}

.company-immo .letterpaper-bg {
  display: none;
}

.company-immo .watermark-logo {
  display: none;
}

.company-immo::before {
  inset: 0 auto 0 0;
  display: block;
  width: 8px;
  background: var(--immo);
}

.company-immo .letterhead {
  display: grid;
  grid-template-columns: 1fr 360px;
  min-height: 118px;
  align-items: start;
}

.company-immo .brand-block {
  grid-column: 2;
  justify-items: end;
  gap: 8px;
}

.company-immo .company-logo {
  width: 360px;
}

.company-immo .brand-line {
  display: none;
}

.company-immo .logo-claim {
  display: none;
}

.company-immo .company-meta {
  display: none;
}

.company-immo .address-row {
  margin-top: 48px;
}

.company-immo .document-box {
  background: var(--immo-soft);
  border-left-color: var(--immo);
}

.company-immo .status-mark {
  color: var(--immo);
}

.company-immo .payment-note {
  background: #faf8f9;
  border-left-color: var(--immo);
}

.company-immo .footer {
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr 1.35fr;
  gap: 22px;
  padding-top: 13px;
  border-top: 1.5px solid rgba(190, 30, 74, 0.62);
  color: #5f6365;
  font-size: 9.4px;
  line-height: 1.35;
  right: 64px;
  left: 64px;
  bottom: 30px;
  z-index: 1;
}

.company-immo .footer strong {
  margin-bottom: 2px;
  color: #45484a;
}

body[data-company="immo"] .segment.active {
  background: var(--immo);
}

.portal-body {
  background:
    linear-gradient(90deg, rgba(190, 30, 74, 0.08), transparent 36%),
    linear-gradient(270deg, rgba(7, 130, 118, 0.08), transparent 38%),
    #eef1f3;
}

.portal-home {
  min-height: 100vh;
  padding: 42px 28px;
  display: grid;
  place-items: center;
}

.auth-gate {
  align-content: center;
}

.auth-card {
  width: min(100%, 520px);
  display: grid;
  gap: 18px;
}

.auth-card h1 {
  font-size: 34px;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-message {
  min-height: 34px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.auth-message[data-state="error"] {
  border-color: rgba(190, 30, 74, 0.3);
  background: #fff4f6;
  color: #a0143c;
}

.portal-hero {
  width: min(1120px, 100%);
  display: grid;
  gap: 34px;
}

.portal-title {
  display: grid;
  gap: 12px;
}

.portal-kicker {
  color: var(--company-accent, var(--muted));
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.portal-title h1,
.portal-topbar h2 {
  margin: 0;
  letter-spacing: 0;
}

.portal-title h1 {
  font-size: 42px;
}

.portal-title p {
  max-width: 640px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.45;
}

.company-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.company-choice {
  min-height: 290px;
  padding: 28px;
  display: grid;
  align-content: space-between;
  gap: 24px;
  text-decoration: none;
  background: #fff;
  border: 1px solid color-mix(in srgb, var(--company-accent), white 72%);
  border-top: 8px solid var(--company-accent);
  border-radius: 8px;
  box-shadow: 0 20px 55px rgba(25, 35, 42, 0.12);
}

.company-choice:hover {
  background: linear-gradient(180deg, #fff, var(--company-soft));
}

.company-choice img {
  width: min(430px, 100%);
  max-height: 118px;
  object-fit: contain;
  object-position: left center;
}

.company-choice-label {
  color: var(--ink);
  font-size: 24px;
  font-weight: 800;
}

.company-choice-claim {
  color: var(--muted);
  font-size: 15px;
}

.portal-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  background: #f4f6f7;
}

.portal-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow: auto;
  background: #fff;
  border-right: 1px solid var(--line);
  box-shadow: 12px 0 32px rgba(34, 45, 52, 0.05);
}

.sidebar-brand {
  display: grid;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}

.sidebar-brand img {
  width: 190px;
  max-height: 72px;
  object-fit: contain;
  object-position: left center;
}

.portal-gmbh .sidebar-brand img {
  width: 210px;
}

.sidebar-brand span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.portal-nav {
  display: grid;
  gap: 8px;
}

.portal-nav-link,
.portal-subnav a,
.company-switch,
.portal-action {
  text-decoration: none;
}

.portal-nav-link {
  padding: 12px 13px;
  border-left: 4px solid transparent;
  color: #3a4348;
  font-size: 15px;
  font-weight: 800;
}

.portal-nav-link.active {
  background: var(--company-soft);
  border-left-color: var(--company-accent);
  color: var(--ink);
}

.portal-subnav {
  margin: -4px 0 8px 16px;
  display: grid;
  gap: 3px;
  border-left: 1px solid color-mix(in srgb, var(--company-accent), white 62%);
}

.portal-subnav a {
  padding: 8px 10px 8px 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
}

.portal-subnav a.active {
  color: var(--company-accent);
  font-weight: 800;
}

.company-switch {
  margin-top: auto;
  padding: 11px 13px;
  color: var(--company-accent);
  border: 1px solid color-mix(in srgb, var(--company-accent), white 64%);
  border-radius: 7px;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.logout-button {
  min-height: 36px;
  width: 100%;
  margin-top: auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  text-align: left;
}

.logout-button + .company-switch {
  margin-top: 0;
}

.portal-workspace {
  min-width: 0;
  padding: 28px;
}

.portal-topbar {
  min-height: 118px;
  margin-bottom: 24px;
  padding: 22px 26px;
  display: flex;
  justify-content: space-between;
  gap: 22px;
  align-items: center;
  background: #fff;
  border-top: 6px solid var(--company-accent);
  border-radius: 8px;
  box-shadow: 0 14px 36px rgba(28, 38, 44, 0.08);
}

.portal-topbar img {
  width: 260px;
  max-height: 82px;
  object-fit: contain;
  object-position: right center;
}

.portal-gmbh .portal-topbar img {
  width: 300px;
}

.portal-topbar h2 {
  margin-top: 8px;
  font-size: 29px;
}

.portal-panel-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.portal-card {
  padding: 22px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(28, 38, 44, 0.07);
}

.portal-card h3,
.portal-card h4 {
  margin: 0;
  letter-spacing: 0;
}

.portal-card h3 {
  font-size: 22px;
}

.portal-card h4 {
  margin-top: 22px;
  font-size: 16px;
}

.section-heading {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.section-heading p,
.portal-stack p,
.document-row span,
.document-row small,
.empty-state {
  color: var(--muted);
}

.portal-stack {
  display: grid;
  gap: 10px;
}

.portal-action {
  display: block;
  padding: 11px 12px;
  background: var(--company-soft);
  border-left: 4px solid var(--company-accent);
  color: var(--ink);
  font-weight: 800;
}

.portal-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 15px;
}

.document-entry-form {
  align-items: start;
}

.form-actions,
.save-status {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.save-status {
  min-height: 34px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.save-status:empty {
  display: none;
}

.save-status[data-state="ok"] {
  border-color: color-mix(in srgb, var(--company-accent), transparent 65%);
  background: var(--company-soft);
  color: var(--company-accent);
}

.save-status[data-state="warning"] {
  border-color: rgba(190, 30, 74, 0.3);
  background: #fff4f6;
  color: #a0143c;
}

.document-main-fields {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.field input {
  min-height: 42px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 400;
  text-transform: none;
}

.field-hint {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  text-transform: none;
}

.customer-drop-field.drag-over input {
  border-color: var(--company-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--company-accent), transparent 82%);
}

.line-item-preview {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
  padding: 16px;
  background: #f7f9f9;
  border-left: 4px solid var(--company-accent);
}

.stammdaten-picker,
.position-builder {
  display: grid;
  gap: 12px;
}

.stammdaten-picker {
  grid-column: 2;
  grid-row: 1 / span 2;
  padding: 14px;
  background: #f7f9f9;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.picker-list,
.stammdaten-reference {
  display: grid;
  gap: 8px;
}

.picker-chip,
.material-chip {
  width: 100%;
  padding: 10px 11px;
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: grab;
  text-align: left;
}

.material-chip {
  cursor: pointer;
}

.picker-chip:hover,
.material-chip:hover {
  border-color: var(--company-accent);
}

.item-number {
  color: var(--company-accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.item-name {
  font-weight: 800;
}

.picker-chip small,
.material-chip small,
.master-row-main small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.position-builder {
  grid-column: 1;
  grid-row: 2;
  padding: 16px;
  background: #fbfcfc;
  border: 1px solid var(--line);
  border-left: 4px solid var(--company-accent);
  border-radius: 8px;
}

.position-builder-head,
.position-input-grid {
  display: grid;
  gap: 12px;
}

.position-builder-head {
  grid-template-columns: 1fr auto;
  align-items: start;
}

.doc-type-pill {
  padding: 6px 9px;
  background: var(--company-soft);
  color: var(--company-accent);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.position-input-grid {
  grid-template-columns: minmax(260px, 1fr) 110px auto;
  align-items: end;
}

.material-status {
  min-height: 34px;
  padding: 9px 11px;
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
}

.material-status[data-state="ok"] {
  border-color: rgba(7, 130, 118, 0.34);
  background: #eef8f6;
  color: #076d64;
}

.material-status[data-state="missing"] {
  border-color: rgba(190, 30, 74, 0.28);
  background: #fff4f7;
  color: #9d1742;
}

.inline-action {
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid var(--company-accent);
  border-radius: 5px;
  background: #fff;
  color: var(--company-accent);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

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

.entry-positions-table th {
  padding: 9px 8px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  text-align: left;
  text-transform: uppercase;
}

.entry-positions-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}

.entry-positions-table td:first-child {
  color: var(--company-accent);
  font-weight: 900;
}

.vat-select {
  min-height: 32px;
  width: 82px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

.line-total {
  font-weight: 800;
  text-align: right;
}

.tax-summary {
  display: grid;
  justify-self: end;
  min-width: min(100%, 420px);
  margin-top: 12px;
  border-top: 1px solid color-mix(in srgb, var(--company-accent), transparent 65%);
}

.tax-summary-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  color: #343d42;
  font-size: 13px;
}

.tax-summary-row strong {
  text-align: right;
  white-space: nowrap;
}

.tax-summary-total {
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
}

.stammdaten-reference {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.document-list,
.master-list {
  display: grid;
  gap: 10px;
}

.document-workbench {
  display: grid;
  gap: 16px;
}

.document-search {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 14px;
  align-items: end;
  padding: 14px;
  background: #f7f9f9;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.document-search-input {
  min-height: 42px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: 14px;
}

.document-row,
.master-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.document-record {
  align-items: flex-start;
}

.document-row div {
  display: grid;
  gap: 3px;
}

.document-record-title {
  display: flex !important;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.status-badge {
  padding: 3px 7px;
  background: #eef1f3;
  color: #536066;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.status-entwurf {
  background: var(--company-soft);
  color: var(--company-accent);
}

.status-gebucht,
.status-versendet {
  background: #eaf4ef;
  color: #216747;
}

.document-actions {
  min-width: 430px;
  display: flex !important;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.master-row-main {
  display: grid;
  gap: 3px;
}

.master-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.master-create {
  margin-top: 12px;
}

.master-edit-form {
  display: grid;
  width: 100%;
  gap: 14px;
  padding: 14px;
  background: #f9fbfb;
  border: 1px solid var(--line);
  border-left: 4px solid var(--company-accent);
  border-radius: 8px;
}

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

.portal-button {
  min-height: 38px;
  padding: 9px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--company-accent);
  border-radius: 6px;
  background: var(--company-accent);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.portal-button.secondary {
  background: #fff;
  color: var(--company-accent);
}

.portal-button.danger {
  border-color: #9f1d2f;
  background: #fff;
  color: #9f1d2f;
}

.portal-button.danger:hover {
  background: #fff1f3;
}

.portal-button:disabled {
  border-color: #d7dde0;
  background: #eef1f3;
  color: #8a969c;
  cursor: not-allowed;
}

.portal-button:disabled:hover {
  background: #eef1f3;
}

.document-detail {
  display: grid;
  gap: 18px;
}

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

.detail-item {
  display: grid;
  gap: 5px;
  padding: 13px;
  background: #f7f9f9;
  border-left: 4px solid var(--company-accent);
}

.detail-item span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.detail-position-table {
  margin-top: 2px;
}

.workflow-note {
  padding: 14px 16px;
  background: var(--company-soft);
  border-left: 4px solid var(--company-accent);
  color: #343d42;
  line-height: 1.45;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.empty-state {
  padding: 16px;
  background: #f7f9f9;
  border: 1px dashed var(--line);
  border-radius: 7px;
}

@media (max-width: 920px) {
  .company-choice-grid,
  .portal-shell,
  .portal-panel-grid,
  .portal-form,
  .document-main-fields,
  .position-input-grid,
  .stammdaten-reference,
  .document-search,
  .document-detail-grid {
    grid-template-columns: 1fr;
  }

  .document-actions {
    min-width: 0;
    justify-content: flex-start;
  }

  .portal-sidebar {
    position: relative;
    height: auto;
  }

  .portal-topbar {
    align-items: flex-start;
    flex-direction: column-reverse;
  }

  .portal-topbar img {
    object-position: left center;
  }

  .document-main-fields,
  .stammdaten-picker,
  .position-builder {
    grid-column: auto;
    grid-row: auto;
  }
}

.blank-letter .document-box,
.blank-letter .title-row,
.blank-letter .positions,
.blank-letter .totals,
.blank-letter .payment-note {
  display: none;
}

.blank-letter .address-row {
  display: block;
}

.blank-letter .recipient strong,
.blank-letter .recipient span:not(.sender-line) {
  display: none;
}

.blank-letter .sender-line {
  display: block;
  width: 390px;
}

@media (max-width: 900px) {
  .app {
    padding: 14px;
  }

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

  .controls {
    position: static;
    grid-template-columns: 1fr 1fr;
  }

  .sheet {
    width: 794px;
    min-height: 1123px;
    padding: 58px 64px 48px;
  }

  .letterhead {
    grid-template-columns: minmax(240px, 390px) 1fr;
  }

  .address-row {
    grid-template-columns: minmax(250px, 1fr) 220px;
  }

  .company-meta {
    justify-items: end;
    text-align: right;
  }

  .company-gmbh .letterhead {
    grid-template-columns: 1fr;
  }

  .company-immo .letterhead {
    grid-template-columns: 1fr minmax(240px, 330px);
  }

  .company-immo .brand-block {
    justify-items: end;
  }

  .footer {
    right: 64px;
    left: 64px;
    grid-template-columns: 1.3fr 1.15fr 0.9fr;
  }
}

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

  body {
    background: #fff;
  }

  .app {
    padding: 0;
  }

  .controls {
    display: none;
  }

  .workspace {
    display: block;
  }

  .sheet {
    width: 210mm;
    height: 297mm;
    min-height: 297mm;
    box-shadow: none;
  }
}

.letterpaper-template {
  background: var(--page-bg);
}

.template-pages {
  display: grid;
  gap: 18px;
  justify-content: center;
  padding: 18px 0;
}

.letterpaper-template .sheet {
  width: 794px;
  min-height: 1123px;
  margin: 0;
}

.letterpaper-template .template-first-page .letterhead,
.letterpaper-template .template-first-page .address-row {
  position: relative;
  z-index: 1;
}

.template-continuation-page {
  display: block;
}

.template-continuation-head {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 24px;
  align-items: end;
}

.template-page-meta,
.template-page-number {
  color: var(--muted);
  font-size: 12px;
}

.template-continuation-logo {
  display: block;
  max-width: 100%;
  height: auto;
}

.company-gmbh .template-continuation-head {
  padding: 28px 0 14px;
  border-bottom: 2px solid rgba(7, 130, 118, 0.72);
  font-family: "Courier New", Courier, monospace;
}

.company-gmbh .template-continuation-logo {
  width: 190px;
}

.company-immo.template-continuation-page .template-continuation-head {
  grid-template-columns: 1fr auto 300px;
  padding-top: 70px;
}

.company-immo .template-continuation-logo {
  width: 300px;
  justify-self: end;
}

.company-immo .template-page-meta,
.company-immo .template-page-number {
  color: #6f686b;
}

@media print {
  .letterpaper-template {
    background: #fff;
  }

  .template-pages {
    display: block;
    padding: 0;
  }

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

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

.contract-template {
  background: var(--page-bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

.contract-pages {
  display: grid;
  gap: 18px;
  justify-content: center;
  padding: 18px 0;
}

.contract-sheet {
  position: relative;
  width: 794px;
  min-height: 1123px;
  padding: 52px 64px 112px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 18px 55px rgba(22, 31, 37, 0.16);
}

.contract-sheet::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 8px;
  background: var(--immo);
  z-index: 0;
}

.contract-watermark {
  position: absolute;
  top: 405px;
  left: 50%;
  width: 430px;
  max-width: 58%;
  opacity: 0.055;
  transform: translateX(-50%);
  z-index: 0;
}

.contract-first-head,
.contract-repeat-head,
.contract-sender,
.contract-intro,
.contract-party-grid,
.contract-content,
.contract-footer {
  position: relative;
  z-index: 1;
}

.contract-first-head,
.contract-repeat-head {
  display: grid;
  grid-template-columns: 1fr 330px;
  gap: 22px;
  align-items: end;
}

.contract-first-head {
  min-height: 114px;
  justify-content: end;
}

.contract-repeat-head {
  min-height: 92px;
  padding-top: 20px;
  border-bottom: 1.5px solid rgba(190, 30, 74, 0.62);
}

.contract-logo {
  grid-column: 2;
  width: 330px;
  justify-self: end;
}

.contract-logo-small {
  width: 245px;
  justify-self: end;
}

.contract-running,
.contract-page-number {
  color: #6f686b;
  font-size: 10px;
  line-height: 1.35;
}

.contract-page-number {
  white-space: nowrap;
}

.contract-sender {
  width: 390px;
  margin-top: 26px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 9px;
}

.contract-intro {
  margin-top: 30px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 20px;
  align-items: end;
}

.contract-eyebrow {
  grid-column: 1 / -1;
  color: var(--immo);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.contract-intro h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.05;
}

.contract-badge {
  align-self: center;
  padding: 6px 10px;
  border: 1px solid rgba(190, 30, 74, 0.55);
  color: var(--immo);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.contract-badge:empty {
  display: none;
}

.contract-intro p {
  grid-column: 1 / -1;
  max-width: 620px;
  color: #555d61;
  font-size: 12px;
  line-height: 1.45;
}

.contract-party-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 18px;
}

.contract-party {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  background: #faf8f9;
  border-left: 3px solid var(--immo);
}

.contract-party span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.contract-party strong {
  font-size: 14px;
}

.contract-content {
  display: grid;
  gap: 13px;
  margin-top: 20px;
}

.contract-repeat-head + .contract-content {
  margin-top: 22px;
}

.contract-flow-content {
  display: block;
  margin-top: 22px;
}

.contract-block {
  break-inside: avoid;
  page-break-inside: avoid;
  padding: 13px 15px 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #e2e5e6;
  border-left: 4px solid rgba(190, 30, 74, 0.72);
}

.contract-block h2 {
  margin: 0 0 10px;
  color: #34383b;
  font-size: 15px;
  line-height: 1.2;
}

.contract-flow-block {
  break-inside: avoid;
  page-break-inside: avoid;
  margin: 0 0 18px;
  padding: 0 0 14px;
  border-bottom: 1px solid #e4e8e9;
}

.contract-flow-block h2 {
  margin: 0 0 8px;
  color: #34383b;
  font-size: 16px;
  line-height: 1.25;
}

.contract-flow-block p {
  margin: 0 0 7px;
  color: #30363a;
  font-size: 12.4px;
  line-height: 1.48;
}

.contract-flow-alert-block {
  padding: 12px 14px 14px;
  background: #fff8fa;
  border: 1px solid rgba(190, 30, 74, 0.28);
  border-left: 4px solid var(--immo);
}

.contract-editable-text {
  padding: 0 3px 1px;
  border-bottom: 1px solid rgba(190, 30, 74, 0.35);
  background: rgba(190, 30, 74, 0.045);
}

.contract-flow-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  margin-top: 18px;
}

.contract-alert-block {
  background: #fff8fa;
  border-color: rgba(190, 30, 74, 0.28);
  border-left-color: var(--immo);
}

.contract-alert {
  margin: 0 0 11px;
  color: #8a1739;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.contract-fields {
  display: grid;
  gap: 7px;
}

.contract-field {
  display: grid;
  grid-template-columns: 165px 1fr;
  gap: 12px;
  align-items: baseline;
  min-height: 20px;
  padding-bottom: 5px;
  border-bottom: 1px solid #edf0f1;
  font-size: 12px;
}

.contract-field > span:first-child {
  color: #687176;
  font-weight: 700;
}

.contract-field strong {
  color: #242a2d;
  font-weight: 500;
}

.contract-field.money strong {
  font-weight: 700;
}

.contract-field.signature {
  grid-template-columns: 1fr;
  gap: 5px;
  align-items: end;
  min-height: 54px;
  border-bottom: 0;
}

.signature-line {
  display: block;
  width: 210px;
  border-bottom: 1px solid #444;
}

.contract-footer {
  position: absolute;
  right: 64px;
  bottom: 30px;
  left: 64px;
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr 1.35fr;
  gap: 22px;
  padding-top: 13px;
  border-top: 1.5px solid rgba(190, 30, 74, 0.62);
  color: #5f6365;
  font-size: 9.2px;
  line-height: 1.35;
}

.contract-footer-page {
  position: absolute;
  right: 0;
  bottom: -17px;
  color: #8a8f92;
  font-size: 9px;
  text-align: right;
}

.real-contract-sheet {
  padding-bottom: 118px;
}

.real-contract-intro {
  margin-top: 24px;
}

.real-contract-payment-alert {
  margin: 18px 0 12px;
  padding: 12px 15px;
  background: rgba(190, 30, 74, 0.055);
  border-left: 4px solid var(--immo);
  color: #30373a;
  font-size: 13px;
  line-height: 1.45;
}

.real-contract-payment-alert strong {
  display: block;
  margin-bottom: 4px;
  color: var(--immo);
  font-size: 12px;
  text-transform: uppercase;
}

.real-contract-content {
  position: relative;
  z-index: 1;
  margin-top: 20px;
}

.first-real-content {
  margin-top: 18px;
}

.real-contract-block {
  break-inside: avoid;
  page-break-inside: avoid;
  margin: 0 0 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(217, 222, 225, 0.82);
}

.real-contract-block h2 {
  margin: 0 0 6px;
  color: #2f3437;
  font-size: 15px;
  line-height: 1.25;
}

.real-contract-block p {
  margin: 0;
  color: #282e31;
  font-size: 11.1px;
  line-height: 1.42;
  text-align: justify;
}

.real-contract-template .contract-editable-text {
  padding: 0 2px 1px;
  border-bottom: 1px solid rgba(190, 30, 74, 0.36);
  background: rgba(190, 30, 74, 0.04);
}

.real-contract-review-mode {
  padding-top: 76px;
}

.real-contract-review-mode .contract-editable-text {
  padding: 0;
  border-bottom: 0;
  background: transparent;
}

.real-contract-review-mode .real-contract-block p[contenteditable="true"] {
  min-height: 20px;
  padding: 0;
  outline: 0;
  border-radius: 0;
}

.real-contract-review-mode .contract-party strong[contenteditable="true"] {
  padding: 0;
  outline: 0;
  border-radius: 0;
}

.real-contract-review-mode .real-contract-block p[contenteditable="true"]:hover,
.real-contract-review-mode .real-contract-block p[contenteditable="true"]:focus,
.real-contract-review-mode .contract-party strong[contenteditable="true"]:hover,
.real-contract-review-mode .contract-party strong[contenteditable="true"]:focus {
  background: transparent;
}

.review-placeholder {
  padding: 0 3px;
  background: #ffe66d;
  color: #111;
  font-weight: 700;
}

.real-staffel-block {
  display: grid;
  gap: 8px;
}

.staffel-subtitle {
  color: var(--immo);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.real-staffel-block .staffel-intro,
.real-staffel-block .staffel-summary,
.real-staffel-block .staffel-note {
  margin: 0;
}

.staffel-inline-value,
.staffel-input {
  font-weight: 700;
}

.real-contract-review-mode .staffel-inline-value,
.real-contract-review-mode .staffel-input {
  padding: 0 2px;
  background: rgba(255, 230, 109, 0.42);
  outline: 0;
}

.staffel-table {
  width: 100%;
  margin-top: 4px;
  border-collapse: collapse;
  font-size: 10.5px;
}

.staffel-table th,
.staffel-table td {
  padding: 5px 6px;
  border-bottom: 1px solid rgba(90, 95, 99, 0.28);
  text-align: left;
  vertical-align: top;
}

.staffel-table th {
  color: #34383b;
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
}

.staffel-table td:nth-child(n + 2) {
  text-align: left;
  white-space: nowrap;
}

.staffel-note {
  padding-top: 2px;
}

.contract-signature-block {
  margin-top: 18px;
  border-bottom: 0;
}

.signature-hint {
  color: #4f575b;
  text-align: left;
}

.signature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
  margin-top: 14px;
}

.signature-field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.signature-date-line span,
.signature-print-line {
  display: block;
  height: 28px;
  border-bottom: 1px solid rgba(47, 52, 55, 0.72);
}

.signature-date-line small,
.signature-meta span {
  display: block;
  margin-top: 4px;
  color: #5b6266;
  font-size: 9.5px;
}

.signature-canvas-wrap {
  height: 76px;
  border: 1px solid rgba(190, 30, 74, 0.28);
  background: rgba(255, 255, 255, 0.72);
  pointer-events: none;
}

.signature-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.signature-print-line {
  display: none;
}

.signature-meta strong {
  display: block;
  color: #2f3437;
  font-size: 10.5px;
  text-transform: uppercase;
}

.signature-open,
.signature-clear {
  justify-self: start;
  padding: 5px 8px;
  border: 1px solid rgba(190, 30, 74, 0.24);
  border-radius: 4px;
  background: #fff;
  color: var(--immo);
  font: inherit;
  font-size: 10px;
}

.signature-open {
  background: rgba(190, 30, 74, 0.08);
  color: #97183a;
  font-weight: 800;
}

.signature-open:hover,
.signature-clear:hover {
  border-color: rgba(190, 30, 74, 0.54);
}

.signature-dialog-open {
  overflow: hidden;
}

.signature-dialog-backdrop {
  position: fixed;
  z-index: 90;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(20, 24, 27, 0.48);
}

.signature-dialog {
  width: min(940px, 100%);
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 74px rgba(0, 0, 0, 0.28);
}

.signature-dialog-head {
  display: grid;
  gap: 4px;
}

.signature-dialog-head strong {
  color: #2f3437;
  font-size: 17px;
}

.signature-dialog-head span {
  color: #697176;
  font-size: 13px;
}

.signature-dialog-canvas-wrap {
  height: min(280px, 44vh);
  border: 1px solid rgba(190, 30, 74, 0.28);
  background: #fff;
}

.signature-dialog-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.signature-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.signature-dialog-actions button {
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid rgba(190, 30, 74, 0.32);
  border-radius: 6px;
  background: #fff;
  color: var(--immo);
  cursor: pointer;
  font-weight: 800;
}

.signature-dialog-actions button:last-child {
  background: var(--immo);
  color: #fff;
}

.contract-draft-status {
  display: block;
  padding: 8px 10px;
  border-left: 3px solid rgba(190, 30, 74, 0.64);
  background: rgba(190, 30, 74, 0.06);
  color: #4f575b;
  font-size: 11px;
  line-height: 1.35;
}

.contract-draft-status[data-state="ok"] {
  border-left-color: #078276;
  background: rgba(7, 130, 118, 0.08);
  color: #1d5c55;
}

.contract-draft-status[data-state="error"] {
  border-left-color: #b21d3d;
  background: rgba(178, 29, 61, 0.08);
  color: #8f1730;
}

.immo-form-sheet {
  min-height: 1123px;
  padding-bottom: 118px;
}

.immo-form-sheet .contract-first-head {
  min-height: 100px;
}

.immo-form-sheet .contract-sender {
  margin-top: 18px;
}

.immo-form-intro {
  margin-top: 20px;
}

.form-repeat-sender {
  display: none;
}

.form-repeat-intro {
  margin-top: 18px;
}

.form-repeat-intro .contract-eyebrow,
.form-repeat-intro p {
  display: none;
}

.form-repeat-intro h1 {
  font-size: 22px;
}

.immo-form-intro p {
  margin: 0;
}

.immo-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.immo-form-actions button {
  border: 1px solid rgba(190, 30, 74, 0.42);
  border-radius: 4px;
  background: #fff;
  color: #9f173c;
  font: inherit;
  font-weight: 800;
  padding: 7px 10px;
}

.immo-form-content {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.immo-form-section {
  position: relative;
  z-index: 1;
  break-inside: avoid;
  page-break-inside: avoid;
  padding: 10px 0 12px;
  border-bottom: 1px solid rgba(217, 222, 225, 0.82);
}

.immo-form-section h2 {
  margin: 0 0 8px;
  color: #2f3437;
  font-size: 14px;
  line-height: 1.25;
  text-transform: uppercase;
}

.immo-form-section p {
  margin: 0;
  color: #2b3134;
  font-size: 11.2px;
  line-height: 1.45;
}

.immo-field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
}

.immo-field {
  display: grid;
  grid-template-columns: 145px 1fr;
  gap: 8px;
  min-height: 24px;
  align-items: end;
  font-size: 10.8px;
}

.immo-field span {
  color: #697176;
  font-weight: 700;
}

.immo-field strong,
.immo-field input,
.immo-field textarea {
  display: block;
  min-height: 18px;
  border-bottom: 1px solid rgba(90, 95, 99, 0.42);
}

.immo-field input,
.immo-field textarea,
.immo-form-table input,
.immo-line-area input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid rgba(90, 95, 99, 0.42);
  border-radius: 0;
  background: transparent;
  color: #1f2427;
  font: inherit;
  padding: 0 0 2px;
}

.immo-field textarea {
  resize: vertical;
  line-height: 1.3;
}

.immo-check-list {
  display: grid;
  gap: 7px;
}

.immo-check-list > div {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 8px;
  align-items: start;
  color: #2b3134;
  font-size: 11px;
  line-height: 1.35;
}

.immo-box {
  width: 11px;
  height: 11px;
  margin-top: 1px;
  border: 1.3px solid rgba(190, 30, 74, 0.75);
}

.immo-check-list input[type="checkbox"] {
  width: 12px;
  height: 12px;
  margin: 1px 0 0;
  accent-color: #be1e4a;
}

.immo-form-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10.5px;
}

.immo-form-table th,
.immo-form-table td {
  height: 26px;
  padding: 5px 6px;
  border-bottom: 1px solid rgba(90, 95, 99, 0.26);
  text-align: left;
  vertical-align: top;
}

.immo-form-table th {
  color: #3c4245;
  font-size: 9.4px;
  font-weight: 800;
  text-transform: uppercase;
}

.immo-line-area {
  display: grid;
  gap: 10px;
  padding-top: 2px;
}

.immo-line-area span {
  display: block;
  min-height: 18px;
  border-bottom: 1px solid rgba(90, 95, 99, 0.34);
}

.immo-signatures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 26px;
}

.immo-signatures div {
  display: grid;
  gap: 7px;
}

.immo-signatures span {
  display: block;
  height: 24px;
  border-bottom: 1px solid rgba(35, 38, 40, 0.7);
}

.immo-signatures strong {
  color: #60676b;
  font-size: 9.5px;
  font-weight: 700;
}

.review-toolbar {
  position: fixed;
  z-index: 30;
  top: 12px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(92vw, 794px);
  padding: 10px 12px;
  transform: translateX(-50%);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(22, 31, 37, 0.16);
  color: #333;
  font-size: 12px;
}

.review-toolbar strong {
  color: var(--immo);
  font-size: 12px;
  text-transform: uppercase;
}

.review-toolbar span {
  flex: 1;
  color: var(--muted);
}

.review-toolbar button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(190, 30, 74, 0.35);
  border-radius: 5px;
  background: #fff;
  color: var(--immo);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.real-contract-form-mode {
  padding-top: 0;
  padding-right: min(410px, 34vw);
}

.contract-input-panel {
  position: fixed;
  z-index: 32;
  top: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  align-content: start;
  gap: 0;
  width: min(390px, 34vw);
  overflow: auto;
  padding: 16px;
  background: #ffffff;
  border-left: 1px solid var(--line);
  box-shadow: -16px 0 34px rgba(22, 31, 37, 0.13);
  color: #2d3438;
}

.contract-input-head {
  position: sticky;
  z-index: 2;
  top: -16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px;
  padding: 0 0 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.contract-input-head span,
.contract-input-head em,
.contract-draft-status {
  grid-column: 1 / -1;
}

.contract-input-close,
.contract-mobile-panel-toggle,
.contract-mobile-panel-backdrop {
  display: none;
}

.contract-input-close {
  align-self: start;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid rgba(190, 30, 74, 0.28);
  border-radius: 6px;
  background: #fff;
  color: var(--immo);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

.contract-input-head strong {
  color: var(--immo);
  font-size: 15px;
  text-transform: uppercase;
}

.contract-input-head span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.contract-input-head em {
  display: block;
  padding: 8px 9px;
  background: rgba(190, 30, 74, 0.055);
  border-left: 3px solid var(--immo);
  color: #3c4448;
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
  line-height: 1.35;
}

.contract-input-group {
  display: grid;
  gap: 9px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(217, 222, 225, 0.82);
}

.contract-input-group h2 {
  margin: 0;
  color: #2f3437;
  font-size: 12px;
  text-transform: uppercase;
}

.contract-input-field {
  display: grid;
  gap: 4px;
}

.contract-input-field span {
  color: #687177;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.contract-input-field input,
.contract-input-field textarea,
.contract-input-field select {
  width: 100%;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #273036;
  font: inherit;
  font-size: 13px;
}

.contract-input-field textarea {
  resize: vertical;
}

.contract-input-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding-top: 14px;
}

.contract-input-actions button {
  min-height: 36px;
  border: 1px solid rgba(190, 30, 74, 0.35);
  border-radius: 6px;
  background: #fff;
  color: var(--immo);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.contract-footer div {
  display: grid;
  gap: 2px;
  align-content: start;
}

.contract-footer strong {
  margin-bottom: 2px;
  color: #45484a;
}

@media (max-width: 980px) {
  .real-contract-form-mode {
    padding-right: 0;
  }

  .contract-template.real-contract-form-mode {
    overflow-x: hidden;
  }

  .contract-pages {
    display: block;
    padding: 0;
  }

  .contract-sheet {
    width: 100%;
    min-height: auto;
    padding: 30px 18px 88px 28px;
    box-shadow: none;
  }

  .contract-sheet::before {
    width: 5px;
  }

  .contract-watermark {
    top: 42%;
    width: 72vw;
    max-width: 72vw;
  }

  .contract-footer {
    position: relative;
    right: auto;
    bottom: auto;
    left: auto;
    grid-template-columns: 1fr 1fr;
    gap: 10px 14px;
    margin-top: 28px;
    font-size: 8.6px;
  }

  .contract-footer-page {
    right: 0;
    bottom: -24px;
  }

  .contract-flow-signatures {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .signature-field {
    max-width: 100%;
  }

  .contract-input-panel {
    z-index: 70;
    width: min(430px, 94vw);
    max-width: 94vw;
    border-left: 1px solid rgba(190, 30, 74, 0.18);
    transform: translateX(104%);
    transition: transform 180ms ease;
  }

  .contract-input-open .contract-input-panel {
    transform: translateX(0);
  }

  body.contract-input-open {
    overflow: hidden;
  }

  .contract-input-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .contract-mobile-panel-toggle {
    position: fixed;
    z-index: 60;
    right: 14px;
    bottom: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 14px;
    border: 1px solid rgba(190, 30, 74, 0.3);
    border-radius: 7px;
    background: var(--immo);
    color: #fff;
    box-shadow: 0 10px 28px rgba(40, 20, 28, 0.24);
    font: inherit;
    font-size: 13px;
    font-weight: 800;
  }

  .contract-mobile-panel-backdrop {
    position: fixed;
    z-index: 65;
    inset: 0;
    display: none;
    border: 0;
    background: rgba(22, 24, 27, 0.36);
  }

  .contract-input-open .contract-mobile-panel-backdrop {
    display: block;
  }

  .signature-dialog-backdrop {
    align-items: stretch;
    padding: 0;
  }

  .signature-dialog {
    gap: 10px;
    width: 100%;
    min-height: 100%;
    padding: 12px;
    border-radius: 0;
  }

  .signature-dialog-canvas-wrap {
    height: min(360px, 58vh);
  }

  .signature-dialog-actions {
    justify-content: stretch;
  }

  .signature-dialog-actions button {
    flex: 1;
  }
}

@media print {
  .contract-template {
    background: #fff;
  }

  .contract-input-panel,
  .contract-mobile-panel-toggle,
  .contract-mobile-panel-backdrop,
  .review-toolbar,
  .signature-open,
  .signature-dialog-backdrop,
  .signature-clear {
    display: none;
  }

  .signature-canvas-wrap {
    border: 0;
    border-bottom: 1px solid rgba(47, 52, 55, 0.72);
    background: transparent;
  }

  .contract-pages {
    display: block;
    padding: 0;
  }

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

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