:root {
  --bg: #0f1420;
  --card: #171e2e;
  --border: #2a3348;
  --text: #eef1f7;
  --muted: #93a0b8;
  --accent: #3d8bfd;
  --good: #2fbf71;
  --bad: #ef4444;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

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

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

header.topbar h1 {
  font-size: 18px;
  margin: 0;
}

header.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  margin-left: 16px;
  font-size: 14px;
}

header.topbar nav a.active,
header.topbar nav a:hover {
  color: var(--text);
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

input, select, button {
  font-size: 16px;
  font-family: inherit;
}

input[type="text"], input[type="password"], input[type="number"], select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0d1220;
  color: var(--text);
  margin-top: 4px;
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-top: 10px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 12px 16px;
  background: var(--accent);
  color: white;
  font-weight: 600;
}

button.secondary {
  background: #2a3348;
  color: var(--text);
}

button.danger {
  background: var(--bad);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.row {
  display: flex;
  gap: 10px;
}

.row > * {
  flex: 1;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text);
  background: #0d1220;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  flex: 1;
  justify-content: center;
}

.check-label input {
  width: auto;
  margin: 0;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 500;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 24px 16px;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  margin: 0;
}

.thumb {
  cursor: pointer;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.lightbox-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: white;
  font-size: 36px;
  line-height: 1;
  cursor: pointer;
  padding: 8px;
  z-index: 810;
}

.lightbox-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
  max-height: 100%;
  overflow-y: auto;
}

.lightbox-img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 10px;
  background: #0d1220;
}

.lightbox-info {
  text-align: center;
  margin-top: 16px;
  color: var(--text);
}

.gen-filter-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.compliance-pill {
  display: inline-block;
  padding: 1px 6px;
  margin: 1px;
  border-radius: 999px;
  background: #0d1220;
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}

#scanFlash {
  position: fixed;
  inset: 0;
  background: var(--good);
  opacity: 0;
  pointer-events: none;
  z-index: 999;
  transition: opacity 0.15s ease-out;
}

#scanFlash.flash {
  opacity: 0.85;
  transition: opacity 0.05s ease-in;
}

#reader {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
}

.part-info {
  text-align: center;
}

.part-info .qty {
  font-size: 48px;
  font-weight: 700;
  margin: 8px 0;
}

.part-info .part-number {
  font-size: 20px;
  font-weight: 600;
}

.part-info .description {
  color: var(--muted);
  margin-bottom: 8px;
}

.adjust-buttons {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.adjust-buttons button {
  flex: 1;
  font-size: 22px;
  padding: 16px;
}

.msg {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}

.msg.error {
  background: rgba(239, 68, 68, 0.15);
  color: #ff8080;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.msg.success {
  background: rgba(47, 191, 113, 0.15);
  color: #6ee7a0;
  border: 1px solid rgba(47, 191, 113, 0.4);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
}

.qty-pill {
  display: inline-block;
  min-width: 28px;
  text-align: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #0d1220;
  border: 1px solid var(--border);
  font-weight: 600;
}

.qty-pill.low {
  color: #ff8080;
  border-color: rgba(239, 68, 68, 0.4);
}

.search-box {
  margin-bottom: 12px;
}

.part-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.part-actions button {
  padding: 4px 10px;
  font-size: 13px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.thumb {
  display: block;
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin-bottom: 4px;
}

.thumb-empty {
  background: #0d1220;
}

.part-photo {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 10px;
  background: #0d1220;
}

.file-input-wrap {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}
