* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: #f5f6f8;
  color: #1f2937;
}

#app {
  max-width: 1280px;
  margin: 40px auto;
  padding: 0 16px;
}

.card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.hidden {
  display: none;
}

.field {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

input,
select,
button {
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
}

button {
  background: #2563eb;
  color: #fff;
  border: none;
  cursor: pointer;
}

button:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sub {
  color: #6b7280;
  font-size: 13px;
}

.emit {
  display: flex;
  gap: 12px;
  margin: 20px 0;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.filters.hidden {
  display: none;
}

.filters-toggle {
  background: transparent;
  border: 1px solid #d1d5db;
  color: #374151;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
  margin-bottom: 10px;
}

.filters input,
.filters select,
.filters button {
  font-size: 12px;
  padding: 8px 10px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.table-wrap {
  max-width: 100%;
  overflow-x: hidden;
}

th,
td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: top;
  font-size: 13px;
  line-height: 1.25;
  word-break: break-word;
}

td.col-barcode {
  white-space: nowrap;
}

td.col-print {
  white-space: nowrap;
}

td.col-print button {
  width: auto;
  min-width: 70px;
  padding: 6px 10px;
  white-space: nowrap;
  margin-right: 6px;
}

.action-secondary {
  background: #ffffff;
  color: #1f2937;
  border: 1px solid #d1d5db;
}


tr.pending {
  background: #f3f4f6;
}

tr.error {
  background: #fee2e2;
}

tr.issued {
  background: #dcfce7;
}

tr.printed {
  background: #ffffff;
}

tr.processing {
  position: relative;
  overflow: hidden;
  background: #e7f8ee;
}

tr.processing::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.2), rgba(34, 197, 94, 0.5));
  transform: scaleX(var(--progress, 0.05));
  transform-origin: left center;
  transition: transform 0.6s ease;
  z-index: 0;
}

tr.processing td {
  position: relative;
  z-index: 1;
}

.hint {
  color: #dc2626;
  margin-top: 8px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  width: 80%;
  max-width: 900px;
  max-height: 80vh;
  overflow: auto;
  padding: 20px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #f9fafb;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

body.modal-open {
  overflow: hidden;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn-secondary {
  background: #fff;
  color: #1f2937;
  border: 1px solid #d1d5db;
}

.modal-wide {
  max-width: 720px;
}

.modal-cert {
  max-width: 480px;
  width: 92%;
}

.cert-picker-hint {
  margin: 0 0 8px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.4;
  color: #374151;
  background: #f3f4f6;
  border-radius: 8px;
}

.cert-picker-hint-warn {
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fcd34d;
}

.cert-picker-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 360px;
  overflow-y: auto;
  margin: 8px 0 16px;
  padding: 4px;
}

.cert-picker-loading,
.cert-picker-empty {
  padding: 24px 12px;
  text-align: center;
  color: #6b7280;
  font-size: 14px;
}

.cert-picker-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  color: #1f2937;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.cert-picker-item:hover {
  border-color: #93c5fd;
  background: #f8fafc;
}

.cert-picker-item.selected {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: inset 0 0 0 1px #2563eb;
}

.cert-picker-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}

.cert-picker-meta {
  font-size: 12px;
  color: #6b7280;
}

.cert-picker-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.cert-picker-footer button {
  min-width: 100px;
}

.container-upload {
  margin: 12px 0 16px;
  padding: 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
}

.container-upload h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.container-upload-hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: #6b7280;
  line-height: 1.4;
}

.container-upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.container-upload-status {
  margin: 10px 0 0;
  font-size: 13px;
  color: #059669;
}

.container-upload-status.error {
  color: #b45309;
}

.file-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.sig-badge-ok {
  background: #d1fae5;
  color: #065f46;
}

.sig-badge-warn {
  background: #fef3c7;
  color: #92400e;
}

.sig-saved-details {
  margin-top: 16px;
  font-size: 13px;
  color: #6b7280;
}

.sig-saved-details summary {
  cursor: pointer;
  margin-bottom: 8px;
}

.sig-saved-details .sig-uploaded {
  margin-top: 8px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.sig-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

.sig-section h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.sig-hint {
  color: #6b7280;
  font-size: 13px;
  margin: 0 0 12px;
}

.sig-status {
  font-size: 13px;
  margin: 0 0 12px;
  padding: 8px 12px;
  border-radius: 8px;
}

.sig-status-ok {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.sig-status-warn {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.sig-warn {
  color: #b45309;
}

.sig-drives {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.sig-drive-chip {
  display: inline-block;
  padding: 6px 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  font-size: 13px;
}

.sig-certs,
.sig-uploaded {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sig-cert-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.sig-cert-row.sig-default {
  border-color: #2563eb;
  background: #eff6ff;
}

.sig-cert-info {
  flex: 1;
  font-size: 13px;
}

.sig-meta {
  color: #6b7280;
  font-size: 12px;
}

.sig-badge {
  color: #2563eb;
  font-size: 12px;
  font-weight: 600;
}

.sig-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.action-danger {
  background: #dc2626;
}

td.col-store {
  max-width: 120px;
}

.analytics-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}

.field-inline {
  margin-bottom: 0;
  min-width: 140px;
}

.analytics-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.summary-card {
  flex: 1;
  min-width: 140px;
  padding: 12px 16px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-card.summary-success {
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.summary-card.summary-error {
  background: #fef2f2;
  border-color: #fecaca;
}

.summary-label {
  font-size: 12px;
  color: #6b7280;
}

.summary-value {
  font-size: 20px;
  font-weight: 600;
}

.analytics-table-wrap {
  max-height: 50vh;
  overflow: auto;
}

tr.analytics-store-first td.col-store {
  font-weight: 600;
}

#analyticsTable th:nth-child(3),
#analyticsTable th:nth-child(4),
#analyticsTable th:nth-child(5),
#analyticsTable th:nth-child(6),
#analyticsTable td:nth-child(3),
#analyticsTable td:nth-child(4),
#analyticsTable td:nth-child(5),
#analyticsTable td:nth-child(6) {
  text-align: center;
  white-space: nowrap;
}
