body { font-family: sans-serif; margin: 0; background: #f5f6f8; color: #111; }
.wrap { max-width: 980px; margin: 0 auto; padding: 20px; }
.card { background: #fff; border-radius: 14px; padding: 20px; box-shadow: 0 2px 10px rgba(0,0,0,.07); }
.hidden { display: none !important; }
h1, h2, h3, p { margin: 0; }
button { cursor: pointer; border: none; border-radius: 8px; font-weight: 600; }
.btn-primary { background: #15a34a; color: #fff; padding: 10px 14px; }
.btn-secondary { background: #111827; color: #fff; padding: 10px 14px; }
.status { margin-top: 12px; font-size: 14px; font-weight: 600; }
.status.idle { color: #374151; }
.status.pending { color: #1d4ed8; }
.status.ok { color: #15803d; }
.status.error { color: #b91c1c; }
.status.warn { color: #b45309; }
.sync-progress { margin-top: 10px; }
.sync-progress-bar { width: 100%; height: 6px; border-radius: 999px; background: rgba(15,23,42,.08); overflow: hidden; }
.sync-progress-fill {
  width: 100%; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, #1d4ed8 0%, #3b82f6 100%);
  transform-origin: left center; transform: scaleX(0);
}
.sync-progress-fill.done { background: linear-gradient(90deg, #15803d 0%, #22c55e 100%); }
.sync-progress-fill.warn { background: linear-gradient(90deg, #d97706 0%, #f59e0b 100%); }
.sync-progress-text { margin-top: 4px; color: #4b5563; font-size: 12px; font-weight: 600; }

.pairing-header { margin-bottom: 18px; }
.pairing-header h1 { font-size: 36px; margin-bottom: 10px; }
.pairing-header p { color: #4b5563; line-height: 1.5; max-width: 760px; }
.pairing-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}
.pairing-option {
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  padding: 22px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.pairing-option.offline {
  background: #fff7e6;
  border-color: #f3e8b1;
}
.pairing-option.live {
  background: #eef5ff;
  border-color: #bfdbfe;
}
.pairing-option h2 {
  font-size: 24px;
  line-height: 1.15;
}
.pairing-option p {
  color: #4b5563;
  line-height: 1.5;
}
.pairing-points {
  margin: 0;
  padding-left: 18px;
  color: #374151;
  display: grid;
  gap: 8px;
}
.pairing-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
  min-width: 44px;
  position: relative;
}
.pairing-divider::before,
.pairing-divider::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 1px;
  background: #d1d5db;
  transform: translateX(-50%);
}
.pairing-divider::before {
  top: 0;
  height: calc(50% - 18px);
}
.pairing-divider::after {
  bottom: 0;
  height: calc(50% - 18px);
}
.qr-box {
  min-height: 220px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: #fff;
}
.instructions h3 { margin-bottom: 8px; }
.instructions ol { margin: 8px 0 0 18px; padding: 0; }
.instructions li { margin-bottom: 8px; line-height: 1.4; }
.muted { color: #6b7280; font-size: 13px; }
.pairing-actions { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; }
.pairing-note {
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 12px;
  padding: 12px 14px;
}
.session-code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.btn-inline-secondary {
  background: transparent;
  color: #1f2937;
  border: 1px solid #cbd5e1;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.session-timer {
  margin-top: 10px;
}
.session-timer-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, .08);
  overflow: hidden;
}
.session-timer-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0f766e 0%, #14b8a6 100%);
  transform-origin: left center;
  transition: transform .9s linear, background-color .2s ease;
}
.session-timer-fill.warn {
  background: linear-gradient(90deg, #d97706 0%, #f59e0b 100%);
}
.session-timer-fill.danger {
  background: linear-gradient(90deg, #dc2626 0%, #f87171 100%);
}
.session-timer-text {
  margin-top: 6px;
  color: #4b5563;
  font-size: 12px;
  font-weight: 600;
}
.session-code-inline {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ecfeff;
  color: #0f766e;
  font-weight: 700;
  font-family: monospace;
  letter-spacing: 1px;
}

.session-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.session-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.session-code-badge {
  background: #eff6ff;
  color: #1e3a8a;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0;
}
.session-code-badge.clickable {
  cursor: pointer;
  border: 1px solid #bfdbfe;
}
.session-code-badge.clickable:hover {
  background: #dbeafe;
}
.session-code-help {
  color: #4b5563;
  font-size: 13px;
  margin-top: -6px;
  margin-bottom: 12px;
}
.tabs {
  display: flex;
  gap: 8px;
  margin: 8px 0 12px 0;
}
.tab-btn {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  color: #111827;
  font-weight: 600;
}
.tab-btn.active {
  background: #111827;
  color: #fff;
  border-color: #111827;
}
.tab-btn:disabled {
  background: #e5e7eb;
  color: #6b7280;
  border-color: #d1d5db;
  cursor: not-allowed;
}
.tab-panel { border-top: 1px solid #e5e7eb; padding-top: 12px; }
.history-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.sync-qr-box {
  min-height: 220px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: #f9fafb;
  margin-top: 14px;
}
.modal-connect-card {
  margin-top: 12px;
}
.modal-connect-card .pairing-actions {
  margin-top: 0;
}
.list-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.list-actions .btn-secondary {
  padding: 9px 12px;
}
.history-search {
  flex: 1 1 260px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
}
.history-filter-btn {
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #f9fafb;
  color: #111827;
  font-size: 13px;
  font-weight: 600;
}
.history-filter-btn.active {
  background: #111827;
  color: #fff;
  border-color: #111827;
}
.inventory-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.inventory-toolbar .btn-primary,
.inventory-toolbar .btn-secondary {
  padding: 10px 14px;
}
.inventory-toolbar-help {
  color: #4b5563;
  font-size: 13px;
  font-weight: 600;
}
.inventory-list {
  display: grid;
  gap: 18px;
}
.inventory-card {
  border: 1px solid #d9e2ef;
  border-radius: 22px;
  padding: 20px 22px;
  background: #ffffff;
  box-shadow: 0 10px 26px rgba(15, 23, 42, .05);
}
.inventory-card h3 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.15;
}
.inventory-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}
.inventory-card-title {
  min-width: 0;
  flex: 1;
}
.inventory-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-bottom: 8px;
}
.inventory-compare-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.inventory-compare-toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #111827;
  cursor: pointer;
}
.inventory-title-row h3 {
  margin: 0;
  min-width: 0;
}
.inventory-rename-btn {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #506079;
  border: none;
  font-size: 14px;
  flex: 0 0 auto;
}
.inventory-quick-scan-btn {
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid #dbe4f0;
  background: #f8fbff;
  color: #244a8f;
  font-size: 12px;
  font-weight: 700;
  flex: 0 0 auto;
}
.inventory-quick-scan-btn:hover {
  background: #eef5ff;
  border-color: #c7d8f3;
  color: #173870;
}
.inventory-rename-btn:hover,
.inventory-inline-icon:hover {
  color: #111827;
  background: rgba(15, 23, 42, .06);
}
.inventory-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 0;
}
.inventory-actions.compact {
  align-items: center;
  justify-content: flex-end;
}
.inventory-meta-block {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}
.inventory-summary {
  color: #1f2937;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 0;
}
.inventory-meta-line {
  color: #667085;
  font-size: 13px;
  line-height: 1.45;
}
.custom-data-list {
  display: grid;
  gap: 10px;
}
.custom-data-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}
.custom-data-add {
  align-self: flex-start;
}
.inventory-content-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.inventory-disclosure {
  position: relative;
  margin-top: 4px;
}
.inventory-disclosure summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-start;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: #111827;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex: 0 0 auto;
}
.inventory-disclosure summary::-webkit-details-marker {
  display: none;
}
.inventory-disclosure summary::before {
  content: "▸";
  font-size: 11px;
  transition: transform .18s ease;
}
.inventory-disclosure[open] summary::before {
  transform: rotate(90deg);
}
.inventory-compare-results {
  display: grid;
  gap: 12px;
}
.inventory-compare-table-wrap {
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #fff;
  overflow: auto;
}
.inventory-compare-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.inventory-compare-table th,
.inventory-compare-table td {
  vertical-align: top;
  width: 50%;
}
.inventory-compare-table thead th {
  padding: 14px 16px;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
  text-align: left;
  font-size: 16px;
}
.inventory-compare-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid #eef2f7;
}
.inventory-compare-table tbody tr:last-child td {
  border-bottom: none;
}
.inventory-compare-table tbody td + td {
  border-left: 1px solid #eef2f7;
}
.inventory-compare-table tbody td.merged {
  border-left: none;
}
.inventory-compare-cell.both {
  background: #f0fdf4;
  border-radius: 10px;
  padding: 10px 12px;
}
.inventory-compare-cell.empty {
  background: #f3f4f6;
  border-radius: 10px;
  padding: 10px 12px;
  color: #6b7280;
  font-style: italic;
}
.inventory-compare-code {
  font-weight: 700;
}
.inventory-compare-line {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.inventory-compare-qty.changed {
  font-weight: 800;
}
.inventory-compare-section {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  padding: 12px;
}
.inventory-compare-section h4 {
  margin: 0 0 8px 0;
  font-size: 15px;
}
.inventory-compare-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, .58);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 48;
}
.inventory-compare-modal {
  width: min(1200px, 100%);
  max-height: calc(100vh - 32px);
  background: #fff;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
  overflow: auto;
}
@media (max-width: 900px) {
  .inventory-compare-table {
    min-width: 760px;
  }
}
.inventory-item-title {
  font-weight: 700;
}
.inventory-item-head {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.inventory-item-meta {
  color: #4b5563;
  font-size: 12px;
  margin-left: 0;
}
.inventory-inline-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 7px;
  margin-left: 0;
  border-radius: 8px;
  background: transparent;
  color: #506079;
  border: none;
  font-size: 13px;
  line-height: 1;
  vertical-align: middle;
}
.inventory-inline-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}
.inventory-item-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}
.inventory-item-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .92);
  border: 1px solid #e5edf7;
}
.inventory-item-main {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 4px;
}
.inventory-item-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}
.inventory-item-code {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -.02em;
}
.inventory-item-subline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: #667085;
  font-size: 13px;
}
.inventory-item-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  margin-top: 2px;
}
.inventory-empty-state {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .9);
  border: 1px dashed #d9e2ef;
  color: #667085;
}
.inventory-panel {
  margin-top: 14px;
  padding: 16px;
  border-radius: 18px;
  background: #f7faff;
  border: 1px solid #e4ebf5;
}
ul { padding-left: 18px; margin: 0; }
li { margin-bottom: 8px; }
.pill { background: #eef2ff; color: #1e3a8a; border-radius: 999px; padding: 2px 8px; font-size: 12px; }
.pill.favorite { background: #fee2e2; color: #991b1b; }
.history-name { font-weight: 700; margin-left: 6px; }
.history-desc { color: #4b5563; font-size: 12px; margin-left: 6px; }
.scan-copy-btn {
  margin-left: 8px;
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 6px;
  background: #111827;
  color: #fff;
}
.icon-btn {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
  background: #e5e7eb;
  color: #111827;
  border: 1px solid #d1d5db;
}
.menu {
  position: relative;
}
.menu summary {
  list-style: none;
}
.menu summary::-webkit-details-marker {
  display: none;
}
.menu-summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #1e293b;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
}
.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 220px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 14px 30px rgba(0,0,0,.12);
  padding: 8px;
  z-index: 20;
  display: grid;
  gap: 6px;
}
.menu-panel button {
  text-align: left;
  padding: 9px 10px;
  border-radius: 8px;
  background: #f9fafb;
  color: #111827;
  font-size: 13px;
  border: 1px solid #e5e7eb;
}
.menu-panel button:disabled {
  opacity: .5;
  cursor: not-allowed;
}
.generator-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 40;
}
.generator-modal {
  width: min(640px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
}
.generator-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.generator-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.generator-select {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  min-width: 180px;
  background: #fff;
}
.generator-preview {
  min-height: 280px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: #fff;
  overflow: auto;
}
.inventory-scanner-modal {
  width: min(720px, 100%);
}
.inventory-scanner-backdrop {
  z-index: 50;
}
.inventory-duplicate-backdrop {
  z-index: 46;
}
.inventory-scanner-preview {
  min-height: 360px;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  overflow: hidden;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
}
.inventory-scanner-preview > div {
  width: 100%;
}
.inventory-scanner-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.form-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 45;
}
.form-modal {
  width: min(720px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.inline-input-row {
  display: flex;
  gap: 0;
  align-items: center;
  border-radius: 10px;
}
.inline-input-row .input-with-action {
  flex: 1;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
}
.inline-input-row .input-action-btn {
  white-space: nowrap;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  flex: 0 0 auto;
  padding: 10px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.inline-input-row:focus-within {
  box-shadow: 0 0 0 3px rgba(64, 105, 177, 0.14);
}
.inline-input-row:focus-within .input-with-action,
.inline-input-row:focus-within .input-action-btn {
  border-color: #9db8e8;
  box-shadow: none;
  outline: none;
}
.form-field.full {
  grid-column: 1 / -1;
}
.form-field label {
  font-size: 13px;
  font-weight: 700;
  color: #374151;
}
.form-field input,
.form-field select,
.form-field textarea {
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: #111827;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: #9db8e8;
  box-shadow: 0 0 0 3px rgba(64, 105, 177, 0.14);
}
.inline-input-row .input-with-action:focus {
  box-shadow: none;
}
.form-field select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 40px;
  background-image:
    linear-gradient(45deg, transparent 50%, #6b7280 50%),
    linear-gradient(135deg, #6b7280 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
.form-field textarea {
  min-height: 96px;
  resize: vertical;
}
.form-error {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 13px;
  font-weight: 600;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}
.scan-copy-btn.success { background: #15803d; }
.scan-copy-btn.error { background: #b91c1c; }
.item-check {
  margin-right: 8px;
  transform: translateY(1px);
}

@media (max-width: 820px) {
  .pairing-grid {
    grid-template-columns: 1fr;
  }
  .pairing-divider {
    min-height: 24px;
  }
  .pairing-divider::before,
  .pairing-divider::after {
    top: 50%;
    left: auto;
    width: calc(50% - 28px);
    height: 1px;
    transform: translateY(-50%);
  }
  .pairing-divider::before {
    left: 0;
  }
  .pairing-divider::after {
    right: 0;
  }
  .inventory-card-head {
    flex-direction: column;
  }
  .inventory-actions.compact {
    width: 100%;
    justify-content: flex-start;
  }
  .inventory-item-row {
    flex-direction: column;
  }
  .inventory-item-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .menu-panel {
    left: 0;
    right: auto;
    min-width: min(260px, calc(100vw - 48px));
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .inventory-scanner-preview {
    min-height: 300px;
  }
  .custom-data-row {
    grid-template-columns: 1fr;
  }
  .qr-box { min-height: 180px; }
  .session-top { flex-direction: column; align-items: flex-start; }
}
