:root {
  --bg: #ffffff;
  --ink: #16202a;
  --muted: #64748b;
  --line: #d8dee7;
  --line-strong: #c6d0dc;
  --brand: #245fd1;
  --brand-soft: #eff5ff;
  --danger: #b42318;
  --warn: #a15c07;
  --ok: #11755d;
  --surface-subtle: #f8fafc;
  font-family: "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

body {
  line-height: 1.45;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select {
  font: inherit;
}

.ops-shell {
  min-height: 100vh;
  max-width: 1520px;
  margin: 0 auto;
  padding: 28px 32px 56px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.topbar-brand,
.section-lead {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.section-icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  flex-shrink: 0;
  margin-top: 2px;
}

.brand-icon {
  width: 28px;
  height: 28px;
  margin-top: 4px;
}

.section-icon svg {
  width: 100%;
  height: 100%;
}

.topbar h1,
.panel-header h2,
.auth-header h1 {
  margin: 0;
}

.topbar h1 {
  font-size: 2.8rem;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.panel-header h2 {
  font-size: 1.55rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

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

.toolbar {
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar form {
  margin: 0;
}

button,
.link-button {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  color: var(--brand);
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

button:hover,
.link-button:hover {
  text-decoration: underline;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  text-decoration: none;
}

button.primary {
  color: var(--ink);
}

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

.layout {
  display: grid;
  gap: 0;
}

.panel {
  padding: 26px 0 28px;
  border-bottom: 1px solid var(--line);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.panel-header > .muted {
  max-width: 420px;
  text-align: right;
}

.diagnosis-card {
  display: grid;
  gap: 16px;
}

.diagnosis-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.diagnosis-summary {
  margin: 10px 0 0;
  font-size: 0.98rem;
  line-height: 1.6;
}

.diagnosis-actions {
  display: flex;
  justify-content: flex-end;
}

.chip-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.chip,
.state-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.chip::before,
.state-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.8;
}

.state-success,
.state-running,
.state-ready {
  color: var(--ok);
}

.state-failed,
.state-upstream_failed,
.state-error,
.state-blocked {
  color: var(--danger);
}

.state-up_for_retry,
.state-queued,
.state-scheduled,
.state-deferred,
.state-mixed,
.state-stale,
.state-noop {
  color: var(--warn);
}

.state-unknown,
.state-none,
.state-empty,
.state-in_progress {
  color: var(--muted);
}

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

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

.finding:last-child {
  border-bottom: 0;
}

.finding p {
  margin: 8px 0 0;
  display: inline-flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--ink);
}

.finding-critical,
.finding-high {
  color: var(--danger);
}

.finding-medium {
  color: var(--warn);
}

.finding-info {
  color: var(--ok);
}

.manual-upload-shell {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.manual-upload-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.manual-upload-chips {
  margin-top: 0;
}

.manual-upload-note {
  margin: 10px 0 0;
  max-width: 880px;
  line-height: 1.6;
}

.manual-upload-toolbar {
  justify-content: flex-end;
}

.hidden-upload-input {
  display: none;
}

.upload-dropzone {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 16px 0;
  border-top: 1px dashed var(--line-strong);
  border-bottom: 1px dashed var(--line-strong);
  transition: background-color 160ms ease, border-color 160ms ease;
}

.upload-dropzone.is-over {
  border-color: var(--brand);
  background: rgba(36, 95, 209, 0.03);
}

.upload-dropzone.is-busy {
  opacity: 0.72;
  pointer-events: none;
}

.upload-dropzone-title {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 4px;
}

.manual-upload-table-wrap {
  margin-top: -2px;
}

.manual-upload-table select,
.auth-form input {
  width: min(220px, 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 11px;
  background: #fff;
  color: var(--ink);
}

.manual-upload-remove {
  color: var(--muted);
}

.manual-upload-empty {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  color: var(--muted);
}

.chain-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0;
}

.chain-list li,
.dag-card,
.run-card,
.log-line {
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
  background: none;
}

.chain-list li:last-child,
.dag-card:last-child,
.run-card:last-child,
.log-line:last-child {
  border-bottom: 0;
}

.chain-list li {
  display: grid;
  grid-template-columns: minmax(0, 120px) minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.chain-step {
  font-weight: 700;
}

.dag-grid,
.metrics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.dag-card,
.run-card {
  padding-right: 12px;
}

.dag-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.dag-card h3,
.run-card h3 {
  margin: 0;
  font-size: 1rem;
}

.card-actions {
  margin-top: 10px;
  display: flex;
  gap: 12px;
}

.split-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead th {
  padding: 10px 12px 10px 0;
  border-bottom: 1px solid var(--line-strong);
  text-align: left;
  vertical-align: top;
  color: var(--muted);
  font-size: 0.79rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.data-table tbody td {
  padding: 12px 12px 12px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

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

.activity-log {
  display: grid;
  gap: 0;
}

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

.flash {
  padding: 10px 0;
  margin-bottom: 16px;
}

.flash-error {
  color: var(--danger);
}

.auth-shell {
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(520px, 100%);
  padding: 42px 0 12px;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-form label {
  display: grid;
  gap: 8px;
}

.inline-icon {
  width: 15px;
  height: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
  flex-shrink: 0;
}

.inline-icon svg {
  width: 100%;
  height: 100%;
}

@media (max-width: 980px) {
  .ops-shell {
    padding: 20px 18px 42px;
  }

  .topbar,
  .panel-header,
  .diagnosis-header,
  .manual-upload-header,
  .upload-dropzone {
    flex-direction: column;
  }

  .panel-header > .muted {
    max-width: none;
    text-align: left;
  }

  .manual-upload-toolbar {
    width: 100%;
    justify-content: flex-start;
  }

  .split-panel {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .chain-list li {
    grid-template-columns: 1fr;
  }
}
