:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef3f8;
  --ink: #07142f;
  --muted: #61708a;
  --line: #d8e0ea;
  --line-strong: #c5d0de;
  --accent: #f05a28;
  --accent-2: #24347e;
  --accent-soft: #fff0eb;
  --danger: #c9342b;
  --danger-soft: #fff0ef;
  --success: #157347;
  --warning: #996600;
  --shadow: 0 16px 40px rgba(12, 27, 54, 0.1);
  --shadow-soft: 0 8px 22px rgba(12, 27, 54, 0.07);
  --radius: 8px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111827;
  --surface: #172033;
  --surface-2: #1f2b42;
  --surface-3: #263450;
  --ink: #f8fafc;
  --muted: #a8b5c7;
  --line: #31405b;
  --line-strong: #465773;
  --accent-soft: rgba(240, 90, 40, 0.17);
  --danger-soft: rgba(201, 52, 43, 0.16);
  --shadow: 0 16px 42px rgba(0, 0, 0, 0.34);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  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;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.hidden {
  display: none !important;
}

.lock-screen {
  align-items: center;
  background:
    linear-gradient(135deg, rgba(36, 52, 126, 0.92), rgba(7, 20, 47, 0.98)),
    var(--bg);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-shell {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.28);
  display: grid;
  gap: 26px;
  max-width: 520px;
  padding: 34px;
  width: 100%;
}

.login-brand,
.sidebar-brand {
  align-items: center;
  display: flex;
  gap: 12px;
}

.login-brand img {
  height: 54px;
  max-width: 210px;
  object-fit: contain;
}

.login-brand span,
.sidebar-brand span,
.eyebrow,
.product-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-copy h1 {
  font-size: clamp(32px, 5vw, 48px);
  line-height: 1.05;
  margin: 8px 0 12px;
}

.login-copy p:last-child {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
  margin: 0;
}

.product-label,
.eyebrow {
  margin: 0;
}

.passcode-form label,
.dialog-form label,
.mapping-tools label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 800;
  gap: 8px;
}

.passcode-row {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
}

input,
textarea,
select {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  min-height: 42px;
  outline: none;
  padding: 10px 12px;
  width: 100%;
}

input:focus,
textarea:focus,
select:focus,
button:focus-visible {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(36, 52, 126, 0.12);
}

textarea {
  resize: vertical;
}

.form-error {
  color: var(--danger);
  display: block;
  font-size: 13px;
  min-height: 18px;
  padding-top: 8px;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button,
.passcode-row button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  display: inline-flex;
  font-weight: 800;
  gap: 8px;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.primary-button,
.passcode-row button {
  background: var(--accent);
  color: #ffffff;
}

.secondary-button {
  background: var(--accent-2);
  color: #ffffff;
}

.ghost-button,
.icon-button {
  background: var(--surface-3);
  border-color: var(--line);
  color: var(--ink);
}

.danger-button {
  background: var(--danger-soft);
  border-color: rgba(201, 52, 43, 0.25);
  color: var(--danger);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.icon-button {
  aspect-ratio: 1;
  padding: 0;
  width: 40px;
}

.full-width {
  width: 100%;
}

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

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100vh;
  padding: 22px;
  position: sticky;
  top: 0;
}

.sidebar-brand img {
  height: 48px;
  max-width: 128px;
  object-fit: contain;
}

.sidebar-brand strong {
  display: block;
  font-size: 24px;
  line-height: 1.1;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--muted);
  display: flex;
  gap: 10px;
  min-height: 46px;
  padding: 0 12px;
  text-align: left;
}

.nav-tab.active,
.nav-tab:hover {
  background: var(--accent-soft);
  border-color: rgba(240, 90, 40, 0.28);
  color: var(--ink);
}

.nav-icon {
  align-items: center;
  display: inline-flex;
  font-size: 17px;
  height: 24px;
  justify-content: center;
  width: 24px;
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.save-pill {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
}

.save-pill.saving {
  color: var(--warning);
}

.save-pill.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.main-content {
  min-width: 0;
  padding: 28px 30px;
}

.topbar,
.section-toolbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 0 auto 22px;
  max-width: 1440px;
}

.topbar h2,
.section-toolbar h3,
.detail-header h2 {
  margin: 0;
}

.topbar h2 {
  font-size: 30px;
}

.section-toolbar h3 {
  font-size: 20px;
}

.section-toolbar p,
.detail-header p {
  color: var(--muted);
  line-height: 1.5;
  margin: 4px 0 0;
}

.toolbar-actions,
.header-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.search-input {
  min-width: 240px;
}

.view {
  display: none;
  margin: 0 auto;
  max-width: 1440px;
}

.active-view {
  display: block;
}

.projects-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.project-card,
.category-column,
.status-column,
.mapping-tools,
.empty-state {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.project-card {
  display: grid;
  gap: 14px;
  min-height: 176px;
  padding: 16px;
  text-align: left;
}

.project-card:hover {
  border-color: rgba(240, 90, 40, 0.5);
}

.project-card-header,
.project-footer,
.category-header,
.status-header,
.task-card-header,
.node-card-header,
.panel-heading,
.connection-row {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.project-card h3 {
  font-size: 22px;
  margin: 0;
}

.project-card p,
.project-meta,
.task-card p,
.status-project p,
.connection-row span,
.selection-panel p {
  color: var(--muted);
  line-height: 1.45;
  margin: 0;
}

.badge {
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  min-height: 26px;
  padding: 4px 9px;
}

.empty-state {
  padding: 36px;
  text-align: center;
}

.empty-state h3 {
  margin: 0 0 8px;
}

.empty-state p {
  color: var(--muted);
  margin: 0 0 18px;
}

.detail-header {
  align-items: center;
  display: grid;
  gap: 16px;
  grid-template-columns: auto 1fr auto;
  margin-bottom: 18px;
}

.task-board {
  align-items: start;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.category-column,
.status-column {
  min-height: 260px;
  padding: 14px;
}

.category-header h3,
.status-header h3 {
  font-size: 17px;
  margin: 0;
}

.task-list,
.status-list,
.connections-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.task-list.drag-over,
.status-column.drag-over {
  outline: 2px dashed rgba(240, 90, 40, 0.55);
  outline-offset: 4px;
}

.task-card,
.status-project {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.task-card {
  cursor: grab;
}

.task-card.done {
  border-color: rgba(21, 115, 71, 0.32);
}

.task-card.done h4 {
  text-decoration: line-through;
}

.task-card h4,
.status-project h4 {
  margin: 0;
}

.priority {
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  padding: 3px 8px;
}

.priority.Normal {
  background: var(--surface);
  color: var(--muted);
}

.priority.High {
  background: #fff6d7;
  color: #8a5b00;
}

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

.compact-actions {
  display: flex;
  gap: 6px;
}

.compact-actions button,
.mini-button {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-weight: 800;
  min-height: 30px;
  min-width: 30px;
  padding: 0 8px;
}

.compact-actions button:hover,
.mini-button:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.mapping-layout {
  display: grid;
  gap: 14px;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: calc(100vh - 172px);
}

.mapping-tools {
  align-self: start;
  display: grid;
  gap: 14px;
  padding: 16px;
}

.tool-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.selection-panel,
.connections-panel {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 8px;
  padding: 12px;
}

.selection-panel span,
.panel-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.canvas-wrap {
  background:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px),
    var(--surface);
  background-size: 32px 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 680px;
  overflow: auto;
  position: relative;
}

.node-canvas {
  min-height: 1400px;
  min-width: 1800px;
  position: relative;
}

.connection-layer {
  height: 1400px;
  left: 0;
  pointer-events: none;
  position: absolute;
  top: 0;
  width: 1800px;
  z-index: 1;
}

.node {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 138px;
  position: absolute;
  touch-action: none;
  width: 260px;
  z-index: 2;
}

.node.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(240, 90, 40, 0.14), var(--shadow);
}

.node-card-header {
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: grab;
  min-height: 38px;
  padding: 8px 10px;
}

.node-card-header strong {
  font-size: 13px;
}

.node-body {
  display: grid;
  gap: 10px;
  padding: 10px;
}

.node textarea {
  border-color: transparent;
  min-height: 66px;
  padding: 0;
}

.node textarea:focus {
  border-color: var(--line);
  padding: 8px;
}

.node-controls {
  display: flex;
  gap: 6px;
  justify-content: space-between;
}

.connection-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
}

.status-board {
  align-items: start;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(5, minmax(230px, 1fr));
  overflow-x: auto;
  padding-bottom: 12px;
}

.status-column {
  min-width: 230px;
}

.status-project {
  cursor: grab;
}

.status-project select {
  margin-top: 10px;
}

dialog {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--ink);
  max-width: 480px;
  width: calc(100% - 32px);
}

dialog::backdrop {
  background: rgba(7, 20, 47, 0.58);
}

.dialog-form {
  display: grid;
  gap: 14px;
  padding: 8px;
}

.dialog-form h3,
.dialog-form p {
  margin: 0;
}

.dialog-form p {
  color: var(--muted);
  line-height: 1.5;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.mobile-only {
  display: none;
}

@media (max-width: 960px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    bottom: 0;
    box-shadow: var(--shadow);
    height: auto;
    max-width: 320px;
    position: fixed;
    top: 0;
    transform: translateX(-104%);
    transition: transform 180ms ease;
    width: 86vw;
    z-index: 10;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-only {
    display: inline-flex;
  }

  .main-content {
    padding: 18px;
  }

  .detail-header,
  .mapping-layout,
  .section-toolbar {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .section-toolbar,
  .detail-header {
    display: grid;
  }

  .toolbar-actions,
  .header-actions {
    justify-content: flex-start;
  }

  .search-input {
    min-width: 0;
  }

  .canvas-wrap {
    min-height: 560px;
  }

  .passcode-row {
    grid-template-columns: 1fr;
  }
}
