:root {
  --paper:    #ffffff;
  --paper-2:  #f7f8fa;
  --ink:      #0f1419;
  --ink-2:    #4a5460;
  --ink-3:    #8b95a3;
  --rule:     #e1e4e8;
  --rule-2:   #ebeef2;
  --grid:     transparent;
  --accent:   #d35400;       /* Orange, etwas zurueckgenommen vom Mennige */
  --accent-2: #a04000;
  --steel:    #2a4659;
  --steel-2:  #3a6378;
  --ok:       #2c6b3f;
  --warn:     #b85b00;

  --serif:  'Inter', system-ui, -apple-system, sans-serif;
  --sans:   'Inter', system-ui, -apple-system, sans-serif;
  --mono:   'JetBrains Mono', 'Menlo', 'Consolas', monospace;
}

* { box-sizing: border-box; }
html { font-feature-settings: 'cv11', 'ss01'; }
table, .num, .mono { font-variant-numeric: tabular-nums; }

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Bauplan-Raster bewusst entfernt - schlichter, weniger ablenkend */

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100vh;
}

/* ============= SIDEBAR ============= */
aside {
  border-right: 1px solid var(--rule);
  background: var(--paper-2);
  padding: 28px 0 28px 28px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
aside header {
  padding-right: 28px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 16px;
}
aside .brand {
  font-family: var(--serif);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
  line-height: 1;
}
aside .brand span { color: var(--accent); }
aside .tag {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink-3);
  margin-top: 8px;
}

aside .group-label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink-3);
  margin: 18px 28px 6px 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
aside .group-label .count {
  font-weight: 600;
  color: var(--accent);
}

aside ul {
  list-style: none;
  margin-right: 0;
}
aside li button {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  padding: 9px 28px 9px 13px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  transition: all .12s;
}
aside li button:hover {
  background: rgba(0,0,0,0.03);
  color: var(--ink);
}
aside li button.active {
  border-left-color: var(--accent);
  background: var(--paper);
  color: var(--ink);
  font-weight: 600;
}
aside li button .typ-badge {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.05em;
}
aside li button .auftrag-nr {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
}

aside footer {
  margin-top: 36px;
  padding: 18px 28px 0 0;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  line-height: 1.6;
}

/* ============= MAIN ============= */
main {
  padding: 48px 56px 96px;
  max-width: 1240px;
}

/* Doc-Header */
.doc-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: end;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 18px;
  margin-bottom: 32px;
}
.doc-head .meta-line {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.doc-head h1 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 44px;
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.doc-head h1 .typ {
  color: var(--accent);
}
.doc-head h1 .sub {
  display: block;
  font-size: 18px;
  font-weight: 400;
  color: var(--ink-3);
  letter-spacing: 0;
  margin-top: 8px;
  font-family: var(--sans);
}

.auftrag-stamp {
  border: 2px solid var(--ink);
  padding: 12px 18px;
  text-align: right;
  background: var(--paper);
  position: relative;
}
/* Doppelrand des Auftrags-Stempels entfernt - schlichter */
.auftrag-stamp .label {
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-3);
}
.auftrag-stamp .nr {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.05em;
  margin-top: 4px;
}

/* Stat-Strip */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin-bottom: 40px;
}
.stat {
  padding: 16px 20px;
  border-right: 1px solid var(--rule);
}
.stat:last-child { border-right: none; }
.stat .label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink-3);
}
.stat .value {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 28px;
  color: var(--ink);
  margin-top: 4px;
  letter-spacing: -0.02em;
}
.stat .value.mono { font-family: var(--mono); font-size: 22px; }
.stat .unit {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  margin-left: 4px;
  font-weight: 400;
}

/* Section-Heading */
section { margin-bottom: 56px; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--ink);
}
.section-head h2 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.section-head .num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.15em;
}

/* Drawings */
.drawings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}
.drawing-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 16px;
  position: relative;
}
.drawing-card .corner { display: none; }
.drawing-card img {
  width: 100%;
  height: 200px;
  object-fit: contain;
  background: #fff;
  display: block;
}
.drawing-card .caption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
}
.drawing-card .caption .role {
  color: var(--accent);
  font-weight: 600;
}
.drawing-card .download {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-2);
  text-decoration: none;
  border: 1px solid var(--rule);
  padding: 3px 8px;
  transition: all .15s;
}
.drawing-card .download:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* Position-Tabelle */
.tbl-wrap {
  overflow-x: auto;
  border: 1px solid var(--rule);
  background: var(--paper);
}
table.positions {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12px;
}
table.positions thead {
  background: var(--ink);
  color: var(--paper);
}
table.positions th {
  text-align: left;
  padding: 10px 10px;
  font-weight: 500;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  white-space: nowrap;
}
table.positions th.num,
table.positions td.num { text-align: right; }
table.positions tbody tr {
  border-bottom: 1px solid var(--rule-2);
  transition: background .1s;
}
table.positions tbody tr:hover { background: rgba(200,67,30,0.04); }
table.positions tbody tr.empty { color: var(--ink-3); opacity: 0.55; }
table.positions tbody tr.has-stk td.pos,
table.positions tbody tr.has-stk td.stk {
  color: var(--accent);
  font-weight: 600;
}
table.positions td {
  padding: 9px 10px;
  white-space: nowrap;
}
table.positions td.dim {
  color: var(--ink-2);
}
table.positions td.dim.zero {
  color: var(--ink-3);
  opacity: 0.4;
}
table.positions tfoot {
  background: var(--paper-2);
  font-weight: 600;
}
table.positions tfoot td {
  padding: 12px 10px;
  border-top: 2px solid var(--ink);
  font-size: 12px;
}

/* Preis-Tabelle */
table.preis {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12px;
  background: var(--paper);
  border: 1px solid var(--rule);
}
table.preis th, table.preis td { padding: 9px 12px; text-align: right; }
table.preis th:first-child, table.preis td:first-child { text-align: left; }
table.preis thead { background: var(--steel); color: #fff; }
table.preis th {
  font-weight: 500;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
table.preis tbody tr { border-bottom: 1px solid var(--rule-2); }
table.preis tbody tr.has-pos td:first-child { color: var(--accent); font-weight: 600; }
table.preis tfoot { font-weight: 600; background: var(--paper-2); }
table.preis tfoot td { border-top: 2px solid var(--ink); padding: 12px; }
table.preis .total-row td { font-size: 14px; }

.preis-note {
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--warn);
  letter-spacing: 0.05em;
}

/* Export-Bar */
.exports {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.btn {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  padding: 10px 18px;
  background: var(--paper);
  border: 1px solid var(--ink);
  color: var(--ink);
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn:hover {
  background: var(--ink);
  color: var(--paper);
}
.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn.primary:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
}
.btn.ghost {
  border-style: dashed;
  opacity: 0.7;
  cursor: not-allowed;
}
.btn .glyph { font-size: 14px; line-height: 1; }

/* Schema-Diagram */
.schema {
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 24px;
  margin-bottom: 24px;
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 32px;
  align-items: center;
}
.schema-vars {
  font-family: var(--mono);
  font-size: 11px;
}
.schema-vars dt {
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: inline-block;
  width: 70px;
}
.schema-vars dd {
  display: inline-block;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.schema-vars div { margin-bottom: 4px; }

/* Empty / fallbacks */
.empty-msg {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-3);
  padding: 24px;
  text-align: center;
  border: 1px dashed var(--rule);
}

/* Responsive */
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  aside { position: relative; height: auto; border-right: none; border-bottom: 1px solid var(--rule); padding: 24px; }
  aside header { padding-right: 0; }
  aside li button { padding: 8px 10px; }
  main { padding: 32px 20px; }
  .doc-head { grid-template-columns: 1fr; }
  .doc-head h1 { font-size: 36px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat { border-bottom: 1px solid var(--rule); }
  .schema { grid-template-columns: 1fr; }
}

/* ============= DROP ZONE / EMPTY STATE ============= */
.drop-shell {
  min-height: calc(100vh - 96px);
  display: grid;
  place-items: center;
  padding: 48px 56px;
}
.drop-card {
  width: min(720px, 100%);
  background: var(--paper);
  border: 2px dashed var(--rule);
  border-radius: 4px;
  padding: 64px 48px;
  text-align: center;
  position: relative;
  transition: border-color .2s, background .2s, transform .15s;
}
.drop-card.hover {
  border-color: var(--accent);
  background: var(--paper-2);
  transform: scale(1.005);
}
.drop-card .corner { display: none; }
.drop-card h1 {
  font-family: var(--serif);
  font-weight: 800;
  font-size: 42px;
  line-height: 1;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}
.drop-card h1 .ink2 { color: var(--accent); }
.drop-card .lead {
  font-size: 15px;
  color: var(--ink-2);
  margin: 0 auto 28px;
  max-width: 460px;
  line-height: 1.55;
}
.drop-card .pickup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--ink);
  color: var(--paper);
  border: none;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 14px;
  padding: 14px 24px;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background .15s;
}
.drop-card .pickup:hover { background: var(--accent-2); }
.drop-card .pickup .glyph { font-family: var(--mono); font-size: 16px; }
.drop-card .small {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 18px;
  letter-spacing: 0.05em;
}
.status-bar {
  margin-top: 24px;
  padding: 12px 16px;
  border-left: 3px solid var(--rule);
  background: var(--paper-2);
  font-size: 13px;
  color: var(--ink-2);
  text-align: left;
  font-family: var(--mono);
  display: none;
}
.status-bar.show { display: block; }
.status-bar.ok   { border-left-color: var(--ok); color: var(--ok); }
.status-bar.warn { border-left-color: var(--warn); color: var(--warn); }
.status-bar.err  { border-left-color: var(--accent); color: var(--accent); }

.status-bar .status-msg { line-height: 1.5; }
.status-bar .status-diag {
  margin-top: 10px;
  border-top: 1px dashed var(--rule);
  padding-top: 10px;
  color: var(--ink-2);
  font-size: 11px;
}
.status-bar .status-diag summary {
  cursor: pointer;
  user-select: none;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}
.status-bar .status-diag summary:hover { color: var(--ink); }
.status-bar .status-diag pre {
  margin: 10px 0;
  padding: 10px 12px;
  background: var(--paper);
  border: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow-y: auto;
  text-align: left;
}
.status-bar .diag-copy {
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 6px 12px;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-2);
  cursor: pointer;
}
.status-bar .diag-copy:hover { border-color: var(--ink); color: var(--ink); }

aside .reset-row {
  margin-top: 18px;
  padding-right: 28px;
}
aside .reset-row button {
  width: 100%;
  background: none;
  border: 1px solid var(--rule);
  padding: 9px 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: all .15s;
}
aside .reset-row button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Print */
@media print {
  body::before, body::after { display: none; }
  .app { grid-template-columns: 1fr; }
  aside, .exports, .status-bar { display: none; }
  main { padding: 0; max-width: none; }
}
