:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Noto Sans TC", sans-serif;
  background: #eef1f5;
  color: #171b22;
  --panel: #ffffff;
  --panel-soft: #f7f8fb;
  --ink: #171b22;
  --muted: #667085;
  --line: #d9dee8;
  --green: #0f9f6e;
  --red: #d92d20;
  --amber: #b7791f;
  --blue: #2563eb;
  --violet: #6d28d9;
  --shadow: 0 14px 42px rgba(16, 24, 40, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #eef1f5;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 0 18px;
}

.brand-block,
.header-actions,
.section-title,
.tabs {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #171b22;
  color: #ffffff;
  font-weight: 800;
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 4px;
  color: #516071;
  font-size: 12px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  font-size: 17px;
  letter-spacing: 0;
}

h3 {
  font-size: 15px;
  letter-spacing: 0;
}

.header-actions {
  gap: 8px;
}

.icon-button,
.tab,
.settings button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  font-size: 20px;
  line-height: 1;
}

.ops-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.ops-card,
.surface,
.command-band {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.ops-card {
  position: relative;
  min-height: 104px;
  border-radius: 12px;
  padding: 14px;
  overflow: hidden;
}

.ops-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: #94a3b8;
}

.ops-card span,
.ops-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.ops-card strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0;
}

.accent-green::before,
.ready::before {
  background: var(--green);
}

.accent-red::before,
.blocked::before {
  background: var(--red);
}

.accent-amber::before {
  background: var(--amber);
}

.accent-blue::before {
  background: var(--blue);
}

.command-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 12px 0;
  border-radius: 14px;
  padding: 16px;
}

.connection-pill {
  flex: 0 0 auto;
  border: 1px solid #badbcc;
  border-radius: 999px;
  background: #ecfdf3;
  color: #067647;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.tab {
  min-height: 42px;
  border-radius: 10px;
  color: #475467;
  font-weight: 700;
}

.tab.active {
  background: #171b22;
  color: #ffffff;
  border-color: #171b22;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.8fr);
  gap: 12px;
}

.surface {
  border-radius: 14px;
  padding: 16px;
}

.section-title {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title span {
  color: var(--muted);
  font-size: 12px;
}

select,
.search-box input,
.settings input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 12px;
}

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

.work-list.compact {
  max-height: 520px;
  overflow: auto;
}

.work-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  padding: 12px;
}

.work-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.work-item p,
.route-item span,
.settings p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.status-dot {
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 50%;
  background: #94a3b8;
  flex: 0 0 auto;
}

.status-active {
  background: var(--green);
}

.status-blocked {
  background: var(--red);
}

.status-needs_review {
  background: var(--amber);
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.badge {
  border: 1px solid #d4dae5;
  border-radius: 999px;
  background: #ffffff;
  color: #475467;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
}

.badge-p0 {
  border-color: #fecdca;
  background: #fff1f3;
  color: #b42318;
}

.badge-p1 {
  border-color: #fedf89;
  background: #fffaeb;
  color: #93370d;
}

.route-list,
.pipeline-board {
  display: grid;
  gap: 10px;
}

.route-item,
.lane {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  padding: 12px 12px 12px 16px;
  overflow: hidden;
}

.route-item::before,
.lane::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: #94a3b8;
}

.pipeline-board {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.lane h3 {
  margin-bottom: 8px;
}

.lane-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.mini-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.mini-list button {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  padding: 8px;
  text-align: left;
  color: var(--ink);
}

.graph-surface {
  padding-bottom: 14px;
}

.graph-wrap {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #111827;
  overflow: hidden;
}

.graph {
  display: block;
  width: 100%;
  height: min(58vh, 620px);
  min-height: 430px;
  touch-action: manipulation;
}

.edge {
  stroke: rgba(203, 213, 225, 0.36);
  stroke-width: 1.3;
}

.node {
  cursor: pointer;
}

.node circle {
  stroke-width: 2;
}

.node text {
  fill: #f8fafc;
  font-size: 12px;
  text-anchor: middle;
  paint-order: stroke;
  stroke: rgba(17, 24, 39, 0.9);
  stroke-width: 4px;
}

.detail {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  padding: 12px;
  color: #475467;
  line-height: 1.55;
}

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

.search-box {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.search-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.settings {
  width: min(520px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  color: var(--ink);
  padding: 0;
  box-shadow: 0 24px 72px rgba(16, 24, 40, 0.24);
}

.settings::backdrop {
  background: rgba(17, 24, 39, 0.42);
}

.settings form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-head button {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

.settings label {
  display: grid;
  gap: 6px;
  color: #475467;
  font-size: 12px;
  font-weight: 700;
}

.settings menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.settings menu button {
  min-height: 40px;
  border-radius: 10px;
  padding: 0 14px;
}

#saveSettings {
  background: #171b22;
  color: #ffffff;
  border-color: #171b22;
}

@media (max-width: 820px) {
  .app-shell {
    padding: 12px;
  }

  h1 {
    font-size: 23px;
  }

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

  .command-band,
  .split-layout {
    grid-template-columns: 1fr;
  }

  .command-band {
    display: grid;
  }

  .connection-pill {
    width: fit-content;
  }

  .pipeline-board {
    grid-template-columns: 1fr;
  }

  .graph {
    min-height: 390px;
  }
}

@media (max-width: 460px) {
  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }

  .ops-card {
    min-height: 92px;
  }

  .ops-card strong {
    font-size: 28px;
  }

  .tab {
    min-height: 38px;
    font-size: 13px;
  }
}
