:root {
  color-scheme: dark;
  --bg: #121212;
  --surface: #1b1b1b;
  --surface-2: #242424;
  --border: #2e2e2e;
  --text: #f2f2f2;
  --muted: #a3a3a3;
  --accent: #005bac;
  --accent-hover: #0073e6;
  --success: #3fb950;
  --warning: #e3b341;
  --danger: #f85149;
  --radius: 6px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

h1 {
  font-size: 1.4rem;
  margin: 0;
}

h2 {
  font-size: 1.05rem;
  margin: 0 0 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}

#content {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

label {
  font-weight: 600;
  font-size: 0.9rem;
}

select,
input {
  min-width: 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid #3a3a3a;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

select:disabled {
  opacity: 0.5;
}

button {
  padding: 0.55rem 1rem;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
}

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

button.secondary {
  border: 1px solid #4a4a4a;
  background: transparent;
  color: var(--text);
}

button.secondary:hover:not(:disabled) {
  background: var(--surface-2);
}

select:focus-visible,
input:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 2px;
}

.create {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.75rem 1rem;
  align-items: end;
}

.field,
.stack {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.75rem;
}

.inline input {
  flex: 1 1 280px;
}

details {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

summary {
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}

details[open] summary {
  margin-bottom: 1rem;
}

.refresh {
  margin-top: 1rem;
}

.message {
  margin: 0.9rem 0 0;
  padding: 0.6rem 0.8rem;
  border-left: 3px solid var(--accent-hover);
  border-radius: var(--radius);
  background: rgba(0, 115, 230, 0.14);
}

.message.success {
  border-color: var(--success);
  background: rgba(63, 185, 80, 0.12);
}

.message.error {
  border-color: var(--danger);
  background: rgba(248, 81, 73, 0.12);
}

.section-head .message,
#files-message {
  margin: 0 0 0.9rem;
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

tbody tr:nth-child(even) td {
  background: #202020;
}

.status {
  min-width: 11rem;
}

.date {
  white-space: nowrap;
}

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

.badge.pending {
  background: rgba(0, 115, 230, 0.22);
  color: #8cc2ff;
}

.badge.success {
  background: rgba(63, 185, 80, 0.18);
  color: #7ee08f;
}

.badge.failed {
  background: rgba(248, 81, 73, 0.18);
  color: #ff9a94;
}

.detail {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.detail.warning {
  color: var(--warning);
}

progress {
  display: block;
  width: 100%;
  max-width: 11rem;
  height: 0.4rem;
  margin-top: 0.45rem;
  border: none;
  border-radius: 999px;
  background: #343434;
  overflow: hidden;
  appearance: none;
}

progress::-webkit-progress-bar {
  background: #343434;
}

progress::-webkit-progress-value {
  background: var(--accent-hover);
}

progress::-moz-progress-bar {
  background: var(--accent-hover);
}

.actions {
  text-align: right;
  white-space: nowrap;
}

.actions button + button {
  margin-left: 0.5rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 640px) {
  .create {
    grid-template-columns: 1fr;
  }

  thead {
    display: none;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  tr {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
  }

  td,
  tbody tr:nth-child(even) td {
    padding: 0.3rem 0.25rem;
    border: none;
    background: none;
  }

  td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 0.7rem;
    text-transform: uppercase;
  }

  .actions {
    text-align: left;
  }
}
