/* Schriften der Hühner-Boutique (selbst gehostet, kein externer Aufruf) */
@font-face {
  font-family: 'Indie Flower';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/indie-flower.woff2') format('woff2');
}
@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url('/fonts/open-sans.woff2') format('woff2');
}
@font-face {
  font-family: 'Lovelyta';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/lovelyta.otf') format('opentype');
}

:root {
  --bg: #f3d9dd;
  --card: #fffbfc;
  --ink: #45333a;
  --muted: #9c8189;
  --primary: #bf6c86;
  --primary-dark: #a4536e;
  --pink: #e0879f;
  --green: #6f8a5a;
  --green-soft: #e8efe0;
  --red: #c0533f;
  --red-soft: #f6e1dc;
  --amber-soft: #f6e6cf;
  --border: #e3acba;
  --radius: 20px;
  --shadow: 0 4px 16px rgba(150, 90, 110, 0.13);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
}

h1, h2, .site-title { font-family: 'Indie Flower', cursive; font-weight: 400; }

.wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

/* ---- Kopfbereich ---------------------------------------------------------- */

.site-header {
  text-align: center;
  padding: calc(20px + env(safe-area-inset-top)) 16px 0;
}
.logo { width: 130px; height: auto; }
.logo-sm { width: 38px; height: 38px; object-fit: contain; }
.site-title {
  font-family: 'Lovelyta', 'Indie Flower', cursive;
  font-size: 2.6rem;
  line-height: 1.15;
  color: var(--primary-dark);
  margin-top: 6px;
}
.site-sub { font-family: 'Indie Flower', cursive; font-size: 1.2rem; color: var(--muted); }

/* ---- Karten -------------------------------------------------------------- */

.card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card h2 { font-size: 1.2rem; margin-bottom: 14px; color: var(--primary-dark); }

/* ---- Bestand ------------------------------------------------------------- */

.stock-card {
  text-align: center;
  background: linear-gradient(160deg, #ffffff, #fdeef1);
  font-family: 'Indie Flower', cursive;
  position: relative;
}
.preview-tag {
  position: absolute;
  top: 8px; right: 12px;
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.stock-hint { margin-top: 10px; font-size: 0.9rem; color: var(--muted); white-space: pre-line; }
.stock-hint.warn { color: var(--red); font-weight: 400; }

/* Bestand: aktuelle Stufe – Bild + Label + Hinweis */
.ampel-stack-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.ampel-stack-item img {
  max-width: 110px;
  max-height: 110px;
  width: auto;
  height: auto;
  display: block;
  margin-bottom: 8px;
}
.ampel-stack-item .ampel-text {
  font-size: 1.5rem;
  color: var(--primary-dark);
  line-height: 1.15;
}
.ampel-stack-item .stock-hint {
  margin-top: 6px;
}

/* ---- Formularfelder ------------------------------------------------------ */

.field-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin: 14px 0 5px;
}
.input {
  width: 100%;
  font: inherit;
  padding: 12px 13px;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  background: #fffafb;
  color: var(--ink);
}
.input:focus { outline: none; border-color: var(--primary); }
textarea.input { resize: vertical; }
select.input { appearance: none; }

.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 92px; }
.pw-toggle {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font: inherit;
  font-size: 0.82rem;
  color: var(--primary-dark);
  text-decoration: underline;
  cursor: pointer;
  padding: 8px 9px;
}

.qty-wrap { position: relative; }
.qty-wrap .input { padding-right: 124px; }
.qty-wrap .input::-webkit-outer-spin-button,
.qty-wrap .input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty-wrap .input[type="number"] { -moz-appearance: textfield; }
.qty-btns {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 5px;
}
.qty-step {
  font: inherit;
  padding: 7px 12px;
  border: none;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
}
.qty-step:active { background: var(--primary-dark); }
.carton-hint { font-size: 0.85rem; color: var(--muted); margin-top: 6px; min-height: 1.1em; }

.wish-options { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 6px; }
.wish-options label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.wish-options input[type="radio"] { width: 18px; height: 18px; accent-color: var(--primary); }
.wish-date { margin-top: 8px; }

/* ---- Prognose-Box -------------------------------------------------------- */

.forecast-box {
  margin: 14px 0 4px;
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  white-space: pre-line;
}
.forecast-box.ok { background: var(--green-soft); color: var(--green); }
.forecast-box.wait { background: var(--amber-soft); color: var(--primary-dark); }
.forecast-inline { font-weight: 400; color: var(--primary-dark); margin: 8px 0; white-space: pre-line; }

/* Bestell-Block in Handschrift */
#orderSection { font-family: 'Indie Flower', cursive; }
#orderSection .field-label,
#orderSection .forecast-box,
#orderSection .form-msg,
#orderSection .btn { font-weight: 400; }

/* ---- Buttons ------------------------------------------------------------- */

.btn {
  display: block;
  width: 100%;
  font: inherit;
  font-weight: 700;
  padding: 14px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  margin-top: 16px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-secondary { background: var(--pink); color: #fff; }
.btn-ghost { background: transparent; color: var(--primary-dark); border: 1.5px solid var(--border); }
.btn:disabled { opacity: 0.6; }

.link-btn {
  background: none;
  border: none;
  color: var(--primary-dark);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  padding: 6px 0;
}

/* ---- Meldungen ----------------------------------------------------------- */

.form-msg {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 0.9rem;
  font-weight: 600;
}
.form-msg.ok { background: var(--green-soft); color: var(--green); }

.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 0.85rem; }

/* ---- Erfolg / Bestellbestätigung ---------------------------------------- */

.success-card { text-align: center; font-family: 'Indie Flower', cursive; }
.success-card strong, .success-card .btn { font-weight: 400; }
.success-icon {
  width: 66px; height: 66px; line-height: 66px;
  margin: 0 auto 8px;
  background: var(--green-soft); color: var(--green);
  border-radius: 50%; font-size: 2.1rem; font-weight: 800;
}
.link-box {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 10px;
  margin: 8px 0 14px;
  word-break: break-all;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.link-box a { color: var(--primary-dark); flex: 1; text-align: left; }
.link-copy {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--primary-dark);
  border-radius: 8px;
  padding: 4px 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.link-copy:hover { background: var(--card); }
.link-copy.ok { color: var(--green); border-color: var(--green); }

/* ---- Statusansicht (Kunde) ---------------------------------------------- */

.status-card { font-family: 'Indie Flower', cursive; }
.status-card h2 { margin-bottom: 16px; }
.status-card > #backToShop { margin-top: 18px; }
.stepper { list-style: none; display: flex; margin: 10px 0 22px; }
.stepper li {
  flex: 1;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  position: relative;
}
.stepper li .dot {
  display: block;
  width: 24px; height: 24px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background: var(--border);
}
.stepper li::before {
  content: "";
  position: absolute;
  top: 10px; left: -50%;
  width: 100%; height: 4px;
  background: var(--border);
  z-index: 0;
}
.stepper li:first-child::before { display: none; }
.stepper li .dot { position: relative; z-index: 1; }
.stepper li.done .dot, .stepper li.active .dot { background: var(--primary); }
.stepper li.done::before, .stepper li.active::before { background: var(--primary); }
.stepper li.active { color: var(--primary-dark); font-weight: 400; }
.stepper li.done { color: var(--ink); }

.status-detail { margin: 6px 0 12px; }
.status-detail > div { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); }
.status-detail dt { color: var(--muted); }
.status-detail dd { font-weight: 400; text-align: right; }
.status-hint { background: var(--amber-soft); color: var(--primary-dark); padding: 12px; border-radius: 10px; font-size: 1rem; white-space: pre-line; }
.status-pill { display: inline-block; padding: 5px 12px; border-radius: 20px; font-weight: 400; margin-bottom: 10px; }
.status-pill.cancelled { background: var(--red-soft); color: var(--red); }
.push-area { margin-top: 14px; }
.push-area .push-enable { width: 100%; }
.push-area p.muted { margin: 8px 0 0; text-align: center; }
.push-area .push-off { width: 100%; margin-top: 10px; }
.push-area .push-test { width: 100%; margin-top: 10px; }
.top-cust-label { margin-top: 18px; margin-bottom: 4px; }

/* ---- Fußbereich ---------------------------------------------------------- */

.site-footer {
  max-width: 480px;
  margin: 0 auto;
  padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
  text-align: center;
  font-family: 'Indie Flower', cursive;
  font-size: 1.05rem;
  color: var(--muted);
}
.admin-link { display: block; margin-top: 8px; color: var(--muted); }
.pickup-note {
  margin-top: 1.8rem;
  text-align: center;
  font-size: 1rem;
  color: var(--muted);
  white-space: pre-line;
}

/* ===== Adminbereich ======================================================= */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  align-items: safe center;
  justify-content: center;
  padding: 20px;
}
/* Nach dem Login wirklich ausblenden (sonst gewinnt display:flex). */
.login-screen[hidden] { display: none; }
.login-card { width: 100%; max-width: 360px; text-align: center; }
.login-card .logo { width: 70px; }
.login-card h1 { font-size: 1.4rem; color: var(--primary-dark); margin: 4px 0 2px; }

.admin-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 10px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.admin-brand {
  align-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  font-family: 'Lovelyta', 'Indie Flower', cursive;
  font-size: 1.5rem;
  color: var(--primary-dark);
}
#logoutBtn { align-self: flex-end; }

.tabbar {
  display: flex;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 9;
  overflow-x: auto;
}
.tab {
  flex: 1;
  min-width: max-content;
  font: inherit;
  font-weight: 600;
  font-size: 1.05rem;
  padding: 12px 12px;
  background: none;
  border: none;
  border-right: 1px solid var(--border);
  border-bottom: 3px solid transparent;
  color: var(--muted);
  cursor: pointer;
}
.tab:last-child { border-right: none; }
.tab.active { color: var(--primary-dark); border-bottom-color: var(--primary); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- Ampel-Bilder-Upload ------------------------------------------------- */

.ampel-uploads {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 8px;
}
.ampel-upload {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  background: var(--card);
}
.ampel-upload-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.ampel-upload-preview {
  width: 100%;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 8px;
}
.ampel-upload-preview img { max-width: 100%; max-height: 76px; }
.ampel-upload-preview.empty { color: var(--muted); font-size: 0.8rem; }
.ampel-upload .file-btn {
  display: inline-block;
  font-size: 0.85rem;
  padding: 4px 12px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  border: none;
}
.ampel-upload .file-btn:hover { background: var(--primary-dark); }
.ampel-upload input[type="file"] { display: none; }
.ampel-upload .btn-mini { margin-left: 6px; }

/* ---- Statistik ----------------------------------------------------------- */

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-grid.one { grid-template-columns: 1fr; }
.stat {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px 8px;
  text-align: center;
}
.stat-num { font-size: 1.9rem; font-weight: 800; color: var(--primary); }
.stat-num.bad { color: var(--red); }
.stat-lbl { font-size: 0.78rem; color: var(--muted); }

.alert {
  background: var(--red-soft);
  color: var(--red);
  border-radius: 12px;
  padding: 14px;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 16px;
  white-space: pre-line;
}

.count-list { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px; }
.count-item { font-size: 0.88rem; color: var(--muted); }
.count-item strong { color: var(--ink); font-size: 1rem; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form .input { flex: 1; min-width: 120px; }
.inline-form .btn { width: auto; margin-top: 0; }

/* ---- Filter-Chips -------------------------------------------------------- */

.filter-row { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  font: inherit;
  font-size: 0.82rem;
  padding: 6px 12px;
  border-radius: 16px;
  border: 1.5px solid var(--border);
  background: #fffafb;
  color: var(--muted);
  cursor: pointer;
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.quick-dates,
.quick-qty { display: flex; gap: 7px; flex-wrap: wrap; margin: 6px 0 14px; }

/* ---- Bestellkarten ------------------------------------------------------- */

.order-list { display: flex; flex-direction: column; gap: 12px; }
.order-card {
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 12px;
  padding: 13px;
}
.order-card.status-abholbereit { border-left-color: var(--green); }
.order-card.status-angefragt { border-left-color: var(--pink); }
.order-card.status-bestaetigt { border-left-color: var(--primary); }
.order-card.status-abgeholt { border-left-color: var(--border); opacity: 0.75; }
.order-card.status-storniert { border-left-color: var(--red); opacity: 0.7; }

.order-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.order-name { font-weight: 700; }
.order-meta { font-size: 0.88rem; margin-top: 3px; }
.order-note {
  margin-top: 6px; font-size: 0.85rem; font-style: italic;
  background: var(--bg); padding: 6px 9px; border-radius: 8px;
}

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 12px;
  white-space: nowrap;
}
.badge-angefragt { background: #fbe6ec; color: var(--pink); }
.badge-bestaetigt { background: var(--amber-soft); color: var(--primary-dark); }
.badge-abholbereit { background: var(--green-soft); color: var(--green); }
.badge-abgeholt { background: #ece6dd; color: var(--muted); }
.badge-storniert { background: var(--red-soft); color: var(--red); }

.order-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; }
.btn-mini {
  font: inherit;
  font-size: 0.83rem;
  font-weight: 600;
  padding: 7px 11px;
  border-radius: 9px;
  border: 1.5px solid var(--border);
  background: #fffafb;
  color: var(--ink);
  cursor: pointer;
}
.btn-mini.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-mini.wa { background: #25d366; color: #fff; border-color: #25d366; }
.btn-mini.ghost { background: #fffafb; color: var(--muted); }
.btn-mini.danger { background: #fffafb; color: var(--red); border-color: var(--red-soft); }

/* ---- Verlauf / Listen ---------------------------------------------------- */

.history-list { display: flex; flex-direction: column; }
.history-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.87rem;
}
.history-row:last-child { border-bottom: none; }
.history-row.editing { flex-direction: column; align-items: stretch; }
.hist-date { color: var(--muted); white-space: nowrap; }
.hist-type { font-weight: 600; }
.hist-qty { font-weight: 700; margin-left: auto; }
.hist-qty.pos { color: var(--green); }
.hist-qty.neg { color: var(--red); }
.hist-note { color: var(--muted); flex: 1; min-width: 0; }
.history-row .btn-mini { padding: 2px 9px; }

/* Bestellmengen-Tabelle: sortierbare Spalten */
.sales-table { margin-top: 8px; }
.sales-thead, .sales-tr {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) 1fr 1fr 1fr 1.2fr;
  gap: 6px;
  align-items: center;
}
.sales-thead { border-bottom: 2px solid var(--border); padding-bottom: 4px; margin-bottom: 4px; }
.sales-th {
  background: none;
  border: 0;
  padding: 4px 2px;
  font: inherit;
  font-weight: 700;
  color: var(--primary-dark);
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
}
.sales-th:hover { background: var(--bg); }
.sales-th.active { color: var(--primary); }
.sales-tr {
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}
.sales-tr:last-child { border-bottom: none; }
.sales-td { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sales-td.name { font-weight: 600; }
.sales-td.num { text-align: right; padding-right: 4px; font-variant-numeric: tabular-nums; }
.sales-th:nth-child(2), .sales-th:nth-child(3), .sales-th:nth-child(4) { text-align: right; padding-right: 4px; }

@media (max-width: 540px) {
  .sales-thead, .sales-tr { grid-template-columns: minmax(0, 1.4fr) 1fr 1fr 1fr; gap: 4px; font-size: 0.85rem; }
  .sales-th:nth-child(5), .sales-td:nth-child(5) { display: none; }
}

.suggest {
  margin: 8px 0;
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--amber-soft);
  padding: 9px 11px;
  border-radius: 9px;
}
.suggest .btn-mini { margin-left: 6px; padding: 3px 9px; }

code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.85em;
}

/* Lege-Kurve */
.chart-range { margin-bottom: 10px; }
.chart-summary { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 8px; color: var(--muted); }
.chart-summary strong { color: var(--primary); font-size: 1.25rem; margin-right: 3px; }
.chart-svg { width: 100%; height: auto; display: block; margin-top: 4px; }
.chart-bar { fill: var(--primary); }
.chart-grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; }
.chart-value { fill: var(--primary-dark); font-family: 'Indie Flower', cursive; font-size: 15px; text-anchor: middle; }
.chart-xlabel { fill: var(--muted); font-family: 'Indie Flower', cursive; font-size: 14px; text-anchor: middle; }

/* Verwaltung: komplett in Handschrift (Marken-Schriftzug bleibt Lovelyta) */
body.admin { font-family: 'Indie Flower', cursive; }
body.admin * { font-weight: 400; }
