:root {
  --bg-primary: #0a0e17;
  --bg-surface: #111827;
  --bg-card: #1f2937;
  --border-color: #374151;
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --accent-laser: #ef4444;
  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-blue: #3b82f6;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* Device Top Status Bar */
.status-bar {
  background: #030712;
  border-bottom: 1px solid var(--border-color);
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
}

.status-left, .status-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.led-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-success);
  box-shadow: 0 0 8px var(--accent-success);
  display: inline-block;
  animation: pulse-led 2s infinite;
}

@keyframes pulse-led {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.9); }
}

.device-tag {
  color: #34d399;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.status-meta {
  color: var(--text-secondary);
}

/* Main Container */
.app-container {
  flex: 1;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Station Card */
.station-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.station-title {
  font-size: 11px;
  font-family: ui-monospace, monospace;
  color: #818cf8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.station-name {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
}

.badge {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
  font-family: ui-monospace, monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
}

/* Viewfinder Area */
.viewfinder-card {
  position: relative;
  background: #030712;
  border: 2px solid #374151;
  border-radius: 16px;
  height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.8);
  transition: border-color 0.2s ease;
}

.viewfinder-card.scanning {
  border-color: var(--accent-laser);
}

.viewfinder-card.verified {
  border-color: var(--accent-success);
}

.laser-beam {
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #ef4444, #f87171, #ef4444, transparent);
  box-shadow: 0 0 16px 2px #ef4444;
  opacity: 0;
  pointer-events: none;
}

.viewfinder-card.scanning .laser-beam {
  animation: sweep 1.4s ease-in-out infinite;
  opacity: 1;
}

@keyframes sweep {
  0% { top: 10%; opacity: 0; }
  25% { opacity: 1; }
  75% { opacity: 1; }
  100% { top: 90%; opacity: 0; }
}

.aim-reticle {
  width: 220px;
  height: 80px;
  border: 1.5px dashed rgba(239, 68, 68, 0.4);
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.03);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  font-weight: 600;
  color: #f87171;
  letter-spacing: 1px;
  transition: all 0.2s ease;
}

.viewfinder-card.verified .aim-reticle {
  border-color: var(--accent-success);
  color: #34d399;
  background: rgba(16, 185, 129, 0.08);
}

.viewfinder-status {
  margin-top: 10px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Hardware Trigger Button */
.trigger-btn {
  background: #dc2626;
  color: #ffffff;
  border: 1px solid rgba(248, 113, 113, 0.4);
  border-radius: 12px;
  padding: 14px 20px;
  font-family: ui-monospace, monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.05s ease, background 0.15s ease;
  min-height: 52px;
}

.trigger-btn:hover {
  background: #ef4444;
}

.trigger-btn:active {
  transform: scale(0.98);
  background: #b91c1c;
}

/* Quick Tools Bar */
.tools-bar {
  display: flex;
  gap: 8px;
}

.tool-btn {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s;
}

.tool-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: #4b5563;
}

.tool-btn.active {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.4);
}

/* Ledger Card */
.ledger-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 200px;
}

.ledger-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
}

.ledger-title {
  font-weight: 700;
  color: #d1d5db;
  text-transform: uppercase;
}

.ledger-count {
  color: #818cf8;
}

.ledger-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
}

.ledger-item {
  background: rgba(17, 24, 39, 0.8);
  border: 1px solid #374151;
  padding: 10px 12px;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: border-color 0.3s;
}

.ledger-item.new-item {
  border-color: var(--accent-success);
  background: rgba(16, 185, 129, 0.05);
}

.item-code {
  color: #34d399;
  font-weight: 700;
}

.item-desc {
  color: #9ca3af;
  font-size: 10px;
  margin-left: 6px;
}

.item-badge {
  font-size: 10px;
  font-weight: 700;
  color: #34d399;
  background: rgba(16, 185, 129, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Offline Banner */
.offline-banner {
  display: none;
  background: #78350f;
  border: 1px solid #d97706;
  color: #fef3c7;
  padding: 8px 12px;
  border-radius: 8px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  text-align: center;
}

.offline-banner.visible {
  display: block;
}
