:root {
  --paper: #f4f1ea;
  --paper-2: #ebe6dc;
  --ink: #1c1917;
  --muted: #57534e;
  --line: #d6d1c7;
  --accent: #8f2d2d;
  --accent-ink: #fffaf7;
  --ok: #166534;
  --green: #166534;
  --red: #8f2d2d;
  --warn-ink: #7c2d12;
  --row: #faf8f4;
  --zebra: #efeae2;
  --danger: #8f2d2d;
  --radius: 2px;
  --font: system-ui, "Segoe UI", "Source Sans 3", "Segoe UI Historic", sans-serif;
  --mark: Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.35;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button {
  cursor: pointer;
  font-family: inherit;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: var(--muted);
  gap: 4px;
}

/* ——— Shared controls ——— */
.btn,
.btn-full {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-weight: 600;
  font-size: 1rem;
  background: #fff;
  color: var(--ink);
}

.btn-full {
  width: 100%;
}

.btn.primary,
.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn.ghost,
.ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn.danger,
.danger {
  background: #fff;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn.warn,
.warn {
  background: #fff;
  color: var(--warn-ink);
  border: 1px solid var(--line);
}

.btn.orange,
.orange {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.muted {
  color: var(--muted);
}

.brand {
  font-family: var(--mark);
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--muted);
  font-weight: 400;
}

.brand-org {
  font-family: var(--mark);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-top: -2px;
}

.org-logo {
  display: block;
  margin: 0 auto 10px;
  max-height: 80px;
  max-width: min(200px, 70vw);
  width: auto;
  height: auto;
  object-fit: contain;
}

.title {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sub {
  color: var(--muted);
  font-weight: 600;
}

.debt {
  font-size: 1.35rem;
  font-weight: 700;
}

.debt.red {
  color: var(--accent);
}

.debt.green {
  color: var(--ok);
}

.big {
  font-size: 3rem;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.45);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 40;
}

.msg {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  width: min(360px, 100%);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ——— Theke (phone) ——— */
body.kasse {
  user-select: none;
  background:
    linear-gradient(180deg, #f7f4ee 0%, var(--paper) 40%, var(--paper-2) 100%);
}

body.kasse #app {
  width: min(440px, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}

body.kasse #app.has-cart-bar {
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.key {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 0;
  min-height: 64px;
  font-size: 1.4rem;
  font-weight: 700;
  background: #fff;
  color: var(--ink);
}

.key:active {
  background: var(--paper-2);
}

.key.enter {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}

.key.del {
  background: var(--paper-2);
  color: var(--accent);
  font-size: 0.85rem;
  letter-spacing: 0.03em;
}

.dots {
  letter-spacing: 10px;
  font-size: 1.7rem;
  color: #a8a29e;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.dots.on {
  color: var(--ok);
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 16px 14px;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 600;
  text-align: left;
}

.menu-item:active {
  background: var(--paper-2);
}

.menu-item .hint {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.menu-item.out {
  border-color: var(--accent);
  color: var(--accent);
}

.grid2 {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tile {
  display: none;
}

.drink-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  flex: 1;
  align-content: start;
}

.drink {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  padding: 20px 12px;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  font-weight: 700;
  font-size: 1.1rem;
  text-align: center;
}

.drink:active {
  background: var(--paper-2);
}

.drink strong {
  font-size: 1.15rem;
  line-height: 1.2;
}

.drink small {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
}

.drink .price {
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.cart-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  max-width: 440px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.cart-bar .btn {
  flex: 1;
  min-height: 52px;
  font-size: 1.05rem;
}

.pay-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  text-align: left;
}

.pay-grid .btn {
  min-height: 52px;
  border-radius: var(--radius);
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  gap: 8px;
  text-align: left;
}

.btns {
  display: flex;
  gap: 6px;
  align-items: center;
}

.btns .btn {
  padding: 10px 12px;
  min-width: 40px;
}

.qty {
  min-width: 28px;
  text-align: center;
  font-weight: 700;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

.scroll {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.recent {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  text-align: left;
}

.kasse-head {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.logout-link {
  margin-top: auto;
  padding-top: 8px;
}

.idle-hint {
  font-size: 12px;
  opacity: 0.75;
  margin-top: 4px;
}

/* ——— Büro (desktop) ——— */
body.office {
  background: var(--paper);
  color: var(--ink);
  user-select: text;
  -webkit-user-select: text;
}

body.office input,
body.office select,
body.office textarea {
  user-select: text;
  -webkit-user-select: text;
  pointer-events: auto;
  color: var(--ink);
  background: #fff;
  caret-color: var(--ink);
}

body.office #app {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 0;
  min-height: 100dvh;
  display: block;
}

.office-shell {
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: 100dvh;
}

.office-nav {
  border-right: 1px solid var(--line);
  background: var(--paper-2);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100dvh;
  overflow: auto;
}

.office-nav .wordmark {
  font-family: var(--mark);
  font-size: 15px;
  margin-bottom: 2px;
  color: var(--ink);
}

.office-nav .nav-sub {
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 4px;
}

.office-nav .nav-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 12px 0 6px;
}

.brand-form .brand-preview {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin: 4px 0 8px;
}

.brand-form .org-logo {
  margin: 0;
  max-height: 64px;
}

.office-nav a,
.office-nav button.nav-link {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 9px 10px;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}

.office-nav a:hover,
.office-nav button.nav-link:hover,
.office-nav a.active,
.office-nav button.nav-link.active {
  background: #fff;
  border: 1px solid var(--line);
  padding: 8px 9px;
}

.office-nav .nav-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 16px;
}

.office-main {
  padding: 24px 28px 48px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.office-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.office-top h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.office-top .meta {
  color: var(--muted);
  font-size: 13px;
}

.stock-toggle {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border: 2px solid var(--line);
  background: #fff;
  cursor: pointer;
  user-select: none;
  min-width: min(280px, 100%);
}

.stock-toggle.on {
  border-color: var(--green, #2f7d4a);
  background: #f3faf5;
}

.stock-toggle.off {
  border-color: #c9a227;
  background: #fffbeb;
}

.stock-toggle-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  text-align: left;
}

.stock-toggle-text strong {
  font-size: 15px;
  color: var(--ink, #1a1a1a);
}

.stock-toggle-text small {
  font-size: 12px;
  color: var(--muted);
}

.stock-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.stock-switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 999px;
  background: #c4c4c4;
  transition: background 0.15s ease;
}

.stock-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease;
}

.stock-toggle input:checked + .stock-switch {
  background: var(--green, #2f7d4a);
}

.stock-toggle input:checked + .stock-switch::after {
  transform: translateX(20px);
}

.summary-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  border: 1px solid var(--line);
  background: #fff;
}

.summary-row .stat {
  padding: 14px 16px;
  border-right: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

.summary-row .stat:last-child {
  border-right: 0;
}

.summary-row .stat b {
  display: block;
  font-size: 1.35rem;
  margin-top: 4px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-margin-top: 16px;
}

.section > h2 {
  font-size: 1.15rem;
  font-weight: 700;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.section > .lead {
  color: var(--muted);
  font-size: 14px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--row);
  font-weight: 600;
}

tbody tr:nth-child(even) {
  background: var(--zebra);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.login-box {
  max-width: 400px;
  margin: 12vh auto;
  padding: 24px;
  border: 1px solid var(--line);
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-box h1 {
  font-size: 1.4rem;
}

.backup-box {
  border: 1px solid var(--line);
  background: #fff;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.backup-meta {
  font-size: 13px;
  color: var(--muted);
  font-family: ui-monospace, "Cascadia Mono", "Consolas", monospace;
  word-break: break-all;
}

.fn-tag {
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.office .btn {
  color: inherit;
}

.office .btn.primary {
  color: var(--accent-ink);
}

code {
  font-size: 12px;
  word-break: break-all;
}

@media (max-width: 860px) {
  .office-shell {
    grid-template-columns: 1fr;
  }

  .office-nav {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
  }

  .office-nav .nav-label,
  .office-nav .wordmark {
    width: 100%;
  }

  .office-nav .nav-foot {
    margin-top: 8px;
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .office-main {
    padding: 16px;
  }

  .summary-row {
    grid-template-columns: 1fr;
  }

  .summary-row .stat {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .summary-row .stat:last-child {
    border-bottom: 0;
  }
}
