:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f4f7;
  --ink: #17202a;
  --muted: #687381;
  --line: #d9e0e7;
  --blue: #1769c2;
  --blue-2: #e7f1fc;
  --green: #138a55;
  --green-2: #e6f5ee;
  --orange: #b86414;
  --orange-2: #fff0df;
  --red: #b42318;
  --red-2: #fdebea;
  --purple: #6f4cc3;
  --shadow: 0 12px 32px rgba(23, 32, 42, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
}

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

button {
  cursor: pointer;
}

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

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #eef4f9 0%, #f9fafb 100%);
}

.login-panel {
  width: min(440px, 100%);
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand-row,
.app-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.login-panel h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.login-panel p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

label {
  display: grid;
  gap: 7px;
  margin-top: 16px;
  color: #3d4651;
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cbd5df;
  border-radius: 6px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

textarea {
  min-height: 112px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 105, 194, 0.14);
}

.primary-btn,
.ghost-btn,
.danger-btn,
.small-btn,
.nav-item,
.tab {
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 38px;
  padding: 8px 12px;
  white-space: nowrap;
}

.primary-btn {
  margin-top: 16px;
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 700;
}

.ghost-btn,
.small-btn {
  background: #fff;
  border-color: var(--line);
  color: #23313f;
}

.danger-btn {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.small-btn {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 650;
}

.error-line {
  min-height: 20px;
  margin-top: 12px;
  color: var(--red);
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 16px;
  background: #17202a;
  color: #fff;
}

.app-brand {
  padding: 4px 4px 20px;
}

.app-brand .brand-mark {
  background: #fff;
  color: #17202a;
}

.brand-title {
  font-size: 14px;
  font-weight: 800;
}

.brand-subtitle {
  margin-top: 3px;
  color: #b5c0ca;
  font-size: 11px;
}

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

.nav-item {
  width: 100%;
  min-height: 42px;
  text-align: left;
  color: #d9e1e8;
  background: transparent;
  border-color: transparent;
}

.nav-item.active,
.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.11);
}

.main {
  min-width: 0;
  padding: 24px;
}

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

.topbar h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.banner {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--orange);
  border-radius: 8px;
  background: #fff;
}

.banner.ok {
  border-left-color: var(--green);
  background: var(--green-2);
}

.banner.error {
  border-left-color: var(--red);
  background: var(--red-2);
}

.banner strong {
  display: block;
  margin-bottom: 3px;
}

.banner span {
  color: #4e5a66;
  font-size: 13px;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 16px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
  min-width: 0;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(23, 32, 42, 0.03);
}

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

.panel-head h2 {
  margin: 0;
  font-size: 16px;
}

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

.kpi {
  min-height: 112px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.kpi .label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.kpi .value {
  margin-top: 9px;
  font-size: 24px;
  line-height: 1.15;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.kpi .meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.delta.good {
  color: var(--green);
}

.delta.bad {
  color: var(--red);
}

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

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #495461;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 800;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.object-name {
  max-width: 460px;
  overflow-wrap: anywhere;
  font-weight: 650;
}

.muted {
  color: var(--muted);
}

.empty {
  padding: 18px;
  color: var(--muted);
  background: #fbfcfd;
  border: 1px dashed #cbd5df;
  border-radius: 8px;
  font-size: 13px;
}

.stack {
  display: grid;
  gap: 10px;
}

.record {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.record-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.record-title {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.record-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.record-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-top: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: #3a4652;
  font-size: 12px;
  font-weight: 750;
}

.badge.ok,
.badge.connected,
.badge.succeeded,
.badge.ready,
.badge.passed {
  background: var(--green-2);
  color: var(--green);
}

.badge.error,
.badge.failed,
.badge.blocked,
.badge.high,
.badge.deleted {
  background: var(--red-2);
  color: var(--red);
}

.badge.warning,
.badge.not_tested,
.badge.medium,
.badge.running,
.badge.queued,
.badge.pending,
.badge.draft {
  background: var(--orange-2);
  color: var(--orange);
}

.badge.submitted,
.badge.open {
  background: var(--blue-2);
  color: var(--blue);
}

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

.form-grid .wide,
.form-grid button {
  grid-column: 1 / -1;
}

.divider {
  height: 1px;
  margin: 6px 0;
  background: var(--line);
}

.tabs,
.filters {
  display: flex;
  gap: 8px;
  align-items: end;
  flex-wrap: wrap;
}

.filters.compact {
  justify-content: flex-end;
}

.tab {
  min-height: 36px;
  background: #fff;
  border-color: var(--line);
  color: #344251;
  font-weight: 700;
}

.tab.active {
  color: var(--blue);
  background: var(--blue-2);
  border-color: #b9d6f5;
}

.filters label {
  width: 180px;
  margin-top: 0;
}

.tag-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid #c9d7e3;
  border-radius: 999px;
  background: #f7fafc;
  color: #334252;
  font-size: 12px;
  font-weight: 700;
}

.analysis-job {
  border-left: 4px solid #b9d6f5;
}

.analysis-summary {
  margin-top: 10px;
  padding: 10px;
  color: #344251;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.metric-strip div {
  min-height: 58px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.metric-strip span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.metric-strip strong {
  display: block;
  margin-top: 5px;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.evidence-list {
  margin: 8px 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
}

.timeline {
  display: grid;
  gap: 9px;
}

.timeline-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 92px;
  gap: 10px;
  align-items: center;
  font-size: 12px;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  background: #edf1f5;
  border-radius: 999px;
}

.bar {
  width: 0;
  height: 100%;
  background: var(--blue);
}

details {
  margin-top: 8px;
}

summary {
  color: var(--blue);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

pre {
  max-height: 220px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 10px;
  border-radius: 6px;
  background: #111827;
  color: #e5e7eb;
  font-size: 12px;
  line-height: 1.45;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #17202a;
  color: #fff;
  box-shadow: var(--shadow);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  font-size: 13px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid.two,
  .kpi-grid,
  .metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .main {
    padding: 16px;
  }

  .topbar,
  .record-head {
    display: grid;
  }

  .toolbar,
  .record-actions {
    justify-content: start;
  }

  .nav,
  .grid.two,
  .kpi-grid,
  .form-grid,
  .metric-strip {
    grid-template-columns: 1fr;
  }

  .filters label {
    width: 100%;
  }

  .timeline-row {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .timeline-row .muted:last-child {
    grid-column: 2;
  }
}
