*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #0f172a;
  color: #e2e8f0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.hidden { display: none !important; }

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem 0.875rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
header h1 { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.01em; }
.header-left { display: flex; align-items: center; gap: 0.5rem; }

/* Sync dot */
.sync-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #334155;
  transition: background 0.3s;
}
.sync-dot.connected { background: #22c55e; }

/* Buttons */
.btn-primary {
  background: #7c3aed;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 0.9rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: opacity 0.15s;
}
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary:not(:disabled):active { opacity: 0.8; }

.btn-secondary {
  background: transparent;
  color: #94a3b8;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 0.45rem 0.875rem;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}
.btn-secondary:active { opacity: 0.7; }

/* Auth screen */
.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  max-width: 340px;
  width: 100%;
  margin: auto;
  padding: 2rem 1.5rem;
}
.auth-icon { font-size: 3rem; }
.auth-container h1 { font-size: 2rem; font-weight: 700; }

input[type="password"] {
  width: 100%;
  background: rgba(255,255,255,0.08);
  border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 0.875rem 1rem;
  color: #e2e8f0;
  font-size: 1.1rem;
  outline: none;
  transition: border-color 0.15s;
}
input[type="password"]:focus { border-color: #7c3aed; }

.error { color: #f87171; font-size: 0.875rem; text-align: center; }

/* Incoming screen */
.incoming-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem 1.5rem;
  flex: 1;
}
.incoming-icon { font-size: 3rem; margin-top: 0.5rem; }
.incoming-subtitle { color: #94a3b8; font-size: 0.9rem; text-align: center; }
.incoming-preview {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  padding: 1rem;
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  color: #64748b;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow-y: auto;
  line-height: 1.55;
}
.incoming-container .btn-primary { margin-top: auto; }

/* Processing screen */
.processing-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 3rem 1.5rem;
  flex: 1;
  justify-content: center;
}
.spinner {
  width: 48px; height: 48px;
  border: 3px solid rgba(124,58,237,0.2);
  border-top-color: #7c3aed;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.processing-title { font-size: 1rem; color: #cbd5e1; }

#processing-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
#processing-steps li {
  font-size: 0.9rem;
  color: #475569;
  transition: color 0.2s;
}
#processing-steps li.step-done { color: #22c55e; }
#processing-steps li.step-active { color: #a78bfa; }

/* List screen */
#list-container {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 1.5rem;
}

.category-section { margin-top: 0.5rem; }

.category-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.category-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.07);
}

.list-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.2rem 0.75rem;
  padding: 0.65rem 0.75rem;
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.2s;
  user-select: none;
}
.list-item:active { opacity: 0.7; }
.list-item.ticked { opacity: 0.35; }

.item-emoji {
  font-size: 1.7rem;
  width: 2.2rem;
  text-align: center;
  flex-shrink: 0;
  line-height: 1;
}
.item-info { flex: 1; min-width: 0; }
.item-name {
  font-size: 0.95rem;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item.ticked .item-name { text-decoration: line-through; }
.item-qty { font-size: 0.78rem; color: #64748b; margin-top: 2px; }

.checkbox {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid #334155;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: #fff;
  transition: background 0.15s, border-color 0.15s;
}
.list-item.ticked .checkbox {
  background: #22c55e;
  border-color: #22c55e;
}
