:root {
  --bg: #f3f1ec;
  --ink: #191a1f;
  --ink-soft: #5f646f;
  --card: rgba(255, 255, 255, 0.86);
  --line: #d2d5dd;
  --primary: #0b4abf;
  --primary-2: #0d7a78;
  --alert: #a22828;
  --ok: #207e44;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 85% -10%, #f6e8c9 0%, transparent 52%),
              radial-gradient(circle at 10% 10%, #d5e8ff 0%, transparent 45%),
              var(--bg);
  min-height: 100vh;
}

.bg-layer {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(transparent 31px, rgba(25, 26, 31, 0.04) 32px),
                    linear-gradient(90deg, transparent 31px, rgba(25, 26, 31, 0.04) 32px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 0;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1200px, 94vw);
  margin: 30px auto 56px;
  animation: fade-in 320ms ease-out;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

.topnav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topnav a {
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  background: #fff;
}

.topnav a.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(120deg, var(--primary), var(--primary-2));
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.4rem, 1.6vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--ink-soft);
}

.panel,
.login-card,
.kpi-card {
  background: var(--card);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 10px 35px rgba(23, 26, 36, 0.08);
  border-radius: var(--radius);
}

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

.panel.compact {
  padding: 16px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.kpi-card {
  padding: 14px;
}

.kpi-card h3 {
  margin: 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-soft);
}

.kpi-card p {
  margin: 7px 0 0;
  font-weight: 800;
  font-size: 1.6rem;
}

.filters {
  display: grid;
  grid-template-columns: 1.8fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  font-size: 0.92rem;
  font-weight: 600;
}

input,
select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 10px 11px;
  font: inherit;
  outline: none;
  background: #fff;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(11, 74, 191, 0.12);
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(120deg, var(--primary), var(--primary-2));
}

.btn-danger {
  color: #fff;
  background: #b42626;
  border-color: #9f1f1f;
}

.btn-ghost,
.btn-small {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-small {
  font-size: 0.84rem;
  padding: 6px 10px;
}

.btn-danger.btn-small {
  color: #fff;
  background: #b42626;
  border-color: #9f1f1f;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 10px;
  border-bottom: 1px solid #ebedf3;
  font-size: 0.92rem;
}

th {
  background: #f8fafc;
  color: #2e3445;
  font-weight: 700;
}

tbody tr:hover {
  background: #f9fbff;
}

.tag {
  display: inline-block;
  border: 1px solid #cdd8f3;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.76rem;
  font-weight: 700;
  color: #1f396f;
  background: #edf3ff;
}

.tag-warn {
  border-color: #f6d6ad;
  color: #7b4200;
  background: #fff2df;
}

.empty {
  color: var(--ink-soft);
  text-align: center;
  padding: 18px;
}

.subtle {
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.mono {
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 0.8rem;
}

.pager {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.pager-actions {
  display: flex;
  gap: 8px;
}

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

.run-list article {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  display: grid;
  gap: 4px;
}

.detail-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 16px;
  margin: 0;
}

.detail-grid dt {
  font-weight: 800;
}

.detail-grid dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.toolbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: 8px 0 12px;
}

.actions-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.actions-inline form {
  margin: 0;
}

.checkbox-col {
  width: 42px;
}

.body-pre {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  max-height: 460px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.alerts {
  margin-bottom: 14px;
}

.alert {
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid;
}

.alert.error {
  background: #fdeeee;
  border-color: #f6c5c5;
  color: var(--alert);
}

.alert.success {
  background: #e8f8ef;
  border-color: #bfe9cf;
  color: #176539;
}

.alert.warning {
  background: #fff6e8;
  border-color: #f5ddb5;
  color: #8b5a0a;
}

.login-wrap {
  min-height: 70vh;
  display: grid;
  place-items: center;
}

.login-card {
  width: min(420px, 92vw);
  padding: 24px;
}

.login-card .badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--ok);
  background: #e8f8ef;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.login-card h2 {
  margin: 12px 0 6px;
  font-size: 1.6rem;
}

.login-card p {
  margin: 0 0 14px;
  color: var(--ink-soft);
}

@media (max-width: 960px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .pager {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 600px) {
  .shell {
    width: min(95vw, 95vw);
    margin-top: 20px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

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