:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --line: #d9dde3;
  --text: #20242a;
  --muted: #68707c;
  --blue: #0878d7;
  --blue-dark: #075da7;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: var(--blue-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.brand { font-weight: 700; font-size: 20px; }
nav { display: flex; flex-direction: column; gap: 6px; }
nav a { color: var(--text); padding: 10px; border-radius: 6px; }
nav a:hover { background: #eef2f6; text-decoration: none; }
.new-plan, .primary, .secondary {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 40px;
  padding: 8px 14px;
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: white;
  font-weight: 700;
  cursor: pointer;
}
.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}
.new-plan:hover, .primary:hover { background: var(--blue-dark); text-decoration: none; }
.secondary:hover { background: #eef2f6; text-decoration: none; }
.context-switch label, .context-switch select { display: block; width: 100%; }
.context-switch label { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.context-switch select, input, select, textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  font: inherit;
}
button { font: inherit; }
.signed-in { color: var(--muted); font-size: 14px; }
.main { margin-left: 260px; padding: 34px; }
.page-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: start;
  margin-bottom: 22px;
}
h1 { margin: 0 0 4px; font-size: 28px; }
h2 { margin-top: 28px; font-size: 20px; }
p { color: var(--muted); }
.hint { margin-top: 0; color: var(--muted); font-size: 14px; }
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.data-table th, .data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.data-table.compact th, .data-table.compact td { padding: 7px 9px; font-size: 14px; }
.data-table th { color: var(--muted); font-weight: 600; background: #fbfcfd; }
.data-table tr:last-child td { border-bottom: 0; }
.pill, .stage {
  display: inline-block;
  border: 1px solid #f2a8b8;
  color: #9f273e;
  background: #fff5f7;
  border-radius: 999px;
  padding: 4px 10px;
  font-weight: 700;
  font-size: 13px;
}
.summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 28px;
}
.summary-strip div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
}
.summary-strip span { display: block; color: var(--muted); font-size: 12px; }
.summary-strip strong { font-size: 22px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.form-card, .edit-form, .workflow-panel, .line-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.diff-panel {
  margin-top: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.form-grid, .line-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
}
.line-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.line-title { font-weight: 700; margin-bottom: 12px; }
.section-title {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  margin-top: 20px;
}
.section-title h2 { margin-top: 0; }
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.row-actions form { margin: 0; }
.row-actions .secondary { min-height: 32px; padding: 5px 10px; }
.narrow { max-width: 720px; }
.message {
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: 6px;
  background: #eef7ee;
  border: 1px solid #b9dab9;
}
.message.error { background: #fff0f0; border-color: #f0b2b2; }
.recent-block { border-top: 1px solid var(--line); padding-top: 14px; font-size: 13px; }
.recent-block h3 { margin: 0 0 8px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.recent-block a { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.workflow-map-button {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: zoom-in;
  overflow: hidden;
}
.workflow-map-button img { display: block; width: 100%; height: auto; }
.lightbox {
  width: min(1100px, 92vw);
  border: 0;
  border-radius: 8px;
  padding: 18px;
}
.lightbox::backdrop { background: rgba(0, 0, 0, .7); }
.lightbox img { display: block; width: 100%; height: auto; }
.lightbox-close {
  float: right;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 6px 10px;
  cursor: pointer;
}
@media (max-width: 960px) {
  .sidebar { position: static; width: auto; }
  .main { margin-left: 0; padding: 20px; }
  .split, .form-grid, .line-grid { grid-template-columns: 1fr; }
}
