:root {
  --bg: #f4f6f8; --card: #ffffff; --text: #1d2733; --muted: #66707c; --line: #dde2e8;
  --accent: #0b5e8e; --accent-2: #e8f1f7; --danger: #b3261e; --warn-bg: #fff4e0; --warn: #8a5300;
  --radius: 8px; --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 var(--font); background: var(--bg); color: var(--text); }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12.5px; }

.topbar { position: sticky; top: 0; z-index: 10; background: #12344d; color: #fff; }
.navrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 24px; padding: 8px 20px 0; }
.mainnav { display: flex; flex-wrap: wrap; gap: 2px; }
.mainnav a { color: rgba(255,255,255,.75); text-decoration: none; padding: 7px 12px; border-radius: 6px 6px 0 0; font-size: 13.5px; }
.mainnav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.mainnav a.active { color: #fff; background: #1d4a6b; font-weight: 600; }
.topbar .actions { background: #1d4a6b; padding: 8px 20px; }
.pagetitle { font-weight: 600; margin-right: 10px; }
.brand { font-weight: 600; font-size: 16px; }
.brand span { font-weight: 400; opacity: .7; margin-left: 8px; font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.actions select { max-width: 280px; }

button, .btn { font: inherit; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 6px;
  padding: 6px 12px; cursor: pointer; text-decoration: none; display: inline-block; line-height: 1.3; }
button:hover, .btn:hover { filter: brightness(1.08); }
.topbar .ghost { background: transparent; border-color: rgba(255,255,255,.4); color: #fff; }
.topbar .primary { background: #f0a500; border-color: #f0a500; color: #1d2733; font-weight: 600; }
.card .ghost { background: #fff; color: var(--accent); }
button.small { padding: 3px 10px; font-size: 13px; }
button.icon { background: transparent; border: none; color: var(--muted); padding: 2px 6px; font-size: 14px; }
button.icon.danger:hover, .danger { color: var(--danger); }
.topbar .danger { color: #ffb4ab; }
.file-btn input { display: none; }

input, select, textarea { font: inherit; border: 1px solid var(--line); border-radius: 5px; padding: 5px 7px;
  background: #fff; color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-2); border-color: var(--accent); }
input[type=checkbox] { width: auto; }
input.ro { background: #eef1f4; color: var(--muted); }
textarea { resize: vertical; }
label { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; padding-top: 18px; }
details { margin-top: 12px; } summary { cursor: pointer; color: var(--accent); font-size: 13px; margin-bottom: 8px; }
details label { margin-bottom: 8px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }

.layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; padding: 16px 20px; align-items: start; }
.admin { padding: 16px 20px; display: grid; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.form { display: grid; gap: 16px; }
.cards { gap: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 10px 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; } .span4 { grid-column: 1 / -1; }
.sticky { position: sticky; top: 112px; max-height: calc(100vh - 130px); overflow: auto; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
table.edit th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 4px; white-space: nowrap; }
table.edit td { padding: 3px 4px; vertical-align: middle; }
table.edit input[type=number] { min-width: 64px; }
table.edit input.wide { min-width: 200px; }
#vmTable .f-name { min-width: 110px; }
#vmTable td:has(input[type=checkbox]) { text-align: center; }
.row-actions { white-space: nowrap; text-align: right; }
td.empty { color: var(--muted); font-style: italic; padding: 10px 4px; }

.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 14px; }
.totals div { background: var(--accent-2); border-radius: 6px; padding: 8px 10px; display: flex; flex-direction: column; }
.totals span { font-size: 12px; color: var(--muted); }
.totals strong { font-size: 17px; }
.totals small { color: var(--muted); font-size: 11.5px; }
.warn { background: var(--warn-bg); color: var(--warn); border-radius: 5px; padding: 6px 10px; margin-bottom: 6px; font-size: 13px; }

.preview-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); padding: 5px 6px; }
.preview-table td { padding: 4px 6px; border-bottom: 1px solid #f0f2f5; vertical-align: top; }
.preview-table .r { text-align: right; white-space: nowrap; }
.preview-table .t-group td { font-weight: 700; font-size: 14.5px; padding-top: 14px; border-bottom: 2px solid var(--text); }
.preview-table .t-section td { font-weight: 600; color: var(--accent); padding-top: 10px; }
.preview-table .t-sub td { font-weight: 600; padding-top: 8px; }
.preview-table .t-sum td { font-weight: 700; border-top: 1px solid var(--text); background: #fafbfc; }
.lt { font-weight: 400; color: var(--muted); font-size: 12px; white-space: pre-line; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: #12344d; color: #fff;
  padding: 10px 18px; border-radius: 6px; opacity: 0; transition: .2s; pointer-events: none; z-index: 50; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--danger); }

.print-only { display: none; }
@media (max-width: 1100px) { .layout { grid-template-columns: 1fr; } .sticky { position: static; max-height: none; } }
@media (max-width: 700px) { .g3, .g4, .g2 { grid-template-columns: 1fr; } .span2 { grid-column: auto; } .totals { grid-template-columns: 1fr; } }
@media print {
  .topbar, .form, #warnings, #toast { display: none !important; }
  body { background: #fff; }
  .layout { display: block; padding: 0; }
  .card { border: none; padding: 0; }
  .sticky { position: static; max-height: none; overflow: visible; }
  .print-only { display: block; margin-bottom: 16px; }
}
#vmTable .f-os { min-width: 105px; }
#freeTable .f-abrechnung { min-width: 110px; }
#freeTable .f-key { min-width: 160px; }
.preview-table td.mono { white-space: nowrap; }

/* ---------- Offerte aus Vorlagen ---------- */
.nowrap { white-space: nowrap; }
.err { color: var(--danger); font-weight: 600; cursor: help; }
input.invalid { border-color: var(--danger); background: #fff5f4; }
input.strong { font-weight: 600; }
.add-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.add-row select { flex: 1; min-width: 220px; width: auto; }
.small-row { margin-top: 10px; }
.small-row select { max-width: 420px; font-size: 13px; }
.empty-card { color: var(--muted); font-style: italic; text-align: center; }
#blocks { display: grid; gap: 16px; }
.block { border-left: 4px solid var(--accent); }
.block-off { opacity: .55; border-left-color: var(--line); }
.block-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.block-head .b-name { font-weight: 600; font-size: 15px; flex: 1; min-width: 200px; width: auto; }
.b-sum { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.block-actions { display: flex; align-items: center; gap: 4px; }
.check-inline { flex-direction: row; align-items: center; gap: 5px; color: var(--text); font-size: 13px; margin-right: 6px; }
.b-params { margin-bottom: 12px; padding: 10px; background: var(--accent-2); border-radius: 6px; }
.b-params label.check { padding-top: 16px; }
.pos-table td { vertical-align: top; }
.pos-table .p-menge, .pos-table .p-preis { width: 90px; min-width: 80px; }
.formel { color: var(--muted); font-size: 11px; margin-top: 2px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.pos-text td { padding-top: 8px; }
tr.row-off td:not(:first-child) { opacity: .45; }
.p-abr, .p-betrag { padding-top: 9px !important; font-size: 13px; }
button:disabled { opacity: .35; cursor: default; }

/* ---------- Vorlagen-Editor ---------- */
.tpl-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; padding: 16px 20px; align-items: start; }
.tpl-list { position: sticky; top: 112px; max-height: calc(100vh - 130px); overflow: auto; padding: 12px; }
.tpl-list input { margin-bottom: 8px; }
.tpl-kat { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 12px 4px 4px; }
.tpl-item { display: block; padding: 7px 9px; border-radius: 6px; text-decoration: none; color: var(--text); }
.tpl-item small { display: block; color: var(--muted); font-size: 12px; }
.tpl-item:hover { background: #f0f3f6; }
.tpl-item.active { background: var(--accent-2); box-shadow: inset 3px 0 0 var(--accent); }
.tpl-editor { display: grid; gap: 16px; }
#posTable .q-menge { min-width: 220px; }
#posTable .q-preis { width: 100px; }
#posTable .q-key { min-width: 220px; }
#posTable .q-artnr { margin-top: 4px; }
#paramTable .q-key { min-width: 120px; }
.help { margin-top: 12px; font-size: 13px; }
.help ul { margin: 6px 0 0; padding-left: 20px; color: var(--muted); }
.help code { background: #eef1f4; padding: 1px 5px; border-radius: 4px; color: var(--text); }
@media (max-width: 900px) { .tpl-layout { grid-template-columns: 1fr; } .tpl-list { position: static; max-height: 260px; } }
@media print { .block, .add-tpl, .tpl-layout { display: none !important; } }
.form, #blocks, .tpl-editor { grid-template-columns: minmax(0, 1fr); }
.block-head .b-name { min-width: 160px; }
#posTable .q-abr { min-width: 130px; }
#posTable .q-preis { width: 160px; } .opt-row td { padding-top: 0; } .opt-row label { font-size: 11.5px; } #ruleTable .r-bed { min-width: 240px; }
#posTable .q-key { min-width: 190px; } #posTable .q-menge { min-width: 170px; } #posTable .q-preis { width: 140px; } #posTable .q-abr { min-width: 115px; }
#posTable .q-bez { min-width: 160px; }

.fg-box { margin-top: 12px; border: 1px solid var(--line); border-radius: 6px; background: #0f1d29; }
.fg-actions { padding: 6px 8px; border-bottom: 1px solid #23394d; text-align: right; }
.fg-actions .ghost { background: transparent; color: #cfe3f3; border-color: #3a5a75; }
#fgOut { margin: 0; padding: 10px 12px; color: #d8e6f2; font: 12px/1.45 Consolas, "Cascadia Mono", monospace; max-height: 420px; overflow: auto; white-space: pre; }
.small-btn { padding: 3px 10px; font-size: 13px; }
.card .btn.ghost { background: #fff; color: var(--accent); }

.note { background: #eef3f7; color: #34495e; border-left: 3px solid #8aa4bb; border-radius: 5px; padding: 6px 10px; margin-bottom: 6px; font-size: 13px; }
.b-rules { margin: -4px 0 12px; display: grid; gap: 4px; }
.b-rules-title { font-size: 12px; color: var(--muted); }
.rule-item { flex-direction: row; align-items: flex-start; gap: 8px; font-size: 12.5px; color: var(--text); padding: 4px 8px; border-radius: 5px; cursor: pointer; }
.rule-item.is-note { background: #f3f6f9; }
.rule-item.is-warn { background: var(--warn-bg); }
.rule-item input { margin-top: 2px; }
.rule-item:has(input:not(:checked)) .rule-txt { text-decoration: line-through; color: var(--muted); }
.rule-art { font-weight: 600; min-width: 58px; color: var(--muted); }
#ruleTable .r-art { min-width: 100px; }

.logo-row { display: flex; gap: 16px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.logo-preview { width: 220px; height: 70px; border: 1px dashed var(--line); border-radius: 6px; display: flex; align-items: center; justify-content: center; background: #fafbfc; color: var(--muted); font-size: 12.5px; }
.logo-preview img { max-width: 200px; max-height: 60px; }

.preview-table .t-sub2 td { font-style: italic; padding-top: 6px; }
.block-cloud { border-left-color: #f0a500; }
.badge { background: #f0a500; color: #1b2430; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; text-transform: uppercase; letter-spacing: .04em; }
.cloud-sub h3 { margin: 0; font-size: 13.5px; }
.cloud-sub { margin-bottom: 12px; }
.cloud-grid { padding: 10px; background: var(--accent-2); border-radius: 6px; margin-bottom: 10px; }
.cloud-fg summary { font-size: 13px; }
.small-sel { width: auto; font-size: 13px; padding: 3px 6px; }
.c-vms .f-name { min-width: 100px; } .c-vms .f-os { min-width: 100px; }
#cloudSelect { flex: 1; min-width: 220px; width: auto; }
.fg-box pre { margin: 0; padding: 10px 12px; color: #d8e6f2; font: 12px/1.45 Consolas, "Cascadia Mono", monospace; max-height: 420px; overflow: auto; white-space: pre; }

/* ---------- Anmeldung / Benutzer ---------- */
.navrow .usermenu { margin-left: auto; display: flex; gap: 2px; align-items: center; }
.usermenu a { color: rgba(255,255,255,.8); text-decoration: none; padding: 7px 10px; border-radius: 6px 6px 0 0; font-size: 13px; }
.usermenu a:hover, .usermenu a.active { color: #fff; background: rgba(255,255,255,.08); }
.usermenu small { background: #f0a500; color: #1b2430; border-radius: 8px; padding: 0 6px; font-size: 10.5px; font-weight: 700; margin-left: 4px; }
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #12344d; }
.auth-card { width: min(400px, calc(100vw - 32px)); padding: 28px; }
.auth-brand { font-weight: 700; font-size: 20px; color: #12344d; margin-bottom: 14px; }
.auth-brand span { display: block; font-weight: 400; font-size: 12.5px; color: var(--muted); }
.auth-form { display: grid; gap: 12px; margin-top: 8px; }
.auth-form button { padding: 9px; font-weight: 600; }
.admin.narrow { max-width: 900px; margin: 0 auto; }
.pw-box code.pw { font-size: 16px; background: #eef1f4; padding: 3px 8px; border-radius: 4px; letter-spacing: .05em; }
#userTable input { min-width: 120px; }
.mine { color: #fff; font-size: 12.5px; margin: 0 6px 0 0; }
#userTable select { min-width: 130px; }

.sso-btn { display: block; text-align: center; padding: 10px; font-weight: 600; margin: 6px 0 14px; }
.local-login { margin-top: 6px; } .local-login summary { font-size: 13px; color: var(--muted); }
.src { font-size: 11.5px; padding: 1px 7px; border-radius: 8px; background: #eef1f4; color: var(--muted); }
.src-zitadel { background: #e6f0fb; color: #0b5e8e; }
select:disabled, input:disabled { background: #f3f5f7; color: var(--muted); }
