* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f0f2f5;
  color: #1a1a1a;
  min-height: 100vh;
  margin: 0;
  padding: 32px 16px;
}
.container { max-width: 1100px; margin: 0 auto; }
h1 { font-size: 22px; font-weight: 600; margin-bottom: 22px; color: #111; }

.header-row { display: flex; align-items: center; justify-content: space-between; }
.header-row h1 { margin-bottom: 22px; }

body.login-page { display: flex; align-items: center; justify-content: center; }
.login-card {
  background: #fff; border-radius: 10px; padding: 32px; width: 320px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.12); display: flex; flex-direction: column; gap: 12px;
}
.login-card h1 { text-align: center; margin-bottom: 6px; }
.login-card input {
  border: 1px solid #e5e7eb; border-radius: 6px; padding: 10px 12px; font-size: 14px;
  font-family: inherit; background: #f9fafb;
}
.login-card input:focus { outline: none; border-color: #3b82f6; background: #fff; }
.login-error { color: #b91c1c; font-size: 13px; text-align: center; margin: 0; }

.section-nav {
  display: flex; gap: 4px; margin-bottom: 20px;
  border-bottom: 2px solid #e5e7eb; padding-bottom: 0;
}
.section-btn {
  border: none; background: transparent; color: #6b7280;
  font-size: 15px; font-weight: 500; cursor: pointer;
  padding: 8px 18px; border-radius: 6px 6px 0 0;
  margin-bottom: -2px; border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.section-btn:hover { color: #374151; }
.section-btn.active { color: #2563eb; border-bottom-color: #2563eb; }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; }

.tab-bar-row { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tab-bar { display: flex; gap: 6px; flex-wrap: wrap; }

.tab {
  display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 7px;
  background: #f3f4f6; color: #4b5563; font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: background 0.15s, color 0.15s;
}
.tab:hover { background: #e5e7eb; }
.tab.active { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }

.tab-label { white-space: nowrap; }
.tab-count { font-size: 11px; color: #9ca3af; }
.tab.active .tab-count { color: #60a5fa; }

.tab-rename-input {
  border: 1px solid #93c5fd; border-radius: 5px; padding: 2px 5px; font-size: 13px;
  font-family: inherit; width: 120px;
}

.tab-close {
  border: none; background: transparent; color: #9ca3af; font-size: 15px; line-height: 1;
  cursor: pointer; padding: 0 2px; opacity: 0; transition: opacity 0.15s, color 0.15s;
}
.tab:hover .tab-close { opacity: 1; }
.tab-close:hover { color: #ef4444; }

.tab-add {
  border: 1.5px dashed #d1d5db; background: transparent; color: #9ca3af; border-radius: 7px;
  width: 30px; height: 30px; font-size: 16px; cursor: pointer; flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}
.tab-add:hover { border-color: #3b82f6; color: #3b82f6; }

.btn {
  border: none; border-radius: 6px; padding: 9px 16px;
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background 0.15s;
}
.btn-primary { background: #3b82f6; color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-success { background: #10b981; color: #fff; }
.btn-success:hover:not(:disabled) { background: #059669; }
.btn-success:disabled { background: #a7e8d1; cursor: not-allowed; }
.btn-secondary { background: #f3f4f6; color: #374151; }
.btn-secondary:hover { background: #e5e7eb; }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover:not(:disabled) { background: #fecaca; }
.btn-danger:disabled { background: #fef2f2; color: #fca5a5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
thead th {
  text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.03em; color: #6b7280; padding: 10px 12px; border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
}
.col-check { width: 36px; }
.col-name { width: 220px; }
.col-photo { width: 160px; }
.col-photo-clean { width: 196px; }
.col-actions { width: 70px; }
.col-ai { width: 40px; text-align: center; }
.openai-btn { background: #f5f3ff; color: #6d28d9; box-shadow: none; }
.openai-btn:hover { background: #ede9fe; }
.openai-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.openai-btn.busy {
  width: auto; min-width: 24px; padding: 0 6px; font-size: 11px;
  white-space: nowrap; opacity: 1;
}
.actions-cell { display: flex; align-items: center; justify-content: center; gap: 4px; }

.photo-cell-row { display: flex; align-items: flex-start; gap: 8px; }
.push-panel { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 4px; }
.push-check { color: #10b981; font-size: 17px; font-weight: 700; line-height: 1; }

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: #3b82f6; }
.sort-indicator { margin-left: 4px; color: #3b82f6; font-size: 11px; }

tbody tr { border-bottom: 1px solid #f0f0f0; }
tbody tr:last-child { border-bottom: none; }
tbody td { padding: 10px 12px; vertical-align: middle; }

.name-cell { display: flex; align-items: center; gap: 6px; }

.name-input {
  flex: 1; min-width: 0; border: 1px solid transparent; border-radius: 6px; padding: 7px 9px;
  font-size: 14px; background: #f9fafb; transition: border-color 0.15s, background 0.15s;
}
.name-input:hover { background: #f3f4f6; }
.name-input:focus { outline: none; border-color: #3b82f6; background: #fff; }

.qty-label {
  margin-top: 3px; padding: 2px 9px;
  font-size: 11px; color: #6b7280; font-weight: 500;
}

.barcode-input {
  width: 100%; margin-top: 4px; border: 1px solid transparent; border-radius: 6px; padding: 4px 9px;
  font-size: 11px; color: #6b7280; background: #f9fafb; transition: border-color 0.15s, background 0.15s;
}
.barcode-input:hover { background: #f3f4f6; }
.barcode-input:focus { outline: none; border-color: #3b82f6; background: #fff; color: #1f2937; }

.note-row { display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.note-input {
  flex: 1; min-width: 0; border: 1px solid transparent; border-radius: 6px; padding: 4px 9px;
  font-size: 11px; color: #6b7280; background: #f9fafb; transition: border-color 0.15s, background 0.15s;
}
.note-input:hover { background: #f3f4f6; }
.note-input:focus { outline: none; border-color: #3b82f6; background: #fff; color: #1f2937; }
.fetch-note-btn { width: 20px; height: 20px; font-size: 11px; flex-shrink: 0; }

.filter-input {
  margin-left: auto; border: 1px solid #e5e7eb; border-radius: 6px; padding: 8px 12px;
  font-size: 13px; width: 220px; background: #f9fafb; transition: border-color 0.15s, background 0.15s;
}
.filter-input:hover { background: #f3f4f6; }
.filter-input:focus { outline: none; border-color: #3b82f6; background: #fff; }

.pager-bar { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }
.pager-info { font-size: 13px; color: #6b7280; }

.smart-paste {
  border: 1.5px dashed #93c5fd; border-radius: 8px; background: #f5f9ff;
  color: #3b82f6; font-size: 13px; font-weight: 500; text-align: center;
  padding: 14px; margin-bottom: 16px; cursor: pointer; outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.smart-paste:hover { background: #eff6ff; }
.smart-paste:focus { border-color: #2563eb; background: #eff6ff; box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.smart-paste.busy { opacity: 0.6; cursor: wait; pointer-events: none; }

.photo-cell {
  position: relative; width: 130px; height: 130px; border-radius: 8px;
  border: 1.5px dashed #d1d5db; background: #fafafa;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; outline: none; overflow: hidden;
  transition: border-color 0.15s, background 0.15s;
}
.photo-cell:hover { border-color: #93c5fd; background: #f5f9ff; }
.photo-cell:focus { border-color: #3b82f6; background: #eff6ff; box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }

.photo-placeholder { font-size: 12px; color: #9ca3af; text-align: center; line-height: 1.5; padding: 6px; }
.photo-placeholder span { color: #3b82f6; font-weight: 600; }

.photo-img { display: none; max-width: 100%; max-height: 100%; object-fit: contain; }
.photo-cell.has-image .photo-placeholder { display: none; }
.photo-cell.has-image .photo-img { display: block; }

.photo-toolbar {
  position: absolute; top: 4px; right: 4px; display: none; gap: 4px;
}
.photo-cell.has-image:hover .photo-toolbar,
.photo-cell.has-image:focus .photo-toolbar { display: flex; }

.icon-btn {
  border: none; background: rgba(255,255,255,0.92); border-radius: 5px;
  width: 24px; height: 24px; font-size: 13px; cursor: pointer; color: #374151;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.icon-btn:hover { background: #fff; color: #111; }

.delete-row-btn { background: transparent; box-shadow: none; color: #9ca3af; }
.delete-row-btn:hover { color: #ef4444; }

.flag-btn { background: transparent; box-shadow: none; color: #d1d5db; }
.flag-btn:hover { color: #f97316; }
.flag-btn.active { color: #f97316; }

tr.flagged-row { background: #fff7ed; }
tr.flagged-row:hover { background: #ffedd5; }

.flag-filter-label {
  display: flex; align-items: center; gap: 6px; font-size: 13px; color: #374151; cursor: pointer; white-space: nowrap;
}
.flag-filter-label input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

.hint { color: #6b7280; font-size: 14px; margin-top: 14px; text-align: center; }

.mod-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }

.mod-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.mod-filter-btn {
  border: 1.5px solid transparent; border-radius: 20px; padding: 4px 13px;
  font-size: 12px; font-weight: 600; cursor: pointer; background: #f3f4f6; color: #6b7280;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.mod-filter-btn:hover { background: #e5e7eb; color: #374151; }
.mod-filter-btn.active              { background: #e5e7eb; color: #111827; border-color: #d1d5db; }
.mod-filter-btn.bottled.active      { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.mod-filter-btn.draft.active        { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.mod-filter-btn.other.active        { background: #f3f4f6; color: #6b7280; border-color: #d1d5db; }

.mod-list {
  list-style: none; margin: 0; padding: 0;
  background: #fff; border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06); overflow: hidden;
}
.mod-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; font-size: 14px; color: #1a1a1a;
  border-bottom: 1px solid #f3f4f6;
}
.mod-list li:last-child { border-bottom: none; }
.mod-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mod-info-btn {
  flex-shrink: 0; border: 1px solid #e5e7eb; background: #f9fafb; color: #6b7280;
  border-radius: 6px; width: 26px; height: 26px; font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.mod-info-btn:hover { border-color: #3b82f6; background: #eff6ff; color: #2563eb; }

.mod-photo-cell {
  flex-shrink: 0; width: 52px; height: 52px; border-radius: 6px;
  border: 1px dashed #d1d5db; background: #f9fafb;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; outline: none; overflow: hidden; position: relative;
  transition: border-color 0.15s, background 0.15s;
}
.mod-photo-cell:focus { border-color: #3b82f6; background: #eff6ff; }
.mod-photo-cell.has-photo { border-style: solid; border-color: #d1fae5; background: #f0fdf4; }
.mod-photo-cell.uploading { border-color: #93c5fd; background: #eff6ff; }
.mod-photo-cell.uploading::after {
  content: ''; position: absolute; inset: 0;
  background: rgba(255,255,255,0.7) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='10' stroke='%233b82f6' stroke-width='3' fill='none' stroke-dasharray='31' stroke-dashoffset='10'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 12 12' to='360 12 12' dur='0.8s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E") center/24px no-repeat;
}
.mod-photo-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.mod-photo-hint { font-size: 20px; line-height: 1; color: #9ca3af; pointer-events: none; }

.mod-push-btn {
  flex-shrink: 0; border: 1px solid #e5e7eb; background: #f9fafb; color: #374151;
  border-radius: 6px; width: 30px; height: 30px; font-size: 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}
.mod-push-btn:hover:not(:disabled) { border-color: #3b82f6; background: #eff6ff; }
.mod-push-btn:disabled { opacity: 0.5; cursor: default; }

/* product info modal */
.modal-product { width: 480px; max-width: calc(100vw - 32px); }
.pi-image { display: block; width: 100%; max-height: 220px; object-fit: contain; border-radius: 8px; background: #f9fafb; margin-bottom: 14px; }
.pi-image.hidden { display: none; }
.pi-status {
  display: flex; align-items: center; gap: 8px; margin-bottom: 14px;
  font-size: 13px; font-weight: 600; padding: 8px 12px; border-radius: 8px;
}
.pi-status.found { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.pi-status.not-found { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.pi-status.loading { background: #f8fafc; color: #6b7280; border: 1px solid #e2e8f0; }
.pi-name { font-size: 17px; font-weight: 600; color: #111; margin-bottom: 14px; line-height: 1.35; }
.pi-props { display: flex; flex-direction: column; gap: 0; margin-bottom: 12px; border: 1px solid #f3f4f6; border-radius: 8px; overflow: hidden; }
.pi-prop-row {
  display: flex; align-items: stretch; border-top: 1px solid #f3f4f6; cursor: pointer;
  transition: background 0.12s;
}
.pi-prop-row:first-child { border-top: none; }
.pi-prop-row:hover { background: #f8fafc; }
.pi-prop-row.copied { background: #f0fdf4; }
.pi-prop-label { flex: 0 0 110px; padding: 9px 12px; font-size: 12px; font-weight: 500; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.03em; }
.pi-prop-value { flex: 1; padding: 9px 12px; font-size: 13px; color: #1f2937; }
.pi-prop-copy { flex: 0 0 36px; display: flex; align-items: center; justify-content: center; color: #d1d5db; font-size: 14px; }
.pi-prop-row:hover .pi-prop-copy { color: #6b7280; }
.pi-prop-row.copied .pi-prop-copy { color: #15803d; }
.pi-desc { font-size: 13px; color: #374151; line-height: 1.55; margin-bottom: 12px; }
.pi-cands { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.pi-cand {
  padding: 10px 12px; border: 1px solid #e5e7eb; border-radius: 8px; cursor: pointer;
  background: #fafafa; transition: border-color 0.15s, background 0.15s;
}
.pi-cand:hover { border-color: #3b82f6; background: #eff6ff; }
.pi-cand-name { font-size: 13px; color: #1f2937; font-weight: 500; }
.pi-cand-sub { font-size: 12px; color: #9ca3af; margin-top: 2px; }

.type-badge {
  display: inline-block; font-size: 11px; font-weight: 600; white-space: nowrap;
  padding: 2px 8px; border-radius: 4px; flex-shrink: 0;
}
.type-badge.bottled { background: #dbeafe; color: #1d4ed8; }
.type-badge.draft   { background: #d1fae5; color: #065f46; }
.type-badge.other   { background: #f3f4f6; color: #9ca3af; }
.hidden { display: none !important; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(17,24,39,0.55);
  display: flex; align-items: center; justify-content: center; z-index: 2000;
}
.modal {
  background: #fff; border-radius: 10px; padding: 22px 26px; width: 380px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.25);
}
.modal h2 { font-size: 16px; font-weight: 600; margin: 0 0 14px; color: #111; }

#cropCanvas {
  display: block; margin: 0 auto; border-radius: 8px; border: 1px solid #e5e7eb;
  cursor: grab; touch-action: none;
}
#cropCanvas:active { cursor: grabbing; }

.modal-controls { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.modal-row { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #374151; }
.modal-row span { display: flex; justify-content: space-between; }
.modal-row input[type="range"] { width: 100%; }

.modal-checkbox-row {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: #374151; cursor: pointer;
}
.modal-checkbox-row input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

.modal-hint { font-size: 12px; color: #9ca3af; margin-top: 10px; text-align: center; }

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

.modal-wide-btn { width: 100%; }

.partner-list {
  margin-top: 12px; max-height: 320px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
}
.partner-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 6px; background: #f9fafb; cursor: pointer;
  font-size: 13px; transition: background 0.15s;
}
.partner-row:hover { background: #eff6ff; }
.partner-name { color: #1f2937; }
.partner-pending { color: #6b7280; font-size: 12px; white-space: nowrap; }
.partner-loading { color: #9ca3af; font-size: 13px; text-align: center; padding: 12px 0; }

#toast {
  position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 1000;
}
.toast-item {
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 6px; font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2); opacity: 0; transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast-item.show { opacity: 1; transform: translateY(0); }
.toast-item.error { background: #991b1b; }

.share-link-row { display: flex; gap: 8px; margin-top: 10px; }
.share-link-input { flex: 1; padding: 7px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; background: #f9fafb; }
#shareSessionModal .modal { max-width: 480px; }
