:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-strong: #eef3f1;
  --ink: #17211f;
  --muted: #61706d;
  --line: #dbe4e1;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-soft: #d9f3ef;
  --warn: #c2410c;
  --warn-soft: #ffedd5;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --ok: #2f855a;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --shadow: 0 20px 60px rgba(23, 33, 31, 0.09);
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 20px 16px;
  background: #101817;
  color: #f6fbfa;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  margin-bottom: 26px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #4ade80;
  color: #0c1312;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 3px;
  color: #a9bbb7;
  font-size: 12px;
}

.version-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 22px;
  margin-top: 8px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #dff7ef;
  font-size: 11px;
  font-weight: 900;
}

.nav-group,
.project-list,
.todo-list,
.doc-tree {
  display: grid;
  gap: 8px;
}

.nav-item,
.project-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #dbe7e4;
  text-align: left;
}

.nav-item:hover,
.project-button:hover,
.nav-item.active,
.project-button.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.sidebar-section {
  margin-top: 28px;
}

.section-label,
.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar .section-label {
  color: #8ba09b;
}

.project-button {
  align-items: flex-start;
  flex-direction: column;
  gap: 3px;
}

.project-button strong {
  font-size: 14px;
}

.project-button span {
  color: #9fb2ad;
  font-size: 12px;
}

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

.topbar,
.panel-heading,
.metrics-strip,
.topbar-actions,
.segmented,
.lower-grid,
.docs-layout,
.workspace-grid {
  display: flex;
}

.topbar {
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.topbar h1,
.panel-heading h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.06;
}

.topbar-actions {
  align-items: center;
  gap: 10px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 300px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.search input,
.todo-form input,
.doc-title-input,
.doc-body-input,
select {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.primary-button,
.secondary-button,
.todo-form button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 800;
}

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

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

.secondary-button,
.todo-form button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

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

.metrics-strip div,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metrics-strip div {
  padding: 16px;
}

.metrics-strip span,
.task-meta,
.subtask-meta,
.test-meta,
.doc-meta {
  color: var(--muted);
  font-size: 12px;
}

.metrics-strip strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.panel {
  min-width: 0;
  padding: 16px;
}

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

.panel-heading.compact {
  margin-bottom: 12px;
}

.panel-heading h2 {
  font-size: 18px;
}

.segmented {
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.segmented button {
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.segmented button.active {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(23, 33, 31, 0.08);
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.kanban-column {
  min-width: 190px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
}

.column-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 30px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.task-card {
  display: grid;
  gap: 10px;
  width: 100%;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  text-align: left;
}

.drag-handle {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
  color: var(--muted);
  cursor: grab;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  user-select: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.dragging {
  opacity: 0.55;
}

.drag-over {
  border-color: var(--accent);
  background: #ecfdf8;
  box-shadow: inset 0 0 0 2px rgba(15, 118, 110, 0.14);
}

.task-open,
.doc-open {
  display: grid;
  gap: 10px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.task-card:hover,
.task-card.active {
  border-color: var(--accent);
  box-shadow: 0 12px 32px rgba(15, 118, 110, 0.12);
}

.task-card strong {
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.task-footer,
.tag-row,
.subtask-row,
.test-row,
.doc-node,
.flow-step {
  display: flex;
  align-items: center;
}

.task-footer {
  justify-content: space-between;
  gap: 8px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--blue-soft);
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 900;
}

.tag-row {
  flex-wrap: wrap;
  gap: 6px;
}

.capsule-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 2px;
}

.capsule-actions button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
}

.capsule-actions button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.capsule-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.tag,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.risk {
  background: var(--warn-soft);
  color: var(--warn);
}

.blocked {
  background: var(--danger-soft);
  color: var(--danger);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--muted);
  font-size: 20px;
}

.inspector-body {
  display: grid;
  gap: 14px;
}

.inspector-title {
  margin: 0;
  font-size: 22px;
  line-height: 1.18;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8efed;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.subtask-list {
  display: grid;
  gap: 8px;
}

.subtask-row {
  gap: 8px;
  min-height: 36px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.subtask-row[data-depth="1"] {
  margin-left: 16px;
}

.subtask-row[data-depth="2"] {
  margin-left: 32px;
}

.subtask-row input {
  width: 16px;
  height: 16px;
}

.capsule-manager {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
}

.capsule-manager label {
  display: grid;
  gap: 6px;
}

.lower-grid,
.docs-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
  gap: 18px;
  margin-top: 18px;
}

select {
  width: auto;
  min-height: 38px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.flow-diagram {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
  align-items: stretch;
}

.flow-step {
  position: relative;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-height: 110px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f4faf8 100%);
}

.flow-step:not(:last-child)::after {
  content: "→";
  position: absolute;
  top: 50%;
  right: -15px;
  transform: translateY(-50%);
  color: var(--accent);
  font-weight: 900;
  z-index: 1;
}

.flow-step strong {
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.flow-step span:first-child {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.flow-step span:last-child {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.todo-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 12px;
}

.todo-form input {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.todo-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.todo-item label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.todo-item label span {
  overflow-wrap: anywhere;
}

.todo-item.done label span {
  color: var(--muted);
  text-decoration: line-through;
}

.doc-node {
  display: grid;
  gap: 8px;
  width: 100%;
  min-height: 54px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
}

.doc-node .drag-handle {
  justify-self: start;
}

.doc-open {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.doc-node.active {
  border-color: var(--accent);
  background: #f2fbf9;
}

.doc-node strong,
.doc-node span {
  display: block;
}

.doc-title-input {
  min-height: 48px;
  margin-bottom: 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  font-size: 20px;
  font-weight: 900;
}

.doc-meta-input {
  min-height: 42px;
  margin-bottom: 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

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

.doc-link-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.doc-link-grid label {
  display: grid;
  gap: 6px;
}

.doc-link-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.doc-link-summary div {
  min-height: 54px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
}

.doc-link-summary strong,
.doc-link-summary span {
  display: block;
}

.doc-link-summary span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.doc-body-input {
  min-height: 460px;
  resize: vertical;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  line-height: 1.55;
}

.doc-preview {
  margin-top: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  line-height: 1.55;
}

.doc-preview h3,
.doc-preview h2,
.doc-preview h4,
.doc-preview p,
.doc-preview ul {
  margin-top: 0;
}

.doc-preview h2 {
  margin-bottom: 12px;
  font-size: 24px;
}

.doc-preview h3 {
  margin-bottom: 10px;
  font-size: 20px;
}

.doc-preview h4 {
  margin-bottom: 8px;
  font-size: 16px;
}

.doc-preview ul {
  padding-left: 20px;
}

.test-matrix {
  display: grid;
  gap: 8px;
}

.test-row {
  display: grid;
  grid-template-columns: auto minmax(180px, 1.4fr) minmax(110px, 0.8fr) minmax(120px, 0.8fr) auto auto;
  gap: 10px;
  align-items: center;
  min-height: 54px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.status-select {
  width: 100%;
}

.empty-state {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1120px) {
  .workspace-grid,
  .lower-grid,
  .docs-layout {
    grid-template-columns: 1fr;
  }

  .inspector {
    position: static;
  }

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

  .flow-step:not(:last-child)::after {
    display: none;
  }
}

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

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

  .main {
    padding: 14px;
  }

  .topbar,
  .topbar-actions,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .search {
    min-width: 0;
  }

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

  .kanban-board {
    grid-template-columns: repeat(4, 78vw);
  }

  .flow-diagram,
  .test-row,
  .doc-link-grid,
  .doc-link-summary {
    grid-template-columns: 1fr;
  }

  .todo-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .todo-item .capsule-actions {
    grid-column: 1 / -1;
  }

  .capsule-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 440px) {
  .metrics-strip {
    grid-template-columns: 1fr;
  }

  .segmented {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .segmented button {
    padding: 0 6px;
  }
}
