:root {
  --bg: #0f1720;
  --panel: #17212b;
  --panel-2: #1e2a37;
  --line: #2a3947;
  --text: #e8eef4;
  --muted: #93a4b3;
  --accent: #f6b93b;
  --accent-ink: #2a1e00;
  --danger: #e05a5a;
  --radius: 14px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.head { margin-bottom: 18px; }
.head h1 { font-size: 1.55rem; margin: 0; }
.sub { color: var(--muted); margin: 4px 0 0; font-size: .95rem; }

/* Add form */
.add {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}
.add input {
  flex: 1;
  min-width: 0;
  padding: 13px 14px;
  font-size: 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
}
.add input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.add button {
  padding: 0 18px;
  font-size: 1rem;
  font-weight: 600;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}
.add button:active { transform: translateY(1px); }

/* Table */
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;               /* mobil horizontal scrollbar statt geclippt */
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; min-width: 480px; }
thead th {
  text-align: left;
  font-size: .72rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
}
.col-count { text-align: center; }
.col-price { text-align: right; white-space: nowrap; }
.col-sum { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.col-del { width: 40px; }

tbody tr { border-bottom: 1px solid var(--line); }
tbody tr:last-child { border-bottom: none; }
tbody td { padding: 10px; vertical-align: middle; }

.name-cell {
  font-weight: 600;
  font-size: 1.02rem;
  font-family: inherit;
  border: none;
  background: transparent;
  color: var(--text);
  width: 100%;
  text-align: left;
  padding: 6px 4px;
  border-radius: 8px;
  cursor: pointer;
}
.name-cell:hover { background: var(--panel-2); }
.name-cell:focus-visible { outline: 2px solid var(--accent); background: var(--panel-2); }

/* Counter */
.counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.counter button {
  width: 38px;
  height: 38px;
  font-size: 1.4rem;
  line-height: 1;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.counter button:active { transform: translateY(1px); }
.counter .plus { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.counter .val {
  min-width: 2.2ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 1.15rem;
  font-weight: 700;
}

/* Price (Klick oeffnet Modal) */
.price-cell {
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  padding: 6px 6px;
  border-radius: 8px;
  width: 100%;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.price-cell:hover { background: var(--panel-2); color: var(--accent); }
.price-cell:focus-visible { outline: 2px solid var(--accent); }

/* Date */
.date-input {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 8px;
  font-size: .92rem;
  font-family: inherit;
  color-scheme: dark;
}
.date-input:focus { outline: 2px solid var(--accent); }

/* Delete */
.del {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  border-radius: 8px;
  cursor: pointer;
}
.del:hover { color: var(--danger); background: var(--panel-2); }

tfoot th, tfoot td {
  padding: 12px 10px;
  border-top: 2px solid var(--line);
  font-weight: 700;
  font-size: 1rem;
}
tfoot .col-count { text-align: center; }
tfoot #foot-sum { color: var(--accent); }

.empty { color: var(--muted); text-align: center; padding: 26px 14px; margin: 0; }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: 100%;
  max-width: 360px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.modal h2 {
  margin: 0 0 16px;
  font-size: 1.2rem;
  word-break: break-word;
}
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  color-scheme: dark;
}
.field input:focus { outline: 2px solid var(--accent); }
.hint { color: var(--muted); font-size: .82rem; margin: -4px 0 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.btn-ghost, .btn-primary {
  padding: 11px 18px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid var(--line);
}
.btn-ghost { background: transparent; color: var(--text); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--danger);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: .9rem;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
  z-index: 10;
}

@media (max-width: 420px) {
  .counter button { width: 34px; height: 34px; }
  tbody td { padding: 8px 6px; }
  .date-input { padding: 7px 6px; }
}
