:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-alt: #273449;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #22d3ee;
  --accent-dark: #0891b2;
  --danger: #f87171;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  height: 100%;
}

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

button, input {
  font-family: inherit;
}

.centered-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
}

.brand h1 {
  margin: 0;
  font-size: 1.5rem;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field span {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 1rem;
}

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

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.checkbox-field input {
  width: 18px;
  height: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 13px 16px;
  border-radius: 10px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #06222b;
}

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

.btn-secondary {
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.error-text {
  color: var(--danger);
  font-size: 0.9rem;
  min-height: 1.2em;
  margin: 0 0 12px;
}

.hint-text {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.topbar-user {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.topbar-spacer {
  width: 36px;
}

.btn-logout, .btn-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}

.menu-page {
  padding: 24px;
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-size: 1.1rem;
  font-weight: 600;
}

.menu-item:active {
  background: var(--surface-alt);
}

.status-page {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 480px;
  margin: 0 auto;
}

.scan-card {
  display: flex;
  flex-direction: column;
}

.scanner-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 16px;
}

.scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-video[hidden] {
  display: none;
}

.scanner-guide {
  position: absolute;
  inset: 20% 10%;
  border: 2px solid var(--accent);
  border-radius: 10px;
  pointer-events: none;
}

.manual-form {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.product-card {
  display: flex;
  flex-direction: column;
}

.product-details {
  margin-bottom: 16px;
}

.product-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.product-row:last-child {
  border-bottom: none;
}

.product-label {
  color: var(--text-muted);
}

.product-value {
  font-weight: 600;
}

.button-row {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.button-row .btn {
  margin-bottom: 0;
}

.section-title {
  margin: 0 0 16px;
  font-size: 1.1rem;
}

.field select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 1rem;
}

.field select:focus {
  outline: none;
  border-color: var(--accent);
}

.context-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
}

.context-info {
  color: var(--text);
  font-weight: 600;
}

.context-sep {
  color: var(--text-muted);
  margin: 0 6px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px;
}

.serial-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.serial-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  border-radius: 12px;
  background: var(--accent);
  color: #06222b;
  font-weight: 700;
}

.serial-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
}

.serial-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
}

.serial-remove {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--accent);
  color: #06222b;
  padding: 12px 20px;
  border-radius: 10px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
  max-width: 90%;
  text-align: center;
}

.toast-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
