:root {
  --bg: #f4f6f8;
  --ink: #17202a;
  --muted: #607080;
  --line: #d8dee5;
  --blue: #2457d6;
  --red: #c73933;
  --amber: #b87500;
  --green: #147a42;
  --teal: #0c8f8f;
  --shadow: 0 14px 34px rgba(28, 39, 54, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

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

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.side {
  background: #101820;
  color: #eef3f7;
  padding: 22px 16px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: #f0c247;
  color: #101820;
  font-weight: 900;
}

.brand span {
  display: block;
  color: #aab7c2;
  font-size: 12px;
}

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

.nav a {
  color: #fff;
  text-decoration: none;
  padding: 12px;
  border: 1px solid #314352;
  background: #1d2a36;
}

.offer-link {
  color: var(--ink);
  text-decoration: none;
}

.offer-link:hover { color: var(--blue); }

.main {
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.app-footer {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-top: auto;
  padding-top: 22px;
  text-align: center;
}

.top,
.head,
.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.top { margin-bottom: 18px; }

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  margin: 0 0 6px;
}

h1,
h2,
p { margin: 0; }

.btn {
  border: 1px solid var(--line);
  background: #f8fafc;
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
}

.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 800;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric,
.panel {
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
  min-height: 126px;
}

.label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.value {
  font-size: 34px;
  font-weight: 900;
  margin-top: 12px;
}

.note,
.sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.panel {
  padding: 16px;
  margin-bottom: 18px;
}

.head {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.table { overflow: auto; }

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.pagination a,
.pagination strong {
  border: 1px solid var(--line);
  min-width: 34px;
  min-height: 34px;
  padding: 7px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.pagination a {
  color: var(--ink);
  background: #f8fafc;
}

.pagination strong {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.pagination.single {
  justify-content: flex-start;
}

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

.jobs-table {
  table-layout: fixed;
  min-width: 1180px;
}

.jobs-table th:nth-child(1),
.jobs-table td:nth-child(1) { width: 58px; }

.jobs-table th:nth-child(2),
.jobs-table td:nth-child(2) { width: 170px; }

.jobs-table th:nth-child(3),
.jobs-table td:nth-child(3) { width: 92px; }

.jobs-table th:nth-child(4),
.jobs-table td:nth-child(4) { width: 74px; }

.jobs-table th:nth-child(5),
.jobs-table td:nth-child(5),
.jobs-table th:nth-child(6),
.jobs-table td:nth-child(6),
.jobs-table th:nth-child(7),
.jobs-table td:nth-child(7) { width: 128px; }

.jobs-table th:nth-child(8),
.jobs-table td:nth-child(8) { width: 220px; }

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.job-payload code,
.job-error {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.job-payload code {
  white-space: normal;
}

.job-error-preview {
  max-height: 4.8em;
  overflow: hidden;
  line-height: 1.45;
}

.job-error details {
  margin-top: 8px;
}

.job-error summary {
  color: var(--blue);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.job-error pre {
  background: #f8fafc;
  border: 1px solid var(--line);
  color: var(--ink);
  margin: 8px 0 0;
  max-height: 220px;
  overflow: auto;
  padding: 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.score {
  display: flex;
  gap: 10px;
  align-items: center;
}

.bar {
  width: 84px;
  height: 8px;
  background: #e6ebf0;
}

.fill { height: 100%; }

.status,
.sev,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 850;
}

.status.open,
.status.error,
.status.failed,
.sev.critical,
.badge.fail {
  background: #fde8e5;
  color: var(--red);
}

.status.done,
.status.ok,
.sev.low,
.badge.ok {
  background: #ebf6ee;
  color: var(--green);
}

.status.queued {
  background: #eaf0ff;
  color: var(--blue);
}

.status.running,
.status.retry {
  background: #fff1d6;
  color: var(--amber);
}

.sev.high,
.badge.warn {
  background: #fff1d6;
  color: var(--amber);
}

.sev.medium {
  background: #e7f4f2;
  color: var(--teal);
}

.form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.filter-form {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-form label {
  min-width: 280px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  min-height: 40px;
  padding: 0 10px;
}

textarea { padding: 10px; }

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

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.check {
  align-items: start;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--ink);
  display: flex;
  gap: 8px;
  min-height: 44px;
  padding: 10px;
  text-transform: none;
}

.check input {
  min-height: auto;
  margin-top: 2px;
}

.check span {
  color: var(--muted);
  font-size: 12px;
  margin-left: auto;
  white-space: nowrap;
}

.user-edit-form {
  margin-top: 12px;
  min-width: 720px;
}

.flash {
  background: #ebf6ee;
  color: var(--green);
  padding: 12px 14px;
  border: 1px solid #b7dec4;
  margin-bottom: 18px;
}

.flash.error {
  background: #fde8e5;
  color: var(--red);
  border-color: #f3b5ae;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 24px;
}

.login-box {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 24px;
}

.single { grid-template-columns: 1fr; }

.offer-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  align-items: start;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.gallery a {
  display: block;
  border: 1px solid var(--line);
  background: #f8fafc;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

.gallery img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.description {
  line-height: 1.55;
}

.alert-card {
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.alert-card:first-of-type { padding-top: 0; }
.alert-card:last-child { border-bottom: 0; }

.alert-card summary {
  display: grid;
  gap: 8px;
  cursor: pointer;
}

.alert-card summary::marker { color: var(--muted); }

.alert-body {
  display: grid;
  gap: 10px;
  padding: 10px 0 0 18px;
}

.kv {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px 12px;
  margin: 0;
}

.kv dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.kv.compact {
  grid-template-columns: 90px 1fr;
  gap: 4px 10px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.detail-grid div {
  border: 1px solid var(--line);
  padding: 10px;
  background: #f8fafc;
}

.detail-grid strong {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.detail-grid span {
  display: block;
  margin-top: 6px;
  font-weight: 800;
}

.json {
  max-height: 360px;
  overflow: auto;
  background: #101820;
  color: #eef3f7;
  padding: 12px;
  font-size: 12px;
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .metrics,
  .form,
  .offer-layout,
  .detail-grid { grid-template-columns: 1fr; }
  .top,
  .head,
  .filter-form {
    align-items: flex-start;
    flex-direction: column;
  }

  .filter-form label {
    min-width: 0;
    width: 100%;
  }
}
