/* Bestell-App – dunkles Design mit Bronze-Akzenten */
:root {
  color-scheme: dark;
  --bg: #121110;
  --surface: #1c1a18;
  --surface-2: #26231f;
  --surface-3: #2f2b26;
  --line: #3a342d;
  --text: #ece6dd;
  --muted: #a89f92;
  --bronze: #b08d57;
  --bronze-hi: #cda873;
  --bronze-lo: #7a5f3a;
  --on-bronze: #17130e;
  --ok: #7fa37a;
  --warn: #d4a24c;
  --err: #c96a5a;
  --radius: 8px;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px rgb(0 0 0 / .25);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--bronze-hi); }
h1, h2, h3 { font-weight: 600; letter-spacing: -.01em; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .06em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
svg.i { width: 20px; height: 20px; flex: none; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.nav {
  background: var(--surface);
  border-right: 1px solid var(--line);
  width: 232px; flex: none;
  display: flex; flex-direction: column; gap: 4px;
  padding: 20px 12px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; font-weight: 600; font-size: 1.05rem; }
.brand svg { width: 28px; height: 28px; color: var(--bronze); }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; min-height: 44px;
  color: var(--muted); text-decoration: none; border-radius: var(--radius);
  border-left: 2px solid transparent;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: var(--bronze-hi); background: var(--surface-2); border-left-color: var(--bronze); }
.nav .spacer { flex: 1; }
.nav .who { padding: 10px 12px; color: var(--muted); font-size: .875rem; border-top: 1px solid var(--line); margin-top: 8px; }

main { flex: 1; min-width: 0; padding: 28px 32px 48px; max-width: 1100px; }

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .nav {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto; z-index: 20;
    width: 100%; height: auto; flex-direction: row; justify-content: space-around;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line);
  }
  .brand, .nav .spacer, .nav .who { display: none; }
  .nav a { flex-direction: column; gap: 2px; font-size: .7rem; padding: 6px 4px; border-left: 0; border-top: 2px solid transparent; border-radius: 0; flex: 1; justify-content: center; }
  .nav a.active { border-top-color: var(--bronze); background: transparent; }
  main { padding: 16px 16px 96px; }
}

/* ---------- Bausteine ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.toolbar .grow { flex: 1; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }
.card.accent { border-top: 2px solid var(--bronze); }
.stack > * + * { margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  font: inherit; font-weight: 500; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: var(--bronze-lo); }
.btn.primary { background: var(--bronze); color: var(--on-bronze); border-color: var(--bronze); }
.btn.primary:hover { background: var(--bronze-hi); border-color: var(--bronze-hi); }
.btn.primary:active { background: var(--bronze-lo); }
.btn.danger { color: var(--err); }
.btn.danger:hover { border-color: var(--err); }
.btn.icon { padding: 0; width: 44px; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .875rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--bronze-hi); outline-offset: 2px; }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: .875rem; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  min-height: 44px; padding: 8px 12px; width: 100%;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--bronze); box-shadow: 0 0 0 3px rgb(176 141 87 / .2); }
input[type="checkbox"] { width: 20px; min-height: 20px; height: 20px; accent-color: var(--bronze); }
label.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
::-webkit-calendar-picker-indicator { filter: invert(.8) sepia(.4); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button {
  font: inherit; color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 10px 14px; min-height: 44px; cursor: pointer; white-space: nowrap;
}
.tabs button.active { color: var(--bronze-hi); border-bottom-color: var(--bronze); }

table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-weight: 500; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.list td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
.scroll-x { overflow-x: auto; }

.badge { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.badge.bronze { color: var(--bronze-hi); border-color: var(--bronze-lo); }
.badge.ok { color: var(--ok); border-color: rgb(127 163 122 / .4); }
.badge.err { color: var(--err); border-color: rgb(201 106 90 / .4); }

/* ---------- Tagesansicht ---------- */
.daynav { display: flex; align-items: center; gap: 8px; }
.daynav input[type="date"] { width: auto; }
.daytitle { font-size: 1.35rem; font-weight: 600; }
.summary { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.summary .chip { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: .875rem; }
.summary .chip b { color: var(--bronze-hi); font-weight: 600; }

.order {
  display: grid; grid-template-columns: 72px 1fr auto; gap: 4px 16px; align-items: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; text-decoration: none; color: inherit;
}
.order + .order { margin-top: 8px; }
.order:hover { border-color: var(--bronze-lo); }
.order .time { font-size: 1.15rem; font-weight: 600; color: var(--bronze-hi); }
.order .cust { font-weight: 600; }
.order .items { color: var(--text); font-size: .95rem; }
.order .note { color: var(--muted); font-size: .875rem; font-style: italic; }
.order .loc { font-size: .8rem; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- Formular Bestellung ---------- */
.items-edit { display: flex; flex-direction: column; gap: 8px; }
.item-row { display: grid; grid-template-columns: 1fr 130px 56px 44px; gap: 8px; align-items: center; }
.item-row .unit { color: var(--muted); font-size: .9rem; }
@media (max-width: 600px) { .item-row { grid-template-columns: 1fr 96px 40px 44px; } }

/* ---------- Auth-Seiten ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: 100%; max-width: 400px; padding: 28px; }
.auth .brand { justify-content: center; padding: 0 0 16px; font-size: 1.25rem; }
.auth .brand svg { width: 40px; height: 40px; }
.auth .links { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; font-size: .875rem; flex-wrap: wrap; }

.code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 1.6rem; letter-spacing: .12em; color: var(--bronze-hi); text-align: center; padding: 12px; background: var(--surface-2); border: 1px dashed var(--bronze-lo); border-radius: var(--radius); user-select: all; }

.msg { padding: 10px 14px; border-radius: var(--radius); border: 1px solid; font-size: .9rem; }
.msg.err { color: #f0b3a8; border-color: rgb(201 106 90 / .5); background: rgb(201 106 90 / .1); }
.msg.ok { color: #c3dcbf; border-color: rgb(127 163 122 / .5); background: rgb(127 163 122 / .1); }
.msg.warn { color: #f0d49e; border-color: rgb(212 162 76 / .5); background: rgb(212 162 76 / .1); }

/* ---------- Dialog & Toast ---------- */
dialog {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-top: 2px solid var(--bronze); border-radius: var(--radius);
  padding: 22px; width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgb(0 0 0 / .6); }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--surface-3); border: 1px solid var(--line); border-left: 3px solid var(--bronze);
  padding: 12px 18px; border-radius: var(--radius); box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}
.toast.err { border-left-color: var(--err); }
@media (max-width: 860px) { .toast { bottom: 88px; } }

/* ---------- Druckansicht (Bildschirm) ---------- */
.sheet { background: #fff; color: #111; border-radius: var(--radius); padding: 32px; max-width: 820px; box-shadow: var(--shadow); }
.sheet h1 { font-size: 1.4rem; margin: 0; }
.sheet .head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid #b08d57; padding-bottom: 8px; margin-bottom: 16px; gap: 16px; }
.sheet .meta { color: #555; font-size: .9rem; text-align: right; }
.sheet h2 { font-size: 1.05rem; margin: 18px 0 6px; padding-bottom: 4px; border-bottom: 1px solid #ccc; }
.sheet table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.sheet td, .sheet th { padding: 6px 8px; border-bottom: 1px solid #e3e3e3; vertical-align: top; text-align: left; }
.sheet th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: #555; }
.sheet td.t { width: 60px; font-weight: 600; }
.sheet td.c { width: 26%; font-weight: 600; }
.sheet .n { color: #444; font-style: italic; }
.sheet tr { break-inside: avoid; }
.sheet .totals td:last-child { text-align: right; font-weight: 600; }
.sheet .foot { margin-top: 20px; color: #777; font-size: .75rem; display: flex; justify-content: space-between; }

@media print {
  @page { size: A4; margin: 14mm 12mm; }
  html, body { background: #fff !important; color: #000; }
  .nav, .toolbar, .toast, .noprint { display: none !important; }
  .app { display: block; }
  main { padding: 0; max-width: none; }
  .sheet { box-shadow: none; padding: 0; max-width: none; border-radius: 0; }
  .sheet h2 { break-after: avoid; }
}
table.list td .toolbar { margin: 0; gap: 6px; flex-wrap: nowrap; justify-content: flex-end; }

/* ---------- Phase 2 ---------- */
.mob-only { display: none !important; }
@media (max-width: 860px) {
  .desk-only { display: none !important; }
  .mob-only { display: flex !important; }
}
.banner { margin-bottom: 16px; }
.banner a { margin-left: 4px; }

.cal-title { margin: 0; min-width: 200px; text-align: center; font-size: 1.25rem; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head { text-align: center; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; padding: 4px 0; }
.cal-cell {
  aspect-ratio: 1 / .85; min-height: 56px; position: relative;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--muted); text-decoration: none; padding: 6px 8px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.cal-cell.empty-cell { background: transparent; border-color: transparent; }
.cal-cell:hover { border-color: var(--bronze-lo); color: var(--text); }
.cal-cell.sun .d { color: var(--bronze-lo); }
.cal-cell.has { color: var(--text); background: var(--surface-2); }
.cal-cell.today { border-color: var(--bronze); box-shadow: inset 0 0 0 1px var(--bronze); }
.cal-cell .d { font-weight: 500; }
.cal-cell .n {
  align-self: flex-end; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px;
  background: var(--bronze); color: var(--on-bronze); font-weight: 600; font-size: .9rem;
  display: inline-flex; align-items: center; justify-content: center;
}
@media (max-width: 600px) {
  .cal { gap: 3px; }
  .cal-cell { padding: 4px; min-height: 48px; aspect-ratio: auto; }
  .cal-cell .n { min-width: 22px; height: 22px; font-size: .75rem; padding: 0 6px; align-self: center; }
  .cal-title { min-width: 0; font-size: 1.05rem; }
}

.search-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.search-row .grow { flex: 1 1 240px; }
.search-row .field { flex: 0 1 180px; }
.search-row .field.grow { flex: 1 1 240px; }
.order .time .small { font-size: .75rem; color: var(--muted); font-weight: 500; }

.trash-row { display: flex; gap: 8px; align-items: center; }
.trash-row + .trash-row { margin-top: 8px; }
.trash-row .order { flex: 1; cursor: default; }
@media (max-width: 600px) { .trash-row { flex-direction: column; align-items: stretch; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stats .card + .card { margin-top: 0; }
.stats h3 { font-size: .75rem; }
.more-item .time { color: var(--bronze); }
.more-item .time svg { width: 24px; height: 24px; }
