:root {
  color-scheme: dark;
  --bg: #07101f;
  --panel: #101a2c;
  --panel-2: #17243a;
  --line: #2a3d5d;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --success: #22c55e;
  --warning: #fb923c;
  --danger: #ef4444;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 10%, rgba(56, 189, 248, .12), transparent 28rem),
    var(--bg);
  font: 14px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.site-nav {
  position: sticky;
  z-index: 100;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 58px;
  padding: 10px max(16px, calc((100vw - 1500px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(7, 16, 31, .94);
  backdrop-filter: blur(12px);
  flex-wrap: nowrap;
}

.site-brand {
  flex: 0 0 auto;
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
  text-decoration: none;
}

.site-nav-links {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.site-nav-links > a {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-2);
  text-decoration: none;
}

.site-nav-links .current-user,
.site-nav-links .nav-button {
  flex: 0 0 auto;
}

main {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

header {
  margin-bottom: 24px;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.nav-link {
  flex: 0 0 auto;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: var(--panel-2);
  text-decoration: none;
}

.nav-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

.nav-button {
  width: auto;
  border-color: var(--line);
  background: var(--panel-2);
}

.current-user {
  color: var(--muted);
  font-size: 12px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 900px;
  margin-bottom: 8px;
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1.05;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.subtitle {
  max-width: 820px;
  color: var(--muted);
  font-size: 16px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(330px, .8fr);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(16, 26, 44, .94);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .22);
}

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

.section-heading h2 {
  margin: 0;
}

.small-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.state {
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel-2);
  font-size: 12px;
  font-weight: 700;
}

.state.completed {
  color: #dcfce7;
  background: #166534;
}

.state.running {
  color: #dbeafe;
  background: #1d4ed8;
}

.state.queued {
  color: #ffedd5;
  background: #9a3412;
}

.state.failed {
  color: #fee2e2;
  background: #991b1b;
}

.state.cancelling {
  color: #ffedd5;
  background: #9a3412;
}

.state.cancelled {
  color: #e5e7eb;
  background: #374151;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 15px;
  color: #dbeafe;
  font-weight: 600;
}

label small {
  color: var(--muted);
  font-weight: 400;
}

input,
select,
button {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: #0b1424;
  font: inherit;
}

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

button {
  cursor: pointer;
  border-color: #0ea5e9;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  font-weight: 800;
}

button:disabled {
  cursor: wait;
  opacity: .55;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 14px;
}

.full {
  grid-column: 1 / -1;
}

details {
  margin: 12px 0 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

summary {
  color: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

.options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.check {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 9px;
  margin: 0;
  font-weight: 500;
}

.check input {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.status-panel {
  position: sticky;
  top: 18px;
}

#job-message {
  color: var(--muted);
}

.progress {
  min-height: 260px;
  max-height: 430px;
  margin: 14px 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #cbd5e1;
  background: #07101f;
  white-space: pre-wrap;
}

.downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.downloads a {
  padding: 8px 11px;
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-2);
  text-decoration: none;
}

.job-list,
.history-list {
  display: grid;
  gap: 14px;
}

.history-date-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.history-date-separator::before,
.history-date-separator::after {
  height: 1px;
  background: var(--line);
  content: "";
  flex: 1 1 auto;
}

.report-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 9px 0;
}

.report-tags span {
  padding: 4px 8px;
  border: 1px solid #0e7490;
  border-radius: 999px;
  color: #cffafe;
  background: #164e63;
  font-size: 11px;
  font-weight: 700;
}

.job-card,
.history-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0b1424;
}

.job-heading,
.history-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.job-heading small,
.history-card-heading small {
  display: block;
  margin-top: 3px;
}

.job-time,
.job-message,
.history-summary {
  color: var(--muted);
}

.job-message {
  min-height: 21px;
  margin: 12px 0;
}

.job-inputs {
  margin: 10px 0;
  padding: 10px;
}

.job-inputs pre,
.job-progress {
  margin: 10px 0 0;
  padding: 10px;
  overflow: auto;
  border-radius: 8px;
  color: #cbd5e1;
  background: #07101f;
  white-space: pre-wrap;
}

.job-progress {
  min-height: 90px;
  max-height: 210px;
}

.job-actions,
.job-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.job-actions > button {
  width: auto;
}

.job-links a {
  padding: 7px 9px;
  border-radius: 7px;
  color: var(--text);
  background: var(--panel-2);
  text-decoration: none;
}

.cancel-button {
  border-color: #dc2626;
  background: #991b1b;
}

.remove-button {
  border-color: #7f1d1d;
  background: #450a0a;
}

.clone-button {
  border-color: #7c3aed;
  background: #5b21b6;
}

.auth-main {
  display: grid;
  min-height: calc(100vh - 58px);
  place-items: center;
}

.auth-panel {
  width: min(460px, calc(100% - 24px));
}

.auth-message {
  min-height: 21px;
  color: #fecaca;
}

.history-panel {
  max-width: 1200px;
  margin: 0 auto;
}

.schedule-layout {
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr);
}

.schedule-list-panel {
  position: sticky;
  top: 78px;
  max-height: calc(100vh - 96px);
  overflow: auto;
}

.schedule-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 8px;
  margin-bottom: 12px;
}

.schedule-toolbar button {
  width: auto;
}

.schedule-list {
  display: grid;
  gap: 12px;
}

.schedule-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #0b1424;
}

.schedule-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.schedule-card-heading small {
  display: block;
  margin-top: 3px;
}

.state.enabled {
  color: #dcfce7;
  background: #166534;
}

.state.paused,
.state.completed {
  color: #e5e7eb;
  background: #374151;
}

.schedule-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.schedule-details div {
  padding: 8px;
  border-radius: 7px;
  background: var(--panel-2);
}

.schedule-details span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.schedule-details strong {
  display: block;
  overflow-wrap: anywhere;
}

.schedule-card pre {
  max-height: 220px;
  margin-top: 10px;
  padding: 10px;
  overflow: auto;
  border-radius: 8px;
  color: #cbd5e1;
  background: #07101f;
  white-space: pre-wrap;
}

.schedule-message,
.schedule-error {
  min-height: 21px;
  margin: 10px 0;
  color: var(--muted);
}

.schedule-error {
  color: #fecaca;
}

.schedule-job-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--accent);
}

.schedule-run-button {
  border-color: #2563eb;
  background: #1d4ed8;
}

.schedule-toggle-button {
  border-color: #c2410c;
  background: #9a3412;
}

.schedule-edit-button {
  border-color: #0d9488;
  background: #0f766e;
}

.schedule-edit-cancel {
  width: auto;
  border-color: #64748b;
  background: #334155;
}

hr {
  height: 1px;
  margin: 24px 0;
  border: 0;
  background: var(--line);
}

.user-admin {
  max-width: 1200px;
  margin: 0 auto;
}

.users-page {
  width: min(900px, calc(100% - 32px));
}

.user-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.user-list span {
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--text);
  background: var(--panel-2);
}

.history-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 180px auto;
  gap: 10px;
}

.history-toolbar button {
  width: auto;
}

.history-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.history-inputs div {
  padding: 9px;
  border-radius: 8px;
  background: var(--panel-2);
}

.history-inputs span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.history-inputs strong {
  display: block;
  overflow-wrap: anywhere;
}

.preview {
  margin-top: 20px;
}

.preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.preview-heading button {
  width: auto;
  background: var(--panel-2);
}

#report-frame {
  width: 100%;
  min-height: 900px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

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

  .status-panel {
    position: static;
  }

  .schedule-list-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 620px) {
  main {
    width: min(100% - 20px, 1500px);
  }

  .form-grid,
  .options {
    grid-template-columns: 1fr;
  }

  .page-heading,
  .history-toolbar {
    grid-template-columns: 1fr;
    display: grid;
  }

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

  .site-nav {
    align-items: center;
    flex-direction: row;
  }

  .site-nav-links {
    justify-content: flex-start;
    width: auto;
  }
}
