/* Tiefkühler — Swiss Design: Raster, Typografie, Schwarz/Weiss, ein Rot. */

@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/static/fonts/InterVariable.woff2') format('woff2');
}

:root {
  --bg: #ffffff;
  --fg: #000000;
  --muted: #5c5c5c;
  --line: #000000;
  --hair: #d9d9d9;
  --soft: #f2f2f2;
  --red: #e30613;
  --on-red: #ffffff;
  --on-fg: #ffffff;
  --u: 8px;
  --gutter: 16px;
  --max: 1040px;
  --nav-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0b;
    --fg: #f5f5f5;
    --muted: #a3a3a3;
    --line: #f5f5f5;
    --hair: #333333;
    --soft: #1a1a1a;
    --red: #ff2a35;
    --on-fg: #0b0b0b;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  font-family: 'Inter Variable', Inter, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-feature-settings: 'cv11', 'ss01', 'tnum';
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + var(--u) * 3);
}

a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--red); }

:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }

.wrap {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.skip { position: absolute; left: -9999px; }
.skip:focus { left: var(--gutter); top: var(--u); background: var(--fg); color: var(--bg); padding: var(--u) calc(var(--u) * 2); z-index: 10; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Kopf ---------- */
.top { border-bottom: 2px solid var(--line); }
.top-inner {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 3);
  min-height: 56px;
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--u);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .04em;
  text-transform: uppercase;
  text-decoration: none;
}
.mark { width: 16px; height: 16px; background: var(--red); display: inline-block; }

.nav { display: flex; gap: calc(var(--u) * 3); margin-right: auto; }
.nav-link {
  font-weight: 500;
  font-size: 15px;
  text-decoration: none;
  padding: var(--u) 0;
  border-bottom: 3px solid transparent;
}
.nav-link[aria-current="page"] { border-bottom-color: var(--red); }

.top-tools { display: flex; align-items: center; gap: calc(var(--u) * 2); margin-left: auto; font-size: 14px; }
.lang { display: flex; gap: var(--u); font-weight: 600; letter-spacing: .04em; }
.lang a { text-decoration: none; color: var(--muted); }
.lang a:hover { color: var(--red); }
.lang-current { border-bottom: 2px solid var(--fg); }

/* Mobil: Navigation als Leiste am unteren Rand (Daumenreichweite) */
@media (max-width: 719px) {
  .nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 5;
    gap: 0;
    background: var(--bg);
    border-top: 2px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .nav-link {
    flex: 1;
    text-align: center;
    font-size: 13px;
    padding: 0 4px;
    height: var(--nav-h);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 0;
    border-top: 4px solid transparent;
  }
  .nav-link[aria-current="page"] { border-top-color: var(--red); font-weight: 700; }
}
@media (min-width: 720px) {
  body { padding-bottom: calc(var(--u) * 8); }
}

/* ---------- Typografie ---------- */
.display {
  font-size: clamp(36px, 8vw, 64px);
  line-height: 1;
  font-weight: 700;
  letter-spacing: -.035em;
  margin: 0;
  overflow-wrap: anywhere;
}
.lead { font-size: 20px; line-height: 1.4; max-width: 34ch; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin: calc(var(--u) * 6) 0 calc(var(--u) * 2);
  padding-top: var(--u);
  border-top: 2px solid var(--line);
}
.crumb { margin: calc(var(--u) * 3) 0 0; font-size: 14px; }
.crumb a { text-decoration: none; color: var(--muted); }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: calc(var(--u) * 2);
  margin: calc(var(--u) * 4) 0 calc(var(--u) * 3);
}
.page-head-item { align-items: flex-start; }
.big-qty { font-size: clamp(28px, 6vw, 40px); font-weight: 600; letter-spacing: -.02em; margin: 0; white-space: nowrap; }

/* ---------- Meldungen ---------- */
.flash {
  margin: calc(var(--u) * 3) 0;
  padding: calc(var(--u) * 1.5) calc(var(--u) * 2);
  border-left: 6px solid var(--fg);
  background: var(--soft);
  font-weight: 500;
}
.flash ul { margin: 0; padding-left: 18px; }
.flash-error { border-left-color: var(--red); }
.flash-ok { border-left-color: var(--fg); }

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--u);
  min-height: 44px;
  padding: 0 calc(var(--u) * 2);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
  background: var(--bg);
  border: 2px solid var(--fg);
  border-radius: 0;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--fg); color: var(--bg); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn:disabled:hover { background: var(--bg); color: var(--fg); }
.btn-primary { background: var(--red); border-color: var(--red); color: var(--on-red); }
.btn-primary:hover { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.btn-ghost { border-color: transparent; text-decoration: underline; text-underline-offset: 3px; }
.btn-ghost:hover { background: transparent; color: var(--red); }
.btn-large { min-height: 56px; font-size: 17px; padding: 0 calc(var(--u) * 3); }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
button.link:hover { color: var(--red); }
form.inline { display: inline; margin: 0; }

/* ---------- Formulare ---------- */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); }

input, select, textarea {
  font: inherit;
  font-size: 17px; /* verhindert Zoom auf iOS */
  color: var(--fg);
  background: var(--bg);
  border: 0;
  border-bottom: 2px solid var(--fg);
  border-radius: 0;
  padding: 10px 0;
  width: 100%;
  min-height: 48px;
}
textarea { resize: vertical; min-height: 72px; }
select {
  appearance: none;
  padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, var(--fg) 50%), linear-gradient(135deg, var(--fg) 50%, transparent 50%);
  background-position: calc(100% - 12px) 55%, calc(100% - 6px) 55%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
input:focus, select:focus, textarea:focus { outline: none; border-bottom-color: var(--red); }
input:disabled { color: var(--muted); border-bottom-style: dashed; }
input[type="date"], input[type="month"] { min-width: 0; }
::placeholder { color: var(--muted); opacity: .8; }

.form { margin: 0; }
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: calc(var(--u) * 3) calc(var(--u) * 3);
}
@media (min-width: 600px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .span-2 { grid-column: span 2; }
}
.actions { display: flex; flex-wrap: wrap; gap: calc(var(--u) * 1.5); margin-top: calc(var(--u) * 4); }
@media (max-width: 599px) {
  .actions .btn { flex: 1 1 100%; }
}

/* ---------- Kennzahlen ---------- */
.stats {
  list-style: none;
  margin: 0 0 calc(var(--u) * 4);
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 2px solid var(--line);
}
.stats li { padding: calc(var(--u) * 1.5) var(--u) 0 0; display: flex; flex-direction: column; min-width: 0; }
.stats strong { font-size: clamp(28px, 7vw, 44px); line-height: 1; font-weight: 700; letter-spacing: -.03em; }
.stats span { font-size: 12px; color: var(--muted); margin-top: 4px; overflow-wrap: anywhere; }
.stats .is-red strong { color: var(--red); }

/* ---------- Filter ---------- */
.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: calc(var(--u) * 2);
  margin-bottom: calc(var(--u) * 3);
  align-items: end;
}
.field-search { grid-column: 1 / -1; }
.filter-actions { display: flex; gap: var(--u); grid-column: 1 / -1; }
.js .filter-actions .btn[type="submit"] { display: none; }
@media (min-width: 720px) {
  .filters { grid-template-columns: 2fr 1fr 1fr 1fr auto; }
  .field-search, .filter-actions { grid-column: auto; }
}

/* ---------- Artikelliste ---------- */
.items { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--line); }
.item { border-bottom: 1px solid var(--hair); }
.item a {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: calc(var(--u) * 2);
  padding: calc(var(--u) * 2) 0;
  text-decoration: none;
  position: relative;
}
.item a:hover { color: inherit; background: var(--soft); }
.item.is-expired a::before {
  content: '';
  position: absolute;
  left: calc(var(--gutter) * -1);
  top: 0; bottom: 0;
  width: 6px;
  background: var(--red);
}
.item-main, .item-side { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.item-side { text-align: right; align-items: flex-end; }
.item-name { font-size: 19px; font-weight: 600; letter-spacing: -.01em; overflow-wrap: anywhere; }
.item-meta, .item-days { font-size: 14px; color: var(--muted); }
.item-qty { font-size: 19px; font-weight: 600; white-space: nowrap; }
.item-date { font-size: 14px; font-variant-numeric: tabular-nums; }
.is-expired .item-days { color: var(--red); font-weight: 600; }
.item-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 0; }
.item-badges:empty { display: none; }

.badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 2px 6px;
  line-height: 1.4;
}
.badge-red { background: var(--red); color: var(--on-red); }
.badge-black { background: var(--fg); color: var(--bg); }
.badge-outline { box-shadow: inset 0 0 0 1.5px var(--fg); }

.empty { border-top: 2px solid var(--line); padding: calc(var(--u) * 6) 0; }
.empty p { font-size: 24px; font-weight: 600; margin: 0 0 calc(var(--u) * 3); }

/* ---------- Artikeldetail ---------- */
.action-panel {
  border-top: 2px solid var(--line);
  padding-top: calc(var(--u) * 3);
  display: grid;
  gap: calc(var(--u) * 3);
}
.out-form { display: grid; gap: calc(var(--u) * 2); }
@media (min-width: 600px) {
  .out-form { grid-template-columns: 1fr auto; align-items: end; }
}
.qty-input { display: flex; align-items: stretch; gap: var(--u); }
.qty-input input { text-align: center; font-size: 24px; font-weight: 600; min-width: 0; flex: 1; }
.qty-input .step { width: 56px; min-height: 56px; font-size: 24px; padding: 0; }
.qty-input .unit { align-self: center; font-weight: 600; min-width: 4ch; }
html:not(.js) .step { display: none; }
.secondary-actions { display: flex; flex-wrap: wrap; gap: calc(var(--u) * 1.5); }

.details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: calc(var(--u) * 2) calc(var(--u) * 3);
  margin: calc(var(--u) * 5) 0 0;
  padding-top: calc(var(--u) * 2);
  border-top: 2px solid var(--line);
}
@media (min-width: 720px) { .details { grid-template-columns: repeat(3, 1fr); } }
.details div { min-width: 0; }
.details dt { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.details dd { margin: 2px 0 0; font-size: 17px; overflow-wrap: anywhere; }
.details .span-all { grid-column: 1 / -1; }
.note { white-space: pre-wrap; }

/* ---------- Verlauf ---------- */
.moves { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--line); }
.move {
  display: grid;
  grid-template-columns: 11ch 1fr;
  gap: 2px calc(var(--u) * 2);
  padding: calc(var(--u) * 1.5) 0;
  border-bottom: 1px solid var(--hair);
}
.move-type { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding-top: 3px; }
.move-in .move-type { color: var(--fg); }
.move-out .move-type { color: var(--red); }
.move-open .move-type, .move-edit .move-type { color: var(--muted); }
.move-what { font-weight: 600; display: flex; flex-wrap: wrap; gap: 0 var(--u); }
.move-what a { text-decoration: none; }
.move-qty { font-weight: 400; }
.move-meta { grid-column: 2; font-size: 14px; color: var(--muted); }
@media (min-width: 720px) {
  .move { grid-template-columns: 12ch 1fr auto; }
  .move-meta { grid-column: 3; text-align: right; }
}

/* ---------- Einstellungen ---------- */
.section { margin-bottom: calc(var(--u) * 2); }
.editor { list-style: none; margin: 0; padding: 0; }
.editor-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--u) calc(var(--u) * 1.5);
  padding: var(--u) 0;
  border-bottom: 1px solid var(--hair);
}
.editor-row > .field:first-of-type { flex: 1 1 14rem; }
.editor-row > .field-months { flex: 0 0 8ch; }
.editor-row .btn { min-height: 44px; font-size: 14px; flex: none; }
.editor-new { margin-top: var(--u); border-bottom: 0; }
.is-archived input { text-decoration: line-through; }

/* ---------- Login ---------- */
.login { padding: calc(var(--u) * 8) 0; display: grid; gap: calc(var(--u) * 3); justify-items: start; }
.login .display { font-size: clamp(48px, 14vw, 120px); }

@media (prefers-reduced-motion: no-preference) {
  .btn, .item a, a { transition: background-color .12s, color .12s, border-color .12s; }
}

@media print {
  .top, .filters, .action-panel, .nav { display: none; }
  body { padding: 0; }
}
