:root {
  --bg: #0f1115;
  --panel: #171a20;
  --panel-alt: #1c2128;
  --border: #262b33;
  --border-soft: #21252c;
  --border-strong: #2a3038;
  --text: #e8eaed;
  --muted: #9aa0ab;
  --muted-2: #7d8390;
  --muted-3: #565c68;
  --muted-4: #4a505c;
  --green: #34d399;
  --green-bright: #5eead4;
  --green-bg: #12291f;
  --green-border: #1e4534;
  --green-btn-bg: #0f3d27;
  --green-btn-border: #1d6b47;
  --amber: #fbbf24;
  --amber-bg: #2a1e0a;
  --amber-border: #78500f;
  --red: #f87171;
  --red-bg: #2a1418;
  --red-border: #472026;
  --blue: #93c5fd;
  --blue-bg: #1e3a8a;
  --mono: 'SF Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  height: 100%;
}

#app {
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
}

button, input {
  font-family: inherit;
  color: inherit;
}

.hidden { display: none !important; }

/* ---------- Top bar shared across views ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.topbar-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-title .shop-name { color: var(--muted-2); font-weight: 600; font-size: 18px; }

.steps {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 600;
}

.step-badge {
  padding: 9px 18px;
  border-radius: 22px;
  background: var(--panel-alt);
  color: var(--muted-3);
  transition: background .15s, color .15s;
}
.step-badge.active-order { background: var(--blue-bg); color: #bfdbfe; }
.step-badge.active-cash { background: #78350f; color: #fde68a; }
.step-badge.active-done { background: #134e2e; color: #86efac; }
.step-arrow { color: var(--muted-4); }

.topbar-actions { display: flex; align-items: center; gap: 14px; }

.switch-user-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--muted-2);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.switch-user-btn:hover { background: var(--panel-alt); color: var(--text); }

/* ---------- Login screen ---------- */

#view-login {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 28px;
}

.login-title {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.login-subtitle {
  font-size: 18px;
  color: var(--muted-2);
  margin-top: -16px;
}

.pin-dots { display: flex; gap: 20px; }
.pin-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: transparent;
  transition: background .1s, border-color .1s;
}
.pin-dot.filled { background: var(--green); border-color: var(--green); }
.pin-dots.error .pin-dot { border-color: var(--red); }
.pin-dots.error .pin-dot.filled { background: var(--red); }
.pin-dots.shake { animation: shake .3s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.login-error {
  color: var(--red);
  font-size: 14px;
  font-weight: 600;
  height: 18px;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 106px);
  gap: 10px;
}
.keypad.login-keypad { grid-template-columns: repeat(3, 104px); gap: 14px; }

.key-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  width: 106px;
  height: 82px;
  border-radius: 14px;
  background: var(--panel-alt);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background .08s;
}
.key-btn:hover { background: #232a33; }
.key-btn:active { transform: scale(0.96); background: #2a3340; }
.key-btn .key-num { font-size: 19px; font-weight: 800; font-family: var(--mono); }
.key-btn .key-label { font-size: 11px; font-weight: 600; color: var(--muted); }

/* Inside the kassa till, keys stretch to fill their grid cell (see
   #item-keypad/.pad-extra-row/#cash-keypad below) - scale their type up
   accordingly so text doesn't look lost in a much bigger button. */
#item-keypad .key-btn .key-num, .pad-extra-row .key-btn .key-num, #cash-keypad .key-btn.login-key {
  font-size: 36px;
}
#item-keypad .key-btn .key-label, .pad-extra-row .key-btn .key-label {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}
#item-keypad .key-btn, .pad-extra-row .key-btn {
  padding: 18px 22px;
  gap: 6px;
}

.key-btn.login-key {
  width: 104px;
  height: 78px;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 34px;
  font-weight: 800;
}

.key-btn.key-danger { background: var(--red-bg); border-color: var(--red-border); color: var(--red); }
.key-btn.key-danger:hover { background: #341a1f; }
.key-btn.key-danger .key-label { color: #c98d92; }

.key-btn.key-enter { background: var(--green-btn-bg); border-color: var(--green-btn-border); color: var(--green-bright); }
.key-btn.key-enter[data-stage="cash"] { background: #4a2e05; border-color: #78500f; color: var(--amber); }
.key-btn.key-enter[data-stage="done"] { background: var(--green-btn-bg); border-color: var(--green-btn-border); color: var(--green-bright); }
.key-btn.key-enter[data-stage="order"] { background: #0f2d57; border-color: #1d4c8c; color: var(--blue); }

.key-btn.key-discount.active { background: var(--amber-bg); border-color: var(--amber-border); color: var(--amber); }

.key-icon-row { display: flex; align-items: center; gap: 8px; }

/* ---------- Kassa layout ---------- */

#view-kassa {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.kassa-content {
  flex: 1;
  width: 100%;
}

.history-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.history-panel-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted-2);
  margin-bottom: 8px;
  white-space: nowrap;
}
.history-row {
  display: flex;
  flex-direction: column;
  border-radius: 10px;
  padding: 12px;
  cursor: default;
}
.history-row:hover { background: var(--panel-alt); }
.history-row-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.history-time { font-size: 14px; color: var(--muted-2); font-weight: 600; }
.history-total { font-family: var(--mono); font-size: 15px; font-weight: 700; color: #c7cbd4; white-space: nowrap; }
.history-summary { font-size: 13px; color: var(--muted-3); }
.history-detail {
  display: none;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
}
.history-row:hover .history-detail { display: flex; }
.history-line { display: flex; align-items: baseline; justify-content: space-between; }
.history-line-name { font-size: 15px; color: #c7cbd4; }
.history-line-qty { color: var(--muted-2); font-family: var(--mono); }
.history-line-total { font-family: var(--mono); font-size: 15px; color: var(--muted); }
.history-discount-row, .history-total-row, .history-cash-row, .history-change-row {
  display: flex; align-items: center; justify-content: space-between;
}
.history-total-row { padding-top: 4px; border-top: 1px solid var(--border-soft); }
.empty-note { color: var(--muted-4); font-size: 16px; padding: 8px 0; }

.order-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  min-height: 600px;
}
.order-panel-title {
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  margin-bottom: 16px;
}
.order-lines { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.order-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 13px 0;
  border-bottom: 1px solid var(--border-soft);
}
.order-line-left { display: flex; align-items: baseline; gap: 12px; }
.order-line-qty { font-family: var(--mono); font-size: 21px; color: var(--muted-2); width: 34px; }
.order-line-name { font-size: 23px; font-weight: 600; }
.order-line-total { font-family: var(--mono); font-size: 23px; color: #c7cbd4; }
.order-empty { color: var(--muted-4); font-size: 20px; padding: 20px 0; }

.order-totals {
  border-top: 1px solid var(--border);
  margin-top: 14px;
  padding-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.total-row { display: flex; align-items: center; justify-content: space-between; }
.total-row .label { font-size: 17px; font-weight: 600; color: var(--muted); }
.total-row .value { font-family: var(--mono); font-size: 19px; color: var(--muted); }
.total-row.discount .label, .total-row.discount .value { color: var(--amber); }
.total-row.grand .label { font-size: 18px; font-weight: 600; color: var(--muted); }
.total-row.grand .value { font-family: var(--mono); font-size: 42px; font-weight: 700; color: var(--green); }

.cash-row {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: var(--panel-alt);
  border-radius: 10px;
  padding: 14px 18px;
}
.cash-row .label { font-size: 17px; font-weight: 600; color: var(--muted); }
.cash-row .value { font-family: var(--mono); font-weight: 700; color: var(--text); }

.change-panel {
  display: none;
  flex-direction: column;
  gap: 8px;
  background: var(--green-bg);
  border: 1px solid var(--green-border);
  border-radius: 12px;
  padding: 20px 22px;
  animation: pulseIn .25s ease;
}
@keyframes pulseIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.change-panel .label { font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--green); }
.change-panel .value { font-family: var(--mono); font-size: 46px; font-weight: 800; color: var(--green-bright); }
.change-panel .countdown { font-size: 15px; font-weight: 600; color: #7dd3ac; }

.order-error { display: none; color: var(--red); font-size: 16px; font-weight: 600; }

.pad-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  min-height: 600px;
  box-sizing: border-box;
}

/* #normal-view and .cash-view are the two alternating faces of the pad
   column (order stage vs cash stage) - whichever is visible stretches to
   fill the whole card, and its keypad grid fills all the space that's left
   after the banner/title/shortcuts/actions take their natural height. */
#normal-view, .cash-view {
  flex: 1;
  width: 100%;
  min-height: 0;
  flex-direction: column;
  gap: 16px;
}
#normal-view { display: flex; }
.cash-view { display: none; }

.stage-banner { font-size: 22px; font-weight: 700; flex-shrink: 0; }

#item-keypad {
  flex: 4;
  min-height: 0;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, 1fr);
  width: 100%;
}

.pad-extra-row {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
}

#item-keypad .key-btn, .pad-extra-row .key-btn, #cash-keypad .key-btn {
  width: 100%;
  height: 100%;
}

.shortcuts-note {
  font-size: 14px;
  color: var(--muted-3);
  line-height: 1.7;
  max-width: 100%;
  flex-shrink: 0;
}
.shortcuts-note b { color: var(--muted-2); }

/* ---------- Cash entry stage ---------- */

.cash-view-title { font-size: 34px; font-weight: 800; color: var(--amber); line-height: 1.25; flex-shrink: 0; }

#cash-keypad {
  flex: 1;
  min-height: 0;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, 1fr);
  width: 100%;
}

.cash-actions { display: flex; flex-direction: column; gap: 12px; flex-shrink: 0; }
.cash-action-btn {
  width: 100%;
  box-sizing: border-box;
  padding: 24px 28px;
  border-radius: 14px;
  font-size: 26px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border: 1px solid transparent;
}
.cash-action-btn.primary { background: var(--green-btn-bg); border-color: var(--green-btn-border); color: var(--green-bright); }
.cash-action-btn.primary:hover { background: #12492e; }
.cash-action-btn.secondary {
  background: var(--panel-alt); border-color: var(--border-strong); color: var(--text);
  font-size: 20px; font-weight: 700; padding: 18px 28px;
}
.cash-action-btn.secondary:hover { background: #232a33; }
.cash-action-btn.danger {
  background: var(--red-bg); border-color: var(--red-border); color: var(--red);
  font-size: 20px; font-weight: 700; padding: 18px 28px;
}
.cash-action-btn.danger:hover { background: #341a1f; }
.cash-action-btn:active { transform: scale(0.98); }
.key-hint {
  font-size: 14px; font-weight: 700; letter-spacing: 0.04em;
  padding: 5px 10px; border-radius: 6px;
}
.cash-action-btn.primary .key-hint { background: #134e2e; color: #86efac; }
.cash-action-btn.secondary .key-hint { background: #262b33; color: var(--muted); }
.cash-action-btn.danger .key-hint { background: var(--red-border); color: #fca5a5; }

/* ---------- Admin ---------- */

#view-admin { flex: 1; display: flex; flex-direction: column; max-width: 1200px; margin: 0 auto; width: 100%; padding: 0 24px 32px; }

.admin-tabs { display: flex; gap: 8px; padding: 20px 0; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.admin-tab {
  background: transparent; border: 1px solid transparent; color: var(--muted-2);
  padding: 10px 18px; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.admin-tab:hover { background: var(--panel-alt); }
.admin-tab.active { background: var(--panel-alt); color: var(--text); border-color: var(--border-strong); }

.admin-panel { display: none; flex-direction: column; gap: 20px; }
.admin-panel.active { display: flex; }

.admin-section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-2); }

.admin-columns { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }

.admin-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  flex: 1;
  min-width: 340px;
}

.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted-3); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.admin-table td { padding: 10px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.admin-table tr.inactive { opacity: 0.45; }
.admin-table input[type="text"], .admin-table input[type="number"] {
  background: var(--panel-alt); border: 1px solid var(--border-strong); color: var(--text);
  border-radius: 8px; padding: 7px 9px; font-size: 14px; width: 100%;
}
.admin-slot-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 8px; background: var(--panel-alt);
  font-family: var(--mono); font-weight: 700; font-size: 13px; color: var(--muted);
}

.btn {
  border: 1px solid var(--border-strong);
  background: var(--panel-alt);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: #232a33; }
.btn.btn-primary { background: var(--green-btn-bg); border-color: var(--green-btn-border); color: var(--green-bright); }
.btn.btn-primary:hover { background: #12492e; }
.btn.btn-danger { background: var(--red-bg); border-color: var(--red-border); color: var(--red); }
.btn.btn-danger:hover { background: #341a1f; }
.btn.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.admin-form-row { display: flex; gap: 10px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.admin-form-row label { font-size: 12px; color: var(--muted-2); font-weight: 600; display: flex; flex-direction: column; gap: 4px; }
.admin-form-row input, .admin-form-row select {
  background: var(--panel-alt); border: 1px solid var(--border-strong); color: var(--text);
  border-radius: 8px; padding: 8px 10px; font-size: 14px;
}
.admin-form-row select { min-width: 110px; }

.admin-toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--panel);
  border: 1px solid var(--border-strong); color: var(--text); padding: 12px 18px;
  border-radius: 10px; font-size: 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.4);
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; pointer-events: none;
  z-index: 100;
}
.admin-toast.show { opacity: 1; transform: translateY(0); }
.admin-toast.error { border-color: var(--red-border); color: var(--red); }

.admin-summary-row { display: flex; gap: 16px; flex-wrap: wrap; }
.summary-tile {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px 20px; min-width: 160px; flex: 1;
}
.summary-tile .tile-label { font-size: 12px; color: var(--muted-2); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.summary-tile .tile-value { font-family: var(--mono); font-size: 26px; font-weight: 700; color: var(--green); margin-top: 6px; }

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

.toggle-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.toggle-switch input { display: none; }
.toggle-track {
  width: 36px; height: 20px; border-radius: 10px; background: var(--border-strong); position: relative; transition: background .15s;
}
.toggle-track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--muted); transition: transform .15s, background .15s;
}
.toggle-switch input:checked + .toggle-track { background: var(--green-border); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(16px); background: var(--green); }

/* ---------- Responsive ---------- */
/* Column stacking below the lg breakpoint is handled by Bootstrap's
   col-12 col-lg-* classes directly in index.html. */

@media (max-width: 720px) {
  .topbar { padding: 14px 16px; }
  .topbar-title .shop-name { display: none; }
}
