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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  color: #333;
  padding-top: 32px;
}

.env-banner {
  position: fixed; top: 0; left: 0; right: 0;
  text-align: center; font-weight: bold; font-size: 12px;
  padding: 4px; z-index: 1000; text-transform: uppercase;
}
.env-prod { background: #e53e3e; color: white; }
.env-test { background: #ecc94b; color: #333; }
.env-dev { background: #4299e1; color: white; }

nav {
  background: #2d3748; padding: 0 1rem;
  display: flex; align-items: center; gap: 0;
}
nav a {
  color: #e2e8f0; text-decoration: none;
  padding: 0.75rem 1rem; display: inline-block;
}
nav a:hover { background: #4a5568; }
.nav-right { margin-left: auto; color: #a0aec0; font-size: 0.875rem; padding: 0.75rem 0; }
.nav-right a { font-size: 0.875rem; }

main { max-width: 1100px; margin: 1.5rem auto; padding: 0 1rem; }

h1 { margin-bottom: 0.75rem; }
h2 { margin: 1rem 0 0.5rem; }
h3 { margin: 0.5rem 0 0.25rem; }

.stats-grid {
  display: grid; grid-template-columns: repeat(6, 1fr);
  gap: 0.625rem; margin-bottom: 1rem;
}
.stats-grid-4 { grid-template-columns: repeat(4, 1fr); }
.stat-card {
  background: white; border-radius: 6px; padding: 0.75rem;
  text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.stat-link { text-decoration: none; color: inherit; transition: box-shadow 0.2s; display: block; }
.stat-link:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.stat-value { font-size: 1.5rem; font-weight: bold; color: #2d3748; word-break: break-word; }
.stat-label { font-size: 0.75rem; color: #718096; margin-top: 0.125rem; }

table { width: 100%; border-collapse: collapse; background: white; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
th, td { padding: 0.625rem 0.75rem; text-align: left; border-bottom: 1px solid #e2e8f0; }
th { background: #f7fafc; font-weight: 600; font-size: 0.875rem; color: #4a5568; }
td { font-size: 0.875rem; }
tr:last-child td { border-bottom: none; }

.detail-table th { width: 150px; background: #f7fafc; }

.badge { padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; }
.badge-answered { background: #c6f6d5; color: #22543d; }
.badge-escalated { background: #fefcbf; color: #744210; }
.badge-skipped { background: #e2e8f0; color: #4a5568; }
.badge-error { background: #fed7d7; color: #9b2c2c; }

.content-block {
  background: white; border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 1rem; white-space: pre-wrap; word-wrap: break-word;
  font-size: 0.875rem; line-height: 1.5; max-height: 400px; overflow-y: auto;
}

.filter-bar { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.filter-bar a {
  padding: 0.375rem 0.75rem; border-radius: 4px; text-decoration: none;
  color: #4a5568; background: white; border: 1px solid #e2e8f0; font-size: 0.875rem;
}
.filter-bar a.active { background: #2d3748; color: white; border-color: #2d3748; }

.pagination { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; justify-content: center; }
.pagination a { color: #4299e1; text-decoration: none; }

.login-box {
  max-width: 360px; margin: 4rem auto; background: white;
  padding: 2rem; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.login-box h1 { text-align: center; margin-bottom: 1.5rem; }
label { display: block; margin-bottom: 1rem; font-size: 0.875rem; font-weight: 600; }
input[type="email"], input[type="password"], input[type="text"], input[type="number"], select {
  width: 100%; padding: 0.5rem; border: 1px solid #e2e8f0; border-radius: 4px;
  font-size: 0.875rem; margin-top: 0.25rem;
}
textarea {
  width: 100%; padding: 0.5rem; border: 1px solid #e2e8f0; border-radius: 4px;
  font-size: 0.875rem; font-family: monospace; resize: vertical;
}

button {
  background: #4299e1; color: white; border: none; padding: 0.5rem 1rem;
  border-radius: 4px; cursor: pointer; font-size: 0.875rem;
  transition: background 0.2s, opacity 0.2s;
}
button:hover { background: #3182ce; }
button.btn-loading {
  background: #a0aec0; cursor: not-allowed; opacity: 0.8;
  pointer-events: none;
}
.btn-danger { background: #e53e3e; }
.btn-danger:hover { background: #c53030; }
.btn-success { background: #38a169; }
.btn-success:hover { background: #2f855a; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.75rem; }

.error { color: #e53e3e; margin-bottom: 1rem; }
.success { color: #38a169; margin-bottom: 1rem; }

.config-group { background: white; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); overflow: hidden; margin-bottom: 1.5rem; }
.config-form { padding: 1rem 1.25rem; border-bottom: 1px solid #e2e8f0; }
.config-form:last-child { border-bottom: none; }
.config-header { margin-bottom: 0.5rem; }
.config-header h3 { margin: 0; font-size: 0.95rem; }
.config-description { color: #718096; font-size: 0.8rem; }
.config-input { width: 100%; padding: 0.5rem; border: 1px solid #e2e8f0; border-radius: 4px; font-size: 0.875rem; }
.form-actions { display: flex; align-items: center; gap: 1rem; margin-top: 0.5rem; }

.inline-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; }

.poller-controls { background: white; padding: 1rem; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

.toggle { display: flex; align-items: center; gap: 0.75rem; cursor: pointer; user-select: none; }
.toggle input[type="checkbox"] { display: none; }
.toggle-slider {
  width: 44px; height: 24px; background: #cbd5e0; border-radius: 12px;
  position: relative; transition: background 0.2s;
}
.toggle-slider::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; background: white; border-radius: 50%;
  transition: transform 0.2s;
}
.toggle input:checked + .toggle-slider { background: #38a169; }
.toggle input:checked + .toggle-slider::after { transform: translateX(20px); }
.toggle-label { font-size: 0.875rem; color: #4a5568; }

.sparkline-row { display: flex; gap: 2rem; justify-content: center; flex-wrap: wrap; }
.sparkline-chart { text-align: center; }
.sparkline-label { font-size: 0.75rem; color: #718096; margin-bottom: 0.25rem; }
.sparkline-chart svg { display: block; }

.rating-buttons { display: flex; gap: 0.5rem; }
.btn-rate {
  font-size: 1.25rem; padding: 0.25rem 0.75rem; background: #edf2f7; border: 2px solid transparent;
  border-radius: 6px; cursor: pointer; opacity: 0.5; transition: opacity 0.2s, border-color 0.2s;
}
.btn-rate:hover { opacity: 0.8; }
.btn-rate.active { opacity: 1; border-color: #4a5568; }

.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.modal-content {
  background: white; border-radius: 8px; padding: 1.5rem; max-width: 700px; width: 90%;
  max-height: 80vh; overflow-y: auto; box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.tool-use-info { background: #f7fafc; border: 1px solid #e2e8f0; border-radius: 6px; padding: 0.75rem 1rem; margin-bottom: 0.75rem; font-size: 0.85rem; }
.tool-use-info ul { margin: 0.25rem 0 0 1.25rem; padding: 0; }
.tool-use-info li { margin: 0.15rem 0; word-break: break-all; }
