:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --primary: #1e6fd9;
  --primary-dark: #1558ad;
  --text: #1a2332;
  --muted: #5c6b7a;
  --danger: #c0392b;
  --border: #d8dee8;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(26, 35, 50, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

.screen.hidden,
.hidden {
  display: none !important;
}

.hero {
  text-align: center;
  margin: 24px 0 32px;
}

.hero h1 {
  margin: 0;
  font-size: 2rem;
}

.hero p {
  margin: 8px 0 0;
  color: var(--muted);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.topbar-label {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.topbar-value {
  margin: 4px 0 0;
  font-weight: 700;
  font-size: 1.05rem;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

.field-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1.1rem;
  background: var(--surface);
}

.field-input:focus {
  outline: none;
  border-color: var(--primary);
}

.pin-display {
  margin: 24px auto 16px;
  width: 180px;
  text-align: center;
  font-size: 2rem;
  letter-spacing: 0.35em;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

.keypad button {
  padding: 18px 0;
  font-size: 1.4rem;
  border: none;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.keypad button:active {
  transform: scale(0.97);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: #fff;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: #e8eef7;
  color: var(--text);
  white-space: nowrap;
}

.btn-ghost {
  background: transparent;
  color: var(--primary);
  padding: 8px 10px;
}

.btn-sm {
  font-size: 0.9rem;
}

.error {
  color: var(--danger);
  margin: 12px 0;
}

.info {
  color: var(--primary);
  margin: 12px 0;
  font-weight: 600;
}

.status {
  text-align: center;
  color: var(--muted);
  margin: 12px 0 20px;
}

.card-list {
  display: grid;
  gap: 12px;
}

.order-card {
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.order-card:active {
  border-color: var(--primary);
}

.order-card strong {
  display: block;
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.order-card span {
  color: var(--muted);
  font-size: 0.95rem;
}

.scanner-wrap {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 320px;
  margin-bottom: 12px;
  position: relative;
}

#scanner-video {
  display: block;
  width: 100%;
  min-height: 320px;
  max-height: 420px;
  object-fit: contain;
  background: #000;
}

.scanner-wrap--starting #scanner-video {
  visibility: hidden;
}

.scanner-wrap--starting {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.95rem;
}

#scanner-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 16px;
  text-align: center;
  z-index: 2;
  pointer-events: none;
}

.manual-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 12px;
}

.btn-finish {
  width: 100%;
  background: #2e7d32;
  color: #fff;
  margin-bottom: 12px;
}

.recent-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.recent-list li {
  background: var(--surface);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-size: 0.95rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.recent-main {
  min-width: 0;
}

.recent-qty {
  font-weight: 700;
  white-space: nowrap;
  text-align: right;
  flex-shrink: 0;
}

.recent-list small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.quantity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

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

.quantity-field {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-left: auto;
}

.quantity-unit {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  min-width: 2.5rem;
}

.quantity-input {
  width: 110px;
  font-size: 1.6rem;
  text-align: right;
  margin-bottom: 0;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: 20px 20px 14px 14px;
  padding: 24px 20px;
  box-shadow: var(--shadow);
}

.modal-product {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0 0 4px;
}

.modal-index {
  color: var(--muted);
  margin: 0 0 16px;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

h2, h3 {
  margin: 0 0 14px;
}

h3 {
  font-size: 1rem;
  color: var(--muted);
}
