* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #fff;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 120px;
  padding-bottom: 40px;
}

.container {
  width: 100%;
  max-width: 700px;
  padding: 0 20px;
}
.purchases-view .container {
  max-width: 1400px;
  padding: 0 40px;
}


.header {
  text-align: center;
  margin-bottom: 40px;
}

.header h1 {
  font-size: 32px;
  font-weight: 400;
  color: #202124;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.subtitle {
  font-size: 14px;
  color: #5f6368;
  margin-top: 8px;
}

.nav-links {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  gap: 16px;
}

.nav-link {
  color: #1a73e8;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.nav-link:hover {
  background-color: #e8f0fe;
  text-decoration: none;
}

.search-container {
  display: flex;
  justify-content: center;
  margin-bottom: 40px;
}

.search-wrapper {
  display: flex;
  width: 100%;
  max-width: 600px;
  border: 1px solid #dfe1e5;
  border-radius: 24px;
  box-shadow: 0 2px 5px 1px rgba(64, 60, 67, 0.16);
  transition: all 0.2s ease;
  overflow: hidden;
  background: #fff;
  margin: 0;
  padding: 0;
}

.search-wrapper:hover {
  box-shadow: 0 2px 8px 1px rgba(64, 60, 67, 0.24);
}

.search-wrapper:focus-within {
  box-shadow: 0 2px 8px 1px rgba(64, 60, 67, 0.24);
  border-color: #4285f4;
}

input[type="text"] {
  flex: 1;
  height: 48px;
  padding: 0 20px;
  border: none;
  border-radius: 24px 0 0 24px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  background: transparent;
}

button {
  background-color: #ff9800;
  border: none;
  border-radius: 0 24px 24px 0;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  padding: 0 24px;
  height: 48px;
  min-width: 100px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
  font-weight: 500;
  white-space: nowrap;
}

button:hover {
  background-color: #fb8c00;
}

button:active {
  background-color: #f57c00;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background-color: #ff9800;
}

.result {
  margin-top: 40px;
  background: #fff;
  border: 1px solid #dfe1e5;
  border-radius: 8px;
  color: #202124;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.result-header {
  background: #f8f9fa;
  padding: 16px 20px;
  border-bottom: 1px solid #dfe1e5;
}

.result-header h2 {
  font-size: 18px;
  font-weight: 500;
  color: #202124;
  margin: 0;
}

.result-content {
  padding: 20px;
}

.result-item {
  display: flex;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid #f1f3f4;
}

.result-item:last-child {
  border-bottom: none;
}

.result-label {
  font-size: 14px;
  color: #5f6368;
  font-weight: 500;
  min-width: 100px;
  margin-right: 16px;
}

.result-value {
  font-size: 14px;
  color: #202124;
  flex: 1;
  word-break: break-word;
}

.result-value.category {
  font-weight: 500;
  color: #1a73e8;
  font-size: 15px;
}

.result-value.confidence {
  color: #34a853;
  font-weight: 500;
}

.error {
  margin-top: 24px;
  padding: 16px 20px;
  background: #fce8e6;
  border: 1px solid #f28b82;
  border-radius: 8px;
  color: #c5221f;
  font-size: 14px;
  line-height: 1.5;
}

.hidden {
  display: none;
}

/* Scheduler Section */
.scheduler-section {
  margin-top: 32px;
  margin-bottom: 32px;
  padding: 24px;
  background: #f8f9fa;
  border: 1px solid #dfe1e5;
  border-radius: 12px;
}

.scheduler-header {
  text-align: center;
  margin-bottom: 20px;
}

.scheduler-header h3 {
  font-size: 18px;
  font-weight: 500;
  color: #202124;
  margin-bottom: 4px;
}

.scheduler-subtitle {
  font-size: 13px;
  color: #5f6368;
  margin: 0;
}

.scheduler-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.scheduler-btn {
  background-color: #509ee3;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.scheduler-btn:hover:not(:disabled) {
  background-color: #4c8fd8;
  transform: translateY(-1px);
}

.scheduler-btn:active:not(:disabled) {
  transform: translateY(0);
}

.scheduler-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.scheduler-btn.start {
  background-color: #34a853;
}

.scheduler-btn.start:hover:not(:disabled) {
  background-color: #2d9148;
}

.scheduler-btn.stop {
  background-color: #ea4335;
}

.scheduler-btn.stop:hover:not(:disabled) {
  background-color: #d33b2c;
}

.scheduler-btn.trigger {
  background-color: #fbbc04;
  color: #202124;
}

.scheduler-btn.trigger:hover:not(:disabled) {
  background-color: #f9ab00;
}

.scheduler-stats {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 16px;
  background: white;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}

.scheduler-stats .stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
}

.scheduler-stats .stat-label {
  font-size: 11px;
  color: #5f6368;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.scheduler-stats .stat-value {
  font-size: 18px;
  color: #202124;
  font-weight: 600;
}

.scheduler-stats .stat-value.success {
  color: #34a853;
}

.scheduler-stats .stat-value.failure {
  color: #ea4335;
}

.scheduler-btn.ghost {
  margin: 16px auto 0;
  display: flex;
  background: transparent;
  color: #509ee3;
  border: 1px dashed #509ee3;
  padding: 8px 16px;
}

.scheduler-btn.ghost:hover:not(:disabled) {
  background: #e8f0fe;
}

.summary-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #dfe1e5;
}

.stat.success {
  background: #e6f4ea;
  border-color: #34a853;
}

.stat.failure {
  background: #fce8e6;
  border-color: #ea4335;
}

.stat-label {
  font-size: 14px;
  color: #5f6368;
  font-weight: 500;
}

.stat-value {
  font-size: 18px;
  color: #202124;
  font-weight: 600;
}

.stat.success .stat-value {
  color: #137333;
}

.stat.failure .stat-value {
  color: #c5221f;
}

.table-container {
  overflow-x: auto;
  margin-top: 24px;
  background: #fff;
  border: 1px solid #efefef;
  border-radius: 8px;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #efefef;
  background: #f9fafb;
}

.table-title {
  font-size: 14px;
  font-weight: 600;
  color: #4c5773;
  margin: 0;
}

.table-refresh-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  color: #4c5773;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  height: 28px;
}

.table-refresh-btn:hover:not(:disabled) {
  background: #f0f0f0;
  border-color: #509ee3;
  color: #509ee3;
}

.table-refresh-btn:active:not(:disabled) {
  background: #e8f0fe;
}

.table-refresh-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.table-refresh-btn svg {
  transition: transform 0.6s ease;
}

.table-refresh-btn:active:not(:disabled) svg {
  transform: rotate(360deg);
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.results-table thead {
  background: transparent;
}

.results-table th {
  padding: 8px 12px;
  text-align: left;
  font-weight: 700;
  color: #949aab;
  font-size: 11px;
  border-bottom: 1px solid #efefef;
  white-space: nowrap;
}

.results-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f9fbfc;
  color: #4c5773;
  vertical-align: middle;
  font-size: 12px;
}

.results-table tbody tr:last-child td {
  border-bottom: none;
}

.results-table tbody tr:hover {
  background: #f9fbfc;
}

.results-table tbody tr {
  position: relative;
}

.status-cell {
  text-align: left;
  width: 60px;
  position: relative;
}

.status-badge {
  display: inline-block;
  font-size: 14px;
}

.status-badge.success {
  color: #88bf4d;
}

.status-badge.failure {
  color: #ed6e6e;
}

.product-name-cell {
  max-width: 400px;
  color: #4c5773;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: default;
  position: relative;
}

.product-name-cell[title]:hover {
  background: #f9fafb;
}

.product-name-cell[title]:hover::after {
  content: attr(title);
  position: absolute;
  left: 0;
  top: calc(100% + 2px);
  background: #2e3b52;
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  white-space: normal;
  word-break: break-word;
  max-width: 400px;
  min-width: 200px;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  line-height: 1.4;
}

.category-cell {
  color: #509ee3;
  font-weight: 400;
  white-space: nowrap;
}

.confidence-cell {
  color: #4c5773;
  font-weight: 400;
  width: 90px;
  text-align: center;
}

.reasoning-cell {
  max-width: 500px;
  color: #4c5773;
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: default;
  position: relative;
}

.reasoning-cell[title]:hover {
  background: #f9fafb;
}

.reasoning-cell[title]:hover::after {
  content: attr(title);
  position: absolute;
  left: 0;
  top: calc(100% + 2px);
  background: #2e3b52;
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  white-space: normal;
  word-break: break-word;
  max-width: 500px;
  min-width: 200px;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  line-height: 1.4;
}

/* Sortable columns */
.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
}

.sortable:hover {
  background: #f0f0f0;
}

.sort-icon {
  font-size: 10px;
  color: #949aab;
  margin-left: 4px;
  opacity: 0.5;
}

.sortable.asc .sort-icon::before {
  content: "↑";
  opacity: 1;
  color: #509ee3;
}

.sortable.desc .sort-icon::before {
  content: "↓";
  opacity: 1;
  color: #509ee3;
}

.sortable.asc .sort-icon,
.sortable.desc .sort-icon {
  opacity: 1;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  border-top: 1px solid #efefef;
  background: #f9fafb;
  flex-wrap: wrap;
}

.page-btn {
  background: #fff;
  color: #4c5773;
  border: 1px solid #efefef;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  height: 32px;
  min-width: 32px;
}

.page-btn:hover:not(:disabled) {
  background: #509ee3;
  color: white;
  border-color: #509ee3;
}

.page-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.page-numbers {
  display: flex;
  gap: 4px;
  align-items: center;
}

.page-number-btn {
  background: #fff;
  color: #4c5773;
  border: 1px solid #efefef;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  height: 32px;
  min-width: 32px;
}

.page-number-btn:hover {
  background: #f0f0f0;
  border-color: #509ee3;
}

.page-number-btn.active {
  background: #509ee3;
  color: white;
  border-color: #509ee3;
}

.page-ellipsis {
  color: #949aab;
  padding: 0 4px;
  font-size: 12px;
}

.item-count {
  font-size: 11px;
  color: #949aab;
  font-weight: 400;
  margin-left: 8px;
}

/* Action buttons */
.action-cell {
  width: 140px;
  white-space: nowrap;
}

.action-btn {
  background: #509ee3;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin: 0 2px;
}

.action-btn:hover:not(:disabled) {
  background: #4c8fd8;
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.action-btn.secondary {
  background: #f0f0f0;
  color: #4c5773;
  border: 1px solid #e0e0e0;
}

.action-btn.secondary:hover:not(:disabled) {
  background: #e0e0e0;
}

.action-btn.processing {
  background: #949aab;
}

/* Token overlay */
.token-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.token-overlay.hidden {
  display: none;
}

.token-modal {
  background: #fff;
  padding: 32px;
  border-radius: 12px;
  width: 90%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.token-modal h2 {
  margin-bottom: 8px;
  font-size: 20px;
  color: #202124;
}

.token-modal p {
  font-size: 14px;
  color: #5f6368;
  margin-bottom: 20px;
}

#adminTokenForm {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#adminTokenForm input {
  padding: 10px 12px;
  border: 1px solid #dfe1e5;
  border-radius: 6px;
  font-size: 14px;
}

.token-overlay-error {
  margin-top: 8px;
  font-size: 12px;
  color: #ea4335;
}

