:root {
  --bg: #f2efe8;
  --panel: #fffaf1;
  --ink: #1f2933;
  --accent: #0f766e;
  --accent-soft: #c7ece8;
  --border: #d8cfc0;
  --danger: #b42318;
  --warning: #b54708;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.16), transparent 24%),
    linear-gradient(180deg, #f6f2ea 0%, #ece6dc 100%);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

.page {
  width: min(1280px, 100%);
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.panel {
  width: 100%;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(80, 61, 39, 0.08);
  padding: 24px;
}

.hero {
  margin-bottom: 24px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(32px, 4vw, 56px);
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 16px;
  margin-top: 20px;
  align-items: end;
}

.controls label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 600;
  min-width: 0;
}

.controls .checkbox {
  align-self: center;
}

input, button {
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 12px 14px;
  font-size: 15px;
  background: white;
  width: 100%;
  max-width: 100%;
}

button {
  background: var(--accent);
  color: white;
  cursor: pointer;
  border: none;
}

select {
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 12px 14px;
  font-size: 15px;
  background: white;
  width: 100%;
  max-width: 100%;
}

.secondary {
  background: white;
  color: var(--ink);
  border: 1px solid var(--border);
}

.secondary.danger {
  color: var(--danger);
  border-color: #f3b5ad;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.table-wrap {
  max-width: 100%;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto;
  gap: 14px;
  margin-bottom: 16px;
  align-items: end;
}

.toolbar label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 600;
  min-width: 0;
}

.checkbox {
  flex-direction: row !important;
  align-items: center;
  gap: 10px !important;
  align-self: end;
  justify-self: start;
  width: auto;
  max-width: 100%;
}

.checkbox input {
  width: auto;
  flex: 0 0 auto;
}

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

th, td {
  text-align: left;
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 16px;
  flex-wrap: wrap;
}

.count {
  margin: 0;
  color: #6b7280;
  font-size: 14px;
  max-width: 100%;
  word-break: break-word;
}

.status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: #ede7dc;
  font-size: 13px;
}

.status-downloaded {
  background: var(--accent-soft);
}

.status-downloading {
  background: #dbeafe;
}

.status-failed, .status-cancelled {
  background: #fee4e2;
}

.job-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
}

.job-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.job-name {
  margin: 10px 0 0;
  font-weight: 600;
  word-break: break-word;
}

.progress {
  margin: 12px 0 8px;
  height: 10px;
  background: #e7e0d5;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #0f766e, #14b8a6);
}

.message {
  min-height: 20px;
  margin-top: 16px;
}

.error {
  color: var(--danger);
}

.empty {
  color: #6b7280;
}

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

@media (max-width: 640px) {
  .page {
    padding: 20px 12px 32px;
  }

  .panel {
    padding: 18px;
  }
}

@media (max-width: 1100px) {
  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 14px;
  }

  tr {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.55);
    padding: 10px 14px;
  }

  td {
    display: grid;
    grid-template-columns: minmax(84px, 120px) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 10px 0;
    border-bottom: 1px solid rgba(216, 207, 192, 0.7);
  }

  td:last-child {
    border-bottom: none;
  }

  td::before {
    content: attr(data-label);
    font-weight: 700;
    color: #5b6470;
  }
}
