:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --border: #d8dee8;
  --text: #17202a;
  --muted: #657184;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --wait: #d8dde6;
  --rank-bg: #f9fbfd;
  --shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: #111827;
  color: white;
  border-bottom: 1px solid #0b1220;
}

.brand {
  font-weight: 700;
  letter-spacing: 0;
}

.tabs {
  display: inline-flex;
  gap: 6px;
}

.tab {
  width: auto;
  height: 30px;
  color: #cbd5e1;
  background: transparent;
  border-color: transparent;
}

.tab.active {
  color: white;
  background: #273449;
  border-color: #3a4a63;
}

.status {
  color: #cbd5e1;
  font-size: 13px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 6, 23, 0.68);
}

.error-modal-card {
  width: min(560px, 100%);
  color: #e5e7eb;
  background: #111827;
  border: 1px solid #334155;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

.error-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #263244;
}

.error-modal-title {
  color: #fecaca;
  font-size: 15px;
  font-weight: 700;
}

.icon-button {
  width: 30px;
  height: 30px;
  padding: 0;
  color: #cbd5e1;
  background: transparent;
  border-color: transparent;
  font-size: 22px;
  line-height: 1;
}

.icon-button:hover {
  background: #1f2937;
  border-color: #334155;
}

.error-modal-body {
  padding: 16px;
  color: #fecaca;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.error-modal-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 16px 16px;
}

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
}

.view {
  display: none;
}

.view.active {
  display: grid;
}

.config-panel {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow: auto;
}

.main-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 0;
}

.form-section {
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.section-title {
  margin-bottom: 10px;
  font-weight: 700;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

label span,
.header-row {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  height: 34px;
  padding: 0 9px;
  color: var(--text);
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid rgba(37, 99, 235, 0.25);
  outline-offset: 1px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.three-col {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.three-col label {
  min-width: 0;
}

.three-col input {
  padding: 0 7px;
}

.duration-grid {
  display: grid;
  grid-template-columns: 42px 1fr 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.duration-grid .op-name {
  height: 28px;
  display: inline-flex;
  align-items: center;
  font-weight: 700;
}

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

button {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: #aab5c6;
}

button.primary {
  color: white;
  background: var(--accent);
  border-color: var(--accent);
}

button.primary:hover {
  background: var(--accent-strong);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.metric {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
}

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

.metric .value {
  margin-top: 4px;
  font-size: 20px;
  font-weight: 700;
}

.timeline-toolbar {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.timeline-toolbar button {
  width: auto;
}

.toolbar-check {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.toolbar-check input {
  width: 16px;
  height: 16px;
}

.compare-check {
  height: 34px;
  min-width: 0;
  justify-content: start;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fbfcfe;
}

.compare-check span {
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.compare-toggle-row {
  margin-bottom: 12px;
}

.zoom-control {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  min-width: 220px;
  margin: 0;
}

.zoom-control input {
  width: 160px;
  padding: 0;
}

.timeline-wrap {
  min-height: 0;
  overflow: auto;
  background: #eef2f7;
}

.compare-main {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.compare-timelines {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1px;
  background: var(--border);
}

.compare-lane {
  min-height: 0;
  display: grid;
  grid-template-rows: 34px minmax(0, 1fr);
  background: #eef2f7;
}

.compare-title {
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: #344154;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
}

#timeline {
  display: block;
}

#compare-timeline-a,
#compare-timeline-b {
  display: block;
}

.rank-band {
  fill: var(--rank-bg);
}

.rank-label {
  fill: #344154;
  font-size: 12px;
  font-weight: 700;
}

.axis-line {
  stroke: #c9d2df;
  stroke-width: 1;
}

.axis-text {
  fill: var(--muted);
  font-size: 11px;
}

.grid-line {
  stroke: #d7dee9;
  stroke-width: 1;
  stroke-dasharray: 3 5;
}

.op-rect {
  stroke: rgba(15, 23, 42, 0.72);
  stroke-width: 1;
  cursor: pointer;
}

.op-rect.selected {
  stroke: #111827;
  stroke-width: 2.5;
}

.op-rect.matched {
  stroke: #f59e0b;
  stroke-width: 2.5;
}

.wait-rect {
  fill: var(--wait);
  opacity: 0.8;
}

.op-label {
  fill: #0f172a;
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
}

.details-panel {
  min-height: 112px;
  max-height: 220px;
  overflow: auto;
  padding: 12px 14px;
  background: var(--panel);
  border-top: 1px solid var(--border);
}

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

.details-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(90px, 1fr));
  gap: 8px;
}

.detail-item {
  min-width: 0;
}

.detail-item .key {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.detail-item .val {
  margin-top: 2px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.deps {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.dep-row {
  margin-bottom: 8px;
  padding: 8px;
  color: #334155;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.dep-row strong {
  color: var(--text);
}

.dep-row span {
  color: var(--muted);
}

.dep-row code {
  display: block;
  margin-top: 4px;
  color: #64748b;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.tooltip {
  position: fixed;
  z-index: 20;
  display: none;
  min-width: 220px;
  max-width: 360px;
  padding: 9px 10px;
  color: white;
  background: rgba(17, 24, 39, 0.96);
  border-radius: 6px;
  box-shadow: var(--shadow);
  pointer-events: none;
  font-size: 12px;
  line-height: 1.45;
}

.tooltip strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .config-panel {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .summary-strip,
  .details-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}
