:root {
  color-scheme: light dark;
  --bg: #0f1115;
  --panel: #171a21;
  --border: #2a3140;
  --text: #e8ecf3;
  --muted: #9aa7bd;
  --accent: #5b8cff;
  --pass: #2f9e6b;
  --fail: #d45b5b;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: Inter, system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

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

.header-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}

h1,
h2 {
  margin: 0 0 0.5rem;
}

.subtitle,
.hint,
.status {
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.tab {
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.75rem 1rem;
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
  display: grid;
  gap: 1.25rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}

.panel-header,
.collapsible-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.collapsible {
  padding-top: 0.75rem;
}

.collapsible-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  margin-bottom: 0;
}

.collapsible-summary::-webkit-details-marker {
  display: none;
}

.collapsible-summary::before {
  content: "▸";
  color: var(--muted);
  font-size: 0.85rem;
  transition: transform 0.15s ease;
}

.collapsible[open] > .collapsible-summary::before {
  transform: rotate(90deg);
}

.collapsible[open] > .collapsible-summary {
  margin-bottom: 1rem;
}

.collapsible-summary h2 {
  margin: 0;
}

.collapsible-summary-row h2 {
  flex: 1;
}

.field-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.tooltip-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  flex-shrink: 0;
}

.tooltip-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tooltip-content {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.45rem);
  transform: translateX(-50%);
  width: max-content;
  max-width: 260px;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.4;
  white-space: normal;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 20;
}

.tooltip-trigger:hover .tooltip-content,
.tooltip-trigger:focus-visible .tooltip-content {
  opacity: 1;
  visibility: visible;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field-label > span:first-child {
  color: var(--muted);
  font-size: 0.9rem;
}

input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  width: 100%;
  font: inherit;
}

textarea {
  min-height: 120px;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.site-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}

button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-weight: 600;
}

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

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}

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

.add-filter,
.run-controls,
.actions-panel {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.checkbox-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.filter-list,
.queries-list {
  display: grid;
  gap: 0.75rem;
}

.filter-item,
.query-card {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.filter-item {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.filter-item span,
.query-card h3 {
  font-family: var(--mono);
}

.query-card-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.query-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.results {
  display: grid;
  gap: 1.5rem;
}

.result-section {
  display: grid;
  gap: 1rem;
}

.result-heading {
  margin: 0;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

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

.job-card h3 {
  margin: 0 0 0.25rem;
}

.job-card h3 a {
  color: var(--text);
}

.job-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.job-description {
  margin: 0.75rem 0;
}

.description-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: pre-wrap;
  line-height: 1.45;
}

.description-empty {
  font-style: italic;
}

.description-toggle {
  margin: 0.35rem 0 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.description-toggle:hover {
  color: var(--text);
}

.filter-results {
  display: grid;
  gap: 0.5rem;
}

.filter-result {
  border-left: 3px solid var(--border);
  padding-left: 0.75rem;
}

.filter-result.pass {
  border-left-color: var(--pass);
}

.filter-result.fail {
  border-left-color: var(--fail);
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}

.badge.pass {
  background: color-mix(in srgb, var(--pass) 20%, transparent);
  color: var(--pass);
}

.badge.fail {
  background: color-mix(in srgb, var(--fail) 20%, transparent);
  color: var(--fail);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 0.75rem;
}

.empty {
  color: var(--muted);
  font-style: italic;
}

.last-run-error-panel {
  border-color: color-mix(in srgb, var(--fail) 45%, var(--border));
}

.last-run-error-panel h2 {
  color: var(--fail);
}

.last-run-error-text {
  margin: 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow: auto;
}

.last-run-logs-panel {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}

.last-run-logs-text {
  margin: 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow: auto;
}
