* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0f172a;
  color: #e2e8f0;
}

header {
  padding: 16px 24px;
  border-bottom: 1px solid #1e293b;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

header h1 { margin: 0; font-size: 18px; }
.subtitle { color: #64748b; font-size: 13px; }

nav#tabs {
  display: flex;
  gap: 4px;
  padding: 8px 24px;
  border-bottom: 1px solid #1e293b;
}

.tab {
  background: none;
  border: none;
  color: #94a3b8;
  padding: 8px 16px;
  cursor: pointer;
  border-radius: 6px;
  font-size: 14px;
  text-decoration: none;
  display: inline-block;
}

.tab.active { background: #1e293b; color: #f1f5f9; }
.tab:hover { color: #f1f5f9; }

main { padding: 24px; max-width: 1100px; margin: 0 auto; }

.back-link {
  display: inline-block;
  color: #60a5fa;
  text-decoration: none;
  font-size: 13px;
  margin-bottom: 16px;
}

.back-link:hover { text-decoration: underline; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

h2 { margin: 0; font-size: 16px; color: #f1f5f9; }

button {
  background: #2563eb;
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

button:disabled { opacity: 0.7; cursor: not-allowed; }

.btn-spinner {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 7px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  vertical-align: -1px;
  animation: btn-spin 0.6s linear infinite;
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

button:hover { background: #1d4ed8; }
button.secondary { background: #334155; }
button.secondary:hover { background: #475569; }
button.danger { background: #991b1b; }
button.danger:hover { background: #b91c1c; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #1e293b;
}

th { color: #94a3b8; font-weight: 600; }

.cell-truncate {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #1e293b; }

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: #e2e8f0; }
th.sortable.active { color: #60a5fa; }

.filters {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #94a3b8;
}
.filters select, .filters input { margin-left: 4px; }

.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  font-size: 13px;
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

.view-toggle { display: flex; gap: 4px; }

.expand-toggle { width: 20px; color: #94a3b8; }

.session-expand-row td { background: #0f172a; padding: 12px 10px 12px 34px; }
.session-expand-row:hover { background: #0f172a; }

.nested-table { font-size: 12px; }
.nested-table th, .nested-table td { padding: 6px 8px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.badge.active, .badge.valid, .badge.sent, .badge.success { background: #14532d; color: #bbf7d0; }
.badge.paused, .badge.skipped, .badge.missing, .badge.unchecked, .badge.disabled { background: #422006; color: #fde68a; }
.badge.challenged, .badge.pending, .badge.in_progress { background: #1e3a5f; color: #bfdbfe; }
.badge.banned, .badge.failed, .badge.failure, .badge.expired, .badge.invalid { background: #450a0a; color: #fecaca; }
.badge.unknown { background: #581c87; color: #e9d5ff; }

#account-detail, #job-detail { margin-top: 20px; }

.card {
  background: #1e293b;
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 16px;
}

.card h3 { margin: 0 0 12px; font-size: 14px; color: #f1f5f9; }
.card form h3 { margin-top: 32px; }

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 32px 0 12px;
}
.card form .section-title h3 { margin: 0; }

form label {
  display: block;
  margin-bottom: 10px;
  font-size: 12px;
  color: #94a3b8;
}

.checkbox-label { display: flex; flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 8px; }
.checkbox-label input[type="checkbox"] { width: auto; margin-top: 0; }

input, select, textarea {
  width: 100%;
  margin-top: 4px;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid #334155;
  background: #0f172a;
  color: #f1f5f9;
  font-size: 13px;
  font-family: inherit;
}

textarea { min-height: 60px; resize: vertical; }

.form-row { display: flex; gap: 12px; }
.form-row > label { flex: 1; }

.form-actions { display: flex; gap: 8px; margin-top: 12px; }
.form-actions-end { justify-content: flex-end; }

.detail-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.session-progress {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 16px;
}

.session-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  font-size: 13px;
}

.session-progress-step { color: #f1f5f9; font-weight: 600; }
.session-progress-runs { color: #94a3b8; }

.session-progress-track {
  height: 8px;
  background: #0f172a;
  border-radius: 999px;
  overflow: hidden;
}

.session-progress-fill {
  height: 100%;
  background: #2563eb;
  width: 0%;
  transition: width 0.4s ease;
}

.session-progress.status-failed .session-progress-fill { background: #dc2626; }
.session-progress.status-completed .session-progress-fill { background: #16a34a; }
.session-progress.status-skipped .session-progress-fill,
.session-progress.status-unknown .session-progress-fill { background: #ca8a04; }

.session-progress-time { margin-top: 6px; font-size: 12px; color: #64748b; }

.topbar-actions { display: flex; gap: 8px; }

.usage-badges { display: flex; gap: 8px; }

.usage-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
}

.usage-badge svg { flex: 0 0 auto; }

.usage-badge.usage-ok { background: #14532d; color: #bbf7d0; border-color: #166534; }
.usage-badge.usage-warn { background: #422006; color: #fde68a; border-color: #854d0e; }
.usage-badge.usage-critical { background: #450a0a; color: #fecaca; border-color: #991b1b; }

.icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  background: #334155;
}
.icon-btn:hover { background: #475569; }

.menu-wrapper { position: relative; display: inline-block; }

.menu-dropdown {
  position: absolute;
  top: 40px;
  right: 0;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  min-width: 170px;
  padding: 4px;
  z-index: 20;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.menu-dropdown.hidden { display: none; }

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  color: #e2e8f0;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
}
.menu-item:hover { background: #334155; }
.menu-item.danger { color: #fca5a5; }
.menu-item.danger:hover { background: #450a0a; }

.webhook-example {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
  color: #e2e8f0;
  overflow-x: auto;
  margin-top: 4px;
}

.steps-list { list-style: none; margin: 0; padding: 0; }

.steps-list li {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid #0f172a;
  font-size: 12px;
  align-items: baseline;
}

.steps-list .step-name { flex: 0 0 140px; color: #f1f5f9; }
.steps-list .step-msg { color: #94a3b8; }
.steps-list .step-at { color: #475569; margin-left: auto; white-space: nowrap; }

.capture-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.capture-grid figure {
  margin: 0;
  background: #0f172a;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #334155;
}

.capture-grid img { width: 100%; display: block; }
.capture-grid figcaption { padding: 6px 8px; font-size: 11px; color: #94a3b8; }
.capture-grid figcaption a { color: #60a5fa; text-decoration: none; }

.hidden { display: none !important; }

#modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

#modal {
  background: #1e293b;
  border-radius: 10px;
  padding: 20px 24px;
  width: 480px;
  max-height: 80vh;
  overflow-y: auto;
}

.copy-field { position: relative; width: 50%; margin-bottom: 12px; }
.copy-field input.readonly-field {
  width: 100%;
  margin-top: 0;
  padding-right: 34px;
  background: #172032;
  color: #94a3b8;
  cursor: default;
}
.copy-field .copy-icon-btn {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #94a3b8;
  border-radius: 0 6px 6px 0;
}
.copy-field .copy-icon-btn:hover { background: #334155; color: #f1f5f9; }
.copy-field .copy-icon-btn.copied { color: #4ade80; }

.muted { color: #64748b; font-size: 12px; }
.run-info { color: #f1f5f9; font-size: 12px; }
.error-text { color: #fca5a5; font-size: 12px; white-space: pre-wrap; }

.form-error {
  background: #450a0a;
  border: 1px solid #7f1d1d;
  border-radius: 6px;
  padding: 8px 12px;
  margin: 0 0 14px;
}
.close-btn { float: right; }
