/* 3D-Druck Kalkulator – mobile first */
:root {
  --bg: #f3f1ec;
  --surface: #ffffff;
  --ink: #1f2a33;
  --ink-2: #4d5a65;
  --muted: #7b8792;
  --line: #dcd8cf;
  --line-2: #ebe8e1;
  --accent: #e8650f;
  --accent-ink: #ffffff;
  --accent-soft: #fdeee3;
  --ok: #2f7d4f;
  --ok-soft: #e5f2ea;
  --warn: #9a6a00;
  --warn-soft: #fbf2d9;
  --err: #b3261e;
  --err-soft: #fbe6e4;
  --top: #1f2a33;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; border-radius: 0; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--sans); }
a { color: var(--accent); }
h1 { font-size: 1.45rem; margin: 0; line-height: 1.2; }
h2 { font-size: 1.05rem; margin: 1.4rem 0 .6rem; letter-spacing: .01em; }
.card > h2:first-child, .card > form > h2:first-child { margin-top: 0; }
p { margin: .4rem 0 .8rem; }
small { color: var(--muted); display: block; margin-top: .25rem; font-size: .82rem; }
.muted { color: var(--muted); font-size: .9rem; }
code { font-family: var(--mono); background: var(--line-2); padding: 0 .25em; }

/* Kopfzeile */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem; background: var(--top); color: #fff; padding: 0 16px; min-height: 54px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .55rem; color: #fff; text-decoration: none; font-weight: 600; }
.brand__mark { background: var(--accent); color: #fff; font: 700 .85rem/1 var(--mono); padding: .4rem .45rem; }
.brand__text { letter-spacing: .02em; }
.nav-toggle { margin-left: auto; background: none; border: 0; padding: 12px 4px; cursor: pointer; display: flex; flex-direction: column; gap: 5px; }
.nav-toggle span { display: block; width: 24px; height: 2px; background: #fff; }
.mainnav { display: none; width: 100%; flex-direction: column; padding-bottom: .5rem; }
.mainnav.is-open { display: flex; }
.mainnav a { color: #d9e0e6; text-decoration: none; padding: .7rem 0; border-top: 1px solid #2f3c47; }
.mainnav a.is-active { color: #fff; box-shadow: inset 3px 0 0 var(--accent); padding-left: .7rem; }
.mainnav__logout { color: #9fb0bd !important; }

@media (min-width: 960px) {
  .nav-toggle { display: none; }
  .mainnav { display: flex; flex-direction: row; width: auto; margin-left: auto; padding: 0; gap: .2rem; }
  .mainnav a { border: 0; padding: 1rem .7rem; font-size: .93rem; }
  .mainnav a.is-active { box-shadow: inset 0 -3px 0 var(--accent); padding-left: .7rem; }
}

/* Seite */
.page { max-width: 1180px; margin: 0 auto; padding: 18px 16px 90px; }
.page--narrow { max-width: 460px; margin: 0 auto; }
.pagehead { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-start; justify-content: space-between; margin-bottom: 1rem; }
.pagehead__sub { color: var(--ink-2); max-width: 70ch; margin: .35rem 0 0; font-size: .95rem; }
.pagehead__actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 0 0 2rem; }

.card { background: var(--surface); border: 1px solid var(--line); padding: 16px; margin-bottom: 14px; }
.cols { display: grid; gap: 14px; }
.cols > .card, .cols > div > .card:last-child { margin-bottom: 0; }
@media (min-width: 960px) {
  .cols { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
  .cols > .breakdown { position: sticky; top: 70px; }
}
.grid2 { display: grid; gap: 0 14px; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }

/* Meldungen */
.flash { padding: .7rem .9rem; margin-bottom: 12px; border-left: 4px solid; font-size: .95rem; }
.flash--ok { background: var(--ok-soft); border-color: var(--ok); }
.flash--warn { background: var(--warn-soft); border-color: var(--warn); }
.flash--err { background: var(--err-soft); border-color: var(--err); }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 42px; padding: .5rem 1rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: .95rem; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink-2); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn--primary:hover { background: #cf590b; border-color: #cf590b; }
.btn--danger { color: var(--err); border-color: #e7b9b5; }
.btn--danger:hover { background: var(--err); color: #fff; border-color: var(--err); }
.btn--sm { min-height: 36px; padding: .35rem .75rem; font-size: .88rem; }
.btn--icon { min-height: 36px; min-width: 36px; padding: 0; font-size: 1.05rem; }

/* Formulare */
.form .field, .field { display: block; margin-bottom: 12px; }
.field > span:first-child { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-2); margin-bottom: .3rem; }
input[type=text], input[type=email], input[type=password], input[type=search], input:not([type]), select, textarea {
  width: 100%; min-height: 44px; padding: .55rem .65rem; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-size: 16px;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
input[readonly] { background: var(--line-2); }
.input-suffix { display: flex; }
.input-suffix input { flex: 1; min-width: 0; }
.input-suffix em { font-style: normal; display: flex; align-items: center; padding: 0 .6rem; background: var(--line-2); border: 1px solid var(--line); border-left: 0; color: var(--ink-2); font-size: .88rem; white-space: nowrap; }
.duration { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.colorpick input { width: 70px; height: 44px; padding: 2px; border: 1px solid var(--line); background: #fff; }
.check { display: flex; align-items: center; gap: .55rem; margin: .4rem 0 .9rem; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.form__actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; margin-top: .8rem; }
.form__actions--sticky { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 35%); padding: 18px 0 10px; z-index: 5; }
.form--inline { display: inline-block; margin: 0 .3rem .3rem 0; }
.filter { margin-bottom: 12px; }

/* Listen */
.list { list-style: none; margin: 0 0 14px; padding: 0; background: var(--surface); border: 1px solid var(--line); }
.list__item + .list__item { border-top: 1px solid var(--line-2); }
.list__item > a, .list__row { display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem; color: inherit; text-decoration: none; }
.list__row { flex-wrap: wrap; }
.list__item > a:hover { background: #faf9f6; }
.list__item.is-muted { opacity: .55; }
.list__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.list__title { font-weight: 600; overflow-wrap: anywhere; }
.list__meta { color: var(--muted); font-size: .85rem; }
.list__value { font: 600 .92rem var(--mono); white-space: nowrap; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; }
.list__value.is-warn { color: var(--warn); }
.list__actions { display: flex; flex-wrap: wrap; gap: .2rem; }
.swatch { display: inline-block; width: 22px; height: 22px; border: 1px solid rgba(0,0,0,.18); flex: none; vertical-align: middle; }
.plain { margin: 0 0 1rem; padding-left: 1.2rem; }
.plain-ol { margin: 0; padding-left: 1.3rem; }
.plain-ol li { margin: .3rem 0; }

/* Kacheln */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { display: flex; flex-direction: column; gap: .2rem; padding: 14px; background: var(--surface); border: 1px solid var(--line); color: inherit; text-decoration: none; border-top: 3px solid var(--accent); }
.tile:hover { border-color: var(--ink-2); border-top-color: var(--accent); }
.tile__title { font-weight: 600; }
.tile__count { font: 700 1.6rem var(--mono); }
.tile__sub { color: var(--accent); font-size: .82rem; font-weight: 600; }
.tile__text { color: var(--muted); font-size: .82rem; }
.quick { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 18px; }

/* Kosten-Aufschlüsselung */
.kvlist { display: flex; flex-direction: column; }
.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .42rem 0; border-bottom: 1px solid var(--line-2); font-size: .93rem; }
.kv > span:last-child { font-family: var(--mono); white-space: nowrap; text-align: right; }
.kv--sub { padding-left: .8rem; color: var(--ink-2); font-size: .86rem; }
.kv--strong { font-weight: 600; }
.kv--total { font-weight: 700; font-size: 1.05rem; border-bottom: 2px solid var(--ink); }
.kv--muted { color: var(--muted); font-size: .86rem; }
.kv--pos > span:last-child { color: var(--ok); font-weight: 700; }
.kv--neg > span:last-child { color: var(--err); font-weight: 700; }
.result { font: 600 .95rem var(--mono); color: var(--ink-2); }

/* Zeilen (Filament, Arbeit) */
.lines { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.linerow { display: grid; grid-template-columns: 1fr 76px 40px; gap: 6px; align-items: center; }
.linerow .linerow__main { grid-column: 1 / -1; }
.linerow:has(.input-suffix) { grid-template-columns: 1fr 40px; }
.linerow:has(.input-suffix) .linerow__main { grid-column: 1 / -1; }
@media (min-width: 640px) {
  .linerow { grid-template-columns: 1fr 110px 70px 40px; }
  .linerow .linerow__main { grid-column: auto; }
  .linerow:has(.input-suffix) { grid-template-columns: 1fr 140px 40px; }
  .linerow:has(.input-suffix) .linerow__main { grid-column: auto; }
}
.linerow { padding-bottom: 8px; border-bottom: 1px dashed var(--line-2); }

/* Positionen */
.items { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.item { border: 1px solid var(--line); border-left: 4px solid var(--ink-2); background: #fcfbf9; }
.item[data-type=part] { border-left-color: var(--accent); }
.item[data-type=hardware] { border-left-color: #5b7c99; }
.item[data-type=work] { border-left-color: #7d5ba6; }
.item[data-type=shipping] { border-left-color: #3f8f7a; }
.item[data-type=custom] { border-left-color: #8a8a8a; }
.item__head { display: flex; align-items: center; gap: .6rem; padding: .45rem .5rem .45rem .8rem; border-bottom: 1px solid var(--line-2); }
.item__sum { margin-left: auto; font: 700 .95rem var(--mono); white-space: nowrap; }
.item__tools { display: flex; gap: 2px; }
.item__head .item__sum + .item__tools { margin-left: .4rem; }
.item__head > .tag + .item__tools { margin-left: auto; }
.item__body { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; padding: .7rem .8rem 0; }
.item__body .field { margin-bottom: 10px; }
.item__main { grid-column: 1 / -1; }
@media (min-width: 640px) { .item__body { grid-template-columns: 2fr 1fr 1fr; } .item__main { grid-column: auto; } }
.item__calc { display: flex; flex-wrap: wrap; gap: .3rem 1rem; padding: 0 .8rem .55rem; color: var(--ink-2); font: .8rem var(--mono); }
.item__more { border-top: 1px solid var(--line-2); }
.item__more summary { cursor: pointer; padding: .5rem .8rem; color: var(--ink-2); font-size: .86rem; }
.addbar { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }

.tag { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: .15rem .4rem; background: var(--line-2); color: var(--ink-2); vertical-align: middle; }
.tag--part { background: var(--accent-soft); color: #a8470a; }
.tag--private { background: #e6ebf0; color: #3d5466; font-size: .66rem; }
.badge { display: inline-block; min-width: 1.4em; padding: 0 .35em; background: var(--accent); color: #fff; font-size: .78rem; text-align: center; }

/* Tabellen */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.num { text-align: right !important; font-family: var(--mono); white-space: nowrap; }

/* Freigaben */
.sharebox { border: 1px solid var(--line); margin: 12px 0; background: #fcfbf9; }
.sharebox summary { cursor: pointer; padding: .7rem .9rem; font-weight: 600; }
.sharebox > :not(summary) { margin-left: .9rem; margin-right: .9rem; }
.checklist { padding-bottom: .4rem; }
.checklist .check { margin: .3rem 0 .6rem; }
.sharedbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; padding: .7rem .9rem; margin-bottom: 14px; background: #e6ebf0; border-left: 4px solid #3d5466; }

/* Dropdown */
.dropdown { position: relative; }
.dropdown > summary { list-style: none; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown > summary::after { content: "▾"; margin-left: .3rem; }
.dropdown__menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 220px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0,0,0,.12); display: flex; flex-direction: column; }
.dropdown__menu a { padding: .7rem .9rem; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line-2); }
.dropdown__menu a:hover { background: var(--accent-soft); }

/* Vorschläge */
.proposal__head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; justify-content: space-between; margin-bottom: .3rem; }
.proposal__actions { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.proposal__merge { display: inline-flex; gap: .3rem; flex-wrap: wrap; }
.proposal__merge select { width: auto; max-width: 100%; min-height: 36px; }
.copyfield { display: flex; gap: .4rem; }
.copyfield input { flex: 1; font-family: var(--mono); font-size: .85rem; }

/* Überbreite durch lange Auswahltexte verhindern */
.cols > *, .item__body > *, .linerow > *, .grid2 > * { min-width: 0; }
select { max-width: 100%; text-overflow: ellipsis; }
.item__head { flex-wrap: wrap; row-gap: .3rem; }
.item__head .tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 420px) { .item__tools .btn--icon { min-width: 32px; min-height: 32px; } }

[data-add-line]:not([data-template-name]) { margin-bottom: 1rem; }

/* Passwort anzeigen */
.pwfield { display: flex; }
.pwfield input { flex: 1; min-width: 0; }
.pwfield__toggle { flex: none; min-width: 92px; border: 1px solid var(--line); border-left: 0; background: var(--line-2); color: var(--ink-2); font: inherit; font-size: .85rem; cursor: pointer; }
.pwfield__toggle:hover { color: var(--ink); }
.pagehead__actions .btn + .btn { margin-left: 0; }

/* Farben */
.swatch--sm { width: 14px; height: 14px; margin-right: .35rem; vertical-align: -2px; }
.swatch--xl { width: 72px; height: 72px; flex: none; }
.swatches { display: inline-flex; gap: 2px; margin-right: .3rem; vertical-align: -2px; }
.swatches .swatch--sm { margin-right: 0; }
.colorpick { display: flex; gap: 6px; align-items: stretch; }
.colorpick input[type=color] { width: 56px; min-height: 44px; padding: 2px; border: 1px solid var(--line); background: #fff; flex: none; cursor: pointer; }
.colorpick input[type=text] { flex: 1; min-width: 0; font-family: var(--mono); text-transform: uppercase; }
.colorcard { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); padding: 12px 16px; margin-bottom: 14px; }
.colorcard div { display: flex; flex-direction: column; gap: .2rem; }
.colorcard span { font: .9rem var(--mono); color: var(--ink-2); }
.refbox { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; align-items: baseline; padding: .7rem .9rem; margin-bottom: 14px; background: var(--accent-soft); border-left: 4px solid var(--accent); }
.refbox small { flex-basis: 100%; margin: 0; }
.grid3 { display: grid; gap: 0 14px; }
@media (min-width: 640px) { .grid3 { grid-template-columns: repeat(3, 1fr); } }
.table tr.is-current td { background: var(--accent-soft); }
select[data-color-select] { transition: border-left-width .1s; }

/* Import */
.importhelp { background: #fcfbf9; border: 1px solid var(--line-2); padding: .6rem .8rem; margin-bottom: 12px; font-size: .9rem; overflow-wrap: anywhere; }
.importhelp p { margin: .3rem 0; }
.importcounts { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 12px; }
.status { display: inline-block; padding: .15rem .45rem; font-size: .78rem; font-weight: 700; white-space: nowrap; background: var(--line-2); color: var(--ink-2); }
.status--new { background: var(--ok-soft); color: var(--ok); }
.status--update { background: #e6ebf0; color: #3d5466; }
.status--skip { background: var(--line-2); color: var(--muted); }
.status--error { background: var(--err-soft); color: var(--err); }
.card--flush { padding: 0; overflow-x: auto; }
.importtable td, .importtable th { font-size: .86rem; }
.importtable tr.is-error td { background: #fff7f6; }
.form__actions--left { justify-content: flex-start; margin: 0 0 12px; }
.list--plain .list__row { justify-content: space-between; }

.kv--text > span:last-child { white-space: normal; font-family: var(--sans); }
