/* Ludwig POS terminal — self-contained styles (no CDN, works offline). */
:root {
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --bg: #0b1020;
  --panel: #161c30;
  --panel-2: #1e2740;
  --ink: #eef1f8;
  --muted: #97a0be;
  --ok: #16a34a;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app { display: flex; flex-direction: column; min-height: 100vh; }
.muted { color: var(--muted); }
.pad { padding: 1rem; }
.error { color: var(--danger); margin: 0.25rem 0 0; }

/* Top bar ---------------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; padding: 0.7rem 1rem;
  background: var(--panel); border-bottom: 1px solid #0007;
  padding-top: max(0.7rem, env(safe-area-inset-top));
}
.topbar__id { display: flex; flex-direction: column; line-height: 1.2; }
.topbar__id .muted { font-size: 0.8rem; }
.topbar__status { display: flex; align-items: center; gap: 0.5rem; }
.pill {
  font-size: 0.78rem; font-weight: 600; padding: 0.3rem 0.6rem;
  border-radius: 999px; border: 0; color: #fff;
}
.pill--online { background: var(--ok); }
.pill--offline { background: var(--warn); color: #201400; }
.pill--queue { background: var(--accent); cursor: pointer; }
.pill--queue:disabled { opacity: 0.6; }
.linkbtn { background: none; border: 0; color: var(--muted); font-size: 0.8rem; cursor: pointer; }

/* Event-laptop-hub reachability banner ------------------------------------ */
.hub-banner {
  padding: 0.5rem 1rem; text-align: center; font-size: 0.85rem; font-weight: 600;
  background: var(--warn); color: #201400;
}

/* Screens ---------------------------------------------------------------- */
.screen { flex: 1; display: flex; }

/* Login ------------------------------------------------------------------ */
.login {
  margin: auto; width: min(92vw, 380px);
  background: var(--panel); padding: 1.5rem; border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 0.85rem;
}
.login h1 { margin: 0; font-size: 1.4rem; }
.login label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); }
.login input {
  padding: 0.8rem; font-size: 1.1rem; border-radius: 10px;
  border: 1px solid #2c3454; background: var(--panel-2); color: var(--ink);
}
button {
  font-family: inherit; font-size: 1rem; cursor: pointer;
}
.login button, .charge {
  padding: 0.9rem; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 1.05rem;
}
.login button:disabled, .charge:disabled { opacity: 0.5; }

/* Sell ------------------------------------------------------------------- */
.sell { flex-direction: column; }
@media (min-width: 760px) { .sell { flex-direction: row; } }

.catalog { flex: 1; padding: 1rem; overflow-y: auto; }
.grid {
  display: grid; gap: 0.7rem;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}
.product {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.35rem;
  padding: 1rem; min-height: 84px; text-align: left;
  background: var(--panel-2); color: var(--ink);
  border: 1px solid #2c3454; border-radius: var(--radius);
}
.product:active { transform: scale(0.98); }
.product--low { border-color: var(--warn); }
.product__name { font-weight: 600; }
.product__price { color: var(--muted); font-variant-numeric: tabular-nums; }
.lowstock-badge {
  font-size: 0.65rem; font-weight: 700; background: var(--warn); color: #201400;
  padding: 0.1rem 0.4rem; border-radius: 999px;
}
.product__stock {
  font-size: 0.7rem; font-weight: 700; padding: 0.1rem 0.4rem; border-radius: 999px;
}
.product__stock--out { background: var(--danger); color: #2a0d0d; }

/* Cart ------------------------------------------------------------------- */
.cart {
  background: var(--panel); border-top: 1px solid #0007;
  display: flex; flex-direction: column;
  width: 100%;
}
@media (min-width: 760px) { .cart { width: 340px; border-top: 0; border-left: 1px solid #0007; } }
.cart h2 { margin: 0; padding: 1rem 1rem 0.5rem; font-size: 1rem; }
.cart__lines { flex: 1; overflow-y: auto; padding: 0 1rem; min-height: 90px; }
.line {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 0.75rem;
  padding: 0.55rem 0; border-bottom: 1px solid #ffffff10;
}
.line__qty { display: flex; align-items: center; gap: 0.5rem; }
.line__qty button {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid #2c3454;
  background: var(--panel-2); color: var(--ink); font-size: 1.1rem; line-height: 1;
}
.line__total { font-variant-numeric: tabular-nums; }
.cart__foot { padding: 1rem; padding-bottom: max(1rem, env(safe-area-inset-bottom)); display: grid; gap: 0.7rem; }
.total { display: flex; justify-content: space-between; align-items: baseline; font-size: 1.2rem; }
.total strong { font-variant-numeric: tabular-nums; }
.charge { width: 100%; }

/* Gated-action controls -------------------------------------------------- */
.line--cart { grid-template-columns: 1fr auto auto auto; }
.line__name { display: flex; flex-direction: column; gap: 0.2rem; align-items: flex-start; }
.pricebtn {
  background: none; border: 0; color: var(--muted); padding: 0;
  font-size: 0.8rem; text-decoration: underline dotted; cursor: pointer;
}
.pricebtn--over { color: var(--warn); }
.rm {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid #4a2230;
  background: #2a1620; color: var(--danger); font-size: 1.1rem; line-height: 1;
}
.cart__actions { display: flex; gap: 0.5rem; }
.chip {
  flex: 1; padding: 0.6rem; border-radius: 10px; border: 1px solid #2c3454;
  background: var(--panel-2); color: var(--ink); font-size: 0.9rem;
}
.chip:disabled { opacity: 0.5; }
.chip--on { background: var(--warn); color: #201400; border-color: var(--warn); font-weight: 700; }
.chip--cancel { background: #2a1620; color: var(--danger); border-color: #4a2230; font-weight: 700; }
.refund-badge {
  font-size: 0.7rem; font-weight: 700; background: var(--warn); color: #201400;
  padding: 0.15rem 0.45rem; border-radius: 999px; vertical-align: middle;
}
.split-cash-label {
  display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--muted);
}
.split-cash-label input {
  padding: 0.6rem; font-size: 1rem; border-radius: 10px;
  border: 1px solid #2c3454; background: var(--panel-2); color: var(--ink);
}
.total--sub { font-size: 0.95rem; color: var(--muted); }
.total--sub span { color: var(--muted); }
.total--refund strong { color: var(--danger); }
.money--refund { color: var(--danger); }

/* Bottom-sheet modals (override / discount / price) ---------------------- */
.sheet {
  margin: auto; width: min(92vw, 380px);
  background: var(--panel); border-radius: var(--radius); padding: 1.5rem;
  display: flex; flex-direction: column; gap: 0.85rem;
}
.sheet h2 { margin: 0; }
.sheet label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); }
.checkbox-row {
  display: flex; flex-direction: row !important; align-items: center; gap: 0.5rem;
  font-size: 0.85rem; color: var(--muted);
}
.checkbox-row input[type="checkbox"] { width: 1.1rem; height: 1.1rem; flex-shrink: 0; }
.sheet input {
  padding: 0.8rem; font-size: 1.1rem; border-radius: 10px;
  border: 1px solid #2c3454; background: var(--panel-2); color: var(--ink);
}
.sheet__buttons { display: flex; gap: 0.6rem; margin-top: 0.25rem; }
.sheet__buttons .charge { flex: 1; }
.ghost {
  padding: 0.9rem 1rem; border-radius: 12px; border: 1px solid #2c3454;
  background: transparent; color: var(--ink); font-weight: 600;
}

/* Receipt modal ---------------------------------------------------------- */
.modal {
  position: fixed; inset: 0; background: #000a; display: flex; padding: 1rem;
  align-items: center; justify-content: center; z-index: 50;
}
.receipt {
  width: min(92vw, 360px); background: var(--panel); border-radius: var(--radius);
  padding: 1.25rem; display: flex; flex-direction: column; gap: 0.75rem;
}
.receipt h2 { margin: 0; }
.receipt__no { margin: 0; font-size: 0.9rem; }
.receipt__lines { display: flex; flex-direction: column; gap: 0.1rem; }
.receipt__lines .line { grid-template-columns: 1fr auto; }
