:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --surface-3: #f8fafc;
  --ink: #17202a;
  --muted: #647184;
  --line: #d9e0ea;
  --line-strong: #b8c3d1;
  --heading: #344054;
  --button-bg: #ffffff;
  --button-fg: #263241;
  --button-hover: #eef4ff;
  --button-hover-line: #b4c7f8;
  --input-bg: #ffffff;
  --canvas-bg: #f8fafc;
  --grid-line: #eef2f7;
  --toolbar-bg: rgba(255, 255, 255, 0.92);
  --phase-bg: rgba(255, 255, 255, 0.96);
  --step-bg: #ffffff;
  --mini-bg: #f2f5f9;
  --modal-bg: #ffffff;
  --modal-backdrop: rgba(15, 23, 42, 0.42);
  --blue: #2563eb;
  --purple: #7c3aed;
  --green: #17803b;
  --orange: #d97706;
  --amber: #f4b000;
  --red: #d92d20;
  --gray: #667085;
  --shadow: 0 18px 45px rgba(31, 41, 55, 0.13);
  --team: #667085;
  --team-soft: #eef1f5;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body.theme-dark {
  --bg: #0d1118;
  --surface: #141a24;
  --surface-2: #1b2430;
  --surface-3: #111823;
  --ink: #e8edf5;
  --muted: #9aa7b8;
  --line: #283343;
  --line-strong: #3f4d61;
  --heading: #d8e0ec;
  --button-bg: #192230;
  --button-fg: #e8edf5;
  --button-hover: #22304a;
  --button-hover-line: #4b6596;
  --input-bg: #111823;
  --canvas-bg: #0f1621;
  --grid-line: #1b2532;
  --toolbar-bg: rgba(20, 26, 36, 0.94);
  --phase-bg: rgba(20, 26, 36, 0.97);
  --step-bg: #151d29;
  --mini-bg: #111823;
  --modal-bg: #141a24;
  --modal-backdrop: rgba(0, 0, 0, 0.58);
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1180px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  --left-panel-width: 250px;
  --right-panel-width: 360px;
  --toggle-rail-width: 30px;
  height: 100vh;
  display: grid;
  grid-template-rows: 74px 1fr;
}

.app-shell.left-collapsed {
  --left-panel-width: 0px;
}

.app-shell.right-collapsed {
  --right-panel-width: 0px;
}

.topbar {
  display: grid;
  grid-template-columns: 260px minmax(520px, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 12px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.top-select {
  min-width: 190px;
  max-width: 260px;
  min-height: 34px;
  padding: 0 34px 0 10px;
  color: var(--button-fg);
  background: var(--button-bg);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  font-weight: 750;
  outline: none;
}

.top-select:focus {
  border-color: #4f7bea;
  box-shadow: 0 0 0 3px rgba(79, 123, 234, 0.15);
}

.brand-block h1,
.modal-header h2 {
  margin: 2px 0 0;
  font-size: 20px;
  line-height: 1.15;
  letter-spacing: 0;
}

.eyebrow {
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.summary-strip {
  display: grid;
  grid-template-columns: 1.3fr repeat(3, minmax(110px, 0.5fr));
  gap: 10px;
}

.metric {
  min-width: 0;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.metric-label {
  display: block;
  margin-bottom: 3px;
  font-size: 11px;
  font-weight: 650;
  color: var(--muted);
}

.metric strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.health-pill {
  width: max-content;
  max-width: 100%;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 13px;
}

.health-green {
  color: #0b5d2a;
  background: #dff4e6;
}

.health-yellow {
  color: #6c4600;
  background: #fff2ca;
}

.health-red {
  color: #8a1f15;
  background: #ffe0dc;
}

.workspace {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-columns:
    var(--left-panel-width)
    var(--toggle-rail-width)
    minmax(660px, 1fr)
    var(--toggle-rail-width)
    var(--right-panel-width);
  transition: grid-template-columns 180ms ease;
}

.left-panel,
.right-panel {
  min-height: 0;
  overflow: auto;
  background: var(--surface);
  border-color: var(--line);
}

.left-panel {
  grid-column: 1;
  grid-row: 1;
  border-right: 1px solid var(--line);
}

.right-panel {
  grid-column: 5;
  grid-row: 1;
  border-left: 1px solid var(--line);
}

.app-shell.left-collapsed .left-panel,
.app-shell.right-collapsed .right-panel {
  visibility: hidden;
  overflow: hidden;
  border: 0;
}

.panel-section {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.fill-section {
  border-bottom: 0;
}

.section-heading,
.section-heading-row {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--heading);
}

.section-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.section-heading-row p,
.risk-section p {
  margin: 5px 0 0;
  font-size: 12px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
}

.control-row {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
}

.primary-button,
.secondary-button,
.icon-button,
.top-icon-button,
.toolbar-icon-button,
.sidebar-toggle {
  min-height: 34px;
  border-radius: 7px;
  border: 1px solid transparent;
  font-weight: 750;
}

.primary-button {
  padding: 0 14px;
  color: #ffffff;
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.primary-button:hover {
  background: #1e40af;
}

.secondary-button,
.icon-button,
.top-icon-button,
.toolbar-icon-button,
.sidebar-toggle {
  color: var(--button-fg);
  background: var(--button-bg);
  border-color: var(--line-strong);
}

.secondary-button {
  width: 100%;
  padding: 0 12px;
}

.secondary-button:hover,
.icon-button:hover,
.top-icon-button:hover,
.toolbar-icon-button:hover,
.sidebar-toggle:hover {
  background: var(--button-hover);
  border-color: var(--button-hover-line);
}

.icon-button {
  width: 34px;
  padding: 0;
  display: grid;
  place-items: center;
}

.top-icon-button,
.toolbar-icon-button,
.sidebar-toggle {
  width: 34px;
  padding: 0;
  display: grid;
  place-items: center;
}

.top-icon-button svg,
.toolbar-icon-button svg,
.sidebar-toggle svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.top-icon-button.is-active,
.toolbar-icon-button.is-active {
  color: #ffffff;
  background: #334155;
  border-color: #334155;
}

body.theme-dark .top-icon-button.is-active,
body.theme-dark .toolbar-icon-button.is-active {
  background: #4f7bea;
  border-color: #4f7bea;
}

.sidebar-toggle {
  align-self: start;
  justify-self: center;
  z-index: 2;
  margin-top: 14px;
  box-shadow: 0 8px 18px rgba(31, 41, 55, 0.12);
}

.sidebar-toggle-left {
  grid-column: 2;
  grid-row: 1;
}

.sidebar-toggle-right {
  grid-column: 4;
  grid-row: 1;
}

.text-input,
.select-input,
.textarea-input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--input-bg);
  color: var(--ink);
  outline: none;
}

.text-input,
.select-input {
  min-height: 36px;
  padding: 8px 10px;
}

.textarea-input {
  min-height: 72px;
  resize: vertical;
  padding: 9px 10px;
}

.text-input:focus,
.select-input:focus,
.textarea-input:focus {
  border-color: #4f7bea;
  box-shadow: 0 0 0 3px rgba(79, 123, 234, 0.15);
}

.field-label,
.detail-form label,
.modal-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.filter-list {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.filter-chip {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  color: var(--heading);
  background: var(--button-bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  text-align: left;
}

.filter-chip.is-muted {
  opacity: 0.48;
}

.team-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--team);
}

.chip-count {
  color: var(--muted);
  font-size: 11px;
}

.phase-outline {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.outline-button {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 7px 8px;
  color: var(--heading);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  text-align: left;
}

.outline-button:hover,
.outline-button.active {
  background: var(--button-hover);
  border-color: var(--button-hover-line);
}

.outline-button span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.outline-count {
  color: var(--muted);
  font-size: 11px;
}

.canvas-region {
  grid-column: 3;
  grid-row: 1;
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-rows: 52px 1fr;
  overflow: hidden;
  background:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    var(--canvas-bg);
  background-size: 28px 28px;
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 14px;
  background: var(--toolbar-bg);
  border-bottom: 1px solid var(--line);
}

.canvas-toolbar strong {
  display: block;
  font-size: 13px;
}

.canvas-toolbar span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

.toolbar-actions .secondary-button {
  width: auto;
}

.canvas-viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.canvas-viewport.dragging {
  cursor: grabbing;
}

.canvas-content {
  position: absolute;
  left: 0;
  top: 0;
  width: 4120px;
  height: 1220px;
  transform-origin: 0 0;
}

.pipeline-rail {
  position: absolute;
  left: 150px;
  top: 126px;
  width: 3660px;
  height: 2px;
  background: var(--line-strong);
}

.phase-card {
  position: absolute;
  width: 300px;
  min-height: 300px;
  background: var(--phase-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(31, 41, 55, 0.08);
  overflow: hidden;
}

.phase-card.is-focus {
  border-color: #4f7bea;
  box-shadow: 0 0 0 4px rgba(79, 123, 234, 0.14), var(--shadow);
}

.phase-header {
  min-height: 76px;
  padding: 13px 14px 10px;
  border-bottom: 1px solid var(--line);
}

.phase-title-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 10px;
}

.phase-title {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
  letter-spacing: 0;
}

.phase-status {
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--heading);
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 800;
}

.phase-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.team-strip {
  display: flex;
  width: 100%;
  height: 7px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.team-strip span {
  height: 100%;
  background: var(--team);
}

.step-list {
  display: grid;
  gap: 7px;
  padding: 10px;
}

.step-node {
  --team: #667085;
  min-height: 58px;
  display: grid;
  grid-template-columns: 6px 1fr auto;
  gap: 9px;
  align-items: stretch;
  padding: 0 9px 0 0;
  background: var(--step-bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  text-align: left;
  box-shadow: 0 1px 0 rgba(16, 24, 40, 0.03);
}

.step-node:hover,
.step-node.is-selected {
  border-color: #4f7bea;
  box-shadow: 0 0 0 3px rgba(79, 123, 234, 0.13);
}

.step-node.is-dimmed {
  opacity: 0.25;
}

.step-node.is-hidden {
  display: none;
}

.team-bar {
  border-radius: 7px 0 0 7px;
  background: var(--team);
}

.step-main {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 8px 0;
}

.step-title {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: var(--ink);
  font-size: 12px;
  font-weight: 760;
  line-height: 1.2;
}

.step-subtitle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 11px;
}

.step-icons {
  display: grid;
  align-content: center;
  justify-items: end;
  gap: 5px;
  min-width: 34px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cbd5e1;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.status-in-progress {
  background: var(--blue);
}

.status-waiting-customer {
  background: var(--amber);
}

.status-done {
  background: var(--green);
}

.flag-marker {
  width: 15px;
  height: 15px;
  border-radius: 4px 4px 4px 0;
  transform: skewX(-8deg);
  background: transparent;
}

.flag-yellow {
  background: var(--amber);
}

.flag-red {
  background: var(--red);
}

.jira-marker,
.owner-marker {
  min-width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 10px;
  font-weight: 900;
}

.minimap-wrap {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 292px;
  padding: 10px;
  background: var(--toolbar-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(31, 41, 55, 0.1);
}

.minimap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.minimap-header strong {
  display: block;
  color: var(--heading);
  font-size: 12px;
  line-height: 1.2;
}

.minimap-header span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.mini-map {
  position: relative;
  height: 86px;
  overflow: hidden;
  border-radius: 5px;
  background: var(--mini-bg);
}

.mini-phase {
  position: absolute;
  height: 54px;
  top: 16px;
  border-radius: 4px;
  background: #d9e0ea;
}

.mini-viewport {
  position: absolute;
  border: 2px solid #1d4ed8;
  background: rgba(29, 78, 216, 0.08);
  border-radius: 5px;
  pointer-events: none;
}

.minimap-zoom {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
}

.minimap-zoom input[type="range"] {
  width: 100%;
  min-width: 0;
}

.risk-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.risk-group-title {
  margin-top: 10px;
  color: var(--heading);
  font-size: 12px;
  font-weight: 850;
}

.risk-item {
  width: 100%;
  min-height: 50px;
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 9px;
  padding: 9px;
  background: var(--step-bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  text-align: left;
}

.risk-item:hover {
  background: var(--surface-3);
  border-color: #aab7c8;
}

.risk-color {
  width: 10px;
  height: 10px;
  margin-top: 3px;
  border-radius: 50%;
  background: var(--gray);
}

.risk-title {
  display: block;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
}

.risk-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.empty-state {
  margin-top: 10px;
  padding: 16px;
  color: var(--muted);
  background: var(--surface-3);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  font-size: 13px;
}

.detail-form {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}

.detail-group {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.step-modal-panel {
  width: min(760px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.step-modal-intro {
  padding: 12px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.step-modal-intro h3 {
  margin: 0 0 7px;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.step-modal-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field-grid label:nth-child(5) {
  grid-column: 1 / -1;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--modal-backdrop);
}

.modal-panel {
  width: min(520px, 100%);
  display: grid;
  gap: 18px;
  padding: 18px;
  background: var(--modal-bg);
  border-radius: 9px;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.template-options {
  display: grid;
  gap: 10px;
}

.template-option {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--step-bg);
}

.template-option strong,
.template-option small {
  display: block;
}

.template-option small {
  margin-top: 3px;
  color: var(--muted);
}

.active-template {
  border-color: #93b4ff;
  background: var(--button-hover);
}

.disabled-template {
  opacity: 0.56;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-actions .secondary-button,
.modal-actions .primary-button {
  width: auto;
  min-width: 108px;
}

.hidden {
  display: none !important;
}

.canvas-content.zoom-executive .step-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.canvas-content.zoom-executive .step-node {
  min-height: 24px;
  grid-template-columns: 1fr;
  padding: 0;
}

.canvas-content.zoom-executive .team-bar,
.canvas-content.zoom-executive .step-subtitle,
.canvas-content.zoom-executive .step-icons {
  display: none;
}

.canvas-content.zoom-executive .step-main {
  min-height: 24px;
  padding: 0;
  background: var(--team);
  border-radius: 5px;
}

.canvas-content.zoom-executive .step-title {
  font-size: 0;
}

.canvas-content.zoom-operational .step-title {
  -webkit-line-clamp: 1;
}

@media (max-width: 1320px) {
  body {
    min-width: 1040px;
  }

  .app-shell {
    --left-panel-width: 230px;
    --right-panel-width: 330px;
  }

  .workspace {
    grid-template-columns:
      var(--left-panel-width)
      var(--toggle-rail-width)
      minmax(560px, 1fr)
      var(--toggle-rail-width)
      var(--right-panel-width);
  }

  .summary-strip {
    grid-template-columns: repeat(4, minmax(100px, 1fr));
  }
}
