/* ============================================
   DroneSense Fleet Manager — Main Stylesheet
   ============================================ */

/* ----- Reset ----- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ----- CSS Custom Properties (Dark theme — default) ----- */
:root {
  --bg: #1a1a1a;
  --surface: #242424;
  --surface2: #2e2e2e;
  --border: #3a3a3a;
  --accent: #4a9fd5;
  --accent2: #3b82c4;
  --gradient: linear-gradient(135deg, #4a9fd5, #3b82c4);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text: #f5f5f5;
  --text2: #a0a0a0;
  --text3: #666666;
  --radius: 8px;
}

/* ----- Light Theme ----- */
[data-theme="light"] {
  --bg: #f8f9fc;
  --surface: #ffffff;
  --surface2: #f1f3f8;
  --border: #e2e5eb;
  --accent: #4f8ef7;
  --accent2: #4338ca;
  --gradient: linear-gradient(135deg, #4f8ef7, #4338ca);
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --text: #111827;
  --text2: #6b7280;
  --text3: #9ca3af;
}

[data-theme="light"] .stat-card,
[data-theme="light"] .detail-field {
  background: rgba(255,255,255,0.7);
}

/* ----- Body & App Shell ----- */
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.01em;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ----- Auth Screen ----- */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.auth-card h1 {
  font-size: 22px;
  margin-bottom: 4px;
}

.auth-card p {
  color: var(--text2);
  margin-bottom: 28px;
  font-size: 14px;
}

.auth-logo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin: 0 auto 16px;
  object-fit: cover;
  border: 2px solid var(--border);
}

/* ----- Brand ----- */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  margin-right: 20px;
}

.brand img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
}

.brand span {
  font-weight: 700;
  font-size: 16px;
  color: #ffffff;
  white-space: nowrap;
  font-family: 'Sora', sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ----- Navigation Bar ----- */
#nav {
  background: #1a1a1a;
  border-bottom: 1px solid #333;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
  overflow-x: auto;
}

[data-theme="light"] #nav {
  background: #ffffff;
  border-bottom: 1px solid #e5e5e5;
}

.nav-btn {
  background: none;
  border: none;
  color: #a0a0a0;
  padding: 8px 16px;
  border-radius: 0;
  cursor: pointer;
  font-size: 13px;
  font-family: 'Sora', sans-serif;
  font-weight: 400;
  transition: color 0.2s;
  white-space: nowrap;
  letter-spacing: 0.02em;
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
}

.nav-btn:hover {
  color: #ffffff;
  background: none;
}

.nav-btn.active {
  color: #ffffff;
  font-weight: 500;
  background: none;
}

.nav-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
}

#nav .spacer {
  flex: 1;
  min-width: 2px;
}

#nav .user-email {
  font-size: 11px;
  color: var(--text2);
  white-space: nowrap;
  font-family: 'Sora', sans-serif;
}

#nav .signout {
  font-size: 11px;
  color: var(--text2);
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 8px;
  white-space: nowrap;
  font-family: 'Sora', sans-serif;
  transition: all 0.15s;
}

#nav .signout:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
}

.receive-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  font-weight: 600;
  font-size: 12px;
  padding: 8px 20px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  font-family: 'Sora', sans-serif;
  letter-spacing: 0.03em;
  transition: background 0.2s;
  text-transform: uppercase;
}
.receive-btn:hover {
  background: var(--accent2);
}

/* ----- Main Content Area ----- */
#main {
  flex: 1;
  padding: 20px 14px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

/* ----- Search ----- */
.search-wrap {
  position: relative;
  margin-bottom: 20px;
}

.search-wrap input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px 11px 40px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 142, 247, 0.1);
}

.search-wrap .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  font-size: 16px;
  line-height: 0;
  display: flex;
  align-items: center;
}

#search-results {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 4px;
  overflow: hidden;
  display: none;
  position: absolute;
  width: 100%;
  z-index: 50;
  max-height: 300px;
  overflow-y: auto;
}

.sr-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.sr-item:last-child {
  border-bottom: none;
}

.sr-item:hover {
  background: var(--surface2);
}

/* ----- Filter Bar & Chips ----- */
.filter-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.filter-chip:hover,
.filter-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ----- Stats Grid ----- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--gradient);
}

.stat-card.clickable {
  cursor: pointer;
}

.stat-card.clickable:hover {
  border-color: var(--accent);
  background: var(--surface2);
}

.stat-card .num {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  font-family: 'Sora', sans-serif;
  letter-spacing: -0.5px;
}

.stat-card .label {
  font-size: 12px;
  color: var(--text2);
  margin-top: 4px;
  font-weight: 300;
  letter-spacing: 0.03em;
}

/* ----- Section Header ----- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}

.section-header h2 {
  font-size: 17px;
  font-weight: 600;
}

/* ----- Table ----- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 20px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 400px;
}

th {
  background: var(--surface2);
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

td {
  padding: 8px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(79, 142, 247, 0.04);
  cursor: pointer;
}

tr:hover td:first-child {
  border-left: 3px solid var(--accent);
}

/* ----- Badges ----- */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 5px;
  background: currentColor;
  vertical-align: middle;
}

.badge-in_stock,
.badge-back_in_stock {
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
}

.badge-deployed {
  background: rgba(79, 142, 247, 0.12);
  color: #7cb3f9;
}

.badge-ordered {
  background: rgba(67, 56, 202, 0.15);
  color: #a5b4fc;
}

.badge-incident {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
}

.badge-rma_in_transit,
.badge-under_repair {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
}

.badge-repaired {
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
}

.badge-open {
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
}

.badge-closed {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
}

.badge-denied {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
}

/* ----- Modal ----- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

.modal h3 {
  font-size: 17px;
  margin-bottom: 18px;
}

/* ----- Forms ----- */
.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 11px;
  color: var(--text2);
  margin-bottom: 4px;
  font-weight: 500;
}

.fg-input,
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.fg-input:focus {
  border-color: var(--accent);
}

.form-group select option {
  background: var(--surface2);
}

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

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 18px;
}

/* ----- Buttons ----- */
.btn {
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #3b7de8, #3730a3);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

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

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 11px;
}

.btn-icon {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
}

.btn-icon:hover {
  background: var(--border);
  color: var(--text);
}

.scan-btn {
  background: var(--accent2);
  color: #fff;
  border: none;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 11px;
  white-space: nowrap;
}

/* ----- Detail View ----- */
.detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.detail-header .back {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.detail-field {
  backdrop-filter: blur(10px);
  background: rgba(17,19,24,0.7);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: var(--radius);
  padding: 12px;
}

.detail-field .key {
  font-size: 10px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}

.detail-field .val {
  font-size: 13px;
  font-weight: 500;
}

.detail-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}

.audit-info {
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 16px;
}

/* ----- Empty State ----- */
.empty {
  text-align: center;
  padding: 50px 20px;
  color: var(--text2);
}

.empty .icon {
  font-size: 36px;
  margin-bottom: 10px;
}

/* ----- Toast ----- */
#toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 13px;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
}

/* ----- Wizard (Receive Flow) ----- */
.wizard-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 300;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.wizard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.wizard-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.wizard-close {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}

.wizard-progress {
  display: flex;
  gap: 3px;
  padding: 8px 14px;
  background: var(--surface);
  flex-shrink: 0;
}

.dot {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  transition: background 0.3s;
}

.dot.done {
  background: var(--success);
}

.dot.active {
  background: var(--accent);
}

.wizard-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px;
  -webkit-overflow-scrolling: touch;
}

.wizard-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.wizard-footer .btn {
  flex: 1;
  padding: 13px;
  font-size: 14px;
  font-weight: 600;
}

.wiz-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.wiz-sub {
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 18px;
}

/* ----- Checklist (Wizard) ----- */
.cl-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cl-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: all 0.15s;
}

.cl-row.on {
  border-color: rgba(34, 197, 94, 0.3);
  background: rgba(34, 197, 94, 0.06);
}

.cl-box {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
  transition: all 0.15s;
}

.cl-row.on .cl-box {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.cl-label {
  font-size: 13px;
}

/* ----- Review Sections (Wizard) ----- */
.rev-section {
  margin-bottom: 16px;
}

.rev-section h4 {
  font-size: 11px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 5px;
}

.rev-row {
  display: flex;
  justify-content: space-between;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  margin-bottom: 2px;
}

.rev-row .rl {
  color: var(--text2);
  font-size: 11px;
}

.rev-row .rv {
  font-family: monospace;
  font-size: 12px;
  font-weight: 500;
}

.rev-row .rv.empty {
  color: var(--text3);
  font-style: italic;
  font-family: inherit;
}

/* ----- Photos ----- */
.photo-area {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.photo-thumb {
  width: 70px;
  height: 70px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  cursor: pointer;
}

.photo-add {
  width: 70px;
  height: 70px;
  border-radius: 8px;
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text2);
  font-size: 22px;
}

.photo-add:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ----- Group Cards (By Organization, By PO) ----- */
.group-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}

.group-hdr {
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.group-hdr h3 {
  font-size: 14px;
  font-weight: 600;
}

.group-hdr .meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.group-hdr .cnt {
  font-size: 11px;
  color: var(--text2);
  background: var(--surface2);
  padding: 2px 9px;
  border-radius: 12px;
}

.group-hdr .arrow {
  color: var(--text3);
  transition: transform 0.2s;
  font-size: 12px;
}

.group-hdr.open .arrow {
  transform: rotate(180deg);
}

.group-body {
  display: none;
  border-top: 1px solid var(--border);
}

.group-body.open {
  display: block;
}

.group-stats {
  display: flex;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--text2);
}

.group-stats span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ----- Confirm Dialog ----- */
.confirm-box {
  text-align: center;
  padding: 10px 0;
}

.confirm-box p {
  margin-bottom: 18px;
  font-size: 14px;
}

/* ----- Scanner (Full Screen) ----- */
.scan-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 400;
  display: flex;
  flex-direction: column;
}

.scan-overlay video {
  flex: 1;
  object-fit: cover;
  width: 100%;
}

.scan-overlay .scan-ui {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.scan-overlay .scan-top {
  padding: 20px;
  text-align: center;
  pointer-events: auto;
}

.scan-overlay .scan-top p {
  color: #fff;
  font-size: 14px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.scan-overlay .scan-bottom {
  padding: 20px;
  text-align: center;
  pointer-events: auto;
}

.scan-overlay .scan-cancel {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: none;
  padding: 12px 32px;
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.scan-reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 220px;
  height: 220px;
  border: 3px solid var(--accent);
  border-radius: 16px;
  pointer-events: none;
}

/* ----- Searchable Select ----- */
.search-select {
  position: relative;
}

.search-select input {
  width: 100%;
}

.search-select .ss-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
  display: none;
}

.search-select .ss-list.open {
  display: block;
}

.search-select .ss-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.search-select .ss-item:hover {
  background: var(--surface2);
}

.search-select .ss-item:last-child {
  border-bottom: none;
}

/* ============================================
   NEW: Loading Skeletons
   ============================================ */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
}

.skeleton-card {
  height: 80px;
  margin-bottom: 10px;
}

.skeleton-table-row {
  height: 40px;
  margin-bottom: 4px;
}

/* ============================================
   NEW: Pagination
   ============================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px;
}

.pagination button {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.pagination button:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination .current {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.pagination .info {
  font-size: 11px;
  color: var(--text2);
}

/* ============================================
   NEW: Bulk Operations Toolbar
   ============================================ */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface2);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  margin-bottom: 12px;
  color: var(--text);
  font-size: 13px;
  position: sticky;
  top: 62px;
  z-index: 50;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.bulk-bar .bulk-count {
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.bulk-bar select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
}

.bulk-bar select:focus {
  border-color: var(--accent);
}

.bulk-bar button {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}

.bulk-bar button:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.bulk-bar button.bulk-apply {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}

.bulk-bar button.bulk-apply:hover {
  background: var(--accent2);
  border-color: var(--accent2);
}

.bulk-bar button.bulk-clear {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--text2);
}

.bulk-bar button.bulk-clear:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* ============================================
   NEW: Sortable Table Headers
   ============================================ */
th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover {
  color: var(--text);
}

th.sortable::after {
  content: '\21C5';
  margin-left: 4px;
  opacity: 0.3;
}

th.sort-asc::after {
  content: '\2191';
  opacity: 1;
}

th.sort-desc::after {
  content: '\2193';
  opacity: 1;
}

/* ============================================
   NEW: Bulk Select Checkbox
   ============================================ */
.row-check {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ============================================
   NEW: Theme Toggle Button
   ============================================ */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--text2);
}

/* ============================================
   NEW: Keyboard Shortcut Hints
   ============================================ */
.kbd {
  font-size: 9px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 4px;
  color: var(--text3);
  margin-left: 4px;
}

/* ============================================
   NEW: Smooth Tab Transitions
   ============================================ */
#main > div[id^="view-"] {
  animation: fadeIn 0.2s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   NEW: Color-coded Table Rows by Status
   ============================================ */
tr[data-status="in_stock"] td, tr[data-status="back_in_stock"] td { background: rgba(34,197,94,0.03); }
tr[data-status="deployed"] td { background: rgba(59,130,246,0.03); }
tr[data-status="incident"] td, tr[data-status="rma_in_transit"] td, tr[data-status="under_repair"] td { background: rgba(245,158,11,0.03); }

/* ============================================
   NEW: Click-to-copy Cursor
   ============================================ */
.copy-serial {
  cursor: pointer;
  position: relative;
}

.copy-serial:hover {
  color: var(--accent);
}

.copy-serial:hover::after {
  content: 'Click to copy';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 10px;
  white-space: nowrap;
  color: var(--text2);
  pointer-events: none;
}

/* ============================================
   NEW: Kit Completion Progress Bar
   ============================================ */
.kit-progress {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}

.kit-progress-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--success));
  transition: width 0.3s ease;
}

/* ============================================
   NEW: Breadcrumb Styles
   ============================================ */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 12px;
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb .sep {
  color: var(--text3);
}

/* ============================================
   NEW: Quick Action Buttons on Dashboard
   ============================================ */
.quick-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.quick-action-btn {
  flex: 1;
  padding: 16px 20px;
  background: var(--accent);
  border: none;
  border-radius: 100px;
  cursor: pointer;
  text-align: center;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Sora', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.2s cubic-bezier(0.2, 0, 0, 1), border-radius 0.6s cubic-bezier(0.2, 0, 0, 1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 4px 8px rgba(0,0,0,0.15);
  letter-spacing: 0.01em;
}

.quick-action-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  transition: opacity 0.15s linear;
  border-radius: inherit;
}

.quick-action-btn:hover::before {
  opacity: 0.08;
}

.quick-action-btn:active {
  transform: scale(0.97);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.quick-action-btn:active::before {
  opacity: 0.12;
}

.quick-action-btn:nth-child(2) {
  background: var(--surface2);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.quick-action-btn:nth-child(3) {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
  box-shadow: none;
}

.quick-action-btn:nth-child(3):hover {
  background: rgba(79, 142, 247, 0.08);
}

.qicon-svg {
  width: 20px;
  height: 20px;
  color: inherit;
  flex-shrink: 0;
}

/* ============================================
   Kit Tracking Timeline
   ============================================ */
.kit-timeline {
  display: flex;
  align-items: flex-start;
  margin-bottom: 24px;
  padding: 20px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.kit-timeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
  min-width: 120px;
}

.kit-timeline-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface2);
  border: 3px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: all 0.3s;
}

.kit-timeline-step.done .kit-timeline-dot {
  background: var(--accent);
  border-color: var(--accent);
}

.kit-timeline-line {
  position: absolute;
  top: 14px;
  left: calc(50% + 14px);
  right: calc(-50% + 14px);
  height: 3px;
  background: var(--border);
  z-index: 1;
}

.kit-timeline-step.done .kit-timeline-line {
  background: var(--accent);
}

.kit-timeline-label {
  margin-top: 10px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  color: var(--text2);
  line-height: 1.3;
}

.kit-timeline-step.done .kit-timeline-label {
  color: var(--text);
}

.kit-timeline-date {
  margin-top: 4px;
  font-size: 10px;
  color: var(--text3);
  text-align: center;
}

.kit-timeline-step.done .kit-timeline-date {
  color: var(--accent);
}

@media (max-width: 600px) {
  .kit-timeline {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px;
    gap: 0;
  }

  .kit-timeline-step {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    min-width: auto;
    width: 100%;
    padding: 8px 0;
  }

  .kit-timeline-line {
    position: absolute;
    top: calc(50% + 14px);
    bottom: calc(-50% + 14px);
    left: 14px;
    right: auto;
    width: 3px;
    height: auto;
  }

  .kit-timeline-label {
    margin-top: 0;
    text-align: left;
  }

  .kit-timeline-date {
    margin-top: 0;
    margin-left: auto;
    text-align: right;
  }
}

/* ============================================
   Notes/Comments Section
   ============================================ */
.notes-section {
  margin-bottom: 18px;
}

.notes-thread {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 10px;
}

.notes-thread .note-entry {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.notes-thread .note-entry:last-child {
  border-bottom: none;
}

.note-meta {
  font-size: 10px;
  color: var(--text3);
  margin-bottom: 4px;
  display: flex;
  gap: 8px;
}

.note-meta .note-author {
  color: var(--accent);
  font-weight: 600;
}

.note-body {
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
  line-height: 1.5;
}

.notes-empty {
  color: var(--text3);
  font-size: 12px;
  font-style: italic;
  padding: 12px 0;
}

.note-add-area {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.note-add-area textarea {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  resize: vertical;
  min-height: 40px;
  font-family: inherit;
}

.note-add-area textarea:focus {
  border-color: var(--accent);
}

.note-add-area button {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.note-add-area button:hover {
  background: var(--accent2);
}

/* ============================================
   Empty Filter State
   ============================================ */
.empty-filter {
  text-align: center;
  padding: 40px 20px;
  color: var(--text2);
}

.empty-filter p {
  margin-bottom: 12px;
  font-size: 14px;
}

.empty-filter button {
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.empty-filter button:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ============================================
   Charts
   ============================================ */

/* ============================================
   Responsive — Mobile
   ============================================ */
@media (max-width: 900px) {
  #nav {
    overflow-x: auto;
    scrollbar-width: none;
  }
  #nav::-webkit-scrollbar { display: none; }
  #nav .brand span { display: none; }
  #nav .user-email { display: none; }
}

@media (max-width: 600px) {
  #nav {
    position: fixed;
    bottom: 0;
    top: auto;
    left: 0;
    right: 0;
    height: auto;
    padding: 4px 2px;
    flex-wrap: nowrap;
    overflow-x: auto;
    border-bottom: none;
    border-top: 1px solid var(--border);
    z-index: 100;
    gap: 0;
  }

  #nav .brand, #nav .spacer, #nav .user-email, #nav .signout, #nav .theme-toggle {
    display: none;
  }

  #nav .receive-btn {
    position: fixed;
    bottom: 56px;
    right: 12px;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    padding: 0;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 101;
  }

  .nav-btn {
    padding: 8px 10px;
    font-size: 11px;
    flex-shrink: 0;
  }

  #main {
    padding: 14px 8px;
    padding-bottom: 64px;
  }

  th {
    top: 0;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .modal {
    padding: 16px;
  }
}

/* ============================================
   Print
   ============================================ */
@media print {
  #nav, .search-wrap, .receive-btn, .btn, .theme-toggle, .signout, .user-email,
  .quick-actions, .filter-bar, .detail-actions, .modal-overlay, #toast,
  #wizard-container, #modal-container, #scan-container { display: none !important; }
  body { background: #fff; color: #000; }
  #main { padding: 0; max-width: 100%; }
  .stat-card { border: 1px solid #ccc; background: #fff; }
  .stat-card .num { color: #333; }
  .table-wrap { border: 1px solid #ccc; }
  th { background: #f5f5f5; color: #333; border-bottom: 2px solid #ccc; }
  td { border-bottom: 1px solid #eee; color: #000; }
  tr:hover td { background: transparent; }
  .badge { border: 1px solid #999; background: #f0f0f0; color: #333; }
  .detail-field, .group-card { border-color: #ccc; }
}
