/*
 * SOP Manager Styles — Field Tool Redesign
 * Worker-facing, touch-first, glove-friendly
 * Dark mode default (warehouse environment)
 * 56px minimum touch targets
 * Mobile-first responsive
 */

/* =====================================================
   BODY & BACKGROUND
   ===================================================== */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  opacity: 0.02;
  pointer-events: none;
  z-index: 0;
}

.main {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

/* =====================================================
   HEADER — Compact, functional
   ===================================================== */
.header {
  background: var(--header-bg);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid var(--gold);
  position: sticky;
  top: 0;
  z-index: 40;
  gap: 8px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.header-logo { height: 32px; flex-shrink: 0; }

.header-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--header-text);
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* =====================================================
   HEADER BUTTONS
   ===================================================== */
.header-btn {
  background: rgba(255,255,255,0.08);
  color: var(--header-text);
  border: 1px solid rgba(255,255,255,0.15);
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
  min-height: 44px;
  white-space: nowrap;
}
.header-btn:hover { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.25); }
.header-btn:active { transform: scale(0.97); }
.header-btn.primary { background: var(--gold); color: var(--header-bg); border-color: var(--gold); font-weight: 600; }
.header-btn.primary:hover { background: var(--gold-light); }
.header-btn.primary:active { background: #d4982e; }

/* =====================================================
   LANGUAGE SWITCH — Big, prominent, always visible
   ===================================================== */
.lang-switch {
  background: var(--gold);
  color: #fff;
  border: 2px solid var(--gold);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
  min-height: 48px;
  letter-spacing: 0.5px;
}
.lang-switch:hover { background: var(--gold-light); transform: scale(1.03); }
.lang-switch:active { transform: scale(0.97); }
.lang-switch i { font-size: 20px; }

/* =====================================================
   DARK MODE TOGGLE
   ===================================================== */
.dark-mode-toggle {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--header-text);
  min-height: 44px;
}
.dark-mode-toggle:hover { background: rgba(255,255,255,0.15); }
.dark-mode-toggle:active { transform: scale(0.97); }
body.dark-mode .dark-mode-toggle { background: var(--gold-dim); border-color: var(--gold); color: var(--gold); }

.request-badge {
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  margin-left: 4px;
}

/* =====================================================
   TOOLBAR — Search front and center
   ===================================================== */
.toolbar {
  background: var(--bg-card);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

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

/* =====================================================
   SEARCH BOX — Full width on mobile, prominent
   ===================================================== */
.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}
.search-box input {
  width: 100%;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 14px 14px 14px 44px;
  color: var(--text);
  font-size: 16px;
  min-height: 48px;
  transition: border-color 0.15s;
}
.search-box input:focus { outline: none; border-color: var(--green); background: var(--bg-card); }
.search-box input::placeholder { color: var(--text-light); }
.search-box i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 18px;
}

/* =====================================================
   FILTER SELECTS
   ===================================================== */
.filter-select {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  min-width: 130px;
  min-height: 44px;
}
.filter-select:focus { outline: none; border-color: var(--green); }

/* =====================================================
   CATEGORY CHIPS — Horizontal scroll, touch-friendly
   ===================================================== */
.category-chips-wrapper {
  background: var(--bg-card);
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  display: none; /* Shown on mobile via media query */
  position: relative;
}
/* Scroll fade indicators */
.category-chips-wrapper::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 40px;
  background: linear-gradient(to right, transparent, var(--bg-card));
  pointer-events: none;
  z-index: 1;
}

.category-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 2px 0;
}
.category-chips::-webkit-scrollbar { display: none; }

.category-chip {
  flex-shrink: 0;
  padding: 10px 18px;
  border-radius: 24px;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.category-chip:active { transform: scale(0.96); }
.category-chip.active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}
.category-chip.active.gold-chip {
  background: var(--gold);
  border-color: var(--gold);
  color: #1a1f16;
}

/* =====================================================
   VIEW TOGGLE
   ===================================================== */
.view-toggle {
  display: flex;
  background: var(--bg);
  border-radius: 10px;
  padding: 3px;
  border: 1px solid var(--border);
}
.view-toggle button {
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  min-height: 40px;
  min-width: 40px;
}
.view-toggle button.active { background: var(--green); color: #fff; }

/* =====================================================
   CONTENT AREA
   ===================================================== */
.content {
  padding: 16px;
  flex: 1;
  background: var(--bg);
}

/* =====================================================
   STATS BAR
   ===================================================== */
.stats-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  min-width: 100px;
  flex: 1;
  max-width: 160px;
  border-top: 3px solid var(--border);
}
.stat-card:nth-child(1) { border-top-color: var(--gold); }
.stat-card:nth-child(2) { border-top-color: var(--green); }
.stat-card:nth-child(3) { border-top-color: var(--sungrown); }
.stat-card:nth-child(4) { border-top-color: var(--danger); }
.stat-card:nth-child(5) { border-top-color: var(--indoor); }
.stat-card-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-light);
  margin-bottom: 4px;
  font-weight: 600;
}
.stat-card-value { font-size: 28px; font-weight: 700; }
.stat-card-value.gold { color: var(--gold); }
.stat-card-value.danger { color: var(--danger); }
.stat-card-value.green { color: var(--green); }
.stat-card-value.sungrown { color: var(--sungrown); }
.stat-card-value.indoor { color: var(--indoor); }

/* =====================================================
   SOP GRID — Cards
   ===================================================== */
.sop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.sop-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  transition: all 0.15s;
  cursor: pointer;
  animation: cardFadeIn 0.3s ease backwards;
}
@keyframes cardFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.sop-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  border-color: var(--green);
}
.sop-card:active { transform: scale(0.99); }

.sop-card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.sop-card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  line-height: 1.3;
  color: var(--text);
}
.sop-card-dept {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.sop-card-rev {
  background: var(--green);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
}
.sop-card-rev.draft { background: var(--gold); color: var(--header-bg); }

.sop-card-preview {
  height: 80px;
  background: var(--bg-warm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.sop-card-preview img { width: 100%; height: 100%; object-fit: cover; }
.sop-card-preview-empty {
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}
.sop-card-preview-empty i { font-size: 24px; opacity: 0.4; }

.sop-card-meta {
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sop-card-steps {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}
.sop-card-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.sop-tag {
  background: var(--gold-dim);
  color: var(--gold);
  font-size: 9px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.sop-tag.danger { background: var(--danger-dim); color: var(--danger); }
.sop-tag.green { background: var(--green-dim); color: var(--green); }
.sop-tag.sungrown { background: var(--sungrown-dim); color: var(--sungrown); }
.sop-tag.greenhouse { background: var(--greenhouse-dim); color: var(--greenhouse); }
.sop-tag.indoor, .sop-tag.blue { background: var(--indoor-dim); color: var(--indoor); }
.sop-tag.purple { background: rgba(139,92,246,0.12); color: #8b5cf6; }

.sop-card-actions {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}
.sop-card-actions button {
  flex: 1;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  padding: 14px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
  font-size: 16px;
  min-height: 48px;
}
.sop-card-actions button:last-child { border-right: none; }
.sop-card-actions button:hover { background: var(--green-dim); color: var(--green); }
.sop-card-actions button:active { background: var(--green); color: #fff; }
.sop-card-actions button.qr-btn:hover { background: var(--gold-dim); color: var(--gold); }
.sop-card-actions button.del-btn:hover { background: var(--danger-dim); color: var(--danger); }

/* =====================================================
   SOP LIST VIEW (Table)
   ===================================================== */
.sop-list { display: none; }
.sop-list.active { display: block; }
.sop-grid.hidden { display: none; }

.sop-table {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.sop-table table { width: 100%; border-collapse: collapse; }
.sop-table th {
  text-align: left;
  padding: 12px 16px;
  background: var(--bg);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}
.sop-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
.sop-table tr:last-child td { border-bottom: none; }
.sop-table tr:hover { background: var(--bg); cursor: pointer; }
.sop-table .title-cell { font-weight: 600; color: var(--green); }
.sop-table .actions-cell { display: flex; gap: 6px; }
.sop-table .actions-cell button {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  min-height: 40px;
  min-width: 40px;
}
.sop-table .actions-cell button:hover { border-color: var(--green); color: var(--green); background: var(--green-dim); }

/* =====================================================
   EMPTY STATE & LOADING
   ===================================================== */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state i { font-size: 56px; margin-bottom: 16px; color: var(--green); opacity: 0.4; }
.empty-state h3 { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.empty-state p { margin-bottom: 20px; }

.loading-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.loading-state .spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================
   MODALS — Full-screen on mobile
   ===================================================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.modal.active { display: flex; }

.modal-box {
  background: var(--bg-card);
  border-radius: 16px;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.modal-box.wide { max-width: 1100px; }
.modal-box.small { max-width: 500px; }

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--header-bg);
  flex-shrink: 0;
}
.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--header-text);
}
.modal-close {
  background: rgba(255,255,255,0.1);
  border: none;
  color: var(--header-text);
  font-size: 22px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 8px;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: rgba(255,255,255,0.2); }
.modal-close:active { transform: scale(0.95); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  background: var(--bg-card);
  position: relative;
  -webkit-overflow-scrolling: touch;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg);
  flex-shrink: 0;
}
.modal-footer .header-btn {
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.modal-footer .header-btn:hover { background: var(--green-dim); color: var(--green); border-color: var(--green); }
.modal-footer .header-btn.primary { background: var(--green); color: #fff; border-color: var(--green); }
.modal-footer .header-btn.primary:hover { background: var(--green-dark); }

/* =====================================================
   FORMS
   ===================================================== */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-input {
  width: 100%;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  color: var(--text);
  font-size: 16px;
  min-height: 48px;
  transition: border-color 0.15s;
}
.form-input:focus { outline: none; border-color: var(--green); background: var(--bg-card); }
textarea.form-input { min-height: 80px; resize: vertical; font-family: inherit; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* =====================================================
   STEPS SECTION (Edit Modal)
   ===================================================== */
.steps-section { margin-top: 20px; }
.steps-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.steps-header h3 {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}
.steps-list { display: flex; flex-direction: column; gap: 12px; }

.step-item {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  gap: 14px;
  transition: border-color 0.15s;
}
.step-item:hover { border-color: var(--green); }

.step-number {
  width: 36px;
  height: 36px;
  background: var(--green);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.step-content { flex: 1; min-width: 0; }

.step-title-input {
  width: 100%;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
  min-height: 44px;
}
.step-title-input:focus { outline: none; border-color: var(--green); }

.step-desc-input {
  width: 100%;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  font-size: 14px;
  min-height: 60px;
  resize: vertical;
  font-family: inherit;
}
.step-desc-input:focus { outline: none; border-color: var(--green); }

.step-image { width: 140px; flex-shrink: 0; }
.step-image-preview {
  width: 100%;
  height: 120px;
  background: var(--bg-card);
  border: 2px dashed var(--border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s;
}
.step-image-preview:hover { border-color: var(--gold); background: var(--gold-dim); }
.step-image-preview.has-image { border-style: solid; }
.step-image-preview img { width: 100%; height: 100%; object-fit: cover; }
.step-image-preview .placeholder {
  color: var(--text-light);
  font-size: 11px;
  text-align: center;
}
.step-image-preview .placeholder i { font-size: 20px; display: block; margin-bottom: 4px; }

.step-icons { display: flex; gap: 6px; margin-top: 8px; }
.step-icon-btn {
  width: 36px;
  height: 36px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--text-muted);
  transition: all 0.15s;
}
.step-icon-btn:hover { border-color: var(--gold); color: var(--gold); }
.step-icon-btn:active { transform: scale(0.93); }
.step-icon-btn.active { background: var(--gold); color: #fff; border-color: var(--gold); }
.step-icon-btn.safety.active { background: var(--danger); border-color: var(--danger); }
.step-icon-btn.quality.active { background: var(--green); border-color: var(--green); }

.step-actions { display: flex; flex-direction: column; gap: 4px; }
.step-action-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: var(--bg-card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 15px;
  transition: all 0.15s;
}
.step-action-btn:hover { background: var(--border); }
.step-action-btn:active { transform: scale(0.93); }
.step-action-btn.delete:hover { background: var(--danger-dim); color: var(--danger); }

/* =====================================================
   INLINE ADD / TAGS
   ===================================================== */
.inline-add-btn {
  width: 44px;
  height: 44px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 16px;
  flex-shrink: 0;
}
.inline-add-btn:hover { border-color: var(--green); color: var(--green); background: var(--green-dim); }
.inline-add-btn.save { background: var(--green); color: #fff; border-color: var(--green); }
.inline-add-btn.save:hover { background: var(--green-dark); }
.inline-add-btn.cancel { background: var(--bg); }
.inline-add-btn.cancel:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-dim); }

.tag-item { display: flex; align-items: center; gap: 4px; }
.tag-item .tag-delete {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 12px;
  padding: 2px;
  border-radius: 3px;
  opacity: 0.6;
}
.tag-item .tag-delete:hover { color: var(--danger); opacity: 1; }
.add-tag-btn {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
}
.add-tag-btn:hover { border-color: var(--green); color: var(--green); border-style: solid; }
.tag-color-picker-mini { display: flex; gap: 6px; }
.tag-color-picker-mini .color-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
}
.tag-color-picker-mini .color-dot:hover { transform: scale(1.15); }
.tag-color-picker-mini .color-dot.selected { border-color: var(--text); }

/* =====================================================
   QR MODAL
   ===================================================== */
.qr-modal-content { text-align: center; padding: 20px; }
.qr-url {
  background: var(--bg);
  padding: 12px;
  border-radius: 8px;
  font-size: 11px;
  color: var(--text-muted);
  word-break: break-all;
  margin-top: 16px;
}

/* =====================================================
   VIEW SOP — Step-by-step viewer
   ===================================================== */
.view-sop-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--border);
}
.view-sop-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
  line-height: 1.3;
}
.view-sop-meta { display: flex; gap: 12px; flex-wrap: wrap; }
.view-sop-meta-item {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}
.view-sop-qr {
  width: 80px;
  height: 80px;
  background: #fff;
  border-radius: 8px;
  padding: 4px;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

/* View Steps */
.view-step {
  display: flex;
  gap: 14px;
  padding: 18px;
  background: var(--bg);
  border-radius: 12px;
  margin-bottom: 12px;
  border-left: 4px solid var(--green);
  transition: all 0.15s;
}
.view-step-number {
  width: 44px;
  height: 44px;
  background: var(--green);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}
.view-step-content { flex: 1; min-width: 0; }
.view-step-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  line-height: 1.4;
}
.view-step-title .icon.safety { color: var(--danger); font-size: 20px; }
.view-step-title .icon.quality { color: var(--green); font-size: 20px; }
.view-step-desc {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.view-step-image {
  width: 160px;
  height: 100px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid var(--border);
  cursor: pointer;
}
.view-step-image img { width: 100%; height: 100%; object-fit: cover; }

/* Safety Step — impossible to miss */
.view-step.safety-step {
  border-left: 6px solid var(--danger);
  background: rgba(196, 92, 74, 0.08);
  border-color: var(--danger);
}
body.dark-mode .view-step.safety-step {
  background: rgba(196, 92, 74, 0.12);
}
.view-step.safety-step .view-step-number {
  background: var(--danger);
}

/* Safety Warning Banner (inside view steps) */
.safety-warning-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--danger-dim);
  border: 2px solid var(--danger);
  border-radius: 10px;
  margin-bottom: 10px;
  font-weight: 600;
  color: var(--danger);
  font-size: 14px;
}
.safety-warning-banner i { font-size: 24px; flex-shrink: 0; }

/* =====================================================
   WIZARD MODE (View Modal — mobile step-by-step)
   ===================================================== */
.wizard-container {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.wizard-progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 12px;
  flex-shrink: 0;
}
.wizard-progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

.wizard-counter {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.wizard-step {
  flex: 1;
  animation: wizardFadeIn 0.25s ease;
}

@keyframes wizardFadeIn {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Reverse direction when going back */
.wizard-step.prev-direction {
  animation-name: wizardFadeInReverse;
}
@keyframes wizardFadeInReverse {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

.wizard-nav {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.wizard-btn {
  flex: 1;
  min-height: 56px;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s;
}
.wizard-btn:active { transform: scale(0.97); }
.wizard-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.wizard-btn.primary {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}
.wizard-btn.primary:active { background: var(--green-dark); }

/* =====================================================
   IMAGE ZOOM OVERLAY
   ===================================================== */
.image-zoom-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  cursor: pointer;
}
.image-zoom-overlay img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}
.zoom-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 56px;
  height: 56px;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font-size: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.zoom-close:active { transform: scale(0.9); }

/* =====================================================
   FAB MANAGER — Mobile action menu
   ===================================================== */
.fab-manager {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 50;
  display: none; /* Shown on mobile */
}

.fab-main {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3), 0 8px 32px rgba(0,0,0,0.2);
  transition: all 0.2s;
  position: relative;
  z-index: 2;
}
.fab-main:active { transform: scale(0.92); }
.fab-main.open { background: var(--danger); transform: rotate(45deg); }
.fab-main.open:active { transform: rotate(45deg) scale(0.92); }

.fab-menu {
  position: absolute;
  bottom: 76px;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
  z-index: 1;
}

.fab-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  min-height: 52px;
  transition: all 0.15s;
}
.fab-item:active { transform: scale(0.96); }
.fab-item i { font-size: 20px; color: var(--green); }
.fab-item .request-badge { margin-left: 4px; }

/* FAB menu entrance animation */
.fab-menu.open .fab-item { animation: fabItemIn 0.2s ease backwards; }
.fab-menu.open .fab-item:nth-child(1) { animation-delay: 0s; }
.fab-menu.open .fab-item:nth-child(2) { animation-delay: 0.05s; }
.fab-menu.open .fab-item:nth-child(3) { animation-delay: 0.1s; }
@keyframes fabItemIn {
  from { opacity: 0; transform: translateY(10px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* =====================================================
   SETTINGS
   ===================================================== */
.settings-section { margin-bottom: 24px; }
.settings-section-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}
.settings-section-title i { color: var(--green); font-size: 18px; }
.settings-list { display: flex; flex-wrap: wrap; gap: 8px; }
.settings-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
}
.settings-item:hover { border-color: var(--green); }
.settings-item .item-delete {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  font-size: 14px;
  min-width: 28px;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.settings-item .item-delete:hover { color: var(--danger); background: var(--danger-dim); }
.settings-add-form { display: flex; gap: 8px; margin-top: 12px; }
.settings-add-form input {
  flex: 1;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  color: var(--text);
  min-height: 44px;
}
.settings-add-form input:focus { outline: none; border-color: var(--green); }
.settings-add-btn {
  background: var(--green);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
}
.settings-add-btn:hover { background: var(--green-dark); }
.settings-note { font-size: 11px; color: var(--text-light); margin-top: 8px; }
.tag-color-picker { display: flex; gap: 6px; align-items: center; }
.tag-color-option {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
}
.tag-color-option:hover { transform: scale(1.1); }
.tag-color-option.selected { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg-card); }
.tag-color-option.gold { background: var(--gold); }
.tag-color-option.green { background: var(--green); }
.tag-color-option.danger { background: var(--danger); }
.tag-color-option.sungrown { background: var(--sungrown); }
.tag-color-option.greenhouse { background: var(--greenhouse); }
.tag-color-option.indoor { background: var(--indoor); }

/* =====================================================
   LANGUAGE TOGGLES (in modals)
   ===================================================== */
.lang-toggle {
  display: flex;
  background: var(--bg);
  border-radius: 10px;
  padding: 3px;
  border: 1px solid var(--border);
}
.lang-toggle button {
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  min-height: 36px;
}
.lang-toggle button.active { background: var(--green); color: #fff; }
.lang-toggle button:hover:not(.active) { background: var(--bg-warm); }

.translate-btn {
  background: var(--sungrown-dim);
  border: 1px solid var(--sungrown);
  color: var(--sungrown);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
}
.translate-btn:hover { background: var(--sungrown); color: #fff; }
.translate-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.translation-notice {
  background: var(--sungrown-dim);
  border: 1px solid var(--sungrown);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--sungrown);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* =====================================================
   REQUESTS
   ===================================================== */
.requests-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  background: var(--bg);
  padding: 4px;
  border-radius: 12px;
}
.requests-tab {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 44px;
}
.requests-tab:hover { background: var(--bg-card); }
.requests-tab.active { background: var(--bg-card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.requests-tab .tab-count {
  background: var(--gold-dim);
  color: var(--gold);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  margin-left: 6px;
}
.requests-tab.active .tab-count { background: var(--gold); color: #fff; }

.request-list { display: flex; flex-direction: column; gap: 10px; max-height: 400px; overflow-y: auto; }
.request-item {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  transition: all 0.15s;
}
.request-item:hover { border-color: var(--green); }
.request-item.completed { opacity: 0.6; }
.request-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}
.request-item-title { font-weight: 600; color: var(--text); font-size: 15px; flex: 1; }
.request-item-priority {
  font-size: 10px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  text-transform: uppercase;
}
.request-item-priority.high { background: var(--danger-dim); color: var(--danger); }
.request-item-priority.medium { background: var(--gold-dim); color: var(--gold); }
.request-item-priority.low { background: var(--green-dim); color: var(--green); }
.request-item-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; line-height: 1.5; }
.request-item-meta {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--text-light);
  flex-wrap: wrap;
  align-items: center;
}
.request-item-meta i { margin-right: 4px; }
.request-item-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.request-item-actions button {
  padding: 10px 14px;
  font-size: 12px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
  min-height: 40px;
}
.request-action-create { background: var(--green); color: #fff; }
.request-action-create:hover { background: var(--green-dark); }
.request-action-complete { background: var(--gold-dim); color: var(--gold); }
.request-action-complete:hover { background: var(--gold); color: #fff; }
.request-action-delete { background: var(--danger-dim); color: var(--danger); }
.request-action-delete:hover { background: var(--danger); color: #fff; }
.request-action-edit { background: var(--bg-card); color: var(--text-muted); border: 1px solid var(--border); }
.request-action-edit:hover { border-color: var(--green); color: var(--green); }

.request-empty { text-align: center; padding: 32px 20px; color: var(--text-muted); }
.request-empty i { font-size: 40px; margin-bottom: 12px; opacity: 0.3; }
.request-empty p { font-size: 14px; }

.add-request-form {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
}
.add-request-form .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.add-request-form .form-input { font-size: 14px; padding: 12px 14px; }
.add-request-form .form-label { font-size: 11px; margin-bottom: 4px; }

/* =====================================================
   AI FEATURES
   ===================================================== */
.ai-improve-btn {
  background: linear-gradient(135deg, var(--gold) 0%, var(--sungrown) 100%);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  margin-left: 8px;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  vertical-align: middle;
  min-height: 32px;
}
.ai-improve-btn:hover { transform: scale(1.05); box-shadow: 0 2px 8px rgba(228,170,79,0.4); }
.ai-improve-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.ai-improve-btn.loading { animation: pulse 1s infinite; }
.ai-improve-btn i { font-size: 12px; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

.step-ai-btn {
  background: linear-gradient(135deg, var(--gold) 0%, var(--sungrown) 100%);
  color: #fff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.step-ai-btn:hover { transform: scale(1.1); box-shadow: 0 2px 8px rgba(228,170,79,0.4); }
.step-ai-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.step-ai-btn i { font-size: 15px; }

/* =====================================================
   PDF MODAL
   ===================================================== */
.pdf-layout-options { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.pdf-layout-option { cursor: pointer; }
.pdf-layout-option input { display: none; }
.pdf-layout-card {
  width: 100px;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 12px;
  text-align: center;
  transition: all 0.15s;
  background: var(--bg-card);
}
.pdf-layout-card:hover { border-color: var(--green); }
.pdf-layout-option input:checked + .pdf-layout-card { border-color: var(--green); background: var(--green-dim); }
.pdf-layout-preview {
  height: 50px;
  background: var(--bg);
  border-radius: 4px;
  margin-bottom: 8px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}
.pdf-layout-preview .line { height: 4px; background: var(--border); border-radius: 2px; }
.pdf-layout-preview .line.short { width: 60%; }
.pdf-layout-preview.grid-preview { display: grid; gap: 4px; align-content: center; }
.pdf-layout-preview.grid-preview.cols-1 { grid-template-columns: 1fr; }
.pdf-layout-preview.grid-preview.cols-2 { grid-template-columns: 1fr 1fr; }
.pdf-layout-preview .box { background: var(--green); opacity: 0.3; border-radius: 2px; min-height: 16px; }
.pdf-layout-card span { font-size: 11px; color: var(--text-muted); font-weight: 500; }

/* PDF layout help text */
.pdf-layout-help { margin-top: 4px; }
.pdf-layout-help span { display: none; font-size: 11px; color: var(--text-light); font-style: italic; }
.pdf-layout-help span.active { display: block; }

/* PDF progress bar */
.pdf-progress { margin-top: 12px; }
.pdf-progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.pdf-progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 3px;
  transition: width 0.3s ease;
  width: 0%;
}
.pdf-progress-text { font-size: 11px; color: var(--text-muted); }

/* =====================================================
   MEDIA UPLOAD MODAL
   ===================================================== */
.media-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.media-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.15s;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  min-height: 80px;
}
.media-option:hover { border-color: var(--green); background: var(--green-dim); }
.media-option:active { transform: scale(0.97); }
.media-option i { font-size: 28px; color: var(--green); }
.media-option.url-option { grid-column: span 2; flex-direction: row; padding: 14px; }
.media-option.url-option i { font-size: 22px; }

.media-url-input { padding: 16px; background: var(--bg); border-radius: 12px; }

.media-preview { padding: 16px; background: var(--bg); border-radius: 12px; text-align: center; }
.media-preview img, .media-preview video {
  max-width: 100%;
  max-height: 250px;
  border-radius: 10px;
  border: 2px solid var(--border);
  margin-bottom: 12px;
}
.media-preview-actions { display: flex; gap: 10px; justify-content: center; }

.media-note {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--gold-dim);
  padding: 12px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
.media-note i { color: var(--gold); font-size: 16px; }

/* Video in steps */
.step-media-preview { position: relative; }
.step-media-preview video { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.video-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.4);
  border-radius: 6px;
  cursor: pointer;
}
.video-play-overlay i { font-size: 32px; color: #fff; }
.video-play-overlay:hover { background: rgba(0,0,0,0.6); }

.view-step-video {
  width: 160px;
  height: 100px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid var(--border);
  position: relative;
}
.view-step-video video { width: 100%; height: 100%; object-fit: cover; }
.view-step-video iframe { width: 100%; height: 100%; border: none; }

.media-type-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 10px;
  padding: 3px 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* =====================================================
   ANNOTATION EDITOR
   ===================================================== */
.annotation-modal { max-width: 95vw; max-height: 95vh; }

.annotation-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg);
  overflow: hidden;
}

.annotation-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border);
  flex-wrap: wrap;
}

.tool-group { display: flex; gap: 4px; }
.tool-divider { width: 1px; height: 32px; background: var(--border); margin: 0 6px; }

.tool-btn {
  width: 44px;
  height: 44px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-muted);
  transition: all 0.15s;
}
.tool-btn:hover { border-color: var(--green); color: var(--green); background: var(--green-dim); }
.tool-btn.active { background: var(--green); border-color: var(--green); color: #fff; }
.tool-btn.action-btn { background: var(--bg-card); }
.tool-btn.action-btn:hover { background: var(--gold-dim); border-color: var(--gold); color: var(--gold); }

.color-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.color-btn:hover { transform: scale(1.15); }
.color-btn.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--bg-card), 0 2px 8px rgba(0,0,0,0.3);
}

.symbol-picker {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--gold);
  flex-wrap: wrap;
}
.symbol-btn {
  width: 48px;
  height: 48px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.symbol-btn:hover { border-color: var(--gold); background: var(--gold-dim); transform: scale(1.1); }
.symbol-btn.active { border-color: var(--gold); background: var(--gold-dim); }

.canvas-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a1a;
  border-radius: 12px;
  overflow: hidden;
  min-height: 300px;
  position: relative;
  touch-action: none;
}
#annotationCanvas { max-width: 100%; max-height: 100%; cursor: crosshair; touch-action: none; }

.step-image-edit-btn {
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 36px;
  height: 36px;
  background: rgba(0,0,0,0.7);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  opacity: 0;
  transition: all 0.15s;
  z-index: 5;
}
.step-image-preview:hover .step-image-edit-btn,
.step-image-preview.has-image .step-image-edit-btn { opacity: 1; }
.step-image-edit-btn:hover { background: var(--gold); transform: scale(1.1); }

/* =====================================================
   TUTORIAL WALKTHROUGH
   ===================================================== */
.tutorial-toggle-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--header-text);
  font-size: 16px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 8px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  min-width: 44px;
  min-height: 44px;
}
.tutorial-toggle-btn:hover { background: rgba(255,255,255,0.2); border-color: rgba(255,255,255,0.25); }
.tutorial-toggle-btn.active { background: var(--gold); color: var(--header-bg); border-color: var(--gold); }

.fab-add-step {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  transition: all 0.2s;
  z-index: 1000;
}
.fab-add-step:hover { background: var(--green-dark); transform: scale(1.05); }
.fab-add-step:active { transform: scale(0.95); }

.tutorial-banner {
  background: linear-gradient(135deg, #3d5a45 0%, #2a4030 100%);
  border: 2px solid var(--gold);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 18px;
  position: relative;
  z-index: 200;
  box-shadow: 0 4px 20px rgba(228, 170, 79, 0.25);
}
.tutorial-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.tutorial-step-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tutorial-hint { font-size: 16px; color: #fff; line-height: 1.5; margin-bottom: 14px; }
.tutorial-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.tutorial-btn {
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
}
.tutorial-btn.skip {
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.7);
}
.tutorial-btn.skip:hover { border-color: rgba(255, 255, 255, 0.5); color: #fff; }
.tutorial-btn.next { background: var(--gold); border: 2px solid var(--gold); color: #000; margin-left: auto; }
.tutorial-btn.next:hover { background: #f0b85d; border-color: #f0b85d; }
.tutorial-progress { height: 4px; background: rgba(255, 255, 255, 0.15); border-radius: 2px; overflow: hidden; }
.tutorial-progress-fill { height: 100%; background: var(--gold); border-radius: 2px; transition: width 0.3s ease; width: 0%; }
.tutorial-banner.complete { text-align: center; }
.tutorial-banner.complete .tutorial-hint { font-size: 18px; margin-bottom: 12px; }
.tutorial-complete-icon { font-size: 32px; margin-bottom: 8px; }

.tutorial-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 50;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.tutorial-highlight {
  position: relative;
  z-index: 100 !important;
  outline: 3px solid var(--gold) !important;
  outline-offset: 2px;
  box-shadow: 0 0 0 6px rgba(228, 170, 79, 0.4), 0 0 30px rgba(228, 170, 79, 0.3) !important;
  border-radius: 10px;
  background: var(--bg-card) !important;
  transition: all 0.3s ease;
}
.tutorial-highlight-group {
  position: relative;
  z-index: 100 !important;
  outline: 3px solid var(--gold);
  outline-offset: 4px;
  border-radius: 14px;
  box-shadow: 0 0 0 8px rgba(228, 170, 79, 0.3), 0 0 30px rgba(228, 170, 79, 0.25);
  background: var(--bg-card);
  padding: 12px;
}
.tutorial-highlight-parent {
  position: relative;
  z-index: 100 !important;
  background: var(--bg-card);
  border-radius: 14px;
  padding: 12px;
  margin: -12px;
}

/* =====================================================
   SOP LINK CHIPS AND CROSS-REFERENCES
   ===================================================== */
.sop-link-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 32px;
}
.sop-link-chip:hover { background: var(--green); color: white; border-color: var(--green); }
.sop-link-chip i { font-size: 14px; }
.sop-link-chip .remove-link { margin-left: 4px; opacity: 0.6; }
.sop-link-chip .remove-link:hover { opacity: 1; }

.linked-sops-section { margin-top: 16px; padding: 12px; background: var(--bg); border-radius: 10px; }
.linked-sops-group { margin-bottom: 10px; }
.linked-sops-group:last-child { margin-bottom: 0; }
.linked-sops-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.linked-sops-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.link-sop-list { max-height: 200px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.link-sop-item {
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.link-sop-item:last-child { border-bottom: none; }
.link-sop-item:hover { background: var(--bg); }
.link-sop-item.selected { background: var(--green-dim); }
.link-sop-item input[type="radio"] { margin: 0; }
.link-sop-item-title { font-weight: 500; }
.link-sop-item-meta { font-size: 12px; color: var(--text-muted); }

.sop-preview-popup {
  position: fixed;
  z-index: 10001;
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  padding: 16px;
  width: 300px;
  max-width: 90vw;
  border: 1px solid var(--border);
}
.sop-preview-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sop-preview-header #previewTitle { font-weight: 600; font-size: 15px; }
.sop-preview-header #previewDocNum { font-size: 12px; color: var(--text-muted); }
.sop-preview-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.sop-preview-desc {
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sop-preview-open {
  width: 100%;
  padding: 12px;
  background: var(--green);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  min-height: 44px;
}
.sop-preview-open:hover { background: var(--green-dark); }
.sop-preview-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.view-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 12px;
  min-height: 40px;
}
.view-back-btn:hover { background: var(--green-dim); border-color: var(--green); }

.step-refs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.step-ref-chip { font-size: 12px; padding: 4px 10px; }

/* =====================================================
   TOAST
   ===================================================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 24px;
  border-radius: 12px;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  z-index: 10000;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  display: none;
  align-items: center;
  gap: 10px;
  max-width: 85vw;
  width: max-content;
  text-align: center;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  line-height: 1.4;
}
.toast.show { display: flex; animation: slideInUp 0.3s ease; }
.toast.success { background: var(--green); }
.toast.error { background: var(--danger); }
@keyframes slideInUp { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* =====================================================
   ACCESSIBILITY
   ===================================================== */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--green);
  color: white;
  padding: 8px 16px;
  z-index: 10000;
  text-decoration: none;
  font-weight: 600;
  border-radius: 0 0 8px 0;
}
.skip-link:focus {
  top: 0;
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

button:focus-visible, a:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* =====================================================
   MOBILE — Phones (max-width: 768px)
   ===================================================== */
@media (max-width: 768px) {
  /* Header: compact, just essentials */
  .header { padding: 8px 12px; gap: 6px; }
  .header-title { font-size: 13px; }
  .header-logo { height: 28px; }

  /* Hide non-essential header buttons on mobile */
  .header-right .header-btn:not(.primary),
  .header-right .dark-mode-toggle { display: none; }

  /* Keep lang switch and New SOP visible but compact */
  .header-right { gap: 6px; }
  .header-btn.primary { padding: 8px 12px; font-size: 13px; }

  /* Toolbar: search prominent */
  .toolbar { padding: 10px 12px; }
  .toolbar-left { width: 100%; }
  .search-box { width: 100%; max-width: none; }

  /* Hide selects and view toggle on mobile */
  .filter-select { display: none; }
  .toolbar-right { display: none; }

  /* Show category chips on mobile */
  .category-chips-wrapper { display: block; }

  /* Content */
  .content { padding: 12px; }

  /* Hide stats bar on mobile */
  .stats-bar { display: none; }

  /* Single column grid */
  .sop-grid { grid-template-columns: 1fr; gap: 12px; }
  .sop-card-preview { height: 60px; }

  /* Show FAB on mobile */
  .fab-manager { display: block; }

  /* Forms stack on mobile */
  .form-row, .form-row-3 { grid-template-columns: 1fr; }

  /* Steps: vertical stack */
  .step-item { flex-direction: column; }
  .step-image { width: 100%; }
  .step-image-preview { height: 150px; }

  /* Modals: full screen */
  .modal { padding: 0; }
  .modal-box, .modal-box.wide, .modal-box.small {
    max-width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    height: 100vh;
    height: 100dvh;
  }
  .modal-header { padding: 12px 16px; }
  .modal-header h2 { font-size: 15px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; gap: 8px; }
  .modal-footer .header-btn { flex: 1; justify-content: center; min-height: 48px; }

  /* View modal: steps full width, images below text */
  .view-sop-header { flex-direction: column; gap: 12px; }
  .view-sop-qr { display: none; } /* Hide QR on mobile — use the QR button instead */
  .view-sop-title { font-size: 18px; }

  .view-step { flex-direction: column; gap: 10px; padding: 16px; }
  .view-step-number { width: 48px; height: 48px; font-size: 22px; }
  .view-step-title { font-size: 17px; }
  .view-step-desc { font-size: 15px; }
  .view-step-image { width: 100%; height: auto; min-height: 150px; max-height: 300px; }
  .view-step-image img { height: auto; min-height: 150px; }
  .view-step-video { width: 100%; height: 200px; }

  /* Wizard navigation */
  .wizard-nav { position: sticky; bottom: 0; background: var(--bg-card); margin: 0 -16px -16px; padding: 12px 16px; border-top: 1px solid var(--border); }
  .wizard-btn { min-height: 56px; font-size: 17px; border-radius: 14px; }

  /* Safety steps extra prominent on mobile */
  .view-step.safety-step {
    border-left-width: 8px;
    padding: 18px;
  }
  .view-step.safety-step .view-step-number { width: 52px; height: 52px; font-size: 24px; }

  /* Media options */
  .media-options { gap: 8px; }
  .media-option { padding: 16px 12px; min-height: 70px; }

  /* Requests */
  .request-item-actions { flex-direction: column; }
  .request-item-actions button { justify-content: center; }
  .add-request-form .form-row { grid-template-columns: 1fr; }

  /* Toast centered bottom */
  .toast { bottom: 100px; } /* Above FAB */

  /* Annotation */
  .annotation-modal { max-width: 100vw; max-height: 100vh; border-radius: 0; }
  .annotation-toolbar { justify-content: center; }
  .tool-divider { display: none; }
  .tool-group { flex-wrap: wrap; justify-content: center; }
  .canvas-container { min-height: 250px; }
}

/* =====================================================
   SMALL PHONES (max-width: 400px)
   ===================================================== */
@media (max-width: 400px) {
  .header-title { display: none; }
  .header-btn.primary span { display: none; }
  .media-options { grid-template-columns: 1fr; }
  .media-option.url-option { grid-column: span 1; }
}

/* =====================================================
   TABLET (601-1024px)
   ===================================================== */
@media (min-width: 601px) and (max-width: 1024px) {
  .sop-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .toolbar-left { flex-wrap: wrap; }
}

/* =====================================================
   TOUCH DEVICES — 56px targets (gloves!)
   ===================================================== */
@media (pointer: coarse) {
  /* Tap highlight */
  button, a, [onclick], .sop-card, .step-image-preview, .media-option,
  input[type="checkbox"], input[type="radio"], label {
    -webkit-tap-highlight-color: rgba(102, 137, 113, 0.2);
  }

  /* CRITICAL: 16px minimum prevents iOS auto-zoom */
  .form-input, .filter-select, .search-box input,
  .step-title-input, .step-desc-input,
  .settings-add-form input, .add-request-form .form-input,
  input, textarea, select {
    font-size: 16px !important;
  }

  /* Increase padding for touch */
  .form-input, .filter-select { padding: 16px; }
  .search-box input { padding: 16px 16px 16px 48px; }
  .step-title-input, .step-desc-input { padding: 16px; }

  /* 56px minimum touch targets for ALL interactive elements */
  .header-btn, .dark-mode-toggle, .lang-switch {
    min-height: 56px;
    padding: 14px 18px;
    font-size: 15px;
  }

  .view-toggle button {
    min-height: 48px;
    min-width: 48px;
    padding: 12px 16px;
  }

  .inline-add-btn, .step-action-btn, .step-ai-btn, .step-icon-btn {
    min-width: 56px;
    min-height: 56px;
    width: 56px;
    height: 56px;
    font-size: 18px;
  }

  .sop-card-actions button {
    min-height: 56px;
    padding: 16px;
    font-size: 18px;
  }

  .settings-add-btn, .request-item-actions button {
    min-height: 48px;
    padding: 14px 18px;
  }

  .modal-close {
    min-width: 56px;
    min-height: 56px;
    padding: 14px;
    font-size: 24px;
  }

  .tag-color-option, .tag-color-picker-mini .color-dot {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
  }

  .ai-improve-btn {
    min-height: 48px;
    padding: 12px 16px;
    font-size: 13px;
  }

  .category-chip {
    min-height: 56px;
    padding: 14px 22px;
    font-size: 15px;
  }

  .fab-item {
    min-height: 56px;
    padding: 16px 22px;
  }

  .lang-toggle button, .requests-tab {
    min-height: 48px;
    padding: 14px 18px;
  }

  .translate-btn {
    min-height: 48px;
    padding: 14px 18px;
  }

  .sop-table .actions-cell button {
    min-width: 48px;
    min-height: 48px;
    padding: 12px 16px;
  }

  /* Checkbox/radio larger */
  input[type="checkbox"], input[type="radio"] {
    width: 24px;
    height: 24px;
    margin-right: 8px;
  }

  /* Active states for touch */
  .header-btn:active, .dark-mode-toggle:active {
    background: rgba(255,255,255,0.25);
    transform: scale(0.97);
  }
  .header-btn.primary:active { background: #d4982e; transform: scale(0.97); }
  .sop-card:active { transform: scale(0.98); border-color: var(--green); }
  .step-image-preview:active { background: var(--gold-dim); border-color: var(--gold); }
  .media-option:active { transform: scale(0.95); background: var(--green-dim); border-color: var(--green); }

  /* Color buttons larger */
  .color-btn { width: 44px; height: 44px; }

  /* Step edit button always visible on touch */
  .step-image-edit-btn {
    width: 48px;
    height: 48px;
    font-size: 20px;
    opacity: 1;
  }

  /* Modal sizing */
  .modal-box { max-height: 92vh; }
  .modal-box.wide { max-width: 95vw; }
  .modal-box.small { max-width: 92vw; }

  /* Better spacing */
  .step-item { padding: 18px; gap: 14px; }
  .step-icons { gap: 8px; }
  .step-actions { gap: 6px; }

  /* Wizard buttons extra chunky */
  .wizard-btn { min-height: 64px; font-size: 18px; border-radius: 16px; }

  /* Tutorial buttons */
  .tutorial-btn { min-height: 52px; padding: 14px 22px; font-size: 15px; }
}

/* =====================================================
   LANDSCAPE MODE
   ===================================================== */
@media (max-height: 500px) and (orientation: landscape) {
  .header { padding: 6px 12px; }
  .modal-box { max-height: 95vh; }
  .wizard-btn { min-height: 48px; }
}
