* { box-sizing: border-box; }
body {
  font-family: -apple-system, system-ui, sans-serif;
  margin: 0;
  padding: 0 1rem 2rem;
  background: #f5f5f5;
  color: #222;
}
.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 1rem 0;
  border-bottom: 1px solid #ccc;
  margin-bottom: 1rem;
  position: sticky;
  top: 0;
  background: #f5f5f5;
  z-index: 5;
}
.tab-btn {
  padding: 0.5rem 1rem;
  border: 1px solid #ccc;
  background: #fff;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  font-size: 1rem;
}
.tab-btn.active { background: #2a6; color: #fff; border-color: #2a6; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; align-items: center; }
.filters input, .filters select { padding: 0.4rem; border: 1px solid #bbb; border-radius: 4px; }
.filters button { padding: 0.4rem 1rem; border: none; background: #2a6; color: #fff; border-radius: 4px; cursor: pointer; }

table.results { width: 100%; border-collapse: collapse; background: #fff; }
table.results th, table.results td { padding: 0.5rem; border-bottom: 1px solid #eee; text-align: left; font-size: 0.9rem; }
table.results tr:hover { background: #f0fff4; cursor: pointer; }
.meta { color: #666; margin-bottom: 0.5rem; font-size: 0.9rem; }
.flag-bad { color: #c33; font-weight: bold; }
.flag-ok { color: #2a6; }
.flag-warn { color: #d90; }

#pagination { margin-top: 1rem; display: flex; gap: 0.5rem; }
#pagination button { padding: 0.3rem 0.8rem; border: 1px solid #bbb; background: #fff; border-radius: 4px; cursor: pointer; }
#pagination button:disabled { opacity: 0.4; cursor: default; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: flex-start; justify-content: center; padding: 2rem 1rem; overflow-y: auto; z-index: 10; }
.modal.hidden { display: none; }
.modal-content { background: #fff; border-radius: 8px; padding: 1.5rem; max-width: 700px; width: 100%; min-width: 0; position: relative; box-sizing: border-box; }
.close-btn { position: absolute; top: 0.5rem; right: 0.75rem; border: none; background: none; font-size: 1.5rem; cursor: pointer; }

.receipt-image img { max-width: 100%; border-radius: 6px; margin-bottom: 1rem; }
.items-table-wrap { overflow-x: auto; max-width: 100%; border-radius: 6px; }
.items-table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; table-layout: fixed; }
.items-table th, .items-table td { padding: 0.35rem; border-bottom: 1px solid #eee; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; }
.items-table input, .items-table select { width: 100%; font-size: 0.85rem; padding: 0.2rem; box-sizing: border-box; }
.items-table th:nth-child(1), .items-table td:nth-child(1) { width: 20%; }
.items-table th:nth-child(2), .items-table td:nth-child(2) { width: 24%; }
.items-table th:nth-child(3), .items-table td:nth-child(3) { width: 10%; }
.items-table th:nth-child(4), .items-table td:nth-child(4) { width: 12%; }
.items-table th:nth-child(5), .items-table td:nth-child(5) { width: 12%; }
.items-table th:nth-child(6), .items-table td:nth-child(6) { width: 14%; }
.items-table .item-actions { white-space: nowrap; width: 88px; padding: 0.2rem; }
.items-table .icon-btn { padding: 0.2rem 0.35rem; font-size: 0.8rem; margin: 0 0.1rem 0.1rem 0; min-width: 0; }
.low-conf { background: #fff3e0; }

.overview { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.stat-card { background: #fff; border-radius: 8px; padding: 1rem; min-width: 140px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.stat-card .value { font-size: 1.5rem; font-weight: bold; }
.stat-card .label { color: #666; font-size: 0.85rem; }

.bar-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.25rem; }
.bar-label { width: 160px; font-size: 0.85rem; flex-shrink: 0; }
.bar-track { flex: 1; background: #eee; border-radius: 3px; height: 18px; position: relative; }
.bar-fill { background: #2a6; height: 100%; border-radius: 3px; }
.bar-value { font-size: 0.8rem; color: #444; width: 80px; text-align: right; }

.hint { color: #666; }

.sync-card { background: #fff; border-radius: 8px; padding: 1.25rem; margin-bottom: 1.5rem; box-shadow: 0 1px 3px rgba(0,0,0,0.1); max-width: 500px; }
.sync-status { margin-top: 0.75rem; font-size: 0.9rem; }
.sync-control-code { font-size: 2rem; font-weight: bold; text-align: center; background: #f0fff4; border: 2px solid #2a6; border-radius: 8px; padding: 0.75rem; margin: 0.5rem 0; letter-spacing: 0.1em; }
.sync-status.status-failed { color: #c33; }
.sync-status.status-done { color: #2a6; }
.save-btn { background: #2a6; color: #fff; border: none; padding: 0.3rem 0.8rem; border-radius: 4px; cursor: pointer; }
.editable-field { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.4rem; }
.editable-field label { width: 140px; font-size: 0.85rem; color: #555; }
