:root {
  --bg: #f4f6f7;
  --surface: #ffffff;
  --ink: #1d2a36;
  --ink-2: #4a5866;
  --muted: #6b7782;
  --line: #d8dfe4;
  --line-2: #e8edf0;
  --accent: #1f5f8b;
  --accent-ink: #ffffff;
  --accent-soft: #e5eff6;
  --nav-bg: #17324a;
  --nav-ink: #c7d6e2;
  --nav-active: #ffffff;
  --ok: #1e7a46;      --ok-soft: #e3f3ea;
  --warn: #9a6100;    --warn-soft: #fbf1dc;
  --bad: #b3261e;     --bad-soft: #fbe6e4;
  --radius: 6px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .2rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: .95rem; margin: 1.2rem 0 .4rem; }
.sub { color: var(--muted); margin: 0 0 1.2rem; font-size: .9rem; }
.small, small { font-size: .82rem; color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side {
  background: var(--nav-bg); color: var(--nav-ink); padding: 1rem 0 2rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { padding: 0 1.1rem .9rem; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: .6rem; }
.brand b { color: #fff; font-size: 1.02rem; display: block; }
.brand span { font-size: .78rem; opacity: .75; }
.side nav a {
  display: block; padding: .32rem 1.1rem; color: var(--nav-ink); font-size: .88rem;
  border-left: 3px solid transparent;
}
.side nav a:hover { background: rgba(255,255,255,.05); text-decoration: none; color: #fff; }
.side nav a.active { color: var(--nav-active); border-left-color: #6fb3e0; background: rgba(255,255,255,.07); }
.side nav .grp {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; opacity: .6;
  padding: .9rem 1.1rem .25rem;
}
.side nav a .code { font-family: var(--mono); font-size: .72rem; opacity: .65; display: inline-block; min-width: 2.6em; }
.main { min-width: 0; }
.topbar {
  display: flex; gap: 1rem; align-items: center; justify-content: space-between;
  padding: .6rem 1.6rem; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar .who { font-size: .85rem; color: var(--ink-2); display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
.content { padding: 1.4rem 1.6rem 4rem; max-width: 1280px; }
.navtoggle, .navtoggle-label { display: none; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: .6rem 0; }
  .side nav { display: none; }
  .navtoggle:checked ~ nav { display: block; }
  .navtoggle-label {
    display: inline-block; margin: 0 1.1rem; padding: .3rem .7rem; border: 1px solid rgba(255,255,255,.25);
    border-radius: var(--radius); color: #fff; font-size: .85rem; cursor: pointer;
  }
  .brand { display: flex; justify-content: space-between; align-items: center; border: 0; margin: 0; }
  .content { padding: 1rem 1rem 3rem; }
  .topbar { padding: .5rem 1rem; position: static; }
}

/* ---------- Bausteine ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
.grid.k4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid.k2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
@media (max-width: 960px) { .grid.k4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .grid.k2 { grid-template-columns: 1fr; } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.kpi .v { font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi .l { font-size: .8rem; color: var(--muted); }
.kpi.bad .v { color: var(--bad); }
.kpi.warn .v { color: var(--warn); }

.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: 0 0 1rem; }
.toolbar .spacer { flex: 1; }
.head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }

.btn, button {
  display: inline-flex; align-items: center; gap: .35rem; font: inherit; font-size: .87rem;
  padding: .42rem .85rem; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover, button:hover { border-color: #b7c3cc; text-decoration: none; }
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover, button.primary:hover { background: #184e74; }
.btn.small, button.small { padding: .2rem .55rem; font-size: .8rem; }
.btn.danger, button.danger { color: var(--bad); }
.inline { display: inline; }

table.list { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .88rem; }
table.list th {
  text-align: left; font-weight: 600; font-size: .78rem; color: var(--ink-2); text-transform: uppercase;
  letter-spacing: .03em; padding: .5rem .6rem; border-bottom: 2px solid var(--line); background: #fafbfc;
}
table.list td { padding: .45rem .6rem; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.list tr:hover td { background: #f8fafb; }
table.list td.code { font-family: var(--mono); font-size: .8rem; color: var(--muted); white-space: nowrap; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.tablewrap table.list { border: 0; }

.badge {
  display: inline-block; font-size: .74rem; font-weight: 600; padding: .1rem .5rem; border-radius: 99px;
  background: var(--line-2); color: var(--ink-2); white-space: nowrap;
}
.badge.ueberfaellig, .badge.nie, .badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.bald, .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }

.flash { padding: .6rem .9rem; border-radius: var(--radius); margin-bottom: .6rem; font-size: .9rem; border: 1px solid; }
.flash.ok { background: var(--ok-soft); border-color: #b9dfc9; color: #155c34; }
.flash.error { background: var(--bad-soft); border-color: #f0c2bd; color: #8a1d16; }
.flash.warn { background: var(--warn-soft); border-color: #ecd4a2; color: #6e4600; }
.flash.info { background: var(--accent-soft); border-color: #c4dbea; color: #174a6c; }

ul.warnlist { list-style: none; margin: 0; padding: 0; }
ul.warnlist li { display: flex; gap: .6rem; padding: .4rem 0; border-bottom: 1px solid var(--line-2); font-size: .9rem; align-items: baseline; }
ul.warnlist li:last-child { border-bottom: 0; }

/* ---------- Formulare ---------- */
form.data { display: grid; grid-template-columns: repeat(12, minmax(0,1fr)); gap: .75rem 1rem; }
form.data .f { grid-column: span 12; }
form.data .f.half { grid-column: span 6; }
form.data .f.third { grid-column: span 4; }
form.data .f.quarter { grid-column: span 3; }
form.data .sec {
  grid-column: span 12; font-weight: 650; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: .3rem; margin-top: .8rem;
}
@media (max-width: 700px) { form.data .f.half, form.data .f.third, form.data .f.quarter { grid-column: span 12; } }
label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-2); margin-bottom: .2rem; }
label .req { color: var(--bad); }
.unitwrap { display: flex; align-items: stretch; }
.unitwrap input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.unitwrap .unit {
  display: flex; align-items: center; padding: 0 .55rem; border: 1px solid var(--line); border-left: 0;
  border-radius: 0 var(--radius) var(--radius) 0; background: #f6f8f9; color: var(--muted); font-size: .82rem;
  white-space: nowrap;
}
input[type=text], input[type=password], input[type=date], input[type=number], input[type=email], input:not([type]),
select, textarea {
  width: 100%; font: inherit; font-size: .92rem; padding: .42rem .55rem; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc7e6; outline-offset: 0; border-color: var(--accent); }
textarea { resize: vertical; }
.check { display: flex; gap: .45rem; align-items: center; font-weight: 500; font-size: .9rem; color: var(--ink); padding-top: .3rem; }
.check input { width: auto; }
.help { font-size: .76rem; color: var(--muted); margin-top: .15rem; }
.formactions { grid-column: span 12; display: flex; gap: .6rem; margin-top: .6rem; padding-top: .9rem; border-top: 1px solid var(--line); }
input::placeholder { color: #8b98a3; }

dl.kv { display: grid; grid-template-columns: minmax(180px, 32%) 1fr; margin: 0; font-size: .9rem; }
dl.kv dt { color: var(--muted); padding: .38rem .6rem .38rem 0; border-bottom: 1px solid var(--line-2); font-size: .84rem; }
dl.kv dd { margin: 0; padding: .38rem 0; border-bottom: 1px solid var(--line-2); white-space: pre-wrap; }
dl.kv .sec { grid-column: 1 / -1; font-weight: 650; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); padding: .9rem 0 .25rem; border-bottom: 1px solid var(--line); }
@media (max-width: 700px) { dl.kv { grid-template-columns: 1fr; } dl.kv dt { border: 0; padding-bottom: 0; } }

.rowform { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.rowform input[type=date] { width: 9.5rem; }
.rowform select { width: auto; }
.rowform input[type=text] { width: 12rem; }

.erfassung td input[type=text] { min-width: 7rem; }
.erfassung td.last { color: var(--muted); font-size: .82rem; white-space: nowrap; }

.login { max-width: 380px; margin: 9vh auto; }
.login .card { padding: 1.6rem; }
.login h1 { font-size: 1.25rem; }
.chart { width: 100%; height: auto; display: block; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 1.2rem; text-align: center; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.mt { margin-top: 1rem; }
.narrow { max-width: 520px; }
table.list .rowform { flex-wrap: nowrap; }
table.list .rowform input[type=date] { width: 8.6rem; }
table.list .rowform input[type=text] { width: 9rem; }
table.list .rowform select { max-width: 11rem; }
@media (max-width: 860px) { table.list .rowform { flex-wrap: wrap; } }

.brand .produkt { display: block; color: #e6eef4; font-size: .82rem; opacity: .9; }
.login .firma { margin: 0 0 .2rem; font-weight: 700; color: var(--accent); letter-spacing: .02em; }

/* Hafner & Schalli */
.brand { display: flex; gap: .7rem; align-items: center; }
.brand .logo { width: 38px; height: 38px; background: #fff; border-radius: 6px; padding: 3px; flex: none; }
.brand > div { flex: 1; min-width: 0; }
.login .briefkopf { display: flex; align-items: center; gap: .8rem; margin-bottom: .6rem; }
.login .briefkopf img { width: 52px; height: 52px; }
.login .firma { font-weight: 700; font-size: 1.15rem; color: #2b8bb8; }
.balken { display: flex; height: 5px; margin: 0 0 1.1rem; }
.balken i { flex: 1; }
.balken i:nth-child(1) { background: #f0e448; }
.balken i:nth-child(2) { background: #90c03c; }
.balken i:nth-child(3) { background: #54c0e4; }
