/* ==========================================================================
   Cramer Mühle · Laborportal — Design-Tokens
   ========================================================================== */
@property --e-t { syntax: '<length>'; inherits: true; initial-value: 0px; }
@property --e-b { syntax: '<length>'; inherits: true; initial-value: 0px; }
@property --e-l { syntax: '<length>'; inherits: true; initial-value: 0px; }
@property --e-r { syntax: '<length>'; inherits: true; initial-value: 0px; }

:root {
  /* warme Basis */
  --base: #efe8d8;
  --base-2: #e7dec8;
  /* hellere beige Flächen (halbtransparent) */
  --panel: rgba(250, 246, 236, 0.72);
  --panel-solid: #f9f5ea;
  --panel-2: rgba(243, 236, 219, 0.9);
  /* Text */
  --ink: #2b261d;
  --ink-2: #5a5244;
  --muted: #857b69;
  /* Linien */
  --line: rgba(122, 96, 44, 0.20);
  --line-soft: rgba(122, 96, 44, 0.12);
  /* Gold */
  --gold: #b8902a;
  --gold-hi: #e2bd62;
  --gold-lo: #8a6a1c;
  --gold-soft: rgba(226, 189, 98, 0.22);
  --gold-glow: rgba(214, 172, 70, 0.35);
  /* Status */
  --ok: #3f7a52;
  --bad: #a8322a;
  --warn: #a86f16;
  --radius: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font: 14.5px/1.5 "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background:
    radial-gradient(1100px 620px at 92% -12%, rgba(226, 189, 98, 0.26), transparent 62%),
    radial-gradient(900px 560px at -8% 112%, rgba(184, 144, 42, 0.16), transparent 60%),
    linear-gradient(180deg, #f2ecdf 0%, var(--base) 55%, var(--base-2) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold-lo); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; font-weight: 650; letter-spacing: -0.015em; margin: 0 0 1.1rem; color: var(--ink); }
h3 { font-size: 0.8rem; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-2); margin: 0 0 0.75rem; }
.muted { color: var(--muted); }
.err { color: var(--bad); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }

/* ==========================================================================
   App-Shell: Icon-Rail links, Topbar oben, Inhalt
   ========================================================================== */
.app {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  grid-template-rows: 66px minmax(0, 1fr);
  min-height: 100vh;
}
.rail {
  grid-row: 1 / span 2;
  grid-column: 1;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0 14px;
  background: linear-gradient(180deg, rgba(250, 246, 236, 0.78), rgba(243, 236, 219, 0.62));
  border-right: 1px solid var(--line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.rail-mark {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.82rem; letter-spacing: 0.06em; color: #fff;
  background: linear-gradient(145deg, var(--gold-hi), var(--gold) 55%, var(--gold-lo));
  box-shadow: 0 0 0 1px rgba(138, 106, 28, 0.35), 0 8px 20px -8px var(--gold-glow);
  margin-bottom: 22px;
}
.rail-nav { position: relative; display: flex; flex-direction: column; gap: 10px; flex: 1; }
/* Gleitender Indikator: beide Kanten werden unabhängig über clip-path animiert */
.rail-ind {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(60px 40px at 50% 30%, rgba(255, 246, 214, 0.9), transparent 70%),
    linear-gradient(160deg, rgba(226, 189, 98, 0.55), rgba(184, 144, 42, 0.30));
  border: 1px solid rgba(184, 144, 42, 0.55);
  box-shadow: 0 0 22px -4px var(--gold-glow), inset 0 1px 0 rgba(255, 255, 255, 0.55);
  clip-path: inset(var(--e-t) var(--e-r) var(--e-b) var(--e-l) round 16px);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.rail-ind.ready { opacity: 1; }
.rail-link {
  position: relative; z-index: 1;
  width: 54px; height: 54px;
  display: grid; place-items: center;
  border-radius: 16px;
  color: var(--ink-2);
  transition: color 0.25s var(--ease), transform 0.25s var(--ease);
}
.rail-link svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rail-link:hover { color: var(--ink); transform: translateY(-1px); text-decoration: none; }
.rail-link.on { color: #5c4310; }
.rail-link:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.rail-foot { margin-top: auto; }
.rail-link.logout { color: var(--muted); }

.topbar {
  grid-column: 2; grid-row: 1;
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 18px;
  padding: 0 26px;
  background: linear-gradient(180deg, rgba(250, 246, 236, 0.85), rgba(250, 246, 236, 0.66));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.topbar .logo { height: 40px; width: auto; display: block; }
.topbar .sep { width: 1px; height: 26px; background: var(--line); }
.topbar .crumb { font-size: 0.82rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold-lo); }
.topbar .who { margin-left: auto; display: flex; align-items: center; gap: 12px; font-weight: 500; color: var(--ink-2); }
.role {
  font-size: 0.68rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase;
  color: #6b4f12; background: var(--gold-soft); border: 1px solid rgba(184, 144, 42, 0.35);
  border-radius: 999px; padding: 0.15rem 0.6rem;
}

.content {
  grid-column: 2; grid-row: 2;
  padding: 26px 30px 40px;
  min-width: 0;
}
.view { max-width: 1320px; }

/* Stagger-Einblendung der Bausteine einer Ansicht */
.view > * { animation: rise 0.62s var(--ease) both; }
.view > *:nth-child(2) { animation-delay: 0.06s; }
.view > *:nth-child(3) { animation-delay: 0.12s; }
.view > *:nth-child(4) { animation-delay: 0.18s; }
.view > *:nth-child(5) { animation-delay: 0.24s; }
.view > *:nth-child(6) { animation-delay: 0.30s; }
.view > *:nth-child(7) { animation-delay: 0.36s; }
.view > *:nth-child(n+8) { animation-delay: 0.40s; }
.kpis > .kpi:nth-child(2) { animation-delay: 0.05s; }
.kpis > .kpi:nth-child(3) { animation-delay: 0.10s; }
.kpis > .kpi:nth-child(4) { animation-delay: 0.15s; }
.kpis > .kpi:nth-child(5) { animation-delay: 0.20s; }
.kpis > .kpi:nth-child(6) { animation-delay: 0.25s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ==========================================================================
   Karten, KPIs, Raster
   ========================================================================== */
.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 18px 40px -26px rgba(90, 66, 16, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
.card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(420px 160px at 100% 0%, rgba(226, 189, 98, 0.13), transparent 70%);
}
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 1rem; }
.grid2 > .card { margin-bottom: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0.9rem; margin-bottom: 1rem; }
.kpi {
  position: relative;
  padding: 1rem 1.1rem 1.05rem;
  border-radius: var(--radius);
  background:
    radial-gradient(160px 90px at 100% 0%, rgba(226, 189, 98, 0.32), transparent 70%),
    var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 16px 34px -24px rgba(90, 66, 16, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; left: 1.1rem; right: 1.1rem; top: 0; height: 2px;
  background: linear-gradient(90deg, var(--gold-hi), var(--gold) 60%, transparent);
  border-radius: 2px;
}
.kpi .v { font-size: 1.85rem; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--ink); line-height: 1.15; }
.kpi .l { margin-top: 0.3rem; font-size: 0.7rem; font-weight: 650; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.kpi.bad .v { color: var(--bad); }
.kpi.bad::after { background: linear-gradient(90deg, #d46a5c, var(--bad) 60%, transparent); }
canvas { max-height: 320px; }

/* ==========================================================================
   Formulare, Buttons, Filter
   ========================================================================== */
.filters {
  display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.85rem 0.95rem; margin-bottom: 1rem;
  backdrop-filter: blur(8px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.filters.slim { margin-bottom: 0.9rem; }
label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.03em; color: var(--muted); }
input, select, textarea {
  font: inherit; font-size: 0.9rem; color: var(--ink);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(122, 96, 44, 0.28);
  border-radius: 10px; padding: 0.5rem 0.65rem; min-width: 150px;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease);
}
input:hover, select:hover, textarea:hover { border-color: rgba(138, 106, 28, 0.5); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); background: #fff; }
textarea { width: 100%; min-height: 84px; }
.login input { width: 100%; min-width: 0; }
.btn {
  font: inherit; font-size: 0.88rem; font-weight: 600; letter-spacing: 0.01em;
  color: #fff; cursor: pointer; border: 1px solid var(--gold-lo);
  background: linear-gradient(180deg, #d9ad4c 0%, #b8902a 55%, #9a7720 100%);
  padding: 0.55rem 1rem; border-radius: 11px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 8px 18px -10px rgba(138, 106, 28, 0.9);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), filter 0.2s var(--ease);
}
.btn:hover { transform: translateY(-1px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 12px 22px -10px rgba(138, 106, 28, 0.95); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn.ghost {
  color: var(--ink-2); background: rgba(255, 255, 255, 0.45);
  border: 1px solid rgba(122, 96, 44, 0.3); box-shadow: none;
}
.btn.ghost:hover { background: rgba(255, 255, 255, 0.8); box-shadow: none; }
.btn.small { padding: 0.3rem 0.65rem; font-size: 0.8rem; border-radius: 9px; }
.fbtn { display: flex; gap: 0.5rem; }

/* Anmeldung */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background:
    radial-gradient(620px 420px at 50% 38%, rgba(226, 189, 98, 0.34), transparent 70%),
    linear-gradient(180deg, #f2ecdf, var(--base-2));
}
.login {
  width: min(400px, 100%); display: flex; flex-direction: column; gap: 0.9rem;
  padding: 2.2rem 2.1rem 1.8rem; text-align: center;
  box-shadow: 0 30px 60px -30px rgba(90, 66, 16, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.login label { text-align: left; }
.login .btn { margin-top: 0.4rem; padding: 0.7rem 1rem; }
.login-logo { width: 230px; margin: 0 auto 0.4rem; }
.login h1 { font-size: 1.3rem; margin: 0; }
.footer-note { color: var(--muted); font-size: 0.76rem; margin-top: 1.1rem; text-align: center; letter-spacing: 0.02em; }

/* ==========================================================================
   Tabellen, Badges, Details
   ========================================================================== */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th {
  font-size: 0.68rem; font-weight: 650; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted);
  background: var(--panel-2); position: sticky; top: 0; border-bottom: 1px solid var(--line);
}
tbody tr { transition: background 0.2s var(--ease); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: rgba(226, 189, 98, 0.16); }
.pager { display: flex; gap: 0.7rem; align-items: center; justify-content: flex-end; margin-top: 0.9rem; font-size: 0.86rem; color: var(--muted); }

.badge { display: inline-block; font-size: 0.72rem; font-weight: 600; padding: 0.15rem 0.55rem; border-radius: 999px; white-space: nowrap; border: 1px solid transparent; }
.badge.ok { background: rgba(63, 122, 82, 0.12); color: var(--ok); border-color: rgba(63, 122, 82, 0.25); }
.badge.bad { background: rgba(168, 50, 42, 0.1); color: var(--bad); border-color: rgba(168, 50, 42, 0.25); }
.badge.warn { background: rgba(168, 111, 22, 0.12); color: var(--warn); border-color: rgba(168, 111, 22, 0.3); }
.badge.muted { background: rgba(122, 110, 90, 0.1); color: var(--muted); border-color: rgba(122, 110, 90, 0.2); }

dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: 0.45rem 1.2rem; margin: 0 0 0.6rem; }
dl.meta dt { color: var(--muted); font-size: 0.8rem; }
dl.meta dd { margin: 0; font-weight: 500; }
.flags { margin: 0.7rem 0 0; padding-left: 1.1rem; color: var(--warn); font-size: 0.86rem; }
.note { border-left: 2px solid var(--gold); padding: 0.5rem 0.8rem; margin: 0.55rem 0; background: rgba(226, 189, 98, 0.1); border-radius: 0 10px 10px 0; }
.note .by { font-size: 0.76rem; color: var(--muted); margin-top: 0.2rem; }
.note-form { margin-top: 0.9rem; display: grid; gap: 0.55rem; }
.caveat {
  font-size: 0.84rem; color: var(--ink-2);
  background: rgba(226, 189, 98, 0.14); border: 1px solid rgba(184, 144, 42, 0.25);
  border-left: 3px solid var(--gold); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.7rem 0.9rem; margin-top: 0.5rem;
}
.toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  background: rgba(43, 38, 29, 0.92); color: #f7f1e1; padding: 0.7rem 1.1rem; border-radius: 12px;
  font-size: 0.88rem; box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.5); z-index: 50;
  border: 1px solid rgba(226, 189, 98, 0.35);
  animation: rise 0.4s var(--ease) both;
}
.foot { text-align: center; font-size: 0.74rem; letter-spacing: 0.02em; color: var(--muted); padding: 2.2rem 0 0; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ==========================================================================
   Responsiv: unten liegende Icon-Leiste auf dem Smartphone
   ========================================================================== */
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: 58px minmax(0, 1fr) 70px; }
  .rail {
    grid-row: 3; grid-column: 1; position: fixed; top: auto; bottom: 0; left: 0; right: 0;
    height: 70px; flex-direction: row; justify-content: center; padding: 0 10px;
    border-right: 0; border-top: 1px solid var(--line);
  }
  .rail-mark { display: none; }
  .rail-nav { flex-direction: row; flex: 0; gap: 4px; }
  .rail-link { width: 50px; height: 50px; }
  .rail-foot { margin: 0 0 0 8px; }
  .topbar { grid-column: 1; grid-row: 1; padding: 0 14px; gap: 10px; }
  .topbar .sep, .topbar .who span:first-child { display: none; }
  .topbar .logo { height: 30px; }
  .content { grid-column: 1; grid-row: 2; padding: 16px 14px 90px; }
  .split { grid-template-columns: 1fr; }
  h1 { font-size: 1.3rem; }
}

/* ==========================================================================
   Barrierefreiheit: reduzierte Bewegung respektieren
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Tägliche Messungen: Arbeitsblatt-Eingabe mit Grenzwert-Farben
   ========================================================================== */
.page-head { margin-bottom: 0.4rem; }
.page-head h1 { margin-bottom: 0.25rem; }
.sub { font-size: 0.86rem; margin: 0 0 1rem; }
.tiny { font-size: 0.8rem; margin: 0.7rem 0 0; }
.legend { font-weight: 600; padding: 0.05rem 0.45rem; border-radius: 6px; }
.legend.ok { background: rgba(63, 122, 82, 0.16); color: #2d5e3d; }
.legend.bad { background: rgba(168, 50, 42, 0.14); color: #8c2a22; }

.entry-card { padding-bottom: 1.1rem; }
.entry-meta {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.7rem 0.8rem; margin-bottom: 0.9rem;
}
.entry-values {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.7rem; margin-bottom: 0.9rem;
}
.entry-foot { display: flex; gap: 0.8rem; align-items: flex-end; flex-wrap: wrap; }
.entry-foot .grow { flex: 1 1 260px; }
.entry-foot .fbtn { margin-left: auto; }
.entry-meta input, .entry-meta select, .entry-foot input { width: 100%; min-width: 0; }

.mcell {
  position: relative;
  padding: 0.55rem 0.7rem 0.5rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.5);
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.mcell > span { font-size: 0.7rem; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.mcell input { width: 100%; min-width: 0; margin-top: 0.25rem; font-size: 1rem; font-weight: 550; font-variant-numeric: tabular-nums; }
.mcell small.lim { display: block; margin-top: 0.3rem; font-size: 0.72rem; color: var(--muted); font-weight: 500; letter-spacing: 0; text-transform: none; }
.mcell.ok {
  background: linear-gradient(180deg, rgba(63, 122, 82, 0.18), rgba(63, 122, 82, 0.10));
  border-color: rgba(63, 122, 82, 0.6);
  box-shadow: inset 0 0 0 1px rgba(63, 122, 82, 0.12), 0 0 16px -6px rgba(63, 122, 82, 0.5);
}
.mcell.bad {
  background: linear-gradient(180deg, rgba(168, 50, 42, 0.18), rgba(168, 50, 42, 0.10));
  border-color: rgba(168, 50, 42, 0.65);
  box-shadow: inset 0 0 0 1px rgba(168, 50, 42, 0.12), 0 0 16px -6px rgba(168, 50, 42, 0.5);
}
.mcell.ok input, .mcell.bad input { font-weight: 650; color: #1f1b14; }
.mcell.ok small.lim { color: #2d5e3d; }
.mcell.bad small.lim { color: #8c2a22; }

.cell-ok { background: rgba(63, 122, 82, 0.15); color: #2d5e3d; font-weight: 650; }
.cell-bad { background: rgba(168, 50, 42, 0.14); color: #8c2a22; font-weight: 650; }
td.cell-ok, td.cell-bad { box-shadow: inset 2px 0 0 currentColor; }

.btn.danger { color: var(--bad); border-color: rgba(168, 50, 42, 0.45); }
.btn.danger:hover { background: rgba(168, 50, 42, 0.08); }

@media (max-width: 820px) {
  .entry-foot .fbtn { margin-left: 0; width: 100%; }
  .entry-foot .fbtn .btn { flex: 1; }
}
