:root {
  --bg: #0f1117;
  --bg-elevated: #171a22;
  --bg-hover: #1e222d;
  --border: #2a3040;
  --text: #e8ecf4;
  --text-muted: #8b95a8;
  --accent: #6c8cff;
  --accent-hover: #8aa4ff;
  --danger: #f07178;
  --danger-hover: #ff8a90;
  --success: #7fd99a;
  --warning: #e6c07b;
  --radius: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "SF Mono", "Fira Code", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.auth-page {
  display: grid;
  place-items: center;
  padding: 2rem;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(108, 140, 255, 0.12), transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(240, 113, 120, 0.08), transparent 50%),
    var(--bg);
}

.auth-card {
  width: min(400px, 100%);
  padding: 2rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
}

.brand {
  text-align: center;
  margin-bottom: 2rem;
}

.brand-mark {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-accent {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
}

.brand-sub,
.brand-inline .topbar-title {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin: 0.25rem 0 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 10;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tab-btn {
  padding: 0.4rem 0.8rem;
  font: inherit;
  font-size: 0.875rem;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
}

.tab-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.tab-btn.active {
  color: var(--text);
  border-color: var(--border);
  background: var(--bg);
}

.tab-page {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.brand-inline {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.layout {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}

.panel h2 {
  margin: 0 0 1rem;
  font-size: 1.125rem;
  font-weight: 600;
}

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

.panel-header h2 {
  margin: 0;
}

.form,
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.form-grid {
  gap: 1.25rem;
}

label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  transition: border-color 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

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

select option:disabled {
  color: var(--text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  font: inherit;
  font-weight: 500;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.radio {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
  color: var(--text);
  cursor: pointer;
}

.radio input {
  width: auto;
}

.hint,
.muted {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0;
}

.error {
  color: var(--danger);
  font-size: 0.875rem;
  margin: 0;
}

.hidden {
  display: none !important;
}

.summary {
  padding: 0.85rem 1rem;
  background: rgba(230, 192, 123, 0.1);
  border: 1px solid rgba(230, 192, 123, 0.35);
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.9375rem;
}

.suggestions {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  max-height: 220px;
  overflow-y: auto;
  background: var(--bg);
}

.suggestions li {
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.suggestions li:last-child {
  border-bottom: none;
}

.suggestions li:hover {
  background: var(--bg-hover);
}

.selected-user {
  padding: 0.65rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
}

.progress-wrap {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: 999px;
  transition: width 0.4s ease;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.stats strong {
  color: var(--text);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.table th,
.table td {
  padding: 0.6rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  color: var(--text-muted);
  font-weight: 500;
}

.table td.message-preview {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 0.75rem;
}

.status-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.status-running {
  background: rgba(108, 140, 255, 0.2);
  color: var(--accent);
}

.status-done {
  background: rgba(127, 217, 154, 0.2);
  color: var(--success);
}

.status-stopped,
.status-interrupted {
  background: rgba(230, 192, 123, 0.2);
  color: var(--warning);
}

.status-error {
  background: rgba(240, 113, 120, 0.2);
  color: var(--danger);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
}

.stat-grid.compact {
  margin-top: 0;
}

.stat-card {
  padding: 0.95rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
}

.stat-label {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-value {
  margin: 0.35rem 0 0.15rem;
  font-size: 1.55rem;
  font-weight: 650;
  font-family: var(--mono);
  letter-spacing: -0.03em;
}

.detail-grid {
  display: grid;
  gap: 0.35rem;
  margin: 1rem 0;
  font-size: 0.9rem;
}

.detail-grid p {
  margin: 0;
}

.inline-field {
  min-width: 160px;
}

code {
  font-family: var(--mono);
  font-size: 0.8em;
}

@media (max-width: 900px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    flex-wrap: wrap;
  }

  .tabs {
    order: 3;
    width: 100%;
  }
}

@media (max-width: 640px) {
  .table {
    display: block;
    overflow-x: auto;
  }

  .stats {
    flex-direction: column;
    gap: 0.5rem;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }
}
