/* Kientaler Betriebsportal — lean internal-tool stylesheet.
   Design tokens come from variables.css (kientaler.de CD). Dense, touch-friendly
   (iPad in the kitchen: targets >= 44px, readable at arm's length). */

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: var(--kk-font-body);
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--kk-text);
  background: var(--kk-paper);
  min-height: 100svh;
}
h1,
h2,
h3 {
  font-family: var(--kk-font-display);
  font-weight: 800;
  line-height: 1.15;
  margin: 0 0 0.5rem;
}
h1 {
  font-size: var(--kk-step-3);
}
h2 {
  font-size: var(--kk-step-2);
}
h3 {
  font-size: var(--kk-step-1);
}
a {
  color: var(--kk-petrol-dark);
}
img,
svg,
table {
  max-width: 100%;
}
a,
button,
input,
select {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

.wrap {
  width: 100%;
  max-width: var(--kk-maxw);
  margin-inline: auto;
  padding-inline: clamp(1rem, 3vw, 2rem);
}
main.wrap {
  padding-block: var(--kk-space-m) var(--kk-space-2xl);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 700;
  color: var(--kk-petrol);
  margin-bottom: 0.5rem;
}
.eyebrow::before {
  content: "";
  width: 1.6rem;
  height: 2px;
  background: var(--kk-petrol);
  border-radius: 2px;
}
.muted {
  color: var(--kk-text-muted);
}

/* ---------- Header / Nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--kk-petrol);
  color: var(--kk-milch);
  border-bottom: 3px solid var(--kk-ink);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding-block: 0.5rem;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--kk-milch);
}
.brand b {
  font-family: var(--kk-font-display);
  font-weight: 800;
  font-size: 1.25rem;
  line-height: 1;
  letter-spacing: -0.01em;
}
.brand span {
  font-size: 0.82rem;
  color: var(--kk-petrol-tint-3);
  font-weight: 600;
}
.nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}
.nav a {
  color: var(--kk-milch);
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  padding: 0.65rem 0.85rem; /* >= 44px touch target */
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border-radius: 10px;
  white-space: nowrap;
}
.nav a:hover {
  background: var(--kk-petrol-dark);
}
.nav a[aria-current="page"] {
  background: var(--kk-petrol-deep);
}

/* ---------- Buttons (pill + hard-shadow press) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  font-family: var(--kk-font-display);
  font-weight: 700;
  font-size: 1.02rem;
  min-height: 48px;
  padding: 0.72rem 1.5rem;
  border-radius: 999px;
  border: 2.5px solid var(--kk-ink);
  cursor: pointer;
  text-decoration: none;
  color: var(--kk-ink);
  transition:
    transform 0.12s ease,
    background 0.15s ease;
  box-shadow: 0 4px 0 var(--kk-ink);
}
.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--kk-ink);
}
.btn-primary {
  background: var(--kk-fuchs);
}
.btn-primary:hover {
  background: var(--kk-fuchs-dark);
}
.btn-ghost {
  background: var(--kk-milch);
}

/* ---------- Cards ---------- */
.card {
  background: var(--kk-milch);
  border: 2px solid var(--kk-ink);
  border-radius: var(--kk-radius);
  padding: var(--kk-space-s) var(--kk-space-m);
  box-shadow: 0 4px 0 rgba(28, 42, 30, 0.9);
}
.card + .card {
  margin-top: var(--kk-space-m);
}
.card h2:first-child,
.card h3:first-child {
  margin-top: 0;
}
.card--stub {
  background: var(--kk-paper-2);
  border-style: dashed;
  box-shadow: none;
}
.grid {
  display: grid;
  gap: var(--kk-space-s);
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  margin-block: var(--kk-space-m);
}
.grid .card {
  margin: 0;
}
.tile {
  display: block;
  text-decoration: none;
  color: var(--kk-ink);
  transition: transform 0.12s ease;
}
.tile:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(28, 42, 30, 0.9);
}
.tile .big {
  font-family: var(--kk-font-display);
  font-weight: 800;
  font-size: var(--kk-step-2);
}

/* ---------- Tables ---------- */
.tablewrap {
  overflow-x: auto;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
  background: var(--kk-milch);
}
table.data th,
table.data td {
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--kk-line);
  vertical-align: top;
}
table.data th {
  font-family: var(--kk-font-display);
  font-weight: 700;
  background: var(--kk-paper-2);
  white-space: nowrap;
}
table.data td.num,
table.data th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
table.data tr.sum td {
  font-weight: 700;
  border-top: 2px solid var(--kk-ink);
  background: var(--kk-paper-2);
}

.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
  margin: 0;
}
.kv dt {
  font-weight: 700;
  color: var(--kk-text-muted);
}
.kv dd {
  margin: 0;
}

.badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  border: 1.5px solid var(--kk-ink);
  background: var(--kk-paper-2);
}
.badge--petrol {
  background: var(--kk-petrol);
  color: var(--kk-milch);
}
.badge--gold {
  background: var(--kk-fuchs);
}
.badge--rot {
  background: #a33000;
  border-color: #a33000;
  color: #fff;
}

.warn {
  background: #fdeeda;
  border: 2px solid var(--kk-fuchs-dark);
  border-radius: var(--kk-radius);
  padding: 0.8rem 1rem;
  margin-block: var(--kk-space-s);
}

/* ---------- Toolbar (week/day navigation) ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-block: var(--kk-space-s);
}
.toolbar .spacer {
  flex: 1;
}

/* ---------- Forms / Login ---------- */
.field label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.3rem;
}
.field input {
  width: 100%;
  font: inherit;
  padding: 0.7rem 0.9rem;
  min-height: 48px;
  border: 2px solid var(--kk-ink);
  border-radius: 12px;
  background: var(--kk-milch);
}
.field input:focus {
  outline: 3px solid var(--kk-petrol);
  outline-offset: 1px;
}
.login-page {
  display: grid;
  place-items: center;
  min-height: 100svh;
  padding: 1rem;
}
.login-card {
  width: min(420px, 100%);
  text-align: center;
}
.login-card .logo {
  width: 84px;
  height: 84px;
  margin-inline: auto;
  margin-bottom: 0.8rem;
  border-radius: 50%;
  background: var(--kk-petrol);
  color: var(--kk-milch);
  border: 2.5px solid var(--kk-ink);
  display: grid;
  place-items: center;
  font-family: var(--kk-font-display);
  font-weight: 800;
  font-size: 1.6rem;
}
.login-card form {
  text-align: left;
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}
.error {
  color: #a33000;
  font-weight: 700;
}
/* Additional (feature-flagged) login ways, stacked under the password form. */
.login-alts {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.login-alt {
  width: 100%;
  text-align: center;
}

/* ---------- HACCP ---------- */
.haccp-card--done {
  background: #e9f4e6;
  border-color: #2e6b34;
  box-shadow: 0 4px 0 rgba(46, 107, 52, 0.55);
}
.haccp-card--nok {
  background: #fdeaea;
  border-color: #a33000;
  box-shadow: 0 4px 0 rgba(163, 48, 0, 0.4);
}
.badge--ok {
  background: #2e6b34;
  border-color: #2e6b34;
  color: #fff;
}
.badge--nok {
  background: #a33000;
  border-color: #a33000;
  color: #fff;
}
.haccp-fields {
  display: grid;
  gap: 0.6rem 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-block: 0.6rem;
}
.haccp-fields select {
  width: 100%;
  font: inherit;
  padding: 0.7rem 0.9rem;
  min-height: 48px;
  border: 2px solid var(--kk-ink);
  border-radius: 12px;
  background: var(--kk-milch);
}
.haccp-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  min-height: 48px;
  cursor: pointer;
}
.toggle input {
  width: 1.7rem;
  height: 1.7rem;
  accent-color: #2e6b34;
}
.foto-btn--set {
  background: #e9f4e6;
}
.foto-thumb {
  max-height: 120px;
  border: 2px solid var(--kk-ink);
  border-radius: 8px;
  vertical-align: middle;
}
/* Shared photo capture (portal/camera.ts): file input + camera button + overlay */
.camera-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.camera-input {
  min-height: 44px;
}
.foto-status {
  display: inline-block;
  margin-top: 0.3rem;
}
.foto-status:not(:empty) {
  color: #2e6b34;
  font-weight: 700;
}
.cam-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.85);
}
.cam-overlay video {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
  background: #000;
}
.cam-bar {
  display: flex;
  gap: 0.75rem;
}
tr.overdue td {
  background: #fdeaea;
  color: #a33000;
  font-weight: 700;
}
.haccp-range {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.haccp-range label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
}
.haccp-range input[type="date"] {
  font: inherit;
  padding: 0.5rem 0.7rem;
  min-height: 44px;
  border: 2px solid var(--kk-ink);
  border-radius: 12px;
  background: var(--kk-milch);
}

/* ---------- Verteilung Soll/Ist ---------- */
.ist-input {
  width: 4.4rem;
  font: inherit;
  text-align: right;
  padding: 0.35rem 0.45rem;
  min-height: 40px;
  border: 2px solid var(--kk-ink);
  border-radius: 10px;
  background: var(--kk-milch);
}
.ist-input:focus {
  outline: 3px solid var(--kk-petrol);
  outline-offset: 1px;
}
.delta {
  color: var(--kk-fuchs-dark);
  font-weight: 700;
  white-space: nowrap;
}

/* ---------- Kosten (budgets + entry form) ---------- */
.kosten-grid {
  display: grid;
  gap: 0.6rem 1rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-block: 0.6rem;
}
.kosten-grid .field--wide {
  grid-column: 1 / -1;
}
.kosten-form select {
  width: 100%;
  font: inherit;
  padding: 0.7rem 0.9rem;
  min-height: 48px;
  border: 2px solid var(--kk-ink);
  border-radius: 12px;
  background: var(--kk-milch);
}
.budget-bar {
  min-width: 90px;
  height: 14px;
  border: 1.5px solid var(--kk-ink);
  border-radius: 999px;
  background: var(--kk-paper-2);
  overflow: hidden;
}
.budget-fill {
  height: 100%;
  background: var(--kk-petrol);
}
.budget-fill--over {
  background: var(--kk-fuchs-dark);
}

/* ---------- Einkauf (actual EKs, supplier compare, import) ---------- */
.einkauf-pills {
  gap: 0.4rem;
}
.ek-input {
  width: 6rem;
  font: inherit;
  text-align: right;
  padding: 0.35rem 0.45rem;
  min-height: 40px;
  border: 2px solid var(--kk-ink);
  border-radius: 10px;
  background: var(--kk-milch);
}
.ek-input--unit {
  width: 4rem;
  text-align: left;
}
.ek-input:focus,
.ek-select:focus {
  outline: 3px solid var(--kk-petrol);
  outline-offset: 1px;
}
.ek-select {
  font: inherit;
  padding: 0.4rem 0.5rem;
  min-height: 40px;
  border: 2px solid var(--kk-ink);
  border-radius: 10px;
  background: var(--kk-milch);
}
.ek-best {
  background: #e9f4e6;
  color: #2e6b34;
  font-weight: 700;
}
.ok-banner {
  background: #e9f4e6;
  border-color: #2e6b34;
  box-shadow: 0 4px 0 rgba(46, 107, 52, 0.55);
}
.inline-form {
  margin: 0;
}

/* ---------- ToDos ---------- */
.todo-filter {
  margin-block: var(--kk-space-s);
}
.todo-filter-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.todo-filter-label {
  font-weight: 700;
  min-width: 5rem;
}
.todo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}
.todo-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.7rem 0.9rem;
  border: 2px solid var(--kk-ink);
  border-radius: 12px;
  background: var(--kk-milch);
}
.todo-item--overdue {
  border-color: #a33000;
  background: #fdeaea;
}
.todo-item--done {
  background: var(--kk-paper-2);
}
.todo-main {
  min-width: 0;
}
.todo-titel {
  font-weight: 700;
}
.todo-titel--done {
  text-decoration: line-through;
  color: var(--kk-text-muted);
}
.todo-besch {
  margin: 0.25rem 0 0;
}
.todo-toggle {
  margin: 0;
  flex: none;
}
.todo-erledigt summary {
  cursor: pointer;
  font-size: 1.05rem;
}

/* ---------- Print (foundation for Kontrolle-PDF mode) ---------- */
@media print {
  .site-header,
  .toolbar,
  .btn,
  .no-print {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
    font-size: 11pt;
  }
  .card {
    border: 1px solid #000;
    box-shadow: none;
    break-inside: avoid;
  }
  table.data th {
    background: #eee;
  }
  a {
    color: #000;
    text-decoration: none;
  }
}

/* ---------- Lieferscheine: signature pad + delivery-note print ---------- */
.sig-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}
.sig-field {
  margin-top: 0.5rem;
}
.sig-field > label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.sig-pad {
  display: block;
  width: 100%;
  height: 180px;
  background: #fff;
  border: 1.5px dashed var(--kk-ink);
  border-radius: 8px;
  touch-action: none;
  cursor: crosshair;
}
.sig-actions {
  margin-top: 0.4rem;
}
.sig-thumb {
  display: block;
  max-width: 100%;
  width: 280px;
  height: auto;
  background: #fff;
  border: 1px solid var(--kk-ink);
  border-radius: 6px;
}
.sig-resend {
  margin: 0.75rem 0 0;
}
.sig-done h3 {
  margin-top: 0;
}
