:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --ink: #111827;
  --muted: #667085;
  --line: #e3ebf5;
  --line-strong: #d0dced;
  --accent: #21a2e3;
  --accent-strong: #178bcb;
  --accent-soft: #e9f7ff;
  --success: #12805c;
  --warning: #b37100;
  --danger: #c53d3d;
  --shadow: 0 14px 32px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Instrument Sans", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

[hidden] {
  display: none !important;
}

.page-shell {
  width: min(1120px, calc(100vw - 28px));
  margin: 24px auto 40px;
}

.topbar {
  margin-bottom: 28px;
  padding: 14px 18px;
  border-radius: 16px;
  background: linear-gradient(90deg, #f8fcff 0%, #eef8ff 100%);
}

.intro {
  text-align: center;
  margin-bottom: 24px;
}

.intro h1,
h2,
h3 {
  margin: 0;
  color: var(--ink);
}

.intro h1 {
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  line-height: 1.12;
}

.intro-copy {
  margin: 10px auto 0;
  max-width: 58ch;
  color: var(--muted);
  line-height: 1.6;
}

.intro-meta {
  margin-top: 14px;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.intro-meta span {
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.intro-meta strong {
  color: var(--accent-strong);
}

.stack-layout {
  display: grid;
  gap: 18px;
}

.panel,
.modal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 20px;
}

.job-form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

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

.field span {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  padding: 13px 15px;
  border-radius: 16px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(33, 162, 227, 0.85);
  box-shadow: 0 0 0 4px rgba(33, 162, 227, 0.12);
}

textarea {
  min-height: 320px;
  resize: vertical;
  padding-top: 18px;
}

.input-field textarea {
  border-radius: 24px;
  background: #ffffff;
}

.checkbox-field {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.checkbox-field input {
  width: auto;
  margin: 0;
}

.field-actions {
  align-content: end;
}

.counter-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.counter-box,
.stat-card {
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.counter-box span,
.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
}

.counter-box strong,
.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.1rem;
}

.form-actions,
.status-actions,
.files-box,
.results-toolbar-buttons {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.centered-actions {
  justify-content: center;
}

.centered-message {
  text-align: center;
}

.primary-button,
.ghost-button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 13px 20px;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease,
    color 160ms ease, opacity 160ms ease, transform 160ms ease;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(33, 162, 227, 0.24);
}

.primary-button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.ghost-button {
  background: #ffffff;
  color: var(--accent-strong);
  border-color: #d6e8f6;
}

.ghost-button:hover {
  background: var(--surface-soft);
}

.primary-button:disabled,
.ghost-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.form-message {
  margin: 0;
  min-height: 1.5em;
  color: var(--muted);
}

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

.form-message.success {
  color: var(--success);
}

.form-message.pending {
  color: var(--warning);
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-head p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  background: #eef3f8;
  color: #415168;
  font-size: 0.84rem;
  font-weight: 700;
  text-transform: capitalize;
}

.status-badge.running,
.status-badge.browser_launched,
.status-badge.page_ready,
.status-badge.prepared,
.status-badge.delaying {
  background: #e9f8f0;
  color: var(--success);
}

.status-badge.waiting,
.status-badge.preparing_profile {
  background: #fff4df;
  color: var(--warning);
}

.status-badge.completed {
  background: #e9f8f0;
  color: var(--success);
}

.status-badge.failed {
  background: #fdeaea;
  color: var(--danger);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.progress-panel {
  margin-top: 16px;
}

.progress-rail {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #e8eef6;
}

.progress-bar {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #5abcf0);
  transition: width 220ms ease;
}

.progress-panel p {
  margin: 10px 0 0;
  color: var(--muted);
}

.status-actions,
.files-box {
  margin-top: 16px;
}

.files-box a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  text-decoration: none;
}

.files-box a.ready {
  background: var(--accent-soft);
  border-color: #cfe8f7;
  color: var(--accent-strong);
}

.log-box {
  margin-top: 16px;
}

.subhead {
  margin-bottom: 8px;
}

pre {
  margin: 0;
  min-height: 220px;
  max-height: 360px;
  overflow: auto;
  padding: 14px;
  border-radius: 18px;
  background: #0f172a;
  color: #dbe7f6;
  white-space: pre-wrap;
  word-break: break-word;
}

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

.results-filter {
  min-width: 0;
}

.results-summary {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  text-align: right;
  min-width: 0;
}

.table-wrap {
  overflow: auto;
  border-radius: 20px;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  text-align: left;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f9fbfe;
  color: var(--muted);
  font-size: 0.86rem;
}

tbody tr:hover {
  background: #fbfdff;
}

.empty-cell {
  text-align: center;
  color: var(--muted);
}

.modal {
  width: min(760px, calc(100vw - 24px));
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.modal-card {
  padding: 22px;
}

.modal-card-help {
  max-width: 620px;
}

.modal-section + .modal-section {
  margin-top: 18px;
}

.modal-section h4 {
  margin: 0 0 12px;
  font-size: 0.95rem;
  color: var(--ink);
}

.modal-note {
  margin: -4px 0 14px;
  color: var(--muted);
  line-height: 1.55;
}

.modal-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.modal-head p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

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

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

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

.results-range-input.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(197, 61, 61, 0.12);
}

.help-list {
  display: grid;
  gap: 10px;
}

.help-list p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 820px) {
  .page-shell {
    width: min(100vw - 18px, 100%);
    margin: 12px auto 24px;
  }

  .panel,
  .modal-card {
    border-radius: 20px;
  }

  .panel-head,
  .results-toolbar,
  .modal-head {
    flex-direction: column;
  }

  .results-toolbar {
    grid-template-columns: 1fr;
  }

  .counter-strip,
  .status-grid,
  .modal-grid,
  .results-range-grid,
  .range-inputs {
    grid-template-columns: 1fr;
  }

  .results-summary {
    text-align: left;
  }
}
