@font-face {
  font-family: 'Cabin';
  font-style: normal;
  font-display: swap;
  font-weight: 400 700;
  src: url('/assets/fonts/cabin-latin-variable.woff2') format('woff2');
}

:root {
  --fahrner-orange: #f18526;
  --orange-text: #a64b08;
  --offer-dark: #2f2f2d;
  --offer-grey: #9d9594;
  --offer-grey-soft: #ece9e8;
  --workbench: #e7e4e2;
  --navy: var(--offer-dark);
  --navy-2: #45413f;
  --paper: #f5f3f2;
  --white: #ffffff;
  --ink: #2f2f2d;
  --muted: #696260;
  --line: #e0dcda;
  --line-strong: #c9c2bf;
  --blue: var(--fahrner-orange);
  --blue-dark: var(--orange-text);
  --blue-soft: #fff1e5;
  --green: #16805c;
  --green-soft: #eaf8f2;
  --red: #b42318;
  --shadow: 0 18px 48px rgba(47, 47, 45, .10);
  --radius: 12px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--workbench); }
body { margin: 0; min-height: 100vh; background: var(--workbench); color: var(--ink); font: 15px/1.4 'Cabin', ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--blue-dark); text-decoration: none; }
a:hover { color: var(--blue-dark); }
button { font: inherit; }
button, .button { border: 0; border-radius: 3px; padding: .72rem 1rem; background: var(--blue); color: var(--offer-dark); font-weight: 700; cursor: pointer; transition: background .15s ease, transform .15s ease, box-shadow .15s ease; }
button:hover, .button:hover { background: #ff9d52; color: var(--offer-dark); }
button:active, .button:active { transform: translateY(1px); }
.secondary { border: 1px solid var(--line-strong); background: #fff; color: var(--ink); }
.secondary:hover { border-color: #a9a09d; background: #faf9f8; color: var(--ink); }
.danger { background: var(--red); color: #fff; }
.danger:hover { background: #8f1c14; color: #fff; }
.button-large { padding: .9rem 1.3rem; white-space: nowrap; }
.button-block { display: block; width: 100%; text-align: center; margin: 0 0 .65rem; }
:focus-visible { outline: 3px solid #ffc16f; outline-offset: 2px; }

.app-shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); min-height: 100vh; }
.app-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; width: 210px; flex-direction: column; padding: 24px 16px; background: var(--offer-dark); color: #fff; }
.brand { display: flex; align-items: center; gap: 11px; color: #fff; font-size: 15px; font-weight: 700; letter-spacing: .055em; }
.brand:hover { color: #fff; }
.brand-mark { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 2px; background: var(--fahrner-orange); color: var(--offer-dark); font-size: 18px; }
.brand small { display: block; margin-top: 1px; color: #b8b1ae; font-size: 9px; letter-spacing: .16em; }
.app-sidebar nav { display: grid; gap: 6px; margin-top: 42px; }
.app-sidebar nav a { display: flex; align-items: center; gap: 11px; padding: 10px 11px; border-radius: 8px; color: #d2ccca; font-weight: 650; }
.app-sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.app-sidebar nav a span { display: grid; width: 26px; height: 26px; place-items: center; border: 1px solid rgba(255,255,255,.14); border-radius: 7px; color: #fff; font-size: 11px; }
.sidebar-logout { margin-top: auto; }
.nav-button { width: 100%; border: 1px solid rgba(255,255,255,.15); background: transparent; color: #d2ccca; text-align: left; }
.nav-button:hover { background: rgba(255,255,255,.08); color: #fff; }

.app-workspace { grid-column: 2; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 15; display: flex; align-items: center; justify-content: space-between; min-height: 78px; padding: 14px 30px; border-bottom: 1px solid #d6d1cf; background: rgba(255,255,255,.97); backdrop-filter: blur(10px); }
.topbar h1 { margin: 2px 0 0; color: var(--navy); font-size: 24px; line-height: 1.1; letter-spacing: -.035em; }
.eyebrow { display: block; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .16em; }
.app-main { width: 100%; max-width: 1480px; margin: 0 auto; padding: 26px 30px 60px; }

.quick-start { display: flex; align-items: center; justify-content: space-between; gap: 30px; margin-bottom: 24px; padding: 34px 38px; border-radius: 16px; background: linear-gradient(120deg, var(--navy), var(--navy-2)); color: #fff; box-shadow: var(--shadow); }
.quick-start h2 { max-width: 680px; margin: 5px 0 8px; font-size: clamp(24px, 3vw, 38px); line-height: 1.08; letter-spacing: -.045em; }
.quick-start p { margin: 0; color: #d2ccca; font-size: 15px; }
.quick-start .eyebrow { color: #ffc089; }
.content-card, .editor-card, .side-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); box-shadow: 0 4px 18px rgba(22,32,51,.035); }
.content-card { padding: 24px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-head > div { display: flex; align-items: center; gap: 10px; }
.section-head h2 { margin: 0; color: var(--navy); font-size: 18px; letter-spacing: -.025em; }
.section-head .eyebrow + h2 { margin-top: 3px; }
.step { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 8px; background: var(--blue-soft); color: var(--orange-text); font-size: 11px; font-weight: 700; }
.empty-state { display: grid; gap: 4px; padding: 34px; border: 1px dashed var(--line-strong); border-radius: 10px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink); font-size: 16px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 12px; border-bottom: 1px solid var(--line-strong); color: var(--muted); font-size: 10px; text-align: left; text-transform: uppercase; letter-spacing: .09em; }
td { padding: 13px 12px; border-bottom: 1px solid var(--line); }
tbody tr:hover { background: #faf9f8; }
.table-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.table-actions .button, .table-actions button { padding: .5rem .65rem; }
.status { display: inline-flex; padding: 4px 8px; border-radius: 999px; background: var(--blue-soft); color: var(--blue-dark); font-size: 11px; font-weight: 700; }
.status-sent { background: var(--green-soft); color: var(--green); }

form { margin: 0; }
.customer-management { display: grid; gap: 18px; }
label { position: relative; display: grid; gap: 6px; margin: 0 0 15px; color: #4b4745; font-size: 12px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 7px; padding: .72rem .8rem; background: #fff; color: var(--ink); font-family: inherit; font-size: 15px; font-weight: 400; line-height: 1.4; box-shadow: inset 0 1px 1px rgba(16,24,40,.025); }
input:hover, select:hover, textarea:hover { border-color: #a9a09d; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: 3px solid rgba(241,133,38,.16); }
textarea { min-height: 82px; resize: vertical; }
.intro-text { min-height: 150px; }
.closing-text { min-height: 180px; }
.field-help { margin: -4px 0 0; color: var(--muted); font-size: 11px; }
.field-suffix { position: absolute; right: 12px; bottom: 11px; color: var(--muted); font-size: 12px; font-weight: 600; pointer-events: none; }

.offer-topline { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; padding: 0 2px; font-size: 12px; font-weight: 700; }
.save-context { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.offer-editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 292px; gap: 24px; align-items: start; }
.offer-main { display: grid; gap: 18px; min-width: 0; }
.offer-paper { display: block; width: 100%; max-width: 100%; overflow: hidden; border: 1px solid #d4cfcc; border-radius: 1px; background: var(--white); box-shadow: 0 20px 55px rgba(47,47,45,.12); }
.offer-paper-header { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding: 30px 36px 18px; }
.offer-paper-header strong { display: block; margin-top: 3px; color: var(--offer-dark); font-size: clamp(20px, 2.4vw, 30px); line-height: 1.08; letter-spacing: -.035em; }
.offer-paper-header .eyebrow { color: var(--orange-text); }
.offer-paper-brand { color: var(--offer-dark); font-size: 13px; font-weight: 700; letter-spacing: .055em; }
.offer-paper-rule { position: relative; height: 4px; background: var(--offer-dark); }
.offer-paper-rule::before { position: absolute; inset: 0 auto 0 0; width: 94px; background: var(--fahrner-orange); content: ""; }
.offer-paper-section { padding: 30px 36px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; box-shadow: none; }
.offer-paper-section:last-child { border-bottom: 0; }
.offer-paper .section-head { margin-bottom: 20px; }
.offer-paper-services .section-head { margin: -30px -36px 22px; padding: 13px 36px; background: var(--offer-grey-soft); }
.offer-paper-services .step { background: var(--offer-dark); color: #fff; }
.offer-paper-closing .section-head { padding-bottom: 10px; border-bottom: 1px solid var(--offer-grey); }
.editor-card { padding: 23px; }
.offer-paper .editor-card { padding: 30px 36px; }
.customer-preview { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; margin: -3px 0 18px; padding: 16px; border: 0; border-left: 4px solid var(--fahrner-orange); border-radius: 0; background: var(--offer-grey-soft); color: var(--muted); }
.customer-preview > div { display: grid; align-content: start; gap: 3px; }
.customer-preview strong { color: var(--ink); font-size: 14px; }
.preview-label { color: var(--orange-text); font-size: 9px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.template-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; margin-bottom: 16px; padding: 12px; border-radius: 2px; background: #f7f5f4; }
.template-bar select { margin: 0; }
.position-head { display: flex; justify-content: space-between; padding: 0 12px 8px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.position { min-width: 0; margin: 0 0 12px; padding: 0; overflow: hidden; border: 1px solid #d7d2d0; border-radius: 2px; background: #fff; }
.position.is-optional { border-color: var(--fahrner-orange); }
.position.is-optional legend { background: var(--blue-soft); }
.position legend { display: grid; grid-template-columns: 1fr auto auto; width: 100%; align-items: center; gap: 14px; padding: 10px 14px; border-bottom: 1px solid #d7d2d0; background: var(--offer-grey-soft); color: var(--navy); font-size: 11px; font-weight: 700; }
.line-total { color: var(--navy); font-variant-numeric: tabular-nums; }
.position-body { padding: 15px; }

.position-values { display: grid; grid-template-columns: 110px 130px minmax(150px, 1fr); gap: 10px; }
.position-values label { margin-bottom: 0; }
.optional-position-control { display: flex; align-items: center; gap: 9px; margin: 14px 0 0; padding: 10px 12px; border-radius: 3px; background: #fff8f1; color: var(--orange-text); }
.optional-position-control input { width: 18px; height: 18px; margin: 0; padding: 0; border: 1px solid var(--line-strong); box-shadow: none; accent-color: var(--fahrner-orange); }
.remove-position { padding: 3px 5px; background: transparent; color: var(--red); font-size: 11px; font-weight: 700; }
.remove-position:hover { background: #fff1f0; color: var(--red); }
.add-position { width: 100%; border-style: dashed; }

.offer-sidebar { position: sticky; top: 96px; display: grid; gap: 12px; }
.side-card { padding: 18px; border-radius: 2px; box-shadow: 0 8px 24px rgba(47,47,45,.07); }
.side-title { display: block; margin-bottom: 14px; color: var(--navy); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.side-card label:last-child { margin-bottom: 0; }
.totals-card { display: grid; gap: 9px; font-variant-numeric: tabular-nums; }
.totals-card > div { display: flex; justify-content: space-between; color: var(--muted); }
.totals-card strong { color: var(--ink); }
.totals-card .grand-total { margin: 6px -18px -18px; padding: 15px 18px; border-top: 0; background: var(--offer-grey-soft); color: var(--navy); font-size: 15px; font-weight: 700; }
.totals-card .grand-total strong { font-size: 17px; }
.action-card .save-state { display: block; margin-bottom: 10px; color: var(--muted); font-size: 11px; font-weight: 650; text-align: center; }
.action-card .action-hint { display: block; color: var(--muted); font-size: 11px; line-height: 1.4; text-align: center; }
.mobile-save-bar { display: none; }

.template-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.template-grid h3 { margin: 24px 0 14px; color: var(--navy); font-size: 15px; }
.toolbar, .row { display: flex; gap: 10px; align-items: end; }
.toolbar input { flex: 1; }
.inline { display: inline; }
.error { padding: 10px 12px; border: 1px solid #f1b5b0; border-radius: 7px; background: #fff1f0; color: var(--red); }

.login-shell { display: grid; min-height: 100vh; place-items: center; align-content: center; gap: 22px; padding: 24px; background: radial-gradient(circle at top left, #f5dfcc, transparent 38%), var(--paper); }
.login-brand { color: var(--navy); font-weight: 700; letter-spacing: .08em; }
.login-brand span { color: var(--orange-text); }
.login-card { width: min(420px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.login-card h1 { margin: 4px 0 22px; font-size: 27px; }
.login-card button { width: 100%; }

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 190px minmax(0, 1fr); }
  .app-sidebar { width: 190px; }
  .offer-editor-grid { grid-template-columns: minmax(0, 1fr) 245px; }
  .app-main { padding-inline: 20px; }
  .topbar { padding-inline: 20px; }
  .position-values { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .position-values label:last-child { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .app-sidebar { position: static; width: auto; padding: 12px 16px; }
  .app-sidebar .brand { display: none; }
  .app-sidebar nav { display: flex; margin: 0; overflow-x: auto; }
  .app-sidebar nav a { white-space: nowrap; }
  .app-sidebar nav a span { display: none; }
  .sidebar-logout { display: none; }
  .app-workspace { min-width: 0; overflow-x: clip; }
  .topbar { top: 0; min-height: 70px; gap: 12px; }
  .topbar > div { min-width: 0; }
  .topbar .button { flex: 0 0 auto; white-space: nowrap; }
  .topbar h1 { font-size: 20px; }
  .offer-topline { gap: 10px; flex-wrap: wrap; }
  .offer-editor-grid { display: block; }
  .offer-paper { box-shadow: 0 10px 30px rgba(47,47,45,.09); }
  .offer-paper .section-head { flex-wrap: wrap; }
  .offer-paper .section-head > div { min-width: 0; }
  .offer-paper .section-head > a { width: 100%; margin-left: 40px; }
  .offer-paper-header { padding: 24px 22px 16px; }
  .offer-paper .editor-card { padding: 24px 22px; }
  .offer-paper-services .section-head { margin: -24px -22px 20px; padding: 12px 22px; }
  .template-grid { grid-template-columns: 1fr; }
  .offer-sidebar { position: static; margin-top: 16px; }
  .customer-preview { grid-template-columns: 1fr; }
  .position-values { grid-template-columns: 1fr 1fr 1.3fr; }
  .position-values label:last-child { grid-column: auto; }
  .mobile-save-bar { display: block; position: fixed; right: 12px; bottom: 12px; left: 12px; z-index: 30; padding: 8px; border: 1px solid var(--line); background: rgba(255,255,255,.96); box-shadow: 0 10px 30px rgba(47,47,45,.18); }
  .mobile-save-bar .button-block { margin: 0; }
}

@media (max-width: 560px) {
  .app-main { padding: 18px 12px 100px; }
  .topbar { padding: 12px; }
  .topbar .button { padding: .65rem .7rem; font-size: 0; }
  .topbar .button::after { content: "+ Neu"; font-size: 12px; }
  .save-context { display: none; }
  .quick-start { display: grid; padding: 24px; }
  .editor-card, .content-card { padding: 16px; }
  .offer-paper-header { align-items: start; padding: 20px 16px 14px; }
  .offer-paper-brand { display: none; }
  .offer-paper .editor-card { padding: 20px 16px; }
  .offer-paper-services .section-head { margin: -20px -16px 18px; padding: 12px 16px; }
  .section-head { align-items: flex-start; }
  .template-bar { grid-template-columns: 1fr; }
  .position-values { grid-template-columns: 1fr; }
  .position-head { display: none; }
  .toolbar, .row { display: grid; }
  table { min-width: 620px; }
}

@media print {
  .app-sidebar, .topbar, .offer-sidebar, .offer-topline { display: none !important; }
  .app-workspace { display: block; }
  .app-main { max-width: none; padding: 0; }
  .editor-card { box-shadow: none; break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
