body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  margin: 0;
  background: #f4f4f4;
  color: #333;
}

header {
  background: #222;
  color: white;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  margin: 0;
  font-size: 1.3em;
}

#logoutBtn {
  background: #555;
  color: white;
  border: none;
  padding: 6px 14px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.85em;
}

#logoutBtn:hover {
  background: #777;
}

nav {
  background: #333;
  padding: 10px 20px;
  display: flex;
  gap: 10px;
}

nav button {
  background: #555;
  color: white;
  border: none;
  padding: 10px 15px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.9em;
}

nav button:hover {
  background: #777;
}

main {
  padding: 20px;
}

#output {
  background: white;
  padding: 20px;
  border-radius: 6px;
  box-shadow: 0 0 5px rgba(0,0,0,0.1);
  overflow-x: auto;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
}

th {
  background: #f0f0f0;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid #ddd;
  font-weight: 600;
}

td {
  padding: 8px 12px;
  border-bottom: 1px solid #eee;
}

tr:hover {
  background: #f9f9f9;
}

.mono {
  font-family: "SF Mono", Consolas, monospace;
  font-size: 0.85em;
}

/* Badges */
.badge {
  display: inline-block;
  color: white;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.8em;
  font-weight: 600;
  text-transform: uppercase;
}

/* Action buttons */
.actions {
  white-space: nowrap;
}

.btn-view,
.btn-delete,
.btn-back {
  border: none;
  padding: 5px 12px;
  cursor: pointer;
  border-radius: 3px;
  font-size: 0.85em;
  margin-right: 4px;
}

.btn-view {
  background: #337ab7;
  color: white;
}

.btn-view:hover {
  background: #286090;
}

.btn-delete {
  background: #d9534f;
  color: white;
}

.btn-delete:hover {
  background: #c9302c;
}

.btn-back {
  background: #777;
  color: white;
}

.btn-back:hover {
  background: #555;
}

/* Detail card */
.detail-card h2 {
  margin: 0 0 15px 0;
  font-size: 1.1em;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.detail-table td.label {
  font-weight: 600;
  width: 140px;
  color: #555;
}

pre {
  background: #f5f5f5;
  padding: 12px;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 0.85em;
  line-height: 1.4;
}

/* Error */
.error {
  color: #d9534f;
  font-weight: 600;
}

/* Login overlay */
#loginOverlay {
  display: flex;
  justify-content: center;
  align-items: center;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #f4f4f4;
  z-index: 1000;
}

#loginBox {
  background: white;
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 2px 20px rgba(0,0,0,0.15);
  text-align: center;
  min-width: 320px;
}

#loginBox h1 {
  margin: 0 0 10px 0;
  font-size: 1.4em;
}

#loginBox p {
  color: #666;
  margin-bottom: 20px;
}

#tokenInput {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1em;
  box-sizing: border-box;
  margin-bottom: 15px;
}

#loginBtn {
  width: 100%;
  background: #337ab7;
  color: white;
  border: none;
  padding: 10px;
  border-radius: 4px;
  font-size: 1em;
  cursor: pointer;
}

#loginBtn:hover {
  background: #286090;
}

#loginError {
  color: #d9534f;
  margin-top: 10px;
  font-size: 0.9em;
}

.error-banner {
  display: none;
  background: #d9534f;
  color: white;
  padding: 10px;
  text-align: center;
  font-weight: 600;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2000;
}

.loading {
  color: #777;
  font-style: italic;
}

.btn-rerun {
  background: #f0ad4e;
  color: white;
  border: none;
  padding: 5px 12px;
  cursor: pointer;
  border-radius: 3px;
  font-size: 0.85em;
  margin-right: 4px;
}

.btn-rerun:hover {
  background: #ec971f;
}

.btn-download {
  background: #337ab7;
  color: white;
  border: none;
  padding: 5px 12px;
  cursor: pointer;
  border-radius: 3px;
  font-size: 0.85em;
  margin-right: 4px;
}

.btn-download:hover {
  background: #286090;
}

.btn-delete-r2 {
  background: #d9534f;
  color: white;
  border: none;
  padding: 5px 12px;
  cursor: pointer;
  border-radius: 3px;
  font-size: 0.85em;
}

.btn-delete-r2:hover {
  background: #c9302c;
}

/* Stat cards */
.stat-cards {
  display: flex;
  gap: 15px;
  margin-bottom: 25px;
  flex-wrap: wrap;
}

.stat-card {
  background: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 15px 20px;
  text-align: center;
  flex: 1;
  min-width: 120px;
}

.stat-card .stat-value {
  font-size: 1.8em;
  font-weight: 700;
  color: #333;
}

.stat-card .stat-label {
  font-size: 0.85em;
  color: #777;
  margin-top: 4px;
}

.stat-card.stat-ok .stat-value { color: #5cb85c; }
.stat-card.stat-fail .stat-value { color: #d9534f; }
.stat-card.stat-cost .stat-value { color: #f0ad4e; }

/* Charts */
.chart-container {
  background: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 20px;
  margin-bottom: 25px;
}

.chart-container h3 {
  margin: 0 0 15px 0;
}

.filters {
  background: #eee;
  padding: 10px 20px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.filters select,
.filters input {
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9em;
}

.filters input {
  min-width: 200px;
}

.btn-clear {
  background: #777;
  color: white;
  border: none;
  padding: 6px 12px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.85em;
}

.btn-clear:hover {
  background: #555;
}
/* Audio player bar */
.audio-player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #222;
  color: white;
  padding: 10px 20px;
  z-index: 3000;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
}

.audio-player-inner {
  display: flex;
  align-items: center;
  gap: 15px;
}

.audio-player-title {
  font-size: 0.85em;
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #aaa;
}

.btn-close-player {
  background: none;
  border: none;
  color: #aaa;
  font-size: 1.2em;
  cursor: pointer;
  padding: 5px;
}

.btn-close-player:hover {
  color: white;
}

/* Audio preview on job detail */
.audio-preview {
  margin: 15px 0;
  padding: 15px;
  background: #f5f5f5;
  border-radius: 6px;
}

.audio-preview h3 {
  margin: 0 0 10px 0;
}

/* Play button */
.btn-play {
  background: #5cb85c;
  color: white;
  border: none;
  padding: 5px 12px;
  cursor: pointer;
  border-radius: 3px;
  font-size: 0.85em;
  margin-right: 4px;
}

.btn-play:hover {
  background: #449d44;
}
.alert-banner {
  padding: 12px 20px;
  border-radius: 4px;
  margin-bottom: 15px;
  font-weight: 600;
}

.alert-warn {
  background: #fcf8e3;
  color: #8a6d3b;
  border: 1px solid #faebcc;
}
.filter-sep {
  color: #aaa;
  margin: 0 5px;
}

.btn-bulk {
  background: #555;
  color: white;
  border: none;
  padding: 6px 12px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.85em;
}

.btn-bulk:hover {
  background: #777;
}

.btn-bulk-rerun {
  background: #f0ad4e;
}

.btn-bulk-rerun:hover {
  background: #ec971f;
}

.btn-bulk-delete {
  background: #d9534f;
}

.btn-bulk-delete:hover {
  background: #c9302c;
}

.job-checkbox {
  cursor: pointer;
}
.chart-container {
  background: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 20px;
  margin-bottom: 25px;
}

.chart-container h3 {
  margin: 0 0 15px 0;
}
/* User management */
.user-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 20px;
}

.user-info {
  flex: 1;
}

.user-info h2 {
  margin: 0 0 5px 0;
}

.user-info .user-email {
  color: #777;
  font-size: 0.9em;
}

.user-info .user-id {
  font-family: "SF Mono", Consolas, monospace;
  font-size: 0.8em;
  color: #999;
  margin-top: 4px;
}

.credits-section {
  background: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 15px 20px;
  min-width: 250px;
}

.credits-section h3 {
  margin: 0 0 10px 0;
  font-size: 1em;
}

.credits-balance {
  font-size: 2em;
  font-weight: 700;
  color: #5cb85c;
  margin-bottom: 10px;
}

.add-credits-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.add-credits-form input {
  width: 80px;
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9em;
}

.add-credits-form select {
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9em;
}

.add-credits-form button {
  background: #5cb85c;
  color: white;
  border: none;
  padding: 6px 14px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.85em;
}

.add-credits-form button:hover {
  background: #449d44;
}

.user-jobs-section {
  margin-top: 25px;
}

.user-jobs-section h3 {
  margin: 0 0 15px 0;
}

.plan-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.8em;
  font-weight: 600;
  text-transform: uppercase;
  background: #5bc0de;
  color: white;
}

.plan-badge.pro {
  background: #f0ad4e;
}

.plan-badge.studio {
  background: #9b59b6;
}
