* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, sans-serif;
  background: #111827;
  color: #e5e7eb;
  line-height: 1.5;
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

h1 { font-size: 1.5rem; }
#subtitle { color: #9ca3af; font-size: 0.9rem; }

.header-right { display: flex; gap: 0.5rem; align-items: center; }

.badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid #374151;
}
.badge.ok { color: #4ade80; border-color: #4ade80; }
.badge.err { color: #f87171; border-color: #f87171; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.stat small {
  display: block;
  color: #9ca3af;
  font-size: 0.7rem;
  text-transform: uppercase;
}

.cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 768px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .cols { grid-template-columns: 1fr; }
}

.card {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 8px;
  overflow: hidden;
}

.card h2 {
  font-size: 0.9rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #374151;
}

.scroll { max-height: 280px; overflow: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { padding: 0.6rem 1rem; text-align: left; border-bottom: 1px solid #374151; }
th { color: #9ca3af; font-size: 0.7rem; text-transform: uppercase; }
tr:hover td { background: #374151; }

.empty { padding: 2rem; text-align: center; color: #9ca3af; }

.btn {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  border: 1px solid #374151;
  background: #374151;
  color: #e5e7eb;
  cursor: pointer;
}
.btn:hover:not(:disabled) { background: #4b5563; }
.btn-primary { background: #2563eb; border-color: #2563eb; }
.btn-primary:hover:not(:disabled) { background: #1d4ed8; }
.btn-danger { background: #b91c1c; border-color: #b91c1c; }
.btn-danger:hover:not(:disabled) { background: #991b1b; }
.btn-sm { padding: 0.2rem 0.5rem; font-size: 0.75rem; }
.actions-cell { white-space: nowrap; }
.actions-cell .btn + .btn { margin-left: 0.35rem; }
.hint { font-size: 0.8rem; margin: 0 0 0.75rem; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn.loading {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 5.5rem;
  justify-content: center;
}

.spinner {
  width: 0.85rem;
  height: 0.85rem;
  border: 2px solid rgba(255,255,255,.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-bar {
  height: 2px;
  background: #374151;
  overflow: hidden;
}
.loading-bar.hidden { display: none; }
.loading-bar::after {
  content: "";
  display: block;
  height: 100%;
  width: 35%;
  background: #2563eb;
  animation: slide 1.2s ease-in-out infinite;
}
@keyframes slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

body.is-busy .card:not(.console-card) { opacity: 0.85; pointer-events: none; }
body.is-busy #btn-refresh:not(.loading) { opacity: 0.55; pointer-events: none; }

.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 20px rgba(0,0,0,.35);
  z-index: 100;
}
.toast.hidden { display: none; }

.console-card pre {
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  padding: 1rem;
  min-height: 100px;
  max-height: 180px;
  overflow: auto;
  color: #9ca3af;
  white-space: pre-wrap;
}

.log-ok { color: #4ade80; }
.log-err { color: #f87171; }

#job-label { font-weight: normal; color: #9ca3af; font-size: 0.8rem; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal.hidden { display: none; }

.modal-box {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 1.25rem;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.modal-box.modal-wide { max-width: 440px; }

.modal-box h3 { margin-bottom: 0.25rem; }
.muted { font-size: 0.75rem; color: #9ca3af; word-break: break-all; }

.modal-box select {
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  border: 1px solid #374151;
  background: #111827;
  color: #e5e7eb;
  font: inherit;
}

.mode-tabs {
  display: flex;
  gap: 0.75rem;
  margin: 0.25rem 0 0.5rem;
}

.mode-tab {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: #e5e7eb;
  cursor: pointer;
}

.warn {
  font-size: 0.75rem;
  color: #fbbf24;
  line-height: 1.4;
}

.hidden { display: none !important; }

.modal-box label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.8rem;
  color: #9ca3af;
}

.modal-box input,
.modal-box textarea {
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  border: 1px solid #374151;
  background: #111827;
  color: #e5e7eb;
  font: inherit;
  resize: vertical;
}

.modal-box textarea { min-height: 4.5rem; }

.note-cell {
  max-width: 12rem;
  color: #9ca3af;
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-preview {
  font-size: 0.8rem;
  color: #d1d5db;
  padding: 0.5rem 0.65rem;
  background: #111827;
  border-radius: 6px;
  border-left: 3px solid #2563eb;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

code { font-size: 0.85em; }
