/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 13px; color: #222; background: #f0f0f0; overflow: hidden; }
body { display: flex; flex-direction: column; }

/* === Menu Entry (shared for dropdowns) === */
.menu-entry { padding: 5px 30px 5px 24px; cursor: pointer; position: relative; white-space: nowrap; font-size: 12px; }
.menu-entry:hover { background: #3daee9; color: #fff; }
.menu-entry.disabled { color: #999; pointer-events: none; }
.menu-separator { height: 1px; background: #ddd; margin: 3px 0; }
.menu-check::before { content: ''; display: inline-block; width: 14px; margin-left: -18px; margin-right: 4px; }
.menu-check.checked::before { content: '\2713'; }

/* === Toolbar Dropdown (Filters button) === */
.tb-dropdown-wrap { position: relative; }
.tb-dropdown { display: none; position: absolute; top: 100%; left: 0; background: #fff; border: 1px solid #bbb; box-shadow: 2px 4px 10px rgba(0,0,0,.18); min-width: 280px; z-index: 1000; margin-top: 2px; }
.tb-dropdown-wrap.open .tb-dropdown { display: block; }

/* === Toolbar === */
#toolbar { display: flex; align-items: center; gap: 4px; padding: 3px 6px; background: #f0f0f0; border-bottom: 1px solid #ccc; flex-shrink: 0; flex-wrap: wrap; }
.tb-btn { background: #3daee9; color: #fff; border: none; padding: 4px 10px; border-radius: 3px; cursor: pointer; font-size: 12px; white-space: nowrap; }
.tb-btn:hover { background: #2a9fd6; }
.tb-btn:active { background: #1e7bb8; }
.tb-btn:disabled, .tb-btn[disabled] { background: #ccc; color: #666; cursor: default; }
.tb-sep { width: 1px; height: 20px; background: #ccc; margin: 0 4px; flex-shrink: 0; }
.tb-label { font-size: 12px; margin-right: 2px; white-space: nowrap; }
.tb-input { border: 1px solid #ccc; border-radius: 3px; padding: 3px 6px; font-size: 12px; width: 160px; }
.tb-input-small { border: 1px solid #ccc; border-radius: 3px; padding: 3px 4px; font-size: 12px; width: 60px; text-align: right; }

/* === Table === */
#table-container {
  flex: 1; overflow: auto; background: #fff; position: relative;
  font-size: var(--viewer-table-font-size, 12px);
}
#empty-state { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: #999; font-size: 1.25em; text-align: center; pointer-events: none; }
#results-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
#results-table thead { position: sticky; top: 0; z-index: 10; }
#results-table th { background: #e8e8e8; border: 1px solid #d0d0d0; padding: 5px 8px; text-align: left; font-weight: 600; font-size: 1em; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: none; resize: horizontal; }
#results-table th:hover { background: #ddd; }
#results-table th.sort-asc::after { content: ' \25B2'; font-size: 10px; }
#results-table th.sort-desc::after { content: ' \25BC'; font-size: 10px; }
#results-table td { border: 1px solid #e0e0e0; padding: 4px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1em; }
#results-table th.col-hidden, #results-table td.col-hidden { display: none !important; }
#results-table tbody tr:nth-child(even) { background: #f8f8f8; }
#results-table tbody tr:nth-child(odd) { background: #fff; }
#results-table tbody tr:hover { background: #e8f4fc; }
#results-table tbody tr.selected { background: #3daee9; color: #fff; }
#results-table tbody tr.selected td { color: #fff; }

/* Column default widths (data-col so visibility toggles do not break nth-child rules) */
#results-table th[data-col="row"], #results-table td[data-col="row"] { width: 40px; text-align: center; }
#results-table th[data-col="quantity"], #results-table td[data-col="quantity"] { width: 80px; }
#results-table th[data-col="sku"], #results-table td[data-col="sku"] { width: 20ch; }
#results-table th[data-col="description"], #results-table td[data-col="description"] { width: 220px; }
#results-table th[data-col="type"], #results-table td[data-col="type"] { width: 100px; }
#results-table th[data-col="stkso"], #results-table td[data-col="stkso"] { width: 60px; text-align: center; }
#results-table th[data-col="confidence"], #results-table td[data-col="confidence"] { width: 100px; }
#results-table th[data-col="text"], #results-table td[data-col="text"] { width: 220px; }
#results-table th[data-col="original"], #results-table td[data-col="original"] { width: 220px; }

/* Row number column */
.row-num-col, .row-num-cell { color: #888; font-size: 0.92em; }
.row-num-col { cursor: default; }

/* Override indicators */
tr.has-override { background: #fffde0 !important; }
tr.has-override td { font-weight: bold; }
td.override-cell { background: #fffde0; font-weight: bold; }

/* No-match description */
td.no-match-desc { color: #c00; font-weight: bold; }

/* Deleted items */
tr.deleted td { text-decoration: line-through; color: #999; }
tr.deleted td.sku-cell { text-decoration: line-through; }

/* SKU cell styles */
td.sku-cell.multi-match { color: #0066cc; cursor: pointer; font-weight: bold; }
td.sku-cell.no-match { color: #999; }

/* === Context Menu === */
.context-menu { position: fixed; background: #fff; border: 1px solid #bbb; box-shadow: 2px 4px 10px rgba(0,0,0,.18); z-index: 2000; min-width: 140px; }
.ctx-entry { padding: 6px 20px; cursor: pointer; font-size: 13px; }
.ctx-entry:hover { background: #3daee9; color: #fff; }

/* === Modal / Dialog === */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,.35); z-index: 3000; display: flex; align-items: center; justify-content: center; }
.modal { background: #f0f0f0; border: 1px solid #999; border-radius: 6px; box-shadow: 0 8px 30px rgba(0,0,0,.25); width: 540px; max-height: 85vh; display: flex; flex-direction: column; }
.modal-header { padding: 10px 16px; font-size: 14px; font-weight: 600; border-bottom: 1px solid #ccc; background: #e8e8e8; border-radius: 6px 6px 0 0; }
.modal-body { padding: 12px 16px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 8px 16px; border-top: 1px solid #ccc; display: flex; align-items: center; justify-content: space-between; }
.modal-footer-right { display: flex; gap: 6px; margin-left: auto; }

fieldset { border: 1px solid #ccc; border-radius: 4px; padding: 8px 12px; margin-bottom: 10px; }
legend { font-size: 12px; font-weight: 600; padding: 0 4px; }
.form-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.form-row label { font-size: 12px; min-width: 70px; flex-shrink: 0; }
.form-row input[type="text"], .form-row input[type="number"] { flex: 1; border: 1px solid #ccc; border-radius: 3px; padding: 4px 6px; font-size: 12px; }

.btn { background: #e0e0e0; color: #333; border: 1px solid #bbb; padding: 5px 14px; border-radius: 3px; cursor: pointer; font-size: 12px; white-space: nowrap; }
.btn:hover { background: #d0d0d0; }
.btn-primary { background: #3daee9; color: #fff; border-color: #2a9fd6; }
.btn-primary:hover { background: #2a9fd6; }
.btn-danger { background: #e74c3c; color: #fff; border-color: #c0392b; }
.btn-danger:hover { background: #c0392b; }

/* Match list (in dialogs) */
.match-list-container { max-height: 220px; overflow-y: auto; border: 1px solid #ccc; border-radius: 3px; background: #fff; }
.match-list { }
.match-item { padding: 6px 10px; cursor: pointer; font-size: 12px; border-bottom: 1px solid #eee; display: flex; align-items: center; }
.match-item:hover { background: #e8f4fc; }
.match-item.selected { background: #3daee9; color: #fff; }
.match-item .conf-symbol { width: 20px; flex-shrink: 0; text-align: center; }
.match-item .match-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Search results - multi-select */
.match-item input[type="checkbox"] { margin-right: 8px; flex-shrink: 0; }

/* Process Document */
.db-list-select { width: 100%; border: 1px solid #ccc; border-radius: 3px; font-size: 12px; margin-top: 6px; }
.pd-status { margin-top: 10px; }
.pd-status-text { font-size: 12px; margin-bottom: 4px; }
.progress-bar { height: 16px; background: #e0e0e0; border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: #3daee9; width: 0%; transition: width 0.3s; }
.progress-bar-fill.indeterminate { width: 100%; animation: indeterminate 1.5s infinite linear; background: linear-gradient(90deg, #3daee9 25%, #6cc4f0 50%, #3daee9 75%); background-size: 200% 100%; }
.progress-bar-fill.activity { animation: indeterminate 1.5s infinite linear; background: linear-gradient(90deg, #3daee9 25%, #6cc4f0 50%, #3daee9 75%); background-size: 200% 100%; }
@keyframes indeterminate { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* === Sessions Dialog === */
.session-item { padding: 9px 16px; cursor: pointer; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.session-item:hover { background: #e8f4fc; }
.session-item.selected { background: #3daee9; color: #fff; }
.session-item-name { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-item-meta { font-size: 11px; color: #888; white-space: nowrap; flex-shrink: 0; }
.session-item.selected .session-item-meta { color: #d8effc; }

/* === Status Bar === */
#statusbar { height: 24px; line-height: 24px; padding: 0 10px; background: #e8e8e8; border-top: 1px solid #ccc; font-size: 12px; color: #555; flex-shrink: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
