/* === Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 13px;
  color: #323130;
  background: #faf9f8;
  overflow-x: hidden;
}

/* === Toast notification === */
.toast {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: 13px;
  color: #fff;
  transition: transform 0.25s ease;
}
.toast.hidden { display: none; }
.toast.success { background: #107c10; }
.toast.error   { background: #a4262c; }
.toast-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  margin-left: 12px;
}

/* === Offline banner === */
.offline-banner {
  background: #fff4ce;
  color: #835c00;
  text-align: center;
  padding: 8px;
  font-size: 12px;
}
.offline-banner.hidden { display: none; }

/* === Header === */
.header {
  background: #0078d4;
  color: #fff;
  padding: 14px 16px;
}
.header h1 { font-size: 16px; font-weight: 600; }

/* === Action bar === */
.action-bar { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }

/* === Current email section === */
.current-email-section { padding: 0 16px 12px; }
.section-label { font-size: 11px; font-weight: 600; color: #605e5c; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 4px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: #0078d4; color: #fff; width: 100%; }
.btn-primary:hover:not(:disabled) { background: #106ebe; }
.btn-secondary { background: #fff; color: #0078d4; border: 1px solid #0078d4; width: 100%; }
.btn-secondary:hover:not(:disabled) { background: #f3f9fd; }
.btn-confirm { background: #107c10; color: #fff; }
.btn-confirm:hover:not(:disabled) { background: #0b6a0b; }
.btn-route { background: #8764b8; color: #fff; }
.btn-route:hover:not(:disabled) { background: #6b4fa0; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-retry { background: #d83b01; color: #fff; margin-left: 8px; }
.btn-retry:hover:not(:disabled) { background: #b7300a; }

/* === Tabs === */
.tabs {
  display: flex;
  border-bottom: 1px solid #edebe9;
  padding: 0 16px;
}
.tab {
  background: none;
  border: none;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #605e5c;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active { color: #0078d4; border-bottom-color: #0078d4; }
.tab:hover { color: #0078d4; }

/* === Tab content === */
.tab-content { display: none; padding: 12px 16px; }
.tab-content.active { display: block; }

/* === Loading / empty === */
.loading, .empty-state {
  text-align: center;
  padding: 24px 0;
  color: #605e5c;
}

/* === Filter bar === */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.filter-bar label { font-weight: 600; }
.filter-bar select {
  padding: 5px 8px;
  border: 1px solid #c8c6c4;
  border-radius: 4px;
  font-size: 13px;
}

/* === Email list / cards === */
.email-list { display: flex; flex-direction: column; gap: 8px; }

.email-card {
  background: #fff;
  border: 1px solid #edebe9;
  border-radius: 6px;
  padding: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.email-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}
.email-subject {
  font-weight: 600;
  font-size: 13px;
  flex: 1;
  margin-right: 8px;
  word-break: break-word;
}
.email-sender {
  font-size: 12px;
  color: #605e5c;
  margin-bottom: 8px;
}
.email-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  font-size: 12px;
}
.confidence { color: #605e5c; }
.email-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.email-actions select {
  padding: 4px 6px;
  border: 1px solid #c8c6c4;
  border-radius: 4px;
  font-size: 12px;
}

/* === State badges === */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}
.badge-Pending-Review  { background: #0078d4; }
.badge-Confirmed       { background: #107c10; }
.badge-Overridden      { background: #d83b01; }
.badge-Routed          { background: #8764b8; }
.badge-Failed          { background: #a4262c; }
.badge-Uncategorized   { background: #a19f9d; }

/* === Bulk actions bar === */
.bulk-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #edebe9;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.email-card .card-checkbox { margin-right: 8px; }

/* === Config tab === */
.config-list { display: flex; flex-direction: column; gap: 6px; }
.config-rule {
  background: #fff;
  border: 1px solid #edebe9;
  border-radius: 6px;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}
.config-rule-info { flex: 1; }
.config-rule-info strong { font-size: 13px; }
.config-rule-info span { display: block; color: #605e5c; margin-top: 2px; }
.config-form { margin-top: 8px; }
.config-input {
  display: block;
  width: 100%;
  padding: 6px 8px;
  margin-bottom: 6px;
  border: 1px solid #c8c6c4;
  border-radius: 4px;
  font-size: 13px;
  box-sizing: border-box;
}
.config-form-actions { display: flex; gap: 8px; margin-top: 4px; }
.btn-danger { background: #a4262c; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #8b1f24; }

/* === Rule reorder arrows === */
.rule-actions { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.rule-actions button { padding: 2px 6px; font-size: 14px; cursor: pointer; background: #f3f2f1; border: 1px solid #c8c6c4; border-radius: 3px; line-height: 1; }
.rule-actions button:hover { background: #e1dfdd; }
.btn-edit { background: #0078d4; color: #fff; }
.btn-edit:hover:not(:disabled) { background: #106ebe; }
.annotation-tag { color: #0078d4; font-weight: 600; }
