* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: #0f172a;
  color: #f8fafc;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 10;
}

.banner {
  padding: 10px 14px;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
}

.banner.offline {
  background: #7f1d1d;
  color: #fecaca;
}

.banner.online {
  background: #14532d;
  color: #bbf7d0;
}

.banner.pc-stale {
  background: #78350f;
  color: #fde68a;
}

.screen {
  padding: 16px;
  max-width: 480px;
  margin: 0 auto;
}

h1 {
  font-size: 22px;
  margin: 0 0 8px;
}

.hint {
  color: #94a3b8;
  font-size: 14px;
  line-height: 1.4;
}

.pairing-code {
  font-size: 64px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-align: center;
  margin: 24px 0 12px;
  color: #38bdf8;
}

.status-text {
  text-align: center;
  color: #cbd5e1;
  font-size: 15px;
}

.session-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 14px;
}

.code-pill {
  background: #1e293b;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
}

.total-block {
  background: #1e293b;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  margin-bottom: 12px;
}

.total-label {
  font-size: 13px;
  color: #94a3b8;
}

.total-qty {
  font-size: 56px;
  font-weight: 800;
  line-height: 1.1;
}

.last-scan {
  background: #334155;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 14px;
}

.qty-row {
  margin-bottom: 14px;
}

.qty-label {
  display: block;
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 6px;
}

.qty-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.qty-buttons button {
  flex: 1;
  min-width: 56px;
}

#qty-custom {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #475569;
  background: #1e293b;
  color: #f8fafc;
  font-size: 16px;
}

.manual-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

#manual-sku {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #475569;
  background: #1e293b;
  color: #f8fafc;
  font-size: 16px;
}

.btn {
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}

.btn.secondary {
  display: block;
  width: 100%;
  margin-top: 16px;
  background: #334155;
}

.btn.danger {
  width: 100%;
  margin-top: 20px;
  background: #b91c1c;
}

.log-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.log-actions .btn.secondary,
.log-actions .btn.errors {
  flex: 1;
  width: auto;
  margin-top: 0;
}

.btn.errors {
  background: #b91c1c;
}

.qty-buttons button.active {
  background: #2563eb;
  outline: 2px solid #93c5fd;
}

.recent-scans {
  margin-bottom: 16px;
}

.scan-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  background: #1e293b;
  margin-bottom: 6px;
  font-size: 13px;
}

.scan-entry.error {
  background: #450a0a;
  color: #fecaca;
}

.scan-entry.ok {
  background: #052e16;
  color: #bbf7d0;
}

.scan-entry.pending {
  background: #422006;
  color: #fde68a;
}

.items-list h2 {
  font-size: 15px;
  margin: 0 0 8px;
  color: #94a3b8;
}

.style-card {
  background: #1e293b;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.style-card .style-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  margin-bottom: 6px;
}

.style-card .style-name {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 600;
  color: #e2e8f0;
}

.pill-group {
  display: inline-flex;
  align-items: stretch;
  flex-shrink: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 0;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
  white-space: nowrap;
}

.pill-style {
  background: #1d4ed8;
  color: #dbeafe;
  border: 1px solid #3b82f6;
}

.pill-qty {
  background: #ca8a04;
  color: #fef9c3;
  border: 1px solid #eab308;
  border-left: none;
}

.style-name,
.pill-style {
  cursor: pointer;
}

.style-name {
  text-decoration: underline;
  text-decoration-color: rgba(148, 163, 184, 0.5);
  text-underline-offset: 3px;
}

.style-card.is-editing .style-name {
  color: #7dd3fc;
}

.size-edit-panel {
  display: none;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #334155;
}

.style-card.is-editing .size-edit-panel {
  display: block;
}

.size-edit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.size-edit-label {
  font-size: 13px;
  font-weight: 600;
  min-width: 48px;
}

.size-qty-input {
  width: 72px;
  padding: 6px 8px;
  border: 1px solid #475569;
  border-radius: 6px;
  background: #0f172a;
  color: #f8fafc;
  font-size: 16px;
  text-align: center;
}

.size-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.size-chip {
  background: #334155;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
}

.scan-field-block {
  margin-bottom: 14px;
}

.scan-field-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #86efac;
  margin-bottom: 6px;
}

.scan-input {
  width: 100%;
  padding: 14px 12px;
  font-size: 18px;
  font-weight: 600;
  border-radius: 10px;
  border: 2px solid #22c55e;
  background: #052e16;
  color: #f0fdf4;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.35);
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
}

.scan-input:focus {
  outline: none;
  border-color: #4ade80;
  box-shadow: 0 0 16px rgba(74, 222, 128, 0.55);
}

.error-flash {
  position: fixed;
  inset: 0;
  background: rgba(185, 28, 28, 0.92);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  pointer-events: none;
}

.error-flash.hidden {
  display: none;
}

.scan-error-ack-modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.scan-error-ack-modal.hidden {
  display: none;
}

.scan-error-ack-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
}

.scan-error-ack-sheet {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: #1e293b;
  border: 2px solid #ef4444;
  border-radius: 12px;
  padding: 18px 16px 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.scan-error-ack-sheet h2 {
  margin: 0 0 10px;
  color: #fca5a5;
  font-size: 20px;
}

.scan-error-ack-sheet p {
  margin: 0 0 12px;
  color: #e2e8f0;
  line-height: 1.4;
}

.scan-error-ack-value {
  font-family: ui-monospace, monospace;
  background: #450a0a;
  border: 1px solid #991b1b;
  border-radius: 8px;
  padding: 10px;
  color: #fecaca;
  word-break: break-all;
}

.scan-error-ack-sheet .btn.primary {
  width: 100%;
  margin-top: 14px;
}

.scan-log-panel {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  z-index: 90;
  display: flex;
  align-items: flex-end;
}

.scan-log-sheet {
  width: 100%;
  max-height: 78vh;
  background: #1e293b;
  border-radius: 16px 16px 0 0;
  padding: 12px 14px 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.scan-log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.scan-log-header h2 {
  margin: 0;
  font-size: 18px;
}

.scan-log-header .btn.secondary {
  width: auto;
  margin: 0;
  padding: 8px 12px;
}

.grouped-items {
  margin-top: 12px;
  margin-bottom: 8px;
}

.grouped-items-title {
  margin: 0 0 8px;
  font-size: 15px;
  color: #94a3b8;
  font-weight: 600;
}

.grouped-items-list {
  max-height: 42vh;
  overflow-y: auto;
}

.scan-log-list {
  overflow-y: auto;
  flex: 1;
  min-height: 120px;
}

.scan-log-entry {
  background: #334155;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  font-size: 13px;
}

.scan-log-entry.error {
  background: #450a0a;
  color: #fecaca;
}

.scan-log-entry.latest {
  outline: 2px solid #38bdf8;
}

.scan-log-entry-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 12px;
  color: #94a3b8;
}

.scan-log-entry-name {
  font-weight: 600;
  margin-bottom: 4px;
}

.scan-log-empty {
  color: #94a3b8;
  text-align: center;
  padding: 24px 12px;
}
