:root {
  color-scheme: dark;
  --bg: #0f172a;
  --panel-bg: rgba(15, 23, 42, 0.9);
  --panel-border: rgba(148, 163, 184, 0.25);
  --text: #f1f5f9;
  --muted: #a5b4fc;
  --muted-strong: #cbd5f5;
  --accent: linear-gradient(120deg, #22d3ee, #6366f1);
  --accent-strong: #38bdf8;
  --accent-text: #0f172a;
  --table-header: rgba(148, 163, 184, 0.12);
  --table-row: rgba(15, 23, 42, 0.78);
  --table-row-hover: rgba(96, 165, 250, 0.18);
  --table-row-selected: rgba(59, 130, 246, 0.28);
  --divider: rgba(148, 163, 184, 0.16);
  --modal-bg: rgba(15, 23, 42, 0.97);
  --input-bg: #f8fafc;
  --input-text: #0f172a;
  --shadow: 0 24px 48px rgba(15, 23, 42, 0.55);
}

body[data-theme="light"] {
  color-scheme: light;
  --bg: #f8fafc;
  --panel-bg: #ffffff;
  --panel-border: rgba(148, 163, 184, 0.2);
  --text: #0f172a;
  --muted: #475569;
  --muted-strong: #1e293b;
  --accent: linear-gradient(120deg, #2563eb, #7c3aed);
  --accent-strong: #2563eb;
  --accent-text: #f8fafc;
  --table-header: rgba(226, 232, 240, 0.95);
  --table-row: rgba(248, 250, 252, 0.95);
  --table-row-hover: rgba(37, 99, 235, 0.12);
  --table-row-selected: rgba(37, 99, 235, 0.2);
  --divider: rgba(148, 163, 184, 0.22);
  --modal-bg: #ffffff;
  --input-bg: #ffffff;
  --input-text: #0f172a;
  --shadow: 0 18px 36px rgba(15, 23, 42, 0.22);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Roboto", sans-serif;
  display: flex;
  flex-direction: column;
}


  .brand-title a {
    color: #facc15;
    font-weight: 700;
    text-decoration: none;
  }

  .brand-title a:hover,
  .brand-title a:focus {
    color: #fde047;                 /* a touch lighter for hover/focus */
    text-decoration: underline;
  }

.top-bar {
  padding: 24px 40px 18px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.85));
}

body[data-theme="light"] .top-bar {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.92), rgba(79, 70, 229, 0.88));
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brand-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.brand-title h1 {
  margin: 0;
  font-size: 2.5rem;
  color: #f8fafc;
}

.brand-version {
  font-size: 0.95rem;
  color: var(--muted);
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  color: #f8fafc;
}

.top-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.theme-toggle {
  border: none;
  border-radius: 999px;
  width: 44px;
  height: 44px;
  font-size: 1.3rem;
  cursor: pointer;
  background: var(--panel-bg);
  color: var(--muted-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px var(--divider);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(14, 165, 233, 0.28);
}

main {
  flex: 1;
  padding: 32px 2% 48px;
  display: flex;
  justify-content: center;
}

.panel {
  width: 100%;
  max-width: 1400px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 28px 30px 32px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.panel-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.panel-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

button {
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 600;
  cursor: pointer;
  color: var(--accent-text);
  background-image: var(--accent);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover:enabled {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(14, 165, 233, 0.32);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.flash {
  min-height: 1.2em;
  color: var(--muted);
  font-size: 0.95rem;
}

.flash.error {
  color: #f87171;
}

.flash.success {
  color: #4ade80;
}

.table-wrapper {
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1100px;
}

th, td {
  padding: 14px 16px;
  font-size: 0.95rem;
  text-align: left;
}

tbody td {
  vertical-align: middle;
}

thead th {
  background: var(--table-header);
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.8rem;
}

tbody tr {
  background: var(--table-row);
  border-bottom: 1px solid var(--panel-border);
  transition: background 0.12s ease;
}

tbody tr:hover {
  background: var(--table-row-hover);
}

tbody tr.selected {
  background: var(--table-row-selected);
}

tbody tr.empty td {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
}

.select-col {
  width: 46px;
  text-align: center;
}

.actions-col {
  width: 120px;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.project-name {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.project-sub {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0;
}

.targets-content {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.download-col {
  min-width: 180px;
}

.targets-count {
  font-weight: 600;
}

.targets-button {
  background: rgba(37, 99, 235, 0.2);
  color: var(--accent-strong);
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.targets-button:hover {
  background: rgba(37, 99, 235, 0.32);
}

.progress-col {
  min-width: 200px;
}

.progress-wrapper {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 72px;
  justify-content: center;
}

.progress-bar {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  height: 12px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--panel-border);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.25s ease;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.progress-meta span:first-child {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-meta span:last-child {
  margin-left: 10px;
  white-space: nowrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-succeeded { background: rgba(34, 197, 94, 0.18); color: #4ade80; }
.status-failed { background: rgba(248, 113, 113, 0.18); color: #f87171; }
.status-running { background: rgba(59, 130, 246, 0.22); color: #60a5fa; }
.status-queued { background: rgba(250, 204, 21, 0.2); color: #facc15; }
.status-scheduled { background: rgba(129, 140, 248, 0.22); color: #c4b5fd; }
.status-never { background: rgba(148, 163, 184, 0.18); color: var(--muted-strong); }

.actions-col {
  min-width: 150px;
}

.actions-content {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(37, 99, 235, 0.18);
  color: var(--accent-strong);
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(37, 99, 235, 0.3);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  background: rgba(37, 99, 235, 0.32);
}

.icon-button.danger {
  background: rgba(248, 113, 113, 0.22);
  border-color: rgba(248, 113, 113, 0.42);
  color: #f87171;
}

.icon-button.danger:hover {
  background: rgba(248, 113, 113, 0.32);
}

.icon-button--stop {
  background: rgba(248, 113, 113, 0.22);
  border-color: rgba(248, 113, 113, 0.42);
  color: #f87171;
}

.icon-button--stop:hover {
  background: rgba(248, 113, 113, 0.32);
}

.report-link {
  color: var(--accent-strong);
  font-weight: 600;
  text-decoration: none;
}

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

footer {
  padding: 0 2% 28px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

footer a {
  color: var(--accent-strong);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

.results-button,
.download-button {
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  background: rgba(37, 99, 235, 0.2);
  border: 1px solid rgba(37, 99, 235, 0.32);
  color: var(--accent-strong);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.results-button:hover:enabled,
.download-button:hover:enabled {
  transform: translateY(-1px);
  background: rgba(37, 99, 235, 0.32);
}

.results-button:disabled,
.download-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  background: rgba(148, 163, 184, 0.2);
  border-color: rgba(148, 163, 184, 0.3);
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 90;
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: all;
  backdrop-filter: blur(3px);
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 100;
}

.modal .modal-content {
  width: min(620px, 92vw);
  background: var(--modal-bg);
  border-radius: 18px;
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  padding: 24px 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  transform: translateY(12px);
  transition: transform 0.2s ease, opacity 0.2s ease;
  opacity: 0;
}

.modal.show {
  pointer-events: all;
}

.modal.show .modal-content {
  transform: translateY(0);
  opacity: 1;
}

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

.modal-header h2 {
  margin: 0;
}

#modal-close,
#targets-modal-close {
  background: none;
  color: var(--muted-strong);
  font-size: 1.8rem;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  padding: 0;
  border: 1px solid transparent;
}

#modal-close:hover,
#targets-modal-close:hover {
  background: rgba(148, 163, 184, 0.15);
  transform: none;
  box-shadow: none;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-field label {
  font-weight: 600;
  color: var(--muted);
}

.modal-field textarea,
.modal-field input[type="text"],
.modal-field input[type="datetime-local"] {
  background: var(--input-bg);
  color: var(--input-text);
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  padding: 12px 14px;
  font-size: 0.95rem;
}

.modal-field textarea {
  resize: vertical;
  min-height: 160px;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

#modal-cancel,
#targets-modal-ok {
  background: rgba(148, 163, 184, 0.25);
  color: var(--text);
}

.modal .feedback {
  min-height: 1.2em;
  color: var(--accent-strong);
  font-size: 0.9rem;
}

.modal .feedback.error {
  color: #f87171;
}

.targets-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.targets-body .targets-count {
  margin: 0;
  font-weight: 600;
  color: var(--muted-strong);
}

.targets-scroll {
  max-height: 320px;
  overflow: auto;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--panel-border);
}

body[data-theme="light"] .targets-scroll {
  background: rgba(248, 250, 252, 0.92);
}

.targets-scroll ol {
  margin: 0;
  padding-left: 22px;
  color: var(--muted-strong);
  line-height: 1.6;
}

@media (max-width: 960px) {
  main {
    padding: 24px 2% 36px;
  }

  .panel {
    padding: 24px;
  }

  .panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-actions {
    justify-content: flex-start;
  }
}

body[data-theme="light"] .progress-bar {
  background: rgba(226, 232, 240, 0.8);
  border-color: rgba(191, 219, 254, 0.8);
}

body[data-theme="light"] .progress-fill {
  background: linear-gradient(120deg, #1d4ed8, #60a5fa);
}
.downloads-content {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
