:root {
  --bg: #0f1419;
  --surface: #1a222c;
  --border: #2c3848;
  --text: #e7eef7;
  --muted: #9aabbd;
  --accent: #3d9cf0;
  --accent-dim: #2a6fad;
  --danger: #e35d6a;
  --ok: #3cba7a;
  --warn: #d4a017;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "Consolas", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 10% -10%, #1b2a3d 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--font);
  min-height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 20, 25, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  min-width: 0;
}

.nav .brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.nav .links {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  margin-right: auto;
}

.nav .links a {
  color: var(--muted);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
}

.nav .links a:hover {
  color: var(--text);
  text-decoration: none;
}

.nav .links a.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-shrink: 0;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.15rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(26, 34, 44, 0.7);
}

.lang-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.25rem 0.45rem;
  border-radius: 4px;
  cursor: pointer;
}

.lang-btn:hover {
  color: var(--text);
}

.lang-btn.active {
  background: var(--accent-dim);
  color: var(--text);
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
  flex: 1 0 auto;
  width: 100%;
}

h1 { margin: 0 0 0.4rem; font-size: 1.8rem; }
h2 { margin-top: 2rem; font-size: 1.2rem; }
.lede { color: var(--muted); margin-top: 0; }

.back-link {
  margin: 0 0 0.85rem;
  text-align: left;
}

.back-link a {
  display: inline-block;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.stats .stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.18s ease, transform 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.stats .stat-card:hover {
  text-decoration: none;
  border-color: var(--accent);
  background: #1f2a38;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.stats .stat-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.stats strong { font-size: 1.6rem; }
.stats span { color: var(--muted); font-size: 0.9rem; }

label {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

form:not(.inline):not(.inline-form) {
  display: grid;
  gap: 0.85rem;
  align-content: start;
}

/* Keep label visually tied to the following control. */
form:not(.inline):not(.inline-form) > label {
  margin-bottom: -0.45rem;
}

form.inline {
  display: inline;
  margin: 0;
}

input, textarea, button {
  font: inherit;
}

input, textarea, select {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.65rem 0.75rem;
}

textarea {
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.45;
  resize: vertical;
}

button {
  background: var(--accent);
  color: #061018;
  border: 0;
  border-radius: 6px;
  padding: 0.65rem 1rem;
  font-weight: 600;
  cursor: pointer;
}

button:hover { background: #5aaff5; }

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

button.secondary:hover {
  background: #1f2a38;
  border-color: var(--accent);
}

button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 0.3rem 0.55rem;
  font-size: 0.85rem;
}

button.linkish {
  background: transparent;
  color: var(--accent);
  padding: 0;
  margin: 0;
  font-weight: 500;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  margin: 0.4rem 0 0;
  border-bottom: 1px solid var(--border);
}

.tabs .tab {
  margin: 0;
  background: transparent;
  color: var(--muted);
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.55rem 0.85rem;
  font-weight: 500;
}

.tabs .tab:hover {
  background: transparent;
  color: var(--text);
}

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

.tab-panel {
  display: grid;
  gap: 0.75rem;
  align-content: start;
}
.tab-panel[hidden],
[hidden] {
  display: none !important;
}

.tab-panel [data-scrape-jobs],
.tab-panel [data-file-sd-groups],
.tab-panel [data-services] {
  display: grid;
  gap: 0.75rem;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.5rem;
}

.toolbar h2 {
  margin: 0;
  font-size: 1.1rem;
}

.actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.actions > button[type="submit"] {
  width: 100%;
}

.group-card [data-auth-basic]:not([hidden]),
.group-card [data-auth-bearer]:not([hidden]),
[data-prom-auth] [data-auth-basic]:not([hidden]),
[data-prom-auth] [data-auth-bearer]:not([hidden]) {
  display: grid;
  gap: 0.55rem;
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.group-card {
  position: relative;
  display: grid;
  gap: 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0.75rem 1rem 1rem;
  margin: 0;
}

.group-card legend {
  padding: 0 0.35rem;
  color: var(--text);
  font-weight: 600;
}

.group-card > label {
  margin-bottom: -0.2rem;
}

.group-card [data-static-fields],
.group-card [data-filesd-fields],
.group-card [data-fsd-group-wrap] {
  display: grid;
  gap: 0.55rem;
}

.group-card [data-static-fields] > label,
.group-card [data-filesd-fields] > label,
.group-card [data-fsd-group-wrap] > label {
  margin-bottom: -0.2rem;
}

.group-card .remove-group {
  position: absolute;
  top: 0.7rem;
  right: 1rem;
  font-size: 0.85rem;
}

.login-form {
  max-width: 360px;
  margin-top: 1.25rem;
}

.flash {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.flash.ok { border-left-color: var(--ok); }
.flash.warn { border-left-color: var(--warn); }
.flash.error { border-left-color: var(--danger); }

.table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

.table th, .table td {
  text-align: left;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table th { color: var(--muted); font-weight: 500; font-size: 0.85rem; }

.job-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.job-list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.85rem;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
}

.help {
  max-width: 52rem;
}

.help-section {
  margin: 1.75rem 0;
}

.help-section h2 {
  margin: 0 0 0.65rem;
  font-size: 1.15rem;
}

.help-section p,
.help-section li {
  color: var(--muted);
  line-height: 1.55;
}

.help-section ul,
.help-section ol {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}

.help-section li {
  margin: 0.35rem 0;
}

.help-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.help-table th,
.help-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

.help-table th {
  color: var(--text);
  font-weight: 600;
  background: rgba(0, 0, 0, 0.18);
}

.help-table td {
  color: var(--muted);
}

.help-table tr:last-child td {
  border-bottom: 0;
}

.help-code {
  margin: 0.75rem 0 0;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow-x: auto;
}

.help-code code {
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text);
  white-space: pre;
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.15rem 0.35rem 0.15rem 0;
  flex-wrap: wrap;
}

.orphan-actions {
  min-width: 18rem;
}

.file-sd-actions {
  min-width: 16rem;
}

.file-sd-actions .inline-form select {
  width: auto;
  min-width: 8rem;
  margin: 0;
}

.move-file,
.rename-file {
  display: grid;
  gap: 0.75rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.move-file > h2,
.rename-file > h2 {
  margin: 0;
}

.move-file > .lede,
.rename-file > .lede {
  margin: 0;
}

.rename-file .inline-form input {
  width: auto;
  min-width: 12rem;
}

.move-file .inline-form select {
  width: auto;
  min-width: 10rem;
}

.orphans {
  display: grid;
  gap: 0.75rem;
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.orphans > h2 {
  margin: 0;
}

.orphans > .lede {
  margin: 0;
}

.site-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0.75rem 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.site-footer .app-version {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr; }
  .nav { flex-wrap: wrap; }
  .nav-left { width: 100%; }
  .nav-right { width: 100%; justify-content: space-between; }
}
