/* ===== LOGIN SCREEN ===== */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #0a0a0a;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-overlay.hidden {
  display: none;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 40px 36px 32px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}

.login-brand {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.login-logo {
  width: 100px;
  height: 100px;
}

.login-brand h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: #e0e0e0;
  line-height: 1.3;
}

.login-brand p {
  margin: 0;
  font-size: 12px;
  color: #666;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.login-field label {
  font-size: 12px;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper svg {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: #666;
  pointer-events: none;
  flex-shrink: 0;
}

.input-wrapper input {
  width: 100%;
  background: #0a0a0a;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 12px 12px 12px 40px;
  color: #e0e0e0;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.input-wrapper input:focus {
  border-color: #2563eb;
}

.input-wrapper input::placeholder {
  color: #444;
}

.toggle-password {
  position: absolute;
  right: 12px;
  color: #666;
  padding: 0;
  display: flex;
  align-items: center;
  transition: color 0.2s;
}

.toggle-password:hover {
  color: #e0e0e0;
}

.toggle-password svg {
  position: static;
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.login-error {
  display: none;
  align-items: center;
  gap: 8px;
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.3);
  color: #f87171;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
}

.login-error.visible {
  display: flex;
}

.login-error svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px;
  background: #dc2626;
  color: #fff;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s, transform 0.1s;
  letter-spacing: 0.02em;
  margin-top: 4px;
}

.login-btn:hover {
  background: #b91c1c;
}

.login-btn:active {
  transform: scale(0.99);
}

.login-btn svg {
  width: 16px;
  height: 16px;
}

.login-footer {
  text-align: center;
  font-size: 12px;
  color: #444;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.login-footer .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #16a34a;
  flex-shrink: 0;
}

/* ===== END LOGIN ===== */

:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #1a1a1a;
  --bg-tertiary: #2a2a2a;
  --border-primary: #333;
  --border-secondary: #444;
  --text-primary: #e0e0e0;
  --text-secondary: #999;
  --text-muted: #666;
  --red-primary: #dc2626;
  --red-hover: #b91c1c;
  --green-primary: #16a34a;
  --green-hover: #15803d;
  --orange-primary: #ea580c;
  --yellow-badge: #ca8a04;
  --blue-primary: #2563eb;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

button { 
  font: inherit; 
  cursor: pointer;
  border: none;
  background: transparent;
}

input, textarea { font: inherit; }

.mobile-menu-btn,
.mobile-nav-backdrop {
  display: none;
}

/* ===== TOP HEADER ===== */
.top-header {
  height: 64px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: relative;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 40px;
  height: 40px;
}

.brand-text h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.brand-text p {
  margin: 0;
  font-size: 11px;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-history {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 13px;
  transition: all 0.2s;
}

.btn-history svg {
  width: 18px;
  height: 18px;
}

.btn-history:hover {
  border-color: var(--red-primary);
  background: var(--bg-secondary);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px 6px 6px;
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  background: var(--bg-tertiary);
  cursor: pointer;
  transition: all 0.2s;
}

.user-profile:hover {
  border-color: var(--border-secondary);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--red-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: white;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.user-role {
  font-size: 11px;
  color: var(--text-secondary);
}

.chevron {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
}

.user-profile {
  position: relative;
}

.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 160px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  z-index: 200;
}

.user-dropdown.open {
  display: block;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.user-dropdown-item svg {
  width: 16px;
  height: 16px;
}

.user-dropdown-item:hover {
  background: var(--red-primary);
  color: #fff;
}

/* ===== APP CONTAINER ===== */
.app-container {
  display: grid;
  grid-template-columns: 180px 1fr 360px;
  height: calc(100vh - 64px);
  overflow: hidden;
}

/* ===== LEFT SIDEBAR ===== */
.left-sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-primary);
  display: flex;
  flex-direction: column;
  padding: 16px 0;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: all 0.2s;
  position: relative;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-item span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(220, 38, 38, 0.15);
  color: var(--red-primary);
  border-left: 3px solid var(--red-primary);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-primary);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-dot.active {
  background: var(--green-primary);
  box-shadow: 0 0 8px var(--green-primary);
}

.status-text {
  font-size: 11px;
}

.version {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 4px;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  overflow-y: auto;
  background: var(--bg-primary);
}

/* ===== SCAN INFO CARD ===== */
.scan-info-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  padding: 20px 24px;
}

.scan-header {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 24px;
  align-items: start;
}

.scan-id {
  display: flex;
  align-items: center;
  gap: 12px;
}

.scan-icon {
  width: 24px;
  height: 24px;
  color: var(--text-secondary);
}

.scan-id h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.scan-meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.meta-value {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.scan-status {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.status-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.status-badge.idle {
  background: rgba(100, 100, 100, 0.15);
  color: var(--text-secondary);
  border: 1px solid var(--border-secondary);
}

.status-badge.warning {
  background: rgba(234, 88, 12, 0.15);
  color: var(--orange-primary);
  border: 1px solid var(--orange-primary);
}

.status-badge.success {
  background: rgba(22, 163, 74, 0.15);
  color: var(--green-primary);
  border: 1px solid var(--green-primary);
}

.scan-stats {
  display: flex;
  gap: 24px;
}

.scan-details-toggle {
  display: none;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
}

.confidence-display {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.confidence-bar {
  width: 120px;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  background: var(--orange-primary);
  border-radius: 3px;
  transition: width 0.3s;
}

/* ===== IMAGE VIEWER ===== */
.image-viewer {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  min-height: 400px;
}

.viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.5);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s;
}

.toolbar-btn svg {
  width: 16px;
  height: 16px;
}

.toolbar-btn:hover {
  background: rgba(0, 0, 0, 0.7);
}

.toolbar-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.run-inspection {
  background: var(--red-primary);
  color: white;
}

.run-inspection:hover:not(:disabled) {
  background: var(--red-hover);
}

.camera-btn {
  background: var(--bg-tertiary);
}

.camera-btn:hover {
  border-color: var(--blue-primary);
}

.toolbar-btn.icon-only {
  padding: 8px;
}

.viewer-sidebar {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  padding: 8px;
  z-index: 10;
}

.viewer-tool {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: var(--text-primary);
  transition: all 0.2s;
}

.viewer-tool svg {
  width: 20px;
  height: 20px;
}

.viewer-tool:hover {
  background: rgba(255, 255, 255, 0.1);
}

.viewer-tool.active {
  background: var(--red-primary);
  color: white;
}

.image-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #2a2a2a;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.image-container.has-image {
  cursor: default;
}

.image-container.has-image .empty-placeholder {
  display: none;
}

#inspectionImage {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: none;
}

#inspectionImage.visible {
  display: block;
}

.empty-placeholder.hidden {
  display: none;
}

.empty-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 40px;
  user-select: none;
  transition: all 0.2s;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.empty-placeholder.hidden {
  display: none !important;
}

.empty-placeholder:hover {
  color: var(--text-primary);
  transform: translate(-50%, -50%);
}

.empty-placeholder:hover svg {
  color: var(--red-hover);
  transform: translateY(-2px);
}

.empty-placeholder svg {
  width: 48px;
  height: 48px;
  color: var(--red-primary);
}

.empty-placeholder p {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
}

.empty-placeholder span {
  font-size: 12px;
  color: var(--text-muted);
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.loading-overlay.active {
  display: flex;
}

.loader {
  width: 40px;
  height: 40px;
  border: 3px solid var(--bg-tertiary);
  border-top-color: var(--red-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.camera-panel {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: none;
  flex-direction: column;
  background: #050505;
}

.camera-panel.active {
  display: flex;
}

.camera-frame {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#cameraVideo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.camera-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--border-primary);
  background: rgba(0, 0, 0, 0.85);
}

.camera-action {
  min-height: 44px;
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
}

.camera-action.secondary {
  border: 1px solid var(--border-primary);
  background: var(--bg-tertiary);
}

.camera-action.primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--red-primary);
  color: white;
}

.camera-action.primary svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.viewer-footer {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid var(--border-primary);
}

.thumbnail-strip {
  display: flex;
  align-items: center;
  gap: 12px;
}

.thumbnail {
  width: 60px;
  height: 60px;
  border: 2px solid transparent;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: all 0.2s;
}

.thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumbnail.active {
  border-color: var(--red-primary);
}

.thumb-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 2px;
}

.thumb-counter {
  font-size: 12px;
  color: var(--text-secondary);
}

.footer-actions {
  display: flex;
  gap: 8px;
}

.btn-secondary {
  padding: 8px 16px;
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--red-primary);
  background: var(--bg-secondary);
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== RIGHT PANEL ===== */
.right-panel {
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-primary);
}

.tab-btn {
  flex: 1;
  padding: 14px 16px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  position: relative;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
}

.tab-btn.active {
  color: var(--red-primary);
  border-bottom-color: var(--red-primary);
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--red-primary);
  color: white;
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
}

.tab-content {
  display: none;
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.tab-content.active {
  display: flex;
}

.panel-title {
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== EDIT OVERLAY CANVAS ===== */
.edit-overlay-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  z-index: 20;
  cursor: crosshair;
}

.edit-overlay-canvas.active {
  display: block;
}

/* ===== FINDINGS TOOLBAR ===== */
.findings-toolbar {
  margin-bottom: 12px;
}

.btn-add-finding {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  border: 1px dashed var(--border-secondary);
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
}

.btn-add-finding:hover {
  border-color: var(--red-primary);
  color: var(--red-primary);
  background: rgba(220, 38, 38, 0.05);
}

/* ===== FINDING EDITOR PANEL ===== */
.finding-editor-panel {
  background: var(--bg-primary);
  border: 1px solid var(--red-primary);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.finding-editor-panel[hidden] {
  display: none;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.editor-header h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--red-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-editor-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background: transparent;
  border: 1px solid var(--border-primary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-editor-close svg {
  width: 14px;
  height: 14px;
}

.btn-editor-close:hover {
  border-color: var(--red-primary);
  color: var(--red-primary);
}

.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.editor-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.editor-grid select,
.editor-grid input {
  padding: 7px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s;
}

.editor-grid select:focus,
.editor-grid input:focus {
  border-color: var(--red-primary);
}

.editor-box-state {
  font-size: 11px;
  color: var(--text-muted);
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px dashed var(--border-primary);
  border-radius: 4px;
  text-align: center;
}

.editor-box-state.ready {
  border-color: #22c55e;
  color: #22c55e;
}

.editor-actions {
  display: flex;
  gap: 8px;
}

.btn-editor-secondary {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-editor-secondary:hover {
  border-color: var(--border-secondary);
  color: var(--text-primary);
}

.btn-editor-primary {
  flex: 2;
  padding: 9px 12px;
  border: none;
  border-radius: 4px;
  background: var(--red-primary);
  color: white;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-editor-primary:hover {
  background: var(--red-hover);
}

/* ===== FINDINGS ===== */
.findings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.finding-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.finding-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.finding-icon {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.finding-icon.warning {
  background: rgba(234, 88, 12, 0.15);
  color: var(--orange-primary);
}

.finding-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.finding-header h4 {
  margin: 0;
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.severity-badge {
  padding: 4px 10px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.severity-badge.medium {
  background: var(--yellow-badge);
  color: #000;
}

.finding-details {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}

.detail-label {
  color: var(--text-secondary);
  min-width: 80px;
}

.detail-value {
  color: var(--text-primary);
  font-weight: 500;
  text-align: right;
}

.detail-value.status-pending {
  color: var(--orange-primary);
}

.detail-value.status-accepted {
  color: var(--green-primary);
}

.detail-value.status-manual {
  color: var(--blue-primary);
}

.confidence-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: flex-end;
}

.confidence-bar-small {
  width: 80px;
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  overflow: hidden;
}

.confidence-fill-small {
  height: 100%;
  background: var(--orange-primary);
  border-radius: 3px;
}

.finding-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.btn-accept,
.btn-edit,
.btn-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-accept {
  background: var(--red-primary);
  color: white;
}

.btn-accept:hover {
  background: var(--red-hover);
}

.btn-accept:disabled {
  background: var(--green-primary);
  color: white;
  opacity: 0.7;
  cursor: default;
}

.btn-accept svg,
.btn-edit svg,
.btn-delete svg {
  width: 16px;
  height: 16px;
}

.btn-edit {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
}

.btn-edit:hover {
  border-color: var(--border-secondary);
  background: var(--bg-secondary);
}

.btn-delete {
  background: transparent;
  color: var(--red-primary);
  border: 1px solid var(--border-primary);
}

.btn-delete:hover {
  border-color: var(--red-primary);
  background: rgba(220, 38, 38, 0.08);
}

/* ===== NOTES ===== */
.notes-textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 13px;
  resize: vertical;
}

.notes-textarea:focus {
  outline: none;
  border-color: var(--red-primary);
}

.char-counter {
  text-align: right;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.empty-message {
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 40px 20px;
}

/* ===== SIGNATURE ===== */
/* ===== PANEL RESIZE HANDLE ===== */
.panel-resize-handle {
  flex-shrink: 0;
  height: 14px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-primary);
  cursor: ns-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  user-select: none;
}

.panel-resize-handle:hover,
.panel-resize-handle.dragging {
  background: rgba(220, 38, 38, 0.08);
}

.panel-resize-bar {
  color: var(--text-muted);
  line-height: 0;
  pointer-events: none;
  transition: color 0.15s;
}

.panel-resize-handle:hover .panel-resize-bar,
.panel-resize-handle.dragging .panel-resize-bar {
  color: var(--red-primary);
}

.panel-resize-bar svg {
  width: 24px;
  height: 6px;
  stroke: currentColor;
  fill: none;
}

.signature-section {
  padding: 20px;
  border-top: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.signature-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.signature-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.btn-clear {
  padding: 4px 12px;
  border: 1px solid var(--border-primary);
  border-radius: 3px;
  background: transparent;
  color: var(--red-primary);
  font-size: 11px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-clear:hover {
  background: rgba(220, 38, 38, 0.1);
  border-color: var(--red-primary);
}

.signature-tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  overflow: hidden;
}

.sig-tab {
  flex: 1;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
}

.sig-tab + .sig-tab {
  border-left: 1px solid var(--border-primary);
}

.sig-tab:hover {
  background: rgba(255, 255, 255, 0.02);
}

.sig-tab.active {
  background: var(--red-primary);
  color: white;
}

.signature-pad {
  position: relative;
  width: 100%;
  height: 120px;
  background: var(--bg-tertiary);
  border: 1px dashed var(--border-primary);
  border-radius: 4px;
  cursor: crosshair;
}

#signatureCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.signature-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  pointer-events: none;
}

.signature-placeholder svg {
  width: 24px;
  height: 24px;
}

.signature-placeholder.hidden {
  display: none;
}

.signature-type-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.signature-type-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.signature-type-input:focus {
  border-color: var(--red-primary);
}

.signature-type-preview {
  min-height: 100px;
  padding: 20px;
  background: var(--bg-tertiary);
  border: 1px dashed var(--border-primary);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Brush Script MT', 'Lucida Handwriting', 'Apple Chancery', cursive;
  font-size: 36px;
  color: var(--text-primary);
  font-weight: 400;
  font-style: italic;
  overflow: hidden;
  text-align: center;
  word-wrap: break-word;
}

.signature-type-preview:empty::before {
  content: 'Your signature will appear here';
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 12px;
  font-style: normal;
  color: var(--text-muted);
}

.signer-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.signer-info strong {
  font-size: 13px;
  color: var(--text-primary);
}

.signer-info span {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-secondary);
}

.verified-icon {
  width: 14px;
  height: 14px;
  color: var(--green-primary);
  fill: var(--green-primary);
  stroke: white;
  stroke-width: 1.5;
}

/* ===== APPROVAL ACTIONS ===== */
.approval-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 20px;
  border-top: 1px solid var(--border-primary);
}

.btn-approve,
.btn-reject,
.btn-report {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px 12px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.2s;
  position: relative;
}

.btn-approve svg,
.btn-reject svg,
.btn-report svg {
  width: 20px;
  height: 20px;
  position: absolute;
  top: 12px;
  left: 12px;
}

.btn-approve {
  background: var(--green-primary);
  color: white;
}

.btn-approve:hover {
  background: var(--green-hover);
}

.btn-reject {
  background: var(--red-primary);
  color: white;
}

.btn-reject:hover {
  background: var(--red-hover);
}

.btn-report {
  grid-column: 1 / -1;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
}

.btn-report:hover:not(:disabled) {
  border-color: var(--blue-primary);
  background: var(--bg-secondary);
}

.btn-report:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-subtitle {
  font-size: 10px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.8;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1400px) {
  .app-container {
    grid-template-columns: 180px 1fr 320px;
  }
  
  .scan-meta {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1200px) {
  .app-container {
    grid-template-columns: 60px 1fr 320px;
  }
  
  .nav-item span {
    display: none;
  }
  
  .scan-header {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .scan-meta {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 900px) {
  body {
    overflow: auto;
    overflow-x: hidden;
  }

  .top-header {
    height: 58px;
    min-height: 58px;
    align-items: center;
    flex-wrap: nowrap;
    gap: 10px;
    padding: 8px 12px;
    position: sticky;
    top: 0;
  }

  .mobile-menu-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .mobile-menu-btn svg {
    width: 22px;
    height: 22px;
  }

  body.mobile-nav-open .mobile-menu-btn {
    border-color: var(--red-primary);
    color: var(--red-primary);
  }

  .header-brand {
    flex: 1;
    min-width: 0;
  }

  .brand-logo {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
  }

  .brand-text {
    min-width: 0;
  }

  .brand-text h1 {
    font-size: 14px;
    line-height: 1.2;
  }

  .brand-text p {
    font-size: 9px;
  }

  .header-actions {
    width: auto;
    gap: 0;
    flex-shrink: 0;
  }

  .btn-history {
    display: none;
  }

  .user-profile {
    width: 40px;
    height: 40px;
    justify-content: center;
    gap: 0;
    padding: 0;
    border-radius: 4px;
  }

  .avatar {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }

  .user-info,
  .chevron {
    display: none;
  }

  .app-container {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 58px);
    overflow: visible;
  }
  
  .left-sidebar {
    display: flex;
    position: fixed;
    top: 58px;
    left: 0;
    bottom: 0;
    width: min(300px, 82vw);
    z-index: 120;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 16px 0 40px rgba(0, 0, 0, 0.35);
  }

  body.mobile-nav-open .left-sidebar {
    transform: translateX(0);
  }

  .mobile-nav-backdrop {
    position: fixed;
    inset: 58px 0 0;
    z-index: 110;
    background: rgba(0, 0, 0, 0.55);
  }

  body.mobile-nav-open .mobile-nav-backdrop {
    display: block;
  }

  .nav-item span {
    display: inline;
  }

  .nav-item {
    min-height: 44px;
  }

  .main-content {
    gap: 10px;
    padding: 10px;
    overflow: visible;
  }

  .image-viewer {
    order: 1;
    flex: none;
    height: 58vh;
    min-height: 340px;
    max-height: 640px;
  }

  .scan-info-card {
    order: 2;
    padding: 12px;
  }

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

  .scan-id {
    order: 1;
    flex: 1 1 160px;
    min-width: 0;
  }

  .scan-icon {
    width: 18px;
    height: 18px;
  }

  .scan-id h2 {
    font-size: 14px;
    line-height: 1.25;
    word-break: break-word;
  }

  .scan-meta {
    display: none;
  }

  .scan-status {
    order: 2;
    margin-left: auto;
    align-items: flex-end;
  }

  .status-label {
    display: none;
  }

  .scan-stats {
    display: none;
  }

  .scan-details-toggle {
    order: 3;
    display: flex;
    flex: 0 0 100%;
    width: 100%;
    align-items: center;
    justify-content: center;
    height: 30px;
    margin-top: 8px;
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-secondary);
  }

  .scan-details-toggle svg {
    width: 18px;
    height: 18px;
    transition: transform 0.2s ease;
  }

  .scan-info-card.expanded .scan-details-toggle svg {
    transform: rotate(180deg);
  }

  .scan-info-card.expanded .scan-meta {
    order: 4;
    flex: 0 0 100%;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
  }

  .scan-info-card.expanded .scan-stats {
    order: 5;
    flex: 0 0 100%;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
  }

  .scan-info-card.expanded .scan-meta .meta-item,
  .scan-info-card.expanded .scan-stats .stat-item {
    display: flex;
    min-width: 0;
    padding: 8px;
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.02);
  }

  .scan-info-card.expanded .scan-status {
    margin-left: 0;
    align-items: stretch;
  }

  .scan-info-card.expanded .status-label {
    display: block;
    font-size: 10px;
    letter-spacing: 0;
    margin-bottom: 4px;
  }

  .status-badge {
    min-height: 30px;
    padding: 5px 8px;
    font-size: 10px;
    letter-spacing: 0;
  }

  .confidence-bar {
    width: 100%;
    max-width: 180px;
  }

  .viewer-toolbar {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
    padding: 8px;
  }

  .toolbar-left {
    max-width: calc(100% - 44px);
    flex-wrap: wrap;
    gap: 6px;
  }

  .toolbar-btn {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 11px;
  }

  .toolbar-btn.icon-only {
    width: 38px;
    height: 38px;
    padding: 0;
    justify-content: center;
  }

  .viewer-sidebar {
    left: 50%;
    right: auto;
    top: auto;
    bottom: 12px;
    transform: translateX(-50%);
    flex-direction: row;
  }

  .empty-placeholder {
    padding: 24px;
    text-align: center;
  }

  .right-panel {
    display: flex;
    border-left: 0;
    border-top: 1px solid var(--border-primary);
    overflow: visible;
  }

  .panel-tabs {
    position: sticky;
    top: 58px;
    z-index: 50;
    background: var(--bg-secondary);
  }

  .tab-content {
    flex: none;
    min-height: 240px;
    max-height: none;
    padding: 16px;
    overflow: visible;
  }

  .signature-section {
    padding: 16px;
  }

  .signature-pad {
    height: 140px;
  }

  .signature-type-preview {
    min-height: 110px;
    font-size: 30px;
  }

  .approval-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 16px;
  }

  .btn-approve,
  .btn-reject {
    min-height: 68px;
    padding: 14px 10px;
    font-size: 12px;
  }
}

@media (max-width: 520px) {
  .top-header {
    padding: 8px 10px;
  }

  .header-actions {
    align-items: stretch;
  }

  .mobile-menu-btn,
  .user-profile {
    width: 38px;
    height: 38px;
  }

  .main-content {
    padding: 8px;
  }

  .brand-logo {
    width: 32px;
    height: 32px;
  }

  .brand-text h1 {
    font-size: 13px;
  }

  .brand-text p {
    display: none;
  }

  .scan-info-card {
    padding: 10px;
  }

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

  .scan-status {
    align-items: stretch;
  }

  .status-badge {
    justify-content: center;
  }

  .scan-details-toggle {
    height: 32px;
  }

  .scan-info-card.expanded .scan-meta,
  .scan-info-card.expanded .scan-stats {
    grid-template-columns: 1fr;
  }

  .scan-id h2 {
    font-size: 13px;
  }

  .scan-icon {
    width: 16px;
    height: 16px;
  }

  .image-viewer {
    height: 56vh;
    min-height: 320px;
  }

  .viewer-sidebar {
    bottom: 10px;
  }

  .viewer-toolbar {
    background: rgba(0, 0, 0, 0.55);
  }

  .toolbar-left {
    width: calc(100% - 46px);
  }

  .toolbar-left .toolbar-btn {
    flex: 1 1 132px;
    justify-content: center;
  }

  .camera-actions {
    grid-template-columns: 1fr;
  }

  .viewer-tool {
    width: 38px;
    height: 38px;
  }

  .panel-tabs {
    top: 58px;
  }

  .tab-btn {
    padding: 13px 10px;
    font-size: 12px;
  }

  .finding-card {
    padding: 14px;
  }

  .finding-header {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px;
  }

  .finding-header h4 {
    min-width: 0;
    word-break: break-word;
  }

  .detail-row {
    align-items: flex-start;
  }

  .approval-actions {
    grid-template-columns: 1fr;
  }

  .btn-approve svg,
  .btn-reject svg {
    top: 50%;
    transform: translateY(-50%);
  }
}